/* * geoc.java * * Created on July 14, 2007, 1:29 AM */ package gui; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.location.LocationException; import java.util.Timer; import nav.*; /** * * @author manut */ public class geoc extends MIDlet implements CommandListener { private navigate nav; /** * Creates a new instance of geoc */ public geoc() { try { nav = new navigate(this); } catch (LocationException e) { this.get_stringItemHead1().setText("no GPS!/n"); } } private Form editForm;//GEN-BEGIN:MVDFields private StringItem stringItemHead1; private Command exitCommand; private TextField textFieldEnterNorth; private TextField textFieldEnterEast; private Spacer spacer1; private StringItem stringItemEnterDest; private Command screenCommand1; private Command exitCommand1; private Command exitCommand2; private Command itemCommand1; private Command itemCommand2; private Form navForm; private Command exitCommand3; private Command exitCommand4; private Command screenCommand2; private StringItem stringItemHead2; private Spacer spacer2; private StringItem stringItemCourse; private StringItem stringItemDistance; private StringItem stringItemActNorth; private StringItem stringItemActEast; private StringItem stringItemActHeight; private StringItem stringItemDestination; private StringItem stringItemDestNorth; private StringItem stringItemDestEast; private Command okCommand1;//GEN-END:MVDFields //GEN-LINE:MVDMethods /** This method initializes UI of the application.//GEN-BEGIN:MVDInitBegin */ private void initialize() {//GEN-END:MVDInitBegin // Insert pre-init code here navForm = new Form(null, new Item[] {//GEN-BEGIN:MVDInitInit get_stringItemHead2(), get_spacer2(), get_stringItemCourse(), get_stringItemDistance(), get_stringItemActNorth(), get_stringItemActEast(), get_stringItemActHeight(), get_stringItemDestination(), get_stringItemDestNorth(), get_stringItemDestEast() }); navForm.addCommand(get_exitCommand4()); navForm.addCommand(get_screenCommand2()); navForm.setCommandListener(this); editForm = new Form(null, new Item[] { get_stringItemHead1(), get_spacer1(), get_stringItemEnterDest(), get_textFieldEnterNorth(), get_textFieldEnterEast() }); editForm.addCommand(get_exitCommand()); editForm.addCommand(get_okCommand1()); editForm.setCommandListener(this); getDisplay().setCurrent(editForm);//GEN-END:MVDInitInit // Insert post-init code here }//GEN-LINE:MVDInitEnd /** Called by the system to indicate that a command has been invoked on a particular displayable.//GEN-BEGIN:MVDCABegin * @param command the Command that ws invoked * @param displayable the Displayable on which the command was invoked */ public void commandAction(Command command, Displayable displayable) {//GEN-END:MVDCABegin // Insert global pre-action code here if (displayable == editForm) {//GEN-BEGIN:MVDCABody if (command == exitCommand) {//GEN-END:MVDCABody // Insert pre-action code here exitMIDlet();//GEN-LINE:MVDCAAction3 // Insert post-action code here at gui.geoc.(geoc.java:34) } else if (command == okCommand1) {//GEN-LINE:MVDCACase3 // Insert pre-action code here javax.microedition.lcdui.Alert al = new javax.microedition.lcdui.Alert("Error"); al.setString("Coord. parsing failed\nor no gps!"); try { nav.setDestination(get_textFieldEnterNorth().getString(), get_textFieldEnterEast().getString()); } catch(Exception ae) { getDisplay().setCurrent(al, navForm); } getDisplay().setCurrent(navForm); /* getDisplay ().setCurrent (navForm);//GEN-LINE:MVDCAAction43 // Iert post-action code here */ }//GEN-BEGIN:MVDCACase43 } else if (displayable == navForm) { if (command == exitCommand4) {//GEN-END:MVDCACase43 // Insert pre-action code here exitMIDlet();//GEN-LINE:MVDCAAction24 // Insert post-action code here } else if (command == screenCommand2) {//GEN-LINE:MVDCACase24 // Insert pre-action code here getDisplay().setCurrent(editForm);//GEN-LINE:MVDCAAction26 // Insert post-action code here }//GEN-BEGIN:MVDCACase26 }//GEN-END:MVDCACase26 // Insert global post-action code here }//GEN-LINE:MVDCAEnd /** * This method should return an instance of the display. */ public Display getDisplay() {//GEN-FIRST:MVDGetDisplay return Display.getDisplay(this); }//GEN-LAST:MVDGetDisplay /** * This method should exit the midlet. */ public void exitMIDlet() {//GEN-FIRST:MVDExitMidlet getDisplay().setCurrent(null); destroyApp(true); notifyDestroyed(); }//GEN-LAST:MVDExitMidlet /** This method returns instance for stringItemHead1 component and should be called instead of accessing stringItemHead1 field directly.//GEN-BEGIN:MVDGetBegin4 * @return Instance for stringItemHead1 component */ public StringItem get_stringItemHead1() { if (stringItemHead1 == null) {//GEN-END:MVDGetBegin4 // Insert pre-init code here stringItemHead1 = new StringItem("geoc", "v0.1");//GEN-LINE:MVDGetInit4 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd4 return stringItemHead1; }//GEN-END:MVDGetEnd4 /** This method returns instance for exitCommand component and should be called instead of accessing exitCommand field directly.//GEN-BEGIN:MVDGetBegin5 * @return Instance for exitCommand component */ public Command get_exitCommand() { if (exitCommand == null) {//GEN-END:MVDGetBegin5 // Insert pre-init code here exitCommand = new Command("Exit", Command.EXIT, 1);//GEN-LINE:MVDGetInit5 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd5 return exitCommand; }//GEN-END:MVDGetEnd5 /** This method returns instance for textFieldEnterNorth component and should be called instead of accessing textFieldEnterNorth field directly.//GEN-BEGIN:MVDGetBegin6 * @return Instance for textFieldEnterNorth component */ public TextField get_textFieldEnterNorth() { if (textFieldEnterNorth == null) {//GEN-END:MVDGetBegin6 // Insert pre-init code here textFieldEnterNorth = new TextField("North", "47:42.466", 120, TextField.ANY);//GEN-LINE:MVDGetInit6 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd6 return textFieldEnterNorth; }//GEN-END:MVDGetEnd6 /** This method returns instance for textFieldEnterEast component and should be called instead of accessing textFieldEnterEast field directly.//GEN-BEGIN:MVDGetBegin7 * @return Instance for textFieldEnterEast component */ public TextField get_textFieldEnterEast() { if (textFieldEnterEast == null) {//GEN-END:MVDGetBegin7 // Insert pre-init code here textFieldEnterEast = new TextField("East", "9:36.620", 120, TextField.ANY);//GEN-LINE:MVDGetInit7 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd7 return textFieldEnterEast; }//GEN-END:MVDGetEnd7 /** This method returns instance for spacer1 component and should be called instead of accessing spacer1 field directly.//GEN-BEGIN:MVDGetBegin9 * @return Instance for spacer1 component */ public Spacer get_spacer1() { if (spacer1 == null) {//GEN-END:MVDGetBegin9 // Insert pre-init code here spacer1 = new Spacer(1000, 1);//GEN-LINE:MVDGetInit9 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd9 return spacer1; }//GEN-END:MVDGetEnd9 /** This method returns instance for stringItemEnterDest component and should be called instead of accessing stringItemEnterDest field directly.//GEN-BEGIN:MVDGetBegin10 * @return Instance for stringItemEnterDest component */ public StringItem get_stringItemEnterDest() { if (stringItemEnterDest == null) {//GEN-END:MVDGetBegin10 // Insert pre-init code here stringItemEnterDest = new StringItem("\nEnter Destination", "");//GEN-LINE:MVDGetInit10 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd10 return stringItemEnterDest; }//GEN-END:MVDGetEnd10 /** This method returns instance for screenCommand1 component and should be called instead of accessing screenCommand1 field directly.//GEN-BEGIN:MVDGetBegin11 * @return Instance for screenCommand1 component */ public Command get_screenCommand1() { if (screenCommand1 == null) {//GEN-END:MVDGetBegin11 // Insert pre-init code here screenCommand1 = new Command("go to", Command.SCREEN, 1);//GEN-LINE:MVDGetInit11 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd11 return screenCommand1; }//GEN-END:MVDGetEnd11 /** This method returns instance for exitCommand1 component and should be called instead of accessing exitCommand1 field directly.//GEN-BEGIN:MVDGetBegin15 * @return Instance for exitCommand1 component */ public Command get_exitCommand1() { if (exitCommand1 == null) {//GEN-END:MVDGetBegin15 // Insert pre-init code here exitCommand1 = new Command("Exit", Command.EXIT, 1);//GEN-LINE:MVDGetInit15 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd15 return exitCommand1; }//GEN-END:MVDGetEnd15 /** This method returns instance for exitCommand2 component and should be called instead of accessing exitCommand2 field directly.//GEN-BEGIN:MVDGetBegin16 * @return Instance for exitCommand2 component */ public Command get_exitCommand2() { if (exitCommand2 == null) {//GEN-END:MVDGetBegin16 // Insert pre-init code here exitCommand2 = new Command("Exit", Command.EXIT, 1);//GEN-LINE:MVDGetInit16 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd16 return exitCommand2; }//GEN-END:MVDGetEnd16 /** This method returns instance for itemCommand1 component and should be called instead of accessing itemCommand1 field directly.//GEN-BEGIN:MVDGetBegin18 * @return Instance for itemCommand1 component */ public Command get_itemCommand1() { if (itemCommand1 == null) {//GEN-END:MVDGetBegin18 // Insert pre-init code here itemCommand1 = new Command("Item", Command.ITEM, 1);//GEN-LINE:MVDGetInit18 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd18 return itemCommand1; }//GEN-END:MVDGetEnd18 /** This method returns instance for itemCommand2 component and should be called instead of accessing itemCommand2 field directly.//GEN-BEGIN:MVDGetBegin19 * @return Instance for itemCommand2 component */ public Command get_itemCommand2() { if (itemCommand2 == null) {//GEN-END:MVDGetBegin19 // Insert pre-init code here itemCommand2 = new Command("Edit Coord.", Command.ITEM, 1);//GEN-LINE:MVDGetInit19 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd19 return itemCommand2; }//GEN-END:MVDGetEnd19 /** This method returns instance for exitCommand3 component and should be called instead of accessing exitCommand3 field directly.//GEN-BEGIN:MVDGetBegin22 * @return Instance for exitCommand3 component */ public Command get_exitCommand3() { if (exitCommand3 == null) {//GEN-END:MVDGetBegin22 // Insert pre-init code here exitCommand3 = new Command("Exit", Command.EXIT, 1);//GEN-LINE:MVDGetInit22 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd22 return exitCommand3; }//GEN-END:MVDGetEnd22 /** This method returns instance for exitCommand4 component and should be called instead of accessing exitCommand4 field directly.//GEN-BEGIN:MVDGetBegin23 * @return Instance for exitCommand4 component */ public Command get_exitCommand4() { if (exitCommand4 == null) {//GEN-END:MVDGetBegin23 // Insert pre-init code here exitCommand4 = new Command("Exit", Command.EXIT, 1);//GEN-LINE:MVDGetInit23 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd23 return exitCommand4; }//GEN-END:MVDGetEnd23 /** This method returns instance for screenCommand2 component and should be called instead of accessing screenCommand2 field directly.//GEN-BEGIN:MVDGetBegin25 * @return Instance for screenCommand2 component */ public Command get_screenCommand2() { if (screenCommand2 == null) {//GEN-END:MVDGetBegin25 // Insert pre-init code here screenCommand2 = new Command("edit Coord.", Command.SCREEN, 1);//GEN-LINE:MVDGetInit25 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd25 return screenCommand2; }//GEN-END:MVDGetEnd25 /** This method returns instance for stringItemHead2 component and should be called instead of accessing stringItemHead2 field directly.//GEN-BEGIN:MVDGetBegin27 * @return Instance for stringItemHead2 component */ public StringItem get_stringItemHead2() { if (stringItemHead2 == null) {//GEN-END:MVDGetBegin27 // Insert pre-init code here stringItemHead2 = new StringItem("geoc", "v0.1");//GEN-LINE:MVDGetInit27 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd27 return stringItemHead2; }//GEN-END:MVDGetEnd27 /** This method returns instance for spacer2 component and should be called instead of accessing spacer2 field directly.//GEN-BEGIN:MVDGetBegin28 * @return Instance for spacer2 component */ public Spacer get_spacer2() { if (spacer2 == null) {//GEN-END:MVDGetBegin28 // Insert pre-init code here spacer2 = new Spacer(1000, 1);//GEN-LINE:MVDGetInit28 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd28 return spacer2; }//GEN-END:MVDGetEnd28 /** This method returns instance for stringItemCourse component and should be called instead of accessing stringItemCourse field directly.//GEN-BEGIN:MVDGetBegin29 * @return Instance for stringItemCourse component */ public StringItem get_stringItemCourse() { if (stringItemCourse == null) {//GEN-END:MVDGetBegin29 // Insert pre-init code here stringItemCourse = new StringItem("\nCourse", "0");//GEN-LINE:MVDGetInit29 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd29 return stringItemCourse; }//GEN-END:MVDGetEnd29 /** This method returns instance for stringItemDistance component and should be called instead of accessing stringItemDistance field directly.//GEN-BEGIN:MVDGetBegin34 * @return Instance for stringItemDistance component */ public StringItem get_stringItemDistance() { if (stringItemDistance == null) {//GEN-END:MVDGetBegin34 // Insert pre-init code here stringItemDistance = new StringItem("Distance", "0");//GEN-LINE:MVDGetInit34 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd34 return stringItemDistance; }//GEN-END:MVDGetEnd34 /** This method returns instance for stringItemActNorth component and should be called instead of accessing stringItemActNorth field directly.//GEN-BEGIN:MVDGetBegin35 * @return Instance for stringItemActNorth component */ public StringItem get_stringItemActNorth() { if (stringItemActNorth == null) {//GEN-END:MVDGetBegin35 // Insert pre-init code here stringItemActNorth = new StringItem("\nNorth", "0");//GEN-LINE:MVDGetInit35 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd35 return stringItemActNorth; }//GEN-END:MVDGetEnd35 /** This method returns instance for stringItemActEast component and should be called instead of accessing stringItemActEast field directly.//GEN-BEGIN:MVDGetBegin36 * @return Instance for stringItemActEast component */ public StringItem get_stringItemActEast() { if (stringItemActEast == null) {//GEN-END:MVDGetBegin36 // Insert pre-init code here stringItemActEast = new StringItem("East", "0");//GEN-LINE:MVDGetInit36 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd36 return stringItemActEast; }//GEN-END:MVDGetEnd36 /** This method returns instance for stringItemActHeight component and should be called instead of accessing stringItemActHeight field directly.//GEN-BEGIN:MVDGetBegin37 * @return Instance for stringItemActHeight component */ public StringItem get_stringItemActHeight() { if (stringItemActHeight == null) {//GEN-END:MVDGetBegin37 // Insert pre-init code here stringItemActHeight = new StringItem("Height", "0");//GEN-LINE:MVDGetInit37 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd37 return stringItemActHeight; }//GEN-END:MVDGetEnd37 /** This method returns instance for stringItemDestination component and should be called instead of accessing stringItemDestination field directly.//GEN-BEGIN:MVDGetBegin38 * @return Instance for stringItemDestination component */ public StringItem get_stringItemDestination() { if (stringItemDestination == null) {//GEN-END:MVDGetBegin38 // Insert pre-init code here stringItemDestination = new StringItem("\nDestination", "");//GEN-LINE:MVDGetInit38 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd38 return stringItemDestination; }//GEN-END:MVDGetEnd38 /** This method returns instance for stringItemDestNorth component and should be called instead of accessing stringItemDestNorth field directly.//GEN-BEGIN:MVDGetBegin40 * @return Instance for stringItemDestNorth component */ public StringItem get_stringItemDestNorth() { if (stringItemDestNorth == null) {//GEN-END:MVDGetBegin40 // Insert pre-init code here stringItemDestNorth = new StringItem("North", "0");//GEN-LINE:MVDGetInit40 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd40 return stringItemDestNorth; }//GEN-END:MVDGetEnd40 /** This method returns instance for stringItemDestEast component and should be called instead of accessing stringItemDestEast field directly.//GEN-BEGIN:MVDGetBegin41 * @return Instance for stringItemDestEast component */ public StringItem get_stringItemDestEast() { if (stringItemDestEast == null) {//GEN-END:MVDGetBegin41 // Insert pre-init code here stringItemDestEast = new StringItem("East", "0");//GEN-LINE:MVDGetInit41 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd41 return stringItemDestEast; }//GEN-END:MVDGetEnd41 /** This method returns instance for okCommand1 component and should be called instead of accessing okCommand1 field directly.//GEN-BEGIN:MVDGetBegin42 * @return Instance for okCommand1 component */ public Command get_okCommand1() { if (okCommand1 == null) {//GEN-END:MVDGetBegin42 // Insert pre-init code here okCommand1 = new Command("goto", Command.OK, 1);//GEN-LINE:MVDGetInit42 // Insert post-init code here }//GEN-BEGIN:MVDGetEnd42 return okCommand1; }//GEN-END:MVDGetEnd42 public void startApp() { initialize(); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } }