ilog.views.graphic
Class IlvLabel

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvLabel
All Implemented Interfaces:
IlvFontInterface, IlvLabelInterface, IlvTextInterface, IlvPersistentObject, Transferable, Serializable
Direct Known Subclasses:
IlvFilledLabel

public class IlvLabel
extends IlvGraphic
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:

The width of the IlvLabel instance is calculated in function on the length of the label string.

Example

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

About Graphic Objects

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.

See Also:
IlvPoint, IlvManager, IlvManagerView, Serialized Form

Constructor Summary
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.
 
Method Summary
 void applyTransform(IlvTransformer t)
          Applies a transformation to the shape of the object.
 IlvRect boundingBox(IlvTransformer t)
          Returns the bounding rectangle of the object.
 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.
 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.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 boolean zoomable()
          Returns true if the object is zoomable.
 
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, moveResize, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setBackground, setEditable, setFillOn, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipText, setVisible, translate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvLabel

public IlvLabel()
Creates a new IlvLabel centered in (0, 0) with an empty label.

Since:
JViews 6.0
See Also:
IlvLabel(IlvPoint, String)

IlvLabel

public IlvLabel(IlvPoint center,
                String label)
Creates a new IlvLabel.

Parameters:
center - The center of the label.
label - The label.

IlvLabel

public IlvLabel(IlvLabel source)
Creates a new IlvLabel by copying an existing one.

Parameters:
source - The source label.

IlvLabel

public IlvLabel(IlvInputStream stream)
         throws IlvReadFileException
Reads the object from an IlvInputStream.

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

copy

public IlvGraphic copy()
Copies the object. This method copies the object by calling the copy constructor.

Specified by:
copy in class IlvGraphic
Returns:
A copy of the object.
See Also:
IlvGraphic

setLabel

public void setLabel(String s)
Changes the label.

Specified by:
setLabel in interface IlvLabelInterface
Parameters:
s - The new label.
See Also:
getLabel()

getLabel

public String getLabel()
Returns the label.

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

supportMultiline

public boolean supportMultiline()
Returns false since this object does not support multiline text.

Specified by:
supportMultiline in interface IlvLabelInterface

setCenter

public void setCenter(IlvPoint center)
Changes the center point of the label.

Parameters:
center - The new center point.

getCenter

public IlvPoint getCenter()
Returns the center point of the label.


isAntialiasing

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


setAntialiasing

public void setAntialiasing(boolean set)
Changes the anti-aliasing mode of the label. Changing this mode may change the bounding box of the object.


draw

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

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

zoomable

public boolean zoomable()
Returns true if the object is zoomable. Otherwise it returns false.

Overrides:
zoomable in class IlvGraphic
Returns:
false because this object is not zoomable.
See Also:
IlvGraphic, IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer), IlvGraphic.boundingBox(IlvTransformer), IlvManager

boundingBox

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

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

getLabelBBox

public IlvRect getLabelBBox(IlvTransformer t)
Returns the bounding area where the label is displayed. The area is the bounding box of the object.

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

applyTransform

public void applyTransform(IlvTransformer t)
Applies a transformation to the shape of the object. The label is nonzoomable; only the center point will be transformed.

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

makeSelection

public IlvSelection makeSelection()
Creates a selection object for this graphic object. Since JViews 7.5, this function returns an unresizable 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.

Overrides:
makeSelection in class IlvGraphic
Since:
JViews 5.0
See Also:
IlvDrawSelection

setForeground

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

Overrides:
setForeground in class IlvGraphic
Parameters:
c - The new color.
See Also:
getForeground()

getForeground

public Color getForeground()
Returns the color of the text.

See Also:
setForeground(java.awt.Color)

setFont

public void setFont(Font font)
Changes the font of the object.

Specified by:
setFont in interface IlvFontInterface
Parameters:
font - The new font.
See Also:
getFont()

getFont

public Font getFont()
Returns the font of the object.

Specified by:
getFont in interface IlvFontInterface
See Also:
setFont(java.awt.Font)

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the object to an IlvOutputStream. You should not call this method directly; instead, you should use the write methods of the manager.

Specified by:
write in interface IlvPersistentObject
Overrides:
write in class IlvGraphic
Parameters:
stream - The output stream.
Throws:
IOException - thrown when an exception occurs during the write operation for this object.

toString

public String toString()
Returns a string representation of the graphic object. The method returns a string that is the concatenation of the string returned by IlvGraphic.toString() with the label (see getLabel()).

Overrides:
toString in class IlvGraphic
Since:
JViews 3.5
See Also:
IlvGraphic.getName()

contains

public boolean contains(IlvPoint p,
                        IlvPoint tp,
                        IlvTransformer t)
Tests if a point lies within the outline of the object.

Overrides:
contains in class IlvGraphic
Parameters:
p - The point to be tested.
tp - The point p transformed by the transformer t.
t - The transformation used to draw the object.
Returns:
true if the point lies inside this graphic object.
See Also:
IlvGraphic

getCaretShape

public Shape getCaretShape(IlvTextSelection.Range range,
                           IlvTransformer t)
This function is called to get the shape enveloping the characters specified by the 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.

Specified by:
getCaretShape in interface IlvTextInterface
Parameters:
range - The range indicates the selected characters.
t - The transformer used while drawing the graphic object being edited.
Returns:
The shape used to highlight the selected characters.
Since:
JViews 7.5

pickCharacter

public int pickCharacter(IlvPoint click,
                         IlvTransformer t)
This function is called when a user is clicking the label to hit-test which character is clicked.

Specified by:
pickCharacter in interface IlvTextInterface
Parameters:
click - The position where the mouse is clicked, already transformed by the specified IlvTransformer.
t - The transformer used while drawing the label.
Returns:
The index of the character on which the mouse is clicked. Returns -1, if there is no character there.
Since:
JViews 7.5

lineCount

public int lineCount()
Indicates the number of lines.

Specified by:
lineCount in interface IlvTextInterface
Returns:
Always 1.
Since:
JViews 7.5
See Also:
IlvTextInterface.lineOffset(int)

lineOffset

public int lineOffset(int index)
Returns the character offset for a given line.

Specified by:
lineOffset in interface IlvTextInterface
Parameters:
index - The line index. The first line in the label has index 0.
Returns:
Always 0;
Since:
JViews 7.5
See Also:
IlvTextInterface.lineCount()


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.