public class RobotContext
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static Obstacle |
box
Box obstacle.
|
static Obstacle |
channel
Channel obstacle.
|
Constructor and Description |
---|
RobotContext()
Creates a RobotContext instance.
|
Modifier and Type | Method and Description |
---|---|
static void |
addMouseListener(GGMouseListener listener)
Registers a mouse listener to get left mouse button press,
release and drag events
|
void |
init()
Initializes the static context.
|
static void |
setLocation(int x,
int y)
Sets the location of the playground (pixel coordinates of the upper left vertex).
|
static void |
setStartDirection(double direction)
Sets the Nxt starting direction (zero to EAST).
|
static void |
setStartPosition(int x,
int y)
Sets the Nxt starting position (x-y-coordinates 0..500, origin at upper left).
|
static void |
setStatusText(java.lang.String text)
Displays the given text in the status bar (if available).
|
static void |
showNavigationBar()
Shows the navigation bar of the GameGrid and runs the simulation immediately.
|
static void |
showNavigationBar(boolean doRun)
Shows the navigation bar of the GameGrid.
|
static void |
showStatusBar(int height)
Shows a status bar with given height.
|
static void |
useBackground(java.lang.String filename)
Use the given image as background (playground size 501 x 501).
|
static void |
useObstacle(java.awt.image.BufferedImage bi,
int x,
int y)
Defines the given buffered image to be used as touch obstacle.
|
static void |
useObstacle(GGBitmap bm,
int x,
int y)
Defines the given GGBitmap to be used as touch obstacle.
|
static void |
useObstacle(Obstacle obstacle)
Defines the given obstacle to be used as touch obstacle.
|
static void |
useObstacle(Obstacle obstacle,
int x,
int y)
Defines the given obstacle to be used as touch obstacle.
|
static void |
useObstacle(java.lang.String filename,
int x,
int y)
Defines the given sprite image to be used as touch obstacle.
|
static void |
useShadow(int ulx,
int uly,
int lrx,
int lry)
Defines a shadow with given size and position.
|
static Target |
useTarget(java.awt.image.BufferedImage bi,
java.awt.Point[] mesh,
int x,
int y)
Creates a target for the ultrasonic sensor using the given buffered image.
|
static Target |
useTarget(GGBitmap bm,
java.awt.Point[] mesh,
int x,
int y)
Creates a target for the ultrasonic sensor using the given GGBitmap.
|
static Target |
useTarget(java.lang.String filename,
int[][] mesh,
int x,
int y)
Creates a target for the ultrasonic sensor using the given sprite image.
|
static Target |
useTarget(java.lang.String filename,
java.awt.Point[] mesh,
int x,
int y)
Creates a target for the ultrasonic sensor using the given sprite image.
|
static Target |
useTarget(Target target,
int x,
int y)
Defines a clone of the given target to be used as target.
|
static void |
useTorch(double power,
int x,
int y,
int z)
Defines a light source (torch) with given power at given position.
|
public static Obstacle box
public static Obstacle channel
public static void addMouseListener(GGMouseListener listener)
listener
- the GGMouseListener to registerpublic void init()
public static void useBackground(java.lang.String filename)
filename
- the image file to use as background.public static void setStartPosition(int x, int y)
x
- the x-coordinate of the starting positiony
- the y-coordinate of the starting positionpublic static void setStartDirection(double direction)
direction
- the starting direction in degrees)public static void setLocation(int x, int y)
x
- the x-pixel-coordinate of the upper left vertex (positive to the right)y
- the y-pixel-coordinate of the upper left vertex (positive to the bottom)public static void useObstacle(java.lang.String filename, int x, int y)
filename
- the image file of the obstaclex
- the x-coordinate of the image centery
- the y-coordinate of the image centerpublic static void useObstacle(java.awt.image.BufferedImage bi, int x, int y)
bi
- the buffered image of the obstaclex
- the x-coordinate of the image centery
- the y-coordinate of the image centerpublic static void useObstacle(Obstacle obstacle, int x, int y)
obstacle
- the obstacle to usex
- the x-coordinate of the image centery
- the y-coordinate of the image centerpublic static void useObstacle(Obstacle obstacle)
obstacle
- the obstacle to usepublic static void useObstacle(GGBitmap bm, int x, int y)
bm
- the GGBitmap to be used as obstaclex
- the x-coordinate of the image centery
- the y-coordinate of the image centerpublic static Target useTarget(java.lang.String filename, int[][] mesh, int x, int y)
filename
- the image file of the targetmesh
- the integer array of mesh points (as x-y-coordinates array) (at least 2)x
- the x-coordinate of the image centery
- the y-coordinate of the image centerpublic static Target useTarget(java.lang.String filename, java.awt.Point[] mesh, int x, int y)
filename
- the image file of the targetmesh
- the mesh points (at least 2)x
- the x-coordinate of the image centery
- the y-coordinate of the image centerpublic static Target useTarget(java.awt.image.BufferedImage bi, java.awt.Point[] mesh, int x, int y)
bi
- the buffered image of the targetmesh
- the mesh points (at least 2)x
- the x-coordinate of the image centery
- the y-coordinate of the image centerpublic static Target useTarget(GGBitmap bm, java.awt.Point[] mesh, int x, int y)
bm
- the GGBitmap to be used as targetmesh
- the mesh points (at least 2)x
- the x-coordinate of the image centery
- the y-coordinate of the image centerpublic static Target useTarget(Target target, int x, int y)
target
- the target to define the clonex
- the x-coordinate of the image centery
- the y-coordinate of the image centerpublic static void useTorch(double power, int x, int y, int z)
power
- the power of the light source (arbitrary units)x
- the x-coordinate of the torchy
- the y-coordinate of the torchz
- the z-coordinate of the torch (height above simulation plane)public static void useShadow(int ulx, int uly, int lrx, int lry)
public static void showNavigationBar(boolean doRun)
doRun
- if true, runs the simulation immediatetly; otherwise the start
button must be hit to run the simulationpublic static void showNavigationBar()
public static void showStatusBar(int height)
height
- the height of the status window in pixels.public static void setStatusText(java.lang.String text)
text
- the text to display.