Class EarthContextElement
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
-
Field Summary
Fields inherited from class noaa.coastwatch.render.PictureElement
position, preferred
-
Constructor Summary
ConstructorDescriptionCreates a new earth context element showing the entire Earth centered at (0'N, 0'E).EarthContextElement
(Point2D position, Dimension size, EarthTransform trans, DataLocation upperLeft, DataLocation lowerRight) Creates a new earth context element from the specified properties.EarthContextElement
(EarthLocation center) Creates a new earth context element showing the entire Earth.EarthContextElement
(EarthTransform trans, DataLocation upperLeft, DataLocation lowerRight) Creates a new earth context element from the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBoundingBox
(LineFeature polygon, Color color, String label) Adds a bounding box to this context element.void
addBoundingBox
(EarthTransform trans, DataLocation upperLeft, DataLocation lowerRight, Color color, String label) Adds a bounding box to this context element.Gets the element bounding area.getBoundingBox
(int index) Gets a polygon bounding box.int
Gets the current number of polygon bounding boxes.Gets the context element center earth location.Gets the current earth image transform for this element.Gets the font for rendering bounding box labels.Gets the lower-right corner of the context area.double
Gets the context size to total size factor.Gets the earth transform used in the context area, or null if no context area is defined.Gets the upper-left corner of the context area.void
Removes all polygon bounding boxes.void
render
(Graphics2D g, Color foreground, Color background) Renders the element graphics.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.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.void
setContextCenter
(EarthLocation center) Sets the earth context center projection point.void
setEdge
(boolean flag) Sets the edge flag to render the earth edges.void
setGrid
(boolean flag) Sets the grid flag to render a global grid.void
setGridIncrement
(int inc) Sets the grid increment in degrees.void
setLabelFont
(Font font) Sets the font for rendering bounding box labels.void
setPreferredSize
(Dimension size) Sets the preferred size of the picture.void
setResolutionLimit
(boolean flag) Sets the flag to limit the minimum pixel resolution in the context element (defaults to true).void
setSizeFactor
(double factor) Sets the context size to total size factor.void
Sets the solar zenith object.void
setSolarZenithFill
(Color dayColor, Color nightColor) Sets the solar zenith fill colors.Methods inherited from class noaa.coastwatch.render.PictureElement
setPosition
Methods inherited from class noaa.coastwatch.render.AnnotationElement
getBounds
-
Constructor Details
-
EarthContextElement
public EarthContextElement(Point2D position, Dimension size, EarthTransform trans, DataLocation upperLeft, DataLocation lowerRight) Creates a new earth context element from the specified properties.- Parameters:
position
- the top-left corner position of the picture.size
- the preferred size of the picture (seePictureElement.setPreferredSize(java.awt.Dimension)
).trans
- the earth transform for converting data to geographic coordinates.upperLeft
- the upper-left corner of the context data window.lowerRight
- the lower-right corner of the context data window.- See Also:
-
EarthContextElement
public EarthContextElement()Creates a new earth context element showing the entire Earth centered at (0'N, 0'E). -
EarthContextElement
Creates a new earth context element showing the entire Earth.- Parameters:
center
- the initial center location.- See Also:
-
EarthContextElement
Creates a new earth context element from the specified properties.- Parameters:
trans
- the earth transform for converting data to geographic coordinates.upperLeft
- the upper-left corner of the context data window.lowerRight
- the lower-right corner of the context data window.- See Also:
-
-
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
Gets the font for rendering bounding box labels. -
setLabelFont
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
Sets the solar zenith fill colors. If null, no filling is done for the solar zenith day or night areas. -
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
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
Gets the upper-left corner of the context area. This method is only valid if a context area is defined. -
getLowerRight
Gets the lower-right corner of the context area. This method is only valid if a context area is defined. -
getTransform
Gets the earth transform used in the context area, or null if no context area is defined. -
setContextArea
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
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
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
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 classPictureElement
- Parameters:
size
- the preferred picture size, or null if the picture size should be determined by the element.
-
setContextCenter
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
Gets the context element center earth location. -
render
Description copied from class:AnnotationElement
Renders the element graphics.- Specified by:
render
in classAnnotationElement
- Parameters:
g
- the graphics object for drawing.foreground
- the foreground element color.background
- the background element color or null for no background.
-
getArea
Description copied from class:AnnotationElement
Gets the element bounding area.- Specified by:
getArea
in classAnnotationElement
- Parameters:
g
- the graphics object for drawing.
-
getBoundingBoxes
public int getBoundingBoxes()Gets the current number of polygon bounding boxes. -
getBoundingBox
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
Gets the current earth image transform for this element.
-