Java DTV API 1.3
18-Nov-2009

com.sun.dtv.ui
Class DefaultTextLayoutManager

java.lang.Object
  extended by com.sun.dtv.ui.DefaultTextLayoutManager
All Implemented Interfaces:
TextLayoutManager

public class DefaultTextLayoutManager
extends Object
implements TextLayoutManager

This class provides a standard mechanism for rendering of provided texts and is at the same time the simplest implementation of the TextLayoutManager interface.

The DefaultTextLayoutManager is capable to handle alignment and justification of the text contained in the provided string in both horizontal and vertical directions. The direction depends on the currently valid alignment mode of the ViewOnlyComponent. Scaling is not supported though, and even the scaling mode of the ViewOnlyComponent is ignored.

Multi-line texts are supported in the provided string paramter to the render method. Color and font information needed for the rendering will be taken from the provided ViewOnlyComponent

See Also:
TextLayoutManager, SophisticatedTextLayoutManager

Constructor Summary
DefaultTextLayoutManager()
           
 
Method Summary
 Dimension getMaximumSize(ViewOnlyComponent component, String text)
          Provides the maximum size required to render the provided text content in the specified ViewOnlyComponent.
 Dimension getMaximumSize(ViewOnlyComponent component, String text, Insets insets)
          Provides the maximum size required to render the provided text content in the specified ViewOnlyComponent.
 Dimension getMinimumSize(ViewOnlyComponent component, String text)
          Provides the minimum size required to render the provided text content in the specified ViewOnlyComponent.
 Dimension getMinimumSize(ViewOnlyComponent component, String text, Insets insets)
          Provides the minimum size required to render the provided text content in the specified ViewOnlyComponent.
 Dimension getPreferredSize(ViewOnlyComponent component, String text)
          Provides the preferred size required to render the provided text content in the specified ViewOnlyComponent.
 Dimension getPreferredSize(ViewOnlyComponent component, String text, Insets insets)
          Provides the preferred size required to render the provided text content in the specified ViewOnlyComponent.
 void render(String text, Graphics g, ViewOnlyComponent component, Insets insets)
          Render a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTextLayoutManager

public DefaultTextLayoutManager()
Method Detail

getMinimumSize

public Dimension getMinimumSize(ViewOnlyComponent component,
                                String text)
Description copied from interface: TextLayoutManager
Provides the minimum size required to render the provided text content in the specified ViewOnlyComponent. In this version of the method, it is assumed that the ViewOnlyComponent parameter defines the borders by its bounds.

Specified by:
getMinimumSize in interface TextLayoutManager
Parameters:
component - the ViewOnlyComponent to look at
text - the provided text to be rendered
Returns:
the minimum size as com.sun.dtv.lwuit.geom.Dimension object

getMinimumSize

public Dimension getMinimumSize(ViewOnlyComponent component,
                                String text,
                                Insets insets)
Description copied from interface: TextLayoutManager
Provides the minimum size required to render the provided text content in the specified ViewOnlyComponent.

Specified by:
getMinimumSize in interface TextLayoutManager
Parameters:
component - the ViewOnlyComponent to look at
text - the provided text to be rendered
insets - the insets to define the area in which the text should be laid out
Returns:
the minimum size as com.sun.dtv.lwuit.geom.Dimension object

getMaximumSize

public Dimension getMaximumSize(ViewOnlyComponent component,
                                String text)
Description copied from interface: TextLayoutManager
Provides the maximum size required to render the provided text content in the specified ViewOnlyComponent. In this version of the method, it is assumed that the ViewOnlyComponent parameter defines the borders by its bounds.

Specified by:
getMaximumSize in interface TextLayoutManager
Parameters:
component - the ViewOnlyComponent to look at
text - the provided text to be rendered
Returns:
the maximum size as com.sun.dtv.lwuit.geom.Dimension object

getMaximumSize

public Dimension getMaximumSize(ViewOnlyComponent component,
                                String text,
                                Insets insets)
Description copied from interface: TextLayoutManager
Provides the maximum size required to render the provided text content in the specified ViewOnlyComponent.

Specified by:
getMaximumSize in interface TextLayoutManager
Parameters:
component - the ViewOnlyComponent to look at
text - the provided text to be rendered
insets - the insets to define the area in which the text should be laid out
Returns:
the maximum size as com.sun.dtv.lwuit.geom.Dimension object

getPreferredSize

public Dimension getPreferredSize(ViewOnlyComponent component,
                                  String text)
Description copied from interface: TextLayoutManager
Provides the preferred size required to render the provided text content in the specified ViewOnlyComponent. In this version of the method, it is assumed that the ViewOnlyComponent parameter defines the borders by its bounds.

Specified by:
getPreferredSize in interface TextLayoutManager
Parameters:
component - the ViewOnlyComponent to look at
text - the provided text to be rendered
Returns:
the preferred size as com.sun.dtv.lwuit.Dimension object

getPreferredSize

public Dimension getPreferredSize(ViewOnlyComponent component,
                                  String text,
                                  Insets insets)
Description copied from interface: TextLayoutManager
Provides the preferred size required to render the provided text content in the specified ViewOnlyComponent.

Specified by:
getPreferredSize in interface TextLayoutManager
Parameters:
component - the ViewOnlyComponent to look at
text - the provided text to be rendered
insets - the insets to define the area in which the text should be laid out
Returns:
the preferred size as com.sun.dtv.lwuit.Dimension object

render

public void render(String text,
                   Graphics g,
                   ViewOnlyComponent component,
                   Insets insets)
Render a string. The passed ViewOnlyComponent can be used to determine any additional information needed in order to render the string properly (e.g. Font, Color etc.), if the TextLayoutManager class implementing this interface does not provide additional information for that.

The ViewOnlyComponent also defines the layout area by its bounds, while of course the provided insets have also to be taken into account if not null. The clipping rectangle of the Graphics object should not be subject of change by the TextLayoutManager, though.

Specified by:
render in interface TextLayoutManager
Parameters:
text - the string to be rendered. This string may be multi-line, where each line is separated by a "\n"(0x0A). If the string does not fit in the space available, it will be truncated and an ellipsis ("...") appended to indicate the truncation.
g - the graphics context. This includes of course also a clipping rectangle, which should be respected as borders within which the rendering is permitted. An insets parameter not equal to null must be additionally taken into account.
component - the ViewOnlyComponent into which to render. Color and font information to be taken from here. If the specified font is not available, it will be replaced by the nearest built-in font. Each missing character is replaced by an "*" character.
insets - the insets to define the area in which the text should be laid out. This parameter can also be null: in this case the ViewOnlyComponent parameter defines the borders by its bounds.

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.