uwcse.graphics
Class AppletGWindow

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--uwcse.graphics.AppletGWindow
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, uwcse.graphics.InternalGWindow, java.awt.MenuContainer, java.io.Serializable

public abstract class AppletGWindow
extends java.applet.Applet
implements uwcse.graphics.InternalGWindow

The AppletGWindow class is an abstract class to be extended by clients that are to be run in an applet window within a web page. This is in contrast to a FrameGWindow which is created to represent a separate window.

See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AppletGWindow()
          Create a new interface to an applet.
 
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 imageURLName)
          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.)
 void init()
          Called to initialize the applet.
 Shape intersects(Shape aShape)
          Return the shape that the argument shape intersects with, or null if none.
 void moveAllBy(int deltaX, int deltaY)
          Translate the position of every object by the given deltas, and repaint the screen.
 void paint(java.awt.Graphics g)
          Do a paint operation.
 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.
 void startTimerEvents(int intervalInMSecs)
          Start delivering timer events to the AppletGWindow.
 void stopTimerEvents()
          Stop delivering timer events to the AppletGWindow.
 void suspendRepaints()
          Suspend repaints.
 java.lang.String toString()
           
 void update(java.awt.Graphics g)
          When we update the window, we just do a paint(g).
 double version()
          Answer the version number.
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AppletGWindow

public AppletGWindow()
Create a new interface to an applet. (Not invoked directly by user code, but instead by the web page containing the applet.)
Method Detail

add

public boolean add(Shape s)
Add the given shape and paint it onto the screen.
Specified by:
add in interface uwcse.graphics.InternalGWindow
Parameters:
s - a shape object (Rectangle, etc)
Returns:
true if the shape was actually added (a shape is only added if it hasn't already been added)

addEventHandler

public void addEventHandler(GWindowEventHandler handler)
Add the given event handler. Right now, only one handler may exist at a time.
Specified by:
addEventHandler in interface uwcse.graphics.InternalGWindow

display

public void display(Shape s)
Simply adds this shape to the to-be-displayed queue.
Specified by:
display in interface uwcse.graphics.InternalGWindow

dispose

public void dispose()
Description copied from interface: uwcse.graphics.InternalGWindow
Close the window.
Specified by:
dispose in interface uwcse.graphics.InternalGWindow

doRepaint

public void doRepaint()
Update the screen, if updates aren't suspended. This is the operation that other classes should invoke if they've done something to a graphical shape that might change its appearance.
Specified by:
doRepaint in interface uwcse.graphics.InternalGWindow

erase

public void erase()
Discards all of the shape objects and clears the screen.
Specified by:
erase in interface uwcse.graphics.InternalGWindow

getEventHandler

public GWindowEventHandler getEventHandler()
Answer the current event handler.
Specified by:
getEventHandler in interface uwcse.graphics.InternalGWindow

getImageFromFilename

public java.awt.Image getImageFromFilename(java.lang.String imageName)
Create and return a new Image, given the filename of the image.
Specified by:
getImageFromFilename in interface uwcse.graphics.InternalGWindow
Parameters:
imageName - the filename containing the image

getImageFromURL

public java.awt.Image getImageFromURL(java.lang.String imageURLName)
Create and return a new Image, given the URL of the image.
Specified by:
getImageFromURL in interface uwcse.graphics.InternalGWindow
Parameters:
imageURL - the URL containing the image

getWindowHeight

public int getWindowHeight()
Return the height of the drawing area of the window (ignoring title bar, borders, etc.)
Specified by:
getWindowHeight in interface uwcse.graphics.InternalGWindow

getWindowWidth

public int getWindowWidth()
Return the width of the drawing area of the window (ignoring title bar, borders, etc.)
Specified by:
getWindowWidth in interface uwcse.graphics.InternalGWindow

init

public void init()
Called to initialize the applet. Not invoked directly by clients, but rather by the applet viewer.
Overrides:
init in class java.applet.Applet

intersects

public Shape intersects(Shape aShape)
Return the shape that the argument shape intersects with, or null if none.
Specified by:
intersects in interface uwcse.graphics.InternalGWindow
Parameters:
aShape - the shape to test intersection against
Returns:
the shape that aStape intersects, or null if no shapes intersect aShape

moveAllBy

public void moveAllBy(int deltaX,
                      int deltaY)
Translate the position of every object by the given deltas, and repaint the screen.
Specified by:
moveAllBy in interface uwcse.graphics.InternalGWindow
Parameters:
x - the deltaX
y - the deltaY

paint

public void paint(java.awt.Graphics g)
Do a paint operation. Clients will almost never call this method. It is called by repaint(), or by update() by the window management system.
Overrides:
paint in class java.awt.Container
Parameters:
g - a graphics context.

print

public void print(java.lang.String msg)
Display a dialog message in a pop-up window.
Specified by:
print in interface uwcse.graphics.InternalGWindow
Parameters:
msg - the message to display

remove

public boolean remove(Shape s)
Remove the given shape and repaint the screen.
Specified by:
remove in interface uwcse.graphics.InternalGWindow
Parameters:
s - a shape object (Rectangle, etc)
Returns:
true if the shape was actually removed, false if not

resumeRepaints

public void resumeRepaints()
Resume repaints.
Specified by:
resumeRepaints in interface uwcse.graphics.InternalGWindow

setExitOnClose

public void setExitOnClose()
Description copied from interface: uwcse.graphics.InternalGWindow
If this is called, the application will exit when a GWindow is closed.
Specified by:
setExitOnClose in interface uwcse.graphics.InternalGWindow

startTimerEvents

public void startTimerEvents(int intervalInMSecs)
Start delivering timer events to the AppletGWindow.
Specified by:
startTimerEvents in interface uwcse.graphics.InternalGWindow

stopTimerEvents

public void stopTimerEvents()
Stop delivering timer events to the AppletGWindow.
Specified by:
stopTimerEvents in interface uwcse.graphics.InternalGWindow

suspendRepaints

public void suspendRepaints()
Suspend repaints. This can be called before doing a whole bunch of updates to shapes, so that each change doesn't appear on the screen. Then resumeRepaints can be called, to do all the repainting in one step.
Specified by:
suspendRepaints in interface uwcse.graphics.InternalGWindow

toString

public java.lang.String toString()
Overrides:
toString in class java.awt.Component

update

public void update(java.awt.Graphics g)
When we update the window, we just do a paint(g).
Overrides:
update in class java.awt.Container

version

public double version()
Answer the version number.
Specified by:
version in interface uwcse.graphics.InternalGWindow