Package noaa.coastwatch.render
Class Legend
java.lang.Object
noaa.coastwatch.render.Legend
- Direct Known Subclasses:
DataColorScale
,EarthPlotInfo
A legend is used to annotate data with descriptive elements. A
legend may have a desired size, font, and color. The actual size
of the legend may vary from the desired size.
- Since:
- 3.1.1
- Author:
- Peter Hollemans
-
Field Summary
Modifier and TypeFieldDescriptionprotected Color
The legend foreground and background colors.static final Stroke
The default stroke for line drawing.protected Font
The legend font.protected Color
The legend foreground and background colors.protected Dimension
The preferred dimensions for the legend.static final int
The default space size between legend elements. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract Dimension
Gets the actual required legend size.abstract void
render
(Graphics2D g, int x, int y) Renders the legend at the specified coordinates in the graphics device.void
setBackground
(Color color) Sets the background color.void
Sets the legend font.void
setForeground
(Color color) Sets the foreground color.void
setPreferredSize
(Dimension size) Sets the preferred size of the legend.
-
Field Details
-
SPACE_SIZE
public static final int SPACE_SIZEThe default space size between legend elements.- See Also:
-
DEFAULT_STROKE
The default stroke for line drawing. -
preferredSize
The preferred dimensions for the legend. -
font
The legend font. -
fore
The legend foreground and background colors. -
back
The legend foreground and background colors.
-
-
Constructor Details
-
Legend
Creates a new legend with the specified properties.- Parameters:
dim
- the dimensions for the legend, or null to detect the size of the legend from the subclassgetSize(java.awt.Graphics2D)
method.font
- the font the use for the legend text.fore
- the forground color to use for text and lines.back
- the background colour for filling behind the legend contents.
-
-
Method Details
-
setForeground
Sets the foreground color.- Parameters:
color
- the foreground color to be used for drawing legend elements.
-
setBackground
Sets the background color.- Parameters:
color
- the background colour to be used for drawing the legend background, or null if no background is to be drawn.
-
setPreferredSize
Sets the preferred size of the legend. The actual size of the legend may or may not match the preferred size. UsegetSize(java.awt.Graphics2D)
to determine the actual rendered size. If the preferred size is null, then the class determines an optimal size.- Parameters:
size
- the preferred legend size, or null for none.
-
render
Renders the legend at the specified coordinates in the graphics device.- Parameters:
g
- the graphics device for rendering.x
- the x coordinate of the top-left corner.y
- the y coordinate of the top-left corner.
-
getSize
Gets the actual required legend size.- Parameters:
g
- the graphics device that the legend will be rendered on.
-
setFont
Sets the legend font.- Parameters:
font
- the legend font, or null to use the default font face, plain style, 12 point.
-