|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.canvas.AbstractFigure
diva.canvas.toolbox.LabelFigure
public class LabelFigure
A figure which draws a string. If the string contains newlines, then it will be broken up into multiple lines. Strings can be "anchored" in the center or on one of the edges or corners, so that when the font or text changes, the label appears to stay in the right location.
Field Summary | |
---|---|
private int |
_anchor
The anchor on the label. |
private static int[] |
_anchors
The order of anchors used by the autoanchor method. |
private java.awt.geom.Rectangle2D |
_bounds
The bounds in the internal coordinate system. |
private java.awt.geom.Rectangle2D |
_cachedBounds
The cached bounds, in the external coordinate system |
private static java.awt.Font |
_defaultFont
The default font. |
private java.awt.Paint |
_fillPaint
The fill paint of the string. |
private java.awt.Font |
_font
The font. |
private double |
_padding
The "padding" around the text |
private java.awt.Shape |
_shape
The list of shapes used to draw the string, in the local coordinate system |
private java.lang.String |
_string
The string that gets painted. |
private TransformContext |
_transformContext
The transform context |
Constructor Summary | |
---|---|
LabelFigure()
Construct an empty label figure. |
|
LabelFigure(java.lang.String s)
Construct a label figure displaying the given string, using the default font. |
|
LabelFigure(java.lang.String s,
java.awt.Font f)
Construct a label figure displaying the given string in the given font. |
|
LabelFigure(java.lang.String s,
java.awt.Font font,
double padding,
int anchor)
Construct a label figure displaying the given string in the given font, with the given padding and anchor. |
|
LabelFigure(java.lang.String s,
java.awt.Font font,
double padding,
int anchor,
java.awt.Color color)
Construct a label figure displaying the given string in the given font, with the given padding and anchor, and the given color. |
|
LabelFigure(java.lang.String s,
java.lang.String face,
int style,
int size)
Construct a label figure displaying the given string in the given face, style, and size. |
Method Summary | |
---|---|
private void |
_update()
Update the shape used to draw the figure. |
void |
autoAnchor(java.awt.Shape s)
Choose an anchor point so as not to intersect a given figure. |
int |
getAnchor()
Get the point at which this figure is "anchored." |
java.awt.geom.Point2D |
getAnchorPoint()
Get the location at which the anchor is currently located. |
java.awt.geom.Rectangle2D |
getBounds()
Get the bounds of this string |
java.awt.Paint |
getFillPaint()
Get the fill paint for this label. |
java.awt.Font |
getFont()
Get the font that this label is drawn in. |
java.awt.geom.Point2D |
getOrigin()
Return the origin, which is the anchor point. |
double |
getPadding()
Get the padding around the text. |
java.awt.Shape |
getShape()
Get the shape of this label figure. |
java.lang.String |
getString()
Get the string. |
void |
paint(java.awt.Graphics2D g)
Paint the figure. |
void |
setAnchor(int anchor)
Set the point at which this figure is "anchored." |
void |
setFillPaint(java.awt.Paint p)
Set the fill paint that this shape is drawn with. |
void |
setFont(java.awt.Font f)
Set the font. |
void |
setPadding(double padding)
Set the "padding" around the text. |
void |
setString(java.lang.String s)
Set the string. |
void |
transform(java.awt.geom.AffineTransform at)
Transform the label with the given transform. |
void |
translateTo(double x,
double y)
Translate the label so that the current anchor is located at the given point. |
void |
translateTo(java.awt.geom.Point2D pt)
Translate the label so that the current anchor is located at the given point. |
Methods inherited from class diva.canvas.AbstractFigure |
---|
contains, getInteractor, getLayer, getParent, getToolTipText, getTransformContext, getUserObject, hit, intersects, isVisible, paint, repaint, repaint, setInteractor, setParent, setToolTipText, setUserObject, setVisible, translate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int _anchor
private java.awt.geom.Rectangle2D _bounds
private java.awt.geom.Rectangle2D _cachedBounds
private static java.awt.Font _defaultFont
private java.awt.Paint _fillPaint
private java.awt.Font _font
private double _padding
private java.awt.Shape _shape
private java.lang.String _string
private TransformContext _transformContext
private static int[] _anchors
Constructor Detail |
---|
public LabelFigure()
public LabelFigure(java.lang.String s)
public LabelFigure(java.lang.String s, java.lang.String face, int style, int size)
public LabelFigure(java.lang.String s, java.awt.Font f)
public LabelFigure(java.lang.String s, java.awt.Font font, double padding, int anchor)
public LabelFigure(java.lang.String s, java.awt.Font font, double padding, int anchor, java.awt.Color color)
Method Detail |
---|
public void autoAnchor(java.awt.Shape s)
public int getAnchor()
public java.awt.geom.Point2D getAnchorPoint()
public java.awt.geom.Rectangle2D getBounds()
getBounds
in interface Figure
getBounds
in class AbstractFigure
public java.awt.Font getFont()
public java.awt.Paint getFillPaint()
public java.awt.geom.Point2D getOrigin()
getOrigin
in interface Figure
getOrigin
in class AbstractFigure
AbstractFigure.getBounds()
public double getPadding()
public java.awt.Shape getShape()
getShape
in interface Figure
getShape
in class AbstractFigure
public java.lang.String getString()
public void paint(java.awt.Graphics2D g)
paint
in interface VisibleComponent
paint
in class AbstractFigure
public void setAnchor(int anchor)
public void setFillPaint(java.awt.Paint p)
public void setFont(java.awt.Font f)
public void setPadding(double padding)
public void setString(java.lang.String s)
public void transform(java.awt.geom.AffineTransform at)
transform
in interface Figure
transform
in class AbstractFigure
public void translateTo(double x, double y)
public void translateTo(java.awt.geom.Point2D pt)
private void _update()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |