public class IlvText extends IlvBidiGraphic 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:
IlvPoint(0, 0)IlvConstants.LEADINGIlvToolkit.defaultFontColor.blacktruefalseColor.grayfalseColor.blackIlvText.OUTLINE_DISABLEDColor.black0falsefalsefalsefalsefalseIlvText.NO_AUTO_WRAPPINGIlvText.WRAP_NONE100100-1IlvConstants.LEADING000000
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:
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.IlvRect,
IlvManager,
IlvManagerView,
IlvConstants,
IlvHTMLText,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
static class |
IlvText.Editor
This is the text editor of IlvText.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
NO_AUTO_WRAPPING
Auto wrapping resize mode.
|
static int |
OUTLINE_BACK
Outline mode that the text draws first its text and then its outline.
|
static int |
OUTLINE_DISABLED
Outline mode that the text does not draw its outline.
|
static int |
OUTLINE_FRONT
Outline mode that the text draws its outline after drawing its text.
|
static int |
OUTLINE_ONLY
Outline mode that the text draws only its outline.
|
static int |
SIZE_AUTO_WRAPPING
Auto wrapping resize mode.
|
static short |
WRAP_CHARACTER
The text is broken into several lines at line break
characters and additional line breaks occur at character boundaries such
that the text best fits the
getWrappingWidth() width. |
static short |
WRAP_NONE
The text is fully displayed and the lines are broken
only where the text explicitly contains
line break characters.
|
static short |
WRAP_TRUNCATE
The 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
The text is broken into several lines at line break
characters and additional line breaks occur at word boundaries such
that the text best fits the
getWrappingWidth() width. |
static int |
ZOOM_AUTO_WRAPPING
Auto wrapping resize mode.
|
| Constructor and Description |
|---|
IlvText()
Creates a new
IlvText instance with (0, 0)
as anchor point and an empty text. |
IlvText(IlvInputStream stream)
r
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. |
| Modifier and Type | Method and Description |
|---|---|
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<? extends AttributedCharacterIterator.Attribute,?> 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. |
void |
baseTextDirectionChanged(int oldBaseTextDirection,
int newBaseTextDirection)
Called when the object is base text direction sensitive and the
resolved base text direction has changed.
|
IlvRect |
boundingBox(IlvTransformer t)
Returns the bounding rectangle of the
IlvText. |
void |
componentOrientationChanged(ComponentOrientation oldOri,
ComponentOrientation newOri)
Called when the object is component orientation sensitive and the
component orientation has changed.
|
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.
|
IlvPoint[] |
getAnchorPoints(boolean leading,
IlvTransformer t)
Returns the array of anchor points for all the lines.
|
int |
getAnchorPosition()
Returns the anchor position for the text.
|
AttributedString |
getAttributedLabel()
Returns the attributed text that will be displayed by the
IlvText. |
int |
getAutoWrappingResizeMode()
Returns the auto resize mode.
|
double |
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 text. |
Color |
getForeground()
Returns the foreground color of object, i.e the color used
to draw the text itself.
|
double |
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. |
double |
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.
|
double |
getOutlineThickness()
Returns the outline thickness of the text.
|
double |
getRightMargin()
Returns the right margin of the box around the text.
|
double |
getRotationAlignmentAngle()
Returns the rotation alignment angle.
|
double |
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.
|
double |
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. |
double |
getWrappingHeight()
Returns the wrapping height of the text.
|
short |
getWrappingMode()
Returns the wrapping mode of the text.
|
double |
getWrappingWidth()
Returns the wrapping width of the text.
|
boolean |
isAntialiasing()
Returns
true if the anti-aliasing mode
of the text is on. |
boolean |
isAutoWrappingSizeMode()
Deprecated.
Since JViews 8.8, use
getAutoWrappingResizeMode(). |
boolean |
isBaseTextDirectionSensitive()
Returns
true because the bounding box of this object
depends on its text direction. |
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 |
isKeepingAspectRatio()
Returns
true if the text keeps the aspect ratio;
otherwise it returns false. |
boolean |
isLocaleSensitive()
Returns
true if the bounding box of this object depends
on the locale of this object. |
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 |
isTruncated()
Returns whether the label is truncated or fully visible.
|
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.
|
void |
localeChanged(ULocale oldLocale,
ULocale newLocale)
Called when the object is locale sensitive and the locale has changed.
|
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(double neww,
double newh)
Resizes the object.
|
void |
rotate(IlvPoint center,
double angle)
Rotates 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 |
setAutoWrappingResizeMode(int mode)
Sets the auto wrapping resize mode.
|
void |
setAutoWrappingSizeMode(boolean value)
Deprecated.
Since JViews 8.8, use
setAutoWrappingResizeMode(int). |
void |
setBackground(Color c)
Changes the background color of the object, i.e the color
used to fill the background rectangle.
|
void |
setBottomMargin(double 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(double spacing)
Sets the interline spacing used when the text is displayed as several lines.
|
void |
setKeepingAspectRatio(boolean set)
Allows or inhibits the ability to have different
zoom factors along the x and y axes.
|
void |
setLabel(String label)
Sets the label that will be displayed by the
IlvText. |
void |
setLeftMargin(double 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(double 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(double margin)
Sets the right margin of the box around the text.
|
void |
setRotationAlignmentAngle(double angle)
Sets the rotation alignment angle.
|
void |
setRotationAlignmentThresholdAngle(double 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(double 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(double height)
Sets the wrapping height of the text.
|
void |
setWrappingMode(short value)
Changes the wrapping mode of the text.
|
void |
setWrappingWidth(double width)
Sets the wrapping width of the text.
|
boolean |
supportMultiline()
Always returns
true for IlvText. |
void |
translate(double dx,
double dy)
Translates the object.
|
boolean |
usesBidiMarkers()
Returns
true if in-place editing implementation uses markers,
which should be taken into account in hit-to-point and point-to-hit
calculations. |
void |
write(IlvOutputStream stream)
Writes the contents of the
IlvText to an IVL file. |
calcResolvedBaseTextDirection, getBaseTextDirection, getComponentOrientation, getResolvedBaseTextDirection, getULocale, invalidateBidiCache, setBaseTextDirection, setBaseTextDirection, setBaseTextDirectionDuringConstructionaddActionListener, addNamedPropertyListener, allViewsRemoved, blinkingStateOn, boundingBox, callDraw, getAndAssociateObjectInteractor, getBlinkingAction, getBlinkingObjectOwner, getBlinkingOffPeriod, getBlinkingOnPeriod, getCenter, getDefaultInteractor, getGraphicBag, GetGraphicObject, getIntersectionWithOutline, getLocale, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenu, getPopupMenuName, getProperty, getToolTipBaseTextDirection, getToolTipText, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, getZOrderIndex, hasProperty, inside, intersects, invalidateBBoxCache, isComponentOrientationSensitive, isDataFlavorSupported, isEditable, isInApplyToObject, isMovable, isPersistent, isSelectable, isVisible, move, move, needsViewNotification, notifyObjectInteractorToManager, processActionEvent, reDraw, registerBlinkingResource, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, scale, setBlinkingAction, setBlinkingOffPeriod, setBlinkingOnPeriod, setEditable, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setToolTipBaseTextDirection, setToolTipText, setVisible, setZOrderIndex, toString, updateNeedsViewNotification, viewAddedOrRemoved, zoomablepublic static final int OUTLINE_ONLY
setOutlineMode(int),
getOutlineMode(),
Constant Field Valuespublic static final int OUTLINE_FRONT
setOutlineMode(int),
getOutlineMode(),
Constant Field Valuespublic static final int OUTLINE_BACK
setOutlineMode(int),
getOutlineMode(),
Constant Field Valuespublic static final int OUTLINE_DISABLED
setOutlineMode(int),
getOutlineMode(),
Constant Field Valuespublic static final short WRAP_NONE
setWrappingMode(short),
Constant Field Valuespublic static final short WRAP_WORD
getWrappingWidth() width.setWrappingMode(short),
Constant Field Valuespublic static final short WRAP_CHARACTER
getWrappingWidth() width.setWrappingMode(short),
Constant Field Valuespublic static final short WRAP_TRUNCATE
getWrappingHeight() height
and getWrappingWidth() width.
IlvTextSelection introduced since JViews 7.5. However the
text can still be edited by the
IlvEditLabelInteractor.setWrappingMode(short),
Constant Field Valuespublic static final int NO_AUTO_WRAPPING
moveResize(IlvRect) and resize(double, double).
do not change the wrapping, but change the internal zoom of the
IlvText to adjust to the
new size, by calling applyTransform(IlvTransformer).setAutoWrappingResizeMode(int),
Constant Field Valuespublic static final int SIZE_AUTO_WRAPPING
moveResize(IlvRect) and resize(double, double).
change the wrapping width and height but not the internal zoom of the
IlvText.
This mode makes only sense when the wrapping mode is not
WRAP_NONE.
If the wrapping mode is WRAP_NONE, the object cannot be
resized.setAutoWrappingResizeMode(int),
Constant Field Valuespublic static final int ZOOM_AUTO_WRAPPING
moveResize(IlvRect) and resize(double, double).
change the wrapping width and height and the internal zoom of the
IlvText.
The wrapping width and height are
changed to match as much as possible the given aspect ratio, then the
IlvText is zoomed while keeping the aspect ratio to match
as much as possible the given size. This mode is suitable if you want
to display an automatically wrapped label in a given area at maximal
possible zoom. This mode is relatively slow and does not support
rotated labels.
This mode makes only sense when the wrapping mode is not
WRAP_NONE and does not include the WRAP_TRUNCATE
flag.
If the wrapping mode is WRAP_NONE, the object is resized
by changing the internal zoom while keeping the aspect ratio.setAutoWrappingResizeMode(int),
Constant Field Valuespublic IlvText()
IlvText instance with (0, 0)
as anchor point and an empty text.IlvText(IlvPoint, String)public IlvText(IlvPoint anchor, String text)
IlvText instance with a specified anchor point.anchor - the anchor point in manager coordinates.text - the text to be displayed.setAnchorPoint(IlvPoint),
setAnchorPosition(int),
setLabel(String)public IlvText(IlvText source)
IlvText instance equivalent to the source
one.source - The IlvText to be copied.public IlvText(IlvInputStream stream) throws IlvReadFileException
IlvText instance from an IlvInputStream.stream - the input streamIlvReadFileException - if the format is not correct.public IlvGraphic copy()
IlvText instance.copy in class IlvGraphicIlvGraphic instance.IlvGraphicpublic void draw(Graphics dst, IlvTransformer t)
IlvText object.draw in class IlvGraphicdst - The destination Graphics.t - The view transformation used to draw the object.IlvGraphic.callDraw(Graphics,IlvTransformer),
IlvGraphic.boundingBox(IlvTransformer),
IlvGraphic.zoomable(),
IlvGraphicpublic final IlvTransformer getTransformer()
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.public IlvRect boundingBox(IlvTransformer t)
IlvText.boundingBox in class IlvGraphict - The view transformer used to draw the object.IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer),
IlvGraphic.zoomable(),
IlvGraphicpublic void applyTransform(IlvTransformer t)
IlvText.
This can be used to rotate or scale the text.applyTransform in class IlvGraphict - The transformer to be applied.IlvGraphicpublic void moveResize(IlvRect size)
getAutoWrappingResizeMode() are:
NO_AUTO_WRAPPING -
This method calls IlvGraphic.moveResize(IlvRect), which in
turn calls applyTransform(IlvTransformer).
The wrapping width and height are not changed, but the
internal zoom of the IlvText is changed to adjust to the
new size.
SIZE_AUTO_WRAPPING -
This method changes the wrapping width and height to match the given
size and then translates the object so that the effective anchor
is at the new position. The internal zoom is not changed.
ZOOM_AUTO_WRAPPING -
This method changes the wrapping width and height to match the aspect
ratio of the given size, then zooms the object while keeping the aspect
ratio to match the given size. This is suitable if you want
to display an automatically wrapped label in a given area at maximal
possible zoom.
moveResize in class IlvGraphicsize - The new bounding rectangle of the object.setAutoWrappingResizeMode(int),
setWrappingWidth(double),
setWrappingHeight(double),
getEffectiveAnchorPoint()public void translate(double dx,
double dy)
translate in class IlvGraphicdx - The horizontal translation factor.dy - The vertical translation factor.IlvGraphic,
IlvGraphic.applyTransform(IlvTransformer)public void resize(double neww,
double newh)
getAutoWrappingResizeMode() are:
NO_AUTO_WRAPPING -
This method calls IlvGraphic.resize(double, double), which in
turn calls applyTransform(IlvTransformer).
The wrapping width and height are not changed, but the
internal zoom of the IlvText is changed to adjust to the
new size.
SIZE_AUTO_WRAPPING -
This method changes the wrapping width and height to match the given
size. The internal zoom is not changed.
ZOOM_AUTO_WRAPPING -
This method changes the wrapping width and height to match the aspect
ratio of the given size, then zooms the object while keeping the aspect
ratio to match the given size. This is suitable if you want
to display an automatically wrapped label in a given area at maximal
possible zoom.
resize in class IlvGraphicneww - The new widthnewh - The new heightsetAutoWrappingResizeMode(int),
setWrappingWidth(double),
setWrappingHeight(double),
getEffectiveAnchorPoint()public void rotate(IlvPoint center, double angle)
angle degrees around the point
center.
The center must be given in untransformed coordinates.
The default implementation calls applyTransform(ilog.views.IlvTransformer) to rotate
the graphic object.rotate in class IlvGraphiccenter - The center of the rotation.angle - The rotation angle in degrees.IlvGraphic,
applyTransform(IlvTransformer)public final void setAnchorPoint(IlvPoint anchor)
getTransformer()) the text
will be attached to.anchor - the anchor point.setAnchorPosition(int)public final IlvPoint getAnchorPoint()
getTransformer()) the text
is attached to.getAnchorPosition()public final IlvPoint getEffectiveAnchorPoint()
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:
IlvConstants.LEFT or
IlvConstants.LEADING. If the text is multiline text
and the lines have different widths, the maximum width of all lines
defines the corners of each line.
IlvConstants.RIGHT or
IlvConstants.TRAILING. If the text is multiline text
and the lines have different widths, the maximum width of all lines
defines the corners of each line.
IlvConstants.CENTER.public final void setAnchorPosition(int position)
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.
setAnchorPoint(IlvPoint)public final int getAnchorPosition()
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.
setAnchorPoint(IlvPoint)public IlvPoint[] getAnchorPoints(boolean leading, IlvTransformer t)
IlvConstants.LEADING or IlvConstants.LEFT,
while the trailing anchor points are not aligned; and it is just the
opposite when the text alignment is
IlvConstants.TRAILING or IlvConstants.RIGHT.
leading - Whether to calculate the leading or trailing anchors.t - The transformer to draw this text in the view.setAlignment(int)public void setLabel(String label)
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.
applyToObject method of the manager.
setLabel in interface IlvLabelInterfacelabel - the new label.public String getLabel()
IlvText.
This method returns the label even if it was set via
setAttributedLabel(java.text.AttributedString).getLabel in interface IlvLabelInterfacesetLabel(String)public void setAttributedLabel(AttributedString label)
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.
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.
applyToObject method of the manager.
label - the new label.TextAttributepublic AttributedString getAttributedLabel()
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).public void addLabelAttribute(AttributedCharacterIterator.Attribute attribute, Object value)
AttributedString.addAttribute(java.text.AttributedCharacterIterator.Attribute, Object).
applyToObject method of the manager.
attribute - The attribute key.value - The value of the attribute; may be null.IllegalArgumentException - if the AttributedString has length 0.
(attributes cannot be applied to a 0-length range).addLabelAttribute(java.text.AttributedCharacterIterator.Attribute, Object, int, int),
TextAttributepublic void addLabelAttribute(AttributedCharacterIterator.Attribute attribute, Object value, int beginIndex, int endIndex)
AttributedString.addAttribute(java.text.AttributedCharacterIterator.Attribute, Object, int, int).
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.
applyToObject method of the manager.
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.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.TextAttributepublic void addLabelAttributes(Map<? extends AttributedCharacterIterator.Attribute,?> attributes, int beginIndex, int endIndex)
AttributedString.addAttributes(Map, int, int).
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.
applyToObject method of the manager.
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.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.addLabelAttribute(java.text.AttributedCharacterIterator.Attribute, Object, int, int),
TextAttributepublic boolean supportMultiline()
true for IlvText.supportMultiline in interface IlvLabelInterfacepublic final boolean isTruncated()
IlvText.WRAP_TRUNCATE
bit, the label might not be fully visible, as it can get truncated
and an ellipsis (...) is displayed instead of the remaining parts of
the label. This method returns
true if the label is truncated, and
false if the label is fully visible.setWrappingMode(short)public IlvRect getLabelBBox(IlvTransformer t)
IlvText.
It is equivalent to boundingBox(IlvTransformer) without the margins.getLabelBBox in interface IlvLabelInterfacet - the transformer used to draw the graphic object.public void setFont(Font font)
Font used to draw the entire IlvText.
setFont in interface IlvFontInterfacefont - The new font.setAttributedLabel(java.text.AttributedString)public Font getFont()
Font used to draw the text.getFont in interface IlvFontInterfacepublic final boolean isAntialiasing()
true if the anti-aliasing mode
of the text is on. The default value is false.public final void setAntialiasing(boolean set)
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.public final boolean isStrikethrough()
true if the entire text has strikethrough attribute.
The default value is false.public final void setStrikethrough(boolean set)
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.
setAttributedLabel(java.text.AttributedString)public final boolean isUnderline()
true if the entire text has underline attribute.
The default value is false.public final void setUnderline(boolean set)
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.
setAttributedLabel(java.text.AttributedString)public int getOutlineMode()
OUTLINE_DISABLED,
OUTLINE_ONLY, OUTLINE_FRONT, and OUTLINE_BACK.setOutlineMode(int)public void setOutlineMode(int mode)
mode - Must be one of the following values: OUTLINE_DISABLED,
OUTLINE_ONLY, OUTLINE_FRONT, and OUTLINE_BACK.getOutlineMode()public final boolean isFractionalMetrics()
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.public final void setFractionalMetrics(boolean set)
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.public void setForeground(Color c)
IlvBlinkingColor.setForeground in class IlvGraphicc - The new color.IlvGraphic.draw(Graphics, IlvTransformer),
IlvGraphic.setBackground(Color),
IlvGraphic.setFillOn(boolean),
IlvGraphic.setStrokeOn(boolean),
IlvGraphicpublic Color getForeground()
Color.BLACK.public void setOutlineColor(Color c)
IlvBlinkingColor.c - The new outline color.public Color getOutlineColor()
Color.BLACK.public void setBackground(Color c)
setFillPaint(java.awt.Paint).setBackground in class IlvGraphicc - The new color.IlvGraphic.draw(Graphics, IlvTransformer),
IlvGraphic.setForeground(Color),
IlvGraphic.setFillOn(boolean),
IlvGraphic.setStrokeOn(boolean),
IlvGraphicpublic void setFillPaint(Paint paint)
Paint of the object, i.e the
paint server used to fill the background rectangle.
This property supports
IlvBlinkingPaint.paint - the new Paint object.public Paint getFillPaint()
Paint object used to fill the background
rectangle. The default value is Color.GRAY.setFillPaint(java.awt.Paint)protected Paint adaptPaint(Shape shape, Paint paint)
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.shape - The shape parameter that the returned Paint
should fit.paint - The initial Paint object.isPaintAbsolute()public final boolean isPaintAbsolute()
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.public final void setPaintAbsolute(boolean set)
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.public final void setFillOn(boolean value)
setFillOn in class IlvGraphicvalue - true if fill is on.IlvGraphic.draw(Graphics, IlvTransformer),
IlvGraphic.setBackground(Color),
IlvGraphic.setForeground(Color),
IlvGraphic.setStrokeOn(boolean),
IlvGraphicpublic final boolean isFillOn()
true if the background rectangle
of the text is drawn.setFillPaint(java.awt.Paint),
setFillOn(boolean)public final void setStrokeOn(boolean value)
setStrokeOn in class IlvGraphicvalue - true if stroke is on.IlvGraphic.draw(Graphics, IlvTransformer),
IlvGraphic.setBackground(Color),
IlvGraphic.setForeground(Color),
IlvGraphic.setFillOn(boolean),
IlvGraphicpublic final boolean isStrokeOn()
true if the frame of the background rectangle
of the text is drawn.setStrokeColor(Color),
setStrokeOn(boolean)public final void setStrokeColor(Color c)
IlvBlinkingColor.c - The new color.getStrokeColor()public final Color getStrokeColor()
getForeground().public final boolean isKeepingAspectRatio()
true if the text keeps the aspect ratio;
otherwise it returns false.
When resizing the text while the auto wrapping mode is off, the text
changes the zoom level according to the desired size. This can cause
different zoom levels along the x and y axes. This
causes a distorted label.
When KeepingAspectRatio is true, the text will
verify each modification of its internal transformer so that the zoom factor
remains the same along the x axis and the y axis.
The default value is false.setKeepingAspectRatio(boolean),
setAutoWrappingResizeMode(int)public final void setKeepingAspectRatio(boolean set)
true, the text will
verify each modification of its internal transformer so that the zoom factor
remains the same along the x axis and the y axis.
The default value is false.
isKeepingAspectRatio(),
setAutoWrappingResizeMode(int)@Deprecated public final void setAutoWrappingSizeMode(boolean value)
setAutoWrappingResizeMode(int).false.value - true if the auto wrapping size mode is needed.getWrappingWidth(),
getWrappingHeight(),
getAnchorPoint()@Deprecated public final boolean isAutoWrappingSizeMode()
getAutoWrappingResizeMode().false.public final void setAutoWrappingResizeMode(int mode)
moveResize(IlvRect) and
resize(double, double).
The options are:
NO_AUTO_WRAPPING - The wrapping is not changed, but the
internal zoom of the IlvText is changed to adjust to the
new size, by calling applyTransform(IlvTransformer).
This is the default value.
SIZE_AUTO_WRAPPING - The wrapping width and height are
changed 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.
The internal zoom is not changed.
WRAP_NONE.
If the wrapping mode is WRAP_NONE, the object cannot be
resized.
ZOOM_AUTO_WRAPPING - The wrapping width and height are
changed to match as much as possible the given aspect ratio, then the
IlvText is zoomed while keeping the aspect ratio to match
as much as possible the given size. This mode is suitable if you want
to display an automatically wrapped label in a given area at maximal
possible zoom. This mode is relatively slow and does not support
rotated labels. 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.
WRAP_NONE and does not include the WRAP_TRUNCATE
flag.
If the wrapping mode is WRAP_NONE, the object is resized
by changing the internal zoom while keeping the aspect ratio.
mode - The auto wrapping resize modegetAutoWrappingResizeMode(),
getWrappingMode(),
getWrappingWidth(),
getWrappingHeight()public final int getAutoWrappingResizeMode()
NO_AUTO_WRAPPING.setAutoWrappingResizeMode(int)public final void setWrappingMode(short value)
IlvText.WRAP_NONE.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_CHARACTER : the text is automatically broken into
characters using a character instance java.text.BreakIterator which will
break the text where appropriate to best fit the getWrappingWidth()
width. It will break the text at character boundaries.
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.
public final short getWrappingMode()
IlvText.WRAP_NONE.setWrappingMode(short)public final void setWrappingWidth(double width)
getWrappingMode() is set to
WRAP_WORD,
WRAP_CHARACTER,
WRAP_TRUNCATE or a combination of the these. The default
value is 100. The value must be positive.width - the new wrapping widthpublic final double getWrappingWidth()
getWrappingMode() is set to
WRAP_WORD,
WRAP_CHARACTER,
WRAP_TRUNCATE or a combination of the these. The default
value is 100.public final void setWrappingHeight(double height)
getWrappingMode() is set to
WRAP_WORD,
WRAP_CHARACTER,
WRAP_TRUNCATE or a combination of the these. The default
value is 100. The value must be positive.height - the new wrapping heightpublic final double getWrappingHeight()
getWrappingMode() is set to
WRAP_WORD,
WRAP_CHARACTER,
WRAP_TRUNCATE or a combination of the these. The default
value is 100.public void setOutlineThickness(double thickness)
0.thickness - The new outline thickness.public double getOutlineThickness()
0.public final void setLeftMargin(double margin)
applyToObject
method of the manager.
The default value is 0.public final double getLeftMargin()
0.setLeftMargin(double)public final void setRightMargin(double margin)
applyToObject
method of the manager.
The default value is 0.public final double getRightMargin()
0.setRightMargin(double)public final void setTopMargin(double margin)
applyToObject
method of the manager.
The default value is 0.public final double getTopMargin()
0.setTopMargin(double)public final void setBottomMargin(double margin)
applyToObject
method of the manager.
The default value is 0.public final double getBottomMargin()
0.setTopMargin(double)public final void setAlignment(int alignment)
alignment - One of the following values:
IlvConstants.LEFT: left aligned text
IlvConstants.RIGHT: right aligned text.
IlvConstants.CENTER: centered text.
IlvConstants.LEADING: leading edge aligned text (the default).
IlvConstants.TRAILING: trailing edge aligned text.
public final int getAlignment()
IlvConstants.LEFT: left aligned text
IlvConstants.RIGHT: right aligned text.
IlvConstants.CENTER: centered text.
IlvConstants.LEADING: leading edge aligned text (the default).
IlvConstants.TRAILING: trailing edge aligned text.
public void setRotationAlignmentThresholdAngle(double angle)
setRotationAlignmentAngle(double),
getRotationAlignmentThresholdAngle()public final double getRotationAlignmentThresholdAngle()
setRotationAlignmentThresholdAngle(double)public void setRotationAlignmentAngle(double angle)
setRotationAlignmentThresholdAngle(double)) specified whether and which
of both axes is used to align the multiple lines of text.
Valid values are 0 (inclusive) to 180 degree (exclusive).
If the rotation alignment threshold angle is 0, or if the text object
contains only a single line text, or if the text object is not rotated
relative to the rotation alignment axis, the rotation alignment angle
has no effect.setRotationAlignmentThresholdAngle(double),
getRotationAlignmentAngle()public final double getRotationAlignmentAngle()
setRotationAlignmentAngle(double)public final void setInterlineSpacing(double spacing)
-1 which means that the
IlvText will let each line decide
(IlvTextLayout.getLeading) what is the
best interline spacing. It means you should use this method only if you want
to override that behavior.spacing - the new interline spacing or -1 for default behavior.public final double getInterlineSpacing()
-1 which means that the
IlvText will let each line decide
(IlvTextLayout.getLeading) what is the best interline spacing.setInterlineSpacing(double)public boolean contains(IlvPoint p, IlvPoint tp, IlvTransformer t)
contains in class IlvGraphicp - The point to be tested.tp - The point p transformed by the transformer
t.t - The transformation used to draw the object.true if the point lies inside this graphic object.IlvGraphicpublic Shape getCaretShape(IlvTextSelection.Range range, IlvTransformer t)
Range. The returned shape is used to draw the background of
the selected characters. Therefore, users can see which characters are selected.
getCaretShape in interface IlvTextInterfacerange - The range indicates the selected characters.t - The transformer used while drawing the graphic object being edited.public int pickCharacter(IlvPoint click, IlvTransformer t)
pickCharacter in interface IlvTextInterfaceclick - The position where the mouse is clicked, already transformed by
the specified IlvTransformer.t - The transformer used while drawing the label.public int lineCount()
lineCount in interface IlvTextInterface1 is returned.lineOffset(int)public int lineOffset(int index)
lineOffset in interface IlvTextInterfaceindex - Specifies the line. The first line has index 0.lineCount()public IlvSelection makeSelection()
IlvTextSelection.makeSelection in class IlvGraphicIlvTextSelection.IlvDrawSelectionpublic void write(IlvOutputStream stream) throws IOException
IlvText to an IVL file.write in interface IlvPersistentObjectwrite in class IlvGraphicstream - The output stream to write this graphic object to.IOException - thrown when an exception occurs during
the write operation for this object.public static void SetTransformerDependentRendering(boolean flag)
IlvText objects are rendered with
a strategy that requires re-rendering when the transformer changes.
This is slower and uses nearly twice as much memory per text object,
but some Chinese and Japanese fonts cannot be rendered
with the faster default strategy where the rendering is pre-calculated
independent from the transformer.
In JDK 1.4, the slow transformer dependent mode was not required.
In JDK 1.5 and later, the slow mode might be required. This depends
on the operating system, on the available fonts, and on
the status of the Sun bug list related to Chinese and Japanese rendering.
false.public static boolean IsTransformerDependentRendering()
IlvText objects are rendered with
a strategy that requires re-rendering when the transformer changes.
This is slower and uses nearly twice as much memory per text object,
but some Chinese and Japanese fonts cannot be rendered
with the faster default strategy where the rendering is pre-calculated
independent from the transformer.public boolean usesBidiMarkers()
true if in-place editing implementation uses markers,
which should be taken into account in hit-to-point and point-to-hit
calculations.usesBidiMarkers in class IlvGraphicpublic boolean isBaseTextDirectionSensitive()
true because the bounding box of this object
depends on its text direction.isBaseTextDirectionSensitive in class IlvGraphicpublic void baseTextDirectionChanged(int oldBaseTextDirection,
int newBaseTextDirection)
baseTextDirectionChanged in class IlvGraphicoldBaseTextDirection - Resolved base text direction of this object before the change.newBaseTextDirection - Resolved base text direction of this object after the change.isBaseTextDirectionSensitive()public void componentOrientationChanged(ComponentOrientation oldOri, ComponentOrientation newOri)
componentOrientationChanged in class IlvGraphicoldOri - Orientation of this object before the orientation change.newOri - Orientation of this object after the orientation change.IlvGraphic.isComponentOrientationSensitive()public boolean isLocaleSensitive()
true if the bounding box of this object depends
on the locale of this object.isLocaleSensitive in class IlvGraphicpublic void localeChanged(ULocale oldLocale, ULocale newLocale)
localeChanged in class IlvGraphicoldLocale - Locale of this object before the locale change.newLocale - Locale of this object after the locale change.isLocaleSensitive()© Copyright Rogue Wave Software, Inc. 1997, 2017. All Rights Reserved.