コード例 #1
0
  private Vector addAnchorString(Vector list, String field, double diff) {
    Vector topIndex = new Vector();
    Hashtable topIndexParms, currEntry;
    double lastValue, currValue;

    if (list.size() == 0) return null;

    currEntry = (Hashtable) list.get(0);
    lastValue = Common.parseDouble((String) currEntry.get(field)) + diff;

    for (int i = 1; i < list.size(); i++) {
      currEntry = (Hashtable) list.get(i);
      currValue = Common.parseDouble((String) currEntry.get(field));
      if (currValue >= lastValue) {
        // Values for navigation line
        topIndexParms = new Hashtable();
        topIndexParms.put("HREF", Convert.toString(i));
        topIndexParms.put("TEXT", Convert.toString(lastValue));
        topIndex.add(topIndexParms);
        // add anchor entry to list
        currEntry.put("ANCHORNAME", Convert.toString(i));
        currEntry.put("ANCHORTEXT", Convert.toString(lastValue));
        lastValue = currValue + diff;
      } else {
        // clear value from previous run
        currEntry.put("ANCHORNAME", "");
        currEntry.put("ANCHORTEXT", "");
      }
      list.set(i, currEntry);
    }
    return topIndex;
  }
コード例 #2
0
  private Vector addAnchorString(Vector list, String field, boolean fullCompare) {
    Vector topIndex = new Vector();
    Hashtable topIndexParms, currEntry;
    String lastValue, currValue;

    if (list.size() == 0) return null;

    currEntry = (Hashtable) list.get(0);
    lastValue = (String) currEntry.get(field);
    if (lastValue == null || lastValue.length() == 0) lastValue = "  ";
    lastValue = lastValue.toUpperCase();

    for (int i = 1; i < list.size(); i++) {
      currEntry = (Hashtable) list.get(i);
      currValue = (String) currEntry.get(field);
      currValue = currValue.toUpperCase();
      if (currValue == null || currValue == "") continue;
      try {
        if (fullCompare) {
          if (lastValue.compareTo(currValue) != 0) {
            // Values for navigation line
            topIndexParms = new Hashtable();
            topIndexParms.put("HREF", Convert.toString(i));
            topIndexParms.put("TEXT", currValue);
            topIndex.add(topIndexParms);
            // add anchor entry to list
            currEntry.put("ANCHORNAME", Convert.toString(i));
            currEntry.put("ANCHORTEXT", currValue);
          } else {
            // clear value from previous run
            currEntry.put("ANCHORNAME", "");
            currEntry.put("ANCHORTEXT", "");
          }
        } else {
          if (lastValue.charAt(0) != currValue.charAt(0)) {
            // Values for navigation line
            topIndexParms = new Hashtable();
            topIndexParms.put("HREF", Convert.toString(i));
            topIndexParms.put("TEXT", currValue.charAt(0) + " ");
            topIndex.add(topIndexParms);
            // add anchor entry to list
            currEntry.put("ANCHORNAME", Convert.toString(i));
            currEntry.put("ANCHORTEXT", currValue.charAt(0) + " ");
          } else {
            // clear value from previous run
            currEntry.put("ANCHORNAME", "");
            currEntry.put("ANCHORTEXT", "");
          }
        }
        list.set(i, currEntry);
        lastValue = currValue;
      } catch (Exception e) {
        continue;
      }
    }
    return topIndex;
  }
コード例 #3
0
  private void parseCoordinatesLine() {
    StringTokenizer exBlock = new StringTokenizer(strData, " ");
    StringTokenizer numbers;
    String lat = new String();
    String lon = new String();

    String test = new String();

    while (exBlock.hasMoreTokens()) {
      test = exBlock.nextToken();
      // Vm.debug("==> " + test + " <==");
      numbers = new StringTokenizer(test, ",");
      // Vm.debug(numbers.nextToken());
      // Vm.debug(numbers.nextToken());
      lon = numbers.nextToken();
      lat = numbers.nextToken();
      point = new CWPoint(Convert.parseDouble(lat), Convert.parseDouble(lon));
      points.add(point);
    }
  }
コード例 #4
0
  /**
   * 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();
    }
  }