ACT-CV - Machine Vision for Cognitive Modeling
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
Robot Class Reference

wrapper for java.awt.Robot More...

#include <Robot.h>

Inheritance diagram for Robot:
Inheritance graph
Collaboration diagram for Robot:
Collaboration graph

Public Member Functions

 Robot ()
 create a new VM and an instance of java.awt.Robot More...
 
 ~Robot ()
 destroy the VM More...
 
int GetScreenWidth () const
 
int GetScreenHeight () const
 
void AttachCurrentThread ()
 
void DetachCurrentThread ()
 
void SetAutoDelay (int ms)
 set the wait delay after generated events More...
 
void Delay (int ms)
 wait the given time More...
 
void MouseMove (int x, int y)
 move the mouse on the screen More...
 
void MousePress (int buttons)
 press (not click) a mouse button More...
 
void MouseRelease (int buttons)
 release a mouse button More...
 
void KeyPress (int keycode)
 press (not click) a key More...
 
void KeyRelease (int keycode)
 release a key on the keyboard More...
 
int GetPixelRGB (int x, int y)
 get the color of the screen of the given position More...
 
IplImage * GetScreenCapture (int left, int top, int right, int bottom)
 create a rectangular screen capture More...
 
- Public Member Functions inherited from JVM
 JVM ()
 create the VM with additional classpath "." More...
 
 JVM (const char *cp)
 create the VM with additional classpath cp More...
 
 ~JVM ()
 (don't) destroy the vm More...
 

Protected Member Functions

jobject CreateRect (int x, int y, int width, int height)
 create a new instance of java.awt.Rectangle More...
 
jobject CreateScreenRect ()
 create a new instance of java.awt.Rectangle for the whole screen More...
 
- Protected Member Functions inherited from JVM
JNIEnv * GetEnv ()
 the environment More...
 
void CreateJVM (const char *classpath)
 create the Java Virtual Machine More...
 
jobject CreateGlobalRef (jobject obj)
 hinder the VM from garbage collecting obj More...
 
jclass CreateGlobalRef (jclass obj)
 hinder the VM from garbage collecting obj More...
 
void AttachCurrentThread ()
 threads different from the one within which the VM was created must be attached More...
 
void DetachCurrentThread ()
 any attached thread has to be detached afterwards More...
 
int GetThreadId ()
 system specific code! More...
 
JavaVM * GetCreatedJavaVM ()
 pointer to an already created virtual machine More...
 

Protected Attributes

int screenWidth
 width of the screen at instantiation More...
 
int screenHeight
 height of the screen at instantiation More...
 
- Protected Attributes inherited from JVM
JavaVM * jvm
 pointer to the virtual machine More...
 

Private Attributes

jclass cls
 class java.awt.Robot More...
 
jobject robot
 an instance of java.awt.Robot More...
 
jclass colorCls
 class java.awt.Color More...
 
jclass rectCls
 class java.awt.Rectangle More...
 
jmethodID initRectMID
 method id of a constructor of java.awt.Rectangle More...
 
jmethodID setAutoDelayMID
 
jmethodID delayMID
 
jmethodID mouseMoveMID
 
jmethodID mousePressMID
 
jmethodID mouseReleaseMID
 
jmethodID keyPressMID
 
jmethodID keyReleaseMID
 
jmethodID getPixelColorMID
 
jmethodID getRGBMID
 
jmethodID createScreenCaptureMID
 
jclass bufrImgCls
 
jmethodID getRGBArrMID
 

Detailed Description

wrapper for java.awt.Robot

All method IDs are calculated at startup and cached

Method IDs are independent of the current environment and thread. Therefore there's no problem with caching them.

Definition at line 50 of file Robot.h.

Constructor & Destructor Documentation

Robot::Robot ( )
Robot::~Robot ( )

destroy the VM

Definition at line 135 of file Robot.cpp.

References JVM::GetEnv(), MHDBGMSG, and robot.

Member Function Documentation

void Robot::AttachCurrentThread ( )

Definition at line 95 of file Robot.h.

References JVM::AttachCurrentThread().

jobject Robot::CreateRect ( int  x,
int  y,
int  width,
int  height 
)
protected

create a new instance of java.awt.Rectangle

Definition at line 72 of file Robot.h.

References JVM::GetEnv(), initRectMID, and rectCls.

Referenced by CreateScreenRect(), and GetScreenCapture().

jobject Robot::CreateScreenRect ( )
protected

create a new instance of java.awt.Rectangle for the whole screen

Definition at line 141 of file Robot.cpp.

References CreateRect(), JVM::GetEnv(), rectCls, screenHeight, and screenWidth.

void Robot::Delay ( int  ms)

wait the given time

Definition at line 113 of file Robot.h.

References delayMID, JVM::GetEnv(), and robot.

void Robot::DetachCurrentThread ( )

Definition at line 98 of file Robot.h.

References JVM::DetachCurrentThread().

int Robot::GetPixelRGB ( int  x,
int  y 
)

get the color of the screen of the given position

Parameters
xhorizontal position in screen coordinates
yvertical position in screen coordinates

The origin of the screen coordinate system is the upper left corner of the screen.

Definition at line 159 of file Robot.cpp.

References JVM::GetEnv(), getPixelColorMID, getRGBMID, and robot.

IplImage * Robot::GetScreenCapture ( int  left,
int  top,
int  right,
int  bottom 
)

create a rectangular screen capture

left, top, right, bottom are the corners of the rectangle in screen coordinates

The origin of the screen coordinate system is the upper left corner of the screen.

The capture is returned as an IplImage* for the use with OpenCV

Warning
You have to release the returned image after you have used it. Otherwise the memory held by this structure will never be freed.

Definition at line 168 of file Robot.cpp.

References CreateRect(), createScreenCaptureMID, JVM::GetEnv(), getRGBArrMID, JVM::jint(), MHDBGMSG, MHDBGMSG_P, MULT, Rgb2Scalar(), and robot.

Referenced by RobotFrameSource::GetNextFrame().

int Robot::GetScreenHeight ( ) const

Definition at line 91 of file Robot.h.

References screenHeight.

Referenced by main(), and SelectSourceInternal().

int Robot::GetScreenWidth ( ) const

Definition at line 88 of file Robot.h.

References screenWidth.

Referenced by main(), and SelectSourceInternal().

void Robot::KeyPress ( int  keycode)

press (not click) a key

Definition at line 147 of file Robot.h.

References JVM::GetEnv(), keyPressMID, and robot.

void Robot::KeyRelease ( int  keycode)

release a key on the keyboard

Definition at line 155 of file Robot.h.

References JVM::GetEnv(), keyReleaseMID, and robot.

void Robot::MouseMove ( int  x,
int  y 
)

move the mouse on the screen

Definition at line 121 of file Robot.h.

References JVM::GetEnv(), mouseMoveMID, and robot.

void Robot::MousePress ( int  buttons)

press (not click) a mouse button

Definition at line 130 of file Robot.h.

References JVM::GetEnv(), mousePressMID, and robot.

void Robot::MouseRelease ( int  buttons)

release a mouse button

Definition at line 138 of file Robot.h.

References JVM::GetEnv(), mouseReleaseMID, and robot.

void Robot::SetAutoDelay ( int  ms)

set the wait delay after generated events

Definition at line 105 of file Robot.h.

References JVM::GetEnv(), robot, and setAutoDelayMID.

Member Data Documentation

jclass Robot::bufrImgCls
private

Definition at line 175 of file Robot.h.

Referenced by Robot().

jclass Robot::cls
private

class java.awt.Robot

Definition at line 53 of file Robot.h.

Referenced by Robot().

jclass Robot::colorCls
private

class java.awt.Color

Definition at line 58 of file Robot.h.

Referenced by Robot().

jmethodID Robot::createScreenCaptureMID
private

Definition at line 174 of file Robot.h.

Referenced by GetScreenCapture(), and Robot().

jmethodID Robot::delayMID
private

Definition at line 110 of file Robot.h.

Referenced by Delay(), and Robot().

jmethodID Robot::getPixelColorMID
private

Definition at line 160 of file Robot.h.

Referenced by GetPixelRGB(), and Robot().

jmethodID Robot::getRGBArrMID
private

Definition at line 176 of file Robot.h.

Referenced by GetScreenCapture(), and Robot().

jmethodID Robot::getRGBMID
private

Definition at line 161 of file Robot.h.

Referenced by GetPixelRGB(), and Robot().

jmethodID Robot::initRectMID
private

method id of a constructor of java.awt.Rectangle

Definition at line 63 of file Robot.h.

Referenced by CreateRect(), and Robot().

jmethodID Robot::keyPressMID
private

Definition at line 144 of file Robot.h.

Referenced by KeyPress(), and Robot().

jmethodID Robot::keyReleaseMID
private

Definition at line 152 of file Robot.h.

Referenced by KeyRelease(), and Robot().

jmethodID Robot::mouseMoveMID
private

Definition at line 118 of file Robot.h.

Referenced by MouseMove(), and Robot().

jmethodID Robot::mousePressMID
private

Definition at line 127 of file Robot.h.

Referenced by MousePress(), and Robot().

jmethodID Robot::mouseReleaseMID
private

Definition at line 135 of file Robot.h.

Referenced by MouseRelease(), and Robot().

jclass Robot::rectCls
private

class java.awt.Rectangle

Definition at line 61 of file Robot.h.

Referenced by CreateRect(), CreateScreenRect(), and Robot().

jobject Robot::robot
private

an instance of java.awt.Robot

Definition at line 55 of file Robot.h.

Referenced by Delay(), GetPixelRGB(), GetScreenCapture(), KeyPress(), KeyRelease(), MouseMove(), MousePress(), MouseRelease(), Robot(), SetAutoDelay(), and ~Robot().

int Robot::screenHeight
protected

height of the screen at instantiation

Definition at line 69 of file Robot.h.

Referenced by CreateScreenRect(), GetScreenHeight(), and Robot().

int Robot::screenWidth
protected

width of the screen at instantiation

Definition at line 67 of file Robot.h.

Referenced by CreateScreenRect(), GetScreenWidth(), and Robot().

jmethodID Robot::setAutoDelayMID
private

Definition at line 102 of file Robot.h.

Referenced by Robot(), and SetAutoDelay().


The documentation for this class was generated from the following files:


ACT-CV - Machine Vision for Cognitive Modeling
© 2015 Marc Halbruegge (actcvlibrary@googlemail.com)