public void setTextColor(Color color) {
    if (color == null) {
      String message = Logging.getMessage("nullValue.ColorIsNull");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    this.textColor = color;
  }
  public void setOutlineWidth(double width) {
    if (width < 0) {
      String message = Logging.getMessage("generic.ArgumentOutOfRange", "width < 0");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    this.outlineWidth = width;
  }
  public void setFont(java.awt.Font font) {
    if (font == null) {
      String message = Logging.getMessage("nullValue.FontIsNull");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    this.font = font;
  }
  public void setInsets(java.awt.Insets insets) {
    if (insets == null) {
      String message = Logging.getMessage("nullValue.InsetsIsNull");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    // Class java.awt.Insets is known to override the method Object.clone().
    this.insets = (java.awt.Insets) insets.clone();
  }
  public void setOpacity(double opacity) {
    if (opacity < 0 || opacity > 1) {
      String message =
          Logging.getMessage("generic.ArgumentOutOfRange", "opacity < 0 or opacity > 1");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    this.opacity = opacity;
  }
  protected void endRendering(DrawContext dc, OGLStackHandler stackHandler) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

    stackHandler.pop(gl);
  }
Example #7
0
    public void render(DrawContext dc) {
      IconRenderer.this.beginDrawIcons(dc);

      try {
        IconRenderer.this.drawIconsInBatch(dc, this);
      } catch (WWRuntimeException e) {
        Logging.logger().log(Level.SEVERE, "generic.ExceptionWhileRenderingIcon", e);
      } catch (Exception e) {
        Logging.logger().log(Level.SEVERE, "generic.ExceptionWhileRenderingIcon", e);
      } finally {
        IconRenderer.this.endDrawIcons(dc);
      }
    }
  public void render(DrawContext dc, String text, int x, int y) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    if (text == null) {
      String message = Logging.getMessage("nullValue.StringIsNull");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    this.doRender(dc, text, x, y);
  }
  public ToolTipRenderer(java.awt.Font font) {
    if (font == null) {
      String message = Logging.getMessage("nullValue.FontIsNull");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    this.useSystemLookAndFeel = false;
    this.font = font;
    this.textColor = java.awt.Color.WHITE;
    this.interiorColor = java.awt.Color.BLACK;
    this.outlineColor = java.awt.Color.WHITE;
    this.outlineWidth = 1;
    this.opacity = 1;
    this.insets = new java.awt.Insets(1, 1, 1, 1);
  }
Example #10
0
 public void pick(DrawContext dc, java.awt.Point pickPoint) {
   IconRenderer.this.pickSupport.clearPickList();
   IconRenderer.this.beginDrawIcons(dc);
   try {
     if (IconRenderer.this.isAllowBatchPicking()) IconRenderer.this.pickIconsInBatch(dc, this);
     else IconRenderer.this.drawIcon(dc, this);
   } catch (WWRuntimeException e) {
     Logging.logger().log(Level.SEVERE, "generic.ExceptionWhileRenderingIcon", e);
   } catch (Exception e) {
     Logging.logger().log(Level.SEVERE, "generic.ExceptionWhilePickingIcon", e);
   } finally {
     IconRenderer.this.endDrawIcons(dc);
     IconRenderer.this.pickSupport.resolvePick(dc, pickPoint, layer);
     IconRenderer.this.pickSupport.clearPickList(); // to ensure entries can be garbage collected
   }
 }
  protected void beginRendering(DrawContext dc, OGLStackHandler stackHandler) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

    int attribMask =
        GL2.GL_COLOR_BUFFER_BIT // for alpha test func and ref, blend func
            | GL2.GL_CURRENT_BIT // for current color
            | GL2.GL_ENABLE_BIT // for enable/disable
            | GL2.GL_LINE_BIT // for line width
            | GL2.GL_TRANSFORM_BIT; // for matrix mode
    stackHandler.pushAttrib(gl, attribMask);

    stackHandler.pushTextureIdentity(gl);
    stackHandler.pushProjectionIdentity(gl);
    java.awt.Rectangle viewport = dc.getView().getViewport();
    gl.glOrtho(
        viewport.x, viewport.x + viewport.width, viewport.y, viewport.y + viewport.height, -1, 1);
    stackHandler.pushModelviewIdentity(gl);

    // Enable the alpha test.
    gl.glEnable(GL2.GL_ALPHA_TEST);
    gl.glAlphaFunc(GL2.GL_GREATER, 0.0f);

    // Enable blending in premultiplied color mode.
    gl.glEnable(GL.GL_BLEND);
    OGLUtil.applyBlending(gl, true);

    gl.glDisable(GL.GL_CULL_FACE);
    gl.glDisable(GL.GL_DEPTH_TEST);
    gl.glDisable(GL2.GL_LIGHTING);
    gl.glDisable(GL.GL_TEXTURE_2D);
  }
Example #12
0
 @Override
 public String toString() {
   return Logging.getMessage("layers.IconLayer.Name");
 }
Example #13
0
  protected Vec4 drawIcon(DrawContext dc, OrderedIcon uIcon) {
    if (uIcon.point == null) {
      String msg = Logging.getMessage("nullValue.PointIsNull");
      Logging.logger().severe(msg);

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

      return null;
    }

    WWIcon icon = uIcon.icon;
    if (dc.getView().getFrustumInModelCoordinates().getNear().distanceTo(uIcon.point) < 0) {
      // Record feedback data for this WWIcon if feedback is enabled.
      this.recordFeedback(dc, icon, uIcon.point, null);

      return null;
    }

    final Vec4 screenPoint = dc.getView().project(uIcon.point);
    if (screenPoint == null) {
      // Record feedback data for this WWIcon if feedback is enabled.
      this.recordFeedback(dc, icon, uIcon.point, null);

      return null;
    }

    double pedestalScale;
    double pedestalSpacing;
    if (this.pedestal != null) {
      pedestalScale = this.pedestal.getScale();
      pedestalSpacing = pedestal.getSpacingPixels();
    } else {
      pedestalScale = 0d;
      pedestalSpacing = 0d;
    }

    GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

    this.setDepthFunc(dc, uIcon, screenPoint);

    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();

    Dimension size = icon.getSize();
    double width = size != null ? size.getWidth() : icon.getImageTexture().getWidth(dc);
    double height = size != null ? size.getHeight() : icon.getImageTexture().getHeight(dc);
    gl.glTranslated(
        screenPoint.x - width / 2, screenPoint.y + (pedestalScale * height) + pedestalSpacing, 0d);

    if (icon.isHighlighted()) {
      double heightDelta = this.pedestal != null ? 0 : height / 2; // expand only above the pedestal
      gl.glTranslated(width / 2, heightDelta, 0);
      gl.glScaled(icon.getHighlightScale(), icon.getHighlightScale(), icon.getHighlightScale());
      gl.glTranslated(-width / 2, -heightDelta, 0);
    }

    Rectangle rect =
        new Rectangle(
            (int) (screenPoint.x - width / 2),
            (int) (screenPoint.y),
            (int) width,
            (int) (height + (pedestalScale * height) + pedestalSpacing));

    if (dc.isPickingMode()) {
      // If in picking mode and pick clipping is enabled, check to see if the icon is within the
      // pick volume.
      if (this.isPickFrustumClippingEnabled() && !dc.getPickFrustums().intersectsAny(rect)) {
        // Record feedback data for this WWIcon if feedback is enabled.
        this.recordFeedback(dc, icon, uIcon.point, rect);

        return screenPoint;
      } else {
        java.awt.Color color = dc.getUniquePickColor();
        int colorCode = color.getRGB();
        this.pickSupport.addPickableObject(colorCode, icon, uIcon.getPosition(), false);
        gl.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
      }
    }

    if (icon.getBackgroundTexture() != null)
      this.applyBackground(dc, icon, screenPoint, width, height, pedestalSpacing, pedestalScale);

    if (icon.getImageTexture().bind(dc)) {
      TextureCoords texCoords = icon.getImageTexture().getTexCoords();
      gl.glScaled(width, height, 1d);
      dc.drawUnitQuad(texCoords);
    }

    if (this.pedestal != null && this.pedestal.getImageTexture() != null) {
      gl.glLoadIdentity();
      gl.glTranslated(screenPoint.x - (pedestalScale * (width / 2)), screenPoint.y, 0d);
      gl.glScaled(width * pedestalScale, height * pedestalScale, 1d);

      if (this.pedestal.getImageTexture().bind(dc)) {
        TextureCoords texCoords = this.pedestal.getImageTexture().getTexCoords();
        dc.drawUnitQuad(texCoords);
      }
    }

    // Record feedback data for this WWIcon if feedback is enabled.
    this.recordFeedback(dc, icon, uIcon.point, rect);

    return screenPoint;
  }
Example #14
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);
    }
  }