Java DTV API 1.3
18-Nov-2009

com.sun.dtv.ui
Class SophisticatedTextLayoutManager

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

public class SophisticatedTextLayoutManager
extends Object
implements TextLayoutManager

This class provides a TextLayoutManager with more features than the DefaultTextLayoutManager in order to enable more sophisticated layout design possibilities for test to be shown in TV components. It is recommended, that the algorithms for rendering the text follow the standard nomenclature and algorithm for layout of bi-directional text as defined in Unicode 3.0. See http://unicode.org for details.

See Also:
DefaultTextLayoutManager, TextLayoutManager

Field Summary
static int DEFAULT_LINE_SPACE
          Constant to be used with the setLineSpace method of SophisticatedTextLayoutManager.
static int HORIZONTAL_ALIGN_CENTER
          Constant to be used with the setHorizontalAlignment method of SophisticatedTextLayoutManager.
static int HORIZONTAL_ALIGN_JUSTIFIED
          Constant to be used with the setHorizontalAlignment method of SophisticatedTextLayoutManager.
static int HORIZONTAL_ALIGN_LEFT
          Constant to be used with the setHorizontalAlignment method of SophisticatedTextLayoutManager.
static int HORIZONTAL_ALIGN_RIGHT
          Constant to be used with the setHorizontalAlignment method of SophisticatedTextLayoutManager.
static int LINE_ORIENTATION_HORIZONTAL
          Constant to be used with the setLineOrientation method of SophisticatedTextLayoutManager.
static int LINE_ORIENTATION_VERTICAL
          Constant to be used with the setLineOrientation method of SophisticatedTextLayoutManager.
static int START_LOWER_LEFT
          Constant to be used with the setStartCorner method of SophisticatedTextLayoutManager.
static int START_LOWER_RIGHT
          Constant to be used with the setStartCorner method of SophisticatedTextLayoutManager.
static int START_UPPER_LEFT
          Constant to be used with the setStartCorner method of SophisticatedTextLayoutManager.
static int START_UPPER_RIGHT
          Constant to be used with the setStartCorner method of SophisticatedTextLayoutManager.
static int VERTICAL_ALIGN_BOTTOM
          Constant to be used with the setVerticalAlignment method of SophisticatedTextLayoutManager.
static int VERTICAL_ALIGN_CENTER
          Constant to be used with the setVerticalAlignment method of SophisticatedTextLayoutManager.
static int VERTICAL_ALIGN_JUSTIFIED
          Constant to be used with the setVerticalAlignment method of SophisticatedTextLayoutManager.
static int VERTICAL_ALIGN_TOP
          Constant to be used with the setVerticalAlignment method of SophisticatedTextLayoutManager.
 
Constructor Summary
SophisticatedTextLayoutManager()
           
 
Method Summary
 void addTextOverflowListener(TextOverflowListener listener)
          Register a TextOverflowListener.
 int getHorizontalAlignment()
          Retrieve horizontal alignment.
 Insets getInsets()
          Returns the insets as set by the setInsets method.
 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.
 int getVerticalAlignment()
          Retrieve vertical alignment.
 void removeTextOverflowListener(TextOverflowListener listener)
          Removes a previously registered TextOverflowListener from this TextLayoutManager.
 void render(String text, Graphics g, ViewOnlyComponent component, Insets insets)
          Render a string.
 int retrieveHorizontalTabSpacing()
          Retrieve horizontal tabulator spacing.
 int retrieveLetterSpace()
          Retrieve letter space .
 int retrieveLineOrientation()
          Retrieve line orientation.
 int retrieveLineSpace()
          Retrieve line spacing.
 int retrieveStartCorner()
          Retrieve starting corner.
 boolean retrieveTextWrapping()
          Retrieve text wrapping.
 void setHorizontalAlignment(int alignment)
          Determine the horizontal alignment.
 void setHorizontalTabSpacing(int spacing)
          Determines the horizontal tabulation spacing.
 void setInsets(Insets insets)
          Determines the insets to be used by the SophisticatedTextLayoutManager to provide a virtual margin.
 void setLetterSpace(int spacing)
          Determines the space between letters.
 void setLineOrientation(int orientation)
          Determine the line orientation.
 void setLineSpace(int spacing)
          Determines space between lines.
 void setStartCorner(int corner)
          Determine the starting corner for text writing.
 void setTextWrapping(boolean wrap)
          Determines whether text is wrapped.
 void setVerticalAlignment(int alignment)
          Determine the vertical alignment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HORIZONTAL_ALIGN_LEFT

public static final int HORIZONTAL_ALIGN_LEFT
Constant to be used with the setHorizontalAlignment method of SophisticatedTextLayoutManager. It indicates that all content will be left aligned. Left aligned means the text is aligned to the left side if the line orientation is horizontal, text starts at upper left corner, and is read from left to right and from top to the bottom.

See Also:
Constant Field Values

HORIZONTAL_ALIGN_CENTER

public static final int HORIZONTAL_ALIGN_CENTER
Constant to be used with the setHorizontalAlignment method of SophisticatedTextLayoutManager. It indicates that all content will be centered horizontally. Centered horizontally means the text is centered horizontally if the line orientation is horizontal, text starts at upper left corner, and is read from left to right and from top to the bottom.

See Also:
Constant Field Values

HORIZONTAL_ALIGN_RIGHT

public static final int HORIZONTAL_ALIGN_RIGHT
Constant to be used with the setHorizontalAlignment method of SophisticatedTextLayoutManager. It indicates that all content will be right aligned. Right aligned means the text is aligned to the right side if the line orientation is horizontal, text starts at upper left corner, and is read from left to right and from top to the bottom.

See Also:
Constant Field Values

HORIZONTAL_ALIGN_JUSTIFIED

public static final int HORIZONTAL_ALIGN_JUSTIFIED
Constant to be used with the setHorizontalAlignment method of SophisticatedTextLayoutManager. It indicates that all content will be justified horizontally. Horizontal justified means the text is written as a horizontal block if the line orientation is horizontal, text starts at upper left corner, and is read from left to right and from top to the bottom.

See Also:
Constant Field Values

VERTICAL_ALIGN_TOP

public static final int VERTICAL_ALIGN_TOP
Constant to be used with the setVerticalAlignment method of SophisticatedTextLayoutManager. It indicates that all content will be top aligned.

See Also:
Constant Field Values

VERTICAL_ALIGN_CENTER

public static final int VERTICAL_ALIGN_CENTER
Constant to be used with the setVerticalAlignment method of SophisticatedTextLayoutManager. It indicates that all content will be centered vertically.

See Also:
Constant Field Values

VERTICAL_ALIGN_BOTTOM

public static final int VERTICAL_ALIGN_BOTTOM
Constant to be used with the setVerticalAlignment method of SophisticatedTextLayoutManager. It indicates that all content will be bottom aligned.

See Also:
Constant Field Values

VERTICAL_ALIGN_JUSTIFIED

public static final int VERTICAL_ALIGN_JUSTIFIED
Constant to be used with the setVerticalAlignment method of SophisticatedTextLayoutManager. It indicates that all content will be justified vertically.

See Also:
Constant Field Values

LINE_ORIENTATION_HORIZONTAL

public static final int LINE_ORIENTATION_HORIZONTAL
Constant to be used with the setLineOrientation method of SophisticatedTextLayoutManager. It indicates that the line orientation is horizontal.

See Also:
Constant Field Values

LINE_ORIENTATION_VERTICAL

public static final int LINE_ORIENTATION_VERTICAL
Constant to be used with the setLineOrientation method of SophisticatedTextLayoutManager. It indicates that the line orientation is vertical.

See Also:
Constant Field Values

START_UPPER_LEFT

public static final int START_UPPER_LEFT
Constant to be used with the setStartCorner method of SophisticatedTextLayoutManager. It indicates that the text starts in the upper left corner.

See Also:
Constant Field Values

START_UPPER_RIGHT

public static final int START_UPPER_RIGHT
Constant to be used with the setStartCorner method of SophisticatedTextLayoutManager. It indicates that the text starts in the upper right corner.

See Also:
Constant Field Values

START_LOWER_LEFT

public static final int START_LOWER_LEFT
Constant to be used with the setStartCorner method of SophisticatedTextLayoutManager. It indicates that the text starts in the lower left corner.

See Also:
Constant Field Values

START_LOWER_RIGHT

public static final int START_LOWER_RIGHT
Constant to be used with the setStartCorner method of SophisticatedTextLayoutManager. It indicates that the text starts in the lower right corner.

See Also:
Constant Field Values

DEFAULT_LINE_SPACE

public static final int DEFAULT_LINE_SPACE
Constant to be used with the setLineSpace method of SophisticatedTextLayoutManager. It indicates that the line space should be set to the default value, determined by the default font.

See Also:
Constant Field Values
Constructor Detail

SophisticatedTextLayoutManager

public SophisticatedTextLayoutManager()
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 TextLayoutManagerClass 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
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.
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.

setHorizontalAlignment

public void setHorizontalAlignment(int alignment)
Determine the horizontal alignment.

Parameters:
alignment - the value for the horizontal alignment. Possible values are: HORIZONTAL_ALIGN_LEFT, HORIZONTAL_ALIGN_RIGHT, HORIZONTAL_ALIGN_CENTER and HORIZONTAL_ALIGN_JUSTIFIED.
See Also:
getHorizontalAlignment()

setVerticalAlignment

public void setVerticalAlignment(int alignment)
Determine the vertical alignment.

Parameters:
alignment - the value for the vertical alignment. Possible values are: VERTICAL_ALIGN_TOP, VERTICAL_ALIGN_BOTTOM, VERTICAL_ALIGN_CENTER and VERTICAL_ALIGN_JUSTIFIED.
See Also:
getVerticalAlignment()

setLineOrientation

public void setLineOrientation(int orientation)
Determine the line orientation.

Parameters:
orientation - the value for the line orientation. Possible values are: LINE_ORIENTATION_HORIZONTAL and LINE_ORIENTATION_VERTICAL.

setStartCorner

public void setStartCorner(int corner)
Determine the starting corner for text writing.

Parameters:
corner - the value for the starting corner. Possible values are: START_UPPER_LEFT, START_UPPER_RIGHT, START_LOWER_LEFT and START_LOWER_RIGHT.

setTextWrapping

public void setTextWrapping(boolean wrap)
Determines whether text is wrapped.

Parameters:
wrap - true if text should be wrapped, false otherwise

setLineSpace

public void setLineSpace(int spacing)
Determines space between lines.

Parameters:
spacing - value for line spacing; an integer or DEFAULT_LINE_SPACE

setLetterSpace

public void setLetterSpace(int spacing)
Determines the space between letters.

Parameters:
spacing - letter space setting in units of 1/256th point

setHorizontalTabSpacing

public void setHorizontalTabSpacing(int spacing)
Determines the horizontal tabulation spacing.

Parameters:
spacing - horizontal tabulator spacing in points

getHorizontalAlignment

public int getHorizontalAlignment()
Retrieve horizontal alignment.

Returns:
horizontal alignment
See Also:
setHorizontalAlignment(int)

getVerticalAlignment

public int getVerticalAlignment()
Retrieve vertical alignment.

Returns:
vertical alignment
See Also:
setVerticalAlignment(int)

retrieveLineOrientation

public int retrieveLineOrientation()
Retrieve line orientation.

Returns:
line orientation

retrieveStartCorner

public int retrieveStartCorner()
Retrieve starting corner.

Returns:
starting corner

retrieveTextWrapping

public boolean retrieveTextWrapping()
Retrieve text wrapping.

Returns:
text wrapping

retrieveLineSpace

public int retrieveLineSpace()
Retrieve line spacing.

Returns:
line spacing: a number or DEFAULT_LINE_SPACE, if the default line spacing is determined

retrieveLetterSpace

public int retrieveLetterSpace()
Retrieve letter space .

Returns:
letter spacing in 1/256th points

retrieveHorizontalTabSpacing

public int retrieveHorizontalTabSpacing()
Retrieve horizontal tabulator spacing.

Returns:
horizontal tabulator spacing

setInsets

public void setInsets(Insets insets)
Determines the insets to be used by the SophisticatedTextLayoutManager to provide a virtual margin. The insets determined by this method have to be added to the insets passed to the render method. If this method has not been called, the default insets are 0 at each edge.

Parameters:
insets - the determined insets
See Also:
getInsets()

getInsets

public Insets getInsets()
Returns the insets as set by the setInsets method. When not previously set, zero insets are returned.

Returns:
insets as set by the setInsets method
See Also:
setInsets(java.awt.Insets)

addTextOverflowListener

public void addTextOverflowListener(TextOverflowListener listener)
Register a TextOverflowListener. This listener will be notified if a text string won't fit into the component during an attempt to render it.

Parameters:
listener - the listener to be registered
See Also:
removeTextOverflowListener(com.sun.dtv.ui.TextOverflowListener)

removeTextOverflowListener

public void removeTextOverflowListener(TextOverflowListener listener)
Removes a previously registered TextOverflowListener from this TextLayoutManager.

Parameters:
listener - the listener to be removed
See Also:
addTextOverflowListener(com.sun.dtv.ui.TextOverflowListener)

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.