ilog.views.graphic
Class IlvGraphicHandle

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvGraphicHandle
All Implemented Interfaces:
IlvPersistentObject, Transferable, Serializable
Direct Known Subclasses:
IlvExpandCollapseRenderer.SubGraphNode, IlvGraphicHandleBag, IlvSubGraphRenderer.CollapsedGraphic, IlvTransformedGraphic

public class IlvGraphicHandle
extends IlvGraphic

An IlvGraphicHandle object, called a handle, is used to reference an IlvGraphic object. Handles make it possible to indirectly access the referenced object. Complex graphic objects can thus be "duplicated" as many time as you like by simply creating new handle objects which all reference the same original graphic object. Referencing a complex graphic object instead of copying it helps you to save computing resources. Note that two handles that reference the same object share the same bounding rectangle, so this class is useful when the handles are in different managers. To put in the same manager several handles referencing the same object, you may use the class IlvTransformedGraphic.

See Also:
Serialized Form

Constructor Summary
  IlvGraphicHandle(IlvGraphic object, boolean owner)
          Creates a new IlvGraphicHandle.
protected IlvGraphicHandle(IlvGraphic object, boolean owner, boolean delegateMoveResize)
          Creates a new IlvGraphicHandle.
  IlvGraphicHandle(IlvGraphicHandle source)
          Creates a new IlvGraphicHandle by copying an existing one.
  IlvGraphicHandle(IlvInputStream stream)
          Reads the object from an IlvInputStream.
 
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 whether a point lies within the outline of the object.
 IlvGraphic copy()
          Copies the object.
 void draw(Graphics dst, IlvTransformer t)
          Draws the object.
 IlvPoint getIntersectionWithOutline(IlvPoint innerPoint, IlvPoint outerPoint, IlvTransformer t)
          Returns the intersection of the line segment from inner point to outer point with the shape of the graphic object.
 IlvGraphic getObject()
          Returns the referenced object.
protected  JPopupMenu getOriginalPopupMenu(IlvPoint p, IlvTransformer t, IlvManagerView view, IlvPopupMenuManager popupManager)
          This is the original implementation of getPopupMenu from the superclass to retrieve the popup menu.
 JPopupMenu getPopupMenu(IlvPoint p, IlvTransformer t, IlvManagerView view, IlvPopupMenuManager popupManager)
          Returns the Swing popup menu to display when the popup is triggered while the mouse pointer is at a specified location inside the graphic object.
 String getToolTipText(IlvPoint p, IlvTransformer t)
          Returns the tooltip text to display when the mouse pointer is at a specified location inside the graphic object.
 boolean inside(IlvRect rect, IlvRect trect, IlvTransformer t)
          Tests whether a rectangle contains the object.
 boolean intersects(IlvRect rect, IlvRect trect, IlvTransformer t)
          Tests whether a rectangle overlaps the object.
 boolean isOwner()
          Returns the ownership property of the object.
 boolean isPersistent()
          If this method returns true the IlvGraphic instance will be saved in IVL files.
 void move(float x, float y)
          Moves the object.
 void move(IlvPoint p)
          Moves the object.
 void moveResize(IlvRect size)
          Resizes the object.
 void resize(float neww, float newh)
          Resizes the object.
 void rotate(IlvPoint center, double angle)
          Rotates the object.
 void scale(double scalex, double scaley)
          Resizes the object.
 void setBackground(Color c)
          Changes the background color of the object.
protected  void setDelegateMoveResize(boolean delegateMoveResize)
          Sets whether operations that change the position of the object are directly delegated to the referenced object.
 void setForeground(Color c)
          Changes the foreground color of the object.
 void setObject(IlvGraphic object)
          Changes the referenced object.
 void setOwner(boolean owner)
          Changes the ownership property of the object.
 void translate(float dx, float dy)
          Translates the 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, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenuName, getProperty, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, hasProperty, isDataFlavorSupported, isEditable, isInApplyToObject, isMovable, isSelectable, isVisible, makeSelection, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, setEditable, setFillOn, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipText, setVisible, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvGraphicHandle

public IlvGraphicHandle(IlvGraphic object,
                        boolean owner)
Creates a new IlvGraphicHandle.

Parameters:
object - the referenced object.
owner - if true then the referenced object will be copied when the handle is copied, otherwise the copy of the handle will reference the same object.

IlvGraphicHandle

protected IlvGraphicHandle(IlvGraphic object,
                           boolean owner,
                           boolean delegateMoveResize)
Creates a new IlvGraphicHandle. This constructor is mainly useful when creating subclasses of this class.

Parameters:
object - The referenced object.
owner - If true, the referenced object will be copied when the handle is copied, otherwise the copy of the handle will refer to the same object.
delegateMoveResize - If true, operations that change the position of the object are directly delegated to the referenced object.
Since:
JViews 8.0

IlvGraphicHandle

public IlvGraphicHandle(IlvGraphicHandle source)
Creates a new IlvGraphicHandle by copying an existing one. Note that the referenced object is copied only if the origin is owner of the reference.


IlvGraphicHandle

public IlvGraphicHandle(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

getObject

public final IlvGraphic getObject()
Returns the referenced object.


setObject

public void setObject(IlvGraphic object)
Changes the referenced object. Note that a call to this method can modify the bounding box of the graphic handle. For this reason, if the graphic handle is contained inside an IlvManager, this method can be called only using the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean) of the manager.


isOwner

public boolean isOwner()
Returns the ownership property of the object. If the handle owns the object it references, then copying the handle will copy the referenced object; otherwise the new handle is referencing the same object.

See Also:
setOwner(boolean)

setOwner

public void setOwner(boolean owner)
Changes the ownership property of the object. If the handle owns the object it references, then copying the handle will copy the referenced object; otherwise the new handle is referencing the same object.

See Also:
isOwner()

setDelegateMoveResize

protected void setDelegateMoveResize(boolean delegateMoveResize)
Sets whether operations that change the position of the object are directly delegated to the referenced object.

Since:
JViews 8.0

copy

public IlvGraphic copy()
Copies the object. Note that the referenced object will be copied only if the object is owner of the reference.

Specified by:
copy in class IlvGraphic
Returns:
a copy of the object.
See Also:
isOwner()

zoomable

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

Overrides:
zoomable in class IlvGraphic
See Also:
IlvGraphic, IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer), IlvGraphic.boundingBox(IlvTransformer), IlvManager

draw

public void draw(Graphics dst,
                 IlvTransformer t)
Draws the object. Calls draw on the referenced 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

boundingBox

public IlvRect boundingBox(IlvTransformer t)
Returns the bounding rectangle of the object. Calls boundingBox on the referenced 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

applyTransform

public void applyTransform(IlvTransformer t)
Applies a transformation to the shape of the object. Calls applyTransform on the referenced object.

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

contains

public boolean contains(IlvPoint p,
                        IlvPoint tp,
                        IlvTransformer t)
Tests whether a point lies within the outline of the object. Calls contains on the referenced 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 applied to the object when it was drawn.
Returns:
true if the point lies inside this graphic object.
See Also:
IlvGraphic

intersects

public boolean intersects(IlvRect rect,
                          IlvRect trect,
                          IlvTransformer t)
Tests whether a rectangle overlaps the object. Calls intersects on the referenced object.

Overrides:
intersects in class IlvGraphic
Parameters:
rect - the rectangle to be tested.
trect - the rectangle rect transformed by the transformer t.
t - the transformation that was applied to the object when it was drawn.
Returns:
true if the rectangle overlaps this graphic object.
See Also:
IlvGraphic

inside

public boolean inside(IlvRect rect,
                      IlvRect trect,
                      IlvTransformer t)
Tests whether a rectangle contains the object. Calls inside on the referenced object.

Overrides:
inside in class IlvGraphic
Parameters:
rect - the rectangle to be tested.
trect - the rectangle rect transformed by the transformer t.
t - the transformation that was applied to the object when it was drawn.
See Also:
IlvGraphic

getIntersectionWithOutline

public IlvPoint getIntersectionWithOutline(IlvPoint innerPoint,
                                           IlvPoint outerPoint,
                                           IlvTransformer t)
Returns the intersection of the line segment from inner point to outer point with the shape of the graphic object. This method is used the clip links against the shape of the node. The implementation of this method must be robust with respect to the input points: Even if innerPoint is not inside the graphic object, or if outerPoint is not outside the graphic object, it must return a valid point. For instance, if there is no intersection, it can return the start point.

Overrides:
getIntersectionWithOutline in class IlvGraphic
Parameters:
innerPoint - A point usually inside the graphic object, given in manager view coordinates.
outerPoint - A point usually outside of the graphic object, given in manager view coordinates.
t - The transformation used to draw the object.
Since:
JViews 8.1
See Also:
IlvClippingLinkConnector

move

public void move(float x,
                 float y)
Moves the object. Calls move on the referenced object.

Overrides:
move in class IlvGraphic
Parameters:
x - The new horizontal position.
y - The new vertical position.
See Also:
IlvGraphic, IlvGraphic.applyTransform(IlvTransformer)

move

public void move(IlvPoint p)
Moves the object. Calls move on the referenced object.

Overrides:
move in class IlvGraphic
Parameters:
p - The new position of the top-left corner.
See Also:
IlvGraphic, IlvGraphic.applyTransform(IlvTransformer)

moveResize

public void moveResize(IlvRect size)
Resizes the object. Calls moveResize on the referenced object.

Overrides:
moveResize in class IlvGraphic
Parameters:
size - The new bounding rectangle for this object.
See Also:
IlvGraphic, IlvGraphic.applyTransform(IlvTransformer)

translate

public void translate(float dx,
                      float dy)
Translates the object. Calls translate on the referenced object.

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

rotate

public void rotate(IlvPoint center,
                   double angle)
Rotates the object. Calls rotate on the referenced object.

Overrides:
rotate in class IlvGraphic
Parameters:
center - The center of the rotation.
angle - The rotation angle in degrees.
See Also:
IlvGraphic, IlvGraphic.applyTransform(IlvTransformer)

scale

public void scale(double scalex,
                  double scaley)
Resizes the object. Calls scale on the referenced object.

Overrides:
scale in class IlvGraphic
Parameters:
scalex - The horizontal scaling factor.
scaley - The vertical scaling factor.
See Also:
IlvGraphic, IlvGraphic.applyTransform(IlvTransformer)

resize

public void resize(float neww,
                   float newh)
Resizes the object. Calls resize on the referenced object.

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

setForeground

public void setForeground(Color c)
Changes the foreground color of the object. Calls setForeground on the referenced object.

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

setBackground

public void setBackground(Color c)
Changes the background color of the object. Calls setBackground on the referenced object.

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

getToolTipText

public String getToolTipText(IlvPoint p,
                             IlvTransformer t)
Returns the tooltip text to display when the mouse pointer is at a specified location inside the graphic object. It tries to retrieve the tooltip text on the referenced object. If this fails, it tries to retrieve the tooltip text on this object.

Note that you must enable the tooltip mechanism for the manager view by calling the static method IlvToolTipManager.registerView(ilog.views.IlvManagerView).

Overrides:
getToolTipText in class IlvGraphic
Parameters:
p - The location of the mouse (in view coordinates).
t - The transformer that converts the coordinate system of this object (the manager coordinates) into the coordinate system of the manager view in which the tooltip is about to be displayed (the view coordinates).
Returns:
The tool tip at point p for transformation t, or null if no tool tip should be displayed.
See Also:
IlvGraphic, IlvGraphic.getToolTipText(), IlvGraphic.setToolTipText(String)

getPopupMenu

public JPopupMenu getPopupMenu(IlvPoint p,
                               IlvTransformer t,
                               IlvManagerView view,
                               IlvPopupMenuManager popupManager)
Returns the Swing popup menu to display when the popup is triggered while the mouse pointer is at a specified location inside the graphic object. It tries to retrieve the popup menu on the referenced object. If this fails, it tries to retrieve the popup menu on this object.

Note that you must enable the popup menu mechanism for the manager view by calling the static method IlvPopupMenuManager.registerView(ilog.views.IlvManagerView).

Overrides:
getPopupMenu in class IlvGraphic
Parameters:
p - The location of the mouse (in view coordinates).
t - The transformer that converts the coordinate system of this object (the manager coordinates) into the coordinate system of the manager view in which the tooltip is about to be displayed (the view coordinates).
view - The manager view that triggered the popup menu.
popupManager - The popup menu manager.
Returns:
The Swing popup menu, which can be null.
Since:
JViews 8.0
See Also:
IlvGraphic, IlvPopupMenuManager.registerView(ilog.views.IlvManagerView), IlvGraphic.getPopupMenu()

getOriginalPopupMenu

protected JPopupMenu getOriginalPopupMenu(IlvPoint p,
                                          IlvTransformer t,
                                          IlvManagerView view,
                                          IlvPopupMenuManager popupManager)
This is the original implementation of getPopupMenu from the superclass to retrieve the popup menu. Subclasses of this class might need access to the original implementation.

Parameters:
p - The location of the mouse (in view coordinates).
t - The transformer that converts the coordinate system of this object (the manager coordinates) into the coordinate system of the manager view in which the tooltip is about to be displayed (the view coordinates).
view - The manager view that triggered the popup menu.
popupManager - The popup menu manager.
Returns:
The Swing popup menu as retrieved by the superclass.
Since:
JViews 8.0

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the object to an IlvOutputStream.

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.

isPersistent

public boolean isPersistent()
If this method returns true the IlvGraphic instance will be saved in IVL files. The method returns true if the referenced object is persistent.

Overrides:
isPersistent in class IlvGraphic
Since:
JViews 8.0


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