com.tensegrity.composite
Interface CompositeLabel

All Superinterfaces:
Attributable, AttributableOnSet, BaseComposite, BaseInteractable, Composite, Interactable

public interface CompositeLabel
extends Composite

A CompositeLabel is a multi-line area that displays text.

The CompositeLabel supports different vertical alignment modes. The follwing table gives an overview of this modes:

mode (constant)description
GraphicConstants.ALIGN_TOP The text starts at the top side of the CompositeLabels bounding box.
GraphicConstants.ALIGN_CENTER The text is vertically centered whithin the CompositeLabels bounding box.
GraphicConstants.ALIGN_BOTTOM The text ends at the bottom side of the CompositeLabels bounding box.

The CompositeLabel supports different horizontal alignment modes. The follwing table gives an overview of this modes:

mode (constant)description
GraphicConstants.ALIGN_LEFT The text starts at the left side of the CompositeLabels bounding box.
GraphicConstants.ALIGN_CENTER The text is horizontally centered whithin the CompositeLabels bounding box.
GraphicConstants.ALIGN_RIGHT The text ends at the right side of the CompositeLabels bounding box.

The size of the CompositeLabels bounding box can be adjusted automatically so that it fits to the extensions of the text displayed by the CompositeLabel. The table below gives an overview of the different modes that are supported for the bounding box adjustment.

mode (constant)description
GraphicConstants.SIZE_ADJUSTMENT_NONE The bounding box of the CompositeLabel is not adjusted. In this mode the user can change the extensions of the CompositeLabels bounding box interactively in any direction.
GraphicConstants.SIZE_ADJUSTMENT_LINE_COUNT The bounding box of the CompositeLabel is adjusted to the count of lines. In this mode the user can change the extensions of the CompositeLabels bounding box interactively only in the horizontal direction.
GraphicConstants.SIZE_ADJUSTMENT_LINE_LENGTH The bounding box of the CompositeLabel is adjusted to the length of the longest line of the displayed text. In this mode the user can change the extensions of the CompositeLabels bounding box interactively only in the vertical direction.
GraphicConstants.SIZE_ADJUSTMENT_LINE_COUNTANDLENGTH The bounding box of the CompositeLabel is adjusted to the count of lines and also to the length of the longest line of the displayed text. In this mode the user can't change the extensions of the CompositeLabels bounding box.

NOTICE:The correct size can only be calculated when the CompositeLabel is added directly to a CompositeView or a CompositeGroup that is added to a CompositeView.
This belongs to the fact that the correct transformation has to be build in order to calculate the correct size.

Version:
$Id: CompositeLabel.java,v 1.19 2005/04/01 15:45:16 MichaelKegel Exp $
Author:
MichaelKegel

Field Summary
 
Fields inherited from interface com.tensegrity.composite.Composite
BBOXMASK_INCLUDE_ALL, BBOXMASK_INCLUDE_EXTERNALS_ALL, BBOXMASK_INCLUDE_EXTERNALS_BACK, BBOXMASK_INCLUDE_EXTERNALS_BOTTOM, BBOXMASK_INCLUDE_EXTERNALS_FRONT, BBOXMASK_INCLUDE_EXTERNALS_LEFT, BBOXMASK_INCLUDE_EXTERNALS_RIGHT, BBOXMASK_INCLUDE_EXTERNALS_TOP, BBOXMASK_INCLUDE_MARKER, BBOXMASK_INCLUDE_SHADOW, BBOXMASK_INCLUDE_STROKE, BBOXMASK_INCLUDE_TEXT_OUTSIDE_OF_LABELS, EVENT_MASK_CHANGE, EVENT_MASK_MOVE, EVENT_MASK_RESIZE, TRANSFORMFROM_COMPOSITE, TRANSFORMTO_COMPOSITE
 
Fields inherited from interface com.tensegrity.composite.BaseComposite
DELEGATE_INFOVALUE, EVENT_MASK_MOUSE, EVENT_MASK_SELECT, GENERAL_INFOVALUE, NON_INFOVALUE
 
Fields inherited from interface com.tensegrity.generic.attribute.AttributableOnSet
TREE_SUBSET_POSTFIX
 
Method Summary
 void adjustSize()
          Adjusts the size of the CompositeLabel according to the mode that is currently set.
 void adjustSize(Transform2D xform_context, ScaleValues scalevalues)
          Adjusts the size of the CompositeLabel according to the size adjustment mode that is currently set and the given transformation and zoom values.
 void enableClipping(boolean enable)
          Enables or disables the clipping.
 void enableFirstWordCharacterWrap(boolean enable)
          Enables or disables the first word character wrap.
 void enableLineShortening(boolean enable)
          Enables or disables the line shortening.
 void enableWordWrap(boolean enable)
          Enables or disables the word wrap.
 FontFormat getFont()
          Returns the FontFormat that is used by the CompositeLabel to draw text.
 int getHorizontalAlignment()
          Returns the horizontal alignment mode currently set to the CompositeLabel.
 int getMarginBottom()
          Returns the value for the margin from the bottom side.
 int getMarginLeft()
          Returns the value for the margin from the left side.
 int getMarginRight()
          Returns the value for the margin from the right side.
 int getMarginTop()
          Returns the value for the margin from the top side.
 PaintFormat getPaint()
          Returns the PaintFormat that is used by the CompositeLabel to fill the background.
 int getSizeAdjustmentMode()
          Returns the size adjustment mode currently set to the CompositeLabel.
 StrokeFormat getStroke()
          Returns the StrokeFormat that is used by the Primitive to draw a borders around the background.
 java.lang.String getText()
          Returns the current text that is currently displayed by the CompositeLabel.
 TextFormatter getTextFormatter()
          Returns the TextFormatter instance that is used by the CompositeLabel.
 int getVerticalAlignment()
          Returns the vertical alignment mode currently set to the CompositeLabel.
 boolean isClippingEnabled()
          Returns a boolean that indicates whether the clipping is enabled or not.
 boolean isFirstWordCharacterWrapEnabled()
          Returns a boolean that indicates whether first word character wrap is enabled or not.
 boolean isLineShorteningEnabled()
          Returns a boolean that indicates whether line shortening is enabled or not.
 boolean isWordWrapEnabled()
          Returns a boolean that indicates whether word wrap is enabled or not.
 void setFont(FontFormat font)
          Sets the FontFormat for the CompositeLabel.
 void setHorizontalAlignment(int hAlignment)
          Sets the horizontal alignment mode to the value given by hAlignment.
 void setMarginBottom(int marginBottom)
          Sets the value for the margin from the bottom side to the value given by marginBottom.
 void setMarginLeft(int marginLeft)
          Sets the value for the margin from the left side to the value given by marginLeft.
 void setMarginRight(int marginRight)
          Sets the value for the margin from the right side to the value given by marginRight.
 void setMargins(int marginLeft, int marginTop, int marginRight, int marginBottom)
          Sets the margins for the CompositeLabel to the values given by marginLeft, marginTop, marginRight and marginBottom.
 void setMarginTop(int marginTop)
          Sets the value for the margin from the top side to the value given by marginTop.
 void setPaint(PaintFormat paint)
          Sets the PaintFormat for the CompositeLabel.
 void setSizeAdjustmentMode(int sizeAdjustmentMode)
          Sets the size adjustment mode to the value given by sizeAdjustmentMode.
 void setStroke(StrokeFormat stroke)
          Sets the StrokeFormat for the CompositeLabel.
 void setText(java.lang.String text)
          Sets the text that is displayed by the CompositeLabel to the String given by text.
 void setVerticalAlignment(int vAlignment)
          Sets the vertical alignment mode to the value given by vAlignment.
 
Methods inherited from interface com.tensegrity.composite.Composite
addCompositeListener, addToLocation, addVetoableCompositeListener, applyState, centerAtLocation, deepCopy, getBackgroundCursorID, getBoundingBox, getCoordinateSystem, getCoordinateSytemTransform, getLocation, getMinimumSize, getSize, getState, getTransform, internalGetHasSideHandles, internalGetKeepAspectRatioAtCornerHandles, internalSetHasSideHandles, internalSetKeepAspectRatioAtCornerHandles, layout, removeCompositeListener, removeVetoableCompositeListener, setBackgroundCursorID, setBoundingBox, setCoordinateSystem, setLocation, setMinimumSize, setSize, setTransform
 
Methods inherited from interface com.tensegrity.composite.BaseComposite
addPrimitive, adjustGeometry, adjustGeometry, applyGeometry, applyStyle, areEventsEnabled, disableEvents, draw, draw, drawComposite, enableEvents, getBaseCompositeContainer, getEventMask, getGeometryName, getInfoValue, getInfoValueIdentifier, getName, getPrimitiveIterator, getShadowColor, getShadowDirection, getStyleName, internalSetGeometryName, internalSetStyleName, isDeletable, isShadowVisible, registerAttributeConstraint, registerEventMediator, registerVetoableEventMediator, removeAllPrimitives, removePrimitive, setBaseCompositeContainer, setDeletable, setEventMask, setInfoValue, setInfoValue, setName, setShadowColor, setShadowDirection, setShadowVisible, unregisterAttributeConstraint
 
Methods inherited from interface com.tensegrity.generic.attribute.AttributableOnSet
addAttributableOnSetListener, areAttributableEventsEnabled, disableAttributableEvents, enableAttributableEvents, getAttributes, getAttributesTree, removeAttributableOnSetListener, setAttributes, setAttributesTree
 
Methods inherited from interface com.tensegrity.generic.attribute.Attributable
getAttribute, getAttributeType, getAttributeValue, setAttribute, setAttributeValue
 
Methods inherited from interface com.tensegrity.graphics.interaction.BaseInteractable
getBoundingBox, getInteractionDescriptor, getMoveItem, hits, internalEnableSelection, internalSelect, internalSetSelected, isMovable, isSelectable, isSelected, mouseClick, mouseDown, mouseEnter, mouseExit, mouseUp, postActing, preActing, select, setMovable, setSelectable, setSelected, startAction, stopAction
 
Methods inherited from interface com.tensegrity.graphics.interaction.Interactable
calculateBoundingBox, isResizable, setResizable
 

Method Detail

getText

public java.lang.String getText()
Returns the current text that is currently displayed by the CompositeLabel.

Returns:
String the current text of the CompositeLabel

setText

public void setText(java.lang.String text)
Sets the text that is displayed by the CompositeLabel to the String given by text.

Parameters:
text - the new text to display

getVerticalAlignment

public int getVerticalAlignment()
Returns the vertical alignment mode currently set to the CompositeLabel.

Returns:
int the current vertical alignment mode

setVerticalAlignment

public void setVerticalAlignment(int vAlignment)
Sets the vertical alignment mode to the value given by vAlignment. Valid values are defined through constants in GraphicConstants.
Please see the class documentation of CompositeLabel to get an overview of the possible values and their meaning.

Parameters:
vAlignment - the new vertical alignment mode to use

getHorizontalAlignment

public int getHorizontalAlignment()
Returns the horizontal alignment mode currently set to the CompositeLabel.

Returns:
int the current horizontal alignment mode

setHorizontalAlignment

public void setHorizontalAlignment(int hAlignment)
Sets the horizontal alignment mode to the value given by hAlignment. Valid values are defined through constants in GraphicConstants.
Please see the class documentation of CompositeLabel to get an overview of the possible values and their meaning.

Parameters:
hAlignment - the new horizontal alignment mode to use

getMarginLeft

public int getMarginLeft()
Returns the value for the margin from the left side.

Returns:
int margin from the left side

setMarginLeft

public void setMarginLeft(int marginLeft)
Sets the value for the margin from the left side to the value given by marginLeft.
The margin should be given in units of the inner coordinate system of the CompositeLabel.

Parameters:
marginLeft - the value for the margin from the left side

getMarginTop

public int getMarginTop()
Returns the value for the margin from the top side.

Returns:
int margin from the top side

setMarginTop

public void setMarginTop(int marginTop)
Sets the value for the margin from the top side to the value given by marginTop.
The margin should be given in units of the inner coordinate system of the CompositeLabel.

Parameters:
marginTop - the value for the margin from the top side

getMarginRight

public int getMarginRight()
Returns the value for the margin from the right side.

Returns:
int margin from the right side

setMarginRight

public void setMarginRight(int marginRight)
Sets the value for the margin from the right side to the value given by marginRight.
The margin should be given in units of the inner coordinate system of the CompositeLabel.

Parameters:
marginRight - the value for the margin from the right side

getMarginBottom

public int getMarginBottom()
Returns the value for the margin from the bottom side.

Returns:
int margin from the bottom side

setMarginBottom

public void setMarginBottom(int marginBottom)
Sets the value for the margin from the bottom side to the value given by marginBottom.
The margin should be given in units of the inner coordinate system of the CompositeLabel.

Parameters:
marginBottom - the value for the margin from the bottom side

setMargins

public void setMargins(int marginLeft,
                       int marginTop,
                       int marginRight,
                       int marginBottom)
Sets the margins for the CompositeLabel to the values given by marginLeft, marginTop, marginRight and marginBottom.
The margins should be given in units of the inner coordinate system of the CompositeLabel.

Parameters:
marginLeft - the value for the margin from the left side
marginTop - the value for the margin from the top side
marginRight - the value for the margin from the right side
marginBottom - the value for the margin from the bottom side

getStroke

public StrokeFormat getStroke()
Returns the StrokeFormat that is used by the Primitive to draw a borders around the background.

Returns:
StrokeFormat the StrokeFormat used by the CompositeLabel

setStroke

public void setStroke(StrokeFormat stroke)
Sets the StrokeFormat for the CompositeLabel.

Parameters:
stroke - the new StrokeFormat to use

getPaint

public PaintFormat getPaint()
Returns the PaintFormat that is used by the CompositeLabel to fill the background.

Returns:
PaintFormat the PaintFormat used by the CompositeLabel

setPaint

public void setPaint(PaintFormat paint)
Sets the PaintFormat for the CompositeLabel.

Parameters:
paint - the new PaintFormat to use

getFont

public FontFormat getFont()
Returns the FontFormat that is used by the CompositeLabel to draw text.

Returns:
FontFormat the FontFormat used by the CompositeLabel

setFont

public void setFont(FontFormat font)
Sets the FontFormat for the CompositeLabel.

Parameters:
font - the new FontFormat to use

isClippingEnabled

public boolean isClippingEnabled()
Returns a boolean that indicates whether the clipping is enabled or not.

Returns:
boolean flag that indicates that the clipping is enabled

enableClipping

public void enableClipping(boolean enable)
Enables or disables the clipping. Clipping means that characters that will extend the bounding box of the CompositeLabel will be clipped away.

Parameters:
enable - flag that indicates whether to enable or disable the clipping

isLineShorteningEnabled

public boolean isLineShorteningEnabled()
Returns a boolean that indicates whether line shortening is enabled or not.

Returns:
boolean flag that indicates that the line shortening is enabled

enableLineShortening

public void enableLineShortening(boolean enable)
Enables or disables the line shortening. Line shortening means that characters that will extend the bounding box of the CompositeLabel will be truncated and replaced by three dots.

Parameters:
enable - flag that indicates whether to enable or disable the line shortening

isWordWrapEnabled

public boolean isWordWrapEnabled()
Returns a boolean that indicates whether word wrap is enabled or not.

Returns:
boolean flag that indicates that the word wrap is enabled

enableWordWrap

public void enableWordWrap(boolean enable)
Enables or disables the word wrap. Word wrap means that words will be wrapped into the next row if the bounding box of the CompositeLabel is to small to display them in the current row.

Parameters:
enable - flag that indicates whether to enable or disable the word wrap

isFirstWordCharacterWrapEnabled

public boolean isFirstWordCharacterWrapEnabled()
Returns a boolean that indicates whether first word character wrap is enabled or not.

Returns:
boolean flag that indicates that the first word character wrap is enabled

enableFirstWordCharacterWrap

public void enableFirstWordCharacterWrap(boolean enable)
Enables or disables the first word character wrap. First word character wrap means that the characters of the first word of a row will be wrapped into the next row if the bounding box of the CompositeLabel is to small to display them all in one row.

Parameters:
enable - flag that indicates whether to enable or disable the first word character wrap

getSizeAdjustmentMode

public int getSizeAdjustmentMode()
Returns the size adjustment mode currently set to the CompositeLabel.

Returns:
int the current size adjustment mode

setSizeAdjustmentMode

public void setSizeAdjustmentMode(int sizeAdjustmentMode)
Sets the size adjustment mode to the value given by sizeAdjustmentMode. Valid values are defined through constants in GraphicConstants.
Please see the class documentation of CompositeLabel to get an overview of the possible values and their meaning.

Parameters:
sizeAdjustmentMode - the new size adjustment mode to use

adjustSize

public void adjustSize()
Adjusts the size of the CompositeLabel according to the mode that is currently set.

NOTICE:
The correct size can only be calculated when the CompositeLabel is added directly to a CompositeView or a CompositeGroup that is added to a CompositeView.
This belongs to the fact that the correct transformation has to be build in order to calculate the correct size.


adjustSize

public void adjustSize(Transform2D xform_context,
                       ScaleValues scalevalues)
Adjusts the size of the CompositeLabel according to the size adjustment mode that is currently set and the given transformation and zoom values.

Parameters:
xform_context - the Transform2D to be used
scalevalues - the scale values for the different directions the CompositeView has been set to

getTextFormatter

public TextFormatter getTextFormatter()
Returns the TextFormatter instance that is used by the CompositeLabel.
NOTICE:This method is for internal use only and may be removed in one of the next verions of the Composite Framework.

Returns:
TextFormatter the TextFormatter instance used by the CompositeLabel


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.