John W. Campbell
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
- Package:
- Jdl.JdlLib;
- Class name:
- JdlSizeofStrings
- Class definition:
- public class JdlSizeofStrings
- Extends:
- Object
- Implements:
- none
- Actions:
- none
No fields with public, package or protected access defined.
Four constructors are available.
Constructor:
Constructor 1
Constructor 2
Constructor 3
Constructor 4
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).
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
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).
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
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
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)
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.
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).
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.
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