public class Text extends PlottableObject
Modifier and Type | Field and Description |
---|---|
protected java.text.AttributedString |
attStr |
protected double[] |
extent |
protected java.lang.String |
fontName |
protected float |
fontSize |
protected float |
fontStyle |
protected java.lang.String |
horizontalAlignment |
protected int |
isLabel |
protected boolean |
isNormalized |
protected double |
margin |
protected double[] |
position |
protected double |
rotation |
protected java.lang.String |
string |
protected java.lang.String |
verticalAlignment |
ax, color, defaultColor, defaultLineStyle, defaultLineWidth, edgeColor, faceColor, lineStyle, lineWidth
Constructor and Description |
---|
Text(double x,
double y,
java.lang.String string)
Creates a Text object containing the specified string at the user
coordinates x, y into the current Axes of the current Figure.
|
Text(double x,
double y,
java.lang.String string,
Axes ax)
Creates a Text object containing the specified string at the user
coordinates x, y into the specified Axes object.
|
Text(double x,
double y,
java.lang.String string,
Axes ax,
int isLabel)
Creates a Text object containing the specified string at the user
coordinates x, y into the specified Axes object.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
cutOut(java.lang.String str,
int index)
General purpose routine: Returns a string with one element (at position
index ) cut out. |
double[] |
getExtent() |
java.lang.String |
getFontName()
Returns the name of the font.
|
float |
getFontSize()
Returns the font size (float).
|
float |
getFontStyle() |
java.lang.String |
getHorizontalAlignment()
Gets the horizontalAlignment of the text object as String:
left (default) - center - right . |
protected int |
getIsLabel() |
double |
getMargin() |
double[] |
getPosition() |
double |
getRotation() |
java.lang.String |
getString()
Returns string of text object.
|
java.lang.String |
getVerticalAlignment()
Gets the horizontalAlignment of the text object as String:
bottom -
baseline (default) -
middle -
top . |
boolean |
isNormalized() |
protected boolean |
isXLg() |
protected boolean |
isYLg() |
protected static void |
out(java.lang.String str) |
protected static void |
outn(java.lang.String str) |
void |
paint(java.awt.Graphics2D g)
The paint method of Text object.
|
void |
setExtent(double[] extent) |
void |
setFontName(java.lang.String fontName)
Sets the name of the font (e.g., "Helvethica").
|
void |
setFontSize(float fontSize)
Sets the font size (default = 12f).
|
void |
setFontStyle(float fontStyle)
Sets the fontStyle of the text (
TextAttribute ). |
void |
setHorizontalAlignment(java.lang.String horizontalAlignment)
Sets the horizontalAlignment of the text object as String:
left (default) - center - right . |
protected void |
setIsLabel(int isLabel)
isLabel specifies what type of label the text object is:
|
void |
setMargin(double margin) |
void |
setNormalized(boolean isNormalized)
Sets the x, y coordinates relative to axes.
|
void |
setPosition(double[] pos)
Sets the position (double[2] x y) of the text.
|
void |
setRotation(double rotation)
Sets the text object's rotation in degrees (0--360) counterclockwise.
|
void |
setString(java.lang.String str)
Sets the string of the Text object.
|
void |
setVerticalAlignment(java.lang.String verticalAlignment)
Sets the horizontalAlignment of the text object as String:
bottom -
baseline (default) -
middle -
top . |
static java.text.AttributedString |
stringToAttString(java.lang.String str)
Converts a String to an AttributedString by superscripting
all characters following a "^" and subscripting all after a "_",
very much like in LaTeX.
|
dashdotted, dashed, dotted, getAxes, getColor, getEdgeColor, getFaceColor, getLineStyle, getLineWidth, setColor, setEdgeColor, setFaceColor, setLineStyle, setLineWidth, solid
protected double[] position
protected java.lang.String string
protected java.text.AttributedString attStr
protected java.lang.String fontName
protected float fontStyle
protected float fontSize
protected java.lang.String horizontalAlignment
protected java.lang.String verticalAlignment
protected double margin
protected double[] extent
protected double rotation
protected int isLabel
protected boolean isNormalized
public Text(double x, double y, java.lang.String string)
x
- y
- string
- public Text(double x, double y, java.lang.String string, Axes ax)
x
- y
- string
- ax
- public Text(double x, double y, java.lang.String string, Axes ax, int isLabel)
x
- y
- string
- ax
- isLabel
- indicates whether the Text object is treated as a
Label (Label.IS_XLABEL
, Label.IS_YLABEL
) or as a
Title (Title.IS_TITLE
) (used to create labels and title).public void paint(java.awt.Graphics2D g)
paint
in class PlottableObject
public static java.text.AttributedString stringToAttString(java.lang.String str)
E.g.: "10^3"
or to superscript multiple characters:
"10^{100}", "X_{12}"
str
- input string.public static java.lang.String cutOut(java.lang.String str, int index)
index
) cut out.str
- input string.index
- index of element to be removed.public void setString(java.lang.String str)
str
- public java.lang.String getString()
setString(String)
public void setPosition(double[] pos)
pos
- getHorizontalAlignment()
,
setHorizontalAlignment(String)
,
getVerticalAlignment()
,
setVerticalAlignment(String)
public double[] getPosition()
setPosition(double[])
public void setFontName(java.lang.String fontName)
fontName
- public java.lang.String getFontName()
public void setFontStyle(float fontStyle)
TextAttribute
).fontStyle
- The fontStyle to set.getFontStyle()
public float getFontStyle()
TextAttribute
).public void setFontSize(float fontSize)
fontSize
- public float getFontSize()
public void setHorizontalAlignment(java.lang.String horizontalAlignment)
left
(default) - center
- right
.horizontalAlignment
- String specifying the horizontal alignment
of text object.public java.lang.String getHorizontalAlignment()
left
(default) - center
- right
.public void setVerticalAlignment(java.lang.String verticalAlignment)
bottom
-
baseline
(default) -
middle
-
top
.verticalAlignment
- String specifying the vertical alignment
of text object.public java.lang.String getVerticalAlignment()
bottom
-
baseline
(default) -
middle
-
top
.public void setRotation(double rotation)
rotation
- The rotation to set.getRotation()
public double getRotation()
setRotation(double)
protected boolean isXLg()
protected boolean isYLg()
protected static void out(java.lang.String str)
protected static void outn(java.lang.String str)
protected int getIsLabel()
protected void setIsLabel(int isLabel)
isLabel
- The isLabel to set.public boolean isNormalized()
setNormalized(boolean)
public void setNormalized(boolean isNormalized)
ax.text(.1, .3, "qwer", ax);
creates the text at
10% left on the x axis and 30% from the bottom of the y axis
irrespective of axis orientation
(Axes.setXDir(String)
, Axes.setYDir(String)
)
or location
Axes.setXAxisLocation(String)
,
Axes.setXAxisLocation(String)
).isNormalized
- The isNormalized to set.public double[] getExtent()
public void setExtent(double[] extent)
extent
- The extent to set.public double getMargin()
public void setMargin(double margin)
margin
- The margin to set.