|
||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uwcse.graphics.GWindow
The GWindow class defines a simple graphics window. The default size is 500 by 400 pixels. A "pixel" is one "dot" on the screen. It is the smallest unit that can be displayed on a window. The coordinate system is x and y, where x and y are offsets from the upper left corner of the window. (Note the y coordinate grows positively in the downward direction -- which is different from the traditional Cartesian coordinate system.)
The GWindow supports two modes of displaying objects. In the first, using the add() and remove() operations, a GWindow maintains a collection of Shape objects. When the GWindow paints itself, it paints each of its shape objects, in the order in which they are added. Shapes obscure other shapes, depending upon the order of their addition (and their position); a shape added later overpaints shapes added earlier.
In the second, using the display() method, the GWindow keeps a list of objects to be displayed. The next time the window repaints itself, all objects in the list are displayed, and then discarded. This mode is used in the (old) simulation framework.
Constructor Summary | |
GWindow()
Create a new window, with default name and size. |
|
GWindow(AppletGWindow appletGWindow)
Create a new window interface to use for an applet |
|
GWindow(int width,
int height)
Create a new window of the given dimensions. |
|
GWindow(java.lang.String name)
Create a new window of the default size. |
|
GWindow(java.lang.String name,
int width,
int height)
Create a new window of the given name and dimensions. |
Method Summary | |
boolean |
add(Shape s)
Add the given shape and paint it onto the screen. |
void |
addEventHandler(GWindowEventHandler handler)
Add the given event handler. |
void |
display(Shape s)
Simply adds this shape to the to-be-displayed queue. |
void |
dispose()
Close the window. |
void |
doRepaint()
Update the screen, if updates aren't suspended. |
void |
erase()
Discards all of the shape objects and clears the screen. |
GWindowEventHandler |
getEventHandler()
Answer the current event handler. |
java.awt.Image |
getImageFromFilename(java.lang.String imageName)
Create and return a new Image, given the filename of the image. |
java.awt.Image |
getImageFromURL(java.lang.String imageURL)
Create and return a new Image, given the URL of the image. |
int |
getWindowHeight()
Return the height of the drawing area of the window (ignoring title bar, borders, etc.) |
int |
getWindowWidth()
Return the width of the drawing area of the window (ignoring title bar, borders, etc.) |
Shape |
intersects(Shape aShape)
Return the shape that the argument shape intersects with, or null if none. |
static void |
main(java.lang.String[] args)
|
void |
moveAllBy(int deltaX,
int deltaY)
Translate the position of every object by the given deltas, and repaint the screen. |
void |
print(java.lang.String msg)
Display a dialog message in a pop-up window. |
boolean |
remove(Shape s)
Remove the given shape and repaint the screen. |
void |
resumeRepaints()
Resume repaints. |
void |
setExitOnClose()
If this is called, the application will exit when a GWindow is closed. |
static void |
showColorTable()
Opens a color picker application. |
void |
startTimerEvents(int intervalInMSecs)
Start delivering timer events to the GWindow. |
void |
stopTimerEvents()
Stop delivering timer events to the GWindow. |
void |
suspendRepaints()
Suspend repaints. |
java.lang.String |
toString()
|
double |
version()
Answer the version number. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public GWindow()
public GWindow(AppletGWindow appletGWindow)
appletGWindow
- the AppletGWindow objectpublic GWindow(int width, int height)
width
- the initial width of the window, in pixelsheight
- the initial height of the window, in pixelspublic GWindow(java.lang.String name)
name
- the title of the windowpublic GWindow(java.lang.String name, int width, int height)
name
- the title of the windowwidth
- the initial width of the window, in pixelsheight
- the initial height of the window, in pixelsMethod Detail |
public boolean add(Shape s)
s
- a shape object (Rectangle, etc)public void addEventHandler(GWindowEventHandler handler)
public void display(Shape s)
public void dispose()
public void doRepaint()
public void erase()
public GWindowEventHandler getEventHandler()
public java.awt.Image getImageFromFilename(java.lang.String imageName)
imageName
- the filename containing the imagepublic java.awt.Image getImageFromURL(java.lang.String imageURL)
imageURL
- the URL containing the imagepublic int getWindowHeight()
public int getWindowWidth()
public Shape intersects(Shape aShape)
aShape
- the shape to test intersection againstpublic static void main(java.lang.String[] args)
public void moveAllBy(int deltaX, int deltaY)
x
- the deltaXy
- the deltaYpublic void print(java.lang.String msg)
msg
- the message to displaypublic boolean remove(Shape s)
s
- a shape object (Rectangle, etc)public void resumeRepaints()
public void setExitOnClose()
public static void showColorTable()
public void startTimerEvents(int intervalInMSecs)
public void stopTimerEvents()
public void suspendRepaints()
public java.lang.String toString()
toString
in class java.lang.Object
public double version()
|
||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |