Exemplo n.º 1
0
  public void makeOrderedRenderable(DrawContext dc, AirspaceRenderer renderer) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (renderer == null) {
      String message = Logging.getMessage("nullValue.RendererIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    for (Layer layer : this.layers) {
      if (!layer.isVisible()) continue;

      if (!layer.isAirspaceVisible(dc)) continue;

      // The layer is responsible for applying its own attributes, so we override its attributes
      // with our own just
      // before rendering.
      layer.setAttributes(this.getAttributes());

      // Create an ordered renderable that draws each layer, but specifies this Cake as the picked
      // object.
      OrderedRenderable or =
          renderer.createOrderedRenderable(dc, layer, layer.computeEyeDistance(dc), this);
      dc.addOrderedRenderable(or);
    }
  }
Exemplo n.º 2
0
  /**
   * Draws the graphic as an ordered renderable.
   *
   * @param dc the current draw context.
   */
  protected void makeOrderedRenderable(DrawContext dc) {
    if (this.lines == null || this.position == null) return;

    this.computeGeometryIfNeeded(dc);

    // Don't draw if beyond the horizon.
    double horizon = dc.getView().getHorizonDistance();
    if (this.eyeDistance > horizon) return;

    if (this.intersectsFrustum(dc)) dc.addOrderedRenderable(this);

    if (dc.isPickingMode()) this.pickLayer = dc.getCurrentLayer();
  }
Exemplo n.º 3
0
  protected void addToolTip(DrawContext dc, WWIcon icon, Vec4 iconPoint) {
    if (icon.getToolTipFont() == null && icon.getToolTipText() == null) return;

    Vec4 screenPoint = dc.getView().project(iconPoint);
    if (screenPoint == null) return;

    if (icon.getToolTipOffset() != null) screenPoint = screenPoint.add3(icon.getToolTipOffset());

    OrderedText tip =
        new OrderedText(
            icon.getToolTipText(),
            icon.getToolTipFont(),
            screenPoint,
            icon.getToolTipTextColor(),
            0d);
    dc.addOrderedRenderable(tip);
  }
Exemplo n.º 4
0
 @Override
 public void doPick(DrawContext dc, Point pickPoint) {
   // Delegate drawing to the ordered renderable list
   dc.addOrderedRenderable(this.orderedImage);
 }
Exemplo n.º 5
0
 @Override
 public void doRender(DrawContext dc) {
   // Delegate drawing to the ordered renderable list
   dc.addOrderedRenderable(this.orderedImage);
 }
Exemplo n.º 6
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);
    }
  }
Exemplo n.º 7
0
 // Rendering
 @Override
 public void doRender(DrawContext dc) {
   dc.addOrderedRenderable(this.orderedImage);
 }