コード例 #1
0
  // Set the colors of the filter buttons according to which filters are active
  private void setColors() {
    // Panel 1 - Bearing & Distance
    if (inpDist.getText().length() > 0
        || !(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)) btnBearing.backGround = COLOR_FILTERACTIVE;
    else btnBearing.backGround = COLOR_FILTERINACTIVE;
    if (!(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)) btnBearing.backGround = COLOR_FILTERALL;
    btnBearing.repaint();

    // Panel 2 - Cache attributes
    if (!(chkArchived.state
        && chkAvailable.state
        && chkFound.state
        && chkOwned.state
        && chkNotArchived.state
        && chkNotAvailable.state
        && chkNotFound.state
        && chkNotOwned.state
        && chcStatus.getText().equals(""))) btnAttributes.backGround = COLOR_FILTERACTIVE;
    else btnAttributes.backGround = COLOR_FILTERINACTIVE;
    if ((chkArchived.state == false && chkNotArchived.state == false)
        || (chkAvailable.state == false && chkNotAvailable.state == false)
        || (chkFound.state == false && chkNotFound.state == false)
        || (chkOwned.state == false && chkNotOwned.state == false))
      btnAttributes.backGround = COLOR_FILTERALL;
    btnAttributes.repaint();

    // Panel 3 - Cache ratings
    if (inpDiff.getText().length() > 0 || inpTerr.getText().length() > 0)
      btnRatings.backGround = COLOR_FILTERACTIVE;
    else btnRatings.backGround = COLOR_FILTERINACTIVE;
    btnRatings.repaint();

    // Panel 5 - Addi Waypoints
    if (chkParking.state
        || chkStage.state
        || chkQuestion.state
        || chkFinal.state
        || chkTrailhead.state
        || chkReference.state) { // At least one tick
      btnAddi.backGround = COLOR_FILTERACTIVE;
      addiWptChk.state = true;
      if (chkParking.state
          && chkStage.state
          && chkQuestion.state
          && chkFinal.state
          && chkTrailhead.state
          && chkReference.state) { // All ticked?
        addiWptChk.bgColor = Color.White;
        btnAddi.backGround = COLOR_FILTERINACTIVE;
      } else {
        addiWptChk.bgColor = Color.LightGray;
      }
    } else { // All not ticked
      btnAddi.backGround = COLOR_FILTERACTIVE;
      addiWptChk.bgColor = Color.White;
      addiWptChk.state = false;
    }
    btnAddi.repaint();

    // Panel 4 - Cache types
    boolean allAddis =
        (chkParking.state
            && chkStage.state
            && chkQuestion.state
            && chkFinal.state
            && chkTrailhead.state
            && chkReference.state);
    if (!(chkTrad.state
        && chkMulti.state
        && chkVirtual.state
        && chkLetter.state
        && chkEvent.state
        && chkWebcam.state
        && chkMystery.state
        && chkEarth.state
        && chkLocless.state
        && chkMega.state
        && chkCito.state
        && chkWherigo.state
        && chkCustom.state
        && allAddis)) btnTypes.backGround = COLOR_FILTERACTIVE;
    else btnTypes.backGround = COLOR_FILTERINACTIVE;
    if (!(chkTrad.state
        || chkMulti.state
        || chkVirtual.state
        || chkLetter.state
        || chkEvent.state
        || chkWebcam.state
        || chkMystery.state
        || chkEarth.state
        || chkLocless.state
        || chkMega.state
        || chkCustom.state
        || chkParking.state
        || chkStage.state
        || chkQuestion.state
        || chkFinal.state
        || chkTrailhead.state
        || chkCito.state
        || chkWherigo.state
        || chkReference.state)) btnTypes.backGround = COLOR_FILTERALL;
    btnTypes.repaint();

    // Panel 6 - Cache container
    if (!(chkMicro.state
        && chkSmall.state
        && chkRegular.state
        && chkLarge.state
        && chkVeryLarge.state
        && chkOther.state)) btnContainer.backGround = COLOR_FILTERACTIVE;
    else btnContainer.backGround = COLOR_FILTERINACTIVE;
    if (!(chkMicro.state
        || chkSmall.state
        || chkRegular.state
        || chkLarge.state
        || chkVeryLarge.state
        || chkOther.state)) btnContainer.backGround = COLOR_FILTERALL;
    btnContainer.repaint();

    // Panel 7 - Search

    // Panel 8 - Cache attributes
    if (attV.selectionMaskYes == 0l && attV.selectionMaskNo == 0l)
      btnCacheAttributes.backGround = COLOR_FILTERINACTIVE;
    else btnCacheAttributes.backGround = COLOR_FILTERACTIVE;
    btnCacheAttributes.repaint();
  }
コード例 #2
0
  /**
   * Examines the filter screen and creates a FilterData object that represents the data entered in
   * the screen.
   */
  private FilterData getDataFromScreen() {
    FilterData data = new FilterData();
    data.setFilterVar(
        (chkArchived.state ? "1" : "0")
            + (chkAvailable.state ? "1" : "0")
            + (chkFound.state ? "1" : "0")
            + (chkOwned.state ? "1" : "0")
            + (chkNotArchived.state ? "1" : "0")
            + (chkNotAvailable.state ? "1" : "0")
            + (chkNotFound.state ? "1" : "0")
            + (chkNotOwned.state ? "1" : "0"));
    data.setFilterType(
        (chkTrad.state ? "1" : "0")
            + (chkMulti.state ? "1" : "0")
            + (chkVirtual.state ? "1" : "0")
            + (chkLetter.state ? "1" : "0")
            + (chkEvent.state ? "1" : "0")
            + (chkWebcam.state ? "1" : "0")
            + (chkMystery.state ? "1" : "0")
            + (chkEarth.state ? "1" : "0")
            + (chkLocless.state ? "1" : "0")
            + (chkMega.state ? "1" : "0")
            + (chkCustom.state ? "1" : "0")
            + (chkParking.state ? "1" : "0")
            + (chkStage.state ? "1" : "0")
            + (chkQuestion.state ? "1" : "0")
            + (chkFinal.state ? "1" : "0")
            + (chkTrailhead.state ? "1" : "0")
            + (chkReference.state ? "1" : "0")
            + (chkCito.state ? "1" : "0")
            + (chkWherigo.state ? "1" : "0"));
    data.setFilterRose(
        (chkNW.state ? "1" : "0")
            + (chkNNW.state ? "1" : "0")
            + (chkN.state ? "1" : "0")
            + (chkNNE.state ? "1" : "0")
            + (chkNE.state ? "1" : "0")
            + (chkENE.state ? "1" : "0")
            + (chkE.state ? "1" : "0")
            + (chkESE.state ? "1" : "0")
            + (chkSE.state ? "1" : "0")
            + (chkSSE.state ? "1" : "0")
            + (chkS.state ? "1" : "0")
            + (chkSSW.state ? "1" : "0")
            + (chkSW.state ? "1" : "0")
            + (chkWSW.state ? "1" : "0")
            + (chkW.state ? "1" : "0")
            + (chkWNW.state ? "1" : "0"));
    data.setFilterSize(
        (chkMicro.state ? "1" : "0")
            + (chkSmall.state ? "1" : "0")
            + (chkRegular.state ? "1" : "0")
            + (chkLarge.state ? "1" : "0")
            + (chkVeryLarge.state ? "1" : "0")
            + (chkOther.state ? "1" : "0"));

    // Distance: If Metric system is set to imperial units,
    //           then the entered value is meant to be miles,
    //           otherwise it's kilometer.
    double distValue = java.lang.Double.NaN;
    String rawDistance = inpDist.getText().replace(',', '.');
    String newDistance = rawDistance; // initial Value;
    if (!rawDistance.trim().equals("")) {
      distValue = java.lang.Double.valueOf(rawDistance).doubleValue();
      if (Global.getPref().metricSystem == Metrics.IMPERIAL) {
        newDistance =
            String.valueOf(Metrics.convertUnit(distValue, Metrics.MILES, Metrics.KILOMETER));
      }
    }
    if (chcDist.selectedIndex == 0) {
      data.setFilterDist("L" + newDistance);
    } else {
      data.setFilterDist("G" + newDistance);
    }

    if (chcDiff.selectedIndex == 0) {
      data.setFilterDiff("L" + inpDiff.getText());
    } else if (chcDiff.selectedIndex == 1) {
      data.setFilterDiff("=" + inpDiff.getText());
    } else {
      data.setFilterDiff("G" + inpDiff.getText());
    }

    if (chcTerr.selectedIndex == 0) {
      data.setFilterTerr("L" + inpTerr.getText());
    } else if (chcTerr.selectedIndex == 1) {
      data.setFilterTerr("=" + inpTerr.getText());
    } else {
      data.setFilterTerr("G" + inpTerr.getText());
    }
    data.setFilterAttrYes(attV.selectionMaskYes);
    data.setFilterAttrNo(attV.selectionMaskNo);
    data.setFilterAttrChoice(chcAttrib.selectedIndex);
    data.setFilterStatus(chcStatus.getText());
    data.setUseRegexp(chkUseRegexp.getState());
    return data;
  }