org.sikuli.api
Interface ScreenRegion

All Superinterfaces:
Region
All Known Implementing Classes:
AbstractScreenRegion, DefaultScreenRegion, DesktopScreenRegion, StaticImageScreenRegion

public interface ScreenRegion
extends Region

The ScreenRegion interface provides definitions for the objects that represent regions of the screen.


Method Summary
 void addROI(int x, int y, int width, int height)
          Add a rectangular region of interest into this ScreenRegion.
 void addState(Target target, Object state)
          Defines a new state of this screen region as represented by the presence of the given target.
 void addStateChangeEventListener(StateChangeListener listener)
          Adds a listener to handle the state changes within this screen region.
 void addTargetEventListener(Target target, TargetEventListener listener)
          Adds a listener for a given target.
 BufferedImage capture()
          Captures and returns a screenshot of this screen region.
 ScreenRegion find(Target target)
          Finds a target on the screen immediately.
 List<ScreenRegion> findAll(Target target)
          Finds all the instances of the target on the screen immediately.
 ScreenLocation getCenter()
          Returns the center of this screen region.
 BufferedImage getLastCapturedImage()
          Returns the last captured image of this ScreenRegion.
 ScreenLocation getLowerLeftCorner()
          Returns the lower-left corner of this screen region.
 ScreenLocation getLowerRightCorner()
          Returns the lower-right corner of this screen region.
 ScreenLocation getRelativeScreenLocation(int xoffset, int yoffset)
          Returns a ScreenRegion relative to the specified region values.
 ScreenRegion getRelativeScreenRegion(int xoffset, int yoffset, int width, int height)
          Returns a ScreenRegion relative to the specified region values.
 List<Rectangle> getROIs()
          Returns a list of Rectangle that represent the rectangular regions of interest for this ScreenRegion.
 double getScore()
          Returns the minimum matching score of this ScreenRegion, which is set if this screen region was returned as the result of a find command.
 Screen getScreen()
          Returns a Screen object of this ScreenRegion.
 Object getState()
          Returns the state of this ScreenRegion.
 Map<Target,Object> getStates()
          Returns a map of Target objects and states, which can be any object, for this screen region.
 ScreenLocation getUpperLeftCorner()
          Returns the upper-left corner of this screen region.
 ScreenLocation getUpperRightCorner()
          Returns the upper-right corner of this screen region.
 void removeState(Target target)
          Removes a particular state represented by the given target from this screen region.
 void removeTargetEventListener(Target target, TargetEventListener listener)
          Removes a particular listener for a particular target.
 void setScore(double score)
          Sets the minimum matching score value for a target to be considered a match.
 void setScreen(Screen screen)
          Sets the Screen of this ScreenRegion to be the specified Screen.
 ScreenRegion snapshot()
          Returns a ScreenRegion object that corresponds to the screen and region of this ScreenRegion.
 ScreenRegion wait(Target target, int mills)
          Blocks and waits until a target is found in this screen region within a given time period.
 
Methods inherited from interface org.sikuli.api.Region
getBounds, getHeight, getWidth, getX, getY, setBounds
 

Method Detail

getScreen

Screen getScreen()
Returns a Screen object of this ScreenRegion.

Returns:
a Screen object that represents the Screen of this ScreenRegion.

setScreen

void setScreen(Screen screen)
Sets the Screen of this ScreenRegion to be the specified Screen.

Parameters:
screen - the Screen for this ScreenRegion.

getRelativeScreenRegion

ScreenRegion getRelativeScreenRegion(int xoffset,
                                     int yoffset,
                                     int width,
                                     int height)
Returns a ScreenRegion relative to the specified region values.

Parameters:
xoffset - Horizontal offset.
yoffset - Vertical offset.
width - the width of this ScreenRegion.
height - the height of this ScreenRegion.
Returns:
a ScreenRegion relative to the specified region values.

getRelativeScreenLocation

ScreenLocation getRelativeScreenLocation(int xoffset,
                                         int yoffset)
Returns a ScreenRegion relative to the specified region values.

Parameters:
xoffset - Horizontal offset.
yoffset - Vertical offset.
Returns:

getUpperLeftCorner

ScreenLocation getUpperLeftCorner()
Returns the upper-left corner of this screen region.

Returns:
a Location object corresponding to the upper-left corner of the screen region.

getLowerLeftCorner

ScreenLocation getLowerLeftCorner()
Returns the lower-left corner of this screen region.

Returns:
a Location object corresponding to the lower-left corner of the screen region.

getUpperRightCorner

ScreenLocation getUpperRightCorner()
Returns the upper-right corner of this screen region.

Returns:
a Location object corresponding to the upper-right corner of the screen region.

getLowerRightCorner

ScreenLocation getLowerRightCorner()
Returns the lower-right corner of this screen region.

Returns:
a Location object corresponding to the lower-right corner of the screen region.

getCenter

ScreenLocation getCenter()
Returns the center of this screen region.

Returns:
a Location object corresponding to the center of the screen region.

getScore

double getScore()
Returns the minimum matching score of this ScreenRegion, which is set if this screen region was returned as the result of a find command. The score should be between 0 and 1 where 1 is the best.

Returns:
the minimum matching score value for a target to be considered a match.

setScore

void setScore(double score)
Sets the minimum matching score value for a target to be considered a match. This score indicates how similar the match is to the target specified. It accepts a value between 0 and 1. A high score close to 1 means the match must be very similar to the target specified. A low score means a match only somehow similar is acceptable; image recognition is more fuzzy.

Parameters:
score - the minimum matching score value for a target to be considered a match. The value should be between 0 and 1.

addState

void addState(Target target,
              Object state)
Defines a new state of this screen region as represented by the presence of the given target.

Parameters:
target - the target whose presence indicates this state.
state - the state, which can be any object.

removeState

void removeState(Target target)
Removes a particular state represented by the given target from this screen region.

Parameters:
target - the representative target of the state to remove.

getState

Object getState()
Returns the state of this ScreenRegion.

Returns:
the state of this ScreenRegion.

findAll

List<ScreenRegion> findAll(Target target)
Finds all the instances of the target on the screen immediately.

Parameters:
target - the target to find.
Returns:
a list of ScreenRegions, each of which corresponds to a found target, or an empty list. if no such target can be found.

find

ScreenRegion find(Target target)
Finds a target on the screen immediately.

Parameters:
target - the target to find on the current screen.
Returns:
the screen region occupied by the found target or null if the can not be found now.

wait

ScreenRegion wait(Target target,
                  int mills)
Blocks and waits until a target is found in this screen region within a given time period.

Parameters:
target - the target to wait.
mills - the maximum time to wait in milliseconds.
Returns:
a ScreenRegion object representing the region occupied by the found target, or null if the specified target can not be found within the given time.

capture

BufferedImage capture()
Captures and returns a screenshot of this screen region.

Returns:
a BufferedImage containing the screenshot. The type of the image is TYPE_3BYTE_BGR.

addTargetEventListener

void addTargetEventListener(Target target,
                            TargetEventListener listener)
Adds a listener for a given target.

Parameters:
target - the target to listener its events for.
listener - the listener to handle the events associated with the target.

removeTargetEventListener

void removeTargetEventListener(Target target,
                               TargetEventListener listener)
Removes a particular listener for a particular target.

Parameters:
target - the target from which the given listener should be removed.
listener - the listener to remove from the given target.

snapshot

ScreenRegion snapshot()
Returns a ScreenRegion object that corresponds to the screen and region of this ScreenRegion.

Returns:
a ScreenRegion that corresponds to the region of this ScreenRegion.

addStateChangeEventListener

void addStateChangeEventListener(StateChangeListener listener)
Adds a listener to handle the state changes within this screen region.

Parameters:
listener - the listener to handle state changes in this screen region.

getStates

Map<Target,Object> getStates()
Returns a map of Target objects and states, which can be any object, for this screen region.

Returns:
a map of Target objects and their states.

addROI

void addROI(int x,
            int y,
            int width,
            int height)
Add a rectangular region of interest into this ScreenRegion.

Parameters:
x - The X coordinate of the upper-left corner of the rectangle to be added.
y - The Y coordinate of the upper-left corner of the rectangle to be added.
width - The width of the rectangle.
height - width The width of the rectangle.

getROIs

List<Rectangle> getROIs()
Returns a list of Rectangle that represent the rectangular regions of interest for this ScreenRegion.

Returns:
a list of rectangles.

getLastCapturedImage

BufferedImage getLastCapturedImage()
Returns the last captured image of this ScreenRegion.

Returns:
a BufferedImage that contains the last captured image of this ScreenRegion.


Copyright © 2014. All rights reserved.