ilog.views.interactor
Class IlvMagnifyInteractor

java.lang.Object
  extended by ilog.views.IlvManagerViewInteractor
      extended by ilog.views.interactor.IlvMagnifyInteractor
All Implemented Interfaces:
IlvPermanentInteractorInterface, Serializable

public class IlvMagnifyInteractor
extends IlvManagerViewInteractor
implements IlvPermanentInteractorInterface

An interactor designed to magnify a part of the view by dragging the mouse over it. It acts as a magnifying glass moved over the view. The area of magnification can be a rectangle when the mode is set to RECTANGULAR or a circle when the mode is set to CIRCULAR or LENS.

This interactor can be directly used on an IlvManagerView (waiting for the user to press a mouse button) or it can be used inside another interactor. For example, if you want to show the magnifier when pressing the mouse down with the Alt key as modifier during the work of the IlvSelectInteractor you can subclass this interactor to do the following:


 public MagSelectInteractor extends IlvSelectInteractor 
 {
   IlvMagnifyInteractor inter = null;
  
   protected void processMouseEvent(MouseEvent e) 
   {
     if (e.getID() == MouseEvent.MOUSE_PRESSED && e.isAltDown()) {
       if (!dispatchToSelection(e)) {
         if (inter == null) {
           inter = new IlvMagnifyInteractor() ;
           inter.setFactor(2.5f);
         }
         getManagerView().pushInteractor(inter, e);
       }
     } else 
       super.processMouseEvent(e);
   }
 }
 

Notice that the LENS mode may consume a large amount of memory if the magnification factor is high and the size of the magnification area is large. In LENS mode, the amount of memory is quadratic proportional to the magnification factor and to the size. RECTANGULAR and CIRCULAR mode use less memory since the amount of memory is only proportional to the size but not influenced by the magnification factor.

Since:
JViews 5.0
See Also:
setMode(short), IlvManagerView.pushInteractor(ilog.views.IlvManagerViewInteractor, java.awt.AWTEvent), Serialized Form

Field Summary
static short CIRCULAR
          The area of magnification is a regular circle.
static short LENS
          The area of magnification is a circle which preserves the continuity between the magnification area and the view.
static short RECTANGULAR
          The area of magnification is a rectangle.
 
Constructor Summary
IlvMagnifyInteractor()
          Constructs and initializes a new instance of the IlvMagnifyInteractor.
 
Method Summary
protected  void attach(IlvManagerView view)
          Called when the interactor is attached to the manager view.
protected  void detach()
          Called when the interactor is detached from the view.
protected  void drawMagnifier(Graphics g)
          Draws the magnifier.
protected  IlvRect getDrawingRect()
          Returns a copy of the rectangle representing the area in which the magnifier is drawn.
 float getFactor()
          Returns the magnification factor used by the interactor.
 short getMode()
          Returns the mode used to draw the magnification area.
 int getSize()
          Returns the size of the magnification area in manager view coordinates.
protected  void handleExpose(Graphics g)
          Called by the view when the view is drawn,;it actually calls the method that draws the magnifier using drawMagnifier(java.awt.Graphics).
 boolean isPermanent()
          Returns false if the interactor will be removed from the view once the object was created.
protected  void processMouseEvent(MouseEvent e)
          Processes the mouse events.
protected  void processMouseMotionEvent(MouseEvent e)
          Processes the mouse motion events.
 void setFactor(float factor)
          Sets the magnification factor used by the interactor.
 void setMode(short mode)
          Sets the mode used to draw the magnification area.
 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 setSize(int size)
          Sets the size of the magnification area.
protected  void update()
          Called by handleExpose(Graphics) when it becomes necessary to update the magnified view.
 
Methods inherited from class ilog.views.IlvManagerViewInteractor
addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, allowEnsureVisible, allowEnsureVisible, disableEvents, drawGhost, drawGhost, enableEvents, ensureVisible, ensureVisible, getManager, getManagerView, getTransformer, isXORGhost, 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
 

Field Detail

RECTANGULAR

public static final short RECTANGULAR
The area of magnification is a rectangle.

This is the default mode.

See Also:
setMode(short), Constant Field Values

CIRCULAR

public static final short CIRCULAR
The area of magnification is a regular circle.

See Also:
setMode(short), Constant Field Values

LENS

public static final short LENS
The area of magnification is a circle which preserves the continuity between the magnification area and the view.

See Also:
setMode(short), Constant Field Values
Constructor Detail

IlvMagnifyInteractor

public IlvMagnifyInteractor()
Constructs and initializes a new instance of the IlvMagnifyInteractor.

Method Detail

attach

protected void attach(IlvManagerView view)
Called when the interactor is attached to the manager view.

Overrides:
attach in class IlvManagerViewInteractor
Parameters:
view - The manager view.
See Also:
IlvManagerViewInteractor.detach()

detach

protected void detach()
Called when the interactor is detached from the view.

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

setSize

public final void setSize(int size)
Sets the size of the magnification area.

Parameters:
size - The size to be set, in manager view coordinate values.
See Also:
getSize()

getSize

public final int getSize()
Returns the size of the magnification area in manager view coordinates. The default value is 128.

See Also:
setSize(int)

setMode

public final void setMode(short mode)
Sets the mode used to draw the magnification area.

Notice that the LENS mode may consume a large amount of memory if the magnification factor is high and the size is large. In LENS mode, the amount of memory is quadratic proportional to the magnification factor and to the size. RECTANGULAR and CIRCULAR mode use less memory since the amount of memory is only proportional to the size but not influenced by the magnification factor.

Parameters:
mode - The magnification mode: RECTANGULAR (the default), CIRCULAR, or LENS.
See Also:
RECTANGULAR, CIRCULAR, LENS, getMode()

getMode

public final short getMode()
Returns the mode used to draw the magnification area.

See Also:
setMode(short)

setFactor

public final void setFactor(float factor)
Sets the magnification factor used by the interactor. It should be greater or equal to 1 and smaller or equal to 4.

Parameters:
factor - The magnification factor as a value from 1 through 4.
See Also:
getFactor()

getFactor

public final float getFactor()
Returns the magnification factor used by the interactor. The default value is 2.

See Also:
setFactor(float)

processMouseEvent

protected void processMouseEvent(MouseEvent e)
Processes the mouse events. The magnifier appears when a mouse button is pressed. It is removed when a mouse button is released.

Overrides:
processMouseEvent in class IlvManagerViewInteractor
Parameters:
e - The mouse event.
See Also:
IlvManagerViewInteractor.addMouseListener(java.awt.event.MouseListener)

processMouseMotionEvent

protected void processMouseMotionEvent(MouseEvent e)
Processes the mouse motion events. When the mouse is dragged, the magnifier is moved over the view.

Overrides:
processMouseMotionEvent in class IlvManagerViewInteractor
Parameters:
e - The mouse motion event.
See Also:
IlvManagerViewInteractor.addMouseMotionListener(java.awt.event.MouseMotionListener)

handleExpose

protected void handleExpose(Graphics g)
Called by the view when the view is drawn,;it actually calls the method that draws the magnifier using drawMagnifier(java.awt.Graphics).

Overrides:
handleExpose in class IlvManagerViewInteractor
Parameters:
g - The view graphics.
See Also:
IlvManagerViewInteractor.drawGhost(java.awt.Graphics), IlvManagerViewInteractor.isXORGhost(), IlvManagerView.getDefaultXORColor()

update

protected void update()
Called by handleExpose(Graphics) when it becomes necessary to update the magnified view.

Since:
JViews 8.0

getDrawingRect

protected IlvRect getDrawingRect()
Returns a copy of the rectangle representing the area in which the magnifier is drawn.


drawMagnifier

protected void drawMagnifier(Graphics g)
Draws the magnifier. If you redefine this method to add additional drawings, you must also redefine the getDrawingRect() method to return a rectangle containing the additional drawings.

Parameters:
g - The view graphics.

isPermanent

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

Specified by:
isPermanent in interface IlvPermanentInteractorInterface

setPermanent

public final 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 - If true the interactor will be removed, otherwise not.


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