/**
   * Generate the positions required to draw the line.
   *
   * @param dc Current draw context.
   * @param positions Positions that define the polygon boundary.
   */
  @Override
  protected void generateIntermediatePositions(
      DrawContext dc, Iterable<? extends Position> positions) {
    Globe globe = dc.getGlobe();

    boolean useDefaultWaveLength = false;
    double waveLength = this.getWaveLength();
    if (waveLength == 0) {
      waveLength = this.computeDefaultWavelength(positions, globe);
      useDefaultWaveLength = true;
    }

    // Generate lines that parallel the control line.
    List<Position> leftPositions = new ArrayList<Position>();
    List<Position> rightPositions = new ArrayList<Position>();
    this.generateParallelLines(
        positions.iterator(), leftPositions, rightPositions, waveLength / 2.0, globe);

    if (useDefaultWaveLength) waveLength = this.computeDefaultWavelength(leftPositions, globe);
    double radius = (waveLength) / 2.0;

    // Generate wavy line to the left of the control line.
    PositionIterator iterator = new PositionIterator(leftPositions, waveLength, globe);
    this.computedPositions =
        this.generateWavePositions(iterator, radius / globe.getRadius(), false);
    this.path.setPositions(this.computedPositions);

    if (useDefaultWaveLength) waveLength = this.computeDefaultWavelength(rightPositions, globe);
    radius = (waveLength) / 2.0;

    // Generate wavy line to the right of the control line.
    iterator = new PositionIterator(rightPositions, waveLength, globe);
    this.path2.setPositions(this.generateWavePositions(iterator, radius / globe.getRadius(), true));
  }
  /**
   * {@inheritDoc}
   *
   * @param positions Control points. This graphic uses only two control point, which determine the
   *     midpoints of two opposite sides of the quad. See Fire Support Area (2.X.4.3.2.1.2) on pg.
   *     652 of MIL-STD-2525C for an example of how these points are interpreted.
   */
  public void setPositions(Iterable<? extends Position> positions) {
    if (positions == null) {
      String message = Logging.getMessage("nullValue.PositionsListIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    Iterator<? extends Position> iterator = positions.iterator();
    try {
      Position pos1 = iterator.next();
      Position pos2 = iterator.next();

      LatLon center = LatLon.interpolateGreatCircle(0.5, pos1, pos2);
      this.quad.setCenter(center);

      Angle heading = LatLon.greatCircleAzimuth(pos2, pos1);
      this.quad.setHeading(heading.subtract(Angle.POS90));

      this.positions = positions;
      this.shapeInvalid = true; // Need to recompute quad size
    } catch (NoSuchElementException e) {
      String message = Logging.getMessage("generic.InsufficientPositions");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }
  }
Exemple #3
0
  /**
   * {@inheritDoc}
   *
   * @param positions Control points that orient the graphic. Must provide at least three points.
   */
  public void setPositions(Iterable<? extends Position> positions) {
    if (positions == null) {
      String message = Logging.getMessage("nullValue.PositionsListIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    try {
      Iterator<? extends Position> iterator = positions.iterator();
      this.position1 = iterator.next();
      this.position2 = iterator.next();
      this.position3 = iterator.next();
    } catch (NoSuchElementException e) {
      String message = Logging.getMessage("generic.InsufficientPositions");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.paths = null; // Need to recompute path for the new control points
    this.arrowHead1 = null;
    this.arrowHead2 = null;

    if (this.symbol != null) {
      this.symbol.setPosition(this.position1);
    }
  }
  /**
   * {@inheritDoc}
   *
   * @param positions Control points. This graphic uses only one control point, which determines the
   *     center of the circle.
   */
  public void setPositions(Iterable<? extends Position> positions) {
    if (positions == null) {
      String message = Logging.getMessage("nullValue.PositionsListIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    try {
      // Ensure that the iterable provides at least four positions.
      Iterator<? extends Position> iterator = positions.iterator();
      for (int i = 0; i < 3; i++) {
        iterator.next();
      }
    } catch (NoSuchElementException e) {
      String message = Logging.getMessage("generic.InsufficientPositions");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.positions = positions;
    this.rings = null;
  }
Exemple #5
0
  protected void drawMany(DrawContext dc, Iterable<? extends WWIcon> icons, Layer layer) {
    if (dc == null) {
      String msg = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    if (dc.getVisibleSector() == null) return;

    SectorGeometryList geos = dc.getSurfaceGeometry();
    //noinspection RedundantIfStatement
    if (geos == null) return;

    if (icons == null) {
      String msg = Logging.getMessage("nullValue.IconIterator");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    Iterator<? extends WWIcon> iterator = icons.iterator();

    if (!iterator.hasNext()) return;

    double horizon = dc.getView().getHorizonDistance();

    while (iterator.hasNext()) {
      WWIcon icon = iterator.next();
      if (!isIconValid(icon, true)) {
        // Record feedback data for this WWIcon if feedback is enabled.
        if (icon != null) this.recordFeedback(dc, icon, null, null);

        continue;
      }

      if (!icon.isVisible()) {
        // Record feedback data for this WWIcon if feedback is enabled.
        this.recordFeedback(dc, icon, null, null);

        continue;
      }

      // Determine Cartesian position from the surface geometry if the icon is near the surface,
      // otherwise draw it from the globe.
      Position pos = icon.getPosition();
      Vec4 iconPoint = null;
      if (pos.getElevation() < dc.getGlobe().getMaxElevation()
          && !this.isAlwaysUseAbsoluteElevation()) {
        iconPoint = dc.getSurfaceGeometry().getSurfacePoint(icon.getPosition());
      }

      if (iconPoint == null) {
        Angle lat = pos.getLatitude();
        Angle lon = pos.getLongitude();
        double elevation = pos.getElevation();
        if (!this.isAlwaysUseAbsoluteElevation()) elevation += dc.getGlobe().getElevation(lat, lon);
        iconPoint = dc.getGlobe().computePointFromPosition(lat, lon, elevation);
      }

      double eyeDistance =
          icon.isAlwaysOnTop() ? 0 : dc.getView().getEyePoint().distanceTo3(iconPoint);

      // X-PATCH Marjan
      // extracted skip conditions into an overrideable method
      if (!meetsRenderCriteria(dc, icon, iconPoint, eyeDistance)) {
        this.recordFeedback(dc, icon, iconPoint, null);
        continue;
      }
      // X-END

      // The icons aren't drawn here, but added to the ordered queue to be drawn back-to-front.
      dc.addOrderedRenderable(new OrderedIcon(icon, iconPoint, layer, eyeDistance, horizon));

      if (icon.isShowToolTip()) this.addToolTip(dc, icon, iconPoint);
    }
  }