net.sourceforge.groboutils.uicapture.v1
Class ScriptGenerator

java.lang.Object
  extended bynet.sourceforge.groboutils.uicapture.v1.ScriptGenerator
All Implemented Interfaces:
IAllowCapturePassThroughListener, ICaptureListener

public class ScriptGenerator
extends java.lang.Object
implements ICaptureListener, IAllowCapturePassThroughListener

Listens to CaptureEvents, and converts these into script commands to the IScriptMaker. It allows for easy subclassing through having a "Meta-Mode". All events will be swallowed (not passed to the UI or IScriptMaker) while in this meta-mode.

Version:
Jan 7, 2002
Author:
Matt Albrecht groboclown@users.sourceforge.net

Constructor Summary
ScriptGenerator(IScreenScraper ss, IFocusedWindowFinder fwf, IScriptMaker maker, java.lang.String baseImageName)
          Create using the given arguments to build the framework.
ScriptGenerator(IScriptMaker maker, java.lang.String baseImageName)
          Uses the Default version for the IScreenScraper and IFocusedWindowFinder.
 
Method Summary
 boolean allowKeyPressed(KeyPressedCaptureEvent ce)
           
 boolean allowKeyReleased(KeyReleasedCaptureEvent ce)
           
 boolean allowMouseMoved(MouseMovedCaptureEvent ce)
          Not part of the allow interface.
 boolean allowMousePressed(MousePressedCaptureEvent ce)
           
 boolean allowMouseReleased(MouseReleasedCaptureEvent ce)
           
 boolean allowMouseWheelMoved(MouseWheelCaptureEvent ce)
           
 void begin()
           
protected  java.io.File createFile()
           
protected  void encounteredError(java.lang.Throwable t)
           
 void end()
           
protected  void fireKeyPressed(KeyCaptureEvent ce)
           
protected  void fireKeyReleased(KeyCaptureEvent ce)
           
protected  void fireMouseMoved(MouseMovedCaptureEvent ce)
           
protected  void fireMousePressed(MouseButtonCaptureEvent ce)
           
protected  void fireMouseReleased(MouseButtonCaptureEvent ce)
           
protected  void fireMouseWheelMoved(MouseWheelCaptureEvent ce)
           
protected  void fireSaveFocusedWindow()
          Saves a picture of the underlying UI's focused window to a file.
protected  void fireSaveScreen()
          Saves the entire screen to a file.
protected  void fireSaveScreenImage(int x, int y, int w, int h)
          Saves the selected screen part to a file.
protected  void fireSaveScreenImage(java.awt.Rectangle bounds)
          Saves the selected screen part to a file.
protected  void fireStop()
           
protected  void generateDelay(CaptureEvent ce)
          Create a delay event in the script maker.
protected  long getDelayTime(CaptureEvent ce)
          Calculate the amount of time between the last event and the given event.
 boolean isInMetaMode()
           
 boolean isRunning()
           
 void keyPressed(KeyPressedCaptureEvent ce)
          If a subclass overrides this method, it must first check if meta-mode is enabled, and invoke the super's version of this method at the very end (right before leaving the method).
 void keyReleased(KeyReleasedCaptureEvent ce)
          If a subclass overrides this method, it must first check if meta-mode is enabled, and invoke the super's version of this method at the very end (right before leaving the method).
protected  void metaKeyPressed(KeyPressedCaptureEvent ce)
          Performs a meta-mode action when this event is caught and the generator is in meta-mode.
protected  void metaKeyReleased(KeyReleasedCaptureEvent ce)
          Performs a meta-mode action when this event is caught and the generator is in meta-mode.
protected  void metaMouseMoved(MouseMovedCaptureEvent ce)
          Performs a meta-mode action when this event is caught and the generator is in meta-mode.
protected  void metaMousePressed(MousePressedCaptureEvent ce)
          Performs a meta-mode action when this event is caught and the generator is in meta-mode.
protected  void metaMouseReleased(MouseReleasedCaptureEvent ce)
          Performs a meta-mode action when this event is caught and the generator is in meta-mode.
protected  void metaMouseWheelMoved(MouseWheelCaptureEvent ce)
          Performs a meta-mode action when this event is caught and the generator is in meta-mode.
 void mouseMoved(MouseMovedCaptureEvent ce)
          If a subclass overrides this method, it must first check if meta-mode is enabled, and invoke the super's version of this method at the very end (right before leaving the method).
 void mousePressed(MousePressedCaptureEvent ce)
          If a subclass overrides this method, it must first check if meta-mode is enabled, and invoke the super's version of this method at the very end (right before leaving the method).
 void mouseReleased(MouseReleasedCaptureEvent ce)
          If a subclass overrides this method, it must first check if meta-mode is enabled, and invoke the super's version of this method at the very end (right before leaving the method).
 void mouseWheelMoved(MouseWheelCaptureEvent ce)
          If a subclass overrides this method, it must first check if meta-mode is enabled, and invoke the super's version of this method at the very end (right before leaving the method).
 void setInMetaMode(boolean set)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptGenerator

public ScriptGenerator(IScriptMaker maker,
                       java.lang.String baseImageName)
Uses the Default version for the IScreenScraper and IFocusedWindowFinder.


ScriptGenerator

public ScriptGenerator(IScreenScraper ss,
                       IFocusedWindowFinder fwf,
                       IScriptMaker maker,
                       java.lang.String baseImageName)
Create using the given arguments to build the framework.

Method Detail

begin

public void begin()
           throws java.awt.AWTException
Throws:
java.awt.AWTException - Robot isn't supported.

end

public void end()

isRunning

public boolean isRunning()

isInMetaMode

public boolean isInMetaMode()

setInMetaMode

public void setInMetaMode(boolean set)

metaMouseWheelMoved

protected void metaMouseWheelMoved(MouseWheelCaptureEvent ce)
Performs a meta-mode action when this event is caught and the generator is in meta-mode. Default action does nothing.


metaMousePressed

protected void metaMousePressed(MousePressedCaptureEvent ce)
Performs a meta-mode action when this event is caught and the generator is in meta-mode. Default action does nothing.


metaMouseReleased

protected void metaMouseReleased(MouseReleasedCaptureEvent ce)
Performs a meta-mode action when this event is caught and the generator is in meta-mode. Default action does nothing.


metaKeyPressed

protected void metaKeyPressed(KeyPressedCaptureEvent ce)
Performs a meta-mode action when this event is caught and the generator is in meta-mode. Default action does nothing.


metaKeyReleased

protected void metaKeyReleased(KeyReleasedCaptureEvent ce)
Performs a meta-mode action when this event is caught and the generator is in meta-mode. Default action does nothing.


metaMouseMoved

protected void metaMouseMoved(MouseMovedCaptureEvent ce)
Performs a meta-mode action when this event is caught and the generator is in meta-mode. Default action does nothing.


fireStop

protected void fireStop()

fireSaveScreen

protected void fireSaveScreen()
Saves the entire screen to a file.


fireSaveFocusedWindow

protected void fireSaveFocusedWindow()
Saves a picture of the underlying UI's focused window to a file.


fireSaveScreenImage

protected void fireSaveScreenImage(int x,
                                   int y,
                                   int w,
                                   int h)
Saves the selected screen part to a file.

Parameters:
x - the x position of the part of the screen to grab.
y - the y position of the part of the screen to grab.
w - the width of the part of the screen to grab.
h - the height of the part of the screen to grab.

fireSaveScreenImage

protected void fireSaveScreenImage(java.awt.Rectangle bounds)
Saves the selected screen part to a file.

Parameters:
bounds - the part of the screen to grab.

fireMouseWheelMoved

protected void fireMouseWheelMoved(MouseWheelCaptureEvent ce)

fireMouseMoved

protected void fireMouseMoved(MouseMovedCaptureEvent ce)

fireMousePressed

protected void fireMousePressed(MouseButtonCaptureEvent ce)

fireMouseReleased

protected void fireMouseReleased(MouseButtonCaptureEvent ce)

fireKeyPressed

protected void fireKeyPressed(KeyCaptureEvent ce)

fireKeyReleased

protected void fireKeyReleased(KeyCaptureEvent ce)

mouseWheelMoved

public void mouseWheelMoved(MouseWheelCaptureEvent ce)
If a subclass overrides this method, it must first check if meta-mode is enabled, and invoke the super's version of this method at the very end (right before leaving the method).

Specified by:
mouseWheelMoved in interface ICaptureListener
See Also:
MouseWheelListener

mouseMoved

public void mouseMoved(MouseMovedCaptureEvent ce)
If a subclass overrides this method, it must first check if meta-mode is enabled, and invoke the super's version of this method at the very end (right before leaving the method).

Specified by:
mouseMoved in interface ICaptureListener
See Also:
MouseMotionListener

mousePressed

public void mousePressed(MousePressedCaptureEvent ce)
If a subclass overrides this method, it must first check if meta-mode is enabled, and invoke the super's version of this method at the very end (right before leaving the method).

Specified by:
mousePressed in interface ICaptureListener
See Also:
MouseListener

mouseReleased

public void mouseReleased(MouseReleasedCaptureEvent ce)
If a subclass overrides this method, it must first check if meta-mode is enabled, and invoke the super's version of this method at the very end (right before leaving the method).

Specified by:
mouseReleased in interface ICaptureListener
See Also:
MouseListener

keyPressed

public void keyPressed(KeyPressedCaptureEvent ce)
If a subclass overrides this method, it must first check if meta-mode is enabled, and invoke the super's version of this method at the very end (right before leaving the method).

Specified by:
keyPressed in interface ICaptureListener
See Also:
KeyListener

keyReleased

public void keyReleased(KeyReleasedCaptureEvent ce)
If a subclass overrides this method, it must first check if meta-mode is enabled, and invoke the super's version of this method at the very end (right before leaving the method).

Specified by:
keyReleased in interface ICaptureListener
See Also:
KeyListener

allowMouseWheelMoved

public final boolean allowMouseWheelMoved(MouseWheelCaptureEvent ce)
Specified by:
allowMouseWheelMoved in interface IAllowCapturePassThroughListener
Returns:
true to allow the event to passed to the underlying UI, or false to 'swallow' the event.
See Also:
MouseWheelListener

allowMousePressed

public final boolean allowMousePressed(MousePressedCaptureEvent ce)
Specified by:
allowMousePressed in interface IAllowCapturePassThroughListener
Returns:
true to allow the event to passed to the underlying UI, or false to 'swallow' the event.
See Also:
MouseListener

allowMouseReleased

public final boolean allowMouseReleased(MouseReleasedCaptureEvent ce)
Specified by:
allowMouseReleased in interface IAllowCapturePassThroughListener
Returns:
true to allow the event to passed to the underlying UI, or false to 'swallow' the event.
See Also:
MouseListener

allowKeyPressed

public final boolean allowKeyPressed(KeyPressedCaptureEvent ce)
Specified by:
allowKeyPressed in interface IAllowCapturePassThroughListener
Returns:
true to allow the event to passed to the underlying UI, or false to 'swallow' the event.
See Also:
KeyListener

allowKeyReleased

public final boolean allowKeyReleased(KeyReleasedCaptureEvent ce)
Specified by:
allowKeyReleased in interface IAllowCapturePassThroughListener
Returns:
true to allow the event to passed to the underlying UI, or false to 'swallow' the event.
See Also:
KeyListener

allowMouseMoved

public final boolean allowMouseMoved(MouseMovedCaptureEvent ce)
Not part of the allow interface.

Returns:
true to allow the event to passed to the underlying UI, or false to 'swallow' the event.

generateDelay

protected void generateDelay(CaptureEvent ce)
Create a delay event in the script maker.


getDelayTime

protected long getDelayTime(CaptureEvent ce)
Calculate the amount of time between the last event and the given event.

Returns:
the delay time in milliseconds.

createFile

protected java.io.File createFile()

encounteredError

protected void encounteredError(java.lang.Throwable t)


Copyright © 2001-2003 by The GroboUtils Project