junit.extensions.jfcunit.eventdata
Class AbstractEventData

java.lang.Object
  extended byjunit.extensions.jfcunit.eventdata.AbstractEventData
All Implemented Interfaces:
EventDataConstants
Direct Known Subclasses:
AbstractKeyEventData, AbstractMouseEventData, DragEventData

public abstract class AbstractEventData
extends java.lang.Object
implements EventDataConstants

Abstract data container class that holds most of the data necessary for jfcUnit to fire events.

Author:
Vijay Aravamudhan : ThoughtWorks Inc.

Field Summary
private  int m_modifiers
          The modifier key values that need to be passed onto the event.
private  int m_position
          The position to place the mouse within the component.
private  java.awt.Point m_referencePoint
          The reference point to place the mouse.
private  java.awt.Point m_screenLocation
          The screen location to place the mouse.
private  long m_sleepTime
          The wait time in ms between each event.
private  JFCTestCase m_testCase
          The JFCTestCase on whose thread awtSleep() has to be invoked.
private  boolean m_valid
          State of event data.
 
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
AbstractEventData()
           
 
Method Summary
protected  java.awt.Point calculatePoint(java.awt.Rectangle rect)
          A utility method to calculate the Point at which the events are to be fired based on the position and reference-point specified.
protected  boolean canConsume(java.awt.AWTEvent ae)
          Check if this event can consume the AWTEvent.
abstract  boolean consume(java.awt.AWTEvent ae)
          Consume the Event.
 boolean equals(java.lang.Object o)
          Compare to event datas and deterime if they are equal.
abstract  java.awt.Component getComponent()
          The source Component on which the event has to be fired.
abstract  int getDefaultModifiers()
          Get the default modifiers.
 int getDefaultPosition()
          Get the default position.
 long getDefaultSleepTime()
          Get the default sleep time.
 java.awt.Point getLocationOnScreen()
          Get the screen location for the event.
 int getModifiers()
          Get the attribute value.
(package private) abstract  java.lang.String getModifierText()
          Get the modifier text for the current modifiers.
 int getPosition()
          Get the attribute value.
 java.awt.Point getReferencePoint()
          Get the attribute value.
 java.awt.Component getRoot()
          Return the root Container of the current Component.
 java.awt.Component getRoot(java.awt.Component c)
          Return the root Container of the specified Component.
 long getSleepTime()
          Get the attribute value.
 JFCTestCase getTestCase()
          Get the attribute value.
 int hashCode()
          Returns the hashCode of the contained component.
 boolean isMetaChar(int keyCode)
          Returns true if the keyCode refers to a meta character.
 boolean isValid()
          Get the valid state.
protected  boolean isValidForProcessing(java.awt.Component comp)
          Checks whether a component is valid for processing using jfcUnit.
 void populate(org.w3c.dom.Element e)
          Populate the Element with the attributes to recreate this event data.
 boolean prepareComponent()
          Prepare the component to receive the Event by calling requestFocus() on the Component and calculating the screen location.
protected  void setLocationOnScreen(java.awt.Point screenLocation)
          Set the screen location for the event.
 void setModifiers(int modifiers)
          Set the attribute value.
 void setPosition(int position)
          Set the attribute value.
 void setReferencePoint(java.awt.Point referencePoint)
          Set the attribute value.
 void setSleepTime(long sleepTime)
          Set the attribute value.
 void setTestCase(JFCTestCase testCase)
          Set the attribute value.
 void setValid(boolean valid)
          Set valid state.
 java.lang.String toString()
          Get the String description of the abstract event.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m_testCase

private JFCTestCase m_testCase
The JFCTestCase on whose thread awtSleep() has to be invoked.


m_referencePoint

private java.awt.Point m_referencePoint
The reference point to place the mouse. Either custom set or derived from the screen location.


m_screenLocation

private java.awt.Point m_screenLocation
The screen location to place the mouse.


m_valid

private boolean m_valid
State of event data. If invalid then data has not been loaded into the event yet.


m_modifiers

private int m_modifiers
The modifier key values that need to be passed onto the event.


m_position

private int m_position
The position to place the mouse within the component.


m_sleepTime

private long m_sleepTime
The wait time in ms between each event.

Constructor Detail

AbstractEventData

public AbstractEventData()
Method Detail

setTestCase

public final void setTestCase(JFCTestCase testCase)
Set the attribute value.

Parameters:
testCase - The new value of the attribute

getTestCase

public final JFCTestCase getTestCase()
Get the attribute value.

Returns:
JFCTestCase The value of the attribute

getComponent

public abstract java.awt.Component getComponent()
The source Component on which the event has to be fired.

Returns:
The source Component

getDefaultPosition

public int getDefaultPosition()
Get the default position.

Returns:
Default position.

getDefaultSleepTime

public long getDefaultSleepTime()
Get the default sleep time.

Returns:
ms sleep time.

getLocationOnScreen

public final java.awt.Point getLocationOnScreen()
Get the screen location for the event.

Returns:
Point screen location for the event.

isMetaChar

public final boolean isMetaChar(int keyCode)
Returns true if the keyCode refers to a meta character.

Parameters:
keyCode - code to be checked.
Returns:
boolean true if the keyCode is a meta key.

setModifiers

public void setModifiers(int modifiers)
Set the attribute value.

Parameters:
modifiers - The new value of the attribute

getModifiers

public final int getModifiers()
Get the attribute value.

Returns:
int The value of the attribute

getDefaultModifiers

public abstract int getDefaultModifiers()
Get the default modifiers.

Returns:
default modifiers for the event.

setPosition

public void setPosition(int position)
Set the attribute value.

Parameters:
position - The value of the attribute

getPosition

public int getPosition()
Get the attribute value.

Returns:
int The value of the attribute

setReferencePoint

public void setReferencePoint(java.awt.Point referencePoint)
Set the attribute value.

Parameters:
referencePoint - The value of the attribute

getReferencePoint

public java.awt.Point getReferencePoint()
Get the attribute value.

Returns:
Point The value of the attribute

getRoot

public java.awt.Component getRoot()
Return the root Container of the current Component.

Returns:
The root Container.

getRoot

public java.awt.Component getRoot(java.awt.Component c)
Return the root Container of the specified Component.

Parameters:
c - The Component to obtain the root for.
Returns:
The root Container.

setSleepTime

public void setSleepTime(long sleepTime)
Set the attribute value.

Parameters:
sleepTime - The new value of the attribute

getSleepTime

public long getSleepTime()
Get the attribute value.

Returns:
long The value of the attribute

consume

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

Parameters:
ae - Event to be consumed.
Returns:
boolean true if the event was consumed.

setValid

public final void setValid(boolean valid)
Set valid state.

Parameters:
valid - true if the event has data configured.

isValid

public final boolean isValid()
Get the valid state.

Returns:
boolean true if the event is valid.

equals

public boolean equals(java.lang.Object o)
Compare to event datas and deterime if they are equal.

Parameters:
o - Object to be compared.
Returns:
true if the events are the same.

hashCode

public int hashCode()
Returns the hashCode of the contained component.

Returns:
int hashCode.

populate

public void populate(org.w3c.dom.Element e)
Populate the Element with the attributes to recreate this event data.

Parameters:
e - Element to be populated.

prepareComponent

public boolean prepareComponent()
Prepare the component to receive the Event by calling requestFocus() on the Component and calculating the screen location.

Returns:
true if the component is ready to receive the Event.

toString

public java.lang.String toString()
Get the String description of the abstract event.

Returns:
String description of the event.

setLocationOnScreen

protected final void setLocationOnScreen(java.awt.Point screenLocation)
Set the screen location for the event.

Parameters:
screenLocation - screenLocation for event.

isValidForProcessing

protected boolean isValidForProcessing(java.awt.Component comp)
Checks whether a component is valid for processing using jfcUnit.

Parameters:
comp - The Component to be tested.
Returns:
boolean specifying whether this component is not null and is showing.

calculatePoint

protected final java.awt.Point calculatePoint(java.awt.Rectangle rect)
A utility method to calculate the Point at which the events are to be fired based on the position and reference-point specified.

Parameters:
rect - The Rectangle containing the source component.
Returns:
The new Point at which the mouse events have to be fired.

canConsume

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

Parameters:
ae - Event to be consumed.
Returns:
boolean true if the event can be consumed.

getModifierText

abstract java.lang.String getModifierText()
Get the modifier text for the current modifiers.

Returns:
String with modifiers separated by the +. Ex: Alt+Shift


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