2.3.4 - Size of Strings - JdlSizeofStrings

John W. Campbell

2.3.4.1 Introduction

This class provides an object to find the maximum bounds for given sets of strings and fonts. Strings may be added to the object in several stages if required. The greatest bounds for the set of strings added to date is returned using the findMaximumDimensions method. Note that a temporary JPanel is created on the current display so that the appropriate font metrics can be determined.

Class, constructor and methods:

Class Details
Accessible Fields
Constructors
Methods

2.3.4.2 Class Details

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

2.3.4.3 Accessible Fields

No fields with public, package or protected access defined.

2.3.4.4 Constructors

2.3.4.4.1 Introduction

Four constructors are available.

Constructor:

Constructor 1
Constructor 2
Constructor 3
Constructor 4

2.3.4.4.2 Constructor 1

Constructs a JdlSizeofStrings with an initial set of strings and one or two fonts specified. This constructor assumes that the rendering is on a component on the current display.

Constructor Definition:
public JdlSizeofStrings(String[] strs, Font font, Font font2)
Parameters List:
strs
An array of strings to be tested.
font
The font for the string size tests.
font2
A second font to use in the tests (may be null if not required).

2.3.4.4.3 Constructor 2

Constructs a JdlSizeofStrings with an initial set of strings and one or two fonts specified. This constructor bases the rendering on a given Graphics Context.

Constructor Definition:
public JdlSizeofStrings(String[] strs, Font font, Font font2, Graphics g)
Parameters List:
strs
An array of strings to be tested.
font
The font for the string size tests.
font2
A second font to use in the tests (may be null if not required).
g
The graphics context

2.3.4.4.4 Constructor 3

Constructs a JdlSizeofStrings with an initial string and one or two fonts specified. This constructor assumes that the rendering is on a component on the current display.

Constructor Definition:
public JdlSizeofStrings(String str, Font font, Font font2)
Parameters List:
str
A string to be tested.
font
The font for the string size test.
font2
A second font to use in the test (may be null if not required).

2.3.4.4.5 Constructor 4

Constructs a JdlSizeofStrings with an initial string and one or two fonts specified. This constructor bases the rendering on a given Graphics Context.

Constructor Definition:
public JdlSizeofStrings(String str, Font font, Font font2, Graphics g)
Parameters List:
str
A string to be tested.
font
The font for the string size test.
font2
A second font to use in the test (may be null if not required).
g
The graphics context

2.3.4.5 Methods

2.3.4.5.1 Introduction

This section contains methods for finding the maximum dimensions for the strings and for adding further strings to the set.

Methods:

Find maximum dimensions - findMaximumDimensions
Add string - addString
Add string - addString
Add set of strings - addStrings
Add set of strings - addStrings

2.3.4.5.2 Find maximum dimensions - findMaximumDimensions

Find the maximum string dimensions from all strings input since the creation of the object (width and height treated separately).

Method Definition:
public Dimension findMaximumDimensions()
Parameters List:
none
Method Return:
The maximum string dimensions (width, height)

2.3.4.5.3 Add string - addString

Add a further string to the test using the fonts defined when the object was created.

Method Definition:
public void addString (String str)
Parameters List:
str
The string to be tested.

2.3.4.5.4 Add string - addString

Add a further string to the test to be tested using the specified fonts.

Method Definition:
public void addString (String str, Font font, Font font2)
Parameters List:
strs
The string to be tested.
font
The font for the string size test.
font2
A second font to use in the test (may be null if not required).

2.3.4.5.5 Add set of strings - addStrings

Add a further set of strings to the test using the fonts defined when the object was created.

Method Definition:
public void addStrings (String[] strs)
Parameters List:
strs
An array of strings to be tested.

2.3.4.5.6 Add set of strings - addStrings

Add a further set of strings to the test to be tested using the specified fonts.

Method Definition:
public void addStrings (String[] strs, Font font, Font font2)
Parameters List:
strs
An array of strings to be tested.
font
The font for the string size tests.
font2
A second font to use in the tests (may be null if not required).

⇑ Up 2   ⇑ Up 1   ⇑ Top of this