|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfr.lri.swingstates.canvas.CShape
fr.lri.swingstates.canvas.CText
public class CText
A text shape for use with an Canvas.
The text is drawn according to the fill paint and the text font.
If the shape is outlined, the bounding box of the text is drawn according to the outline paint and stroke.
| Field Summary | |
|---|---|
static java.awt.font.FontRenderContext |
FRC
The FontRenderContext used to render this text. |
| Constructor Summary | |
|---|---|
CText(java.awt.geom.Point2D loc,
java.lang.String txt,
java.awt.Font f)
Builds a SMtext. |
|
| Method Summary | |
|---|---|
CShape |
copyTo(CShape sms)
Copies this shape into a destination shape. |
CShape |
duplicate()
Creates a new copy of this shape and returns it. |
CEllipse |
getAbsoluteEllipse(double w,
double h)
Returns a CEllipse that surrounds this text. |
CRectangle |
getAbsoluteRectangle(double w,
double h)
Returns a CRectangle that surrounds this text. |
char |
getChar(double x,
double y)
Returns the nearest char from the location (x, y). |
char |
getChar(java.awt.geom.Point2D p)
Returns the nearest char from the point p. |
java.awt.Font |
getFont()
Returns the text font. |
CEllipse |
getRelativeEllipse(double ratioX,
double ratioY)
Returns a CEllipse that surrounds this text. |
CRectangle |
getRelativeRectangle(double ratioX,
double ratioY)
Returns a CRectangle that surrounds this text. |
java.lang.String |
getText()
Returns the text. |
void |
paint(java.awt.Graphics g)
Paints the shape. |
CElement |
setAntialiased(boolean a)
Specifies whether this shape is antialiased. |
CText |
setFont(java.awt.Font f)
Sets the text font. |
CText |
setReferencePointToBaseline()
Sets the reference point of this CText
to its baseline. |
CText |
setText(java.lang.String text)
Sets the text to be displayed. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static java.awt.font.FontRenderContext FRC
| Constructor Detail |
|---|
public CText(java.awt.geom.Point2D loc,
java.lang.String txt,
java.awt.Font f)
loc - The lower left point of this CText.txt - The text of this CText.f - The font of this CText.| Method Detail |
|---|
public void paint(java.awt.Graphics g)
paint in class CShapeg - The graphics with which the shape must be painted.
public char getChar(double x,
double y)
(x, y).
x - The x-coordinate (in the canvas coordinate system)y - The y-coordinate (in the canvas coordinate system)
public char getChar(java.awt.geom.Point2D p)
p.
p - The pont (in the canvas coordinate system)
public CRectangle getRelativeRectangle(double ratioX,
double ratioY)
CRectangle that surrounds this text.
If the bounding box of the text is a box whose width and height are respectively w and h,
the result rectangle is centered at the center of the text and has a width ratioX*w and a height ratioY*h.
This method does NOT add the built CRectangle to the canvas.
ratioX - The width ratio.ratioY - The height ratio.
public CEllipse getRelativeEllipse(double ratioX,
double ratioY)
CEllipse that surrounds this text.
If the bounding box of the text is a box whose width and height are respectively w and h,
the result ellipse is centered at the center of the text and has a width ratioX*w and a height ratioY*h.
This method does NOT add the built CRectangle to the canvas.
ratioX - The width ratio.ratioY - The height ratio.
public CRectangle getAbsoluteRectangle(double w,
double h)
CRectangle that surrounds this text.
The result rectangle is centered at the center of the text and has a width w and a height h.
This method does NOT add the built CRectangle to the canvas.
w - The width ratio.h - The height ratio.
public CEllipse getAbsoluteEllipse(double w,
double h)
CEllipse that surrounds this text.
The result ellipse is centered at the center of the text and has a width w and a height h.
This method does NOT add the built CRectangle to the canvas.
w - The width ratio.h - The height ratio.
public java.lang.String getText()
public CText setReferencePointToBaseline()
CText
to its baseline.
By default, the position of a CText specifies
the upper left corner of its bounding box. For example, the
following lines makes the two CText be displayed
below the segment [(10, 20), (50, 20)]:
CText text1 = canvas.newText(10, 20, "ab"); CText text2 = canvas.newText(30, 20, "pc"); canvas.newSegment(10, 20, 50, 20);This can be an issue for setting the position of a
CText
according to its baseline.
Setting the reference point of a CText to its
baseline allows to overcome this problem:
text1.setReferencePointToBaseline().translateTo(10, 20); text2.setReferencePointToBaseline().translateTo(30, 20);text1 and text2 appear as if they were written on the same virtual line positioned at y=20.
CText.public CText setText(java.lang.String text)
text - The text to set.
public java.awt.Font getFont()
public CText setFont(java.awt.Font f)
f - The font.
public CShape copyTo(CShape sms)
copyTo in class CShapesms - The destination shape
CShape.copyTo(fr.lri.swingstates.canvas.CShape)public CShape duplicate()
duplicate in class CShapeCShape.duplicateWithTags()public CElement setAntialiased(boolean a)
setAntialiased in interface CElementsetAntialiased in class CShapea - True if this shape is to be antialiased.
CShape.setAntialiased(boolean)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||