Exemplo n.º 1
0
  public java.awt.Dimension getPreferredSize(DrawContext dc) {
    java.awt.Dimension imageSize = this.getImageSize(dc);
    java.awt.Dimension insetSize = null;

    // Optionally set the annotation's inset size to the image size.
    if (this.isFitSizeToImage()) {
      insetSize = imageSize;
    }

    // Fallback to the superclass preferred size.
    if (insetSize == null) {
      insetSize = super.getPreferredSize(dc);

      // Optionally set the annotation's aspect ratio to that of the image. We'll use the superclass
      // width, and
      // override it's height to match the image's aspect ration.
      if (this.isUseImageAspectRatio() && imageSize != null) {
        double aspect = imageSize.getHeight() / imageSize.getWidth();
        insetSize =
            new java.awt.Dimension(insetSize.width, (int) Math.round(aspect * insetSize.width));
      }
    }

    java.awt.Insets insets = this.getAttributes().getInsets();
    return new java.awt.Dimension(
        insetSize.width + (insets.left + insets.right),
        insetSize.height + (insets.top + insets.bottom));
  }
Exemplo n.º 2
0
  protected void transformBackgroundImageCoordsToAnnotationCoords(
      DrawContext dc, int width, int height, WWTexture texture) {
    GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

    // Scale background image coordinates to fit the Annotation's dimensions.
    java.awt.Dimension size = this.getImageSize(dc);
    if (size != null) {
      gl.glScaled(size.getWidth() / (double) width, size.getHeight() / (double) height, 1d);
    }

    super.transformBackgroundImageCoordsToAnnotationCoords(dc, width, height, texture);
  }