Game Control Plus
1.2.2
|
Classes | |
class | AttributeRun |
class | TextLayoutHitInfo |
class | TextLayoutInfo |
Public Member Functions | |
MStyledString (String startText) | |
MStyledString (String startText, int wrapWidth) | |
String | getPlainText () |
String[] | getPlainTextAsArray () |
int | length () |
void | setJustify (boolean justify) |
void | setJustifyRatio (float jRatio) |
void | addAttribute (Attribute type, Object value) |
void | addAttribute (Attribute type, Object value, int lineNo, int charStart, int charEnd) |
void | addAttribute (Attribute type, Object value, int charStart, int charEnd) |
void | clearAttributes (int lineNo, int charStart, int charEnd) |
void | clearAttributes (int charStart, int charEnd) |
void | clearAttributes () |
int | insertCharacters (int insertPos, String chars) |
int | insertCharacters (int insertPos, String chars, boolean startNewLine) |
boolean | insertEOL (int insertPos) |
boolean | deleteCharacters (int fromPos, int nbrToRemove) |
void | setFont (Font a_font) |
LinkedList< TextLayoutInfo > | getLines (Graphics2D g2d) |
int | getNbrLines () |
float | getTextAreaHeight () |
float | getMaxLineLength () |
float | getMaxLineHeight () |
int | getWrapWidth () |
void | setWrapWidth (int wrapWidth) |
Static Public Member Functions | |
static void | save (PApplet papp, MStyledString ss, String fname) |
static MStyledString | load (PApplet papp, String fname) |
Package Functions | |
MStyledString | convertToSingleLineText () |
TextLayoutHitInfo | calculateFromXY (Graphics2D g2d, float px, float py) |
TextLayoutInfo | getTLIforLineNo (int ln) |
TextLayoutInfo | getTLIforYpos (float y) |
TextLayoutInfo | getTLIforCharNo (int charNo) |
TextLayoutHitInfo | getTLHIforCharPosition (int lineNo, int charNo) |
Package Attributes | |
int | startIdx = -1 |
int | endIdx = -1 |
Private Member Functions | |
AttributedString | insertParagraphMarkers (String ptext, AttributedString as) |
Object | validateTextAttributeColor (TextAttribute ta, Object value) |
void | applyAttributes () |
int | insertCharactersImpl (int insertPos, String chars, boolean startNewLine) |
String | makeStringSafeForInsert (String chars) |
float | getHeight (TextLayout layout) |
String | removeDoubleSpacingFromPlainText (String chars) |
String | removeSingleSpacingFromPlainText (String chars) |
ImageGraphicAttribute | getParagraghSpacer (int ww) |
void | readObject (ObjectInputStream ois) throws ClassNotFoundException, IOException |
Private Attributes | |
transient AttributedString | styledText = null |
transient ImageGraphicAttribute | spacer = null |
transient LineBreakMeasurer | lineMeasurer = null |
transient LinkedList < TextLayoutInfo > | linesInfo = new LinkedList<TextLayoutInfo>() |
transient Font | font = null |
String | plainText = "" |
LinkedList< AttributeRun > | baseStyle = new LinkedList<AttributeRun>() |
LinkedList< AttributeRun > | atrun = new LinkedList<AttributeRun>() |
int | wrapWidth = Integer.MAX_VALUE |
boolean | invalidLayout = true |
boolean | invalidText = true |
boolean | justify = false |
float | justifyRatio = 0.7f |
float | textHeight = 0 |
float | maxLineLength = 0 |
float | maxLineHeight = 0 |
int | nbrLines |
Static Private Attributes | |
static final long | serialVersionUID = 8380395122026579368L |
Additional Inherited Members | |
Public Attributes inherited from org.gamecontrolplus.gui.MConstantsInternal | |
String | SLIDER_STYLES = "|grey_blue|blue18px|green_red20px|purple18px|red_yellow18px|" |
String | DEFAULT_SLIDER_STYLE = "grey_blue" |
int | DRAW_METHOD = 0x00000001 |
int | MOUSE_METHOD = 0x00000002 |
int | PRE_METHOD = 0x00000004 |
int | KEY_METHOD = 0x00000008 |
int | POST_METHOD = 0x00000010 |
int | ALL_METHOD = 0x0000001f |
int | RUNTIME_ERROR = 0xf0000000 |
int | MISSING = 0x01000001 |
int | NONEXISTANT = 0x01000002 |
int | EXCP_IN_HANDLER = 0x81000003 |
int | OFF_CONTROL = 0 |
int | OVER_CONTROL = 1 |
int | PRESS_CONTROL = 2 |
int | DRAG_CONTROL = 3 |
int | TINT_FOR_ALPHA = 255 |
int | I_NONE = 0 |
int | I_TL = 1 |
int | I_TR = 2 |
int | I_CL = 4 |
int | I_CR = 8 |
int | I_INSIDE = 16 |
int | I_COVERED = 32 |
int | I_MODES = 63 |
int | MERGE_RUNS = 256 |
int | CLIP_RUN = 512 |
int | COMBI_MODES = 768 |
int[][] | grid |
BasicStroke | pen_1_0 = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND) |
BasicStroke | pen_2_0 = new BasicStroke(2, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND) |
BasicStroke | pen_3_0 = new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND) |
BasicStroke | pen_4_0 = new BasicStroke(4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND) |
This class is used to represent text with attributes.
It means that you don't have to have the same style of font or even the same font face over the whole length of the text.
Most font features can be modified all except the text background which is transparent. There is a feature to highlight part of the string by having a different background colour but this is used for highlighting selected text in GTextField and GTextArea components.
It is also used for all controls that use text.
org.gamecontrolplus.gui.MStyledString.MStyledString | ( | String | startText | ) |
This is assumed to be a single line of text (i.e. no wrap). EOL characters will be stripped from the text before use.
startText |
org.gamecontrolplus.gui.MStyledString.MStyledString | ( | String | startText, |
int | wrapWidth | ||
) |
Supports multiple lines of text wrapped on word boundaries.
startText | |
wrapWidth |
void org.gamecontrolplus.gui.MStyledString.addAttribute | ( | Attribute | type, |
Object | value | ||
) |
Add an attribute that affects the whole length of the string.
type | attribute type |
value | attribute value |
void org.gamecontrolplus.gui.MStyledString.addAttribute | ( | Attribute | type, |
Object | value, | ||
int | lineNo, | ||
int | charStart, | ||
int | charEnd | ||
) |
Add a text attribute (style) to the specifies range of characters
type | attribute type |
value | attribute value |
lineNo | the line of test affected |
charStart | the first character affected |
charEnd | the character position after the last character affected. |
void org.gamecontrolplus.gui.MStyledString.addAttribute | ( | Attribute | type, |
Object | value, | ||
int | charStart, | ||
int | charEnd | ||
) |
Set the attribute to be applied to a range of characters starting at charStart and ending with charEnd-1.
type | attribute type |
value | attribute value |
charStart | the first character affected |
charEnd | the character position after the last character affected. |
|
private |
Do not use this method use clearAttributes() instead.
It has been left in to avoid having to release a new GUI Builder version just for this change. Be warned - it will be removed on next release of GUI Builder.
Must call this method to apply
void org.gamecontrolplus.gui.MStyledString.clearAttributes | ( | int | lineNo, |
int | charStart, | ||
int | charEnd | ||
) |
Remove text attributes (style) to the specified line and range of characters
lineNo | the line of test affected |
charStart | the first character affected |
charEnd | the character position after the last character affected. |
void org.gamecontrolplus.gui.MStyledString.clearAttributes | ( | int | charStart, |
int | charEnd | ||
) |
Remove text attributes (style) to the specified range of characters
charStart | the first character affected |
charEnd | the character position after the last character affected. |
void org.gamecontrolplus.gui.MStyledString.clearAttributes | ( | ) |
Removes all styling from the string.
|
package |
Converts this StyledString from multi-line to single-line by replacing all EOL characters with the space character for paragraphs
ptext | |
as |
boolean org.gamecontrolplus.gui.MStyledString.deleteCharacters | ( | int | fromPos, |
int | nbrToRemove | ||
) |
Remove a number of characters from the string
nbrToRemove | number of characters to remove |
fromPos | start location for removal |
|
private |
Get the height of the given TextLayout
layout |
LinkedList<TextLayoutInfo> org.gamecontrolplus.gui.MStyledString.getLines | ( | Graphics2D | g2d | ) |
Get the text layouts for display if the string has changed since last call to this method regenerate them.
g2d | Graphics2D display context |
float org.gamecontrolplus.gui.MStyledString.getMaxLineHeight | ( | ) |
Get the height of the tallest line
float org.gamecontrolplus.gui.MStyledString.getMaxLineLength | ( | ) |
Return the length of the longest line.
int org.gamecontrolplus.gui.MStyledString.getNbrLines | ( | ) |
Get the number of lines in the layout
|
private |
Create a graphic image character to simulate paragraph breaks
ww |
String org.gamecontrolplus.gui.MStyledString.getPlainText | ( | ) |
Get the plain text as a String. Any line breaks will kept and will be represented by the character 'backslash n'
String [] org.gamecontrolplus.gui.MStyledString.getPlainTextAsArray | ( | ) |
Get the plain text as a String array. (splitting on line breaks)
float org.gamecontrolplus.gui.MStyledString.getTextAreaHeight | ( | ) |
Return the height of the text line(s)
|
package |
lineNo | |
charNo |
|
package |
This will always return a layout provided charNo >= 0.
If charNo > than the index of the last character in the plain text then this should be corrected to the last character in the layout by the caller.
charNo | the character position in text (must be >= 0) |
|
package |
Get a layout based on line number
ln | line number |
|
package |
This will always return a layout provide there is some text.
y | Must be >= 0 |
int org.gamecontrolplus.gui.MStyledString.getWrapWidth | ( | ) |
Get the break width used to create the lines.
int org.gamecontrolplus.gui.MStyledString.insertCharacters | ( | int | insertPos, |
String | chars | ||
) |
Insert 1 or more characters into the string. The inserted text will first be made safe by removing any inappropriate EOL characters.
Do not use this method to insert EOL characters, use the
insertEOL(int)
method instead.
insertPos | position in string to insert characters |
chars | the characters to insert |
int org.gamecontrolplus.gui.MStyledString.insertCharacters | ( | int | insertPos, |
String | chars, | ||
boolean | startNewLine | ||
) |
Insert 1 or more characters into the string. The inserted text will first be made safe by removing any inappropriate EOL characters.
Do not use this method to insert EOL characters, use the
insertEOL(int)
method instead.
insertPos | position in string to insert characters |
chars | the characters to insert |
startNewLine | if true insert onto a new line |
boolean org.gamecontrolplus.gui.MStyledString.insertEOL | ( | int | insertPos | ) |
Use this method to insert an EOL character.
insertPos | index position to insert EOL |
|
private |
This class uses transparent images to simulate end/starting positions for paragraphs
ptext | |
as |
int org.gamecontrolplus.gui.MStyledString.length | ( | ) |
Get the number of characters in this styled string
|
static |
Load and return a StyledString object from the given file.
papp | |
fname | the filename of the StyledString |
|
private |
This is ONLY used when multiple characters are to be inserted.
If it is single line text i.e. no wrapping then it removes all EOLs If it is multiple line spacing it will reduce all double EOLs to single EOLs and remove any EOLs at the start or end of the string.
chars |
|
private |
Ensure we do not have blank lines by replacing double EOL characters by single EOL until there are only single EOLs.
Using replaceAll on its own will not work because EOL/EOL/EOL would become EOL/EOL not the single EOL required.
|
private |
Remove all EOL characters from the string. This is necessary if the string is for a single line component.
chars | the string to use |
|
static |
Save the named StyleString in the named file.
papp | |
ss | the styled string |
fname |
void org.gamecontrolplus.gui.MStyledString.setJustify | ( | boolean | justify | ) |
Text can be either left or fully justified.
justify | true for full justification |
void org.gamecontrolplus.gui.MStyledString.setJustifyRatio | ( | float | jRatio | ) |
Justify only if the line has sufficient text to do so.
jRatio | ratio of text length to visibleWidth |
void org.gamecontrolplus.gui.MStyledString.setWrapWidth | ( | int | wrapWidth | ) |
Set the maximum width of a line.
wrapWidth |
|
private |
If the text attribute is BACKGROUND or FOREGROUND then if we pass an integer (e.g. from Processing sketch) then convert it.
ta | the text attribute |
value | the value to use with this text attribute |