protected void showAnnotationPanel(String annoText) {
    String text = this.splitLines(annoText);

    AnnotationAttributes attrs = this.getAnnotationPanelAttributes(text);
    int yOffset =
        Math.min(this.controller.getWWPanel().getSize().height - attrs.getSize().height, 250);
    Point location = new Point(10 + attrs.getSize().width / 2, yOffset);

    if (this.annotationPanel != null)
      this.annotationPanel.setAttributes(this.getAnnotationPanelAttributes(text));
    else
      this.annotationPanel =
          new ScreenAnnotation(annoText, location, getAnnotationPanelAttributes(text));

    this.annotationPanel.setScreenPoint(location);
    this.annotationPanel.setText(text);

    if (this.annotationLayer == null) {
      this.annotationLayer = new AnnotationLayer();
      this.annotationLayer.setPickEnabled(false);
    }

    this.annotationLayer.removeAllAnnotations();
    this.annotationLayer.addAnnotation(this.annotationPanel);
    if (!this.controller.getActiveLayers().contains(this.annotationLayer))
      this.controller.addInternalLayer(this.annotationLayer);
  }
  /**
   * Select the visible grid elements
   *
   * @param dc the current <code>DrawContext</code>.
   */
  protected void selectRenderables(DrawContext dc) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }
    Sector vs = dc.getVisibleSector();
    OrbitView view = (OrbitView) dc.getView();
    // Compute labels offset from view center
    Position centerPos = view.getCenterPosition();
    Double pixelSizeDegrees =
        Angle.fromRadians(
                view.computePixelSizeAtDistance(view.getZoom())
                    / dc.getGlobe().getEquatorialRadius())
            .degrees;
    Double labelOffsetDegrees = pixelSizeDegrees * view.getViewport().getWidth() / 4;
    Position labelPos =
        Position.fromDegrees(
            centerPos.getLatitude().degrees - labelOffsetDegrees,
            centerPos.getLongitude().degrees - labelOffsetDegrees,
            0);
    Double labelLatDegrees = labelPos.getLatitude().normalizedLatitude().degrees;
    labelLatDegrees = Math.min(Math.max(labelLatDegrees, -76), 78);
    labelPos =
        new Position(
            Angle.fromDegrees(labelLatDegrees), labelPos.getLongitude().normalizedLongitude(), 0);

    if (vs != null) {
      for (GridElement ge : this.gridElements) {
        if (ge.isInView(dc)) {
          if (ge.renderable instanceof GeographicText) {
            GeographicText gt = (GeographicText) ge.renderable;
            if (labelPos.getLatitude().degrees < 72
                || "*32*34*36*".indexOf("*" + gt.getText() + "*") == -1) {
              // Adjust label position according to eye position
              Position pos = gt.getPosition();
              if (ge.type.equals(GridElement.TYPE_LATITUDE_LABEL))
                pos =
                    Position.fromDegrees(
                        pos.getLatitude().degrees,
                        labelPos.getLongitude().degrees,
                        pos.getElevation());
              else if (ge.type.equals(GridElement.TYPE_LONGITUDE_LABEL))
                pos =
                    Position.fromDegrees(
                        labelPos.getLatitude().degrees,
                        pos.getLongitude().degrees,
                        pos.getElevation());

              gt.setPosition(pos);
            }
          }

          this.graticuleSupport.addRenderable(ge.renderable, GRATICULE_UTM);
        }
      }
      // System.out.println("Total elements: " + count + " visible sector: " + vs);
    }
  }
  /**
   * Determine the panel size needed to display the full annotation.
   *
   * @param annoText the annotation text.
   * @return the required panel size.
   */
  protected Dimension computePanelSize(String annoText) {
    Dimension lengths = this.computeLengths(annoText);

    // The numbers used below are the average width of a character and average height of a line in
    // Arial-Plain-12.
    int width = 7 * Math.min(lengths.width, this.maxLineLength);
    int height = lengths.height * 17;

    return new Dimension(width, height);
  }
Exemplo n.º 4
0
 protected double computeScale(java.awt.Rectangle viewport) {
   if (this.resizeBehavior.equals(AVKey.RESIZE_SHRINK_ONLY)) {
     return Math.min(1d, (this.toViewportScale) * viewport.width / this.getScaledIconWidth());
   } else if (this.resizeBehavior.equals(AVKey.RESIZE_STRETCH)) {
     return (this.toViewportScale) * viewport.width / this.getScaledIconWidth();
   } else if (this.resizeBehavior.equals(AVKey.RESIZE_KEEP_FIXED_SIZE)) {
     return 1d;
   } else {
     return 1d;
   }
 }