John W. Campbell
This class provides an object to collect together a series of strings and
prepare a list of strings for printer or window output, wrapping within a
requested text width (based on a specified font). If needed 'continuous'
strings may be added; in these spaces will be preserved and not be treated
as word boundaries.
Class, constructor and methods:
Class Details
Accessible Fields
Constructor
Methods
- Package:
- Jdl.JdlLib;
- Class name:
- JdlLineWrapper
- Class definition:
- public class JdlLineWrapper
- Extends:
- Object
- Implements:
- none
- Actions:
- none
No fields with public, package or protected access defined.
A single constructor is available.
Constructor:
Standard constructor
Constructs a JdlLineWrapper object for a given set of font metrics
and line width.
- Constructor Definition:
- public JdlLineWrapper(FontMetrics fm, int linw)
- Parameters List:
- fm
- The font metrics with which the text is to be rendered.
- linw
- The line width limit in pixels.
This section contains methods for adding strings to the object and getting
the processed strings required for output to the window. The required
height for the set of output strings may also be determined.
Methods:
Add string object - addString
Add new string line - addLine
Add string and comma - addStringAndComma
Add continuous string - addContinuousString
New line - newLine
Add a trailing space - addTrailSpace
Get output - getOutputStrings
Get height - getHeight
This method adds a string to the object. Spaces will be treated as
word boundaries and all words will be output with single spaces between them.
- Method Definition:
- public void addString (String str)
- Parameters List:
- str
- The string to be added.
This method starts a new line and adds a string to this line. Spaces will
be treated as word boundaries and all words will be output with single
spaces between them.
- Method Definition:
- public void addLine (String str)
- Parameters List:
- str
- The string to be added.
This method adds a string to the object. Spaces will be treated as word
boundaries and all words will be output with single spaces between them.
A comma will be added to the end of the last word of the string if there
is not one already present.
- Method Definition:
- public void addStringAndComma (String str)
- Parameters List:
- str
- The string to be added with a final comma.
This method adds a 'continuous' string to the object. This will be treated as
a single word and will only be split if its length exceeds the line width
allowed.
- Method Definition:
- public void addContinuousString (String str)
- Parameters List:
- str
- The 'continuous' string to be added.
This method starts a new output line.
- Method Definition:
- public void newLine ()
- Parameters List:
- none
This method adds a trailing space if there is room for one at the end of
the current line.
- Method Definition:
- public void addTrailSpace ()
- Parameters List:
- none
This method returns the required output strings.
- Method Definition:
- public String[] getOutputStrings()
- Parameters List:
- none
- Method Return:
-
The array of strings for output.
This method gets the required height for the set of lines.
- Method Definition:
- public int getHeight()
- Parameters List:
- none
- Method Return:
-
The height of the set of strings in pixels.
⇑ Up 2
⇑ Up 1
⇑ Top of this