package source;

import java.io.IOException;
import javax.bluetooth.BluetoothStateException;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.m2g.SVGImage;
import org.netbeans.microedition.lcdui.SplashScreen;

public class Navigator extends MIDlet implements CommandListener {

    private boolean midletPaused = false;
    //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private List Menu;
    private SplashScreen Welcome;
    private Form Connecteddevice;
    private ChoiceGroup choosedevices;
    private Form Navi;
    private Alert info;
    private Form About;
    private StringItem stringItem;
    private Form Status;
    private Form Satelite;
    private ChoiceGroup chSat;
    private Form SaveForm;
    private ChoiceGroup mem_choice;
    private TextField saveTextBox;
    private Form LoadForm;
    private TextField loadData;
    private ChoiceGroup wayList;
    private TextField way_name;
    private Command exitComMMenu;
    private Command exitComBDev;
    private Command okComMMenu;
    private Command findComBDev;
    private Command cancelCommand;
    private Command connComBDev;
    private Command exitComNavi;
    private Command exitComAbout;
    private Command okGenInfoNavi;
    private Command disconnComStatus;
    private Command exitComStatus;
    private Command exitComSat;
    private Command okComSaveNavi;
    private Command okComNavigaNavi;
    private Command okComKompNavi;
    private Command loadComLoadF;
    private Command itemCommand;
    private Command okComLoadNavi;
    private Command okComStatNavi;
    private Command okComMemNavi;
    private Command delComLoadF;
    private Command exitComLoadF;
    private Command exitComSaveF;
    private Command saveComSaveF;
    private Command okSatInfoComSat;
    private Command backCommand;
    private Command selComLoadF;
    private Image icon;
    private Image mSat24;
    private Image splash;
    private Image mNavi24;
    private Image mAbout24;
    private Image mBT24;
    private SVGImage svgNavi1;
    private Font GPSdata;
    private Font Popis;
    //</editor-fold>//GEN-END:|fields|0|

    /**
     * The Navigator constructor.
     */
    public Navigator() {
    }

    void informSearchError(String string) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
    //</editor-fold>//GEN-END:|methods|0|
    //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
    /**
     * Initilizes the application.
     * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
     */
    private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
        // write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
        // write post-initialize user code here
    }//GEN-BEGIN:|0-initialize|2|
    //</editor-fold>//GEN-END:|0-initialize|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Started point.
     */
    public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
        // write pre-action user code here
        switchDisplayable(null, getWelcome());//GEN-LINE:|3-startMIDlet|1|3-postAction
    // write post-action user code here
    }//GEN-BEGIN:|3-startMIDlet|2|
    //</editor-fold>//GEN-END:|3-startMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
     */
    public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
        // write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
        // write post-action user code here
    }//GEN-BEGIN:|4-resumeMIDlet|2|
    //</editor-fold>//GEN-END:|4-resumeMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
    /**
     * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
     * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
     * @param nextDisplayable the Displayable to be set
     */
    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
        // write pre-switch user code here
        Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
        if (alert == null) {
            display.setCurrent(nextDisplayable);
        } else {
            display.setCurrent(alert, nextDisplayable);
        }//GEN-END:|5-switchDisplayable|1|5-postSwitch
    // write post-switch user code here
    }//GEN-BEGIN:|5-switchDisplayable|2|
    //</editor-fold>//GEN-END:|5-switchDisplayable|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
    /**
     * Called by a system to indicated that a command has been invoked on a particular displayable.
     * @param command the Command that was invoked
     * @param displayable the Displayable where the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
        // write pre-action user code here
        if (displayable == About) {//GEN-BEGIN:|7-commandAction|1|96-preAction
            if (command == exitComAbout) {//GEN-END:|7-commandAction|1|96-preAction
                // write pre-action user code here
                switchDisplayable(null, getMenu());//GEN-LINE:|7-commandAction|2|96-postAction
            // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|3|52-preAction
        } else if (displayable == Connecteddevice) {
            if (command == connComBDev) {//GEN-END:|7-commandAction|3|52-preAction
                // write pre-action user code here
                switchDisplayable(null, getStatus());//GEN-LINE:|7-commandAction|4|52-postAction
                // write post-action user code here
                try {
                    b.connect();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            } else if (command == exitComBDev) {//GEN-LINE:|7-commandAction|5|32-preAction
                // write pre-action user code here
                switchDisplayable(null, getMenu());//GEN-LINE:|7-commandAction|6|32-postAction
            // write post-action user code here
            } else if (command == findComBDev) {//GEN-LINE:|7-commandAction|7|42-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|8|42-postAction
                try {
                    // write post-action user code here
                    b.discoverGPS();
                } catch (BluetoothStateException ex) {
                    ex.printStackTrace();
                }
            }//GEN-BEGIN:|7-commandAction|9|145-preAction
        } else if (displayable == LoadForm) {
            if (command == delComLoadF) {//GEN-END:|7-commandAction|9|145-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|10|145-postAction
                // write post-action user code here
                this.deleteWay();
            } else if (command == exitComLoadF) {//GEN-LINE:|7-commandAction|11|147-preAction
                // write pre-action user code here
                switchDisplayable(null, getNavi());//GEN-LINE:|7-commandAction|12|147-postAction
            // write post-action user code here
            } else if (command == loadComLoadF) {//GEN-LINE:|7-commandAction|13|141-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|14|141-postAction
                // write post-action user code here
                this.wayload = this.getLoadData().getString();
                this.waymanager();
                this.getLoadData().setString("0,0,0,0,N-0,0,0,0,E");
                this.getWay_name().setString("");
                // Podmínka pokud je zadán jen jeden bod neni treba vybirat ho
                if ((int) this.getWayList().getSelectedIndex() == 0) {
                    this.uploadWaypoint();
                }
            } else if (command == selComLoadF) {//GEN-LINE:|7-commandAction|15|210-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|16|210-postAction
                // write post-action user code here
                this.uploadWaypoint();
            }//GEN-BEGIN:|7-commandAction|17|15-preAction
        } else if (displayable == Menu) {
            if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|17|15-preAction
                // write pre-action user code here
                MenuAction();//GEN-LINE:|7-commandAction|18|15-postAction
            // write post-action user code here
            } else if (command == exitComMMenu) {//GEN-LINE:|7-commandAction|19|26-preAction
                // write pre-action user code here
                exitMIDlet();//GEN-LINE:|7-commandAction|20|26-postAction
            // write post-action user code here
            } else if (command == okComMMenu) {//GEN-LINE:|7-commandAction|21|35-preAction
                // write pre-action user code here
                MenuAction();
//GEN-LINE:|7-commandAction|22|35-postAction
            // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|23|86-preAction
        } else if (displayable == Navi) {
            if (command == exitComNavi) {//GEN-END:|7-commandAction|23|86-preAction
                // write pre-action user code here
                switchDisplayable(null, getMenu());//GEN-LINE:|7-commandAction|24|86-postAction
            // write post-action user code here
            } else if (command == okComKompNavi) {//GEN-LINE:|7-commandAction|25|124-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|26|124-postAction
                // write post-action user code here
                // Zobrazení plátna kompasu
                kompas = new Kompas(handler, this);
                switchDisplayable(null, kompas);
            } else if (command == okComLoadNavi) {//GEN-LINE:|7-commandAction|27|130-preAction
                // write pre-action user code here
                switchDisplayable(null, getLoadForm());//GEN-LINE:|7-commandAction|28|130-postAction
            // write post-action user code here
            } else if (command == okComNavigaNavi) {//GEN-LINE:|7-commandAction|29|126-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|30|126-postAction
                // write post-action user code here
                if (this.getWayList().size() != 0) {
                    navigation = new Navigation(this);
                    switchDisplayable(null, this.navigation);
                } else {
                    this.getInfo().setTimeout(3000);
                    this.getInfo().setString("Nemáte nadefinované žádné waypointy.");
                    this.switchDisplayable(null, this.getInfo());
                }
            } else if (command == okComStatNavi) {//GEN-LINE:|7-commandAction|31|133-preAction
                // write pre-action user code here
                switchDisplayable(null, getStatus());//GEN-LINE:|7-commandAction|32|133-postAction
                try {
                    // write post-action user code here
                    this.b.statusBTinfo();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            } else if (command == okGenInfoNavi) {//GEN-LINE:|7-commandAction|33|92-preAction
                // write pre-action user code here
                //this.genInfoShow();
                // Zobrazení plátna
                geninfo = new ShowInfo(this, handler);
                switchDisplayable(null, geninfo);
//GEN-LINE:|7-commandAction|34|92-postAction
            // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|35|120-preAction
        } else if (displayable == Satelite) {
            if (command == exitComSat) {//GEN-END:|7-commandAction|35|120-preAction
                // write pre-action user code here
                switchDisplayable(null, getMenu());//GEN-LINE:|7-commandAction|36|120-postAction
            // write post-action user code here
            } else if (command == okSatInfoComSat) {//GEN-LINE:|7-commandAction|37|173-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|38|173-postAction
                // write post-action user code here
                // Podrobné informace o družici
                this.satDetailInfoShow();
            }//GEN-BEGIN:|7-commandAction|39|150-preAction
        } else if (displayable == SaveForm) {
            if (command == exitComSaveF) {//GEN-END:|7-commandAction|39|150-preAction
                // write pre-action user code here
                switchDisplayable(null, getNavi());//GEN-LINE:|7-commandAction|40|150-postAction
                // write post-action user code here
                // Vymazani pameti instanci
                kompas = null;
                navigation = null;
                geninfo = null;
            } else if (command == saveComSaveF) {//GEN-LINE:|7-commandAction|41|152-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|42|152-postAction
                // write post-action user code here
                this.saveToFile();
            }//GEN-BEGIN:|7-commandAction|43|104-preAction
        } else if (displayable == Status) {
            if (command == disconnComStatus) {//GEN-END:|7-commandAction|43|104-preAction
                // write pre-action user code here
                try {
                    // write post-action user code here
                    this.b.disConnect();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
                switchDisplayable(null, getMenu());//GEN-LINE:|7-commandAction|44|104-postAction

            } else if (command == exitComStatus) {//GEN-LINE:|7-commandAction|45|107-preAction
                // write pre-action user code here
                switchDisplayable(null, getMenu());//GEN-LINE:|7-commandAction|46|107-postAction
            // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|47|19-preAction
        } else if (displayable == Welcome) {
            if (command == SplashScreen.DISMISS_COMMAND) {//GEN-END:|7-commandAction|47|19-preAction
                // write pre-action user code here
                switchDisplayable(null, getMenu());//GEN-LINE:|7-commandAction|48|19-postAction
            // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|49|7-postCommandAction
        }//GEN-END:|7-commandAction|49|7-postCommandAction
    // write post-action user code here
    }//GEN-BEGIN:|7-commandAction|50|
    //</editor-fold>//GEN-END:|7-commandAction|50|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: Menu ">//GEN-BEGIN:|13-getter|0|13-preInit
    /**
     * Returns an initiliazed instance of Menu component.
     * @return the initialized component instance
     */
    public List getMenu() {
        if (Menu == null) {//GEN-END:|13-getter|0|13-preInit
            // write pre-init user code here
            Menu = new List("Hlavn\u00ED menu", Choice.IMPLICIT);//GEN-BEGIN:|13-getter|1|13-postInit
            Menu.append("Navigace", getMNavi24());
            Menu.append("Satelity", getMSat24());
            Menu.append("P\u0159ipojen\u00ED", getMBT24());
            Menu.append("O Aplikaci", getMAbout24());
            Menu.addCommand(getExitComMMenu());
            Menu.addCommand(getOkComMMenu());
            Menu.setCommandListener(this);
            Menu.setFitPolicy(Choice.TEXT_WRAP_DEFAULT);
            Menu.setSelectedFlags(new boolean[] { false, false, false, false });//GEN-END:|13-getter|1|13-postInit
        // write post-init user code here
        }//GEN-BEGIN:|13-getter|2|
        return Menu;
    }
    //</editor-fold>//GEN-END:|13-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: MenuAction ">//GEN-BEGIN:|13-action|0|13-preAction
    /**
     * Performs an action assigned to the selected list element in the Menu component.
     */
    public void MenuAction() {//GEN-END:|13-action|0|13-preAction
        // enter pre-action user code here
        String __selectedString = getMenu().getString(getMenu().getSelectedIndex());//GEN-BEGIN:|13-action|1|108-preAction
        if (__selectedString != null) {
            if (__selectedString.equals("Navigace")) {//GEN-END:|13-action|1|108-preAction
                // write pre-action user code here
                switchDisplayable(null, getNavi());//GEN-LINE:|13-action|2|108-postAction
                // write post-action user code here
                this.naviInfo();
            } else if (__selectedString.equals("Satelity")) {//GEN-LINE:|13-action|3|114-preAction
                // write pre-action user code here
                switchDisplayable(null, getSatelite());//GEN-LINE:|13-action|4|114-postAction
                // write post-action user code here
                this.getChSat().deleteAll();
                this.satInfoShow();
            } else if (__selectedString.equals("P\u0159ipojen\u00ED")) {//GEN-LINE:|13-action|5|22-preAction
                // write pre-action user code here
                // Pokud neni pripojeno zarizeni prejde se na okno pro vyhledani zarizeni
                if (b.isConnect == false)
                    switchDisplayable(null, getConnecteddevice());//GEN-LINE:|13-action|6|22-postAction
                // write post-action user code here
                // Pokud je pripojeno zarizeni prejde se na okno status
                else
                    switchDisplayable(null, getStatus());
            } else if (__selectedString.equals("O Aplikaci")) {//GEN-LINE:|13-action|7|24-preAction
                // write pre-action user code here
                switchDisplayable(null, getAbout());//GEN-LINE:|13-action|8|24-postAction
            // write post-action user code here
            }//GEN-BEGIN:|13-action|9|13-postAction
        }//GEN-END:|13-action|9|13-postAction
    // enter post-action user code here
    }//GEN-BEGIN:|13-action|10|
    //</editor-fold>//GEN-END:|13-action|10|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: Welcome ">//GEN-BEGIN:|17-getter|0|17-preInit
    /**
     * Returns an initiliazed instance of Welcome component.
     * @return the initialized component instance
     */
    public SplashScreen getWelcome() {
        if (Welcome == null) {//GEN-END:|17-getter|0|17-preInit
            // write pre-init user code here
            Welcome = new SplashScreen(getDisplay());//GEN-BEGIN:|17-getter|1|17-postInit
            Welcome.setTitle("V\u00EDt\u00E1 V\u00E1s aplikace Navig\u00E1tor");
            Welcome.setCommandListener(this);
            Welcome.setFullScreenMode(true);
            Welcome.setImage(getSplash());
            Welcome.setText("Navig\u00E1tor");
            Welcome.setTimeout(2500);//GEN-END:|17-getter|1|17-postInit
        // write post-init user code here
        }//GEN-BEGIN:|17-getter|2|
        return Welcome;
    }
    //</editor-fold>//GEN-END:|17-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitComMMenu ">//GEN-BEGIN:|25-getter|0|25-preInit
    /**
     * Returns an initiliazed instance of exitComMMenu component.
     * @return the initialized component instance
     */
    public Command getExitComMMenu() {
        if (exitComMMenu == null) {//GEN-END:|25-getter|0|25-preInit
            // write pre-init user code here
            exitComMMenu = new Command("Konec", Command.EXIT, 0);//GEN-LINE:|25-getter|1|25-postInit
        // write post-init user code here
        }//GEN-BEGIN:|25-getter|2|
        return exitComMMenu;
    }
    //</editor-fold>//GEN-END:|25-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: Connecteddevice ">//GEN-BEGIN:|29-getter|0|29-preInit
    /**
     * Returns an initiliazed instance of Connecteddevice component.
     * @return the initialized component instance
     */
    public Form getConnecteddevice() {
        if (Connecteddevice == null) {//GEN-END:|29-getter|0|29-preInit
            // write pre-init user code here
            Connecteddevice = new Form(" GPS Bluetooth za\u0159\u00EDzen\u00ED", new Item[] { getChoosedevices() });//GEN-BEGIN:|29-getter|1|29-postInit
            Connecteddevice.addCommand(getExitComBDev());
            Connecteddevice.addCommand(getFindComBDev());
            Connecteddevice.addCommand(getConnComBDev());
            Connecteddevice.setCommandListener(this);//GEN-END:|29-getter|1|29-postInit
        // write post-init user code here
        }//GEN-BEGIN:|29-getter|2|
        return Connecteddevice;
    }
    //</editor-fold>//GEN-END:|29-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitComBDev ">//GEN-BEGIN:|31-getter|0|31-preInit
    /**
     * Returns an initiliazed instance of exitComBDev component.
     * @return the initialized component instance
     */
    public Command getExitComBDev() {
        if (exitComBDev == null) {//GEN-END:|31-getter|0|31-preInit
            // write pre-init user code here
            exitComBDev = new Command("Zav\u0159\u00EDt", Command.EXIT, 0);//GEN-LINE:|31-getter|1|31-postInit
        // write post-init user code here
        }//GEN-BEGIN:|31-getter|2|
        return exitComBDev;
    }
    //</editor-fold>//GEN-END:|31-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okComMMenu ">//GEN-BEGIN:|34-getter|0|34-preInit
    /**
     * Returns an initiliazed instance of okComMMenu component.
     * @return the initialized component instance
     */
    public Command getOkComMMenu() {
        if (okComMMenu == null) {//GEN-END:|34-getter|0|34-preInit
            // write pre-init user code here
            okComMMenu = new Command("Ok", Command.OK, 0);//GEN-LINE:|34-getter|1|34-postInit
        // write post-init user code here
        }//GEN-BEGIN:|34-getter|2|
        return okComMMenu;
    }
    //</editor-fold>//GEN-END:|34-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: choosedevices ">//GEN-BEGIN:|36-getter|0|36-preInit
    /**
     * Returns an initiliazed instance of choosedevices component.
     * @return the initialized component instance
     */
    public ChoiceGroup getChoosedevices() {
        if (choosedevices == null) {//GEN-END:|36-getter|0|36-preInit
            // write pre-init user code here
            choosedevices = new ChoiceGroup("GPS za\u0159\u00EDzen\u00ED v dosahu", Choice.EXCLUSIVE);//GEN-BEGIN:|36-getter|1|36-postInit
            choosedevices.setSelectedFlags(new boolean[] {  });//GEN-END:|36-getter|1|36-postInit
        // write post-init user code here
        }//GEN-BEGIN:|36-getter|2|
        return choosedevices;
    }
    //</editor-fold>//GEN-END:|36-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: findComBDev ">//GEN-BEGIN:|41-getter|0|41-preInit
    /**
     * Returns an initiliazed instance of findComBDev component.
     * @return the initialized component instance
     */
    public Command getFindComBDev() {
        if (findComBDev == null) {//GEN-END:|41-getter|0|41-preInit
            // write pre-init user code here
            findComBDev = new Command("Vyhledej", Command.OK, 0);//GEN-LINE:|41-getter|1|41-postInit

        }//GEN-BEGIN:|41-getter|2|
        return findComBDev;
    }
    //</editor-fold>//GEN-END:|41-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancelCommand ">//GEN-BEGIN:|45-getter|0|45-preInit
    /**
     * Returns an initiliazed instance of cancelCommand component.
     * @return the initialized component instance
     */
    public Command getCancelCommand() {
        if (cancelCommand == null) {//GEN-END:|45-getter|0|45-preInit
            // write pre-init user code here
            cancelCommand = new Command("Cancel", Command.CANCEL, 0);//GEN-LINE:|45-getter|1|45-postInit
        // write post-init user code here
        }//GEN-BEGIN:|45-getter|2|
        return cancelCommand;
    }
    //</editor-fold>//GEN-END:|45-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: connComBDev ">//GEN-BEGIN:|51-getter|0|51-preInit
    /**
     * Returns an initiliazed instance of connComBDev component.
     * @return the initialized component instance
     */
    public Command getConnComBDev() {
        if (connComBDev == null) {//GEN-END:|51-getter|0|51-preInit
            // write pre-init user code here
            connComBDev = new Command("P\u0159ipoj", Command.ITEM, 1);//GEN-LINE:|51-getter|1|51-postInit
        // write post-init user code here
        }//GEN-BEGIN:|51-getter|2|
        return connComBDev;
    }
    //</editor-fold>//GEN-END:|51-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: Navi ">//GEN-BEGIN:|83-getter|0|83-preInit
    /**
     * Returns an initiliazed instance of Navi component.
     * @return the initialized component instance
     */
    public Form getNavi() {
        if (Navi == null) {//GEN-END:|83-getter|0|83-preInit
            // write pre-init user code here
            Navi = new Form("Obecn\u00E9 informace", new Item[] { });//GEN-BEGIN:|83-getter|1|83-postInit
            Navi.addCommand(getExitComNavi());
            Navi.addCommand(getOkGenInfoNavi());
            Navi.addCommand(getOkComKompNavi());
            Navi.addCommand(getOkComNavigaNavi());
            Navi.addCommand(getOkComLoadNavi());
            Navi.addCommand(getOkComStatNavi());
            Navi.setCommandListener(this);//GEN-END:|83-getter|1|83-postInit
        // write post-init user code here
            // Info neni pripojene zadne BT zarizeni
                if (this.b.isConnect == false) {
                    this.getInfo().setTimeout(2000);
                    this.getInfo().setString("Není připojeno žádné GPS zařízení");
                    this.switchDisplayable(null, this.getInfo());
                }
        }//GEN-BEGIN:|83-getter|2|
        return Navi;
    }
    //</editor-fold>//GEN-END:|83-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitComNavi ">//GEN-BEGIN:|85-getter|0|85-preInit
    /**
     * Returns an initiliazed instance of exitComNavi component.
     * @return the initialized component instance
     */
    public Command getExitComNavi() {
        if (exitComNavi == null) {//GEN-END:|85-getter|0|85-preInit
            // write pre-init user code here
            exitComNavi = new Command("Menu", Command.EXIT, 0);//GEN-LINE:|85-getter|1|85-postInit
        // write post-init user code here
        }//GEN-BEGIN:|85-getter|2|
        return exitComNavi;
    }
    //</editor-fold>//GEN-END:|85-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okGenInfoNavi ">//GEN-BEGIN:|91-getter|0|91-preInit
    /**
     * Returns an initiliazed instance of okGenInfoNavi component.
     * @return the initialized component instance
     */
    public Command getOkGenInfoNavi() {
        if (okGenInfoNavi == null) {//GEN-END:|91-getter|0|91-preInit
            // write pre-init user code here
            okGenInfoNavi = new Command("Obecn\u00E9 informace", Command.OK, 0);//GEN-LINE:|91-getter|1|91-postInit
        // write post-init user code here
        }//GEN-BEGIN:|91-getter|2|
        return okGenInfoNavi;
    }
    //</editor-fold>//GEN-END:|91-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: info ">//GEN-BEGIN:|93-getter|0|93-preInit
    /**
     * Returns an initiliazed instance of info component.
     * @return the initialized component instance
     */
    public Alert getInfo() {
        if (info == null) {//GEN-END:|93-getter|0|93-preInit
            // write pre-init user code here
            info = new Alert("Info", "", null, AlertType.INFO);//GEN-BEGIN:|93-getter|1|93-postInit
            info.setTimeout(4000);//GEN-END:|93-getter|1|93-postInit
        // write post-init user code here
        }//GEN-BEGIN:|93-getter|2|
        return info;
    }
    //</editor-fold>//GEN-END:|93-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: About ">//GEN-BEGIN:|94-getter|0|94-preInit
    /**
     * Returns an initiliazed instance of About component.
     * @return the initialized component instance
     */
    public Form getAbout() {
        if (About == null) {//GEN-END:|94-getter|0|94-preInit
            // write pre-init user code here
            About = new Form("Navigator", new Item[] { getStringItem() });//GEN-BEGIN:|94-getter|1|94-postInit
            About.addCommand(getExitComAbout());
            About.setCommandListener(this);//GEN-END:|94-getter|1|94-postInit
        // write post-init user code here
        }//GEN-BEGIN:|94-getter|2|
        return About;
    }
    //</editor-fold>//GEN-END:|94-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem ">//GEN-BEGIN:|99-getter|0|99-preInit
    /**
     * Returns an initiliazed instance of stringItem component.
     * @return the initialized component instance
     */
    public StringItem getStringItem() {
        if (stringItem == null) {//GEN-END:|99-getter|0|99-preInit
            // write pre-init user code here
            stringItem = new StringItem("O Aplikaci", "MIDlet slou\u017E\u00ED pro ur\u010Den\u00ED \naktu\u00E1ln\u00ED polohy. Rovn\u011B\u017E\numo\u017E\u0148uje navigov\u00E1n\u00ED k \ndefinovan\u00E9mu bodu.\n\nMIDlet:\tNavig\u00E1tor\nAutor:   \tRadek Figurny\nVerze:\t1.0\nCLDC:\t1.1\nMIDP:\t2.0", Item.PLAIN);//GEN-BEGIN:|99-getter|1|99-postInit
            stringItem.setLayout(ImageItem.LAYOUT_DEFAULT);//GEN-END:|99-getter|1|99-postInit
        // write post-init user code here
        }//GEN-BEGIN:|99-getter|2|
        return stringItem;
    }
    //</editor-fold>//GEN-END:|99-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitComAbout ">//GEN-BEGIN:|95-getter|0|95-preInit
    /**
     * Returns an initiliazed instance of exitComAbout component.
     * @return the initialized component instance
     */
    public Command getExitComAbout() {
        if (exitComAbout == null) {//GEN-END:|95-getter|0|95-preInit
            // write pre-init user code here
            exitComAbout = new Command("Zp\u011Bt", Command.BACK, 0);//GEN-LINE:|95-getter|1|95-postInit
        // write post-init user code here
        }//GEN-BEGIN:|95-getter|2|
        return exitComAbout;
    }
    //</editor-fold>//GEN-END:|95-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: Status ">//GEN-BEGIN:|102-getter|0|102-preInit
    /**
     * Returns an initiliazed instance of Status component.
     * @return the initialized component instance
     */
    public Form getStatus() {
        if (Status == null) {//GEN-END:|102-getter|0|102-preInit
            // write pre-init user code here
            Status = new Form("Stav spojen\u00ED");//GEN-BEGIN:|102-getter|1|102-postInit
            Status.addCommand(getDisconnComStatus());
            Status.addCommand(getExitComStatus());
            Status.setCommandListener(this);//GEN-END:|102-getter|1|102-postInit
        // write post-init user code here
        }//GEN-BEGIN:|102-getter|2|
        return Status;
    }
    //</editor-fold>//GEN-END:|102-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: disconnComStatus ">//GEN-BEGIN:|103-getter|0|103-preInit
    /**
     * Returns an initiliazed instance of disconnComStatus component.
     * @return the initialized component instance
     */
    public Command getDisconnComStatus() {
        if (disconnComStatus == null) {//GEN-END:|103-getter|0|103-preInit
            // write pre-init user code here
            disconnComStatus = new Command("Odpoj", Command.EXIT, 0);//GEN-LINE:|103-getter|1|103-postInit
        // write post-init user code here
        }//GEN-BEGIN:|103-getter|2|
        return disconnComStatus;
    }
    //</editor-fold>//GEN-END:|103-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitComStatus ">//GEN-BEGIN:|106-getter|0|106-preInit
    /**
     * Returns an initiliazed instance of exitComStatus component.
     * @return the initialized component instance
     */
    public Command getExitComStatus() {
        if (exitComStatus == null) {//GEN-END:|106-getter|0|106-preInit
            // write pre-init user code here
            exitComStatus = new Command("Ok", Command.OK, 0);//GEN-LINE:|106-getter|1|106-postInit
        // write post-init user code here
        }//GEN-BEGIN:|106-getter|2|
        return exitComStatus;
    }
    //</editor-fold>//GEN-END:|106-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: Satelite ">//GEN-BEGIN:|116-getter|0|116-preInit
    /**
     * Returns an initiliazed instance of Satelite component.
     * @return the initialized component instance
     */
    public Form getSatelite() {
        if (Satelite == null) {//GEN-END:|116-getter|0|116-preInit
            // write pre-init user code here
            Satelite = new Form("Satelity", new Item[] { getChSat() });//GEN-BEGIN:|116-getter|1|116-postInit
            Satelite.addCommand(getExitComSat());
            Satelite.addCommand(getOkSatInfoComSat());
            Satelite.setCommandListener(this);//GEN-END:|116-getter|1|116-postInit
        // write post-init user code here
        }//GEN-BEGIN:|116-getter|2|
        return Satelite;
    }
    //</editor-fold>//GEN-END:|116-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitComSat ">//GEN-BEGIN:|119-getter|0|119-preInit
    /**
     * Returns an initiliazed instance of exitComSat component.
     * @return the initialized component instance
     */
    public Command getExitComSat() {
        if (exitComSat == null) {//GEN-END:|119-getter|0|119-preInit
            // write pre-init user code here
            exitComSat = new Command("Zp\u011Bt", Command.EXIT, 0);//GEN-LINE:|119-getter|1|119-postInit
        // write post-init user code here
        }//GEN-BEGIN:|119-getter|2|
        return exitComSat;
    }
    //</editor-fold>//GEN-END:|119-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okComKompNavi ">//GEN-BEGIN:|123-getter|0|123-preInit
    /**
     * Returns an initiliazed instance of okComKompNavi component.
     * @return the initialized component instance
     */
    public Command getOkComKompNavi() {
        if (okComKompNavi == null) {//GEN-END:|123-getter|0|123-preInit
            // write pre-init user code here
            okComKompNavi = new Command("Kompas", Command.OK, 0);//GEN-LINE:|123-getter|1|123-postInit
        // write post-init user code here
        }//GEN-BEGIN:|123-getter|2|
        return okComKompNavi;
    }
    //</editor-fold>//GEN-END:|123-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okComNavigaNavi ">//GEN-BEGIN:|125-getter|0|125-preInit
    /**
     * Returns an initiliazed instance of okComNavigaNavi component.
     * @return the initialized component instance
     */
    public Command getOkComNavigaNavi() {
        if (okComNavigaNavi == null) {//GEN-END:|125-getter|0|125-preInit
            // write pre-init user code here
            okComNavigaNavi = new Command("Navigov\u00E1n\u00ED", Command.OK, 0);//GEN-LINE:|125-getter|1|125-postInit
        // write post-init user code here
        }//GEN-BEGIN:|125-getter|2|
        return okComNavigaNavi;
    }
    //</editor-fold>//GEN-END:|125-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okComSaveNavi ">//GEN-BEGIN:|127-getter|0|127-preInit
    /**
     * Returns an initiliazed instance of okComSaveNavi component.
     * @return the initialized component instance
     */
    public Command getOkComSaveNavi() {
        if (okComSaveNavi == null) {//GEN-END:|127-getter|0|127-preInit
            // write pre-init user code here
            okComSaveNavi = new Command("Ulo\u017E pozici", Command.OK, 0);//GEN-LINE:|127-getter|1|127-postInit
        // write post-init user code here
        }//GEN-BEGIN:|127-getter|2|
        return okComSaveNavi;
    }
    //</editor-fold>//GEN-END:|127-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okComLoadNavi ">//GEN-BEGIN:|129-getter|0|129-preInit
    /**
     * Returns an initiliazed instance of okComLoadNavi component.
     * @return the initialized component instance
     */
    public Command getOkComLoadNavi() {
        if (okComLoadNavi == null) {//GEN-END:|129-getter|0|129-preInit
            // write pre-init user code here
            okComLoadNavi = new Command("Definuj pozici", Command.OK, 0);//GEN-LINE:|129-getter|1|129-postInit
        // write post-init user code here
        }//GEN-BEGIN:|129-getter|2|
        return okComLoadNavi;
    }
    //</editor-fold>//GEN-END:|129-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okComStatNavi ">//GEN-BEGIN:|132-getter|0|132-preInit
    /**
     * Returns an initiliazed instance of okComStatNavi component.
     * @return the initialized component instance
     */
    public Command getOkComStatNavi() {
        if (okComStatNavi == null) {//GEN-END:|132-getter|0|132-preInit
            // write pre-init user code here
            okComStatNavi = new Command("Stav", Command.OK, 0);//GEN-LINE:|132-getter|1|132-postInit
        // write post-init user code here
        }//GEN-BEGIN:|132-getter|2|
        return okComStatNavi;
    }
    //</editor-fold>//GEN-END:|132-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okComMemNavi ">//GEN-BEGIN:|134-getter|0|134-preInit
    /**
     * Returns an initiliazed instance of okComMemNavi component.
     * @return the initialized component instance
     */
    public Command getOkComMemNavi() {
        if (okComMemNavi == null) {//GEN-END:|134-getter|0|134-preInit
            // write pre-init user code here
            okComMemNavi = new Command("Pam\u011Bt pozic", Command.OK, 0);//GEN-LINE:|134-getter|1|134-postInit
        // write post-init user code here
        }//GEN-BEGIN:|134-getter|2|
        return okComMemNavi;
    }
    //</editor-fold>//GEN-END:|134-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: SaveForm ">//GEN-BEGIN:|136-getter|0|136-preInit
    /**
     * Returns an initiliazed instance of SaveForm component.
     * @return the initialized component instance
     */
    public Form getSaveForm() {
        if (SaveForm == null) {//GEN-END:|136-getter|0|136-preInit
            // write pre-init user code here
            SaveForm = new Form("Ulo\u017E pozici", new Item[] { getSaveTextBox(), getMem_choice() });//GEN-BEGIN:|136-getter|1|136-postInit
            SaveForm.addCommand(getExitComSaveF());
            SaveForm.addCommand(getSaveComSaveF());
            SaveForm.setCommandListener(this);//GEN-END:|136-getter|1|136-postInit
        // write post-init user code here
        }//GEN-BEGIN:|136-getter|2|
        return SaveForm;
    }
    //</editor-fold>//GEN-END:|136-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: LoadForm ">//GEN-BEGIN:|138-getter|0|138-preInit
    /**
     * Returns an initiliazed instance of LoadForm component.
     * @return the initialized component instance
     */
    public Form getLoadForm() {
        if (LoadForm == null) {//GEN-END:|138-getter|0|138-preInit
            // write pre-init user code here
            LoadForm = new Form("Waypointy", new Item[] { getWay_name(), getLoadData(), getWayList() });//GEN-BEGIN:|138-getter|1|138-postInit
            LoadForm.addCommand(getLoadComLoadF());
            LoadForm.addCommand(getDelComLoadF());
            LoadForm.addCommand(getExitComLoadF());
            LoadForm.addCommand(getSelComLoadF());
            LoadForm.setCommandListener(this);//GEN-END:|138-getter|1|138-postInit
        // write post-init user code here
        }//GEN-BEGIN:|138-getter|2|
        return LoadForm;
    }
    //</editor-fold>//GEN-END:|138-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: loadComLoadF ">//GEN-BEGIN:|140-getter|0|140-preInit
    /**
     * Returns an initiliazed instance of loadComLoadF component.
     * @return the initialized component instance
     */
    public Command getLoadComLoadF() {
        if (loadComLoadF == null) {//GEN-END:|140-getter|0|140-preInit
            // write pre-init user code here
            loadComLoadF = new Command("P\u0159idej", Command.OK, 0);//GEN-LINE:|140-getter|1|140-postInit
        // write post-init user code here
        }//GEN-BEGIN:|140-getter|2|
        return loadComLoadF;
    }
    //</editor-fold>//GEN-END:|140-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: itemCommand ">//GEN-BEGIN:|142-getter|0|142-preInit
    /**
     * Returns an initiliazed instance of itemCommand component.
     * @return the initialized component instance
     */
    public Command getItemCommand() {
        if (itemCommand == null) {//GEN-END:|142-getter|0|142-preInit
            // write pre-init user code here
            itemCommand = new Command("Item", Command.ITEM, 0);//GEN-LINE:|142-getter|1|142-postInit
        // write post-init user code here
        }//GEN-BEGIN:|142-getter|2|
        return itemCommand;
    }
    //</editor-fold>//GEN-END:|142-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: delComLoadF ">//GEN-BEGIN:|144-getter|0|144-preInit
    /**
     * Returns an initiliazed instance of delComLoadF component.
     * @return the initialized component instance
     */
    public Command getDelComLoadF() {
        if (delComLoadF == null) {//GEN-END:|144-getter|0|144-preInit
            // write pre-init user code here
            delComLoadF = new Command("Sma\u017E", Command.OK, 0);//GEN-LINE:|144-getter|1|144-postInit
        // write post-init user code here
        }//GEN-BEGIN:|144-getter|2|
        return delComLoadF;
    }
    //</editor-fold>//GEN-END:|144-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitComLoadF ">//GEN-BEGIN:|146-getter|0|146-preInit
    /**
     * Returns an initiliazed instance of exitComLoadF component.
     * @return the initialized component instance
     */
    public Command getExitComLoadF() {
        if (exitComLoadF == null) {//GEN-END:|146-getter|0|146-preInit
            // write pre-init user code here
            exitComLoadF = new Command("Zp\u011Bt", Command.EXIT, 0);//GEN-LINE:|146-getter|1|146-postInit
        // write post-init user code here
        }//GEN-BEGIN:|146-getter|2|
        return exitComLoadF;
    }
    //</editor-fold>//GEN-END:|146-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitComSaveF ">//GEN-BEGIN:|149-getter|0|149-preInit
    /**
     * Returns an initiliazed instance of exitComSaveF component.
     * @return the initialized component instance
     */
    public Command getExitComSaveF() {
        if (exitComSaveF == null) {//GEN-END:|149-getter|0|149-preInit
            // write pre-init user code here
            exitComSaveF = new Command("Zp\u011Bt", Command.EXIT, 0);//GEN-LINE:|149-getter|1|149-postInit
        // write post-init user code here
        }//GEN-BEGIN:|149-getter|2|
        return exitComSaveF;
    }
    //</editor-fold>//GEN-END:|149-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: saveComSaveF ">//GEN-BEGIN:|151-getter|0|151-preInit
    /**
     * Returns an initiliazed instance of saveComSaveF component.
     * @return the initialized component instance
     */
    public Command getSaveComSaveF() {
        if (saveComSaveF == null) {//GEN-END:|151-getter|0|151-preInit
            // write pre-init user code here
            saveComSaveF = new Command("Ulo\u017E", Command.OK, 0);//GEN-LINE:|151-getter|1|151-postInit
        // write post-init user code here
        }//GEN-BEGIN:|151-getter|2|
        return saveComSaveF;
    }
    //</editor-fold>//GEN-END:|151-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: loadData ">//GEN-BEGIN:|155-getter|0|155-preInit
    /**
     * Returns an initiliazed instance of loadData component.
     * @return the initialized component instance
     */
    public TextField getLoadData() {
        if (loadData == null) {//GEN-END:|155-getter|0|155-preInit
            // write pre-init user code here
            loadData = new TextField("Zadej sou\u0159adnice bodu", "49,13,52,74,N-16,34,13,53,E", 28, TextField.ANY);//GEN-BEGIN:|155-getter|1|155-postInit
            loadData.setInitialInputMode("UCB_BASIC_LATIN");//GEN-END:|155-getter|1|155-postInit
        // write post-init user code here
        }//GEN-BEGIN:|155-getter|2|
        return loadData;
    }
    //</editor-fold>//GEN-END:|155-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: splash ">//GEN-BEGIN:|160-getter|0|160-preInit
    /**
     * Returns an initiliazed instance of splash component.
     * @return the initialized component instance
     */
    public Image getSplash() {
        if (splash == null) {//GEN-END:|160-getter|0|160-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|160-getter|1|160-@java.io.IOException
                splash = Image.createImage("/img/splash.png");
            } catch (java.io.IOException e) {//GEN-END:|160-getter|1|160-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|160-getter|2|160-postInit
        // write post-init user code here
        }//GEN-BEGIN:|160-getter|3|
        return splash;
    }
    //</editor-fold>//GEN-END:|160-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: mSat24 ">//GEN-BEGIN:|162-getter|0|162-preInit
    /**
     * Returns an initiliazed instance of mSat24 component.
     * @return the initialized component instance
     */
    public Image getMSat24() {
        if (mSat24 == null) {//GEN-END:|162-getter|0|162-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|162-getter|1|162-@java.io.IOException
                mSat24 = Image.createImage("/img/mSat24.png");
            } catch (java.io.IOException e) {//GEN-END:|162-getter|1|162-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|162-getter|2|162-postInit
        // write post-init user code here
        }//GEN-BEGIN:|162-getter|3|
        return mSat24;
    }
    //</editor-fold>//GEN-END:|162-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: icon ">//GEN-BEGIN:|163-getter|0|163-preInit
    /**
     * Returns an initiliazed instance of icon component.
     * @return the initialized component instance
     */
    public Image getIcon() {
        if (icon == null) {//GEN-END:|163-getter|0|163-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|163-getter|1|163-@java.io.IOException
                icon = Image.createImage("/img/icon.png");
            } catch (java.io.IOException e) {//GEN-END:|163-getter|1|163-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|163-getter|2|163-postInit
        // write post-init user code here
        }//GEN-BEGIN:|163-getter|3|
        return icon;
    }
    //</editor-fold>//GEN-END:|163-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: mBT24 ">//GEN-BEGIN:|165-getter|0|165-preInit
    /**
     * Returns an initiliazed instance of mBT24 component.
     * @return the initialized component instance
     */
    public Image getMBT24() {
        if (mBT24 == null) {//GEN-END:|165-getter|0|165-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|165-getter|1|165-@java.io.IOException
                mBT24 = Image.createImage("/img/mBT24.png");
            } catch (java.io.IOException e) {//GEN-END:|165-getter|1|165-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|165-getter|2|165-postInit
        // write post-init user code here
        }//GEN-BEGIN:|165-getter|3|
        return mBT24;
    }
    //</editor-fold>//GEN-END:|165-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: mAbout24 ">//GEN-BEGIN:|166-getter|0|166-preInit
    /**
     * Returns an initiliazed instance of mAbout24 component.
     * @return the initialized component instance
     */
    public Image getMAbout24() {
        if (mAbout24 == null) {//GEN-END:|166-getter|0|166-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|166-getter|1|166-@java.io.IOException
                mAbout24 = Image.createImage("/img/mAbout24.png");
            } catch (java.io.IOException e) {//GEN-END:|166-getter|1|166-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|166-getter|2|166-postInit
        // write post-init user code here
        }//GEN-BEGIN:|166-getter|3|
        return mAbout24;
    }
    //</editor-fold>//GEN-END:|166-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: mNavi24 ">//GEN-BEGIN:|167-getter|0|167-preInit
    /**
     * Returns an initiliazed instance of mNavi24 component.
     * @return the initialized component instance
     */
    public Image getMNavi24() {
        if (mNavi24 == null) {//GEN-END:|167-getter|0|167-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|167-getter|1|167-@java.io.IOException
                mNavi24 = Image.createImage("/img/mNavi24.png");
            } catch (java.io.IOException e) {//GEN-END:|167-getter|1|167-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|167-getter|2|167-postInit
        // write post-init user code here
        }//GEN-BEGIN:|167-getter|3|
        return mNavi24;
    }
    //</editor-fold>//GEN-END:|167-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: chSat ">//GEN-BEGIN:|171-getter|0|171-preInit
    /**
     * Returns an initiliazed instance of chSat component.
     * @return the initialized component instance
     */
    public ChoiceGroup getChSat() {
        if (chSat == null) {//GEN-END:|171-getter|0|171-preInit
            // write pre-init user code here
            chSat = new ChoiceGroup("", Choice.EXCLUSIVE);//GEN-BEGIN:|171-getter|1|171-postInit
            chSat.setFitPolicy(Choice.TEXT_WRAP_DEFAULT);
            chSat.setSelectedFlags(new boolean[] {  });//GEN-END:|171-getter|1|171-postInit
        // write post-init user code here
        }//GEN-BEGIN:|171-getter|2|
        return chSat;
    }
    //</editor-fold>//GEN-END:|171-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okSatInfoComSat ">//GEN-BEGIN:|172-getter|0|172-preInit
    /**
     * Returns an initiliazed instance of okSatInfoComSat component.
     * @return the initialized component instance
     */
    public Command getOkSatInfoComSat() {
        if (okSatInfoComSat == null) {//GEN-END:|172-getter|0|172-preInit
            // write pre-init user code here
            okSatInfoComSat = new Command("Info", Command.OK, 0);//GEN-LINE:|172-getter|1|172-postInit
        // write post-init user code here
        }//GEN-BEGIN:|172-getter|2|
        return okSatInfoComSat;
    }
    //</editor-fold>//GEN-END:|172-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand ">//GEN-BEGIN:|185-getter|0|185-preInit
    /**
     * Returns an initiliazed instance of backCommand component.
     * @return the initialized component instance
     */
    public Command getBackCommand() {
        if (backCommand == null) {//GEN-END:|185-getter|0|185-preInit
            // write pre-init user code here
            backCommand = new Command("Back", Command.BACK, 0);//GEN-LINE:|185-getter|1|185-postInit
        // write post-init user code here
        }//GEN-BEGIN:|185-getter|2|
        return backCommand;
    }
    //</editor-fold>//GEN-END:|185-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: svgNavi1 ">//GEN-BEGIN:|197-getter|0|197-preInit
    /**
     * Returns an initiliazed instance of svgNavi1 component.
     * @return the initialized component instance
     */
    public SVGImage getSvgNavi1() {
        if (svgNavi1 == null) {//GEN-END:|197-getter|0|197-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|197-getter|1|197-@java.io.IOException
                svgNavi1 = (SVGImage) SVGImage.createImage(getClass().getResourceAsStream("/img/navi.svg"), null);
            } catch (java.io.IOException e) {//GEN-END:|197-getter|1|197-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|197-getter|2|197-postInit
        // write post-init user code here
        }//GEN-BEGIN:|197-getter|3|
        return svgNavi1;
    }
    //</editor-fold>//GEN-END:|197-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: wayList ">//GEN-BEGIN:|208-getter|0|208-preInit
    /**
     * Returns an initiliazed instance of wayList component.
     * @return the initialized component instance
     */
    public ChoiceGroup getWayList() {
        if (wayList == null) {//GEN-END:|208-getter|0|208-preInit
            // write pre-init user code here
            wayList = new ChoiceGroup("Seznam definovan\u00FDch bod\u016F", Choice.EXCLUSIVE);//GEN-BEGIN:|208-getter|1|208-postInit
            wayList.setFitPolicy(Choice.TEXT_WRAP_OFF);//GEN-END:|208-getter|1|208-postInit
        // write post-init user code here
        }//GEN-BEGIN:|208-getter|2|
        return wayList;
    }
    //</editor-fold>//GEN-END:|208-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: selComLoadF ">//GEN-BEGIN:|209-getter|0|209-preInit
    /**
     * Returns an initiliazed instance of selComLoadF component.
     * @return the initialized component instance
     */
    public Command getSelComLoadF() {
        if (selComLoadF == null) {//GEN-END:|209-getter|0|209-preInit
            // write pre-init user code here
            selComLoadF = new Command("Vyber", Command.ITEM, 0);//GEN-LINE:|209-getter|1|209-postInit
        // write post-init user code here
        }//GEN-BEGIN:|209-getter|2|
        return selComLoadF;
    }
    //</editor-fold>//GEN-END:|209-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: saveTextBox ">//GEN-BEGIN:|211-getter|0|211-preInit
    /**
     * Returns an initiliazed instance of saveTextBox component.
     * @return the initialized component instance
     */
    public TextField getSaveTextBox() {
        if (saveTextBox == null) {//GEN-END:|211-getter|0|211-preInit
            // write pre-init user code here
            saveTextBox = new TextField("Zde vlo\u017Ete textovou informaci k ukl\u00E1d\u00E1n\u00E9 pozici", "", 100, TextField.ANY);//GEN-BEGIN:|211-getter|1|211-postInit
            saveTextBox.setLayout(ImageItem.LAYOUT_DEFAULT | Item.LAYOUT_VEXPAND | Item.LAYOUT_2);//GEN-END:|211-getter|1|211-postInit
        // write post-init user code here
        }//GEN-BEGIN:|211-getter|2|
        return saveTextBox;
    }
    //</editor-fold>//GEN-END:|211-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: GPSdata ">//GEN-BEGIN:|220-getter|0|220-preInit
    /**
     * Returns an initiliazed instance of GPSdata component.
     * @return the initialized component instance
     */
    public Font getGPSdata() {
        if (GPSdata == null) {//GEN-END:|220-getter|0|220-preInit
            // write pre-init user code here
            GPSdata = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_LARGE);//GEN-LINE:|220-getter|1|220-postInit
        // write post-init user code here
        }//GEN-BEGIN:|220-getter|2|
        return GPSdata;
    }
    //</editor-fold>//GEN-END:|220-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: Popis ">//GEN-BEGIN:|221-getter|0|221-preInit
    /**
     * Returns an initiliazed instance of Popis component.
     * @return the initialized component instance
     */
    public Font getPopis() {
        if (Popis == null) {//GEN-END:|221-getter|0|221-preInit
            // write pre-init user code here
            Popis = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);//GEN-LINE:|221-getter|1|221-postInit
        // write post-init user code here
        }//GEN-BEGIN:|221-getter|2|
        return Popis;
    }
    //</editor-fold>//GEN-END:|221-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: mem_choice ">//GEN-BEGIN:|222-getter|0|222-preInit
    /**
     * Returns an initiliazed instance of mem_choice component.
     * @return the initialized component instance
     */
    public ChoiceGroup getMem_choice() {
        if (mem_choice == null) {//GEN-END:|222-getter|0|222-preInit
            // write pre-init user code here
            mem_choice = new ChoiceGroup("M\u00EDsto ulo\u017Een\u00ED", Choice.EXCLUSIVE);//GEN-BEGIN:|222-getter|1|222-postInit
            mem_choice.append("Pam\u011B\u0165 telefonu", null);
            mem_choice.append("Pam\u011B\u0165ov\u00E1 karta", null);
            mem_choice.setSelectedFlags(new boolean[] { false, true });
            mem_choice.setFont(0, null);
            mem_choice.setFont(1, null);//GEN-END:|222-getter|1|222-postInit
        // write post-init user code here
        }//GEN-BEGIN:|222-getter|2|
        return mem_choice;
    }
    //</editor-fold>//GEN-END:|222-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: way_name ">//GEN-BEGIN:|225-getter|0|225-preInit
    /**
     * Returns an initiliazed instance of way_name component.
     * @return the initialized component instance
     */
    public TextField getWay_name() {
        if (way_name == null) {//GEN-END:|225-getter|0|225-preInit
            // write pre-init user code here
            way_name = new TextField("N\u00E1zev bodu", "", 10, TextField.ANY);//GEN-LINE:|225-getter|1|225-postInit
        // write post-init user code here
        }//GEN-BEGIN:|225-getter|2|
        return way_name;
    }
    //</editor-fold>//GEN-END:|225-getter|2|

    /**
     * Returns a display instance.
     * @return the display instance.
     */
    public Display getDisplay() {
        return Display.getDisplay(this);
    }

    /**
     * Exits MIDlet.
     */
    public void exitMIDlet() {
        switchDisplayable(null, null);
        destroyApp(true);
        notifyDestroyed();
    }

    /**
     * Called when MIDlet is started.
     * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
     */
    public void startApp() {
        if (midletPaused) {
            resumeMIDlet();
        } else {
            initialize();
            startMIDlet();
        }
        midletPaused = false;
    }

    /**
     * Called when MIDlet is paused.
     */
    public void pauseApp() {
        midletPaused = true;
    }

    public void destroyApp(boolean unconditional) {
    }
    /**
     * Called to signal the MIDlet to terminate.
     * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
     */
    public boolean InfoRun = false;
    public int savecount = 1;
    /*---------------------------------------------------
     *                Instance tříd
     * ------------------------------------------------*/
    DataHandler handler = new DataHandler();
    Bluetooth b = new Bluetooth(this, handler);
    GpsStreamReader greader = new GpsStreamReader("greader", handler, this);
    NmeaParser gparser = new NmeaParser("gparser", handler, this);
    // Instance platen
    Kompas kompas;
    Navigation navigation;
    ShowInfo geninfo;

    /*---------------------------------------------------
     *                  Metody
     * ------------------------------------------------*/
    public synchronized void sync() throws InterruptedException {
        if (b.getIsConnect() == true) {
            greader.start();
            gparser.start();
        }
    }

    /*--------------------------------------------------------------------------
     *
     *                              Stav družic
     *
     * -----------------------------------------------------------------------*/
    private void satInfoShow() {
        for (int i = 0; i < 12; i++) {
            if (handler.getSat()[i][0] != 0) {
                this.chSat.append("SVN " + handler.getSat()[i][0] + "     " + handler.getSat()[i][3] + "dB", getMSat24());
            }
        }
    }

    private void satDetailInfoShow() {
        int selected = this.chSat.getSelectedIndex();
        if (selected != -1) {
            this.getInfo().setTimeout(-2);
            this.getInfo().setString("SVN......... " + handler.getSat()[selected][0] + "\nElevace.... " + handler.getSat()[selected][1] + "\nAzimut...... " + handler.getSat()[selected][2] + "\nS/N........... " + handler.getSat()[selected][3]);
            switchDisplayable(null, getInfo());
        } else {
            this.getInfo().setTimeout(4000);
            this.getInfo().setString("V seznamu nejsou žádné družice.");
            switchDisplayable(null, getInfo());
        }
    }
    /*----------------------------------------------------
     *
     *              Waypoint manager
     *
     * --------------------------------------------------*/
    private String wayload = null;
    public short findlongitude[] = new short[4];
    public short findlatitude[] = new short[4];
    public String fNS = null;
    public String fWE = null;

    public synchronized void waymanager() {
        String data = wayload;
        int e = 0;
        short tmplongitude[] = new short[4];
        short tmplatitude[] = new short[4];
        String tmpNS = null;
        String tmpWE = null;
        for (int i = 0; i < 4; i++) {
            e = data.indexOf(",");
            tmplatitude[i] = (short) Float.parseFloat(data.substring(0, e));
            data = data.substring(e + 1, data.length());
        }
        tmpNS = data.substring(0, 1);
        data = data.substring(e, data.length());
        for (int i = 0; i < 4; i++) {
            e = data.indexOf(",");
            tmplongitude[i] = (short) Float.parseFloat(data.substring(0, e));
            data = data.substring(e + 1, data.length());
        }
        tmpWE = data.substring(0, 1);
        this.getWayList().append(this.getWay_name().getString() + "-" + tmplatitude[0] + "\u00B0 " + tmplatitude[1] + "' " + tmplatitude[2] + "." + tmplatitude[3] + "\"" + tmpNS + "-" + tmplongitude[0] + "\u00B0 " + tmplongitude[1] + "' " + tmplongitude[2] + "." + tmplongitude[3] + "\"" + tmpWE, null);
        tmplongitude = null;
        tmplatitude = null;
        tmpNS = null;
        tmpWE = null;
    }


    public synchronized void uploadWaypoint() {
        int sel = this.getWayList().getSelectedIndex();
        if (sel != -1) {
            String data = this.getWayList().getString(sel);
            int e = 0;

            e = data.indexOf("-");
            data = data.substring(e + 1, data.length());
            e = data.indexOf("\u00B0");
            this.findlatitude[0] = Short.parseShort(data.substring(0, e));
            data = data.substring(e + 2, data.length());
            e = data.indexOf("'");
            this.findlatitude[1] = Short.parseShort(data.substring(0, e));
            data = data.substring(e + 2, data.length());
            e = data.indexOf(".");
            this.findlatitude[2] = Short.parseShort(data.substring(0, e));
            data = data.substring(e + 1, data.length());
            e = data.indexOf("\"");
            this.findlatitude[3] = Short.parseShort(data.substring(0, e));
            data = data.substring(e + 1, data.length());
            this.fNS = data.substring(0, 1);
            data = data.substring(2, data.length());

            e = data.indexOf("\u00B0");
            this.findlongitude[0] = Short.parseShort(data.substring(0, e));
            data = data.substring(e + 2, data.length());
            e = data.indexOf("'");
            this.findlongitude[1] = Short.parseShort(data.substring(0, e));
            data = data.substring(e + 2, data.length());
            e = data.indexOf(".");
            this.findlongitude[2] = Short.parseShort(data.substring(0, e));
            data = data.substring(e + 1, data.length());
            e = data.indexOf("\"");
            this.findlongitude[3] = Short.parseShort(data.substring(0, e));
            data = data.substring(e + 1, data.length());
            this.fWE = data.substring(0, 1);
        } else {
            this.getInfo().setTimeout(4000);
            this.getInfo().setString("Nemáte definované žádné body.");
            this.switchDisplayable(null, this.getInfo());
        }
    }

    public void deleteWay() {
        int sel = this.getWayList().getSelectedIndex();
        if (sel != -1) {
            this.getWayList().delete(sel);
        }
    }

    /*--------------------------------------------------------------------------
     *
     *                      Uložení do souboru
     *
     * -----------------------------------------------------------------------*/
    public void saveToFile() {
        SaveToFile save = new SaveToFile(this, handler);
        save.start();
        save = null;

    }

    /*--------------------------------------------------------------------------
     *
     *                          Obecné informace
     *
     * -----------------------------------------------------------------------*/
    private void naviInfo() {

        this.getNavi().deleteAll();

        String text = "APLIKACE NAVIGATOR \n" +
                "Možnosti volby \n\n" +
                "OBECNÉ INFORMACE \n" +
                "- zobrazení základních informací o poloze, rychlosti, nadmořské výšce a přesnosti měření\n\n" +
                "KOMPAS\n" +
                "- zobrazení směru severu \n\n" +
                "NAVIGOVÁNÍ \n" +
                "- zobrazení cesty k cíli\n\n" +
                "DEFINUJ POZICI\n" +
                "- načte do paměti pozici, které se má dosáhnout";
        this.getNavi().append(text);
    }
}