2.3.6 - Line Wrapper - JdlLineWrapper

John W. Campbell

2.3.6.1 Introduction

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

2.3.6.2 Class Details

Package:
Jdl.JdlLib;
Class name:
JdlLineWrapper
Class definition:
public class JdlLineWrapper
Extends:
Object
Implements:
none
Actions:
none

2.3.6.3 Accessible Fields

No fields with public, package or protected access defined.

2.3.6.4 Constructor

2.3.6.4.1 Introduction

A single constructor is available.

Constructor:

Standard constructor

2.3.6.4.2 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.

2.3.6.5 Methods

2.3.6.5.1 Introduction

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

2.3.6.5.2 Add string object - addString

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.

2.3.6.5.3 Add new string line - addLine

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.

2.3.6.5.4 Add string and comma - addStringAndComma

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.

2.3.6.5.5 Add continuous string - addContinuousString

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.

2.3.6.5.6 New line - newLine

This method starts a new output line.

Method Definition:
public void newLine ()
Parameters List:
none

2.3.6.5.7 Add a trailing space - addTrailSpace

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

2.3.6.5.8 Get output - getOutputStrings

This method returns the required output strings.

Method Definition:
public String[] getOutputStrings()
Parameters List:
none
Method Return:
The array of strings for output.

2.3.6.5.9 Get height - getHeight

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