public class IlvLabel extends IlvBidiGraphic implements IlvFontInterface, IlvTextInterface
IlvLabel represents a simple graphic object that shows a single
line of text. This object is not zoomable.
The default values for an IlvLabel instance are as
follows:
Color.blackIlvPoint(0, 0)
The width of the IlvLabel instance is calculated in function
on the length of the label string.
The following code example shows how to use an IlvLabel in a
simple Java application:
IlvGrapher grapher = new IlvGrapher(); IlvGraphic node1 = new IlvLabel(new IlvPoint(40,40), "node 1"); grapher.addNode(node1, true); IlvGraphic node2 = new IlvLabel(new IlvPoint(240, 40), "node 2"); grapher.addNode(node2, true); IlvLinkImage link = new IlvLinkImage(node1, node2, true); grapher.addLink(link, true);
The following image shows the graphic objects created in the code example:
IlvLabel 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.
IlvPoint,
IlvManager,
IlvManagerView,
Serialized Form| Constructor and Description |
|---|
IlvLabel()
Creates a new
IlvLabel centered in (0, 0) with an
empty label. |
IlvLabel(IlvInputStream stream)
Reads the object from an
IlvInputStream. |
IlvLabel(IlvLabel source)
Creates a new
IlvLabel by copying an existing one. |
IlvLabel(IlvPoint center,
String label)
Creates a new
IlvLabel. |
| Modifier and Type | Method and Description |
|---|---|
void |
applyTransform(IlvTransformer t)
Applies a transformation to the shape of the object.
|
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 object.
|
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()
Copies the object.
|
void |
draw(Graphics dst,
IlvTransformer t)
Draws the object.
|
Shape |
getCaretShape(IlvTextSelection.Range range,
IlvTransformer t)
This function is called to get the shape enveloping the characters specified by the
Range. |
IlvPoint |
getCenter()
Returns the center point of the label.
|
Font |
getFont()
Returns the font of the object.
|
Color |
getForeground()
Returns the color of the text.
|
String |
getLabel()
Returns the label.
|
IlvRect |
getLabelBBox(IlvTransformer t)
Returns the bounding area where the label is displayed.
|
boolean |
isAntialiasing()
Returns
true if the anti-aliasing mode
of the label is on. |
boolean |
isBaseTextDirectionSensitive()
Returns
true because the bounding box of this object
depends on its text direction. |
int |
lineCount()
Indicates the number of lines.
|
int |
lineOffset(int index)
Returns the character offset for a given line.
|
IlvSelection |
makeSelection()
Creates a selection object for this graphic object.
|
int |
pickCharacter(IlvPoint click,
IlvTransformer t)
This function is called when a user is clicking the label to hit-test which character
is clicked.
|
void |
setAntialiasing(boolean set)
Changes the anti-aliasing mode of the label.
|
void |
setCenter(IlvPoint center)
Changes the center point of the label.
|
void |
setFont(Font font)
Changes the font of the object.
|
void |
setForeground(Color c)
Changes the color of the text.
|
void |
setLabel(String s)
Changes the label.
|
boolean |
supportMultiline()
Returns
false
since this object does not support multiline text. |
String |
toString()
Returns a string representation of the graphic 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 object to an
IlvOutputStream. |
boolean |
zoomable()
Returns
true if the object is zoomable. |
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, isLocaleSensitive, isMovable, isPersistent, isSelectable, isVisible, localeChanged, move, move, moveResize, needsViewNotification, notifyObjectInteractorToManager, processActionEvent, reDraw, registerBlinkingResource, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setBackground, setBlinkingAction, setBlinkingOffPeriod, setBlinkingOnPeriod, setEditable, setFillOn, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipBaseTextDirection, setToolTipText, setVisible, setZOrderIndex, translate, updateNeedsViewNotification, viewAddedOrRemovedpublic IlvLabel()
IlvLabel centered in (0, 0) with an
empty label.IlvLabel(IlvPoint, String)public IlvLabel(IlvPoint center, String label)
IlvLabel.center - The center of the label.label - The label.public IlvLabel(IlvLabel source)
IlvLabel by copying an existing one.source - The source label.public IlvLabel(IlvInputStream stream) throws IlvReadFileException
IlvInputStream.stream - The input stream.IlvReadFileException - if the format is not correct.public IlvGraphic copy()
copy in class IlvGraphicIlvGraphicpublic void setLabel(String s)
setLabel in interface IlvLabelInterfaces - The new label.getLabel()public String getLabel()
getLabel in interface IlvLabelInterfacesetLabel(java.lang.String)public boolean supportMultiline()
false
since this object does not support multiline text.supportMultiline in interface IlvLabelInterfacepublic void setCenter(IlvPoint center)
center - The new center point.public IlvPoint getCenter()
public final boolean isAntialiasing()
true if the anti-aliasing mode
of the label is on.public void setAntialiasing(boolean set)
public void draw(Graphics dst, IlvTransformer t)
draw in class IlvGraphicdst - The destination Graphics.t - The transformation used to draw the object.IlvGraphic.callDraw(Graphics,IlvTransformer),
IlvGraphic.boundingBox(IlvTransformer),
IlvGraphic.zoomable(),
IlvGraphicpublic boolean zoomable()
true if the object is zoomable. Otherwise it returns
false.zoomable in class IlvGraphicfalse because this object is not zoomable.IlvGraphic,
IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer),
IlvGraphic.boundingBox(IlvTransformer),
IlvManagerpublic IlvRect boundingBox(IlvTransformer t)
boundingBox in class IlvGraphict - The transformer used to draw the object.IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer),
IlvGraphic.zoomable(),
IlvGraphicpublic IlvRect getLabelBBox(IlvTransformer t)
getLabelBBox in interface IlvLabelInterfacet - The transformer used to draw the object.public void applyTransform(IlvTransformer t)
applyTransform in class IlvGraphict - The transformer to be applied.IlvGraphicpublic IlvSelection makeSelection()
IlvTextSelection object. Before JViews 7.5,
because this object cannot be resized using the interactor,
the implementation of this method creates an instance
of the class IlvUnresizeableDrawSelection.makeSelection in class IlvGraphicIlvDrawSelectionpublic void setForeground(Color c)
IlvBlinkingColor.setForeground in class IlvGraphicc - The new color.getForeground()public Color getForeground()
setForeground(java.awt.Color)public void setFont(Font font)
setFont in interface IlvFontInterfacefont - The new font.getFont()public Font getFont()
getFont in interface IlvFontInterfacesetFont(java.awt.Font)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 void write(IlvOutputStream stream) throws IOException
IlvOutputStream.
You should not call this
method directly; instead, you should use the write
methods of the manager.write in interface IlvPersistentObjectwrite in class IlvGraphicstream - The output stream.IOException - thrown when an exception occurs during
the write operation for this object.public String toString()
IlvGraphic.toString() with the label
(see getLabel()).toString in class IlvGraphicIlvGraphic.getName()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. So users can see which characters are selected.
In case the range is collapsed, this function will return a shape used to render the insertion caret.
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 IlvTextInterfaceIlvTextInterface.lineOffset(int)public int lineOffset(int index)
lineOffset in interface IlvTextInterfaceindex - The line index. The first line in the label has index 0.IlvTextInterface.lineCount()© Copyright Rogue Wave Software, Inc. 1997, 2017. All Rights Reserved.