Codigo graficador en j2me

Solo disponible en BuenasTareas
  • Páginas : 2 (379 palabras )
  • Descarga(s) : 0
  • Publicado : 12 de mayo de 2010
Leer documento completo
Vista previa del texto
package Graficador;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class Graficador extends MIDlet implements CommandListener {
private Commandsalir,graf,nuevo,ver_raices;
private Display dis;
private SSCanvas screen;
private Form pan;
private TextField a,b,d;
private double y1=0,a1=0,b1=0,c1=0,x,f,f1,x1,x2,in=1,ii=-100,mul=1;
private inti=-100,f2=0,ejey=-50,ejex,ejey1,zoomx=0,zoomy=0;


public Graficador() {
dis=Display.getDisplay(this);
pan=new Form("Graf ax^2+bx+c=0");
salir = new Command("Salir",Command.EXIT,1);nuevo = new Command("Nuevo",Command.BACK,2);
ver_raices = new Command("Raices",Command.BACK,2);
graf = new Command("Graficar",Command.SCREEN,2);
screen=new SSCanvas();

a=newTextField("a=","",5,TextField.DECIMAL);
b=new TextField("b=","",5,TextField.DECIMAL);
d=new TextField("c=","",5,TextField.DECIMAL);

pan.append(a);
pan.append(b);
pan.append(d);pan.addCommand(graf);
pan.addCommand(salir);
//screen.setTicker(raiz);
screen.addCommand(salir);
screen.addCommand(nuevo);
screen.addCommand(ver_raices);
pan.setCommandListener(this);}
public void startApp() throws MIDletStateChangeException {
dis.setCurrent(pan);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public voidcommandAction(Command c, Displayable s) {
if (c == salir) {
destroyApp(false);
notifyDestroyed();
}
else if(c==graf){
a1=Double.parseDouble( a.getString());
b1=Double.parseDouble(b.getString());
c1=Double.parseDouble( d.getString());
raices();
screen.setCommandListener(this);
dis.setCurrent(screen);
}
else if(c==nuevo){pan.setCommandListener(this);
dis.setCurrent(pan);
}

else if(c==ver_raices){
if( f>=0){
Alert solucion=new Alert("RAICES","X1="+x1+"\nX2="+x2,null,AlertType.WARNING );
solucion.setTimeout(...
tracking img