com.yworks.yfiles.server.graphml.flexio.data.flexmarkup
Class TLFLabelStyle

java.lang.Object
  extended bycom.yworks.yfiles.server.graphml.flexio.data.flexmarkup.TLFLabelStyle
All Implemented Interfaces:
ILabelStyle, ISharedInstanceProvider, LabelSizeCalculator

public class TLFLabelStyle
extends java.lang.Object
implements ILabelStyle, LabelSizeCalculator, ISharedInstanceProvider

A data object for the client side com.yworks.graph.drawing.TLFLabelStyle.

This style uses the Flex Text Layout Framework to render the label text.

At client side, this style is only available in the Flex 4 version of yFiles FLEX.


Field Summary
static java.lang.String PLAIN_TEXT_FORMAT
          Constant for the textConverter property which lets the text be rendered as plain text.
static java.lang.String TEXT_FIELD_HTML_FORMAT
          Constant for the textConverter property which lets the text be rendered as HTML text.
static java.lang.String TEXT_LAYOUT_FORMAT
          Constant for the textConverter property which lets the text be rendered using the Flex Text Layout markup.
 
Constructor Summary
TLFLabelStyle()
          Creates a new instance.
TLFLabelStyle(IStroke backgroundStroke, IFill backgroundFill)
          Creates an instance with the given background stroke and fill.
TLFLabelStyle(TextLayoutFormat textFormat, IStroke backgroundStroke, IFill backgroundFill)
          Creates an instance with the given format, background stroke and fill.
TLFLabelStyle(TextLayoutFormat textFormat, java.lang.String textConverter, IStroke backgroundStroke, IFill backgroundFill)
          Creates an instance with the given format, text converter, and background stroke and fill.
TLFLabelStyle(TextLayoutFormat textFormat, java.lang.String textConverter, IStroke backgroundStroke, IFill backgroundFill, boolean clipText)
          Creates an instance with the given format, text converter, and background stroke and fill.
 
Method Summary
 boolean canCalculateSize(Label l)
          Whether the size of the label can be calculated.
 IFill getBackgroundFill()
          The background fill of the label.
 IStroke getBackgroundStroke()
          The border stroke of the label.
 YDimension getCalculatedSize(Label l)
          Calculates the size of a given label.
 java.util.Collection getSharedInstances()
          Returns an Collection for objects that shall be shared.
 java.lang.String getTextConverter()
          A String which defines how the label text will be interpreted.
 TextLayoutFormat getTextFormat()
          The text layout format for the label.
 boolean isClipText()
          Whether to clip the text at the label's bounds.
 void setBackgroundFill(IFill backgroundFill)
          Sets the background fill of the label.
 void setBackgroundStroke(IStroke backgroundStroke)
          Sets the border stroke of the label.
 void setClipText(boolean clipText)
          Whether to clip the text at the label's bounds.
 void setTextConverter(java.lang.String textConverter)
          Sets a String which defines how the label text will be interpreted.
 void setTextFormat(TextLayoutFormat textFormat)
          Sets the text layout format for the label.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEXT_FIELD_HTML_FORMAT

public static final java.lang.String TEXT_FIELD_HTML_FORMAT
Constant for the textConverter property which lets the text be rendered as HTML text.

See Also:
Constant Field Values

PLAIN_TEXT_FORMAT

public static final java.lang.String PLAIN_TEXT_FORMAT
Constant for the textConverter property which lets the text be rendered as plain text.

See Also:
Constant Field Values

TEXT_LAYOUT_FORMAT

public static final java.lang.String TEXT_LAYOUT_FORMAT
Constant for the textConverter property which lets the text be rendered using the Flex Text Layout markup.

See Also:
Constant Field Values
Constructor Detail

TLFLabelStyle

public TLFLabelStyle()
Creates a new instance.


TLFLabelStyle

public TLFLabelStyle(TextLayoutFormat textFormat,
                     java.lang.String textConverter,
                     IStroke backgroundStroke,
                     IFill backgroundFill,
                     boolean clipText)
Creates an instance with the given format, text converter, and background stroke and fill.

Parameters:
textFormat - The TextLayoutFormat to use for the label.
textConverter - Defines how to interpret the label text. One of PLAIN_TEXT_FORMAT, TEXT_FIELD_HTML_FORMAT, or TEXT_LAYOUT_FORMAT.
backgroundStroke - The border stroke for the label. May be null to render no border.
backgroundFill - The background fill for the label. May be null for a transparent background.
clipText - Whether to clip the text at the label's bounds.

TLFLabelStyle

public TLFLabelStyle(TextLayoutFormat textFormat,
                     java.lang.String textConverter,
                     IStroke backgroundStroke,
                     IFill backgroundFill)
Creates an instance with the given format, text converter, and background stroke and fill.

The label text will be clipped at the label bounds.

Parameters:
textFormat - The TextLayoutFormat to use for the label.
textConverter - Defines how to interpret the label text. One of PLAIN_TEXT_FORMAT, TEXT_FIELD_HTML_FORMAT, or TEXT_LAYOUT_FORMAT.
backgroundStroke - The border stroke for the label. May be null to render no border.
backgroundFill - The background fill for the label. May be null for a transparent background.

TLFLabelStyle

public TLFLabelStyle(TextLayoutFormat textFormat,
                     IStroke backgroundStroke,
                     IFill backgroundFill)
Creates an instance with the given format, background stroke and fill.

The label text will be interpreted as plain text and be clipped at the label bounds.

Parameters:
textFormat - The TextLayoutFormat to use for the label.
backgroundStroke - The border stroke for the label. May be null to render no border.
backgroundFill - The background fill for the label. May be null for a transparent background.

TLFLabelStyle

public TLFLabelStyle(IStroke backgroundStroke,
                     IFill backgroundFill)
Creates an instance with the given background stroke and fill.

The label text will be interpreted as plain text and be clipped at the label bounds.

Parameters:
backgroundStroke - The border stroke for the label. May be null to render no border.
backgroundFill - The background fill for the label. May be null for a transparent background.
Method Detail

getBackgroundStroke

public IStroke getBackgroundStroke()
The border stroke of the label.

If set to null no border will be rendered.

Default is null

Returns:
The border stroke. May be null.

setBackgroundStroke

public void setBackgroundStroke(IStroke backgroundStroke)
Sets the border stroke of the label.

If set to null no border will be rendered.

Default is null

Parameters:
backgroundStroke - The border stroke. May be null.

getBackgroundFill

public IFill getBackgroundFill()
The background fill of the label.

If set to null the background will be transparent.

Default is null

Returns:
The background fill. May be null.

setBackgroundFill

public void setBackgroundFill(IFill backgroundFill)
Sets the background fill of the label.

If set to null the background will be transparent.

Default is null

Parameters:
backgroundFill - The background fill. May be null.

isClipText

public boolean isClipText()
Whether to clip the text at the label's bounds.

Default is true.

Returns:
true if the text should be clipped at the label's bounds.

setClipText

public void setClipText(boolean clipText)
Whether to clip the text at the label's bounds.

Default is true.

Returns:
true if the text should be clipped at the label's bounds.

getTextFormat

public TextLayoutFormat getTextFormat()
The text layout format for the label.

Default is a plain instance of TextLayoutFormat.

Returns:
The text layout format object for the label.

setTextFormat

public void setTextFormat(TextLayoutFormat textFormat)
Sets the text layout format for the label.

Default is a plain instance of TextLayoutFormat.

Parameters:
textFormat - The text layout format object for the label. May not be null.
Throws:
java.lang.IllegalArgumentException - If null is set as value.

getTextConverter

public java.lang.String getTextConverter()
A String which defines how the label text will be interpreted.

Default is PLAIN_TEXT_FORMAT which means the text will be interpreted as plain string.

Returns:
A String which defines how the label text will be interpreted.

setTextConverter

public void setTextConverter(java.lang.String textConverter)
Sets a String which defines how the label text will be interpreted.

Setting this property to any other value than one of PLAIN_TEXT_FORMAT, TEXT_FIELD_HTML_FORMAT, or TEXT_LAYOUT_FORMAT may break the rendering at the client.

Default is PLAIN_TEXT_FORMAT which means the text will be interpreted as plain string.

Parameters:
textConverter - A String which defines how the label text will be interpreted.

getCalculatedSize

public YDimension getCalculatedSize(Label l)
                             throws java.lang.IllegalArgumentException
Calculates the size of a given label.

Before calling this method, canCalculateSize(Label) should be queried if all prerequisites are met to calculate the size.

Note that the size can only be calculated for plain text.

Specified by:
getCalculatedSize in interface LabelSizeCalculator
Parameters:
l - The label to calculate the size for.
Returns:
The calculated size of the label.
Throws:
java.lang.IllegalArgumentException - If the size of the label cannot be calculated.

canCalculateSize

public boolean canCalculateSize(Label l)
Whether the size of the label can be calculated.

The size can only be calculated if the text converter is set for plain text.

Specified by:
canCalculateSize in interface LabelSizeCalculator
Parameters:
l - The label to calculate the size for.
Returns:
true if the size of the label can be calculated.

getSharedInstances

public java.util.Collection getSharedInstances()
Description copied from interface: ISharedInstanceProvider
Returns an Collection for objects that shall be shared.

Specified by:
getSharedInstances in interface ISharedInstanceProvider
Returns:


Copyright © 2000-2013 yWorks GmbH. All rights reserved