private Vec4 computeReferencePoint(DrawContext dc) {
    if (dc.getViewportCenterPosition() != null)
      return dc.getGlobe().computePointFromPosition(dc.getViewportCenterPosition());

    java.awt.geom.Rectangle2D viewport = dc.getView().getViewport();
    int x = (int) viewport.getWidth() / 2;
    for (int y = (int) (0.5 * viewport.getHeight()); y >= 0; y--) {
      Position pos = dc.getView().computePositionFromScreenPoint(x, y);
      if (pos == null) continue;

      return dc.getGlobe().computePointFromPosition(pos.getLatitude(), pos.getLongitude(), 0d);
    }

    return null;
  }
Beispiel #2
0
 static void aligntext(Graphics g, String text, Coord c, double ax, double ay) {
   java.awt.FontMetrics m = g.getFontMetrics();
   java.awt.geom.Rectangle2D ts = m.getStringBounds(text, g);
   g.drawString(
       text, (int) (c.x - ts.getWidth() * ax), (int) (c.y + m.getAscent() - ts.getHeight() * ay));
 }
Beispiel #3
0
 static Coord textsz(Graphics g, String text) {
   java.awt.FontMetrics m = g.getFontMetrics();
   java.awt.geom.Rectangle2D ts = m.getStringBounds(text, g);
   return (new Coord((int) ts.getWidth(), (int) ts.getHeight()));
 }