public void switchToMovingMap() { CWPoint centerTo = null; if (myNavigation.isGpsPosValid()) centerTo = new CWPoint(myNavigation.gpsPos); // set gps-pos if gps is on else { // setze Zielpunkt als Ausgangspunkt, wenn GPS aus ist und lade entsprechende Karte // centerTo = new CWPoint(myNavigation.destination); if (myNavigation.destination.isValid()) centerTo = new CWPoint(myNavigation.destination); else { if (mainT.ch != null && mainT.ch.getPos().isValid()) centerTo = new CWPoint(mainT.ch.getPos()); else { if (pref.getCurCentrePt().isValid()) centerTo = new CWPoint(pref.getCurCentrePt()); } } } if (centerTo != null && centerTo.isValid()) mainT.SwitchToMovingMap(centerTo, false); else (new MessageBox( MyLocale.getMsg(321, "Error"), MyLocale.getMsg( 1513, "Cannot start moving map without valid coordinates. Please enter coordinates as destination, as center, in selected cache or start GPS"), FormBase.OKB)) .execute(); }
/** Eventhandler */ public void onEvent(Event ev) { if (ev instanceof MenuEvent) { if (ev.type == MenuEvent.SELECTED) { if (((MenuEvent) ev).menu == mnuContextFormt) { mnuContextFormt.close(); mnuContextFormt.getItemAt(currFormatSel).modifiers &= ~MenuItem.Checked; currFormatSel = mnuContextFormt.getInt(); mnuContextFormt.getItemAt(currFormatSel).modifiers |= MenuItem.Checked; lblPosition.setText( myNavigation.gpsPos.toString(CoordsScreen.getLocalSystem(currFormatSel))); btnGoto.setText(getGotoBtnText()); } // end lat-lon-format context menu if (((MenuEvent) ev).menu == mnuContextRose) { MenuItem action = (MenuItem) mnuContextRose.getSelectedItem(); if (action != null) { for (int i = 0; i < miLuminary.length; i++) { if (action == miLuminary[i]) { myNavigation.setLuminary(i); miLuminary[i].modifiers |= MenuItem.Checked; compassRose.setLuminaryName(SkyOrientation.getLuminaryName(myNavigation.luminary)); } else miLuminary[i].modifiers &= ~MenuItem.Checked; } if (action == miNorthCentered) { if (compassRose.isNorthCentered()) { compassRose.setNorthCentered(false); miNorthCentered.modifiers &= ~MenuItem.Checked; } else { compassRose.setNorthCentered(true); miNorthCentered.modifiers |= MenuItem.Checked; } } } } } } if (ev instanceof ControlEvent && ev.type == ControlEvent.PRESSED) { // start/stop GPS connection if (ev.target == btnGPS) { if (btnGPS.getText().equals(MyLocale.getMsg(1504, "Start"))) startGps(); else myNavigation.stopGps(); } // set current position as centre and recalculate distance of caches in MainTab if (ev.target == btnCenter) { if (myNavigation.gpsPos.isValid()) { pref.setCurCentrePt(myNavigation.gpsPos); } else (new MessageBox( MyLocale.getMsg(312, "Error"), MyLocale.getMsg( 1514, "Cannot recalculate distances, because the GPS position is not set"), FormBase.OKB)) .execute(); } // Start moving map if (ev.target == btnMap) { switchToMovingMap(); } // create new waypoint with current GPS-position if (ev.target == btnSave) { CacheHolder ch = new CacheHolder(); ch.setPos(myNavigation.gpsPos); ch.setType(CacheType.CW_TYPE_STAGE); // see CacheType.GC_AW_STAGE_OF_MULTI // TODO unfertig mainT.newWaypoint(ch); } // change destination waypoint if (ev.target == btnGoto) { if (Vm.isMobile()) { InputScreen InScr = new InputScreen(CoordsScreen.getLocalSystem(currFormatSel)); if (myNavigation.destination.isValid()) InScr.setCoords(myNavigation.destination); else InScr.setCoords(new CWPoint(0, 0)); if (InScr.execute(null, CellConstants.TOP) == FormBase.IDOK) setDestination(InScr.getCoords()); } else { CoordsScreen cs = new CoordsScreen(); if (myNavigation.destination.isValid()) cs.setFields(myNavigation.destination, CoordsScreen.getLocalSystem(currFormatSel)); else cs.setFields(new CWPoint(0, 0), CoordsScreen.getLocalSystem(currFormatSel)); if (cs.execute(null, CellConstants.TOP) == FormBase.IDOK) setDestination(cs.getCoords()); } } } super.onEvent(ev); }
public void setDestinationAndSwitch(CacheHolder ch) { myNavigation.setDestination(ch); mainT.select(this); }
/** * set the coords of the destination and switch to gotoPanel * * @param LatLon destination */ public void setDestinationAndSwitch(CWPoint where) { myNavigation.setDestination(where); mainT.select(this); }