com.miginfocom.ashape.shapes
Class FittingTextAShape

java.lang.Object
  extended by com.miginfocom.ashape.shapes.AbstractAShape
      extended by com.miginfocom.ashape.shapes.TextAShape
          extended by com.miginfocom.ashape.shapes.FittingTextAShape
All Implemented Interfaces:
AShape, PropertyProvider, StringProvider

public class FittingTextAShape
extends TextAShape

A text shape much like TextAShape but with the ability to have more that one text template and paint the first one that fits the bounds. Can not be used with multi line texts though since they have a more uncertain definition on whether a text fits or not.
The following attibutes is currently used by this shape:
A_TEXT_ALTERNATIVES
Note that any attributes used by TextAShape will also be adhered to.


Field Summary
static PropertyKey A_TEXT_ALTERNATIVES
          Value type: String[], not null.
 
Fields inherited from class com.miginfocom.ashape.shapes.TextAShape
A_TEXT_LAYOUT_PADDING, A_TEXT_LINE_SPACE_CORRECTION, A_TEXT_NO_OPTIMIZE_CLIP, A_TEXT_SHADOW_COLOR, A_TEXT_SHADOW_OFFSET, A_TEXT_TYPE, TEMPLATE_CHAR, TYPE_SINGE_LINE, TYPE_SINGE_LINE_ROT_CCW, TYPE_SINGE_LINE_ROT_CW, TYPE_SINGLE_LINE, TYPE_SINGLE_LINE_ROT_CCW, TYPE_SINGLE_LINE_ROT_CW, TYPE_WRAP_TEXT
 
Fields inherited from class com.miginfocom.ashape.shapes.AbstractAShape
hitShape, RETURN_LIVE_ATTR_MAP, SIZE_CONV_MAP
 
Fields inherited from interface com.miginfocom.ashape.shapes.AShape
A_ALIGN_X, A_ALIGN_Y, A_ANTI_ALIAS, A_BORDER, A_CLIP_TYPE, A_COMPOSITE, A_CROP, A_CROP_TO_VISIBILITY_BOUNDS, A_FONT, A_HIT_AREA_Z, A_ICON, A_IMAGE, A_INHERIT, A_LAYOUT, A_MAXIMUM_HEIGHT, A_MAXIMUM_WIDTH, A_MINIMUM_HEIGHT, A_MINIMUM_WIDTH, A_MOUSE_CURSOR, A_PAINT, A_PAINT_LAYER, A_PLACE_RECT, A_PREFERRED_HEIGHT, A_PREFERRED_WIDTH, A_REPORT_HIT_AREA, A_SHADOW_TARGET_PAINT, A_SHAPE, A_SHAPES, A_STROKE, A_SUB_SHAPE_SORTER, A_TEXT, A_TEXTURE_PAINT_ANCHOR, A_UNDERLINE_HEIGHT, A_VISIBILITY, A_WRAPPED_ASHAPE, CLIP_PARENT_BOUNDS, CLIP_PARENT_SHAPE
 
Constructor Summary
FittingTextAShape()
          Empty constructor for XML builders.
FittingTextAShape(java.lang.String name, java.lang.String[] templateTexts, PlaceRect placeRect, int type, java.awt.Font font, java.awt.Paint paint)
          Deprecated. Use the version that takes an Object anti alias hint instead.
FittingTextAShape(java.lang.String name, java.lang.String[] templateTexts, PlaceRect placeRect, int type, java.awt.Font font, java.awt.Paint paint, AtRefRangeNumber alignX, AtRefRangeNumber alignY, java.lang.Boolean antiAlias)
          Deprecated. Use the version that takes an int anti alias hint instead.
FittingTextAShape(java.lang.String name, java.lang.String[] templateTexts, PlaceRect placeRect, int type, java.awt.Font font, java.awt.Paint paint, AtRefRangeNumber alignX, AtRefRangeNumber alignY, java.lang.Boolean antiAlias, java.awt.Point shdOff, java.awt.Color shdColor)
          Deprecated. Use the version that takes an int anti alias hint instead.
FittingTextAShape(java.lang.String name, java.lang.String[] templateTexts, PlaceRect placeRect, int type, java.awt.Font font, java.awt.Paint paint, AtRefRangeNumber alignX, AtRefRangeNumber alignY, int antiAliasHint)
          Contructor.
FittingTextAShape(java.lang.String name, java.lang.String[] templateTexts, PlaceRect placeRect, int type, java.awt.Font font, java.awt.Paint paint, AtRefRangeNumber alignX, AtRefRangeNumber alignY, int antiAliasHint, java.awt.Point shdOff, java.awt.Color shdColor)
          Contructor
 
Method Summary
 java.lang.String getString(int ix)
          Returns the string for the index.
 int getStringCount()
          Returns the number of strings this provider can provide.
 
Methods inherited from class com.miginfocom.ashape.shapes.TextAShape
expand, getHitBounds, getLayoutSize, getNaturalSize, paintShape, setUseClipOptimize
 
Methods inherited from class com.miginfocom.ashape.shapes.AbstractAShape
addAttributes, addSubShape, addSubShape, addToHitShapeList, containsProperty, getAttribute, getAttributes, getClipShape, getDoubleAttribute, getFloatAttribute, getHitShape, getIntAttribute, getLayout, getLongAttribute, getModCount, getName, getPaintLayer, getParent, getProperty, getReferenceBounds, getRoot, getShapeBounds, getSubShapeDeep, getSubShapes, getSubShapesImpl, hasAttribute, increaseModCount, isRoot, isVisible, layout, paintBorder, paintSubTree, removeAttribute, removeSubShape, setAttribute, setAttributeDeep, setAttributes, setHitShape, setName, setParent, setReferenceBounds, setReferenceBounds, setSubShapes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

A_TEXT_ALTERNATIVES

public static final PropertyKey A_TEXT_ALTERNATIVES
Value type: String[], not null. The texts in the array will on by one be expanded (with TextAShape.expand(String)) and drawn if they fit. Only the first that fits will be drawn. The last text will always be drawn, even if it doesn't fit. Set last to "" to have the text shape draw nothing if none fits.

Constructor Detail

FittingTextAShape

public FittingTextAShape()
Empty constructor for XML builders.


FittingTextAShape

public FittingTextAShape(java.lang.String name,
                         java.lang.String[] templateTexts,
                         PlaceRect placeRect,
                         int type,
                         java.awt.Font font,
                         java.awt.Paint paint)
Deprecated. Use the version that takes an Object anti alias hint instead.

Contructor for center/center alignmenment and wonät change anti aliasing from parent shape.

Parameters:
name - The name used for referencing this shape/sub shape
templateTexts - The strings of which the first one that fits will actually be the one drawn.
placeRect - How the shape will fill the bounds (or the parent's bounds)
type - If the text should word/line wrap at end of rectangle. E.g. TextAShape.TYPE_WRAP_TEXT
font - The font to use. Not null.
paint - The paint to use.
See Also:
AtRefRangeNumber, AtStart, AtEnd, AtFraction

FittingTextAShape

public FittingTextAShape(java.lang.String name,
                         java.lang.String[] templateTexts,
                         PlaceRect placeRect,
                         int type,
                         java.awt.Font font,
                         java.awt.Paint paint,
                         AtRefRangeNumber alignX,
                         AtRefRangeNumber alignY,
                         java.lang.Boolean antiAlias)
Deprecated. Use the version that takes an int anti alias hint instead.

Contructor.

Parameters:
name - The name used for referencing this shape/sub shape
templateTexts - The strings of which the first one that fits will actually be the one drawn.
placeRect - How the shape will fill the bounds (or the parent's bounds)
type - If the text should word/line wrap at end of rectangle. E.g. TextAShape.TYPE_WRAP_TEXT
font - The font to use. Not null.
paint - The paint to use.
alignX - The x (horizontal) alignment. E.g. new AtFraction(0.2f) or new AtStart(10f).
alignY - The y (vertical) alignment. E.g. new AtFraction(1f) or new AtEnd(-10f).
antiAlias - Not used.
See Also:
AtRefRangeNumber, AtStart, AtEnd, AtFraction

FittingTextAShape

public FittingTextAShape(java.lang.String name,
                         java.lang.String[] templateTexts,
                         PlaceRect placeRect,
                         int type,
                         java.awt.Font font,
                         java.awt.Paint paint,
                         AtRefRangeNumber alignX,
                         AtRefRangeNumber alignY,
                         int antiAliasHint)
Contructor.

Parameters:
name - The name used for referencing this shape/sub shape
templateTexts - The strings of which the first one that fits will actually be the one drawn.
placeRect - How the shape will fill the bounds (or the parent's bounds)
type - If the text should word/line wrap at end of rectangle. E.g. TextAShape.TYPE_WRAP_TEXT
font - The font to use. Not null.
paint - The paint to use.
alignX - The x (horizontal) alignment. E.g. new AtFraction(0.2f) or new AtStart(10f).
alignY - The y (vertical) alignment. E.g. new AtFraction(1f) or new AtEnd(-10f).
antiAliasHint - The anti alias hint to set if != null. E.g. RenderingHints.VALUE_TEXT_ANTIALIAS_ON. If null the defalt value (i.e. it will not be change on the Graphics object) will be used.
See Also:
AtRefRangeNumber, AtStart, AtEnd, AtFraction

FittingTextAShape

public FittingTextAShape(java.lang.String name,
                         java.lang.String[] templateTexts,
                         PlaceRect placeRect,
                         int type,
                         java.awt.Font font,
                         java.awt.Paint paint,
                         AtRefRangeNumber alignX,
                         AtRefRangeNumber alignY,
                         int antiAliasHint,
                         java.awt.Point shdOff,
                         java.awt.Color shdColor)
Contructor

Parameters:
name - The name used for referencing this shape/sub shape
templateTexts - The strings of which the first one that fits will actually be the one drawn.
placeRect - How the shape will fill the bounds (or the parent's bounds)
type - If the text should word/line wrap at end of rectangle. E.g. TextAShape.TYPE_WRAP_TEXT
font - The font to use. Not null.
paint - The paint to use.
alignX - The x (horizontal) alignment. E.g. new AtFraction(0.2f) or new AtStart(10f).
alignY - The y (vertical) alignment. E.g. new AtFraction(1f) or new AtEnd(-10f).
antiAliasHint - The anti alias hint to set if != null. E.g. RenderingHints.VALUE_TEXT_ANTIALIAS_ON. If null the defalt value (i.e. it will not be change on the Graphics object) will be used.
shdOff - The offset to draw a second text, problably a shadow.
shdColor - The color to draw the second (probably shadow) string with
See Also:
AtRefRangeNumber, AtStart, AtEnd, AtFraction

FittingTextAShape

public FittingTextAShape(java.lang.String name,
                         java.lang.String[] templateTexts,
                         PlaceRect placeRect,
                         int type,
                         java.awt.Font font,
                         java.awt.Paint paint,
                         AtRefRangeNumber alignX,
                         AtRefRangeNumber alignY,
                         java.lang.Boolean antiAlias,
                         java.awt.Point shdOff,
                         java.awt.Color shdColor)
Deprecated. Use the version that takes an int anti alias hint instead.

Contructor

Parameters:
name - The name used for referencing this shape/sub shape
templateTexts - The strings of which the first one that fits will actually be the one drawn.
placeRect - How the shape will fill the bounds (or the parent's bounds)
type - If the text should word/line wrap at end of rectangle. E.g. TextAShape.TYPE_WRAP_TEXT
font - The font to use. Not null.
paint - The paint to use.
alignX - The x (horizontal) alignment. E.g. new AtFraction(0.2f) or new AtStart(10f).
alignY - The y (vertical) alignment. E.g. new AtFraction(1f) or new AtEnd(-10f).
antiAlias - Not used.
shdOff - The offset to draw a second text, problably a shadow.
shdColor - The color to draw the second (probably shadow) string with
See Also:
AtRefRangeNumber, AtStart, AtEnd, AtFraction
Method Detail

getString

public java.lang.String getString(int ix)
Description copied from interface: StringProvider
Returns the string for the index. Throws exception if ix is >= the size

Specified by:
getString in interface StringProvider
Overrides:
getString in class TextAShape
Parameters:
ix - The index.
Returns:
The string for the index. Never null.

getStringCount

public int getStringCount()
Description copied from interface: StringProvider
Returns the number of strings this provider can provide.

Specified by:
getStringCount in interface StringProvider
Overrides:
getStringCount in class TextAShape
Returns:
The number of strings this provider can provide.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.