示例#1
0
  public void createLabels() {
    labels.clear();
    points.clear();

    if (rawllpts == null) {
      return;
    }
    if (rawllpts.length < 4) {
      return;
    }

    Geo lastGeo = new Geo(rawllpts[0], rawllpts[1], units == DECIMAL_DEGREES);
    double latpnt = rawllpts[0];
    double lonpnt = rawllpts[1];
    if (units == RADIANS) {
      latpnt = ProjMath.radToDeg(latpnt);
      lonpnt = ProjMath.radToDeg(lonpnt);
    }
    points.add(new OMPoint(latpnt, lonpnt, 1));
    Geo curGeo = null;
    double cumulativeDist = 0.0;
    for (int p = 2; p < rawllpts.length; p += 2) {
      if (curGeo == null) {
        curGeo = new Geo(rawllpts[p], rawllpts[p + 1], units == DECIMAL_DEGREES);
      } else {
        if (units == DECIMAL_DEGREES) {
          curGeo.initialize(rawllpts[p], rawllpts[p + 1]);
        } else {
          curGeo.initializeRadians(rawllpts[p], rawllpts[p + 1]);
        }
      }

      double dist = getDist(lastGeo, curGeo);
      cumulativeDist += dist;

      labels.add(createLabel(lastGeo, curGeo, dist, cumulativeDist, distUnits));
      latpnt = rawllpts[p];
      lonpnt = rawllpts[p + 1];
      if (units == RADIANS) {
        latpnt = ProjMath.radToDeg(latpnt);
        lonpnt = ProjMath.radToDeg(lonpnt);
      }

      points.add(new OMPoint(latpnt, lonpnt, 1));
      lastGeo.initialize(curGeo);
    }
  }
示例#2
0
  /**
   * Method that provides a recursive mechanism to go through OMGraphicsLists to filter out areas,
   * inside or outside another.
   */
  protected OMGraphicList filterList(OMGraphicList omgl, Area area, boolean getInsideArea) {
    OMGraphicList ret = new OMGraphicList();
    boolean DEBUG_DETAIL = Debug.debugging("filtersupportdetail");
    boolean DEBUG = Debug.debugging("filtersupport") || DEBUG_DETAIL;

    if (DEBUG) {
      Debug.output("FilterSupport.filterList");
    }

    int count = 0; // for debugging

    if (area != null && omgl != null) { // just checking

      for (OMGraphic omg : omgl) {

        if (DEBUG) {
          Debug.output("FilterSupport.filterList evaluating " + (count++) + " OMGraphic, " + omg);
        }

        boolean outsideFilter = true;

        // If not visible, automatically fails...
        if (!omg.isVisible()) {
          if (DEBUG) {
            Debug.output("   OMGraphic not visible, ignoring");
          }
          continue;
        }

        if (omg instanceof OMGraphicList) {
          if (omg == omgl) {
            Debug.output("   OMGraphic is parent list (points to itself), ignoring...");
            continue;
          }

          if (DEBUG) {
            Debug.output("  (filterList recursiving handing OMGraphicList)");
          }

          OMGraphicList subList = filterList((OMGraphicList) omg, area, getInsideArea);

          if (!subList.isEmpty()) {
            if (DEBUG) {
              Debug.output(
                  "  +++ OMGraphicList's contents (" + subList.size() + ") pass filter, adding...");
            }

            if (((OMGraphicList) omg).isVague()) {
              passedFilter(omg);
              omg.setVisible(true);
              ret.add(omg);
            } else {
              passedFilter(subList);
              ret.add(subList);
            }
          } else {
            if (DEBUG) {
              Debug.output("  --- OMGraphicList's contents fail filter, ignoring...");
            }

            failedFilter(omg);
          }
          continue;
        } else {
          Shape omgShape = omg.getShape();
          if (omgShape != null) {
            if (omgShape.getBounds2D().getWidth() == 0 && omgShape.getBounds2D().getHeight() == 0) {
              if (area.contains(omgShape.getBounds2D().getX(), omgShape.getBounds2D().getY())) {
                if (DEBUG_DETAIL) {
                  Debug.output("   +++ omg contains position");
                }

                outsideFilter = false;
              }
            } else if (area.intersects(omgShape.getBounds2D())) {
              if (DEBUG_DETAIL) {
                Debug.output("   +++ omg intersects bounds");
              }

              // The area.interects() method above is a
              // general case. If you care about
              // preciseness, set the precise flag.
              // Depending on the performance cost, we might
              // want to make it permanent.

              if (precise) {
                Area omgArea = new Area(omgShape);
                if (!omgArea.isSingular()) {
                  Area clone = (Area) area.clone();
                  clone.intersect(omgArea);
                  if (!clone.isEmpty()) {
                    outsideFilter = false;
                  }
                } else {
                  outsideFilter = false;
                }
              } else {
                outsideFilter = false;
              }
            }
          }

          // decide what to do depending on filteredOut and
          // getInsideArea
          if ((outsideFilter && !getInsideArea) || (!outsideFilter && getInsideArea)) {

            if (DEBUG) {
              Debug.output("   +++ OMGraphic passes filter, adding...");
            }

            passedFilter(omg);
            ret.add(omg);
          } else {
            if (DEBUG) {
              Debug.output("   --- OMGraphic fails filter, hiding...");
            }

            failedFilter(omg);
          }
        }
      }
    }

    return ret;
  }