Class EarthContextElement


public class EarthContextElement extends PictureElement

The EarthContextElement is a picture element that renders a simplified view of the earth with coastlines and the bounding boxes of a number of arbitrarily shaped areas. The earth is shown in an orthographic projection. The picture element is designed similarly to a National Geographic magazine map legend, which shows a little version of the big map with extra context information around it in the form of coastlines and grid lines in order to give the user some idea of where on the earth the current map is located. In a context element, the "context area" is the area of interest, usually the boundaries of some earth dataset. By default the largest dimension of the context area is about 15% of the element size. This size factor may be set, along with other properties such as the center point and context area itself.

The context element may be set up to highlight not only the central context area, but a set of individual areas via the specification of polygon bounding boxes. The box edges are rendered in a highlighted color, and filled with a slightly darker, semi-transparent version of the same color. The bounding boxes may optionally be annotated with text labels, which are centered on each box area and rendered in a default 12 point font using the same color as the box edges.

Since:
3.1.1
Author:
Peter Hollemans
  • Constructor Details

  • Method Details

    • setResolutionLimit

      public void setResolutionLimit(boolean flag)
      Sets the flag to limit the minimum pixel resolution in the context element (defaults to true). When true, the resolution (km/pixel) of the context element has a lower limit so that at least 1/4 width of the earth is shown in the orthographic projection. This way there are likely to be at least some coastlines visible for context. Setting this resolution limit flag to false removes this lower limit so that much smaller areas of the earth may be shown, at the risk of having no coastlines or grid lines visible in the context element's area.
      Parameters:
      flag - the new resolution limit flag value.
      Since:
      3.4.1
      See Also:
    • getLabelFont

      public Font getLabelFont()
      Gets the font for rendering bounding box labels.
    • setLabelFont

      public void setLabelFont(Font font)
      Sets the font for rendering bounding box labels.
    • getSizeFactor

      public double getSizeFactor()
      Gets the context size to total size factor.
    • setSizeFactor

      public void setSizeFactor(double factor)
      Sets the context size to total size factor. This method must be called prior to setting the context area in order to have any effect.
    • setSolarZenithFill

      public void setSolarZenithFill(Color dayColor, Color nightColor)
      Sets the solar zenith fill colors. If null, no filling is done for the solar zenith day or night areas.
      See Also:
    • setEdge

      public void setEdge(boolean flag)
      Sets the edge flag to render the earth edges.
    • setGrid

      public void setGrid(boolean flag)
      Sets the grid flag to render a global grid.
    • setGridIncrement

      public void setGridIncrement(int inc)
      Sets the grid increment in degrees. By default, the grid increment is 30.
    • setSolarZenith

      public void setSolarZenith(SolarZenith sz)
      Sets the solar zenith object. If null, no solar zenith line is drawn.
    • addBoundingBox

      public void addBoundingBox(EarthTransform trans, DataLocation upperLeft, DataLocation lowerRight, Color color, String label)
      Adds a bounding box to this context element. The new bounding box is created by tracing the edges of the data window at regular intervals to form a closed polygon.
      Parameters:
      trans - the earth transform for converting data to geographic coordinates.
      upperLeft - the upper-left corner of the data window.
      lowerRight - the lower-right corner of the data window.
      color - the bounding box color.
      label - the bounding box label, or null for no label.
    • getUpperLeft

      public DataLocation getUpperLeft()
      Gets the upper-left corner of the context area. This method is only valid if a context area is defined.
    • getLowerRight

      public DataLocation getLowerRight()
      Gets the lower-right corner of the context area. This method is only valid if a context area is defined.
    • getTransform

      public EarthTransform getTransform()
      Gets the earth transform used in the context area, or null if no context area is defined.
    • setContextArea

      public void setContextArea(EarthArea area)
      Sets the area which should be used as the center of attention in the context element using an earth area object. The context area apears centered and magnified.
      Parameters:
      area - the earth area to use for the context area. The area center point and context size are determined by examining the extreme latitude and longitude values.
      See Also:
    • setContextArea

      public void setContextArea(EarthTransform trans, DataLocation upperLeft, DataLocation lowerRight)
      Sets the area which should be used as the center of attention in the context element using an earth transform and data location bounds. The context area appears centered and magnified.
      Parameters:
      trans - the earth transform for converting data to geographic coordinates.
      upperLeft - the upper-left corner of the data window.
      lowerRight - the lower-right corner of the data window.
      See Also:
    • removeAllBoundingBoxes

      public void removeAllBoundingBoxes()
      Removes all polygon bounding boxes.
    • addBoundingBox

      public void addBoundingBox(LineFeature polygon, Color color, String label)
      Adds a bounding box to this context element.
      Parameters:
      polygon - the bounding box earth location polygon points.
      color - the bounding box color.
      label - the bounding box label, or null for no label.
    • setPreferredSize

      public void setPreferredSize(Dimension size)
      Description copied from class: PictureElement
      Sets the preferred size of the picture. The actual picture size may be different than the preferred size. The picture aspect ratio is kept the same, so that the actual picture fits into the preferred size rectangle.
      Overrides:
      setPreferredSize in class PictureElement
      Parameters:
      size - the preferred picture size, or null if the picture size should be determined by the element.
    • setContextCenter

      public void setContextCenter(EarthLocation center)
      Sets the earth context center projection point. This has the effect of changing the context element to a global view centered on the specified location.
      Parameters:
      center - the new center location.
    • getCenter

      public EarthLocation getCenter()
      Gets the context element center earth location.
    • render

      public void render(Graphics2D g, Color foreground, Color background)
      Description copied from class: AnnotationElement
      Renders the element graphics.
      Specified by:
      render in class AnnotationElement
      Parameters:
      g - the graphics object for drawing.
      foreground - the foreground element color.
      background - the background element color or null for no background.
    • getArea

      public Area getArea(Graphics2D g)
      Description copied from class: AnnotationElement
      Gets the element bounding area.
      Specified by:
      getArea in class AnnotationElement
      Parameters:
      g - the graphics object for drawing.
    • getBoundingBoxes

      public int getBoundingBoxes()
      Gets the current number of polygon bounding boxes.
    • getBoundingBox

      public LineFeature getBoundingBox(int index)
      Gets a polygon bounding box.
      Parameters:
      index - the index of the desired polygon bounding box, in the range [0..boxes-1].
      Returns:
      the bounding box as a list of earth locations.
      See Also:
    • getEarthImageTransform

      public EarthImageTransform getEarthImageTransform()
      Gets the current earth image transform for this element.