|
|||||||||
| Home >> All >> cgsuite >> [ plugin overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
cgsuite.plugin
Class StyledTextOutput

java.lang.Objectcgsuite.plugin.StyledTextOutput
- All Implemented Interfaces:
- Output
- public class StyledTextOutput
- extends java.lang.Object
- implements Output
- extends java.lang.Object
An abstract representation of styled character data. Each
StyledTextOutput contains a body of text marked up with
abstract attributes. It can be converted
to plain text, LaTeX source, or a screen image, and the interpretation of
the abstract attributes varies depending on the form of output being
generated. For example, the subscript attribute is ignored when generating
plain text.
Text can be marked up with style attributes, such as location and size modifiers, as well as an attribute restricting the output modes under which that text is displayed. This makes it possible to specify alternate representations for different output modes. Consider the following example:
StyledTextOutput sto = new StyledTextOutput();
sto.appendText("+", StyledTextOutput.STYLE_FACE_MATH, ~StyledTextOutput.MODE_PLAIN_TEXT);
sto.appendText("Tiny(", StyledTextOutput.STYLE_FACE_MATH, StyledTextOutput.MODE_PLAIN_TEXT);
sto.appendText("2", StyledTextOutput.STYLE_FACE_MATH | StyledTextOutput.STYLE_LOCATION_SUBSCRIPT,
StyledTextOutput.MODE_ALL);
sto.appendText(")", StyledTextOutput.STYLE_FACE_MATH, StyledTextOutput.MODE_PLAIN_TEXT);
In plain-text mode, this StyledTextOutput would be rendered as
"Tiny(2)"; otherwise it would be rendered as a plus sign with subscript 2.
It is possible to embed other Output objects, including images,
tables, and existing styled text, within a StyledTextOutput.
See the append* methods for details.
- Version:
- $Revision: 1.5 $ $Date: 2003/11/26 01:39:24 $
| Nested Class Summary | |
private class |
StyledTextOutput.Block
|
private static class |
StyledTextOutput.STOCharacterIterator
|
| Field Summary | |
private boolean |
additionalLines
|
private java.util.List |
blocks
|
static int |
MODE_ALL
This text will included in all output modes. |
static int |
MODE_LATEX_SOURCE
This text will included in the output of toLatexSource 55 . |
static int |
MODE_PLAIN_TEXT
This text will included in the output of toPlainText 55 . |
static int |
MODE_SCREEN_IMAGE
This text will included in the output of toScreenImage 55 . |
private static java.awt.font.FontRenderContext |
screenFrc
|
static int |
STYLE_COLOR_BLACK
|
static int |
STYLE_COLOR_BLUE
|
static int |
STYLE_COLOR_CYAN
|
static int |
STYLE_COLOR_DARK_GRAY
|
static int |
STYLE_COLOR_GRAY
|
static int |
STYLE_COLOR_GREEN
|
static int |
STYLE_COLOR_LIGHT_GRAY
|
static int |
STYLE_COLOR_MAGENTA
|
(package private) static int |
STYLE_COLOR_MASK
|
static int |
STYLE_COLOR_ORANGE
|
static int |
STYLE_COLOR_PINK
|
static int |
STYLE_COLOR_RED
|
static int |
STYLE_COLOR_WHITE
|
static int |
STYLE_COLOR_YELLOW
|
(package private) static int |
STYLE_FACE_MASK
|
static int |
STYLE_FACE_MATH
A "math mode" font face. |
static int |
STYLE_FACE_MONOSPACED
A monospaced font face. |
static int |
STYLE_FACE_TEXT
A "plain text" font face. |
static int |
STYLE_LOCATION_DENOMINATOR
The denominator of a fraction. |
static int |
STYLE_LOCATION_LOWER_LIMIT
The lower limit of an integral symbol. |
(package private) static int |
STYLE_LOCATION_MASK
|
static int |
STYLE_LOCATION_NUMERATOR
The numerator of a fraction. |
static int |
STYLE_LOCATION_SUBSCRIPT
Standard subscript. |
static int |
STYLE_LOCATION_SUPERSCRIPT
Standard superscript. |
static int |
STYLE_LOCATION_UPPER_LIMIT
The upper limit of an integral symbol. |
static int |
STYLE_SIZE_HUGE
A huge font size. |
static int |
STYLE_SIZE_LARGE
A large font size. |
(package private) static int |
STYLE_SIZE_MASK
|
static int |
SYMBOL_DOUBLE_DOWN
A double down arrow. |
static int |
SYMBOL_DOUBLE_UP
A double up arrow. |
static int |
SYMBOL_DOWN
A single down arrow. |
static int |
SYMBOL_INTEGRAL
An integral sign. |
static int |
SYMBOL_MINY
A miny symbol. |
static int |
SYMBOL_PLUS_MINUS
A plus-or-minus sign. |
static int |
SYMBOL_QUADRUPLE_DOWN
A quadruple down arrow. |
static int |
SYMBOL_QUADRUPLE_UP
A quadruple up arrow. |
static int |
SYMBOL_RIGHT_ARROW
A right arrow. |
static int |
SYMBOL_STAR
An asterisk (suitable for nimbers.) |
static int |
SYMBOL_TINY
A tiny symbol. |
static int |
SYMBOL_TRIPLE_DOWN
A triple down arrow. |
static int |
SYMBOL_TRIPLE_UP
A triple up arrow. |
static int |
SYMBOL_UP
A single up arrow. |
| Constructor Summary | |
StyledTextOutput()
Constructs a new StyledTextOutput that is initially empty. |
|
StyledTextOutput(java.lang.String text)
Constructs a new StyledTextOutput beginning with
text. |
|
StyledTextOutput(java.lang.String text,
int style)
Constructs a new StyledTextOutput beginning with
text, formatted according to style. |
|
| Method Summary | |
void |
appendInNewLocation(Output output,
int newLocation)
Appends additional output to the end of this text, changing its location as indicated. |
void |
appendMath(java.lang.String text)
Appends text to the end of this output with the
STYLE_FACE_MATH 55 attribute. |
void |
appendOutput(Output output)
Appends additional output to the end of this text. |
void |
appendOutput(Output output,
int displayModes)
Appends additional output to the end of this text. |
void |
appendSymbol(int symbol)
Appends an abstract symbol to the end of this output. |
void |
appendSymbol(int symbol,
int style)
Appends an abstract symbol to the end of this output. |
void |
appendSymbol(int symbol,
int style,
int displayModes)
Appends an abstract symbol to the end of this output. |
void |
appendText(java.lang.String text)
Appends text to the end of this output. |
void |
appendText(java.lang.String text,
int style)
Appends text to the end of this output with the specified
style attributes. |
void |
appendText(java.lang.String text,
int style,
int displayModes)
Appends text to the end of this output with the specified
style and display mode attributes. |
private static java.awt.font.FontRenderContext |
getScreenFrc()
|
boolean |
hasAdditionalLines()
|
boolean |
hasSubOrSuperscript()
Returns true if any of the text in this output is subscript
or superscript. |
java.text.AttributedCharacterIterator |
iterator()
Gets an iterator over this text output. |
java.lang.String |
toLatexSource()
Converts this Output to a LaTeX source fragment. |
java.lang.String |
toPlainText()
Converts this Output to a String that is
readable as-is. |
java.awt.Image |
toScreenImage(int pixelWidth)
Converts this Output to an image suitable for screen
display. |
java.awt.Image |
toScreenImage(int pixelWidth,
int maxLines)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
STYLE_FACE_TEXT
public static final int STYLE_FACE_TEXT
- A "plain text" font face. Text with this attribute will be displayed
in a Sans Serif font on the screen, and as plain text in LaTeX.
- See Also:
- Constant Field Values
STYLE_FACE_MATH
public static final int STYLE_FACE_MATH
- A "math mode" font face. Text with this attribute will be displayed
in a large Sans Serif font on the screen, and in math mode in LaTeX.
- See Also:
- Constant Field Values
STYLE_FACE_MONOSPACED
public static final int STYLE_FACE_MONOSPACED
- A monospaced font face. Text with this attribute will be displayed
in a monospaced (Courier) font.
- See Also:
- Constant Field Values
STYLE_LOCATION_SUBSCRIPT
public static final int STYLE_LOCATION_SUBSCRIPT
- Standard subscript.
- See Also:
- Constant Field Values
STYLE_LOCATION_SUPERSCRIPT
public static final int STYLE_LOCATION_SUPERSCRIPT
- Standard superscript.
- See Also:
- Constant Field Values
STYLE_LOCATION_NUMERATOR
public static final int STYLE_LOCATION_NUMERATOR
- The numerator of a fraction.
- See Also:
- Constant Field Values
STYLE_LOCATION_DENOMINATOR
public static final int STYLE_LOCATION_DENOMINATOR
- The denominator of a fraction.
- See Also:
- Constant Field Values
STYLE_LOCATION_UPPER_LIMIT
public static final int STYLE_LOCATION_UPPER_LIMIT
- The upper limit of an integral symbol.
- See Also:
- Constant Field Values
STYLE_LOCATION_LOWER_LIMIT
public static final int STYLE_LOCATION_LOWER_LIMIT
- The lower limit of an integral symbol.
- See Also:
- Constant Field Values
STYLE_SIZE_LARGE
public static final int STYLE_SIZE_LARGE
- A large font size.
- See Also:
- Constant Field Values
STYLE_SIZE_HUGE
public static final int STYLE_SIZE_HUGE
- A huge font size.
- See Also:
- Constant Field Values
STYLE_COLOR_BLACK
public static final int STYLE_COLOR_BLACK
- See Also:
- Constant Field Values
STYLE_COLOR_BLUE
public static final int STYLE_COLOR_BLUE
- See Also:
- Constant Field Values
STYLE_COLOR_CYAN
public static final int STYLE_COLOR_CYAN
- See Also:
- Constant Field Values
STYLE_COLOR_DARK_GRAY
public static final int STYLE_COLOR_DARK_GRAY
- See Also:
- Constant Field Values
STYLE_COLOR_GRAY
public static final int STYLE_COLOR_GRAY
- See Also:
- Constant Field Values
STYLE_COLOR_GREEN
public static final int STYLE_COLOR_GREEN
- See Also:
- Constant Field Values
STYLE_COLOR_LIGHT_GRAY
public static final int STYLE_COLOR_LIGHT_GRAY
- See Also:
- Constant Field Values
STYLE_COLOR_MAGENTA
public static final int STYLE_COLOR_MAGENTA
- See Also:
- Constant Field Values
STYLE_COLOR_ORANGE
public static final int STYLE_COLOR_ORANGE
- See Also:
- Constant Field Values
STYLE_COLOR_PINK
public static final int STYLE_COLOR_PINK
- See Also:
- Constant Field Values
STYLE_COLOR_RED
public static final int STYLE_COLOR_RED
- See Also:
- Constant Field Values
STYLE_COLOR_WHITE
public static final int STYLE_COLOR_WHITE
- See Also:
- Constant Field Values
STYLE_COLOR_YELLOW
public static final int STYLE_COLOR_YELLOW
- See Also:
- Constant Field Values
MODE_PLAIN_TEXT
public static final int MODE_PLAIN_TEXT
- This text will included in the output of
toPlainText 55 .
- See Also:
- Constant Field Values
MODE_SCREEN_IMAGE
public static final int MODE_SCREEN_IMAGE
- This text will included in the output of
toScreenImage 55 .
- See Also:
- Constant Field Values
MODE_LATEX_SOURCE
public static final int MODE_LATEX_SOURCE
- This text will included in the output of
toLatexSource 55 .
- See Also:
- Constant Field Values
MODE_ALL
public static final int MODE_ALL
- This text will included in all output modes.
- See Also:
- Constant Field Values
SYMBOL_UP
public static final int SYMBOL_UP
- A single up arrow.
- See Also:
- Constant Field Values
SYMBOL_DOUBLE_UP
public static final int SYMBOL_DOUBLE_UP
- A double up arrow.
- See Also:
- Constant Field Values
SYMBOL_TRIPLE_UP
public static final int SYMBOL_TRIPLE_UP
- A triple up arrow.
- See Also:
- Constant Field Values
SYMBOL_QUADRUPLE_UP
public static final int SYMBOL_QUADRUPLE_UP
- A quadruple up arrow.
- See Also:
- Constant Field Values
SYMBOL_DOWN
public static final int SYMBOL_DOWN
- A single down arrow.
- See Also:
- Constant Field Values
SYMBOL_DOUBLE_DOWN
public static final int SYMBOL_DOUBLE_DOWN
- A double down arrow.
- See Also:
- Constant Field Values
SYMBOL_TRIPLE_DOWN
public static final int SYMBOL_TRIPLE_DOWN
- A triple down arrow.
- See Also:
- Constant Field Values
SYMBOL_QUADRUPLE_DOWN
public static final int SYMBOL_QUADRUPLE_DOWN
- A quadruple down arrow.
- See Also:
- Constant Field Values
SYMBOL_STAR
public static final int SYMBOL_STAR
- An asterisk (suitable for nimbers.)
- See Also:
- Constant Field Values
SYMBOL_TINY
public static final int SYMBOL_TINY
- A tiny symbol.
- See Also:
- Constant Field Values
SYMBOL_MINY
public static final int SYMBOL_MINY
- A miny symbol.
- See Also:
- Constant Field Values
SYMBOL_PLUS_MINUS
public static final int SYMBOL_PLUS_MINUS
- A plus-or-minus sign.
- See Also:
- Constant Field Values
SYMBOL_RIGHT_ARROW
public static final int SYMBOL_RIGHT_ARROW
- A right arrow.
- See Also:
- Constant Field Values
SYMBOL_INTEGRAL
public static final int SYMBOL_INTEGRAL
- An integral sign.
- See Also:
- Constant Field Values
STYLE_FACE_MASK
static final int STYLE_FACE_MASK
- See Also:
- Constant Field Values
STYLE_LOCATION_MASK
static final int STYLE_LOCATION_MASK
- See Also:
- Constant Field Values
STYLE_SIZE_MASK
static final int STYLE_SIZE_MASK
- See Also:
- Constant Field Values
STYLE_COLOR_MASK
static final int STYLE_COLOR_MASK
- See Also:
- Constant Field Values
screenFrc
private static java.awt.font.FontRenderContext screenFrc
blocks
private java.util.List blocks
additionalLines
private boolean additionalLines
| Constructor Detail |
StyledTextOutput
public StyledTextOutput()
- Constructs a new
StyledTextOutputthat is initially empty.
StyledTextOutput
public StyledTextOutput(java.lang.String text, int style)
- Constructs a new
StyledTextOutputbeginning withtext, formatted according tostyle.
StyledTextOutput
public StyledTextOutput(java.lang.String text)
- Constructs a new
StyledTextOutputbeginning withtext.
| Method Detail |
getScreenFrc
private static java.awt.font.FontRenderContext getScreenFrc()
appendText
public void appendText(java.lang.String text, int style, int displayModes)
- Appends
textto the end of this output with the specified style and display mode attributes.The text will be formatted according to
style, and it will only be displayed if the display mode matches one of the specified modes.
appendText
public void appendText(java.lang.String text, int style)
- Appends
textto the end of this output with the specified style attributes.The text will be formatted according to
style, and it will be displayed in any display mode. This method is equivalent to:appendText(text, style, StyledTextOutput.MODE_ALL)
appendText
public void appendText(java.lang.String text)
- Appends
textto the end of this output.The text will be formatted as plain text, and it will be displayed in any display mode. This method is equivalent to:
appendText(text, 0, StyledTextOutput.MODE_ALL)
appendOutput
public void appendOutput(Output output, int displayModes)
- Appends additional output to the end of this text. The output will only
be displayed if the display mode matches one of the specified modes.
If
outputis anotherStyledTextOutput, then its text and style attributes will simply be copied. Ifoutputis a different form of output (for example, an ImageOutput, then it will be embedded in this text at the indicated location.
appendOutput
public void appendOutput(Output output)
- Appends additional output to the end of this text. The output will
be displayed in any display mode. This method is equivalent to:
appendOutput(output, StyledTextOutput.MODE_ALL)
appendInNewLocation
public void appendInNewLocation(Output output, int newLocation)
- Appends additional output to the end of this text, changing its location
as indicated.
If
outputis anotherStyledTextOutput, then its text and attributes will be copied, but any location attributes will be replaced withnewLocation. Ifoutputis a different form of output, then this method is equivalent to:appendOutput(output)
appendMath
public void appendMath(java.lang.String text)
- Appends
textto the end of this output with theSTYLE_FACE_MATH55 attribute. This is purely a convenience method and is equivalent to:appendText(text, STYLE_FACE_MATH)
appendSymbol
public void appendSymbol(int symbol,
int style,
int displayModes)
- Appends an abstract symbol to the end of this output.
The symbol will be formatted according to
style, and it will only be displayed if the display mode matches one of the specified modes.
appendSymbol
public void appendSymbol(int symbol,
int style)
- Appends an abstract symbol to the end of this output.
The symbol will be formatted according to
style, and it will be displayed in any display mode. This method is equivalent to:appendSymbol(symbol, style, StyledTextOutput.MODE_ALL)
appendSymbol
public void appendSymbol(int symbol)
- Appends an abstract symbol to the end of this output.
The symbol will be formatted as plain text, and it will be displayed in any display mode. This method is equivalent to:
appendSymbol(symbol, StyledTextOutput.STYLE_FACE_MATH, StyledTextOutput.MODE_ALL)
hasSubOrSuperscript
public boolean hasSubOrSuperscript()
- Returns
trueif any of the text in this output is subscript or superscript.
iterator
public java.text.AttributedCharacterIterator iterator()
- Gets an iterator over this text output.
toScreenImage
public java.awt.Image toScreenImage(int pixelWidth)
- Description copied from interface:
Output - Converts this
Outputto an image suitable for screen display. The Combinatorial Game Suite user interface calls this method to display worksheet output.The
pixelWidthparameter is the desired width of the image, in pixels. It is not an absolute requirement. TheOutputobject will generate an image that fits withinpixelWidthprovided that this does not otherwise compromise the readability of the display.- Specified by:
toScreenImagein interfaceOutput
toScreenImage
public java.awt.Image toScreenImage(int pixelWidth, int maxLines)
hasAdditionalLines
public boolean hasAdditionalLines()
toPlainText
public java.lang.String toPlainText()
- Description copied from interface:
Output - Converts this
Outputto aStringthat is readable as-is.- Specified by:
toPlainTextin interfaceOutput
toLatexSource
public java.lang.String toLatexSource()
- Description copied from interface:
Output - Converts this
Outputto a LaTeX source fragment. The resultingStringcan then be compiled using LaTeX.- Specified by:
toLatexSourcein interfaceOutput
|
|||||||||
| Home >> All >> cgsuite >> [ plugin overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
cgsuite.plugin.StyledTextOutput