ilog.views.prototypes
Class IlvConnectInteractor

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

public abstract class IlvConnectInteractor
extends IlvManagerViewInteractor
implements IlvPermanentInteractorInterface

This class is a subclass of IlvManagerViewInteractor. It is used to interconnect the values handled by different objects in an interactive way. When the user clicks on a source object (for example, a prototype instance) and drags the mouse to a destination object, the interactor prompts for the names of the output and input properties and connects these values by calling the subscribe method for the source object.

When the connect interactor is attached to a manager view, existing connections are displayed with green arrows. The user can delete a connection by double-clicking on the connecting line.

This interactor also displays the value sources contained in the group bag associated with the manager to which the view is attached. The value sources are drawn as green outlined labels in the top-left corner of the view. Value sources can be connected like any other objects by clicking in and/or dragging to these labels.

This class is abstract. It must be subclassed and its promptValues method must be overridden to define a GUI in which the user can select the output and input values.

See Also:
IlvGroupElement.subscribe(IlvGroupElement, String, String), IlvGroupElement.unsubscribe(ilog.views.prototypes.IlvGroupElement, java.lang.String, java.lang.String), IlvGroup, IlvPrototypeInstance, IlvValueSource, Serialized Form

Constructor Summary
IlvConnectInteractor()
          Creates a new connection interactor.
 
Method Summary
protected  void attach(IlvManagerView v)
          Repaints the view to display existing connections.
protected  void connectionCreated(IlvGroupElement from, IlvGroupElement to, String fromProperty, String toProperty)
          This method is called when a new connection is created.
protected  void connectionDeleted(IlvGroupElement from, IlvGroupElement to, String fromProperty, String toProperty)
          This method is called when a connection is deleted.
protected  void detach()
          Repaints the view to erase displayed connections.
protected  void drawGhost(Graphics g)
          Draws a ghost line between the source and the destination objects when a connection is being established.
 IlvGroupElement getElementAt(int x, int y)
          Returns the group element (or the value source) located at the position defined by (x, y) in the manager view to which this interactor is attached.
protected  void handleExpose(Graphics g)
          Draws the existing connections and the value sources.
 boolean isPermanent()
          Returns false (the default value) if the interactor is removed from the view once the object has been created.
protected  void processMouseEvent(MouseEvent event)
          Processes the MOUSE_PRESSED and MOUSE_RELEASED events to define a connection.
protected  void processMouseMotionEvent(MouseEvent event)
          Processes the MOUSE_DRAGGED events to define a connection.
protected abstract  String[] promptValues(IlvGroupElement from, IlvGroupElement to, boolean create)
          Prompts the user for the names of the source and destination values when a connection is created or deleted.
 void refresh()
          Refreshes the display of connections and value sources.
 void setPermanent(boolean permanent)
          Specifies whether the interactor is removed from the view once the object has been created.
protected  void showDetails(MouseEvent event, IlvGroupElement from, IlvGroupElement to)
          Called when the mouse is moved near a connecting line.
 
Methods inherited from class ilog.views.IlvManagerViewInteractor
addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, allowEnsureVisible, allowEnsureVisible, disableEvents, 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
 

Constructor Detail

IlvConnectInteractor

public IlvConnectInteractor()
Creates a new connection interactor.

Method Detail

isPermanent

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

Specified by:
isPermanent in interface IlvPermanentInteractorInterface

setPermanent

public final void setPermanent(boolean permanent)
Specifies whether the interactor is removed from the view once the object has been created. The default value is false.

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

processMouseEvent

protected void processMouseEvent(MouseEvent event)
Processes the MOUSE_PRESSED and MOUSE_RELEASED events to define a connection.

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

connectionCreated

protected void connectionCreated(IlvGroupElement from,
                                 IlvGroupElement to,
                                 String fromProperty,
                                 String toProperty)
This method is called when a new connection is created.

Parameters:
from - the source of the connection.
to - the target of the connection.
fromProperty - the source property name.
toProperty - the target property name.

connectionDeleted

protected void connectionDeleted(IlvGroupElement from,
                                 IlvGroupElement to,
                                 String fromProperty,
                                 String toProperty)
This method is called when a connection is deleted.

Parameters:
from - the source of the connection.
to - the target of the connection.
fromProperty - the source property name.
toProperty - the target property name.

processMouseMotionEvent

protected void processMouseMotionEvent(MouseEvent event)
Processes the MOUSE_DRAGGED events to define a connection.

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

drawGhost

protected void drawGhost(Graphics g)
Draws a ghost line between the source and the destination objects when a connection is being established.

Overrides:
drawGhost in class IlvManagerViewInteractor
Parameters:
g - The graphics.
See Also:
IlvManagerViewInteractor.handleExpose(java.awt.Graphics), IlvManagerViewInteractor.setXORGhost(boolean)

handleExpose

protected void handleExpose(Graphics g)
Draws the existing connections and the value sources.

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

attach

protected void attach(IlvManagerView v)
Repaints the view to display existing connections.

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

detach

protected void detach()
Repaints the view to erase displayed connections.

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

refresh

public void refresh()
Refreshes the display of connections and value sources. This method can be called by applications that dynamically create value sources or connections.


promptValues

protected abstract String[] promptValues(IlvGroupElement from,
                                         IlvGroupElement to,
                                         boolean create)
Prompts the user for the names of the source and destination values when a connection is created or deleted.

Parameters:
from - the source of the connection.
to - the destination of the connection.
create - true if a connection is being established, false if a connection is being deleted.
Returns:
an array of two String objects: the first element is the source value and the second element is the destination value. If the user canceled the dialog, the method returns null.

showDetails

protected void showDetails(MouseEvent event,
                           IlvGroupElement from,
                           IlvGroupElement to)
Called when the mouse is moved near a connecting line. It can be overridden by subclasses to display the details of the connection with a tooltip or any other feedback.

The default implementation does nothing.

Parameters:
event - the event that can be used to get the mouse location.
from - the source of the connection.
to - the destination of the connection.

getElementAt

public IlvGroupElement getElementAt(int x,
                                    int y)
Returns the group element (or the value source) located at the position defined by (x, y) in the manager view to which this interactor is attached.



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