ilog.views.graphic
Class IlvGraphicHandleSelection

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.IlvSelection
          extended by ilog.views.IlvHandlesSelection
              extended by ilog.views.graphic.IlvGraphicHandleSelection
All Implemented Interfaces:
IlvGraphicBag, IlvPersistentObject, Transferable, Serializable

public class IlvGraphicHandleSelection
extends IlvHandlesSelection
implements IlvGraphicBag

An IlvGraphicHandleSelection object is a selection that acts like a handle to another selection. It is used as selection for subclasses of IlvGraphicHandle.

Since:
JViews 8.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class ilog.views.IlvHandlesSelection
CIRCLE_SHAPE, defaultHandleBackgroundColor, defaultHandleColor, defaultHandleShape, defaultHandleSize, FILLED_CIRCLE_SHAPE, FILLED_SQUARE_SHAPE, SQUARE_SHAPE
 
Constructor Summary
IlvGraphicHandleSelection(IlvGraphic object, IlvSelection selection)
          Creates a new IlvGraphicHandleSelection.
 
Method Summary
 void addObject(IlvGraphic graphic, boolean redraw)
          Adds a graphic object to the bag.
protected  void afterLoopAllHandles()
          This is called by this class after iterating over all handles and calling getHandle(int, ilog.views.IlvTransformer).
 void applyToObject(IlvGraphic graphic, IlvApplyObject f, Object arg, boolean redraw)
          Applies a method to a graphic object of the bag.
protected  void beforeLoopAllHandles(IlvTransformer t)
          This is called by this class before iterating over all handles and calling getHandle(int, ilog.views.IlvTransformer).
 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.
 void draw(Graphics dst, IlvTransformer t)
          Draws the object.
 void drawWithoutHandles(Graphics dst, IlvTransformer t)
          Draws the selection without the handles.
 String getDefaultInteractor()
          Returns the default interactor class name.
 IlvPoint getHandle(int i, IlvTransformer t)
          Returns the location of a handle.
 int getHandleCardinal()
          Returns the number of handles for this object.
 IlvGraphic getObject(String name)
          Returns the graphic object with that name if it exists in the bag, otherwise returns null.
 IlvGraphicEnumeration getObjects()
          Returns the objects of the bag.
 IlvSelection getSelection()
          Returns the referenced selection.
protected  IlvTransformer getVirtualToRealViewTransformer(IlvTransformer t)
          Returns the transformer that converts the virtual view coordinate system to the real view coordinate system.
protected  IlvTransformer getVirtualViewTransformer(IlvTransformer t)
          Returns the transformer that converts the manager coordinate system of the wrapped object into a virtual view coordinate system.
 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 isOptimizedDrawingEnabled()
          This method allows or disables an optimization for drawing a selection object and its selected object.
 boolean isPersistent()
          If this method returns true the IlvGraphic instance will be saved in IVL files.
 boolean isVisible()
          Returns true if the object is visible.
 void moveObject(IlvGraphic graphic, float x, float y, boolean redraw)
          Changes the location of a graphic object.
 void onEnter(IlvObjectInteractorContext context)
          Called when the selection is entered.
 void onExit(IlvObjectInteractorContext context)
          Called when the selection is exited.
 void reDrawObj(IlvGraphic graphic)
          Redraws a graphic object located in the bag.
 void reDrawRegion(IlvRegion region)
          Redraws a region of the bag.
 void removeObject(IlvGraphic graphic, boolean redraw)
          Removes a graphic object from the bag.
 void reshapeObject(IlvGraphic graphic, IlvRect newrect, boolean redraw)
          Changes the size of a graphic object.
 void setBackground(Color c)
          Changes the background color of the object.
 void setForeground(Color c)
          Changes the foreground color of the object.
 boolean setObjectName(IlvGraphic graphic, String name)
          Changes the name of a graphic object.
 void setSelection(IlvSelection selection)
          Sets the referenced selection.
 boolean zoomable()
          Returns true if the object is zoomable.
 
Methods inherited from class ilog.views.IlvHandlesSelection
getActiveHandlesColor, getHandle, getHandlesColor, getHandlesShape, getHandlesSize, isActive, setActiveHandlesColor, setHandlesColor, setHandlesShape, setHandlesSize
 
Methods inherited from class ilog.views.IlvSelection
applyTransform, copy, getObject, SetDefaultInteractor
 
Methods inherited from class ilog.views.IlvGraphic
addActionListener, addNamedPropertyListener, boundingBox, getAndAssociateObjectInteractor, getCenter, getGraphicBag, GetGraphicObject, getIntersectionWithOutline, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenu, getPopupMenuName, getProperty, getToolTipText, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, hasProperty, isDataFlavorSupported, isEditable, isInApplyToObject, isMovable, isSelectable, makeSelection, move, move, moveResize, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setEditable, setFillOn, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipText, setVisible, toString, translate, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ilog.views.IlvGraphicBag
getGraphicBag
 

Constructor Detail

IlvGraphicHandleSelection

public IlvGraphicHandleSelection(IlvGraphic object,
                                 IlvSelection selection)
Creates a new IlvGraphicHandleSelection.

Parameters:
object - the object that has the selection.
selection - the referenced selection.
Method Detail

setSelection

public void setSelection(IlvSelection selection)
Sets the referenced selection.


getSelection

public final IlvSelection getSelection()
Returns the referenced selection.


isVisible

public boolean isVisible()
Returns true if the object is visible.

Overrides:
isVisible in class IlvSelection
Returns:
true if this graphic object is visible.
See Also:
IlvGraphic.setVisible(boolean), IlvGraphic.setSelectable(boolean), IlvGraphic.setMovable(boolean), IlvGraphic.setEditable(boolean)

isOptimizedDrawingEnabled

public boolean isOptimizedDrawingEnabled()
This method allows or disables an optimization for drawing a selection object and its selected object. This method can return true if the selection object covers completely the selected objects. In other words if the bounding box of this selection object is the same or bigger than the bounding box of the corresponding selected object. Note that the default value is false.

Overrides:
isOptimizedDrawingEnabled in class IlvSelection

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 IlvHandlesSelection
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.

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

drawWithoutHandles

public void drawWithoutHandles(Graphics dst,
                               IlvTransformer t)
Draws the selection without the handles.

Overrides:
drawWithoutHandles in class IlvHandlesSelection

boundingBox

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

Overrides:
boundingBox in class IlvHandlesSelection
Parameters:
t - the transformer used to draw the object.
See Also:
IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer), IlvGraphic.zoomable(), 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 IlvHandlesSelection
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

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

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

onEnter

public void onEnter(IlvObjectInteractorContext context)
Called when the selection is entered. The selection is entered if the select interactor moves the mouse over the selection so that mouse events are dispatched to the object interactor of this selection.

Subclasses can override this method to perform specific tasks when the selection is entered. The default implementation does nothing.

Overrides:
onEnter in class IlvHandlesSelection
Parameters:
context - The context for the object interactor.

onExit

public void onExit(IlvObjectInteractorContext context)
Called when the selection is exited. The selection is exited if the select interactor moves the mouse to a blanc area of the view, or to another selection so that mouse events are not anymore dispatched to the object interactor of this selection.

Subclasses can override this method to perform specific tasks when the selection is entered. The default implementation does nothing.

Overrides:
onExit in class IlvHandlesSelection
Parameters:
context - The context for the object interactor.

getHandleCardinal

public int getHandleCardinal()
Returns the number of handles for this object.

Specified by:
getHandleCardinal in class IlvHandlesSelection

getHandle

public IlvPoint getHandle(int i,
                          IlvTransformer t)
Returns the location of a handle.

Specified by:
getHandle in class IlvHandlesSelection
Parameters:
i - the index of the handle.
t - the transformer through which the object is drawn.

beforeLoopAllHandles

protected void beforeLoopAllHandles(IlvTransformer t)
This is called by this class before iterating over all handles and calling getHandle(int, ilog.views.IlvTransformer). Subclasses can override this method to do preparations so that getHandle(int, ilog.views.IlvTransformer) is fast, e.g. fill certain caches that are needed by getHandle(int, ilog.views.IlvTransformer).

Overrides:
beforeLoopAllHandles in class IlvHandlesSelection
Parameters:
t - The transformer to draw this object.
See Also:
afterLoopAllHandles()

afterLoopAllHandles

protected void afterLoopAllHandles()
This is called by this class after iterating over all handles and calling getHandle(int, ilog.views.IlvTransformer). Subclasses can override this method to do cleanup caches that were needed by getHandle(int, ilog.views.IlvTransformer).

Overrides:
afterLoopAllHandles in class IlvHandlesSelection
See Also:
beforeLoopAllHandles(ilog.views.IlvTransformer)

getVirtualViewTransformer

protected IlvTransformer getVirtualViewTransformer(IlvTransformer t)
Returns the transformer that converts the manager coordinate system of the wrapped object into a virtual view coordinate system. This allows to draw wrapped objects in a virtual view that has a different transformer than the real view. The input transformer is the transformer of the real view. If no virtual view is needed, the method returns the real view transformer. This is also the default.

Parameters:
t - The transformer of the real view.
Returns:
The transformer of the virtual view. It can return null to indicate identity transformer.

getVirtualToRealViewTransformer

protected IlvTransformer getVirtualToRealViewTransformer(IlvTransformer t)
Returns the transformer that converts the virtual view coordinate system to the real view coordinate system. This allows to draw wrapped objects in a virtual view that has a different transformer than the real view. The input transformer is the transformer of the real view. If no virtual view is needed, the method returns null or the identity transformer. It returns null by default.

Parameters:
t - The transformer of the real view.
Returns:
The transformer that transforms the virtual view to the real view. It can return null to indicate identity transformer.

getDefaultInteractor

public String getDefaultInteractor()
Returns the default interactor class name.

Overrides:
getDefaultInteractor in class IlvSelection
See Also:
IlvReshapeSelection, IlvSelection.SetDefaultInteractor(java.lang.String)

addObject

public void addObject(IlvGraphic graphic,
                      boolean redraw)
Adds a graphic object to the bag. This is part of the IlvGraphicBag interface. Since the graphic handle selection can contain only one object, you can add only an object if the currently referenced object is null. The passed object becomes the new currently referenced object.

If the graphic handle selection is in a graphic bag, it automatically calls applyToObject on its graphic bag while adding the object.

Specified by:
addObject in interface IlvGraphicBag
Parameters:
graphic - The graphic object.
redraw - If true the object is redrawn.

removeObject

public void removeObject(IlvGraphic graphic,
                         boolean redraw)
Removes a graphic object from the bag. This is part of the IlvGraphicBag interface. Since the graphic handle selection can contain only one object, you can remove only the currently referenced object.

If the graphic handle selection is in a graphic bag, it automatically calls applyToObject on its graphic bag while removing the object.

Specified by:
removeObject in interface IlvGraphicBag
Parameters:
graphic - The graphic object.
redraw - If true the object is redrawn.

getObjects

public IlvGraphicEnumeration getObjects()
Returns the objects of the bag. This is part of the IlvGraphicBag interface. This returns an enumeration with one object: the referenced object.

Specified by:
getObjects in interface IlvGraphicBag

reDrawObj

public void reDrawObj(IlvGraphic graphic)
Redraws a graphic object located in the bag. This is part of the IlvGraphicBag interface. If this graphic handle selection is inside a graphic bag, it redraws this graphic handle selection.

Specified by:
reDrawObj in interface IlvGraphicBag
Parameters:
graphic - The graphic object.

reDrawRegion

public void reDrawRegion(IlvRegion region)
Redraws a region of the bag. This is part of the IlvGraphicBag interface. If this graphic handle selection is inside a graphic bag, it redraws this graphic handle selection.

Specified by:
reDrawRegion in interface IlvGraphicBag
Parameters:
region - The region to redraw.

reshapeObject

public void reshapeObject(IlvGraphic graphic,
                          IlvRect newrect,
                          boolean redraw)
Changes the size of a graphic object. This is part of the IlvGraphicBag interface. Since the graphic handle selection can contain only one object, you can reshape only the currently referenced object.

If the graphic handle selection is in a graphic bag, it automatically calls applyToObject on its graphic bag while reshaping the object.

Specified by:
reshapeObject in interface IlvGraphicBag
Parameters:
graphic - The graphic object.
newrect - The new desired bounding rectangle.
redraw - If true the object is redrawn.

moveObject

public void moveObject(IlvGraphic graphic,
                       float x,
                       float y,
                       boolean redraw)
Changes the location of a graphic object. This is part of the IlvGraphicBag interface. Since the graphic handle selection can contain only one object, you can move only the currently referenced object.

If the graphic handle selection is in a graphic bag, it automatically calls applyToObject on its graphic bag while moving the object.

Specified by:
moveObject in interface IlvGraphicBag
Parameters:
graphic - The graphic object.
x - The new desired x position.
y - The new desired y position.
redraw - If true the object is redrawn.

applyToObject

public void applyToObject(IlvGraphic graphic,
                          IlvApplyObject f,
                          Object arg,
                          boolean redraw)
Applies a method to a graphic object of the bag. This is part of the IlvGraphicBag interface.

If the graphic handle selection is in a graphic bag, it automatically calls applyToObject on its graphic bag while applying the object.

Specified by:
applyToObject in interface IlvGraphicBag
Parameters:
graphic - The graphic object.
f - The method to apply.
arg - The arguments passed to the method f.
redraw - If true the object is redrawn.

setObjectName

public boolean setObjectName(IlvGraphic graphic,
                             String name)
Changes the name of a graphic object. This is part of the IlvGraphicBag interface. Since the graphic handle selection can contain only one object, you can only change the name of the currently referenced object.

Specified by:
setObjectName in interface IlvGraphicBag
Parameters:
graphic - The graphic object.
name - The new name.
Returns:
true if the name can be changed.

getObject

public IlvGraphic getObject(String name)
Returns the graphic object with that name if it exists in the bag, otherwise returns null. Since the graphic handle selection can contain only one object, it returns currently referenced object if this matches the input name, and null otherwise.

Specified by:
getObject in interface IlvGraphicBag
Parameters:
name - The graphic object name.


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