Watermarking over a non-static 3D image? (using javascript?)
Hi,
I am trying to resolve the issue I have of not being able to create a watermark to sit permanetly over the top of a non-static 3D image.
I am aware that I cannot use the normal watermarking method so I have been looking at Javascript methods...
Im not familair with Javascrpit at all but so far I have a simple script inserted in my console window but am not sure what to do next to get this to activate and work.
p.s the watermark to be used is a simple jpg. file.
The javascipt currently in the console window is.......
this.addWatermarkFromFile()
cText:"C:\Documents and Settings\Acomlay\My Documents\EEC watermarking and logo\COPYRIGHT"
nOpacity: 0.5
Any help appreciated
Ali.
Hi,
What I mean is... its a 3D CAD model which I have converted in acrobat 9 Pro from Pro Engineer (straight foward 3d pdf). The problem is when I add a watermark using the built in tools....the watermark is displayed correctly but the 3D veiwing of the model is lost and it effectively becomes a flat 2d image.
My predecessor in this job has told me that originally he had some form of script in place so he could batch the watermarking action to various files, which Is what I need to be able to do.
Also he said that it was important to set the background to transparent in the 'properties' menu. That is all he can remember.
Similar Messages
-
Non-static variable being used in static context
I am currently attempting to write a basic user login system using basic applets. I have two JTextFields named "userText" and "passText".
What i am attempting to do is use the ".getText()" method to get the text out of the JTextField and verifying the string against a string already in a file using the bufferedReader, etc.
However when i try to compare the string in the file with the one in the text field using the following code:
if ((line.compareTo(username)) == 0)
i get the following error...
"non-static variable being used in a static context"
Any ideas?The static method doesn't know about instances of the class instead you pass the instance to the method:
static public void myMethod(MyClass instance, String var) {
if(instance.line.compareTo(var))
And then the call would be:
MyClass.myMethod(anInstance, userName); -
Writing specialized metadata to image using Javascript...
I'm working on a project where we are dumping metadata from a database into a text file and then writing it to images using javascript. As long as I use the fields listed in the Javascript reference manual, it works perfectly.
However, the client has asked me to write specialized metadata. I created a panel for them to add in the extra fields. Is there a way to get Javascript to write the extra fields? (Is there a way to extend the DocumentInfo class in Javascript? Me thinks not...but I thought I'd ask.)
Thanks,
LauraI very interested in this as well... Found an answer yet? Seem silly to me that do don't have access to all of your tags...
-
Replacing images using Javascript
There are several posts explaining how to replace an image using Javascript (simpler with JQuery), but when I tried the code, the image kept reverting to the original image specified. This occurred regardless of browser, but does not revert in DW's "Live View". It turns out the culprit is that I was using an anchor <a> with a href attribute. The browser apparently evaluates the href after processing the OnClick() event. Switching to a button versus an anchor solved the problem. DW needs a little tuning.
It turns out the culprit is that I was using an anchor <a> with a href attribute. The browser apparently evaluates the href after processing the OnClick() event. Switching to a button versus an anchor solved the problem.
If you show us your code that wasn't working we'll be happy to recommend
Don't need to see code. The explanation was clear enough to determine the cause of issue. <a href="somefile.ext" onclick="somefunction();">click</a> is going to somefile.ext immediately after triggering the onclick event on the page. Lookup return false; for the solution of using onclick event in an anchor tag. -
Using javascript to set non database values
I finally figured out how to set the values of a non database form field using Javascript. The only problem is, I want this
field to be a display only field, and the value does not get set if I make the field non updateable on the form. Can
somebody please help me!! This is urgent.Stan,
One way to do this is to call the doSubmit() function and create a page branch to handle your request. This way you can use apex validations and other goodies if your requirements change. Also this will save the state of your items on the page you are leaving.
Edit
I forgot to mention that you can pass a string parameter to the doSubmit function. The parameter will be the request sent to apex. For instance you could use doSubmit('DO_SOMETHING') and you can have a page branch which will fire if the request is equal to DO_SOMETHING.
Cheers,
Tyson Jouglet
Edited by: Tyson Jouglet on Dec 1, 2009 10:11 AM -
Can I dynamically display Page title over a static header image?
Is there a way to Dynamically Display Page Title Text Over my static site Header Image? here is a link so you can see what I am talking about. http://www.bridgestoprosperity.org/See-Our-Work/afghanistan/afghanistan.htm where Afghanistan would be the text to be replaced automatically on each page. Please note, currently, I must create individual headers, insert the page title in photoshop, etc. I am hoping to figure out a way for all this to happen dynamically perhaps by calling the text from the page title info.
Thank you,
AllanHi, Allan,
I realize my suggestion is off your point, and you probably have already thought of some of this, hence your question... But, rather than going the dynamic route, Why not create a Header Image without a title on it and use it as a div background image? Replace this
<img src="/See-Our-Work/afghanistan/Images/header/afghanistan-header.jpg" name="topnavbar_r1_c1" width="779" height="114" border="0" alt="bridges to prosperity: afghanistan">
with the styled div, for instance:
<div id="header"><h2>Afghanistan</h2><h3>Bridges to Prosperity: USA</h3><div>
At this point, you can use a more generic image for the background, one that does not have "Afghanistan" embedded in it, and you may style the #header thus:
#header {
width: 779px;
height: 114px;
border: 0;
background-image: url(/See-Our-Work/Images/header/header.jpg;)/* for instance */
and the header Headline styles thus:
#header h2, #header h3 {
color: white;
text-align: right;
font-family: Arial, Helvetica, sans-serif;
Then you can place your html (<h2>, <h3> etc.) in the same div, only on the "surface".
Using the tags <h2> and <h3> will maintain their usefulness to Search Engines; as hiding them in images does not.
If you still wished to vary the header image, depending on the contents of the page, you can actually control all of this from the CSS file, if you add an id attribute to the <body> of each page.
For instance, for your example page, if you did this:
<body id="afghanistan">
You could then do this in your CSS file:
#header {
width: 779px;
height: 114px;
border: 0;
body#afghanistan #header {
background-image: url(/See-Our-Work/afghanistan/Images/header/afghanistan-header.jpg);
You could then proceed to have a different background image for each page. (Not your original intention, but now possible).
<body id="pakistan"> would use a CSS style declaration like:
body#pakistan #header {
background-image: url(...pakistan-header.jpg...etc.);
I am not aware of being able to pass content (other than background images) using CSS, so I would go into each page and put the Headline in html.
But if you were using multiple background images in the header div (one image for afghanistan, another for pakistan, in my example), you can use the same <body id="afghanistan"> for ALL pages about Afghanistan, and thus have the continuity of the same image for all. Likewise, you could id all pages about Pakistan <body id="pakistan">.
I hope this gives you some ideas...
Z -
Using a non-static vector in a generic class with static methods
I have a little problem with a class (the code is shown underneath). The problem is the Assign method. This method should return a clone (an exact copy) of the set given as an argument. When making a new instance of a GenericSet (with the Initialize method) within the Assign method, the variables of the original set and the clone have both a reference to the same vector, while there exists two instances of GenericSet. My question is how to refer the clone GenericSet's argument to a new vector instead of the existing vector of the original GenericSet. I hope you can help me. Thanks
package genericset;
import java.util.*;
public class GenericSet<E>{
private Vector v;
public GenericSet(Vector vec) {
v = vec;
private <T extends Comparable> Item<T> get(int index) {
return (Item<T>) v.get(index);
public static <T extends Comparable> GenericSet<T> initialize() {
return new GenericSet<T>(new Vector());
public Vector getVector() {
return v;
public static <T extends Comparable> GenericSet<T> insert (GenericSet<T> z, Item<T> i){
GenericSet<T> g = assign(z);
Vector v = g.getVector();
if (!member(g,i))
v.addElement(i);
return g;
public static <T extends Comparable> GenericSet<T> delete(GenericSet<T> z, Item<T> i){
GenericSet<T> g = assign(z);
Vector v = g.getVector();
if (member(g,i))
v.remove(i);
return g;
public static <T extends Comparable> boolean member(GenericSet<T> z, Item<T> i) {
Vector v = z.getVector();
return v.contains(i);
public static <T extends Comparable> boolean equal(GenericSet<T> z1, GenericSet<T> z2) {
Vector v1 = z1.getVector();
Vector v2 = z2.getVector();
if((v1 == null) && (v2 != null))
return false;
return v1.equals(v2);
public static <T extends Comparable> boolean empty(GenericSet<T> z) {
return (cardinality(z) == 0);
public static <T extends Comparable> GenericSet<T> union(GenericSet<T> z1, GenericSet<T> z2) {
GenericSet<T> g = assign(z1);
for(int i=0; i<cardinality(z2); i++) {
Item<T> elem = z2.get(i);
insert(g, elem);
return g;
public static <T extends Comparable> GenericSet<T> intersection(GenericSet<T> z1, GenericSet<T> z2) {
GenericSet<T> g = initialize();
for(int i=0; i<cardinality(z2); i++) {
Item<T> elem = z2.get(i);
if(member(z1, elem))
insert(g, elem);
return g;
public static <T extends Comparable> GenericSet<T> difference(GenericSet<T> z1, GenericSet<T> z2) {
GenericSet<T> g = initialize();
for(int i=0; i<cardinality(z1); i++) {
Item<T> elem = z1.get(i);
if(!member(z2, elem))
insert(g, elem);
for(int i=0; i<cardinality(z2); i++) {
Item<T> elem = z2.get(i);
if(!member(z1, elem))
insert(g, elem);
return g;
public static <T extends Comparable> GenericSet<T> assign(GenericSet<T> z) {
GenericSet<T> g = initialize();
for(int i=0; i<cardinality(z); i++) {
Item<T> elem = z.get(i);
insert(g, elem);
return g;
public static <T extends Comparable> boolean subset(GenericSet<T> z1, GenericSet<T> z2) {
for(int i=0; i<cardinality(z1); i++) {
Item<T> elem = z1.get(i);
if(!member(z2, elem))
return false;
return true;
public static <T extends Comparable> int cardinality(GenericSet<T> z){
Vector v = z.getVector();
return v.size();
}The issue is not "reference a non-static interface", but simply that you cannot reference a non-static field in a static method - what value of the field ed would the static method use? Seems to me your findEditorData should look something like this: public static EditorBean findEditorData( String username, EditorBean editorData )
return editorData.ed.findEditor( username );
} -
How can I use non-static func in a static func?
Hello guys,
I have a func processFiles which is static, i wanna use a func from another class FileData in processFile func and i dnt wanna make processFile non-static, what should i do?
my code:
public class Library {
private FileData file = new FileData();
public static void main(String[] args){
try{
Library lib = new Library();
lib.processFiles(args);
catch(IOException e)
System.err.println("IOException occurred in main.");
System.exit(0);
@SuppressWarnings("unchecked")
public static void processFiles(String[] fileNames) throws IOException {
file.getMaterial();// I get error here;
class FileData{
getMaterila() {}
}1) it's not "func", it's "method".
2) Create a FileData instance and call the method on that
3) Read the basic tutorials about what "static" means, and put the error message into Google. -
Drawing Over Transparent Region of SplashScreen Image
Has anyone been successful trying to paint over a transparent region of an image using the Java 6 SplashScreen ?
I've got a PNG with a transparent background as my SplashScreen image, and I would like to paint over part of the transparent area. Whatever I try, I can't seem to accomplish it. I've played around with the Graphics2D setComposite and setClip, but I'm not having any luck. It paints over the non-transparent area, but not the transparent area. It's like there is a clip region for the image that I cannot seem to undo.
Anyone have any suggestions?To expand on the problem, I tried doing the same thing just in a panel, like so:
public class SplashTest {
public static final File IMAGE_FILE = new File("SplashTest.png");
public static void main(String[] args) {
SplashScreen splashScreen = SplashScreen.getSplashScreen();
Graphics2D g2d = splashScreen.createGraphics();
g2d.setColor(Color.RED);
g2d.fillRect(0, 200, 300, 100); // draw red rectangle across bottom
g2d.dispose();
splashScreen.update();
try {
Thread.sleep(3000); // show splash for 3 seconds before exiting
} catch (Exception e) {
e.printStackTrace();
splashScreen.close();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
JFrame frame = new JFrame("Try it again");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final BufferedImage image = ImageIO.read(IMAGE_FILE);
Graphics2D g2d = image.createGraphics();
g2d.setColor(Color.RED);
g2d.fillRect(0, 200, 300, 100); // draw red rectangle across bottom
g2d.dispose();
JPanel panel = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, 0, 0, this);
frame.setContentPane(panel);
frame.setSize(300, 300);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
} catch (IOException ioe) {
ioe.printStackTrace();
}The rectangle shows up completely in the JPanel, which suggests the problem is somehow specific to the SplashScreen. For now I'm just going to edit the image so I'm not trying to paint over any transparent regions. But if anyone can shed any light on this, please do. :-)
Edited by: Skotty on Jul 26, 2010 10:17 PM -
Non-static method destroyApp(boolean) cannot be referenced from a static co
Hi guys, ive been writing, erasing and rewriting code, and finally my midlet runs well. It get complicated when i began to use the class Canvas, because the main process required values from the Canvas class. Im not sure if the program is well designed. Sugestions are apreciated.
Well, i used static public boolean hilo; to share that variable between classes, and its working, however there is just a final procedure I want to implement, and that is that terminate the midlet when the user press the erase button.
When I detect the button, i cant call the notifyDestroyed() method.
Here's the code
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class TS_Online extends MIDlet implements CommandListener {
public static Display display; // Objeto para que muestre en pantalla
private SSCanvas sscInicio; // Objeto canvas para mostrar imagenes
private Form frmServidor; // Objeto forma
private TextField ip1; // Direcci�n IP
private TextField ip2; // Direcci�n IP
private TextField ip3; // Direcci�n IP
private TextField ip4; // Direcci�n IP
private TextField puerto; // Puerto a conectarse
private Command cmdEntrada; // Objeto comando
private Command cmdSalida; // Objeto comando
private Command cmdVolver; // Objeto comando
// * Constructor *
public TS_Online() {
display = Display.getDisplay(this); // Obtiene la pantalla
sscInicio = new SSCanvas(); // Nueva forma
cmdEntrada = new Command("Entrada", Command.STOP, 2);
cmdSalida = new Command("Salida", Command.STOP, 2);
cmdVolver = new Command("Volver", Command.BACK, 1);
sscInicio.addCommand(cmdEntrada); // Coloca el comando Entrada
sscInicio.addCommand(cmdSalida); // Coloca el comando Salida
sscInicio.setCommandListener(this); // Define la forma que escucha comandos
ip1 = new TextField("Direcci�n IP:", "0", 3, TextField.NUMERIC); // Caja de texto
ip2 = new TextField(null, "0", 3, TextField.NUMERIC);
ip3 = new TextField(null, "0", 3, TextField.NUMERIC);
ip4 = new TextField(null, "0", 3, TextField.NUMERIC);
puerto = new TextField("Puerto:", "24300", 5, TextField.NUMERIC);
frmServidor = new Form("Configuraci�n"); // Titulo de la forma
frmServidor.append(ip1);
frmServidor.append(ip2);
frmServidor.append(ip3);
frmServidor.append(ip4);
frmServidor.append(puerto);
frmServidor.addCommand(cmdVolver); // Coloca el comando Salida
// * Metodos *
public void startApp() {
sscInicio.hilo = true; // Habilita el hilo
new Thread(sscInicio).start(); // Hilo en Canvas
display.setCurrent(sscInicio); // Define objeto a mostrar
sscInicio.setTitle("TicketShop S.A."); // Titulo de la forma
// Metodos comunes en todos los Midlet
public void pauseApp() {
System.out.println("*** Pausado ***");
sscInicio.hilo = false; // Detiene el hilo
public void destroyApp(boolean unconditional) {
sscInicio.hilo = false;
System.out.println("*** Terminado ***");
notifyDestroyed();
public void commandAction(Command c, Displayable s) {
if (c == cmdEntrada) {
if (sscInicio.img == sscInicio.ts) { // Configurar servidor
sscInicio.hilo = false;
sscInicio.ip = true;
System.out.println(sscInicio.hilo);
frmServidor.setCommandListener(this);
display.setCurrent(frmServidor);
} else {
sscInicio.valido(); // Tiquete valido
} else if (c == cmdSalida) {
sscInicio.invalido(); // Tiquete invalido
} else if (c == cmdVolver) { // Volver a la pantalla anterior
sscInicio.setCommandListener(this);
sscInicio.hilo = true; // Arranca el hilo
new Thread(sscInicio).start(); // Hilo en Canvas
display.setCurrent(sscInicio);
System.out.println(sscInicio.hilo);
// * Clase graficadora *
class SSCanvas extends Canvas implements Runnable {
private int sleepTime; // Tiempo de retrazo
static public boolean ip; // Configurar IP
static public boolean hilo; // Continuar hilo
static public Image ts = null; // Contenedor imagen
static public Image rojo = null; // Contenedor imagenpri
static public Image verde = null; // Contenedor imagen
static public Image img = null; // Contenedor imagen
static public String mensaje = null; // Cadena de salida
//private CommConnection cc = null; // Conector para puerto
private SocketConnection sc = null; // Conector para red
private SocketConnection cc = null; // Conector para red
public SSCanvas() {
// Cargamos las im�genes a usar
try {
ts = Image.createImage("/TicketShop.PNG"); // Procedimiento para cargar las imagenes
rojo = Image.createImage("/Rojo.PNG"); // Procedimiento para cargar las imagenes
verde = Image.createImage("/Verde.PNG"); // Procedimiento para cargar las imagenes
} catch (IOException e) {} // Error si no encuentra las imagenes
void iniciar() {
img = ts; // Imagen de bienvenida
mensaje = "Conectando al servidor"; // Mensaje de inicio
// Tiempo de espera para configurar servidor
for (sleepTime = 1;sleepTime <= 3; sleepTime++) {
try {
mensaje = mensaje + "."; // Mensaje de inicio
repaint(); // Redibuja la pantalla
serviceRepaints(); // Espera que termine
Thread.sleep(1000);
} catch (InterruptedException e) {
System.out.println(e.toString());
sleepTime = 50;
img = verde;
System.out.println("Iniciar");
void codigo() {
void valido() {
img = verde; // Imagen OK
mensaje = "Tiquete OK"; // Tiquete valido
AlertType.CONFIRMATION.playSound(TS_Online.display); // Sonido
void invalido() {
img = rojo; // Imagen OK
mensaje = "Tiquete Inv�lido"; // Tiquete valido
AlertType.ERROR.playSound(TS_Online.display); // Sonido
// thread que contiene el game loop
public void run() {
System.out.println("*** Hilo arrancado ***");
if (img == null)
iniciar();
while (hilo) {
System.out.println("Hilo");
// Actualizar pantalla
repaint(); // Redibuja la pantalla
serviceRepaints(); // Espera que termine
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
System.out.println(e.toString());
public void keyPressed(int keyCode) {
if (keyCode == -8) { // Si presiona borrar
hilo = false; // Salir de la aplicacion
System.out.println("*** Terminado ***");
TS_Online.destroyApp(true);
notifyDestroyed();
public void paint(Graphics g) {
// Borrar la pantalla
g.setColor(255,255,255);
g.fillRect (0, 0, getWidth(), getHeight());
// Coloca la imagen correspondiente
g.drawImage (img, getWidth()/2, 10, Graphics.HCENTER|Graphics.TOP);
// Poner texto
Font fuente = Font.getFont (Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_MEDIUM);
g.setFont(fuente);
g.setColor(0,0,0);
g.drawString(mensaje, getWidth()/2, getHeight() - 40,Graphics.TOP|Graphics.HCENTER);
}Im using the boolean hilo to stop the thread. I seems to work fine for me. By the way, im using 4 textFields to get the IP address, however they appear one over the other, id like to see them one next to the other, or a better way to validate an IP address.
Thanks for the help!!Well, the solution was really easy, i just needed to create a reference to the midlet inside the Canvas class public SSCanvas(MIDlet m), so i got this new code, however, it seems cool in the emulator but i still cant get two comands in a row in the phone.
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.rms.*;
public class TS_Online extends MIDlet implements CommandListener {
public static Display display; // Objeto para que muestre en pantalla
private SSCanvas sscInicio = null; // Objeto canvas para mostrar imagenes
private Form frmServidor; // Objeto forma
private StringItem subtitulo; // Subtitulo de la forma
private TextField[] ip; // Direcci�n IP
private TextField puerto; // Puerto a conectarse
private Command cmdEntrada; // Objeto comando
private Command cmdSalida; // Objeto comando
private Command cmdVolver; // Objeto comando
private String direccion; // Direcci�n del socket
private RecordStore rsDireccion = null; // Almacenamiento RMS
// * Constructor *
public TS_Online() {
display = Display.getDisplay(this); // Obtiene la pantalla
sscInicio = new SSCanvas(this); // Nueva forma con ref este midlet
cmdEntrada = new Command("Entrada", Command.STOP, 2);
cmdSalida = new Command("Salida", Command.STOP, 2);
cmdVolver = new Command("Volver", Command.BACK, 1);
sscInicio.addCommand(cmdEntrada); // Coloca el comando Entrada
sscInicio.addCommand(cmdSalida); // Coloca el comando Salida
sscInicio.setTitle("TicketShop S.A."); // Titulo del canvas
// Constructor forma Configurar Servidor
ip = new TextField[4]; //
ip[0] = new TextField(null, "190", 3, TextField.NUMERIC); // Caja de texto
ip[1] = new TextField(null, "65", 3, TextField.NUMERIC);
ip[2] = new TextField(null, "161", 3, TextField.NUMERIC);
ip[3] = new TextField(null, "158", 3, TextField.NUMERIC);
puerto = new TextField("Puerto:", "24300", 5, TextField.NUMERIC);
ip[0].setLayout(Item.LAYOUT_2); // Coloca los elementos pegados
ip[1].setLayout(Item.LAYOUT_2);
ip[2].setLayout(Item.LAYOUT_2);
ip[3].setLayout(Item.LAYOUT_2);
frmServidor = new Form("Configuraci�n"); // Titulo de la forma
subtitulo = new StringItem("Direccion IP:", "");
frmServidor.append(subtitulo); // Coloca cadena de texto
frmServidor.append(ip[0]);
frmServidor.append(ip[1]);
frmServidor.append(ip[2]);
frmServidor.append(ip[3]);
frmServidor.append("\n ");
frmServidor.append(puerto);
frmServidor.addCommand(cmdVolver); // Coloca el comando Salida
// * Metodos *
public void startApp() {
sscInicio.hilo = true; // Habilita el hilo
new Thread(sscInicio).start(); // Hilo en Canvas
sscInicio.setCommandListener(this); // Define la forma que escucha comandos
display.setCurrent(sscInicio); // Define objeto a mostrar
// Metodos comunes en todos los Midlet
public void pauseApp() {
System.out.println("*** Pausado ***");
sscInicio.hilo = false; // Detiene el hilo
public void destroyApp(boolean unconditional) {
public void salir() {
sscInicio.hilo = false;
System.out.println("*** Terminado ***");
destroyApp(false); // Destruir objetos
notifyDestroyed(); // Salir de la aplicacion
String cargarIP() {
String cadena;
// Cargar la direccion del servidor
try {
rsDireccion = RecordStore.openRecordStore("ipRecordStore", true ); // Crear si no existe
} catch (Exception error) {}
try {
byte[] byteOutputData = rsDireccion.getRecord(1); // Lee el primer registro
cadena = new String(byteOutputData);
System.out.println("Cargada: " + cadena);
} catch (Exception error) {
cadena = "190.65.161.158:24300";
try {
rsDireccion.closeRecordStore(); // Cerrar
} catch (Exception error) {}
return cadena;
void guardarIP (String cadena) {
// Almacenar la direcci�n ip y puerto
try {
RecordStore.deleteRecordStore("ipRecordStore"); // Borrar si existe
} catch (Exception error) {}
try {
rsDireccion = RecordStore.openRecordStore("ipRecordStore", true ); // Crear si no existe
} catch (Exception error) {}
try {
byte[] byteOutputData = cadena.getBytes(); // Almacena los datos
rsDireccion.addRecord(byteOutputData, 0, byteOutputData.length);
System.out.println("Guardada: " + cargarIP()); // rsDireccion.getNumRecords()
} catch (Exception error) {}
try {
rsDireccion.closeRecordStore(); // Cerrar
} catch (Exception error) {}
void mostrarIP(String cadena) {
int i, j=0, k;
for (k=0; k<=2; k++) {
i = cadena.indexOf('.', j); // Posicion del punto
if (i < 0) {
ip[k].setString("0"); // Si hay error coloca 0
} else {
ip[k].setString(cadena.substring(j, i)); // Extrae direccion
j = i + 1;
i = cadena.indexOf(':', j); // Posicion del punto
ip[3].setString(cadena.substring(j, i)); // Extrae direccion
i = cadena.lastIndexOf(':'); // Posicion dos puntos
puerto.setString(cadena.substring(i+1)); // Extrae puerto
public void commandAction(Command c, Displayable s) {
if (c == cmdEntrada) {
if (sscInicio.img == sscInicio.ts) { // Configurar servidor
sscInicio.hilo = false;
direccion = cargarIP (); // Cargar del record
mostrarIP(direccion); // Mostrar en la forma
System.out.println("*** OK ***");
frmServidor.setCommandListener(this);
display.setCurrent(frmServidor);
} else {
sscInicio.entrada = true; // Tiquete entrada
AlertType.ERROR.playSound(TS_Online.display); // Sonido
} else if (c == cmdSalida) {
sscInicio.entrada = false; // Tiquete salida
AlertType.ERROR.playSound(TS_Online.display); // Sonido
} else if (c == cmdVolver) { // Volver a la pantalla anterior
direccion = ip[0].getString() + "." + ip[1].getString() + "."
+ ip[2].getString() + "." + ip[3].getString() + ":" + puerto.getString();
guardarIP(direccion); //Almacenar en record
sscInicio.setCommandListener(this);
sscInicio.hilo = true; // Arranca el hilo
new Thread(sscInicio).start(); // Hilo en Canvas
display.setCurrent(sscInicio);
System.out.println(sscInicio.hilo);
// * Clase graficadora *
class SSCanvas extends Canvas implements Runnable {
private int sleepTime; // Tiempo de retrazo
static public boolean entrada = true; // Tiquete de entrada
static public boolean hilo; // Continuar hilo
static public Image ts = null; // Contenedor imagen
static public Image rojo = null; // Contenedor imagenpri
static public Image verde = null; // Contenedor imagen
static public Image img = null; // Contenedor imagen
static public String mensaje = null; // Cadena de salida
static public String mensaje2 = ""; // Cadena de salida Codigo de barras
MIDlet midlet; // Enlace al midlet inicial
CommConnection cc = null; // Conector para puerto
//SocketConnection sc = null; // Conector para red
//SocketConnection cc = null; // Conector para red
public SSCanvas(MIDlet m) {
midlet = m; // Referencia al MIDlet iniciado
// Cargamos las im�genes a usar
try {
ts = Image.createImage("/TicketShop.PNG"); // Procedimiento para cargar las imagenes
rojo = Image.createImage("/Rojo.PNG"); // Procedimiento para cargar las imagenes
verde = Image.createImage("/Verde.PNG"); // Procedimiento para cargar las imagenes
} catch (IOException e) {} // Error si no encuentra las imagenes
img = ts; // Imagen de bienvenida
mensaje = "Conectando";
mensaje2 = ""; // Mensaje de inicio
void iniciar() {
img = ts; // Imagen de bienvenida
// Tiempo de espera para configurar servidor
for (sleepTime = 1;sleepTime <= 3; sleepTime++) {
try {
mensaje = mensaje + "."; // Mensaje de inicio
repaint(); // Redibuja la pantalla
serviceRepaints(); // Espera que termine
Thread.sleep(1000);
} catch (InterruptedException e) {
System.out.println(e.toString());
mensaje = "Conectado!";
img = verde;
repaint(); // Redibuja la pantalla
serviceRepaints(); // Espera que termine
sleepTime = 50;
System.out.println("Iniciar");
void codigo() {
try {
System.out.println("Leyendo");
CommConnection cc = (CommConnection)Connector.open("comm:com0;baudrate=9600");
//cc = (SocketConnection)Connector.open("socket://127.0.0.1:24300");
//int baudrate = cc.getBaudRate();
InputStream ic = cc.openInputStream(); // Entrada serial
//OutputStream oc = cc.openOutputStream();
StringBuffer sbCodigo = new StringBuffer(); // Cadena de diferentes tipos de datos
int ch = 255;
while(ch > 32) {
ch = ic.read();
//oc.write(ch);
if (ch > 32)
sbCodigo.append((char)ch);
mensaje2 = sbCodigo.toString(); // Codigo de barras
if (mensaje2.equals("2864634059CULIB")) {
valido();
} else {
invalido();
ic.close(); // Cierra las conexiones
//oc.close();
cc.close();
} catch (Exception e) {
Alert a = new Alert("Error!", e.toString(), rojo, AlertType.ERROR);
a.setTimeout(Alert.FOREVER); // Alerta hasta que oprima boton
TS_Online.display.setCurrent(a); // Despues de la alerta vuelve a Inicio
try {
Thread.sleep(5000);
} catch (Exception x) {}
void valido() {
img = verde; // Imagen OK
mensaje = "Tiquete OK"; // Tiquete valido
AlertType.CONFIRMATION.playSound(TS_Online.display); // Sonido
void invalido() {
img = rojo; // Imagen OK
mensaje = "Tiquete Inv�lido"; // Tiquete valido
AlertType.ERROR.playSound(TS_Online.display); // Sonido
// thread que contiene el game loop
public void run() {
System.out.println("*** Hilo arrancado ***");
if (img == ts)
iniciar();
while (hilo) {
//System.out.println("Hilo");
// Leer codigo de barras
codigo();
// validar codigo de barras
//validar();
// Actualizar pantalla
repaint(); // Redibuja la pantalla
serviceRepaints(); // Espera que termine
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
System.out.println(e.toString());
protected void keyPressed(int keyCode) {
mensaje = Integer.toString(keyCode);
//int action = getGameAction(keyCode);
if ((keyCode == -8) || (keyCode == 42)) { // Si presiona borrar o *
AlertType.ERROR.playSound(TS_Online.display); // Sonido
((TS_Online)midlet).salir();
} else if (keyCode == -51 || keyCode == -52 || keyCode == -53) {
AlertType.ERROR.playSound(TS_Online.display); // Sonido
public void paint(Graphics g) {
// Borrar la pantalla
g.setColor(255,255,255);
g.fillRect (0, 0, getWidth(), getHeight());
// Coloca la imagen correspondiente
g.drawImage (img, getWidth()/2, 20, Graphics.HCENTER|Graphics.TOP);
// Poner texto
Font fuente = Font.getFont (Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_MEDIUM);
g.setFont(fuente);
g.setColor(0,0,0);
g.drawString(mensaje, getWidth()/2, getHeight()/2,Graphics.TOP|Graphics.HCENTER);
g.drawString(mensaje2, getWidth()/2, 5,Graphics.TOP|Graphics.HCENTER);
} -
Merge files and remove non-static elements
Where is the feature that allowed images to be merged while removing non-static elements. I saw a demonstration of removing people from a scene when multiple pictures were taken and the people had changed their positions. This was touted as a feature found only in PS extended a few years ago. I have never been able to locate it.
This involves an "Image Stack". See http://help.adobe.com/en_US/photoshop/cs/using/WS1E389632-4B37-425e-8EAB-1384C0B432D3a.htm l
-
Converting from non-static to static
I am tyring to convert a method from non-static to static. I changed a few variables to get it to work and everything is now static in the method except for the getClass() method which it calls, does anyone know how I could work around this.
Heres the method -
public static void addObjectToPanel(String type, String name)
JLabel label = new JLabel("The object");
// The getClass() here is causing the problem
label.setIcon(new ImageIcon(getClass().getResource("object.gif")));
label.setBounds(xCoordinate, yCoordinate, width, height);
display.setLayout(null);
display.add(label);
// After the image is placed by this method, then the x coordinate is moved to allow for the next object
xCoordinate +=150;
// This resizes the JPanel as images are added, this solves a potential issue with the JScrollPane
display.setPreferredSize(new Dimension( (900+xCoordinate), (600+yCoordinate) ));Is there any way I can get around using getClass() or is there anything else I could do, thanks.It's a static method. You should know what thename
of the class that it is in is.Sorry, I didn't see that they were talking about the
actuall class that the method is in, i missed
something written earlier.
I am now using label.setIcon(new
ImageIcon("object.gif"));and everything is working fine now.
Thanks everyone for your help.Be warned that this is not the same as what you did initially. The initial version looks in the class loading path. The final version looks in the current directory. I believe your intention is better reflected by the initial version. -
Static nested class VS non-static nested class ??
we know static method can be called without creating an object and static variables are shared among objects.
what is the difference between static nested class and non-static nested class ? When do we use them? what is the advantages of static nested class over non-static nested class in term of performance?From the JLS, chapter 8:
A nested class is any class whose declaration occurs within the body of another class or interface. A top level class is a class that is not a nested class.
This chapter discusses the common semantics of all classes-top level (?7.6) and nested (including member classes (?8.5, ?9.5), local classes (?14.3) and anonymous classes (?15.9.5)).
So "nested" iff "not top level".From the JLS, chapter 8:
An inner class is a nested class that is not explicitly or implicitly declared static.
So a "static" nested class is a bit redundant, since a "non-static" nested class -- a nested class is either static or it isn't -- is more specifically referred to as an "inner class". That's my story and I'm sticking to it. :o)
~ -
Create a new Buffered Image using Raster and ColorModel
Sorry , I crosspost this message,because no one reply.
Recently,I write a programme combining C++ and Java .
The C++ part create a array containing image data in form of BI_RGB and biBitCount==32.
The java part create a image using Raster and ColorModel like this:
static int[] data ;
DataBuffer db = new DataBufferInt(data, data.length);
WritableRaster wr =Raster.createPackedRaster(db, 1024,768, 32, null);
ColorModel cm = new DirectColorModel(32,0xff0000,0x00ff00,0x0000ff);
img = new BufferedImage(cm, wr, false, null);But it doesn't work .
it report this:
Exception in thread "main" java.lang.IllegalArgumentException: Raster sun.awt.im
age.SunWritableRaster@dff3a2 is incompatible with ColorModel DirectColorModel: r
mask=ff0000 gmask=ff00 bmask=ff amask=0
at java.awt.image.BufferedImage.<init>(BufferedImage.java:549)
at monitor.test.Perform2.main(Perform2.java:39)hey epico
compiles & runs 4 me
see javadocs for SinglePixelPackedSampleModel
import java.awt.image.*;
public class Tester {
DataBuffer db;
WritableRaster wr;
ColorModel cm;
BufferedImage im;
int[] data;
int[] masks;
int w = 768;
int h = 576;
public Tester() {
data = new int[768*576];
for (int i = 0;i < w*h ;i++ ) {
data[i] = 0;
masks = new int[3];
masks[0] = 0xff0000;
masks[1] = 0x00ff00;
masks[2] = 0x0000ff;
db = new DataBufferInt(data,data.length);
SinglePixelPackedSampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT,w,h,masks);
cm = new DirectColorModel(32,0xff0000,0x00ff00,0x0000ff);
wr = Raster.createWritableRaster(sm,db,null);
im = new BufferedImage(cm,wr,false,null);
public static void main(String[] args) {
Tester tester1 = new Tester();
} -
Is there a way to save a fillable form (in Reader) as a static (uneditiable) image and send it for signature without the recipient being able to revise the fields at all? I have designed a number of fillable forms and sent them to our clients as Reader extended pdfs to be filled out and sent back. Now, certain clients want to be able to fill in the fields and save the doc as a pdf that can't be tampered with so that they can send it to their own people for signature to be returned to them hand-signed and scanned via email.
Since the forms have been secured, and my cleints are only using the free Acrobat Reader, how can they save the filled in form as a static pdf to send on for signature? They do not want to have to print, scan and email. Is there an app, plug-in, simple solution to this?
Thank you,
RumorThe signature WILL work! I've just looked into it more, thank you so much for pointing me in that direction.
I get it now, it locks the form fields in place after my coworker fills them in and signs it (as the very last step).
I wish I would have asked on here a full day ago. Would have saved a lot of headache and Googling.
Thanks again.
Maybe you are looking for
-
What's the difference between ACW and PCW?
Hi Gurus, What's the difference between ACW (Application Controlled Workflow) and PCW (Process Controlled Workflow) ? I read that SRM 4.0 uses ACW and SRM 7.0 uses PCW. My current system is SRM 4.0 but I'm upgrading to SRM 7.0. What is the difference
-
HP pavilion g6 do not boot nothing from any media
Hi, I have this notebook (HP Pavilion g6-1010sc) and one day it do not boot nothing from any media. I tried to boot linux, winxp, original win7-x64 from internal and external USB disks, but unfortunatelly. Notebook restarts or freezes after i tried t
-
No destination is currently free for parallel processing - SAPRCK10
Hello ABAPers, We have scheduled SAP standard program "SAPRCK10" in background processing at our production server on daily basis. It was worked fine on last week before but its now giving a error says "No destination is currently free for parallel p
-
Boot Mac OS when temp copy of windows is expired?
Hello, I have found myself in a bad situation. New Macbook Pro; installed boot camp a while back and used a temp copy of windows (use it for 30 days and then buy or dont use it anymore); I'm booting the Macbook Pro up as windows and forgot the test c
-
Is there any limit for DAQ_Start(​)'s count parameter?
Is there any limit for DAQ_Start()'s count (the fifth) parameter? It seems that the limit is between 16 million and 18 million. I use PCI-MIO-16E-1 and LabWindows/CVI.