|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--world.WorldCreator
A WorldCreator creates a World with particular Background objects
whose description and location are given in a specified file,
where each line of data is of the following format:
backgroundName xCoordinate yCoordinate width height
where backgroundName is the predetermined name refering to some background
(e.g. Vertical-Road, Lake, House)
where xCoordinate refers to the leftmost x-coordinate of the background
where yCoordinate refers to the uppermost y-coordinate of the background
where width refers to the maximum horizontal distance from the xCoordinate
of the background object
where height refers to the maximum vertical distance from the yCoordinate
of the background object
PLEASE NOTE: This implementation assumes that the file contains no empty
lines of data (i.e. the lines of valid data are consecutive); this can be
easily modified if desired.
Field Summary | |
static java.lang.String |
defaultFilename
Name of a file to use if a good file name is not supplied as a parameter. |
Constructor Summary | |
WorldCreator()
|
Method Summary | |
private static java.io.File |
getFile()
[DO include in the starter code] Displays a dialog box to choose the file, if the requested one doesn't exist. |
private static java.io.File |
getFile(java.lang.String requestedFilename)
Locate the requested file, if possible, or a file selected by the user. |
static World |
modifyWorld(java.lang.String fileName,
World w)
Modifies a currently existing World by adding Background objects specified in the fileName. |
static World |
modifyWorld(World w)
Modifies a World with Background objects taken from a file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String defaultFilename
Constructor Detail |
public WorldCreator()
Method Detail |
public static World modifyWorld(World w)
public static World modifyWorld(java.lang.String fileName, World w)
fileName
- the name of the file describing the background objects;
if the fileName is null or empty or if the file cannot be found,
a built-in default is tried; if that fails,
the user sees a File Chooser dialog and can browse to the desired file.w
- the currently existing World
private static java.io.File getFile()
private static java.io.File getFile(java.lang.String requestedFilename)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |