|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opensourcephysics.display.TextLine
public class TextLine
TextLine is designed to bundle together all the information required to draw short Strings with subscripts and superscripts. TextLine was modified by W. Christian to add Greek characters using TeX notation.
Field Summary | |
---|---|
static int |
ALGEBRAIC
Format to use when parsing a double |
protected int |
ascent
The ascent using the current font |
protected java.awt.Color |
background
Background Color |
static int |
CENTER
Center the Text over the point |
protected java.awt.Color |
color
Text color |
protected int |
descent
The descent using the current font |
protected java.awt.Font |
font
Font to use for text |
protected java.lang.String |
fontname
The logical name of the font to use |
protected int |
fontsize
The font size |
protected int |
fontstyle
The font style |
protected int |
height
The height using the current font ie ascent+descent+leading |
protected int |
justification
Text justification. |
protected int |
leading
The leading using the current font |
static int |
LEFT
Position the Text to the Left of the point |
protected java.awt.Graphics |
lg
Local graphics context. |
protected java.util.Vector<org.opensourcephysics.display.TextState> |
list
The parsed string. |
protected int |
maxAscent
The maximum ascent using the current font |
protected int |
maxDescent
The maximum descent using the current font |
protected boolean |
parse
Has the string been parsed! This only needs to be done once unless the font is altered. |
static int |
RIGHT
Position the Text to the Right of the point |
static int |
SCIENTIFIC
Format to use when parsing a double |
protected double |
script_fraction
Decrease in size of successive script levels |
protected double |
sub_offset
Subscript offset |
protected double |
sup_offset
Superscript offset |
protected java.lang.String |
text
The text to display |
protected int |
width
The width of the text using the current Font |
Constructor Summary | |
---|---|
TextLine()
Instantiate the class |
|
TextLine(java.awt.Font f,
java.awt.Color c,
int j)
Instantiate the class |
|
TextLine(java.lang.String s)
Instantiate the class. |
|
TextLine(java.lang.String s,
java.awt.Color c)
Instantiate the class |
|
TextLine(java.lang.String s,
java.awt.Font f)
Instantiate the class |
|
TextLine(java.lang.String s,
java.awt.Font f,
java.awt.Color c,
int j)
Instantiate the class |
Method Summary | |
---|---|
int |
charWidth(java.awt.Graphics g,
char ch)
|
TextLine |
copyState()
Create a New Textline object copying the state of the existing object into the new one. |
void |
copyState(TextLine t)
Copy the state of the parsed Textline into the existing object. |
void |
drawText(java.awt.Graphics g,
int x,
int y)
Parse the text then draw it without any rotation. |
void |
drawText(java.awt.Graphics g,
int x,
int y,
int j)
Parse the text then draw it. |
int |
getAscent(java.awt.Graphics g)
|
java.awt.Color |
getBackground()
|
java.awt.Color |
getColor()
|
int |
getDescent(java.awt.Graphics g)
|
java.awt.FontMetrics |
getFM(java.awt.Graphics g)
|
java.awt.Font |
getFont()
|
java.lang.String |
getFontName()
|
int |
getFontSize()
|
int |
getFontStyle()
|
int |
getHeight(java.awt.Graphics g)
|
int |
getJustification()
|
int |
getLeading(java.awt.Graphics g)
|
int |
getMaxAscent(java.awt.Graphics g)
|
int |
getMaxDescent(java.awt.Graphics g)
|
java.awt.Font |
getScriptFont(java.awt.Font f)
|
java.awt.geom.Rectangle2D |
getStringBounds(java.awt.Graphics g)
Returns the bounding box for this string. |
java.lang.String |
getText()
|
int |
getWidth(java.awt.Graphics g)
|
boolean |
isNull()
|
static double |
log10(double x)
|
boolean |
parseDouble(double d)
Parse a double value. |
boolean |
parseDouble(double d,
int p)
Parse a double value. |
boolean |
parseDouble(double d,
int n,
int p,
int f)
Parse a double value |
void |
parseText(java.awt.Graphics g)
parse the text. |
void |
setBackground(java.awt.Color c)
Set the Background Color to use with the class |
void |
setColor(java.awt.Color c)
Set the Color to use with the class |
void |
setFont(java.awt.Font f)
Set the Font to use with the class |
void |
setFontName(java.lang.String s)
Set the Logical font name of the current font |
void |
setFontSize(int i)
Set the Font size of the current font |
void |
setFontStyle(int i)
Set the Font style of the current font |
void |
setJustification(int i)
Set the Justification to use with the class |
void |
setText(java.lang.String s)
Set the String to use with the class |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CENTER
public static final int LEFT
public static final int RIGHT
public static final int SCIENTIFIC
public static final int ALGEBRAIC
protected double script_fraction
protected double sup_offset
protected double sub_offset
protected java.awt.Font font
protected java.awt.Color color
protected java.awt.Color background
protected java.lang.String text
protected java.lang.String fontname
protected int fontsize
protected int fontstyle
protected int justification
protected int width
protected int ascent
protected int maxAscent
protected int descent
protected int maxDescent
protected int height
protected int leading
protected boolean parse
protected java.awt.Graphics lg
protected java.util.Vector<org.opensourcephysics.display.TextState> list
Constructor Detail |
---|
public TextLine()
public TextLine(java.lang.String s)
s
- String to parse.public TextLine(java.lang.String s, java.awt.Font f)
s
- String to parse.f
- Font to use.public TextLine(java.lang.String s, java.awt.Font f, java.awt.Color c, int j)
s
- String to parse.f
- Font to use.c
- Color to usej
- Justificationpublic TextLine(java.lang.String s, java.awt.Color c)
s
- String to parse.c
- Color to usepublic TextLine(java.awt.Font f, java.awt.Color c, int j)
f
- Font to use.c
- Color to usej
- JustificationMethod Detail |
---|
public TextLine copyState()
public void copyState(TextLine t)
t
- The TextLine to get the state information from.public void setFont(java.awt.Font f)
f
- Fontpublic void setText(java.lang.String s)
s
- Stringpublic void setColor(java.awt.Color c)
c
- Colorpublic void setBackground(java.awt.Color c)
c
- Colorpublic void setJustification(int i)
i
- Justificationpublic java.awt.Font getFont()
public java.lang.String getText()
public java.awt.Color getColor()
public java.awt.Color getBackground()
public int getJustification()
public java.awt.FontMetrics getFM(java.awt.Graphics g)
g
- Graphics context.
public int charWidth(java.awt.Graphics g, char ch)
g
- Graphics context.ch
- The character.
public java.awt.geom.Rectangle2D getStringBounds(java.awt.Graphics g)
g
- Graphics
public int getWidth(java.awt.Graphics g)
g
- Graphics context.
public int getHeight(java.awt.Graphics g)
g
- Graphics context.
public int getAscent(java.awt.Graphics g)
g
- Graphics context.
public int getMaxAscent(java.awt.Graphics g)
g
- Graphics context.
public int getDescent(java.awt.Graphics g)
g
- Graphics context.
public int getMaxDescent(java.awt.Graphics g)
g
- Graphics context.
public int getLeading(java.awt.Graphics g)
g
- Graphics context.
public void parseText(java.awt.Graphics g)
g
- Graphics context.public boolean isNull()
public void drawText(java.awt.Graphics g, int x, int y, int j)
g
- Graphics contextx
- pixel position of the texty
- pixel position of the textj
- justification of the textpublic void drawText(java.awt.Graphics g, int x, int y)
g
- Graphics contextx
- pixel position of the texty
- pixel position of the textpublic java.lang.String getFontName()
public int getFontStyle()
public int getFontSize()
public void setFontName(java.lang.String s)
s
- Logical font name.public void setFontStyle(int i)
i
- Font style.public void setFontSize(int i)
i
- Font size.public java.awt.Font getScriptFont(java.awt.Font f)
f
- Font
public boolean parseDouble(double d)
d
- double to parse
return true if the parse was successfulpublic boolean parseDouble(double d, int p)
d
- double to parsep
- precision of the number
return true if the parse was successfulpublic boolean parseDouble(double d, int n, int p, int f)
d
- double to parsen
- number of significant figuresp
- precision of the numberf
- format of the number scientific, algebraic etc.
return true if the parse was successfulpublic static double log10(double x) throws java.lang.ArithmeticException
x
- a double value
java.lang.ArithmeticException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |