|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object kareltherobot.World
Build and maintain the world in which Robots work and play. The normal operation is to show the world in its own frame, which is initially not visible. You can either call World.setVisible(true) to show this frame or extract its Canvas with World.worldCanvas() if you would rather show the world in another context. You can save worlds in files and restore them. You can even create the worlds in a text editor. For information on the external form of worlds see http://csis.pace.edu/~bergin/KarelJava2ed/karelexperimental.html , This format is also assumed by getWorld and is produced by asText when the separator is a newline. Note that the features here are not intended for normal robot programming, but for world initialization and maintenance.
Nested Class Summary |
Nested classes inherited from class kareltherobot.Directions |
Directions.Direction |
Field Summary | |
static World |
asObject
|
Fields inherited from interface kareltherobot.Directions |
East, EastVal, infinity, North, NorthVal, South, SouthVal, West, WestVal |
Method Summary | |
static World |
asObject()
|
static java.lang.String |
asText(java.lang.String sep)
Return a String version of the world's contents suitable for saving and restoring. |
static int |
delay()
Return the current delay value. |
static void |
getWorld(java.lang.String commands)
Read a world from a string. |
static void |
makeView()
|
static void |
placeBeepers(int Street,
int Avenue,
int howMany)
Put some beepers on a corner. |
static void |
placeEWWall(int NorthOfStreet,
int atAvenue,
int lengthTowardEast)
Place a chain of East-West walls. |
static void |
placeNSWall(int atStreet,
int EastOfAvenue,
int lengthTowardNorth)
Place a chain of North-South walls. |
static void |
readWorld(java.lang.String filename)
Read a world from a file in the current directory. |
static void |
readWorld(java.lang.String directoryPath,
java.lang.String filename)
Read a world from a file in the given directory path. |
static void |
repaint()
Repaint the world. |
static void |
replaceCloser(java.awt.event.WindowListener w)
Replace the standard window closer (which calls exit) of the frame with one of your choice. |
static void |
reset()
Remove everything from this world. |
static void |
resume()
Resume all the threads after stopping them. |
static void |
saveWorld(java.lang.String filename)
Save the world in a file in the current directory. |
static void |
saveWorld(java.lang.String directoryPath,
java.lang.String filename)
Save the world in a file in the given directory path. |
static void |
saveXMLWorld(java.lang.String filename)
|
static void |
saveXMLWorld(java.lang.String directoryPath,
java.lang.String filename)
Save a world in XML format |
static void |
setBeeperColor(java.awt.Color color)
Change the color of beepers from the standard black to any color you choose. |
static void |
setDelay(int d)
Slow down the operation of robots in the world. |
static void |
setNeutroniumColor(java.awt.Color color)
Change the color of walls from the standard black to any color you choose. |
static void |
setOS9Mac(boolean mac)
HIDE. |
static void |
setSize(int numberOfStreets,
int numberOfAvenues)
Set the size of the world. |
static void |
setStreetColor(java.awt.Color color)
Change the color of streets and avenues from the standard dark red to any color you choose. |
static void |
setTrace(boolean t)
Turn tracing on or off. |
static void |
setupThread(java.lang.Runnable r)
Let a robot run in its own thread. |
static void |
setVisible()
|
static void |
setVisible(boolean show)
Make the frame visible or not. |
static void |
setWorldColor(java.awt.Color color)
Change the color of the background of the world from the standard * white to any color you choose * |
static void |
showSpeedControl(boolean show)
Make the speed dialog visible or not. |
static void |
showWorld()
Print a representation of the world's contents on System.out. |
static void |
startThreads()
Start all the threads initially. |
static void |
stop()
Suspend all the threads in the world. |
static java.awt.Canvas |
worldCanvas()
Return the canvas that normally shows in the world's frame. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final World asObject
Method Detail |
public static final World asObject()
public static final void setOS9Mac(boolean mac)
public static void placeBeepers(int Street, int Avenue, int howMany)
public static java.awt.Canvas worldCanvas()
public static final void placeEWWall(int NorthOfStreet, int atAvenue, int lengthTowardEast)
public static final void placeNSWall(int atStreet, int EastOfAvenue, int lengthTowardNorth)
public static final void saveWorld(java.lang.String filename)
public static final void saveXMLWorld(java.lang.String filename)
public static final java.lang.String asText(java.lang.String sep)
public static final void saveWorld(java.lang.String directoryPath, java.lang.String filename)
public static void saveXMLWorld(java.lang.String directoryPath, java.lang.String filename)
public static final void showWorld()
public static final void readWorld(java.lang.String filename)
public static final void readWorld(java.lang.String directoryPath, java.lang.String filename)
public static void getWorld(java.lang.String commands)
public static final void reset()
public static final void setDelay(int d)
public static final int delay()
public static final void resume()
public static final void stop()
public static final void setSize(int numberOfStreets, int numberOfAvenues)
public static final void setTrace(boolean t)
public static final void setupThread(java.lang.Runnable r)
public static final void showSpeedControl(boolean show)
public static final void setVisible(boolean show)
public static final void setVisible()
public static final void replaceCloser(java.awt.event.WindowListener w)
public static final void setStreetColor(java.awt.Color color)
* Note that the colors set in the world are NOT saved in the world files. * They are just a feature of the current run of the program. *
* @param c the color for streets and avenues
public static final void setNeutroniumColor(java.awt.Color color)
* Note that the colors set in the world are NOT saved in the world files. * They are just a feature of the current run of the program. *
* @param c the color for walls, which are made of Neutronium, an impenetrable substance
public static final void setBeeperColor(java.awt.Color color)
* Note that the colors set in the world are NOT saved in the world files. * They are just a feature of the current run of the program. *
* @param c the color for beepers.
public static final void setWorldColor(java.awt.Color color)
* Note that the colors set in the world are NOT saved in the world files. * They are just a feature of the current run of the program. *
* @param color the color for the background of the world.
public static final void repaint()
public static final void startThreads()
public static final void makeView()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |