G4P (GUI for Processing) 4.3.11
A set of GUI controls for your Processing sketch.
|
Classes | |
class | TextLayoutHitInfo |
class | TextLayoutInfo |
Public Member Functions | |
void | addAttribute (Attribute type, Object value) |
void | addAttribute (Attribute type, Object value, int beginIdx, int endIdx) |
void | addAttribute (Attribute type, Object value, int lineNo) |
void | addAttribute (Attribute type, Object value, int lineNo, int charStart, int charEnd) |
void | clearAttributes () |
void | clearAttributes (int beginIdx, int endIdx) |
void | clearAttributes (int lineNo) |
void | clearAttributes (int lineNo, int beginIdx, int endIdx) |
StyledString | deepCopy () throws Exception |
boolean | deleteCharacters (int fromPos, int nbrToRemove) |
LinkedList< TextLayoutInfo > | getLines (Graphics2D g2d) |
float | getMaxLineHeight () |
float | getMaxLineLength () |
int | getNbrLines () |
String | getPlainText () |
String | getPlainText (int beginIdx, int endIdx) |
String | getPlainText (int lineNo) |
String[] | getPlainTextAsArray () |
float | getTextAreaHeight () |
int | getWrapWidth () |
int | insertCharacters (String chars, int insertPos) |
int | insertCharacters (String chars, int insertPos, boolean startNewLine, boolean endNewLine) |
int | insertCharacters (String chars, int lineNo, int charStart, boolean startNewLine, boolean endNewLine) |
boolean | insertEOL (int insertPos) |
void | invalidateText () |
int | length () |
void | setJustify (boolean justify) |
void | setJustifyRatio (float jRatio) |
void | setText (String text) |
void | setText (String text, int wrapWidth) |
void | setWrapWidth (int wrapWidth) |
StyledString (String startText) | |
StyledString (String startText, int wrapWidth) | |
Static Public Member Functions | |
static StyledString | load (PApplet papp, String fname) |
static void | save (PApplet papp, StyledString ss, String fname) |
Protected Member Functions | |
void | removeConsecutiveBlankLines () |
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.
g4p_controls.StyledString.StyledString | ( | 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 | the initial text for this instance |
g4p_controls.StyledString.StyledString | ( | String | startText, |
int | wrapWidth | ||
) |
Supports multiple lines of text wrapped on word boundaries.
startText | the text to use |
wrapWidth | the wrap width |
void g4p_controls.StyledString.addAttribute | ( | Attribute | type, |
Object | value | ||
) |
Add an attribute that affects the whole length of the string.
type | attribute type |
value | attribute value |
void g4p_controls.StyledString.addAttribute | ( | Attribute | type, |
Object | value, | ||
int | beginIdx, | ||
int | endIdx | ||
) |
Set the attribute to be applied to a range of characters starting at beginIdx and ending with endIdx-1.
type | attribute type |
value | attribute value |
beginIdx | the index of the first character (inclusive) |
endIdx | the index of the last character (exclusive) |
void g4p_controls.StyledString.addAttribute | ( | Attribute | type, |
Object | value, | ||
int | lineNo | ||
) |
Add a text attribute (style) to an entire display line
type | attribute type |
value | attribute value |
lineNo | the line of test affected |
void g4p_controls.StyledString.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 g4p_controls.StyledString.clearAttributes | ( | ) |
Removes all styling from the string.
void g4p_controls.StyledString.clearAttributes | ( | int | beginIdx, |
int | endIdx | ||
) |
Remove text attributes (style) to the specified range of characters.
beginIdx | the index of the first character (inclusive) |
endIdx | the index of the last character (exclusive) |
void g4p_controls.StyledString.clearAttributes | ( | int | lineNo | ) |
Clear the attributes from a given line
lineNo | the line to use |
void g4p_controls.StyledString.clearAttributes | ( | int | lineNo, |
int | beginIdx, | ||
int | endIdx | ||
) |
Remove text attributes (style) to the specified line and range of characters.
lineNo | the line of test affected |
beginIdx | the index of the first character (inclusive) |
endIdx | the index of the last character (exclusive) |
boolean g4p_controls.StyledString.deleteCharacters | ( | int | fromPos, |
int | nbrToRemove | ||
) |
Remove a number of characters from the string
nbrToRemove | number of characters to remove |
fromPos | start location for removal |
LinkedList< TextLayoutInfo > g4p_controls.StyledString.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 g4p_controls.StyledString.getMaxLineHeight | ( | ) |
float g4p_controls.StyledString.getMaxLineLength | ( | ) |
int g4p_controls.StyledString.getNbrLines | ( | ) |
String g4p_controls.StyledString.getPlainText | ( | ) |
Get the plain text as a String. Any line breaks will kept and will be represented by the character 'backslash n'
String g4p_controls.StyledString.getPlainText | ( | int | beginIdx, |
int | endIdx | ||
) |
Get the plain text as a String. Any line breaks will kept and will be represented by the character 'backslash n'
beginIdx | the beginning index inclusive |
endIdx | the ending index exclusive |
String g4p_controls.StyledString.getPlainText | ( | int | lineNo | ) |
Get a line of text from the plain text. Lines are separated by End-of-line (EOL) characters.
lineNo | the line number we want the text for |
String[] g4p_controls.StyledString.getPlainTextAsArray | ( | ) |
Get the plain text as a String array. (splitting on line breaks)
float g4p_controls.StyledString.getTextAreaHeight | ( | ) |
int g4p_controls.StyledString.getWrapWidth | ( | ) |
int g4p_controls.StyledString.insertCharacters | ( | String | chars, |
int | insertPos | ||
) |
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 g4p_controls.StyledString.insertCharacters | ( | String | chars, |
int | insertPos, | ||
boolean | startNewLine, | ||
boolean | endNewLine | ||
) |
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 a new line before the chars to insert |
endNewLine | if true append a new line after the chars to insert |
int g4p_controls.StyledString.insertCharacters | ( | String | chars, |
int | lineNo, | ||
int | charStart, | ||
boolean | startNewLine, | ||
boolean | endNewLine | ||
) |
Insert some text into the position indicated.
lineNo | a valid line number |
charStart | the position in the line ≥ 0 |
chars | the characters to insert |
startNewLine | prefix the chars with a EOL |
endNewLine | postfix the chars with a EOL |
boolean g4p_controls.StyledString.insertEOL | ( | int | insertPos | ) |
Use this method to insert an EOL character.
insertPos | index position to insert EOL |
int g4p_controls.StyledString.length | ( | ) |
|
static |
Load and return a StyledString object from the given file.
papp | the main sketch PApplet instance |
fname | the filename of the StyledString |
|
protected |
Ensure we do not have more than 2 consecutive blank lines. This can happen when manually deleting a line adjacent to a blank line.
|
static |
Save the named StyleString in the named file.
papp | the main sketch PApplet instance |
ss | the styled string |
fname | the filename to use |
void g4p_controls.StyledString.setJustify | ( | boolean | justify | ) |
Text can be either left or fully justified.
justify | true for full justification |
void g4p_controls.StyledString.setJustifyRatio | ( | float | jRatio | ) |
Justify only if the line has sufficient text to do so.
jRatio | ratio of text length to visibleWidth |
void g4p_controls.StyledString.setText | ( | String | text | ) |
Change the text for single line styled string
text | the text to use |
void g4p_controls.StyledString.setText | ( | String | text, |
int | wrapWidth | ||
) |
Change the text for single line styled string
text | the text to use |
wrapWidth | the wrap width |
void g4p_controls.StyledString.setWrapWidth | ( | int | wrapWidth | ) |
Set the maximum width of a line.
wrapWidth | the maximum line length in pixels |