/**
  * Returns the degrees or minutes or seconds (depending on parameter what) formatted as a string
  * To determine the degrees, we need to calculate the minutes (and seconds) just in case rounding
  * errors propagate. Equally we need to know the seconds to determine the minutes value.
  *
  * @param deg The coordinate in degrees
  * @param what 0=deg, 1=min, 2=sec
  * @param format DD,CW,DMM,DMS
  * @return
  */
 private String getDMS(double deg, int what, int format) {
   deg = Math.abs(deg);
   long iDeg = (int) deg;
   double tmpMin, tmpSec;
   tmpMin = (deg - iDeg) * 60.0;
   switch (format) {
     case DD:
       return "";
     case CW:
     case DMM:
       // Need to check if minutes would round up to 60
       if (java.lang.Math.round(tmpMin * 1000.0) == 60000) {
         tmpMin = 0;
         iDeg++;
       }
       switch (what) {
         case 0:
           return MyLocale.formatLong(iDeg, "00");
         case 1:
           return MyLocale.formatDouble(tmpMin, "00.000").replace(',', '.');
         case 2:
           return "";
       }
     case DMS:
       tmpSec = (tmpMin - (int) tmpMin) * 60.0;
       tmpMin = (int) tmpMin;
       // Check if seconds round up to 60
       if (java.lang.Math.round(tmpSec * 10.0) == 600) {
         tmpSec = 0;
         tmpMin = tmpMin + 1.0;
       }
       // Check if minutes round up to 60
       if (java.lang.Math.round(tmpMin) == 60) {
         tmpMin = 0;
         iDeg++;
       }
       switch (what) {
         case 0:
           return MyLocale.formatLong(iDeg, "00");
         case 1:
           return MyLocale.formatDouble(tmpMin, "00");
         case 2:
           return MyLocale.formatDouble(tmpSec, "00.0").replace(',', '.');
       }
   }
   return ""; // Dummy to keep compiler happy
 }
 /**
  * Get degrees of longitude in different formats
  *
  * @param format Format: DD, DMM, DMS,
  */
 public String getLonDeg(int format) {
   switch (format) {
     case DD:
       return MyLocale.formatDouble(this.lonDec, "000.00000").replace(',', '.');
     case CW:
     case DMM:
     case DMS:
       return (((lonDec < 100.0) && (lonDec > -100.0)) ? "0" : "") + getDMS(lonDec, 0, format);
     default:
       return "";
   }
 }
 /**
  * Get degrees of latitude in different formats
  *
  * @param format Format: DD, DMM, DMS,
  */
 public String getLatDeg(int format) {
   switch (format) {
     case DD:
       return MyLocale.formatDouble(this.latDec, "00.00000").replace(',', '.');
     case CW:
     case DMM:
     case DMS:
       return getDMS(latDec, 0, format);
     default:
       return "";
   }
 }
 public AttributesSelector() {
   scp.setOptions(MyScrollBarPanel.NeverShowHorizontalScrollers);
   TILESIZE = 30;
   W_OFFSET = 100;
   H_OFFSET = 150;
   if (Vm.isMobile()) {
     if (MyLocale.getScreenWidth() == 240 & MyLocale.getScreenHeight() == 320) {
       TILESIZE = 28;
       W_OFFSET = 80;
       H_OFFSET = 120;
     }
     if (MyLocale.getScreenWidth() == 320 & MyLocale.getScreenHeight() == 240) {}
     if (MyLocale.getScreenWidth() == 480 & MyLocale.getScreenHeight() == 640) {}
     if (MyLocale.getScreenWidth() == 480 & MyLocale.getScreenHeight() == 800) {}
     if (MyLocale.getScreenWidth() == 640 & MyLocale.getScreenHeight() == 480) {}
   } else {
     TILESIZE = 36;
     W_OFFSET = 106;
     H_OFFSET = 150;
   }
   iap.virtualSize = new Rect(0, 0, 0, 0); // create once
   addLast(scp, STRETCH, FILL);
   addLast(mInfo = new mLabel(""), HSTRETCH, HFILL);
 }
  /**
   * React to the users input, create a filter and set the variable of the filter.
   *
   * @see Filter
   */
  public void onEvent(Event ev) {
    if (ev instanceof ControlEvent && ev.type == ControlEvent.PRESSED) {
      if (ev.target == btnCancel) {
        if (savedFiltersChanged) {
          Global.getPref().savePreferences();
          savedFiltersChanged = false;
        }
        fltList.select(-1);
        currentFilterID = "";
        this.close(0);
      } else if (ev.target == btnRoute) {

        File datei;
        FileChooser fc = new FileChooser(FileChooserBase.OPEN, Global.getProfile().dataDir);
        fc.setTitle(MyLocale.getMsg(712, "Select route file"));
        if (fc.execute() != FormBase.IDCANCEL) {
          datei = fc.getChosenFile();
          InfoBox inf = new InfoBox("Distance?", "Dist:", InfoBox.INPUT);
          inf.execute();
          Vm.showWait(true);
          Filter flt = new Filter();
          flt.doFilterRoute(datei, Convert.toDouble(inf.feedback.getText()));
        }
        Vm.showWait(false);
        fltList.select(-1);
        currentFilterID = "";
        this.close(0);

      } else if (ev.target == btnApply) {
        Vm.showWait(true);

        FilterData data = getDataFromScreen();
        Global.getProfile().setCurrentFilter(data);

        Filter flt = new Filter();
        flt.setFilter();
        flt.doFilter();
        if (savedFiltersChanged) {
          Global.getPref().savePreferences();
          savedFiltersChanged = false;
        }
        Global.mainTab.tbP.tc.scrollToVisible(0, 0);
        Vm.showWait(false);
        fltList.select(-1);
        currentFilterID = "";
        this.close(0);
      } else if (ev.target == btnSaveFlt) {
        String ID = fltList.getText();
        FilterData data = getDataFromScreen();
        MessageBox mBox;
        InputBox inp = new InputBox("ID");
        String newID = inp.input(ID, 20);
        if (newID != null && !newID.equals("")) {
          if (Global.getPref().hasFilter(newID)) {
            mBox =
                new MessageBox(
                    MyLocale.getMsg(221, "Overwrite Filter?"),
                    MyLocale.getMsg(222, "The filter already exists. Overwrite it?"),
                    FormBase.IDYES | FormBase.IDNO);
            if (mBox.execute() == FormBase.IDYES) {
              Global.getPref().addFilter(newID, data);
              savedFiltersChanged = true;
              buildFilterList();
            }
          } else {
            Global.getPref().addFilter(newID, data);
            savedFiltersChanged = true;
            buildFilterList();
          }
        }
      } else if (ev.target == btnDelFlt) {
        String ID = fltList.getText();
        if (!ID.equals("")) {
          FilterData data = Global.getPref().getFilter(ID);
          // We only need to delete anything, if there is already a filter of the id
          // in the list box. If not, just delete the text in the box.
          if (data != null) {
            MessageBox mBox =
                new MessageBox(
                    MyLocale.getMsg(223, "Delete filter?"),
                    ID + MyLocale.getMsg(224, " - Delete this filter?"),
                    FormBase.IDYES | FormBase.IDNO);
            if (mBox.execute() == FormBase.IDYES) {
              Global.getPref().removeFilter(ID);
              fltList.setText("");
              savedFiltersChanged = true;
              this.buildFilterList();
            }
          } else {
            fltList.setText("");
          }
        }
      } else if (ev.target == addiWptChk) { // Set all addi filters to value of main addi filter
        chkParking.setState(addiWptChk.state);
        chkStage.setState(addiWptChk.state);
        chkQuestion.setState(addiWptChk.state);
        chkFinal.setState(addiWptChk.state);
        chkTrailhead.setState(addiWptChk.state);
        chkReference.setState(addiWptChk.state);
        addiWptChk.bgColor = Color.White;
        addiWptChk.repaint();
      } else if (ev.target == btnBearing) cp.select(0);
      else if (ev.target == btnAttributes) cp.select(1);
      else if (ev.target == btnRatings) cp.select(2);
      else if (ev.target == btnTypes) cp.select(3);
      else if (ev.target == btnAddi) cp.select(4);
      else if (ev.target == btnContainer) cp.select(5);
      else if (ev.target == btnSearch) cp.select(6);
      else if (ev.target == btnCacheAttributes) cp.select(7);
      else if (ev.target == btnDeselect) {
        chkNW.state =
            chkNNW.state =
                chkN.state =
                    chkNNE.state =
                        chkNE.state =
                            chkENE.state =
                                chkE.state =
                                    chkESE.state =
                                        chkSE.state =
                                            chkSSE.state =
                                                chkS.state =
                                                    chkSSW.state =
                                                        chkSW.state =
                                                            chkWSW.state =
                                                                chkW.state = chkWNW.state = false;
        setColors();
        repaint();

      } else if (ev.target == btnSelect) {
        chkNW.state =
            chkNNW.state =
                chkN.state =
                    chkNNE.state =
                        chkNE.state =
                            chkENE.state =
                                chkE.state =
                                    chkESE.state =
                                        chkSE.state =
                                            chkSSE.state =
                                                chkS.state =
                                                    chkSSW.state =
                                                        chkSW.state =
                                                            chkWSW.state =
                                                                chkW.state = chkWNW.state = true;
        setColors();
        repaint();
      }
    }
    if (ev instanceof DataChangeEvent) {
      if (ev.target == fltList) {
        if (!currentFilterID.equals(fltList.getText())) {
          FilterData data = Global.getPref().getFilter(fltList.getText());
          if (data != null) {
            currentFilterID = fltList.getText();
            this.setData(data);
            this.repaintNow();
          }
        }
        //				Vm.debug("Event: "+ev.toString()+"; Target: "+ev.target+"; Liste: "+fltList.getText()+
        //						" (alt: "+fltList.oldText+")");
        // setColors();
      }
      setColors();
    }
  }
  public FilterScreen() {
    this.title = MyLocale.getMsg(700, "Set Filter");

    //////////////////////////
    // Panel 1 - Bearing & Distance
    //////////////////////////
    addTitle(pnlBearDist, MyLocale.getMsg(714, "Bearings & Distance"));
    pnlBearDist.addNext(
        new mLabel(MyLocale.getMsg(701, "Distance: ")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlBearDist.addNext(
        chcDist = new mChoice(new String[] {"<=", ">="}, 0),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    pnlBearDist.addLast(inpDist = new mInput(), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlBearDist.addLast(new mLabel(""));
    pnlRose.addNext(chkNW = new mCheckBox("NW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkNNW = new mCheckBox("NNW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkN = new mCheckBox("N"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addLast(chkNNE = new mCheckBox("NNE"), CellConstants.HSTRETCH, CellConstants.FILL);

    pnlRose.addNext(chkNE = new mCheckBox("NE"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkENE = new mCheckBox("ENE"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkE = new mCheckBox("E "), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addLast(chkESE = new mCheckBox("ESE"), CellConstants.HSTRETCH, CellConstants.FILL);

    pnlRose.addNext(chkSE = new mCheckBox("SE"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkSSE = new mCheckBox("SSE"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkS = new mCheckBox("S"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addLast(chkSSW = new mCheckBox("SSW"), CellConstants.HSTRETCH, CellConstants.FILL);

    pnlRose.addNext(chkSW = new mCheckBox("SW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkWSW = new mCheckBox("WSW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkW = new mCheckBox("W "), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addLast(chkWNW = new mCheckBox("WNW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(
        btnDeselect = new mButton(MyLocale.getMsg(716, "Deselect all")),
        CellConstants.HSTRETCH,
        CellConstants.FILL);
    btnDeselect.setTag(SPAN, new Dimension(2, 1));
    pnlRose.addLast(
        btnSelect = new mButton(MyLocale.getMsg(717, "Select all")),
        CellConstants.HSTRETCH,
        CellConstants.FILL);
    pnlBearDist.addLast(pnlRose, CellConstants.STRETCH, CellConstants.FILL);

    //////////////////////////
    // Panel 2 - Cache attributes
    //////////////////////////
    addTitle(pnlAttributes, MyLocale.getMsg(720, "Status"));
    mLabel lblTitleAtt;
    pnlAttributes.addLast(
        lblTitleAtt = new mLabel(MyLocale.getMsg(715, "Show all caches with status:")),
        HSTRETCH,
        FILL);
    lblTitleAtt.setTag(SPAN, new Dimension(2, 1));
    pnlAttributes.addNext(
        chkArchived = new mCheckBox(MyLocale.getMsg(710, "Archived")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlAttributes.addLast(
        chkNotArchived = new mCheckBox(MyLocale.getMsg(729, "Nicht archiviert")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);

    pnlAttributes.addNext(
        chkAvailable = new mCheckBox(MyLocale.getMsg(730, "Suchbar")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlAttributes.addLast(
        chkNotAvailable = new mCheckBox(MyLocale.getMsg(711, "Not available")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);

    pnlAttributes.addNext(
        chkFound = new mCheckBox(MyLocale.getMsg(703, "Found")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlAttributes.addLast(
        chkNotFound = new mCheckBox(MyLocale.getMsg(731, "Noch nicht gefunden")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);

    pnlAttributes.addNext(
        chkOwned = new mCheckBox(MyLocale.getMsg(707, "Owned")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlAttributes.addLast(
        chkNotOwned = new mCheckBox(MyLocale.getMsg(732, "Anderer Besitzer")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);

    pnlAttributes.addNext(
        new mLabel(MyLocale.getMsg(307, "Status:")),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    pnlAttributes.addLast(
        chcStatus =
            new mComboBox(
                new String[] {
                  "",
                  MyLocale.getMsg(313, "Flag 1"),
                  MyLocale.getMsg(314, "Flag 2"),
                  MyLocale.getMsg(315, "Flag 3"),
                  MyLocale.getMsg(316, "Flag 4"),
                  MyLocale.getMsg(317, "Search"),
                  MyLocale.getMsg(318, "Found"),
                  MyLocale.getMsg(319, "Not Found"),
                  MyLocale.getMsg(320, "Owner")
                },
                0),
        CellConstants.HSTRETCH,
        (CellConstants.HFILL | CellConstants.WEST));
    pnlAttributes.addLast(chkUseRegexp = new mCheckBox(MyLocale.getMsg(299, "Regular expression")));

    //////////////////////////
    // Panel 3 - Cache ratings
    //////////////////////////
    addTitle(pnlRatings, MyLocale.getMsg(718, "Cache ratings"));
    pnlRatings.addNext(
        new mLabel(MyLocale.getMsg(702, "Difficulty: ")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlRatings.addNext(
        chcDiff = new mChoice(new String[] {"<=", "=", ">="}, 0),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    // pnlRatings.addLast(difIn = new mChoice(new String[]{"1.0", "1.5", "2.0", "2.5", "3.0", "3.5",
    // "4.0", "4.5", "5.0"},0),CellConstants.DONTSTRETCH,
    // (CellConstants.DONTFILL|CellConstants.WEST));
    pnlRatings.addLast(inpDiff = new mInput(), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlRatings.addNext(new mLabel("Terrain: "), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlRatings.addNext(
        chcTerr = new mChoice(new String[] {"<=", "=", ">="}, 0),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    // pnlRatings.addLast(terrIn = new mChoice(new String[]{"1.0", "1.5", "2.0", "2.5", "3.0",
    // "3.5", "4.0", "4.5", "5.0"},0),CellConstants.DONTSTRETCH,
    // (CellConstants.DONTFILL|CellConstants.WEST));
    pnlRatings.addLast(inpTerr = new mInput(), CellConstants.DONTSTRETCH, CellConstants.FILL);

    //////////////////////////
    // Panel 4 - Cache types
    //////////////////////////

    addTitle(pnlCacheTypes, MyLocale.getMsg(719, "Cache types"));
    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_TRADITIONAL)));
    pnlCacheTypes.addNext(
        chkTrad = new mCheckBox("Traditonal"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_MULTI)));
    pnlCacheTypes.addLast(
        chkMulti = new mCheckBox("Multi"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_VIRTUAL)));
    pnlCacheTypes.addNext(
        chkVirtual = new mCheckBox("Virtual"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_LETTERBOX)));
    pnlCacheTypes.addLast(
        chkLetter = new mCheckBox("Letterbox"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_EVENT)));
    pnlCacheTypes.addNext(
        chkEvent = new mCheckBox("Event"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_WEBCAM)));
    pnlCacheTypes.addLast(
        chkWebcam = new mCheckBox("Webcam"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_UNKNOWN)));
    pnlCacheTypes.addNext(
        chkMystery = new mCheckBox("Mystery"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_EARTH)));
    pnlCacheTypes.addLast(
        chkEarth = new mCheckBox("Earth"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_LOCATIONLESS)));
    pnlCacheTypes.addNext(
        chkLocless = new mCheckBox("Locationless"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_MEGA_EVENT)));
    pnlCacheTypes.addLast(
        chkMega = new mCheckBox("Mega-Ev."), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_CITO)));
    pnlCacheTypes.addNext(
        chkCito = new mCheckBox("Cito-Ev."), CellConstants.DONTSTRETCH, CellConstants.FILL);

    // pnlCacheTypes.addLast(addiWptChk = new mCheckBox("Add. Wpt"), CellConstants.DONTSTRETCH,
    // CellConstants.FILL);
    // pnlCacheTypes.addLast(new mLabel(""));
    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_CUSTOM)));
    pnlCacheTypes.addLast(
        chkCustom = new mCheckBox("Custom"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_WHEREIGO)));
    pnlCacheTypes.addNext(
        chkWherigo = new myChkBox("WherIGo"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_DRIVE_IN)));
    pnlCacheTypes.addNext(
        addiWptChk = new myChkBox("Add. Wpt"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    // addiWptChk.modify(0,NotAnEditor);
    //////////////////////////
    // Panel 5 - Addi waypoints
    //////////////////////////
    addTitle(pnlAddi, MyLocale.getMsg(726, "Additional waypoints"));
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_PARKING)));
    pnlAddi.addNext(
        chkParking = new mCheckBox("Parking"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_STAGE)));
    pnlAddi.addLast(
        chkStage = new mCheckBox("Stage"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_QUESTION)));
    pnlAddi.addNext(
        chkQuestion = new mCheckBox("Question"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_FINAL)));
    pnlAddi.addLast(
        chkFinal = new mCheckBox("Final"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_TRAILHEAD)));
    pnlAddi.addNext(
        chkTrailhead = new mCheckBox("Trailhead"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_REFERENCE)));
    pnlAddi.addLast(
        chkReference = new mCheckBox("Reference"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addLast(new mLabel(""), VSTRETCH, FILL);

    //////////////////////////
    // Panel 6 - Cache container
    //////////////////////////
    addTitle(pnlContainer, MyLocale.getMsg(727, "Cache container"));
    pnlContainer.addLast(chkMicro = new mCheckBox("Micro"));
    pnlContainer.addLast(chkSmall = new mCheckBox("Small"));
    pnlContainer.addLast(chkRegular = new mCheckBox("Regular"));
    pnlContainer.addLast(chkLarge = new mCheckBox("Large"));
    pnlContainer.addLast(chkVeryLarge = new mCheckBox("Very Large"));
    pnlContainer.addLast(chkOther = new mCheckBox("Other"));

    //////////////////////////
    // Panel 7 - Search
    //////////////////////////
    addTitle(pnlSearch, "Search");
    pnlSearch.addLast(new mLabel("To be implemented"));

    //////////////////////////
    // Panel 8 - Cache attributes
    //////////////////////////

    if (MyLocale.getScreenHeight() > 240)
      addTitle(pnlCacheAttributes, MyLocale.getMsg(737, "Attributes"));
    pnlCacheAttributes.addNext(
        new mLabel(MyLocale.getMsg(739, "Filter on") + ":"),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlCacheAttributes.addLast(
        chcAttrib =
            new mChoice(
                new String[] {
                  MyLocale.getMsg(740, "all"),
                  MyLocale.getMsg(741, "one"),
                  MyLocale.getMsg(742, "none")
                },
                0),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));

    attV = new AttributesSelector();
    pnlCacheAttributes.addLast(
        attV,
        CellConstants.STRETCH | CellConstants.LEFT /*|CellConstants.BORDER*/,
        CellConstants.STRETCH);
    attV.setSelectionMasks(0l, 0l);

    Frame frmScreen = new Frame();
    mLabel lblInfo;
    frmScreen
        .addLast(
            lblInfo =
                new mLabel(MyLocale.getMsg(725, "Note: Filters are additive, active filter=green")))
        .setTag(SPAN, new Dimension(2, 1));
    lblInfo.setTag(INSETS, new Insets(0, 0, 2, 0));
    frmScreen.borderStyle =
        UIConstants.BDR_RAISEDOUTER | UIConstants.BDR_SUNKENINNER | UIConstants.BF_BOTTOM;
    this.addLast(frmScreen, HSTRETCH, HFILL);

    CellPanel pnlButtons = new CellPanel();
    pnlButtons.addLast(new mLabel("Filter"));
    pnlButtons.addLast(btnBearing = new mButton(MyLocale.getMsg(721, "Bearing")));
    pnlButtons.addLast(btnAttributes = new mButton(MyLocale.getMsg(720, "Attributes")));
    pnlButtons.addLast(btnRatings = new mButton(MyLocale.getMsg(722, "Ratings")));
    pnlButtons.addLast(btnTypes = new mButton(MyLocale.getMsg(723, "Types")));
    pnlButtons.addLast(btnAddi = new mButton(MyLocale.getMsg(733, "Add. Wpt")));
    pnlButtons.addLast(btnContainer = new mButton(MyLocale.getMsg(724, "Container")));
    pnlButtons.addLast(btnCacheAttributes = new mButton(MyLocale.getMsg(738, "Attributes")));
    // Search ist für 0.9n noch deaktiviert
    // pnlButtons.addLast(btnSearch=new mButton("Search")); btnSearch.modify(Disabled,0);
    addNext(pnlButtons, HSTRETCH, FILL);

    cp.addItem(pnlBearDist, "Bear", null);
    cp.addItem(pnlAttributes, "Att", null);
    cp.addItem(pnlRatings, "DT", null);
    cp.addItem(pnlCacheTypes, "Type", null);
    cp.addItem(pnlAddi, "Addi", null);
    cp.addItem(pnlContainer, "Size", null);
    cp.addItem(pnlSearch, "Search", null);
    cp.addItem(pnlCacheAttributes, "Attr", null);
    addLast(cp, VSTRETCH, FILL);

    CellPanel savDelPanel = new CellPanel(); // Panel for "save" and "delete" button
    savDelPanel.equalWidths = true;
    mImage savImg = new mImage("clsave.png");
    savImg.transparentColor = new Color(255, 0, 0);
    savDelPanel.addNext(btnSaveFlt = new mButton(savImg), STRETCH, FILL);
    savDelPanel.addLast(btnDelFlt = new mButton(new mImage("trash.png")), STRETCH, FILL);
    Panel fltListPanel = new Panel();
    fltListPanel.addLast(fltList = new mChoice());
    fltListPanel.addLast(savDelPanel);
    CellPanel btPanel = new CellPanel();
    btPanel.equalWidths = true;
    btPanel.addNext(fltListPanel, CellConstants.STRETCH, CellConstants.FILL);
    btPanel.addNext(
        btnCancel = new mButton(MyLocale.getMsg(708, "Cancel")),
        CellConstants.STRETCH,
        CellConstants.FILL);
    btPanel.addLast(
        btnApply = new mButton(MyLocale.getMsg(709, "Apply")),
        CellConstants.STRETCH,
        CellConstants.FILL);
    //		btPanel.addLast(btnRoute = new mButton("Route"),CellConstants.STRETCH, CellConstants.FILL);
    addLast(
        btPanel.setTag(CellConstants.SPAN, new Dimension(3, 1)),
        CellConstants.STRETCH,
        CellConstants.FILL);

    int sw = MyLocale.getScreenWidth();
    int sh = MyLocale.getScreenHeight();
    Preferences pref = Global.getPref();
    int fs = pref.fontSize;
    int psx;
    int psy;
    if ((sw > 300) && (sh > 300)) {
      // larger screens: size according to fontsize
      psx = 240;
      psy = 260;
      if (fs > 12) {
        psx = 300;
        psy = 330;
      }
      if (fs > 17) {
        psx = 400;
        psy = 340;
      }
      if (fs > 23) {
        psx = 500;
        psy = 350;
      }
      setPreferredSize(psx, psy);
    } else {
      // small screens: fixed size
      if (sh > 240) setPreferredSize(240, 260);
      else setPreferredSize(240, 240);
    }
    cp.select(3);

    // Populating the comboBox of saved filters
    buildFilterList();
  }
 /**
  * Returns the string representation of the CWPoint Formats DD, DMM (same as CW), DMS, UTM
  *
  * @return string representation of CWPoint
  */
 public String toString(int format) {
   if (!isValid()) return MyLocale.getMsg(999, "not set");
   switch (format) {
     case DD:
       return getNSLetter()
           + " "
           + STRreplace.replace(getLatDeg(format), "-", "")
           + "° "
           + getEWLetter()
           + " "
           + STRreplace.replace(getLonDeg(format), "-", "")
           + "°";
     case CW:
       format = DMM;
       return getNSLetter()
           + " "
           + getLatDeg(format)
           + "° "
           + getLatMin(format)
           + " "
           + getEWLetter()
           + " "
           + getLonDeg(format)
           + "° "
           + getLonMin(format);
     case DMM:
       return getNSLetter()
           + " "
           + getLatDeg(format)
           + "° "
           + getLatMin(format)
           + " "
           + getEWLetter()
           + " "
           + getLonDeg(format)
           + "° "
           + getLonMin(format);
     case DMS:
       return getNSLetter()
           + " "
           + getLatDeg(format)
           + "° "
           + getLatMin(format)
           + "\' "
           + getLatSec(format)
           + "\" "
           + getEWLetter()
           + " "
           + getLonDeg(format)
           + "° "
           + getLonMin(format)
           + "\' "
           + getLonSec(format)
           + "\"";
     case UTM:
       return getUTMZone() + " E " + getUTMEasting() + " N " + getUTMNorthing();
     case LON_LAT:
       return Common.DoubleToString(lonDec, 8) + "," + Common.DoubleToString(latDec, 8);
     case LAT_LON:
       return Common.DoubleToString(latDec, 8) + "," + Common.DoubleToString(lonDec, 8);
     case GK:
       return getGermanGkCoordinates();
     default:
       return "Unknown Format: " + format;
   }
 }
  public static void main(String vmargs[]) {
    // start with parameters:
    // args[0]: spider
    // args[1]: distance
    ewe.sys.Vm.startEwe(vmargs);
    /*		Gui.screenIs(Gui.PDA_SCREEN);
    		Rect s = (Rect)Window.getGuiInfo(Window.INFO_SCREEN_RECT,null,new Rect(),0);
    		//Gui.screenIs(Gui.PDA_SCREEN)
    		if (Vm.isMobile() && s.height >= 400) {
    			Font defaultGuiFont = mApp.findFont("gui");
    			int sz = (int)(defaultGuiFont.getSize());
    			Font newGuiFont = new Font(defaultGuiFont.getName(), defaultGuiFont.getStyle(), sz);
    			mApp.addFont(newGuiFont, "gui");
    			mApp.fontsChanged();
    			mApp.mainApp.font = newGuiFont;
    		}
    */
    if (Gui.screenIs(Gui.PDA_SCREEN) && Vm.isMobile()) {
      Vm.setSIP(Vm.SIP_LEAVE_BUTTON);
    }

    // get program command line parameters and switches
    String[] args =
        vmargs; // Vm.getProgramArguments(); <-- only works in eclipse, but mixes the letters in the
                // ewe-vm (tested in ewe-1.49 on win xp)
    String configfile = null;
    boolean debug = false;
    if (args.length > 0) {
      if (args[0].equals("test")) {
        Test t = new Test();
        t.testAll();
      }
      for (int i = 0; i < args.length; i++) {
        Vm.debug("prog: " + args[i]);
        Vm.debug("vm: " + vmargs[i]);
        if (args[i] != null
            && args[i].length() > 1
            && (args[i].startsWith("-") || args[i].startsWith("/"))) {
          String c = args[i].substring(1, args[i].length());
          if (c.equalsIgnoreCase("c")) {
            if (i < args.length - 1) {
              configfile = args[i + 1];
              i++;
            } else {
              (new MessageBox(
                      "Error",
                      MyLocale.getMsg(7200, "Usage: CacheWolf [-c <path to pref.xml>] [-debug]"),
                      MessageBox.OKB))
                  .execute();
              // return usage info
              ewe.sys.Vm.exit(1);
            }
          }
          if (c.equalsIgnoreCase("debug")) {
            // Vm.debug("d");
            debug = true;
          }
        }
      }
    }

    if (debug) {
      Vm.debug("prg-args: " + args.length);
      Vm.debug("vm-args: " + vmargs.length);
    }

    Editor mainF = new MainForm(debug, configfile);
    Device.preventIdleState(true);
    mainF.execute();
    Device.preventIdleState(false);
    ewe.sys.Vm.exit(0);
  }