ilog.views.interactor
Class IlvMakeRectangleInteractor

java.lang.Object
  extended by ilog.views.IlvManagerViewInteractor
      extended by ilog.views.interactor.IlvDragRectangleInteractor
          extended by ilog.views.interactor.IlvMakeRectangleInteractor
All Implemented Interfaces:
IlvPermanentInteractorInterface, Serializable
Direct Known Subclasses:
IlvMakeArcInteractor, IlvMakeEllipseInteractor, IlvMakeFilledEllipseInteractor, IlvMakeFilledRectangleInteractor, IlvMakeReliefRectangleInteractor, IlvMakeRoundRectangleInteractor

public class IlvMakeRectangleInteractor
extends IlvDragRectangleInteractor
implements IlvPermanentInteractorInterface

An interactor that enables you to drag a rectangle to create an IlvRectangle. You can set an object factory on this interactor. When such a factory is installed, it is responsible for creating the graphic object as soon as the drag operation is finished.

The interactor has two modes: the Opaque mode and the Ghost mode. In Opaque mode, the IlvRectangle object that the user creates is drawn for each drag event. In Ghost mode, the object is drawn only when the user releases the mouse button.

The default mode is the Ghost mode.

See Also:
IlvDragRectangleInteractor.setOpaqueMode(boolean), Serialized Form

Constructor Summary
IlvMakeRectangleInteractor()
          Creates the interactor.
 
Method Summary
protected  void addObject(IlvGraphic obj)
          Adds the new object in the manager.
protected  void detach()
          Called when the interactor is detached from the specified manager view.
protected  void drawGhost(Graphics g)
          Draws the rectangle while it is being dragged.
protected  void fireRectangleDraggedEvent(IlvRect rectangle, MouseEvent event)
          Called by the interactor when the mouse is released.
 Color getBackground()
          Returns the background color used to create the object.
 Color getForeground()
          Returns the foreground color used to create the object.
 IlvRectangularObjectFactory getObjectFactory()
          Returns the factory installed, if any.
 boolean isCreationInSubManagersAllowed()
          Returns true if the creation of objects in submanagers is allowed, and false otherwise.
 boolean isFillOn()
          Returns true if the inside of the created object should be filled.
 boolean isGrapherMode()
          Returns true if the interactor is in grapher mode.
 boolean isPermanent()
          Returns false if the interactor will be removed from the view once the object is created.
 boolean isSelectionMode()
          Returns true if the graphic object is selected after creation, while the other objects are deselected.
 boolean isStrokeOn()
          Returns true if the created object should be stroked.
 boolean isXORGhost()
          Returns the ghost drawing mode.
protected  IlvGraphic makeObject(IlvRect rect)
          Creates the IlvRectangle.
protected  void resizeObject(IlvGraphic obj, IlvRect rect)
          Resizes the graphic object.
 void setBackground(Color color)
          Changes the background color that is used to create the object.
 void setCreationInSubManagersAllowed(boolean set)
          Allows objects to be created in submanagers (see IlvManager.getManagers()).
 void setFillOn(boolean set)
          If true, specifies that the inside of the created object should be filled.
 void setForeground(Color color)
          Changes the foreground color used to create the object.
 void setGrapherMode(boolean value)
          Sets the grapher mode value.
 void setObjectFactory(IlvRectangularObjectFactory factory)
          Installs a factory for the creation of the graphic object.
 void setPermanent(boolean permanent)
          Allows you to specify if the interactor will or will not be removed from the view once the object is created.
 void setSelectionMode(boolean select)
          Enables the selection of the created graphic object and the deselection of the other graphic objects contained in the manager after the creation.
 void setStrokeOn(boolean set)
          When set to true, specifies that the created object should be stroked.
 
Methods inherited from class ilog.views.interactor.IlvDragRectangleInteractor
addRectangleDraggedListener, attach, getCursor, getDraggedRectangle, getLineStyle, getRectangleAspectRatio, getStartDragModifier, getStartPoint, handleButtonDown, handleButtonDragged, handleButtonUp, isGridMode, isOpaqueMode, isRotationAllowed, isStartDragModifierDown, processMouseEvent, processMouseMotionEvent, removeRectangleDraggedListener, setCursor, setGridMode, setLineStyle, setOpaqueMode, setRectangleAspectRatio, setRotationAllowed, setStartDragModifier
 
Methods inherited from class ilog.views.IlvManagerViewInteractor
addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, allowEnsureVisible, allowEnsureVisible, disableEvents, drawGhost, enableEvents, ensureVisible, ensureVisible, getManager, getManagerView, getTransformer, handleExpose, processEvent, processFocusEvent, processKeyEvent, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, setXORGhost
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvMakeRectangleInteractor

public IlvMakeRectangleInteractor()
Creates the interactor.

Method Detail

detach

protected void detach()
Called when the interactor is detached from the specified manager view. This overridden implementation calls the detach method of the parent class and performs additional cleaning operations.

Overrides:
detach in class IlvDragRectangleInteractor
See Also:
IlvManagerViewInteractor.attach(ilog.views.IlvManagerView)

fireRectangleDraggedEvent

protected void fireRectangleDraggedEvent(IlvRect rectangle,
                                         MouseEvent event)
Called by the interactor when the mouse is released. In opaque mode, it creates the graphic objects by calling the method makeObject. In ghost mode, it uses the object that has already been created.

By default, the object is of type IlvRectangle. If an object factory is attached, the type of the object is determined by this factory.

The method calls addObject(ilog.views.IlvGraphic) to add the created object into the manager.

Overrides:
fireRectangleDraggedEvent in class IlvDragRectangleInteractor
Parameters:
rectangle - The rectangle that was dragged in the manager coordinate system.
event - The mouse released event.
See Also:
makeObject(ilog.views.IlvRect), setObjectFactory(ilog.views.interactor.IlvRectangularObjectFactory)

setCreationInSubManagersAllowed

public void setCreationInSubManagersAllowed(boolean set)
Allows objects to be created in submanagers (see IlvManager.getManagers()). If creation in submanagers is not allowed, the object is always created in the IlvManager displayed by the IlvManagerView to which this interactor is attached.

The default value is true.

Since:
JViews 5.0

isCreationInSubManagersAllowed

public boolean isCreationInSubManagersAllowed()
Returns true if the creation of objects in submanagers is allowed, and false otherwise.

Since:
JViews 5.0

addObject

protected void addObject(IlvGraphic obj)
Adds the new object in the manager. This method is called by the interactor to add the newly created object in the manager. It simply calls addObject on the manager in default mode. The method calls addNode on the grapher in grapher mode if the interactor is attached to a grapher view.

If the method isSelectionMode() returns true and the created object is selected, the created object is selected (see IlvManager.setSelected(IlvGraphic, boolean, boolean)) and all the other objects are deselected (see IlvManager.deSelectAll(boolean, boolean)). If the method isSelectionMode() returns true and the created object is selectable (IlvManager.isSelectable(IlvGraphic)), the created object is selected (see IlvManager.setSelected(IlvGraphic, boolean, boolean)) and all the other objects are deselected (see IlvManager.deSelectAll(boolean, boolean)).

Parameters:
obj - The object to be added.
See Also:
setGrapherMode(boolean)

isPermanent

public final boolean isPermanent()
Returns false if the interactor will be removed from the view once the object is created. The default value is false.

Specified by:
isPermanent in interface IlvPermanentInteractorInterface

setPermanent

public void setPermanent(boolean permanent)
Allows you to specify if the interactor will or will not be removed from the view once the object is created. The default value is false.

Specified by:
setPermanent in interface IlvPermanentInteractorInterface
Parameters:
permanent - the new mode.

isXORGhost

public boolean isXORGhost()
Returns the ghost drawing mode. Overrides the method of the superclass to force the XOR mode when the method IlvDragRectangleInteractor.isOpaqueMode() returns false and to force the Paint mode when the method IlvDragRectangleInteractor.isOpaqueMode() returns true.

Overrides:
isXORGhost in class IlvDragRectangleInteractor
Returns:
true if the drawing needs to be performed in XOR mode, false otherwise.
Since:
JViews 5.0
See Also:
IlvManagerViewInteractor.setXORGhost(boolean), IlvManagerViewInteractor.handleExpose(java.awt.Graphics), IlvManagerViewInteractor.drawGhost(java.awt.Graphics)

setSelectionMode

public void setSelectionMode(boolean select)
Enables the selection of the created graphic object and the deselection of the other graphic objects contained in the manager after the creation.

The default value is false.

Since:
JViews 5.0
See Also:
addObject(ilog.views.IlvGraphic)

isSelectionMode

public boolean isSelectionMode()
Returns true if the graphic object is selected after creation, while the other objects are deselected. Returns false otherwise.

Objects that are not selectable (see IlvManager.isSelectable(IlvGraphic) are not selected.

Since:
JViews 5.0
See Also:
addObject(ilog.views.IlvGraphic)

setObjectFactory

public final void setObjectFactory(IlvRectangularObjectFactory factory)
Installs a factory for the creation of the graphic object. If a factory is installed, then the createObject method of the factory is called to create the object.

See Also:
getObjectFactory()

getObjectFactory

public IlvRectangularObjectFactory getObjectFactory()
Returns the factory installed, if any.

See Also:
setObjectFactory(ilog.views.interactor.IlvRectangularObjectFactory)

makeObject

protected IlvGraphic makeObject(IlvRect rect)
Creates the IlvRectangle. This method is called by the interactor to create the rectangle.

The default implementation creates an IlvRectangle if no factory is installed; otherwise it calls the createObject method of the factory.


getForeground

public Color getForeground()
Returns the foreground color used to create the object.

See Also:
setForeground(java.awt.Color)

setForeground

public void setForeground(Color color)
Changes the foreground color used to create the object.

See Also:
getForeground()

getBackground

public Color getBackground()
Returns the background color used to create the object.

See Also:
setBackground(java.awt.Color)

setBackground

public void setBackground(Color color)
Changes the background color that is used to create the object.

See Also:
getBackground()

isFillOn

public boolean isFillOn()
Returns true if the inside of the created object should be filled.

Since:
JViews 5.5
See Also:
setFillOn(boolean)

setFillOn

public void setFillOn(boolean set)
If true, specifies that the inside of the created object should be filled.

Since:
JViews 5.5
See Also:
isFillOn()

isStrokeOn

public boolean isStrokeOn()
Returns true if the created object should be stroked.

Since:
JViews 5.5
See Also:
setStrokeOn(boolean)

setStrokeOn

public void setStrokeOn(boolean set)
When set to true, specifies that the created object should be stroked.

Since:
JViews 5.5
See Also:
isStrokeOn()

isGrapherMode

public boolean isGrapherMode()
Returns true if the interactor is in grapher mode. The default is false.

See Also:
setGrapherMode(boolean)

setGrapherMode

public void setGrapherMode(boolean value)
Sets the grapher mode value. If true, created objects will be added to the grapher of the attached view with addNode method. If false, they will be added with addObject.

See Also:
isGrapherMode()

drawGhost

protected void drawGhost(Graphics g)
Draws the rectangle while it is being dragged. In opaque mode, it draws the created object. In ghost mode, it calls the drawGhost(Graphics) method of the parent class.

Overrides:
drawGhost in class IlvDragRectangleInteractor
Parameters:
g - The Graphics.
See Also:
IlvDragRectangleInteractor.setOpaqueMode(boolean)

resizeObject

protected void resizeObject(IlvGraphic obj,
                            IlvRect rect)
Resizes the graphic object. The method is called in opaque mode while the rectangle is being dragged to update the size of the object accordingly. The default implementation calls the method IlvGraphic.moveResize(IlvRect).

Since:
JViews 5.0
See Also:
IlvDragRectangleInteractor.setOpaqueMode(boolean)


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