lt.monarch.chart.text
Class LabelTextPainter

java.lang.Object
  extended by lt.monarch.chart.text.TextPainter
      extended by lt.monarch.chart.text.RotatedLabelPainter
          extended by lt.monarch.chart.text.LabelTextPainter
All Implemented Interfaces:
java.io.Serializable, AbstractTextPainter
Direct Known Subclasses:
PieSliceLabelEntry

public class LabelTextPainter
extends RotatedLabelPainter

See Also:
Serialized Form

Field Summary
Modifier and Type Field and Description
 
Fields inherited from class lt.monarch.chart.text.TextPainter
boundingBox, hAlignment, text, vAlignment, xMargin, yMargin
 
Constructor Summary
Constructor and Description
LabelTextPainter()
          Creates default label text painter for specified text string.
LabelTextPainter(java.lang.String s)
          Creates default label text painter for specified text string.
 
Method Summary
Modifier and Type Method and Description
 Rectangle2D findBounds(AbstractGraphics g, Rectangle2D r)
          This method finds bounds for the label.
 Area getFullArea(java.awt.FontMetrics fm)
          Returns the area where is label.
protected  java.awt.Dimension getFullSize(java.awt.FontMetrics fm)
          Returns full not rotated text size.
 Rectangle2D getPreferredBounds(java.awt.FontMetrics fm)
          Preferred bounds are enough to paint full label.
 float getRelativePosition()
          Returns relative position for the label
 double getRotationAngle()
          Returns rotation angle in radians for text.
 Point2D getRotationPoint()
          Returns rotation point.
 void paint(AbstractGraphics g, Rectangle2D r)
          Paints text (possibly rotated) into specified rectangle using provided graphics context.
 void setRelativePosition(float pos)
          Sets relative (to rotation point) position for not rotated labels.
 void setRotationAngle(double angle)
          Sets rotation angle in radians for text.
 void setRotationPoint(Point2D rotPoint)
          Sets rotation point.
 void setText(java.lang.String s)
          Sets text for text painter.
 
Methods inherited from class lt.monarch.chart.text.TextPainter
dispose, getBounds, getHorizontalAlignment, getHorizontalMargin, getMarginInPixels, getMinimumHeight, getMinimumSize, getMinimumSize, getText, getVerticalAlignment, getVerticalMargin, getWrappingEnabled, setHorizontalAlignment, setHorizontalMargin, setMargin, setText, setVerticalAlignment, setVerticalMargin, setWrappingEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelTextPainter

public LabelTextPainter(java.lang.String s)
Creates default label text painter for specified text string.

Parameters:
s - text string.

LabelTextPainter

public LabelTextPainter()
Creates default label text painter for specified text string.

Method Detail

setText

public void setText(java.lang.String s)
Sets text for text painter.

Specified by:
setText in interface AbstractTextPainter
Overrides:
setText in class TextPainter
Parameters:
s - text string.

setRotationAngle

public void setRotationAngle(double angle)
Sets rotation angle in radians for text.

Specified by:
setRotationAngle in class RotatedLabelPainter
Parameters:
angle - rotation angle

setRotationPoint

public void setRotationPoint(Point2D rotPoint)
Sets rotation point.

Specified by:
setRotationPoint in class RotatedLabelPainter
Parameters:
rotPoint - rotation point

setRelativePosition

public void setRelativePosition(float pos)
Sets relative (to rotation point) position for not rotated labels. Should be in range [-1;1].

Specified by:
setRelativePosition in class RotatedLabelPainter
Parameters:
pos - relative position

getRelativePosition

public float getRelativePosition()
Description copied from class: RotatedLabelPainter
Returns relative position for the label

Specified by:
getRelativePosition in class RotatedLabelPainter
Returns:
relative position for the label

getRotationPoint

public Point2D getRotationPoint()
Returns rotation point.

Specified by:
getRotationPoint in class RotatedLabelPainter
Returns:
rotPoint rotation point

getRotationAngle

public double getRotationAngle()
Returns rotation angle in radians for text.

Specified by:
getRotationAngle in class RotatedLabelPainter
Returns:
angle rotation angle

getFullSize

protected java.awt.Dimension getFullSize(java.awt.FontMetrics fm)
Returns full not rotated text size.

Specified by:
getFullSize in class RotatedLabelPainter
Parameters:
fm - text font metrics.
Returns:
fullSize text full size.

findBounds

public Rectangle2D findBounds(AbstractGraphics g,
                              Rectangle2D r)
This method finds bounds for the label. Used for title painting boundary determination and centering.

Specified by:
findBounds in interface AbstractTextPainter
Overrides:
findBounds in class TextPainter
Parameters:
g - abstract graphics
r - rectangle boundaries
Returns:
bounding box

getPreferredBounds

public Rectangle2D getPreferredBounds(java.awt.FontMetrics fm)
Preferred bounds are enough to paint full label. Matters only if rotation point is set. Otherwise use the getFullSize method to get size of label.

Specified by:
getPreferredBounds in class RotatedLabelPainter
Parameters:
fm - FontMetrics
font - font of label
Returns:
preferred bounds or null if rotation point is not set

getFullArea

public Area getFullArea(java.awt.FontMetrics fm)
Description copied from class: RotatedLabelPainter
Returns the area where is label.

Specified by:
getFullArea in class RotatedLabelPainter
Parameters:
fm - font metrics
Returns:
the bounding area of label

paint

public void paint(AbstractGraphics g,
                  Rectangle2D r)
Paints text (possibly rotated) into specified rectangle using provided graphics context.

Specified by:
paint in interface AbstractTextPainter
Overrides:
paint in class TextPainter
Parameters:
g - current graphics context
r - rectangle where text is painted.