public abstract class Legend
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.awt.Color |
back
The legend foreground and background colors.
|
static java.awt.Stroke |
DEFAULT_STROKE
The default stroke for line drawing.
|
protected java.awt.Font |
font
The legend font.
|
protected java.awt.Color |
fore
The legend foreground and background colors.
|
protected java.awt.Dimension |
preferredSize
The preferred dimensions for the legend.
|
static int |
SPACE_SIZE
The default space size between legend elements.
|
Modifier | Constructor and Description |
---|---|
protected |
Legend(java.awt.Dimension dim,
java.awt.Font font,
java.awt.Color fore,
java.awt.Color back)
Creates a new legend with the specified properties.
|
Modifier and Type | Method and Description |
---|---|
abstract java.awt.Dimension |
getSize(java.awt.Graphics2D g)
Gets the actual required legend size.
|
abstract void |
render(java.awt.Graphics2D g,
int x,
int y)
Renders the legend at the specified coordinates in the graphics
device.
|
void |
setBackground(java.awt.Color color)
Sets the background color.
|
void |
setFont(java.awt.Font font)
Sets the legend font.
|
void |
setForeground(java.awt.Color color)
Sets the foreground color.
|
void |
setPreferredSize(java.awt.Dimension size)
Sets the preferred size of the legend.
|
public static final int SPACE_SIZE
public static final java.awt.Stroke DEFAULT_STROKE
protected java.awt.Dimension preferredSize
protected java.awt.Font font
protected java.awt.Color fore
protected java.awt.Color back
protected Legend(java.awt.Dimension dim, java.awt.Font font, java.awt.Color fore, java.awt.Color back)
dim
- the dimensions for the legend, or null to detect the size
of the legend from the subclass getSize(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.public void setForeground(java.awt.Color color)
color
- the foreground color to be used for drawing legend
elements.public void setBackground(java.awt.Color color)
color
- the background colour to be used for drawing the legend
background., or null if no background is to be drawn.public void setPreferredSize(java.awt.Dimension size)
getSize(java.awt.Graphics2D)
to determine the actual rendered size. If the
preferred size is null, then the class determines an optimal
size.size
- the preferred legend size, or null for none.public abstract void render(java.awt.Graphics2D g, int x, int y)
g
- the graphics device for rendering.x
- the x coordinate of the top-left corner.y
- the y coordinate of the top-left corner.public abstract java.awt.Dimension getSize(java.awt.Graphics2D g)
g
- the graphics device that the legend will be rendered on.public void setFont(java.awt.Font font)
font
- the legend font, or null to use the default font face,
plain style, 12 point.