|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
World
Class to represent a 2d world that can hold turtles and display them Copyright Georgia Institute of Technology 2004
Nested Class Summary |
Nested classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
Nested classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary |
Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Container |
|
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 | |
World()
Constructor that takes no arguments |
|
World(boolean visibleFlag)
Constructor that takes a boolean to say if this world should be visible or not |
|
World(int w,
int h)
Constructor that takes a width and height for this world |
Method Summary | |
void |
addModel(Object model)
Method to add a model to this model displayer |
void |
clearBackground()
Method to clear the background picture |
boolean |
containsTurtle(Turtle turtle)
Method to check if this world contains the passed turtle |
void |
drawOn(Picture p)
Method to drawOn the input picture |
Graphics |
getGraphics()
Method to get the graphics context for drawing on |
int |
getHeight()
Method to get the height in pixels |
Turtle |
getLastTurtle()
Metod to get the last turtle in this world |
Picture |
getPicture()
Method to get the background picture |
Iterator |
getTurtleIterator()
Method to get an iterator on the list of turtles |
List |
getTurtleList()
Method to get the list of turtles in the world |
int |
getWidth()
Method to get the width in pixels |
void |
hide()
Method to hide the frame |
void |
modelChanged()
Method that allows the model to notify the display |
void |
paintComponent(Graphics g)
Method to paint this component |
void |
remove(Object model)
Method to remove the passed object from the world |
void |
setAutoRepaint(boolean value)
Method to set the automatically repaint flag |
void |
setPicture(Picture pict)
Method to set the background picture |
void |
show()
Method to show the frame |
String |
toString()
Method that returns information about this world in the form of a string |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public World()
public World(boolean visibleFlag)
visibleFlag
- if true will be visible
else if false will not be visiblepublic World(int w, int h)
w
- the width for the worldh
- the height for the worldMethod Detail |
public Graphics getGraphics()
getGraphics
in interface ModelDisplay
public void clearBackground()
clearBackground
in interface ModelDisplay
public Picture getPicture()
public void setPicture(Picture pict)
pict
- the background picture to usepublic void paintComponent(Graphics g)
g
- the graphics contextpublic void drawOn(Picture p)
p
- picture to draw on.public Turtle getLastTurtle()
public void addModel(Object model)
addModel
in interface ModelDisplay
model
- the model object to addpublic boolean containsTurtle(Turtle turtle)
public void remove(Object model)
remove
in interface ModelDisplay
model
- the model object to removepublic int getWidth()
getWidth
in interface ModelDisplay
public int getHeight()
getHeight
in interface ModelDisplay
public void modelChanged()
modelChanged
in interface ModelDisplay
public void setAutoRepaint(boolean value)
value
- if true will auto repaintpublic void hide()
public void show()
public List getTurtleList()
public Iterator getTurtleIterator()
public String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |