ilog.views.prototypes
Class IlvEventBehavior

java.lang.Object
  extended by ilog.views.prototypes.IlvBehavior
      extended by ilog.views.prototypes.IlvSingleBehavior
          extended by ilog.views.prototypes.IlvEventBehavior
All Implemented Interfaces:
IlvPersistentObject, IlvInteractiveBehavior, Serializable

public class IlvEventBehavior
extends IlvSingleBehavior
implements IlvInteractiveBehavior

The class IlvEventBehavior is used to handle user events in a prototype.

An event behavior handles input events of a given type (for example, mouse clicked) in an element of the prototype or in the whole prototype. You can specify a Boolean expression to filter events depending on the modifiers (mouse button or key). When an event occurs, the property to which the event behavior is attached is set to an expression. This expression can combine constants, other properties, and special variables containing the details of the event: x/y coordinates, key code, modifiers.

See Also:
Serialized Form

Constructor Summary
IlvEventBehavior(IlvEventBehavior source)
          Creates a new behavior object by copying an existing one.
IlvEventBehavior(IlvInputStream in)
          Reads the behavior from an IlvInputStream stream.
IlvEventBehavior(String name, String elementName, int eventID, String filterExpression, String dataExpression)
          Creates a new event behavior object.
 
Method Summary
protected  void attach(IlvGroup group)
          This method is overridden to set an IlvGroupInteractor on the element(s) for which events are handled.
 IlvBehavior copy()
          Returns a copy of the behavior.
 String getDataExpression()
          Gets the dataExpression parameter for this behavior object.
 String getElementName()
          Gets the elementName parameter for this behavior object.
 int getEventID()
          Gets the eventID parameter for this behavior object.
 String getFilterExpression()
          Gets the filterExpression parameter for this behavior object.
 boolean processEvent(IlvGroup group, IlvGraphicElement element, AWTEvent event, IlvObjectInteractorContext context)
          Implementation of the IlvInteractiveBehavior interface: handles events that match the type and filter expression passed to the constructor.
 void setDataExpression(String dataExpression)
          Sets the dataExpression parameter for this behavior object.
 void setElementName(String elementName)
          Sets the elementName parameter for this behavior object.
 void setEventID(int eventID)
          Sets the eventID parameter for this behavior object.
 void setFilterExpression(String filterExpression)
          Sets the filterExpression parameter for this behavior object.
 String toString()
          Returns a short text describing this behavior object.
 void write(IlvOutputStream out)
          Writes the behavior to an IlvOutputStream.
 
Methods inherited from class ilog.views.prototypes.IlvSingleBehavior
get, get, getName, getValueNames, set, set, setName
 
Methods inherited from class ilog.views.prototypes.IlvBehavior
detach, getParameter, isOutput, isReadable, isWritable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvEventBehavior

public IlvEventBehavior(String name,
                        String elementName,
                        int eventID,
                        String filterExpression,
                        String dataExpression)
Creates a new event behavior object.

Parameters:
name - the name of the behavior object. When an event that matches the eventID and filterExpression parameters occurs in the element designated by elementName, the property name will be set to the expression dataExpression.
elementName - the name of the element in which the event must occur. This parameter can be set to "[all]" to handle events in the whole prototype.
eventID - the type of events to handle. The type must correspond to an event represented by a subclass of java.awt.event.InputEvent. The type can be 0 to indicate that all input events must be handled.
filterExpression - the expression used to filter events. The filter expression is evaluated, and the event is handled only if the result is true. This expression can contain constants, other properties of the prototype, and also the following special variables that contain the event's fields:
  • eventID - the integer ID of the event. The possible event IDs are also predefined as variables that can be used in the expression (for example, eventID == MOUSE_PRESSED).
  • button1Down - contains true if the first mouse button was down when the event occurred.
  • button2Down - contains true if the second mouse button was down when the event occurred.
  • button3Down - contains true if the third mouse button was down when the event occurred.
  • altDown - contains true if the Alt modifier key was down when the event occurred.
  • altGraphDown - contains true if the AltGraph modifier key was down when the event occurred.
  • controlDown - contains true if the Control modifier key was down when the event occurred.
  • metaDown - contains true if the Meta modifier key was down when the event occurred.
  • shiftDown - contains true if the Shift modifier key was down when the event occurred.
  • eventX - contains the X coordinate of the event (for mouse events only).
  • eventY - contains the Y coordinate of the event (for mouse events only).
  • clickCount - contains the click count of the event (for mouse events only).
  • eventKey - contains the key code as a String; for example, "A" or "F10" (for key events only).
dataExpression - the expression to which the property will be set when a matching event occurs. This expression can contain constants, other properties of the prototype, and also the special variables listed above.

IlvEventBehavior

public IlvEventBehavior(IlvEventBehavior source)
Creates a new behavior object by copying an existing one.

Parameters:
source - the behavior object to be copied.

IlvEventBehavior

public IlvEventBehavior(IlvInputStream in)
                 throws IlvReadFileException
Reads the behavior from an IlvInputStream stream. This constructor must be called by the input constructors of subclasses.

Parameters:
in - The input stream.
Throws:
IlvReadFileException - if the stream format is not correct.
Method Detail

write

public void write(IlvOutputStream out)
           throws IOException
Writes the behavior to an IlvOutputStream.

Specified by:
write in interface IlvPersistentObject
Overrides:
write in class IlvSingleBehavior
Parameters:
out - The output stream.
Throws:
IOException - thrown when an exception occurs during the write operation for this object.

copy

public IlvBehavior copy()
Returns a copy of the behavior.

Specified by:
copy in class IlvBehavior

toString

public String toString()
Returns a short text describing this behavior object. This text can be used by GUI editors to display the behavior description.

Specified by:
toString in class IlvBehavior

attach

protected void attach(IlvGroup group)
This method is overridden to set an IlvGroupInteractor on the element(s) for which events are handled.

Overrides:
attach in class IlvBehavior
Parameters:
group - the group to which this behavior object is attached.
See Also:
IlvGroup.addBehavior(ilog.views.prototypes.IlvBehavior)

setElementName

public void setElementName(String elementName)
Sets the elementName parameter for this behavior object.


getElementName

public String getElementName()
Gets the elementName parameter for this behavior object.


setEventID

public void setEventID(int eventID)
Sets the eventID parameter for this behavior object.


getEventID

public int getEventID()
Gets the eventID parameter for this behavior object.


setFilterExpression

public void setFilterExpression(String filterExpression)
Sets the filterExpression parameter for this behavior object.


getFilterExpression

public String getFilterExpression()
Gets the filterExpression parameter for this behavior object.


setDataExpression

public void setDataExpression(String dataExpression)
Sets the dataExpression parameter for this behavior object.


getDataExpression

public String getDataExpression()
Gets the dataExpression parameter for this behavior object.


processEvent

public boolean processEvent(IlvGroup group,
                            IlvGraphicElement element,
                            AWTEvent event,
                            IlvObjectInteractorContext context)
Implementation of the IlvInteractiveBehavior interface: handles events that match the type and filter expression passed to the constructor.

Specified by:
processEvent in interface IlvInteractiveBehavior
Parameters:
group - the group containing the element in which the event occurred.
element - the graphic element in which the event occurred.
event - the event, which can be a MouseEvent or a KeyEvent.
context - the interactor context, which can be used to get the view transformer.
Returns:
true if the event was actually processed, or false if the event was ignored.


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