public class IlvDefaultDataAnnotation extends Object implements IlvDataAnnotation, SwingConstants, Serializable
IlvDataAnnotation
interface
that draws a Swing Icon
.
This class references an object that implements the
javax.swing.Icon
interface, and draws it next to a
display point.
The location of the annotation is computed according to a position
relative to the display point with which it is associated. This position
can take the following values, defined in
javax.swing.SwingConstants
: CENTER, NORTH,
NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST
.
When the position is different from CENTER
, an offset in pixel
can be specified between the annotation and the display point.
Note that the IlvDefaultDataAnnotation
is immutable: changing either the
icon, position or offset creates a new instance.
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
Constructor and Description |
---|
IlvDefaultDataAnnotation(Icon icon)
Initializes a new
IlvDefaultDataAnnotation object that draws
the specified icon with a CENTER position. |
IlvDefaultDataAnnotation(Icon icon,
int position,
int offset)
Initializes a new
IlvDefaultDataAnnotation object that draws
the specified icon with the specified position and offset. |
IlvDefaultDataAnnotation(URL imageURL)
Initializes a new
IlvDefaultDataAnnotation object that draws
an image with a CENTER position. |
IlvDefaultDataAnnotation(URL imageURL,
int position,
int offset)
Initializes a new
IlvDefaultDataAnnotation object that draws
an image with the specified position and offset. |
Modifier and Type | Method and Description |
---|---|
protected Point |
computeIconLocation(IlvDisplayPoint dp)
Computes the location of the icon according to the specified display
point.
|
static Point |
computeLocation(Icon icon,
int position,
int offset,
Point anchor)
Computes the location of an icon according to a specified anchor,
position and offset.
|
void |
draw(Graphics g,
IlvDisplayPoint dp)
Draws the annotation according to the specified display point.
|
Rectangle2D |
getBounds(IlvDisplayPoint dp,
Rectangle2D bounds)
Returns the bounding rectangle of this annotation,
when displayed according to the specified display point.
|
Icon |
getIcon()
Returns the drawn icon.
|
int |
getOffset()
Returns the offset between the annotation and the display point.
|
int |
getPosition()
Returns the position of the annotation relative to the display point.
|
URL |
getURL()
Returns the URL of the drawn image.
|
IlvDefaultDataAnnotation |
setIcon(Icon icon)
Creates a copy of this annotation, with the specified icon.
|
IlvDefaultDataAnnotation |
setOffset(int offset)
Sets the offset between the annotation and the display point.
|
IlvDefaultDataAnnotation |
setPosition(int position)
Sets the position of the annotation relative to the display point.
|
public IlvDefaultDataAnnotation(URL imageURL)
IlvDefaultDataAnnotation
object that draws
an image with a CENTER
position.imageURL
- The URL of the image.getPosition()
public IlvDefaultDataAnnotation(URL imageURL, int position, int offset)
IlvDefaultDataAnnotation
object that draws
an image with the specified position and offset.imageURL
- The URL of the image.position
- The position of the icon relative to the display point.offset
- The offset of the icon, expressed in pixel.getPosition()
,
getOffset()
public IlvDefaultDataAnnotation(Icon icon)
IlvDefaultDataAnnotation
object that draws
the specified icon with a CENTER
position.getPosition()
public IlvDefaultDataAnnotation(Icon icon, int position, int offset)
IlvDefaultDataAnnotation
object that draws
the specified icon with the specified position and offset.icon
- The icon to draw.position
- The position of the icon relative to the display point.offset
- The offset of the icon, expressed in pixel.getPosition()
,
getOffset()
public final URL getURL()
IlvDefaultDataAnnotation(URL)
, or the
IlvDefaultDataAnnotation(URL, int, int)
constructor, and null
otherwise.public final Icon getIcon()
public final IlvDefaultDataAnnotation setIcon(Icon icon)
public final int getOffset()
public final IlvDefaultDataAnnotation setOffset(int offset)
offset
- The offset in pixels.public final int getPosition()
javax.swing.SwingConstants
:
CENTER
, NORTH
,
NORTH_EAST
, EAST
,
SOUTH_EAST
, SOUTH
,
SOUTH_WEST
, WEST,
NORTH_WEST
.
public final IlvDefaultDataAnnotation setPosition(int position)
position
- One of the following positions defined in
javax.swing.SwingConstants
:
CENTER
, NORTH
,
NORTH_EAST
, EAST
,
SOUTH_EAST
, SOUTH
,
SOUTH_WEST
, WEST,
NORTH_WEST
.
public void draw(Graphics g, IlvDisplayPoint dp)
draw
in interface IlvDataAnnotation
public Rectangle2D getBounds(IlvDisplayPoint dp, Rectangle2D bounds)
getBounds
in interface IlvDataAnnotation
dp
- The considered display point.bounds
- A rectangle optionally used to store the result. If
null
, a new Rectangle2D
is allocated.protected Point computeIconLocation(IlvDisplayPoint dp)
public static Point computeLocation(Icon icon, int position, int offset, Point anchor)
icon
- The considered icon.position
- The position relative to the anchor point.offset
- The offset between the anchor point and the icon.anchor
- The anchor point. This parameter is modified and returned
by the method.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.