edu.neu.ccs.gui
Class TextPaintable

java.lang.Object
  extended byedu.neu.ccs.gui.AbstractPaintable
      extended byedu.neu.ccs.gui.TextPaintable
All Implemented Interfaces:
JPTConstants, Paintable, SupportsPropertyChange, SwingConstants

public class TextPaintable
extends AbstractPaintable

A TextPaintable creates a Paintable using a string, a font, and other related data.

In 2.3.5, the class was refactored to be consistent with the new Paintable interface and the new AbstractPaintable class.

In 2.4.0, the default anchor locator was changed from TextAnchor.LEFT_BASELINE to TextAnchor.LEFT_ASCENTLINE. The rationale for this change is to allow text with the default anchor locator and default anchor position of (0, 0) to be visible in a panel or window whose upper left corner is also (0, 0). In practice, a user is likely to want to set the anchor locator and anchor position explicitly but this new default makes it easier to do quick testing.

In 2.4.0, several constructors were added that permit the anchor locator and anchor position to be set without specifying other parameters.

In 2.4.0, this class was also updated to be consistent with refinements to the Paintable interface.

In 2.6.0, changed getOriginalCenter() to return a point equal to the anchor position unless the caller has set a specific default original position.

In 2.6.0, changed setAnchorPostion by calling a new method shiftAnchorPostion. This method makes an adjustment to the internal mutator so that the net effect is visually the same as if the shift had been applied by calling the move method on the mutated paintable.

In 2.6.0, removed final designations on methods to allow for overrides.

Since:
2.3
Version:
2.6.0
See Also:
MultiLineTextPaintable

Field Summary
private  float anchorX
          The x anchor position.
private  float anchorY
          The y anchor position.
private  Paint fillpaint
          The fill paint.
private  Font font
          The font.
private  TextAnchor.Locator locator
          The text anchor locator.
static String SET_ANCHOR_LOCATOR
          Bound property name for set anchor locator.
static String SET_ANCHOR_POSITION
          Bound property name for set anchor position.
static String SET_BOUNDS_STRATEGY
          Bound property name for set bounds strategy.
static String SET_FILL_PAINT
          Bound property name for set fill paint.
static String SET_FONT
          Bound property name for set font.
static String SET_STRING
          Bound property name for set string.
static FontRenderContext standardFRC
          The standard font render context defined using the identity transform, anti-aliasing on, and fractional-metrics off.
private  TextBounds.Strategy strategy
          The text bounds strategy.
private  String string
          The text string.
private  TextLayout textLayout
          The TextLayout for bounds computation and text rendering.
 
Fields inherited from class edu.neu.ccs.gui.AbstractPaintable
SET_BACKGROUND_PAINT, SET_BACKGROUND_TILE
 
Fields inherited from interface edu.neu.ccs.gui.Paintable
REMOVE_PAINTABLE, SET_CLIPPING_SHAPE, SET_DEFAULT_BOUNDS2D, SET_DEFAULT_CENTER, SET_DEFAULT_ORIGINAL_BOUNDS2D, SET_DEFAULT_ORIGINAL_CENTER, SET_MUTATOR, SET_OPACITY, SET_PAINTABLE, SET_VISIBLE, SHIFT_PAINTABLE
 
Fields inherited from interface edu.neu.ccs.util.JPTConstants
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
TextPaintable()
          The constructor that creates a TextPaintable with all defaults.
TextPaintable(String string)
          The constructor that creates a TextPaintable with the given string and with the defaults set as described in the default constructor.
TextPaintable(String string, float anchorX, float anchorY)
          The constructor that creates a TextPaintable with the given string and anchor position and with the defaults set as described in the default constructor.
TextPaintable(String string, Font font)
          The constructor that creates a TextPaintable with the given string and font and with the defaults set as described in the default constructor.
TextPaintable(String string, Font font, float anchorX, float anchorY)
          The constructor that creates a TextPaintable with the given string, font, and anchor position and with the defaults set as described in the default constructor.
TextPaintable(String string, Font font, Paint fillpaint)
          The constructor that creates a TextPaintable with the given string, font, and fill paint and with the defaults set as described in the default constructor.
TextPaintable(String string, Font font, Paint fillpaint, float anchorX, float anchorY)
          The constructor that creates a TextPaintable with the given string, font, fill paint, and anchor position and with the defaults set as described in the default constructor.
TextPaintable(String string, Font font, Paint fillpaint, TextAnchor.Locator locator, float anchorX, float anchorY)
          The constructor that creates a TextPaintable with the given string, font, fill paint, anchor locator, and anchor position and with the defaults set as described in the default constructor.
TextPaintable(String string, Font font, Paint fillpaint, TextBounds.Strategy strategy)
          The constructor that creates a TextPaintable with the given string, font, fill paint, and bounds strategy and with the defaults set as described in the default constructor.
TextPaintable(String string, Font font, Paint fillpaint, TextBounds.Strategy strategy, float anchorX, float anchorY)
          The constructor that creates a TextPaintable with the given string, font, fill paint, bounds strategy, and anchor position and with the defaults set as described in the default constructor.
TextPaintable(String string, Font font, Paint fillpaint, TextBounds.Strategy strategy, TextAnchor.Locator locator)
          The constructor that creates a TextPaintable with the given string, font, fill paint, bounds strategy, and anchor locator and with the defaults set as described in the default constructor.
TextPaintable(String string, Font font, Paint fillpaint, TextBounds.Strategy strategy, TextAnchor.Locator locator, float anchorX, float anchorY)
          The constructor that creates a TextPaintable with the given string, font, fill paint, bounds strategy, anchor locator, and anchor position.
TextPaintable(String string, Font font, TextAnchor.Locator locator, float anchorX, float anchorY)
          The constructor that creates a TextPaintable with the given string, font, anchor locator, and anchor position and with the defaults set as described in the default constructor.
TextPaintable(String string, TextAnchor.Locator locator, float anchorX, float anchorY)
          The constructor that creates a TextPaintable with the given string, anchor locator, and anchor position and with the defaults set as described in the default constructor.
 
Method Summary
 XRect getActualBounds2D()
          Returns the actual bounds of the original paintable or null if the paintable is effectively empty.
 TextAnchor.Locator getAnchorLocator()
          Returns the TextAnchor.Locator for this TextPaintable.
 float[] getAnchorPosition()
          Returns a copy of the anchor position for this TextPaintable as an array float[2].
 float getAscentLineY()
          Returns the ascent line y-coordinate of this TextPaintable.
 float getBaseLineY()
          Returns the base line y-coordinate of this TextPaintable.
 TextBounds.Strategy getBoundsStrategy()
          Returns the bounds strategy for this TextPaintable.
 float getCenterX()
          Returns the center x-coordinate of this TextPaintable.
static Font getDefaultFont()
          Returns the default font for a JLabel in the current UI settings.
 float getDescentLineY()
          Returns the descent line y-coordinate of this TextPaintable.
 Paint getFillPaint()
          Returns the fill paint for this TextPaintable.
 Font getFont()
          Returns the font for this TextPaintable.
 float getHeight()
          Returns the height of the area that will be occupied by this TextPaintable.
 float getLeadingLineY()
          Returns the leading line y-coordinate of this TextPaintable.
 float getLeftX()
          Returns the left x-coordinate of this TextPaintable.
 XRect getLooseBounds()
          Returns the smallest rectangle that contains the pair of rectangles getStringBounds() and getTightBounds().
 XPoint2D getOriginalCenter()
          Returns a copy of the center of the paint region affected by the originalPaint method.
 Shape getOutline()
          Returns the Shape that represents the outline of the rendered text string in its font at its location.
 float getRightX()
          Returns the right x-coordinate of this TextPaintable.
 String getString()
          Returns the string for this TextPaintable.
 XRect getStringBounds()
          Returns a copy of the 2-dimensional bounds of the original paint region as computed using the getStringBounds method of the Font class together with the anchor locator.
 TextLayout getTextLayout()
          Returns the internal TextLayout that encapsulates the text string and the font.
 XRect getTightBounds()
          Returns a copy of the 2-dimensional bounds of the original paint region as computed using the getBounds method of the TextLayout class together with the anchor locator.
 float getWidth()
          Returns the width of the area that will be occupied by this TextPaintable.
 boolean originalContains(double x, double y)
          Tests if a point specified by coordinates is inside the original paintable without mutation.
 void originalPaint(Graphics g)
          Paints onto a Graphics context using information from this object but without the use of the mutator transform.
private  void resetTextLayout()
          Resets the text layout on string or font change.
 void setAnchorLocator(TextAnchor.Locator locator)
          Sets the TextAnchor.Locator for this TextPaintable.
 void setAnchorPosition(float[] position)
          Sets the anchor position for this TextPaintable using an array float[2].
 void setAnchorPosition(float anchorX, float anchorY)
          Sets the anchor position for this TextPaintable.
 void setBoundsStrategy(TextBounds.Strategy strategy)
          Sets the bounds strategy for this TextPaintable.
 void setFillPaint(Paint fillpaint)
          Sets the fill paint for this TextPaintable.
 void setFont(Font font)
          Sets the font for this TextPaintable.
 void setString(String string)
          Sets the string for this TextPaintable.
 void shiftAnchorPosition(float dx, float dy)
          Shift the anchor position by the given dx and dy.
 
Methods inherited from class edu.neu.ccs.gui.AbstractPaintable
addForwardingListener, addPostMutation, addPostMutation, addPreMutation, addPreMutation, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListeners, addPropertyChangeListeners, affinetransform, applyOpacity, clearBackgroundPaint, clearBackgroundTile, clearBothBackgrounds, contains, contains, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundPaint, getBackgroundTile, getBounds2D, getCenter, getCorner, getDefaultBounds2D, getDefaultCenter, getDefaultOriginalBounds2D, getDefaultOriginalCenter, getForwardingListener, getMutator, getMutatorInverse, getOpacity, getOriginalBounds2D, getPreparedGraphics2D, getPropertyChangeListeners, getPropertyChangeListeners, glide, glidereflect, hasListeners, hreflect, isVisible, lineartransform, makeSnapshot, move, move, moveCenterTo, moveCenterTo, moveCornerTo, moveCornerTo, mutate, mutate, originalContains, paint, paintAsTiles, paintAsTiles, paintAsTiles, paintAt, paintAt, paintAt, paintAt, possiblyContains, reflect, removeAndAddForwardingListener, removeForwardingListener, removePropertyChangeListener, removePropertyChangeListener, rotate, scale, scale, setBackgroundPaint, setBackgroundTile, setDefaultBounds2D, setDefaultCenter, setDefaultOriginalBounds2D, setDefaultOriginalCenter, setMutator, setMutator, setOpacity, setVisible, shear, vreflect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SET_STRING

public static final String SET_STRING
Bound property name for set string.

See Also:
Constant Field Values

SET_FONT

public static final String SET_FONT
Bound property name for set font.

See Also:
Constant Field Values

SET_FILL_PAINT

public static final String SET_FILL_PAINT
Bound property name for set fill paint.

See Also:
Constant Field Values

SET_ANCHOR_LOCATOR

public static final String SET_ANCHOR_LOCATOR
Bound property name for set anchor locator.

See Also:
Constant Field Values

SET_ANCHOR_POSITION

public static final String SET_ANCHOR_POSITION
Bound property name for set anchor position.

See Also:
Constant Field Values

SET_BOUNDS_STRATEGY

public static final String SET_BOUNDS_STRATEGY
Bound property name for set bounds strategy.

See Also:
Constant Field Values

standardFRC

public static final FontRenderContext standardFRC
The standard font render context defined using the identity transform, anti-aliasing on, and fractional-metrics off.


string

private String string
The text string.


font

private Font font
The font.


fillpaint

private Paint fillpaint
The fill paint.


strategy

private TextBounds.Strategy strategy
The text bounds strategy.


locator

private TextAnchor.Locator locator
The text anchor locator.


anchorX

private float anchorX
The x anchor position.


anchorY

private float anchorY
The y anchor position.


textLayout

private TextLayout textLayout
The TextLayout for bounds computation and text rendering.

Constructor Detail

TextPaintable

public TextPaintable()

The constructor that creates a TextPaintable with all defaults.


TextPaintable

public TextPaintable(String string)

The constructor that creates a TextPaintable with the given string and with the defaults set as described in the default constructor.

Parameters:
string - the string to display
See Also:
TextPaintable()

TextPaintable

public TextPaintable(String string,
                     float anchorX,
                     float anchorY)

The constructor that creates a TextPaintable with the given string and anchor position and with the defaults set as described in the default constructor.

Parameters:
string - the string to display
anchorX - the anchor x-coordinate
anchorY - the anchor y-coordinate
See Also:
TextPaintable()

TextPaintable

public TextPaintable(String string,
                     TextAnchor.Locator locator,
                     float anchorX,
                     float anchorY)

The constructor that creates a TextPaintable with the given string, anchor locator, and anchor position and with the defaults set as described in the default constructor.

Parameters:
string - the string to display
locator - the locator for the anchor position
anchorX - the anchor x-coordinate
anchorY - the anchor y-coordinate
See Also:
TextPaintable()

TextPaintable

public TextPaintable(String string,
                     Font font)

The constructor that creates a TextPaintable with the given string and font and with the defaults set as described in the default constructor.

Parameters:
string - the string to display
font - the font to use to display the string
See Also:
TextPaintable()

TextPaintable

public TextPaintable(String string,
                     Font font,
                     float anchorX,
                     float anchorY)

The constructor that creates a TextPaintable with the given string, font, and anchor position and with the defaults set as described in the default constructor.

Parameters:
string - the string to display
font - the font to use to display the string
anchorX - the anchor x-coordinate
anchorY - the anchor y-coordinate
See Also:
TextPaintable()

TextPaintable

public TextPaintable(String string,
                     Font font,
                     TextAnchor.Locator locator,
                     float anchorX,
                     float anchorY)

The constructor that creates a TextPaintable with the given string, font, anchor locator, and anchor position and with the defaults set as described in the default constructor.

Parameters:
string - the string to display
font - the font to use to display the string
locator - the locator for the anchor position
anchorX - the anchor x-coordinate
anchorY - the anchor y-coordinate
See Also:
TextPaintable()

TextPaintable

public TextPaintable(String string,
                     Font font,
                     Paint fillpaint)

The constructor that creates a TextPaintable with the given string, font, and fill paint and with the defaults set as described in the default constructor.

Parameters:
string - the string to display
font - the font to use to display the string
fillpaint - the paint to use to fill the string
See Also:
TextPaintable()

TextPaintable

public TextPaintable(String string,
                     Font font,
                     Paint fillpaint,
                     float anchorX,
                     float anchorY)

The constructor that creates a TextPaintable with the given string, font, fill paint, and anchor position and with the defaults set as described in the default constructor.

Parameters:
string - the string to display
font - the font to use to display the string
fillpaint - the paint to use to fill the string
anchorX - the anchor x-coordinate
anchorY - the anchor y-coordinate
See Also:
TextPaintable()

TextPaintable

public TextPaintable(String string,
                     Font font,
                     Paint fillpaint,
                     TextAnchor.Locator locator,
                     float anchorX,
                     float anchorY)

The constructor that creates a TextPaintable with the given string, font, fill paint, anchor locator, and anchor position and with the defaults set as described in the default constructor.

Parameters:
string - the string to display
font - the font to use to display the string
fillpaint - the paint to use to fill the string
locator - the locator for the anchor position
anchorX - the anchor x-coordinate
anchorY - the anchor y-coordinate
See Also:
TextPaintable()

TextPaintable

public TextPaintable(String string,
                     Font font,
                     Paint fillpaint,
                     TextBounds.Strategy strategy)

The constructor that creates a TextPaintable with the given string, font, fill paint, and bounds strategy and with the defaults set as described in the default constructor.

Parameters:
string - the string to display
font - the font to use to display the string
fillpaint - the paint to use to fill the string
strategy - the strategy to use to compute the paintable bounds
See Also:
TextPaintable()

TextPaintable

public TextPaintable(String string,
                     Font font,
                     Paint fillpaint,
                     TextBounds.Strategy strategy,
                     float anchorX,
                     float anchorY)

The constructor that creates a TextPaintable with the given string, font, fill paint, bounds strategy, and anchor position and with the defaults set as described in the default constructor.

Parameters:
string - the string to display
font - the font to use to display the string
fillpaint - the paint to use to fill the string
strategy - the strategy to use to compute the paintable bounds
anchorX - the anchor x-coordinate
anchorY - the anchor y-coordinate
See Also:
TextPaintable()

TextPaintable

public TextPaintable(String string,
                     Font font,
                     Paint fillpaint,
                     TextBounds.Strategy strategy,
                     TextAnchor.Locator locator)

The constructor that creates a TextPaintable with the given string, font, fill paint, bounds strategy, and anchor locator and with the defaults set as described in the default constructor.

Parameters:
string - the string to display
font - the font to use to display the string
fillpaint - the paint to use to fill the string
strategy - the strategy to use to compute the paintable bounds
locator - the locator for the anchor position
See Also:
TextPaintable()

TextPaintable

public TextPaintable(String string,
                     Font font,
                     Paint fillpaint,
                     TextBounds.Strategy strategy,
                     TextAnchor.Locator locator,
                     float anchorX,
                     float anchorY)

The constructor that creates a TextPaintable with the given string, font, fill paint, bounds strategy, anchor locator, and anchor position.

Parameters that are null are set to the following defaults as in the default constructor:

Parameters:
string - the string to display
font - the font to use to display the string
fillpaint - the paint to use to fill the string
strategy - the strategy to use to compute the paintable bounds
locator - the locator for the anchor position
anchorX - the anchor x-coordinate
anchorY - the anchor y-coordinate
See Also:
TextPaintable()
Method Detail

originalPaint

public void originalPaint(Graphics g)

Paints onto a Graphics context using information from this object but without the use of the mutator transform.

Does nothing if the encapsulated text string has zero length or the graphics context is null.

Specified by:
originalPaint in interface Paintable
Specified by:
originalPaint in class AbstractPaintable
Parameters:
g - the graphics context on which to paint

getActualBounds2D

public XRect getActualBounds2D()

Returns the actual bounds of the original paintable or null if the paintable is effectively empty.

Specified by:
getActualBounds2D in interface Paintable
Specified by:
getActualBounds2D in class AbstractPaintable

getOriginalCenter

public XPoint2D getOriginalCenter()

Returns a copy of the center of the paint region affected by the originalPaint method.

If the user has set a default original position then that is returned. Otherwise, we define the original center to be the anchor position. This will usually not be the geometric center.

Specified by:
getOriginalCenter in interface Paintable
Overrides:
getOriginalCenter in class AbstractPaintable
Returns:
a copy of the center of the original paint region

originalContains

public boolean originalContains(double x,
                                double y)

Tests if a point specified by coordinates is inside the original paintable without mutation.

Specified by:
originalContains in interface Paintable
Specified by:
originalContains in class AbstractPaintable
Parameters:
x - the x-coordinate of the point
y - the y-coordinate of the point
Returns:
whether or not a specified point is inside the original paintable

getTextLayout

public TextLayout getTextLayout()

Returns the internal TextLayout that encapsulates the text string and the font.

If the encapsulated text string has zero length, then returns null.

Returns:
the internal TextLayout object

getStringBounds

public XRect getStringBounds()

Returns a copy of the 2-dimensional bounds of the original paint region as computed using the getStringBounds method of the Font class together with the anchor locator.

In the vertical direction, these bounds extend from the ascent line to the leading line. Thus, the height of these bounds do not depend on the particular string being rendered.

In the horizontal direction, these bounds extend from the left edge of string being painted and will include allowances for both leading and trailing white space. Unfortunately, however, if the string has no leading and trailing whitespace, it is possible for pixels to be painted outside of these bounds due to serifs or to the slant of an italic font.

If the encapsulated text string has zero length, then this method returns a rectangle at the anchor position of zero width and height.

Returns:
a copy of the 2-dimensional bounds of the paint region

getTightBounds

public XRect getTightBounds()

Returns a copy of the 2-dimensional bounds of the original paint region as computed using the getBounds method of the TextLayout class together with the anchor locator.

These bounds return a tight rectangle that includes all pixel positions that may be modified when the string is painted. The only exception to this rule is that anti-aliasing may cause some pixels adjacent to this rectangle to be rendered also. There is no Java code that is capable of testing for this effect.

The height of these bounds will vary from string to string depending on the height of the ascenders and descenders of the particular characters in the particular string.

These bounds do not include leading and trailing whitespace.

Be aware that if you have set the logical left edge of the paint area for a string to some value x then it is still possible for pixels to the left of x to be modified during rendering of the string due to the presence of serifs. The bounds returned by this method will include adjustments for such effects and will be as accurate as possible.

If the encapsulated text string has zero length, then this method returns a rectangle at the anchor position of zero width and height.

Returns:
a copy of the tight bounds of the paint region

getLooseBounds

public XRect getLooseBounds()

Returns the smallest rectangle that contains the pair of rectangles getStringBounds() and getTightBounds().

These bounds return a loose rectangle that includes all pixel positions that may be modified when the string is painted plus allowances for additional horizontal and vertical white space.

If the encapsulated text string has zero length, then this method returns a rectangle at the anchor position of zero width and height.

Returns:
a copy of the tight bounds of the paint region

getOutline

public Shape getOutline()

Returns the Shape that represents the outline of the rendered text string in its font at its location.

Experimental tests show that the Shape returned by this method is not 100% accurate. This is due to problems in the getOutline method of the Java class TextLayout.

If the encapsulated text string has zero length, then returns an empty Shape.

Returns:
the Shape object

setString

public void setString(String string)

Sets the string for this TextPaintable.

If the given string is null, it is set to the zero length string.

Does nothing if the string is equal to the current string.

Fires property change: SET_STRING.

Parameters:
string - the string to display

getString

public String getString()
Returns the string for this TextPaintable.

Returns:
the string to display

setFont

public void setFont(Font font)

Sets the font for this TextPaintable.

If the given font is null then it is set to getDefaultFont().

Does nothing if the font is equal to the current font.

Fires property change: SET_FONT.

Parameters:
font - the font to use to display the string

getFont

public Font getFont()
Returns the font for this TextPaintable.

Returns:
the font to use to display the string

setFillPaint

public void setFillPaint(Paint fillpaint)

Sets the fill paint for this TextPaintable.

If the given paint is null, it is set to Color.black.

Fires property change: SET_FILL_PAINT.

Parameters:
fillpaint - the paint to use to fill the string

getFillPaint

public Paint getFillPaint()
Returns the fill paint for this TextPaintable.

Returns:
the paint to use to fill the string

setBoundsStrategy

public void setBoundsStrategy(TextBounds.Strategy strategy)

Sets the bounds strategy for this TextPaintable.

If the given strategy is null, it is set to TextBounds.LOOSE.

Fires property change: SET_BOUNDS_STRATEGY.

Parameters:
strategy - the strategy to use to compute the paintable bounds

getBoundsStrategy

public TextBounds.Strategy getBoundsStrategy()
Returns the bounds strategy for this TextPaintable.

Returns:
the strategy to use to compute the paintable bounds

setAnchorLocator

public void setAnchorLocator(TextAnchor.Locator locator)

Sets the TextAnchor.Locator for this TextPaintable.

The following constants are provided in the class TextAnchor as possible options for the TextAnchor.Locator parameter:

If the given locator is null, it is set to TextAnchor.LEFT_ASCENTLINE.

Fires property change: SET_ANCHOR_LOCATOR.

Parameters:
locator - the locator for the anchor position

getAnchorLocator

public TextAnchor.Locator getAnchorLocator()

Returns the TextAnchor.Locator for this TextPaintable.

Returns:
the locator for the anchor position

setAnchorPosition

public void setAnchorPosition(float anchorX,
                              float anchorY)

Sets the anchor position for this TextPaintable.

Fires property change: SET_ANCHOR_POSITION.

Parameters:
anchorX - the anchor x-coordinate
anchorY - the anchor y-coordinate

setAnchorPosition

public void setAnchorPosition(float[] position)

Sets the anchor position for this TextPaintable using an array float[2].

A null parameter is ignored.

Fires property change: SET_ANCHOR_POSITION.

Parameters:
position - the anchor position

shiftAnchorPosition

public void shiftAnchorPosition(float dx,
                                float dy)

Shift the anchor position by the given dx and dy.

Fires property change: SET_ANCHOR_POSITION.

Parameters:
dx - the shift in the anchor x position
dy - the shift in the anchor y position

getAnchorPosition

public float[] getAnchorPosition()
Returns a copy of the anchor position for this TextPaintable as an array float[2].

Returns:
the anchor position

getLeftX

public float getLeftX()

Returns the left x-coordinate of this TextPaintable.

This method uses the anchor locator.

Returns:
the left x-coordinate of this text paintable

getRightX

public float getRightX()

Returns the right x-coordinate of this TextPaintable.

This method uses the anchor locator.

Returns:
the right x-coordinate of this text paintable

getCenterX

public float getCenterX()

Returns the center x-coordinate of this TextPaintable.

This method uses the anchor locator.

Returns:
the center x-coordinate of this text paintable

getBaseLineY

public float getBaseLineY()

Returns the base line y-coordinate of this TextPaintable.

This method uses the anchor locator.

Returns:
the base line y-coordinate of this text paintable

getAscentLineY

public float getAscentLineY()

Returns the ascent line y-coordinate of this TextPaintable.

This method uses the anchor locator.

Returns:
the ascent line y-coordinate of this text paintable

getDescentLineY

public float getDescentLineY()

Returns the descent line y-coordinate of this TextPaintable.

This method uses the anchor locator.

Returns:
the descent line y-coordinate of this text paintable

getLeadingLineY

public float getLeadingLineY()

Returns the leading line y-coordinate of this TextPaintable.

This methods uses the anchor locator.

Returns:
the leading line y-coordinate of this text paintable

getWidth

public float getWidth()

Returns the width of the area that will be occupied by this TextPaintable.

This method uses the method getBounds2D.

Returns:
the width of this text paintable

getHeight

public float getHeight()

Returns the height of the area that will be occupied by this TextPaintable.

This method uses the method getBounds2D.

Returns:
the height of this text paintable

getDefaultFont

public static Font getDefaultFont()

Returns the default font for a JLabel in the current UI settings. This font is used in constructing a TextPaintable if the user does not specify a font.

Returns:
the current JLabel default font

resetTextLayout

private void resetTextLayout()
Resets the text layout on string or font change.