| 
 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjavalib.worldcanvas.WorldCanvas
public class WorldCanvas
Functional Canvas - allows the drawing of shapes, lines, and text in the window of the given size, window closing and re-opening.
| Field Summary | |
|---|---|
|  JFrame | fthe frame that holds the canvas | 
| protected  int | heightthe height of the panel | 
|  CanvasPanel | panelthe panel that allows us to paint graphics | 
| protected  int | widththe width of the panel | 
| protected  WindowAdapter | winaptA WindowAdapter that allows us to close a window and re-open, provided there is at least one open window. | 
| protected static int | WINDOWS_OPENrecords the number of canvases currently open | 
| Constructor Summary | |
|---|---|
| WorldCanvas(int width,
            int height)Create a new canvas with the default title "Canvas" | |
| WorldCanvas(int width,
            int height,
            String title)Construct a new frame with the as its component. | |
| Method Summary | |
|---|---|
|  void | clear()Clear the canvas before painting the next scene | 
|  boolean | close()Close the window - if it is currently open, do nothing otherwise | 
|  boolean | drawImage(ImageMaker image,
          Posn nw)Draw the image provided by the on theat the given
 NW corner | 
|  boolean | drawImage(String fileName,
          Posn nw)Draw the image in the specified file at the location of the given NW corner | 
|  boolean | drawImage(WorldImage image)Draw the image on the at its
 pinhole location. | 
|  Graphics2D | getBufferGraphics()Returns a Graphics2Dobject that permits
 painting to the internal buffered image for this canvas. | 
|  int | getCurrentHeight()Get the current width of the animation window (which may have been adjusted by the user). | 
|  int | getCurrentWidth()Get the current width of the animation window (which may have been adjusted by the user). | 
|  int | getHeight()Get the initial height. | 
|  int | getWidth()Get the initial width. | 
| static void | main(String[] argv)Self test for the Canvas class | 
|  void | printCurrentFont() | 
|  boolean | show()Show the window with the canvas cleared | 
|  String | toIndentedString(String indent)Produce an indented Stringrepresentation of this Canvas | 
|  String | toString()Produce a Stringrepresentation of this Canvas | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
public transient JFrame f
protected int height
public transient CanvasPanel panel
protected int width
protected transient WindowAdapter winapt
protected static int WINDOWS_OPEN
| Constructor Detail | 
|---|
public WorldCanvas(int width,
                   int height)
width - the width of the canvasheight - the height of the canvas
public WorldCanvas(int width,
                   int height,
                   String title)
Construct a new frame with the 
 CanvasPanel panel
width - the width of the panelheight - the height of the paneltitle - the title of the panel| Method Detail | 
|---|
public void clear()
public boolean close()
true if successfully closed, or closed already
public boolean drawImage(ImageMaker image,
                         Posn nw)
ImageMakerCanvas
image - the image maker for the image filenw - the NW corner for the image placement
public boolean drawImage(String fileName,
                         Posn nw)
fileName - the name of the image filenw - the NW corner for the image placementpublic boolean drawImage(WorldImage image)
Canvas
image - the image to be drawn
truepublic final Graphics2D getBufferGraphics()
Returns a Graphics2D object that permits
 painting to the internal buffered image for this canvas.
The user should always use this object to paint to the buffer and thus indirectly modify this buffered panel.
To make painting changes to the buffer visible, the
 repaint() method must explicitly be called.
 This allows a number of painting operations to be done
 prior to screen repaint.
public int getCurrentHeight()
public int getCurrentWidth()
public int getHeight()
public int getWidth()
public static void main(String[] argv)
argv - public void printCurrentFont()
public boolean show()
true if successfully opened, or opened alreadypublic String toIndentedString(String indent)
String representation of this Canvas
indent - the desired indentation: ignored, because we only produce
 one line of text.public String toString()
String representation of this Canvas
toString in class Object| 
 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||