org.havi.ui
Class HDefaultTextLayoutManager

java.lang.Object
  extended by org.havi.ui.HDefaultTextLayoutManager
All Implemented Interfaces:
HTextLayoutManager

public class HDefaultTextLayoutManager
extends java.lang.Object
implements HTextLayoutManager

The HDefaultTextLayoutManager provides the default text rendering mechanism for the HStaticText HText and HTextButton classes.

The HDefaultTextLayoutManager handles alignment and justification of text in both horizontal and vertical directions as specified by the current alignment modes set on HVisible. It does not support scaling of text content, and the scaling mode of an associated HVisible is ignored.

The string passed to the render method may be multi-line, where each line is separated by a "\n" (0x0A). If the string does not fit in the space available, the string shall be truncated and an ellipsis ("...") appended to indicate the truncation.

The HDefaultTextLayoutManager should query the HVisible passed to its render method to determine the basic font to render text in. If the specified font cannot be accessed the default behavior is to replace it with the nearest builtin font. Each missing character is replaced with an "!" character.

The antialiasing behavior of HDefaultTextLayoutManager is platform dependent.


The parameters to the constructors are as follows, in cases where parameters are not used, then the constructor should use the default values.

Default parameter values exposed in the constructors

ParameterDescriptionDefault value Set methodGet method
None.

Default parameter values not exposed in the constructors

DescriptionDefault valueSet method Get method

See Also:
HTextLayoutManager, HStaticText, HText, HTextButton, HTextLook, HVisible

Constructor Summary
HDefaultTextLayoutManager()
          Creates an HDefaultTextLayoutManager object.
 
Method Summary
 java.awt.Dimension getMaximumSize(HVisible hvisible)
          Returns the maximum size required to render the text content in any possible interaction state of the specified HVisible component.
 java.awt.Dimension getMinimumSize(HVisible hvisible)
          Returns the minimum size required to render the text content in any possible interaction state of the specified HVisible component.
 java.awt.Dimension getPreferredSize(HVisible hvisible)
          Returns the preferred size to render the text content in any possible interaction state of the specified HVisible component.
 void render(java.lang.String markedUpString, java.awt.Graphics g, HVisible v, java.awt.Insets insets)
          Render the string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HDefaultTextLayoutManager

public HDefaultTextLayoutManager()
Creates an HDefaultTextLayoutManager object. See the class description for details of constructor parameters and default values.

Method Detail

getMinimumSize

public java.awt.Dimension getMinimumSize(HVisible hvisible)
Returns the minimum size required to render the text content in any possible interaction state of the specified HVisible component. To achieve this, the maximum width and maximum height of all minimum sizes are returned.

Parameters:
hvisible - - a component within which text will be rendered

getMaximumSize

public java.awt.Dimension getMaximumSize(HVisible hvisible)
Returns the maximum size required to render the text content in any possible interaction state of the specified HVisible component. To achieve this, the maximum width and maximum height of all maximum sizes are returned. It is a valid implementation option to return a dimension with a width and height of Short.MAX_VALUE.

Parameters:
hvisible - - a component within which text will be rendered

getPreferredSize

public java.awt.Dimension getPreferredSize(HVisible hvisible)
Returns the preferred size to render the text content in any possible interaction state of the specified HVisible component. To achieve this, the maximum width and maximum height of all preferred sizes are returned.

Parameters:
hvisible - - a component within which text will be rendered

render

public void render(java.lang.String markedUpString,
                   java.awt.Graphics g,
                   HVisible v,
                   java.awt.Insets insets)
Render the string. The HTextLayoutManager should use the passed HVisible object to determine any additional information required to render the string, e.g. Font, Color etc.

The text should be laid out in the layout area, which is defined by the bounds of the specified HVisible, after subtracting the insets. If the insets are null the full bounding rectangle is used as the area to render text into.

The HTextLayoutManager should not modify the clipping rectangle of the Graphics object.

Specified by:
render in interface HTextLayoutManager
Parameters:
markedUpString - the string to render.
g - the graphics context, including a clipping rectangle which encapsulates the area within which rendering is permitted. If a valid insets value is passed to this method then text must only be rendered into the bounds of the widget after the insets are subtracted. If the insets value is null then text is rendered into the entire bounding area of the HVisible. It is implementation specific whether or not the renderer takes into account the intersection of the clipping rectangle in each case for optimization purposes.
v - the HVisible into which to render.
insets - the insets to determine the area in which to layout the text, or null.