ilog.views.graphic
Class IlvText

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvText
All Implemented Interfaces:
IlvFontInterface, IlvLabelInterface, IlvTextInterface, IlvPersistentObject, Transferable, Serializable

public class IlvText
extends IlvGraphic
implements IlvTextInterface, IlvFontInterface

IlvText represents a customizable multiline text label.

An IlvText instance supports word wrapping and truncation. You can add a background rectangle with margins around the bounding box of the text label.

The default values for an IlvText instance are as follows:

Example

The following code example shows how to use an IlvText in a simple Java application:

  IlvManager manager = new IlvManager();
      
  IlvText myDefaultText = new IlvText(new IlvPoint(10,20), "Default text");    
  IlvText myCustomText = new IlvText(new IlvPoint(60,60), "My Custom\ntext");
  
  myCustomText.setFillOn(true);
  IlvRect textShape = myCustomText.boundingBox();
  myCustomText.setFillPaint(
    new GradientPaint(
      new Point(textShape.xFloor(),
        textShape.yFloor()),
        Color.yellow,
        new Point(textShape.xFloor() + textShape.widthFloor(),
          textShape.yFloor() + textShape.heightFloor()),
        Color.red));
  
  myCustomText.setStrokeOn(true);
  myCustomText.setStrokeColor(Color.blue);
  
  myCustomText.setAlignment(IlvConstants.CENTER);
  myCustomText.setFont(new Font("SansSerif", Font.BOLD, 14));
  myCustomText.setForeground(Color.green);
  myCustomText.setUnderline(true);
  myCustomText.setInterlineSpacing(4);
  
  myCustomText.setLeftMargin(20);
  myCustomText.setRightMargin(20);
  myCustomText.setBottomMargin(20);
  myCustomText.setTopMargin(20);
  
  manager.addObject( myDefaultText, true);
  manager.addObject( myCustomText, true);
 

The following image shows the graphic objects created in the code example:

About Graphic Objects

IlvText is a custom graphic object, that is, a subclass of IlvGraphic. Graphic objects are controlled using an IlvManager instance and displayed using one or more IlvManagerView instances in a Java Swing application. For information about generic features for graphic objects, see IlvGraphic.

Since:
JViews 6.0
See Also:
IlvRect, IlvManager, IlvManagerView, IlvConstants, Serialized Form

Nested Class Summary
static class IlvText.Editor
          This is the text editor of IlvText.
 
Field Summary
static short OUTLINE_BACK
          Outline mode that the text draws first its text and then its outline.
static short OUTLINE_DISABLED
          Outline mode that the text does not draw its outline.
static short OUTLINE_FRONT
          Outline mode that the text draws its outline after drawing its text.
static short OUTLINE_ONLY
          Outline mode that the text draws only its outline.
static short WRAP_NONE
          The text is fully displayed and breaking lines only occurs where the text explicitly contains line break characters.
static short WRAP_TRUNCATE
          This text is broken into several lines at line break characters and an ellipsis is added to the end of each line such that the text fits the getWrappingHeight() height and getWrappingWidth() width.
static short WRAP_WORD
          This text is broken into several lines at line break characters and additional line break occurs such that the text best fit the getWrappingWidth() width.
 
Constructor Summary
IlvText()
          Creates a new IlvText instance with (0, 0) as anchor point and an empty text.
IlvText(IlvInputStream stream)
          This build an IlvText instance from an IlvInputStream.
IlvText(IlvPoint anchor, String text)
          Creates a new IlvText instance with a specified anchor point.
IlvText(IlvText source)
          This build an IlvText instance equivalent to the source one.
 
Method Summary
protected  Paint adaptPaint(Shape shape, Paint paint)
          Returns a new Paint object that will fit the shape parameter according to the initial paint parameter.
 void addLabelAttribute(AttributedCharacterIterator.Attribute attribute, Object value)
          This convenience method allows you to modify a text attribute of the label.
 void addLabelAttribute(AttributedCharacterIterator.Attribute attribute, Object value, int beginIndex, int endIndex)
          This convenient method allows you to modify a text attribute of the label.
 void addLabelAttributes(Map attributes, int beginIndex, int endIndex)
          This convenient method allows you to modify a text attribute of the label.
 void applyTransform(IlvTransformer t)
          Applies an additional transformation to the rendering of the IlvText.
 IlvRect boundingBox(IlvTransformer t)
          Returns the bounding rectangle of the IlvText.
 boolean contains(IlvPoint p, IlvPoint tp, IlvTransformer t)
          Tests if a point lies within the outline of the object.
 IlvGraphic copy()
          Returns a copy of the IlvText instance.
 void draw(Graphics dst, IlvTransformer t)
          Draws the IlvText object.
 int getAlignment()
          Return the alignment of the multilines text.
 IlvPoint getAnchorPoint()
          Returns the anchor point for the text.
 int getAnchorPosition()
          Returns the anchor position for the text.
 AttributedString getAttributedLabel()
          Returns the attributed text that will be displayed by the IlvText.
 float getBottomMargin()
          Returns the bottom margin of the box around the text.
 Shape getCaretShape(IlvTextSelection.Range range, IlvTransformer t)
          This method is called to get the shape enveloping the characters specified by the Range.
 IlvPoint getEffectiveAnchorPoint()
          Returns the effective anchor point.
 Paint getFillPaint()
          Returns the Paint object used to fill the background rectangle.
 Font getFont()
          Returns the Font used to draw the IlvText.
 Color getForeground()
          Returns the foreground color of object, i.e the color used to draw the text itself.
 float getInterlineSpacing()
          Returns the interline spacing used when the text is displayed as several lines.
 String getLabel()
          Returns the label that will be displayed by the IlvText.
 IlvRect getLabelBBox(IlvTransformer t)
          Returns the bounding rectangle of the text part of the IlvText.
 float getLeftMargin()
          Returns the left margin of the box around the text.
 Color getOutlineColor()
          Returns the outline color of the text.
 int getOutlineMode()
          Returns the outline mode.
 float getOutlineThickness()
          Returns the outline thickness of the text.
 float getRightMargin()
          Returns the right margin of the box around the text.
 float getRotationAlignmentAngle()
          Returns the rotation alignment angle.
 float getRotationAlignmentThresholdAngle()
          Returns the threshold angle that decides whether a rotated multiline text object is aligned parallel to the rotation alignment axis, or perpendicular to the rotation alignment axis.
 Color getStrokeColor()
          Returns the stroke color of the object, i.e the color used to draw the stroke around the background rectangle.
 float getTopMargin()
          Returns the top margin of the box around the text.
 IlvTransformer getTransformer()
          Returns the internal transformation used to draw the label in addition to the IlvManagerView transformation.
 float getWrappingHeight()
          Returns the IlvText wrapping height.
 short getWrappingMode()
          Returns the wrapping status of the text.
 float getWrappingWidth()
          Returns the IlvText wrapping width.
 boolean isAntialiasing()
          Returns true if the anti-aliasing mode of the label is on.
 boolean isAutoWrappingSizeMode()
          Returns the auto resize mode.
 boolean isFillOn()
          Returns true if the background rectangle of the text is drawn.
 boolean isFractionalMetrics()
          Returns true if the fractional metrics mode of the text is on.
 boolean isPaintAbsolute()
          Returns false if the TexturePaint or GradientPaint will be adapted to the bounding rectangle of the object.
 boolean isStrikethrough()
          Returns true if the entire text has strikethrough attribute.
 boolean isStrokeOn()
          Returns true if the frame of the background rectangle of the text is drawn.
static boolean IsTransformerDependentRendering()
          Returns whether all IlvText objects are rendered with a strategy that requires re-rendering when the transformer changes.
 boolean isUnderline()
          Returns true if the entire text has underline attribute.
 int lineCount()
          Returns the line count for a multiline text.
 int lineOffset(int index)
          For a multiline label, you need to know the start offset for a specified line.
 IlvSelection makeSelection()
          Create an IlvTextSelection.
 void moveResize(IlvRect size)
          Resizes the object.
 int pickCharacter(IlvPoint click, IlvTransformer t)
          This method is called when a user is clicking on the label to hit-test which character is clicked.
 void resize(float neww, float newh)
          Resizes the object.
 void setAlignment(int alignment)
          Changes the alignment of the multilines text.
 void setAnchorPoint(IlvPoint anchor)
          Sets the anchor point for the text.
 void setAnchorPosition(int position)
          Sets the anchor position for the text.
 void setAntialiasing(boolean set)
          Changes the anti-aliasing mode of the text.
 void setAttributedLabel(AttributedString label)
          Sets the attributed text that will be displayed by the IlvText.
 void setAutoWrappingSizeMode(boolean value)
          Sets the auto wrapping size mode.
 void setBackground(Color c)
          Changes the background color of the object, i.e the color used to fill the background rectangle.
 void setBottomMargin(float margin)
          Sets the bottom margin of the box around the text.
 void setFillOn(boolean value)
          Changes the visibility of the background rectangle of the text.
 void setFillPaint(Paint paint)
          Changes the background Paint of the object, i.e the paint server used to fill the background rectangle.
 void setFont(Font font)
          Sets the Font used to draw the entire IlvText.
 void setForeground(Color c)
          Changes the foreground color of the object, i.e the color used to draw the text itself.
 void setFractionalMetrics(boolean set)
          Changes the fractional metrics mode of the text.
 void setInterlineSpacing(float spacing)
          Sets the interline spacing used when the text is displayed as several lines.
 void setLabel(String label)
          Sets the label that will be displayed by the IlvText.
 void setLeftMargin(float margin)
          Sets the left margin of the box around the text.
 void setOutlineColor(Color c)
          Changes the outline color of the text.
 void setOutlineMode(int mode)
          Sets the outline mode.
 void setOutlineThickness(float thickness)
          Changes the outline thickness of the text.
 void setPaintAbsolute(boolean set)
          When set to false, specifies that the TexturePaint or GradientPaint will be adapted to the bounding rectangle of the object.
 void setRightMargin(float margin)
          Sets the right margin of the box around the text.
 void setRotationAlignmentAngle(float angle)
          Sets the rotation alignment angle.
 void setRotationAlignmentThresholdAngle(float angle)
          Sets the threshold angle that decides whether a rotated multiline text object is aligned parallel to the rotation alignment axis, or perpendicular to the rotation alignment axis.
 void setStrikethrough(boolean set)
          Changes the strikethrough attribute of the entire text.
 void setStrokeColor(Color c)
          Changes the stroke color of the object, i.e the color used to draw the stroke around the background rectangle.
 void setStrokeOn(boolean value)
          Changes the visibility of the stroke of the background rectangle.
 void setTopMargin(float margin)
          Sets the top margin of the box around the text.
static void SetTransformerDependentRendering(boolean flag)
          Sets whether all IlvText objects are rendered with a strategy that requires re-rendering when the transformer changes.
 void setUnderline(boolean set)
          Changes the underline attribute of the entire text.
 void setWrappingHeight(float height)
          Sets the IlvText wrapping height.
 void setWrappingMode(short value)
          Changes the wrapping mode of the text.
 void setWrappingWidth(float width)
          Sets the IlvText wrapping width.
 boolean supportMultiline()
          Always returns true for IlvText.
 void translate(float dx, float dy)
          Translates the object.
 void write(IlvOutputStream stream)
          Writes the contents of the IlvText to an IVL file.
 
Methods inherited from class ilog.views.IlvGraphic
addActionListener, addNamedPropertyListener, boundingBox, getAndAssociateObjectInteractor, getCenter, getDefaultInteractor, getGraphicBag, GetGraphicObject, getIntersectionWithOutline, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenu, getPopupMenuName, getProperty, getToolTipText, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, hasProperty, inside, intersects, isDataFlavorSupported, isEditable, isInApplyToObject, isMovable, isPersistent, isSelectable, isVisible, move, move, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, rotate, scale, setEditable, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setToolTipText, setVisible, toString, zoomable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OUTLINE_ONLY

public static final short OUTLINE_ONLY
Outline mode that the text draws only its outline.

Since:
JViews 8.1
See Also:
setOutlineMode(int), getOutlineMode(), Constant Field Values

OUTLINE_FRONT

public static final short OUTLINE_FRONT
Outline mode that the text draws its outline after drawing its text.

Since:
JViews 8.1
See Also:
setOutlineMode(int), getOutlineMode(), Constant Field Values

OUTLINE_BACK

public static final short OUTLINE_BACK
Outline mode that the text draws first its text and then its outline.

Since:
JViews 8.1
See Also:
setOutlineMode(int), getOutlineMode(), Constant Field Values

OUTLINE_DISABLED

public static final short OUTLINE_DISABLED
Outline mode that the text does not draw its outline.

Since:
JViews 8.1
See Also:
setOutlineMode(int), getOutlineMode(), Constant Field Values

WRAP_NONE

public static final short WRAP_NONE
The text is fully displayed and breaking lines only occurs where the text explicitly contains line break characters.

See Also:
setWrappingMode(short), Constant Field Values

WRAP_WORD

public static final short WRAP_WORD
This text is broken into several lines at line break characters and additional line break occurs such that the text best fit the getWrappingWidth() width.

See Also:
setWrappingMode(short), Constant Field Values

WRAP_TRUNCATE

public static final short WRAP_TRUNCATE
This text is broken into several lines at line break characters and an ellipsis is added to the end of each line such that the text fits the getWrappingHeight() height and getWrappingWidth() width.

Note: In this mode, the text can be selected but cannot be edited in place by using the new IlvTextSelection introduced since JViews 7.5. However the text can still be edited by the IlvEditLabelInteractor.

See Also:
setWrappingMode(short), Constant Field Values
Constructor Detail

IlvText

public IlvText()
Creates a new IlvText instance with (0, 0) as anchor point and an empty text.

See Also:
IlvText(IlvPoint, String)

IlvText

public IlvText(IlvPoint anchor,
               String text)
Creates a new IlvText instance with a specified anchor point.

Parameters:
anchor - the anchor point in manager coordinates.
text - the text to be displayed.
See Also:
setAnchorPoint(IlvPoint), setAnchorPosition(int), setLabel(String)

IlvText

public IlvText(IlvText source)
This build an IlvText instance equivalent to the source one.

Parameters:
source - The IlvText to be copied.

IlvText

public IlvText(IlvInputStream stream)
        throws IlvReadFileException
This build an IlvText instance from an IlvInputStream.

Parameters:
stream - the input stream
Throws:
IlvReadFileException - if the format is not correct.
Method Detail

copy

public IlvGraphic copy()
Returns a copy of the IlvText instance.

Specified by:
copy in class IlvGraphic
Returns:
A copy of this IlvGraphic instance.
See Also:
IlvGraphic

draw

public void draw(Graphics dst,
                 IlvTransformer t)
Draws the IlvText object.

Specified by:
draw in class IlvGraphic
Parameters:
dst - The destination Graphics.
t - The view transformation used to draw the object.
See Also:
IlvGraphic.boundingBox(ilog.views.IlvTransformer), IlvGraphic.zoomable(), IlvGraphic

getTransformer

public final IlvTransformer getTransformer()
Returns the internal transformation used to draw the label in addition to the IlvManagerView transformation. When applyTransform(IlvTransformer) is called its parameter transformer is concatenated to this transformer. The returned value may be null if no transformer has been applied.


boundingBox

public IlvRect boundingBox(IlvTransformer t)
Returns the bounding rectangle of the IlvText.

Specified by:
boundingBox in class IlvGraphic
Parameters:
t - The view transformer used to draw the object.
See Also:
IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer), IlvGraphic.zoomable(), IlvGraphic

applyTransform

public void applyTransform(IlvTransformer t)
Applies an additional transformation to the rendering of the IlvText. This can be used to rotate or scale the text.

Specified by:
applyTransform in class IlvGraphic
Parameters:
t - The transformer to be applied.
See Also:
IlvGraphic

moveResize

public void moveResize(IlvRect size)
Resizes the object. If isAutoWrappingSizeMode() is false this method calls IlvGraphic.moveResize(IlvRect); otherwise it translates the internal transformer (getTransformer()) so that the effective anchor is at the new position and adapts the wrapping width and height according the size rectangle.

Overrides:
moveResize in class IlvGraphic
Parameters:
size - The new bounding rectangle of the object.
See Also:
setWrappingWidth(float), setWrappingHeight(float), getEffectiveAnchorPoint()

translate

public void translate(float dx,
                      float dy)
Translates the object. If isAutoWrappingSizeMode() is false this method calls IlvGraphic.translate(float, float); otherwise it translates the internal transformer (getTransformer()) so that the effective anchor is at the new position.

Overrides:
translate in class IlvGraphic
Parameters:
dx - The horizontal translation factor.
dy - The vertical translation factor.
See Also:
IlvGraphic, IlvGraphic.applyTransform(IlvTransformer)

resize

public void resize(float neww,
                   float newh)
Resizes the object. If isAutoWrappingSizeMode() is false this method calls IlvGraphic.resize(float, float) otherwise it changes the wrapping width (setWrappingWidth(float)) and height (setWrappingHeight(float)) according the given scaling factors.

Overrides:
resize in class IlvGraphic
Parameters:
neww - The new width
newh - The new height
See Also:
IlvGraphic, IlvGraphic.applyTransform(IlvTransformer)

setAnchorPoint

public final void setAnchorPoint(IlvPoint anchor)
Sets the anchor point for the text. This specifies to which point in manager coordinate (before applying getTransformer()) the text will be attached to.

Parameters:
anchor - the anchor point.
See Also:
setAnchorPosition(int)

getAnchorPoint

public final IlvPoint getAnchorPoint()
Returns the anchor point for the text. This is the point in manager coordinate (before applying getTransformer()) the text is attached to.

See Also:
getAnchorPosition()

getEffectiveAnchorPoint

public final IlvPoint getEffectiveAnchorPoint()
Returns the effective anchor point. The anchor point obtained with getAnchorPoint() is the anchor of the untransformed text object. However as soon as the text object is moved or reshaped, the text object is transformed. This method returns the anchor point while respecting this transformation. The meaning of the anchor point depends on the font and on the string displayed in the text. For instance for Latin based fonts with western European text (English, French, German etc., i.e. text with left-to-right orientation), the effective anchor point specifies:

Since:
JViews 8.1

setAnchorPosition

public final void setAnchorPosition(int position)
Sets the anchor position for the text. This specifies which side of the text is used to attach it to the anchor point.

Parameters:
position - the anchor position. One of the following values:
  • IlvConstants.LEFT: the anchor point is at the left side of the first line of the text.
  • IlvConstants.RIGHT: the anchor point is at the right side of the first line of the text.
  • IlvConstants.CENTER: the anchor point is at the center of the text.
  • IlvConstants.LEADING: the anchor point is at the leading edge of the first line of the text (the default).
  • IlvConstants.TRAILING: the anchor points is at the trailing edge of the first line of the text.
See Also:
setAnchorPoint(IlvPoint)

getAnchorPosition

public final int getAnchorPosition()
Returns the anchor position for the text. This specifies which side of the text is used to attach it to the anchor point.

Returns:
One of the following values:
  • IlvConstants.LEFT: the anchor point is at the left side of the first line of the text.
  • IlvConstants.RIGHT: the anchor point is at the right side of the first line of the text.
  • IlvConstants.CENTER: the anchor point is at the center of the text.
  • IlvConstants.LEADING: the anchor point is at the leading edge of the first line of the text (the default).
  • IlvConstants.TRAILING: the anchor points is at the trailing edge of the first line of the text.
See Also:
setAnchorPoint(IlvPoint)

setLabel

public void setLabel(String label)
Sets the label that will be displayed by the IlvText. If the label contains line breaking characters ('\n') it will be displayed on several lines. Depending on the value of getWrappingMode() the text will be drawn differently.

Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify this flag using the applyToObject method of the manager.

Specified by:
setLabel in interface IlvLabelInterface
Parameters:
label - the new label.

getLabel

public String getLabel()
Returns the label that will be displayed by the IlvText. This method returns the label even if it was set via setAttributedLabel(java.text.AttributedString).

Specified by:
getLabel in interface IlvLabelInterface
See Also:
setLabel(String)

setAttributedLabel

public void setAttributedLabel(AttributedString label)
Sets the attributed text that will be displayed by the IlvText. If the text contains line breaking characters ('\n') it will be displayed on several lines. Depending on the value of getWrappingMode() the text will be drawn differently.

All text attributes can be used. However, the label is assumed to be unidirectional, that is, Bidi changes (for example, mixing LTR orientation with RTL orientation) inside the same label are not supported. Partial font attributes (such as TextAttribute.WEIGHT) cannot be specified individually, since the font specification overrides them, but it is possible to specify the full TextAttribute.FONT attribute for selected parts of the string.

Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify this flag using the applyToObject method of the manager.

Parameters:
label - the new label.
Since:
JViews 8.0
See Also:
TextAttribute

getAttributedLabel

public AttributedString getAttributedLabel()
Returns the attributed text that will be displayed by the IlvText. If you modify the attributes of the returned attributed text, you need to call setAttributedLabel(java.text.AttributedString) again so that the new attributes become valid. A more comfortable way is to modify the text attributes via addLabelAttribute(java.text.AttributedCharacterIterator.Attribute, Object, int, int).

Since:
JViews 8.0
See Also:
setAttributedLabel(AttributedString), addLabelAttribute(java.text.AttributedCharacterIterator.Attribute, Object), addLabelAttribute(java.text.AttributedCharacterIterator.Attribute, Object, int, int), addLabelAttributes(Map, int, int)

addLabelAttribute

public void addLabelAttribute(AttributedCharacterIterator.Attribute attribute,
                              Object value)
This convenience method allows you to modify a text attribute of the label. It adds a text attribute to the entire string, like AttributedString.addAttribute(java.text.AttributedCharacterIterator.Attribute, Object).

Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify this flag using the applyToObject method of the manager.

Parameters:
attribute - The attribute key.
value - The value of the attribute; may be null.
Throws:
IllegalArgumentException - if the AttributedString has length 0. (attributes cannot be applied to a 0-length range).
Since:
JViews 8.0
See Also:
addLabelAttribute(java.text.AttributedCharacterIterator.Attribute, Object, int, int), TextAttribute

addLabelAttribute

public void addLabelAttribute(AttributedCharacterIterator.Attribute attribute,
                              Object value,
                              int beginIndex,
                              int endIndex)
This convenient method allows you to modify a text attribute of the label. It adds a text attribute to a subrange of the string, like AttributedString.addAttribute(java.text.AttributedCharacterIterator.Attribute, Object, int, int).

For instance, in order to create a text label and underline the 3th and 4th character of the label, call

 IlvText text = new IlvText(new IlvPoint(0,0), "ABCDEFG");
 text.addLabelAttribute(TextAttribute.UNDERLINE,
                        TextAttribute.UNDERLINE_ON,
                        3, 5);
 
All text attributes can be used. However, the label is assumed to be unidirectional, that is, Bidi changes (for example, mixing LTR orientation with RTL orientation) inside the same label are not supported. Partial font attributes (such as TextAttribute.WEIGHT) cannot be specified individually, since the font specification overrides them, but it is possible to specify the full TextAttribute.FONT attribute for selected parts of the string.

Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify this flag using the applyToObject method of the manager.

Parameters:
attribute - The attribute key.
value - The value of the attribute; may be null.
beginIndex - Index of the first character of the range.
endIndex - Index of the character following the last character of the range.
Throws:
IllegalArgumentException - if beginIndex is less then 0, endIndex is greater than the length of the string, or beginIndex and endIndex together don't define a non-empty subrange of the string.
Since:
JViews 8.0
See Also:
TextAttribute

addLabelAttributes

public void addLabelAttributes(Map attributes,
                               int beginIndex,
                               int endIndex)
This convenient method allows you to modify a text attribute of the label. It adds a set of attributes to a subrange of the string, like AttributedString.addAttributes(Map, int, int).

All text attributes can be used. However, the label is assumed to be unidirectional, that is Bidi changes (for example, mixing LTR orientation with RTL orientation) inside the same label are not supported. Partial font attributes (such as TextAttribute.WEIGHT) cannot be specified individually, since the font specification overrides them, but it is possible to specify the full TextAttribute.FONT attribute for selected parts of the string.

Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify this flag using the applyToObject method of the manager.

Parameters:
attributes - The attributes to be added to the string.
beginIndex - Index of the first character of the range.
endIndex - Index of the character following the last character of the range.
Throws:
IllegalArgumentException - if beginIndex is less then 0, endIndex is greater than the length of the string, or beginIndex and endIndex together don't define a non-empty subrange of the string and the attributes parameter is not an empty Map.
Since:
JViews 8.0
See Also:
addLabelAttribute(java.text.AttributedCharacterIterator.Attribute, Object, int, int), TextAttribute

supportMultiline

public boolean supportMultiline()
Always returns true for IlvText.

Specified by:
supportMultiline in interface IlvLabelInterface

getLabelBBox

public IlvRect getLabelBBox(IlvTransformer t)
Returns the bounding rectangle of the text part of the IlvText. It is equivalent to the boundingBox(IlvTransformer) without the margins.

Specified by:
getLabelBBox in interface IlvLabelInterface
Parameters:
t - the transformer used to draw the graphic object.

setFont

public void setFont(Font font)
Sets the Font used to draw the entire IlvText.

If an attributed string label is used, the local attributes on the attributed string dominate, i.e. set font is only set to those characters of the attributed string that don't have any local font attribute.

Specified by:
setFont in interface IlvFontInterface
Parameters:
font - The new font.
See Also:
setAttributedLabel(java.text.AttributedString)

getFont

public Font getFont()
Returns the Font used to draw the IlvText.

Specified by:
getFont in interface IlvFontInterface

isAntialiasing

public final boolean isAntialiasing()
Returns true if the anti-aliasing mode of the label is on. The default value is false.


setAntialiasing

public final void setAntialiasing(boolean set)
Changes the anti-aliasing mode of the text. The default value is false. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify this flag using the applyToObject method of the manager.


isStrikethrough

public final boolean isStrikethrough()
Returns true if the entire text has strikethrough attribute. The default value is false.

Since:
JViews 7.5

setStrikethrough

public final void setStrikethrough(boolean set)
Changes the strikethrough attribute of the entire text. The default value is false. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify this flag using the applyToObject method of the manager.

If an attributed string label is used, the local attributes on the attributed string dominate, that is strikethrough is only performed on those characters of the attributed string that don't have any strikethrough attribute.

Since:
JViews 7.5
See Also:
setAttributedLabel(java.text.AttributedString)

isUnderline

public final boolean isUnderline()
Returns true if the entire text has underline attribute. The default value is false.

Since:
JViews 7.5

setUnderline

public final void setUnderline(boolean set)
Changes the underline attribute of the entire text. The default value is false. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify this flag using the applyToObject method of the manager.

If an attributed string label is used, the local attributes on the attributed string dominate, that is underlining is only performed on those characters of the attributed string that don't have any underline attribute.

Since:
JViews 7.5
See Also:
setAttributedLabel(java.text.AttributedString)

getOutlineMode

public int getOutlineMode()
Returns the outline mode.

Returns:
One of the following values: OUTLINE_DISABLED, OUTLINE_ONLY, OUTLINE_FRONT, and OUTLINE_BACK.
Since:
JViews 8.1
See Also:
setOutlineMode(int)

setOutlineMode

public void setOutlineMode(int mode)
Sets the outline mode.

Parameters:
mode - Must be one of the following values: OUTLINE_DISABLED, OUTLINE_ONLY, OUTLINE_FRONT, and OUTLINE_BACK.
Since:
JViews 8.1
See Also:
getOutlineMode()

isFractionalMetrics

public final boolean isFractionalMetrics()
Returns true if the fractional metrics mode of the text is on. The default value is true, setting it to false will speed up the IlvText but may lead to less precise text positioning.


setFractionalMetrics

public final void setFractionalMetrics(boolean set)
Changes the fractional metrics mode of the text. The default value is true, setting it to false will speed up the IlvText but may lead to less precise text positioning. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify this flag using the applyToObject method of the manager.


setForeground

public void setForeground(Color c)
Changes the foreground color of the object, i.e the color used to draw the text itself.

Overrides:
setForeground in class IlvGraphic
Parameters:
c - The new color.
See Also:
IlvGraphic.draw(Graphics, IlvTransformer), IlvGraphic.setBackground(Color), IlvGraphic.setFillOn(boolean), IlvGraphic.setStrokeOn(boolean), IlvGraphic

getForeground

public Color getForeground()
Returns the foreground color of object, i.e the color used to draw the text itself. The default value is Color.BLACK.


setOutlineColor

public void setOutlineColor(Color c)
Changes the outline color of the text.

Parameters:
c - The new outline color.
Since:
JViews 8.1

getOutlineColor

public Color getOutlineColor()
Returns the outline color of the text. The default value is Color.BLACK.

Since:
JViews 8.1

setBackground

public void setBackground(Color c)
Changes the background color of the object, i.e the color used to fill the background rectangle. It calls setFillPaint(java.awt.Paint).

Overrides:
setBackground in class IlvGraphic
Parameters:
c - The new color.
See Also:
IlvGraphic.draw(Graphics, IlvTransformer), IlvGraphic.setForeground(Color), IlvGraphic.setFillOn(boolean), IlvGraphic.setStrokeOn(boolean), IlvGraphic

setFillPaint

public void setFillPaint(Paint paint)
Changes the background Paint of the object, i.e the paint server used to fill the background rectangle.

Parameters:
paint - the new Paint object.

getFillPaint

public Paint getFillPaint()
Returns the Paint object used to fill the background rectangle. The default value is Color.GRAY.

See Also:
setFillPaint(java.awt.Paint)

adaptPaint

protected Paint adaptPaint(Shape shape,
                           Paint paint)
Returns a new Paint object that will fit the shape parameter according to the initial paint parameter. This method is called only if isPaintAbsolute() returns false. By default, it deals with GradientPaint and TexturePaint instances to adapt them correctly because they do not automatically fit the shape of the object on which they are drawn. You can override this method to manage your own Paint subclasses if they do not take the shape of the object into account. You will generally call the superclass method for GradientPaint and TexturePaint instances. Other Paint objects deriving from IlvMultipleGradientPaint automatically take into account the shape of the object if their IlvMultipleGradientPaint.isAdapting() method returns true and thus are not modified by this method.

Parameters:
shape - The shape parameter that the returned Paint should fit.
paint - The initial Paint object.
See Also:
isPaintAbsolute()

isPaintAbsolute

public final boolean isPaintAbsolute()
Returns false if the TexturePaint or GradientPaint will be adapted to the bounding rectangle of the object. The default value is false. This value does not affect automatically adjusted Paint such as ilog.views.util.java2d.IlvLinearGradientPaint.

See Also:
setPaintAbsolute(boolean), setFillPaint(java.awt.Paint), adaptPaint(java.awt.Shape, java.awt.Paint)

setPaintAbsolute

public final void setPaintAbsolute(boolean set)
When set to false, specifies that the TexturePaint or GradientPaint will be adapted to the bounding rectangle of the object. The default value is false. This value does not affect automatically adjusted Paint such as ilog.views.util.java2d.IlvLinearGradientPaint.

See Also:
isPaintAbsolute(), setFillPaint(java.awt.Paint), adaptPaint(java.awt.Shape, java.awt.Paint)

setFillOn

public final void setFillOn(boolean value)
Changes the visibility of the background rectangle of the text.

Overrides:
setFillOn in class IlvGraphic
Parameters:
value - true if fill is on.
See Also:
IlvGraphic.draw(Graphics, IlvTransformer), IlvGraphic.setBackground(Color), IlvGraphic.setForeground(Color), IlvGraphic.setStrokeOn(boolean), IlvGraphic

isFillOn

public final boolean isFillOn()
Returns true if the background rectangle of the text is drawn.

See Also:
setFillPaint(java.awt.Paint), setFillOn(boolean)

setStrokeOn

public final void setStrokeOn(boolean value)
Changes the visibility of the stroke of the background rectangle.

Overrides:
setStrokeOn in class IlvGraphic
Parameters:
value - true if stroke is on.
See Also:
IlvGraphic.draw(Graphics, IlvTransformer), IlvGraphic.setBackground(Color), IlvGraphic.setForeground(Color), IlvGraphic.setFillOn(boolean), IlvGraphic

isStrokeOn

public final boolean isStrokeOn()
Returns true if the frame of the background rectangle of the text is drawn.

See Also:
setStrokeColor(Color), setStrokeOn(boolean)

setStrokeColor

public final void setStrokeColor(Color c)
Changes the stroke color of the object, i.e the color used to draw the stroke around the background rectangle.

Parameters:
c - The new color.
See Also:
getStrokeColor()

getStrokeColor

public final Color getStrokeColor()
Returns the stroke color of the object, i.e the color used to draw the stroke around the background rectangle. The default value is the color returned by getForeground().


setAutoWrappingSizeMode

public final void setAutoWrappingSizeMode(boolean value)
Sets the auto wrapping size mode. The default value is false. When set to true subsequent calls to moveResize(IlvRect), resize(float, float) and translate(float, float) instead of calling applyTransform(IlvTransformer) will change the anchor point and the wrapping width and height to match as much as possible the given size. In that case the resulting size of the IlvText may not exactly be the given size if the text doesn't require that much size to be displayed or margins require more room.

Parameters:
value - true if the auto wrapping size mode is needed.
See Also:
getWrappingWidth(), getWrappingHeight(), getAnchorPoint()

isAutoWrappingSizeMode

public final boolean isAutoWrappingSizeMode()
Returns the auto resize mode. The default value is false.

See Also:
setAutoWrappingSizeMode(boolean)

setWrappingMode

public final void setWrappingMode(short value)
Changes the wrapping mode of the text. The default value is IlvText.WRAP_NONE.

Parameters:
value - One of the following values or a combination:
  • IlvText.WRAP_NONE : the text is displayed as-is.
  • IlvText.WRAP_WORD : the text is automatically broken into lines using a line instance java.text.BreakIterator which will break the text where appropriate to best fit the getWrappingWidth() width. For example in latin languages this will break the text at white spaces. To prevent the text from being broken at a particular white space you should use the unicode non-breaking white space (' ').
  • IlvText.WRAP_TRUNCATE : the text is automatically truncated such that it fits the getWrappingHeight() height and the getWrappingWidth() width. An ellipsis is added at the end of the truncated line.