junit.extensions.jfcunit.eventdata
Class DragEventData

java.lang.Object
  extended byjunit.extensions.jfcunit.eventdata.AbstractEventData
      extended byjunit.extensions.jfcunit.eventdata.DragEventData
All Implemented Interfaces:
EventDataConstants

public class DragEventData
extends AbstractEventData

DragEventSource is a wrapper for Drag Events. The event encapsulates the source and destination locations for the drag with xxxMouseEventData types.

Author:
Vijay Aravamudhan : ThoughtWorks Inc.

Field Summary
private  AbstractMouseEventData m_dest
          Destination of the drag event.
private  java.awt.Point m_origPoint
          Original reference location of component.
private  java.util.List m_points
          List of points in the drag path.
private  AbstractMouseEventData m_source
          Source of the drag event.
 
Fields inherited from class junit.extensions.jfcunit.eventdata.AbstractEventData
 
Fields inherited from interface junit.extensions.jfcunit.eventdata.EventDataConstants
CENTER, CUSTOM, DEFAULT_HOLDTIME, DEFAULT_ISPOPUPTRIGGER, DEFAULT_KEY_MODIFIERS, DEFAULT_MOUSE_MODIFIERS, DEFAULT_NUMBEROFCLICKS, DEFAULT_POPUP_MODIFIERS, DEFAULT_POSITION, DEFAULT_SCROLL_AMOUNT, DEFAULT_SLEEPTIME, DEFAULT_WHEEL_ROTATION, DOWN_ARROW_SUBCOMPONENT, EAST, EDITOR_SUBCOMPONENT, INVALID_SUBCOMPONENT, INVALID_TEXT_OFFSET, NORTH, NORTH_EAST, NORTH_WEST, OFFSET, PERCENT, POSITIONSTRINGS, SOUTH, SOUTH_EAST, SOUTH_WEST, UP_ARROW_SUBCOMPONENT, WEST
 
Constructor Summary
DragEventData(JFCTestCase testCase, AbstractMouseEventData source)
          Constructor: Assumes a null destination and default sleep time.
DragEventData(JFCTestCase testCase, AbstractMouseEventData source, AbstractMouseEventData dest)
          Constructor for a drag event.
DragEventData(JFCTestCase testCase, AbstractMouseEventData source, AbstractMouseEventData dest, long delay)
          Constructor for a drag event.
 
Method Summary
 void addPoint(java.awt.Point p)
          Add a Point to the drag path.
 boolean canConsume(java.awt.AWTEvent ae)
          Check if this event can consume the AWTEvent.
 boolean consume(java.awt.AWTEvent ae)
          Consume the AWTEvent.
private  java.awt.Point convertToSource(java.awt.Component comp, java.awt.Point p)
          Convert the point to the source coordinate system.
 boolean equals(java.lang.Object o)
          Equals comparison.
 java.awt.Component getComponent()
          This method is provided here to close the abstract base class.
 int getDefaultModifiers()
          Get the default modifiers.
 AbstractMouseEventData getDest()
          Get the destination MouseEventData.
 java.lang.String getModifierText()
          Get the modifier text for the current.
 java.awt.Point[] getPoints()
          Get the list of points in the drag path.
 AbstractMouseEventData getSource()
          Get the Source of the drag event.
 int hashCode()
          Calculate a hashcode based upon the source and the dest of this class.
 void populate(org.w3c.dom.Element e)
          Populate the element wiht the data.
 boolean prepareComponent()
          This prepares the source and dest components if set, and inserts/appends the screen locations onto the list of points.
 void setDest(AbstractMouseEventData dest)
          Set the Destination of the drag event.
 void setPoints(java.awt.Point[] points)
          Set the points in the drag path.
 void setSource(AbstractMouseEventData source)
          Set the Source of the drag event.
 java.lang.String toString()
          Return a string representing the eventdata.
 
Methods inherited from class junit.extensions.jfcunit.eventdata.AbstractEventData
calculatePoint, getDefaultPosition, getDefaultSleepTime, getLocationOnScreen, getModifiers, getPosition, getReferencePoint, getRoot, getRoot, getSleepTime, getTestCase, isMetaChar, isValid, isValidForProcessing, setLocationOnScreen, setModifiers, setPosition, setReferencePoint, setSleepTime, setTestCase, setValid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m_dest

private AbstractMouseEventData m_dest
Destination of the drag event.


m_source

private AbstractMouseEventData m_source
Source of the drag event.


m_points

private java.util.List m_points
List of points in the drag path.


m_origPoint

private java.awt.Point m_origPoint
Original reference location of component.

Constructor Detail

DragEventData

public DragEventData(JFCTestCase testCase,
                     AbstractMouseEventData source)
Constructor: Assumes a null destination and default sleep time.

Parameters:
testCase - JFCTestCase to fire the sleeps upon.
source - AbstractMouseEventData indicating the starting location of the drag event.

DragEventData

public DragEventData(JFCTestCase testCase,
                     AbstractMouseEventData source,
                     AbstractMouseEventData dest)
Constructor for a drag event. Assumes the default sleepTime.

Parameters:
testCase - JFCTestCase to fire the sleeps upon.
source - AbstractMouseEventData indicating the starting location of the drag event.
dest - AbstractMouseEventData indicating the ending location of the drag event.

DragEventData

public DragEventData(JFCTestCase testCase,
                     AbstractMouseEventData source,
                     AbstractMouseEventData dest,
                     long delay)
Constructor for a drag event.

Parameters:
testCase - TestCase.
source - AbstractMouseEventData indicating the starting location of the drag event.
dest - AbstractMouseEventData indicating the ending location of the drag event.
delay - sleepTime of the event.
Method Detail

getComponent

public final java.awt.Component getComponent()
This method is provided here to close the abstract base class.

Specified by:
getComponent in class AbstractEventData
Returns:
null This method always returns null.

getDefaultModifiers

public final int getDefaultModifiers()
Get the default modifiers.

Specified by:
getDefaultModifiers in class AbstractEventData
Returns:
default modifiers for the drag event.

setDest

public final void setDest(AbstractMouseEventData dest)
Set the Destination of the drag event.

Parameters:
dest - destination AbstractMouseEventData.

getDest

public final AbstractMouseEventData getDest()
Get the destination MouseEventData.

Returns:
The destination AbstractMouseEventData.

getModifierText

public final java.lang.String getModifierText()
Get the modifier text for the current.

Specified by:
getModifierText in class AbstractEventData
Returns:
String modifier text.

setPoints

public final void setPoints(java.awt.Point[] points)
Set the points in the drag path.

Parameters:
points - Set of points to be hit in the drag path.

getPoints

public final java.awt.Point[] getPoints()
Get the list of points in the drag path.

Returns:
Point[] list of points.

setSource

public final void setSource(AbstractMouseEventData source)
Set the Source of the drag event.

Parameters:
source - AbstractMouseEventData indicating the starting location of the drag event.

getSource

public final AbstractMouseEventData getSource()
Get the Source of the drag event.

Returns:
The source AbstractMouseEventData.

addPoint

public final void addPoint(java.awt.Point p)
Add a Point to the drag path.

Parameters:
p - Point to be hit along the drag path.

prepareComponent

public final boolean prepareComponent()
This prepares the source and dest components if set, and inserts/appends the screen locations onto the list of points.

Overrides:
prepareComponent in class AbstractEventData
Returns:
boolean true if the source and destination events were able to "prepare" their components.

canConsume

public boolean canConsume(java.awt.AWTEvent ae)
Check if this event can consume the AWTEvent.

Overrides:
canConsume in class AbstractEventData
Parameters:
ae - AWTEvent to be consumed.
Returns:
boolean true if the event can be consumed.

consume

public boolean consume(java.awt.AWTEvent ae)
Consume the AWTEvent.

Specified by:
consume in class AbstractEventData
Parameters:
ae - Event to be consumed.
Returns:
boolean true if the event was consumed.

equals

public boolean equals(java.lang.Object o)
Equals comparison.

Overrides:
equals in class AbstractEventData
Parameters:
o - Object to be compared.
Returns:
true if the objects are the same.

hashCode

public int hashCode()
Calculate a hashcode based upon the source and the dest of this class.

Overrides:
hashCode in class AbstractEventData
Returns:
int hashcode.

populate

public void populate(org.w3c.dom.Element e)
Populate the element wiht the data.

Overrides:
populate in class AbstractEventData
Parameters:
e - element to be populated.

toString

public java.lang.String toString()
Return a string representing the eventdata.

Overrides:
toString in class AbstractEventData
Returns:
String description of the event data.

convertToSource

private java.awt.Point convertToSource(java.awt.Component comp,
                                       java.awt.Point p)
Convert the point to the source coordinate system.

Parameters:
comp - Souce component.
p - Point to be converted.
Returns:
point of p related to source coordinates.


Licensed under: GNU Lesser General Public License, Ver 2.1, February 1999