|
UIX 2.2.16 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--oracle.cabo.image.painter.AbstractPainter | +--oracle.cabo.image.painter.TextPainter
A painter capable of painting a string using the alignment of its PaintContext. If the string contains newlines, multiple lines of text will be painted.
This class uses new APIs in Java2 and propertly works with BufferedImages.
This TextPainter should be used for all String objects used in the ImageGenerator.
Constructor Summary | |
TextPainter()
Creates a TextPainter object, using the default label data key. |
|
TextPainter(java.lang.Object dataKey)
Creates a TextPainter object using the dataKey to get its
data and supporting mnemonics. |
|
TextPainter(java.lang.Object dataKey,
boolean supportMnemonics)
Creates a TextPainter object. |
Method Summary | |
protected java.lang.Object |
getData(PaintContext context)
|
protected java.lang.Object |
getDataKey()
|
java.awt.Dimension |
getMinimumSize(PaintContext context)
Returns the minimum size of the painter. |
protected java.lang.String |
getMinimumStringData(PaintContext context)
Returns the String to use for the minimum size calculation. |
protected java.lang.String |
getPaintText(PaintContext context,
java.lang.String text,
java.awt.FontMetrics metrics,
int availableWidth)
This method is called for each line of text painted. |
java.awt.Dimension |
getPreferredSize(PaintContext context)
Returns the preferred size of the painter. |
protected java.lang.String |
getStringData(PaintContext context)
Typesafe method to return the String to Paint. |
void |
paint(PaintContext context,
java.awt.Graphics g,
int x,
int y,
int width,
int height)
Paints the TextPainter at the given location. |
protected int |
paintText(PaintContext context,
java.awt.Graphics g,
java.awt.FontMetrics metrics,
java.lang.String text,
int x,
int y,
int availableWidth,
float alignmentX,
int mnemonicIndex)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TextPainter()
public TextPainter(java.lang.Object dataKey)
dataKey
to get its
data and supporting mnemonics.
dataKey
- Key used by this TextPainter to retrieve the String
this TextPainter paints.
PaintContext.getPaintData(java.lang.Object)
public TextPainter(java.lang.Object dataKey, boolean supportMnemonics)
dataKey
- Key used by this TextPainter to retrieve the
String this TextPainter paints.supportMnemonics
- True if this TextPainter should ask its
Paint context for a mnemonic to paint.
PaintContext.getPaintData(java.lang.Object)
Method Detail |
public java.awt.Dimension getPreferredSize(PaintContext context)
getPreferredSize
in class AbstractPainter
context
- Context for determining the preferred size.public java.awt.Dimension getMinimumSize(PaintContext context)
context
- Context for determining the minimum size.public void paint(PaintContext context, java.awt.Graphics g, int x, int y, int width, int height)
context
- Context for painting.g
- Graphics object to draw into.x
- X position to draw at.y
- Y position to draw at.width
- Width to draw into.height
- Height to draw into.protected java.lang.String getPaintText(PaintContext context, java.lang.String text, java.awt.FontMetrics metrics, int availableWidth)
context
- Context for determining the text to paint.text
- Text data for this line.metrics
- FontMetrics to use to paint the text.availableWidth
- Number of pixels available to paint the text.
protected java.lang.String getStringData(PaintContext context)
getData()
, as overriding getStringData()
directly is more efficient.
context
- PaintContext to use to retrieve the TextPainter's
String data.
getData(oracle.cabo.image.painter.PaintContext)
protected java.lang.String getMinimumStringData(PaintContext context)
protected java.lang.Object getData(PaintContext context)
getData
in class AbstractPainter
protected java.lang.Object getDataKey()
getDataKey
in class AbstractPainter
protected int paintText(PaintContext context, java.awt.Graphics g, java.awt.FontMetrics metrics, java.lang.String text, int x, int y, int availableWidth, float alignmentX, int mnemonicIndex)
|
UIX 2.2.16 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |