net.officefloor.demo.play
Class MacroPlayer

java.lang.Object
  extended by net.officefloor.demo.play.MacroPlayer
All Implemented Interfaces:
MacroTaskContext

public class MacroPlayer
extends Object
implements MacroTaskContext

Plays the specified Macro instances.

Author:
Daniel Sagenschneider

Constructor Summary
MacroPlayer(int delay, Point offset)
          Initiate.
MacroPlayer(Robot robot, Point offset)
          Initiate allowing specifying the Robot to use.
 
Method Summary
 Point getAbsoluteLocation(Point relativeLocation)
           Obtains the absolute location for the relative location.
static int[] getCharacterKeyCodes(char character)
          Obtains the key codes for the character.
 Point getRelativeLocation(Point absoluteLocation)
           Obtains the relative location for the absolute location.
 void keyPress(int keycode)
          As per Robot.
 void keyRelease(int keycode)
          As per Robot.
 void keyStroke(int keycode)
          Convenience method to do press and release of key.
 void keyText(String text)
          Convenience method to type in text.
 void mouseClick(int buttons)
          Convenience method to do press and release of mouse button.
 void mouseMove(int x, int y)
          As per Robot.
 void mousePress(int buttons)
          As per Robot.
 void mouseRelease(int buttons)
          As per Robot.
 void mouseWheel(int wheelAmt)
          As per Robot.
 void play(Macro... macros)
          Plays the Macro instances in the order provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MacroPlayer

public MacroPlayer(int delay,
                   Point offset)
            throws AWTException
Initiate.

Parameters:
delay - Delay in between events for the player. The higher the value the slower the play.
offset - Reference point for relative locations.
Throws:
AWTException - If fails to initialise for playing.

MacroPlayer

public MacroPlayer(Robot robot,
                   Point offset)
Initiate allowing specifying the Robot to use.

Parameters:
robot - Robot to use for playing.
offset - Reference point for relative locations.
Method Detail

getCharacterKeyCodes

public static int[] getCharacterKeyCodes(char character)
                                  throws UnsupportedOperationException
Obtains the key codes for the character.

Parameters:
character - Character.
Returns:
Key codes for the character.
Throws:
UnsupportedOperationException - If unsupported character.
See Also:
KeyEvent

play

public void play(Macro... macros)
Plays the Macro instances in the order provided.

Parameters:
macros - Macro instances to play.

mouseMove

public void mouseMove(int x,
                      int y)
Description copied from interface: MacroTaskContext
As per Robot.

Specified by:
mouseMove in interface MacroTaskContext
Parameters:
x - X location.
y - Y location.

mousePress

public void mousePress(int buttons)
Description copied from interface: MacroTaskContext
As per Robot.

Specified by:
mousePress in interface MacroTaskContext
Parameters:
buttons - Buttons.

mouseRelease

public void mouseRelease(int buttons)
Description copied from interface: MacroTaskContext
As per Robot.

Specified by:
mouseRelease in interface MacroTaskContext
Parameters:
buttons - Buttons.

mouseClick

public void mouseClick(int buttons)
Description copied from interface: MacroTaskContext
Convenience method to do press and release of mouse button.

Specified by:
mouseClick in interface MacroTaskContext
Parameters:
buttons - Buttons as per Robot.

mouseWheel

public void mouseWheel(int wheelAmt)
Description copied from interface: MacroTaskContext
As per Robot.

Specified by:
mouseWheel in interface MacroTaskContext

keyPress

public void keyPress(int keycode)
Description copied from interface: MacroTaskContext
As per Robot.

Specified by:
keyPress in interface MacroTaskContext
Parameters:
keycode - Key code.

keyRelease

public void keyRelease(int keycode)
Description copied from interface: MacroTaskContext
As per Robot.

Specified by:
keyRelease in interface MacroTaskContext
Parameters:
keycode - Key code.

keyStroke

public void keyStroke(int keycode)
Description copied from interface: MacroTaskContext
Convenience method to do press and release of key.

Specified by:
keyStroke in interface MacroTaskContext
Parameters:
keycode - Key code as per Robot.

keyText

public void keyText(String text)
Description copied from interface: MacroTaskContext
Convenience method to type in text.

Specified by:
keyText in interface MacroTaskContext
Parameters:
text - Text to be typed in.

getAbsoluteLocation

public Point getAbsoluteLocation(Point relativeLocation)
Description copied from interface: MacroTaskContext

Obtains the absolute location for the relative location.

This is useful for example to display a JDialog and position correctly.

Specified by:
getAbsoluteLocation in interface MacroTaskContext
Parameters:
relativeLocation - Relative location.
Returns:
Absolute location.

getRelativeLocation

public Point getRelativeLocation(Point absoluteLocation)
Description copied from interface: MacroTaskContext

Obtains the relative location for the absolute location.

This is useful for example to find the relative location for a mouse move where the active window only provides an absolute location.

Specified by:
getRelativeLocation in interface MacroTaskContext
Parameters:
absoluteLocation - Absolute location.
Returns:
Relative location.


Copyright © 2005-2011. All Rights Reserved.