|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--edu.sc.ants.Environment
The Environment holds a vector of Thread, each represents a Thing that is running in the world. Environment is responsible for starting/stopping all of them if the user request a stop(). It contains two local classes RunningThing and RunningThingContainer. I am trying to get rid of deadlock situations by moving all synchronization down to the RunningThing class.
Inner Class Summary | |
class |
Environment.RunningThing
This class embodies one running thing (i.e. |
class |
Environment.RunningThingContainer
Contains all the running things (i.e. |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AWTTreeLock |
Field Summary | |
(package private) java.lang.Thread |
animator
the thread |
(package private) Environment.RunningThing |
lastPick
The last agent that was picked. |
(package private) java.awt.Graphics |
offgraphics
|
(package private) java.awt.Image |
offscreen
|
(package private) java.awt.Dimension |
offscreensize
We use page flipping to avoid flickering |
(package private) Environment.RunningThing |
pick
has someone been picked by the user, who? |
(package private) boolean |
running
True if this thread should be running |
(package private) boolean |
suspended
Should this agent just wait? |
(package private) Environment.RunningThingContainer |
theThings
The things in this environment |
(package private) static int |
xSize
the size of the enviroment, in pixels |
(package private) static int |
ySize
the size of the enviroment, in pixels |
Fields inherited from class java.awt.Panel |
base,
nameCounter,
serialVersionUID |
Fields inherited from class java.awt.Container |
component,
containerListener,
containerSerializedDataVersion,
dispatcher,
layoutMgr,
maxSize,
ncomponents,
serialVersionUID |
Fields inherited from class java.awt.Component |
actionListenerK,
adjustmentListenerK,
appContext,
assert,
background,
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
changeSupport,
componentListener,
componentListenerK,
componentOrientation,
componentSerializedDataVersion,
containerListenerK,
cursor,
dropTarget,
enabled,
eventMask,
focusListener,
focusListenerK,
font,
foreground,
hasFocus,
height,
incRate,
inputMethodListener,
inputMethodListenerK,
isInc,
isPacked,
itemListenerK,
keyListener,
keyListenerK,
LEFT_ALIGNMENT,
locale,
LOCK,
minSize,
mouseListener,
mouseListenerK,
mouseMotionListener,
mouseMotionListenerK,
name,
nameExplicitlySet,
newEventsOnly,
ownedWindowK,
parent,
peer,
peerFont,
popups,
prefSize,
RIGHT_ALIGNMENT,
serialVersionUID,
textListenerK,
TOP_ALIGNMENT,
valid,
visible,
width,
windowListenerK,
x,
y |
Constructor Summary | |
(package private) |
Environment()
|
Method Summary | |
void |
createAndAddAgent(java.lang.String type)
Randomly generates a thing (in this case, an agent) of the given type it to the environment |
void |
deleteAgent()
Deletes the thing that was last picked |
void |
die()
Is this ever called? |
(package private) void |
fixCoords(Observation l)
If the coordinates are out of bounds, set them back within bounds. |
java.util.Vector |
getInput(int agentID,
double range)
|
Message |
getMessage(int agentID)
Is there a message waiting for an agent? |
void |
init()
Initialize. |
void |
resume()
Tell this thing to continue executing its run() loop |
void |
run()
The main loop |
void |
scramble()
Scramble the agents around. |
void |
sendMessage(Message m,
double range)
An agent calls this when it wants to send a message. |
void |
shake()
Shake, rattle and roll |
void |
start()
This is called when we start for the first time. |
(package private) void |
startThreads()
Resume all the agent(Thing) threads |
void |
stop()
Tell this Thing to exit its run method |
(package private) void |
stopThreads()
Stop each of the threads |
void |
suspend()
Tell this thing to wait and to nothing in its run loop |
void |
takeAction(int agentID,
Action a)
The agents call this when they want to take an action. |
void |
update(java.awt.Graphics g)
Refresh the screen, we call each agent to draw itself where it is. |
Methods inherited from class java.awt.Panel |
|
Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
applyOrientation,
countComponents,
deliverEvent,
dispatchEventImpl,
dispatchEventToSelf,
doLayout,
eventEnabled,
findComponentAt,
findComponentAt,
getAlignmentX,
getAlignmentY,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents_NoClientCode,
getComponents,
getInsets,
getLayout,
getMaximumSize,
getMinimumSize,
getMouseEventTarget,
getPreferredSize,
getWindow,
initIDs,
insets,
invalidate,
invalidateTree,
isAncestorOf,
layout,
lightweightPrint,
list,
list,
locate,
minimumSize,
nextFocus,
paint,
paintComponents,
paramString,
postProcessKeyEvent,
postsOldMouseEvents,
preferredSize,
preProcessKeyEvent,
print,
printComponents,
printOneComponent,
processContainerEvent,
processEvent,
proxyEnableEvents,
proxyRequestFocus,
readObject,
remove,
remove,
removeAll,
removeContainerListener,
removeNotify,
setFocusOwner,
setFont,
setLayout,
transferFocus,
validate,
validateTree,
writeObject |
Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addPropertyChangeListener,
addPropertyChangeListener,
areInputMethodsEnabled,
bounds,
checkImage,
checkImage,
coalesceEvents,
contains,
contains,
createImage,
createImage,
disable,
disableEvents,
dispatchEvent,
enable,
enable,
enableEvents,
enableInputMethods,
firePropertyChange,
getBackground,
getBounds,
getBounds,
getColorModel,
getComponentOrientation,
getCursor,
getDropTarget,
getFont_NoClientCode,
getFont,
getFontMetrics,
getForeground,
getGraphics,
getHeight,
getInputContext,
getInputMethodRequests,
getLocale,
getLocation,
getLocation,
getLocationOnScreen,
getName,
getNativeContainer,
getParent_NoClientCode,
getParent,
getPeer,
getSize,
getSize,
getToolkit,
getToolkitImpl,
getTreeLock,
getWidth,
getWindowForObject,
getX,
getY,
gotFocus,
handleEvent,
hasFocus,
hide,
imageUpdate,
inside,
isDisplayable,
isDoubleBuffered,
isEnabled,
isEnabledImpl,
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,
processComponentEvent,
processFocusEvent,
processInputMethodEvent,
processKeyEvent,
processMouseEvent,
processMouseMotionEvent,
remove,
removeComponentListener,
removeFocusListener,
removeInputMethodListener,
removeKeyListener,
removeMouseListener,
removeMouseMotionListener,
removePropertyChangeListener,
removePropertyChangeListener,
repaint,
repaint,
repaint,
repaint,
requestFocus,
reshape,
resize,
resize,
setBackground,
setBounds,
setBounds,
setComponentOrientation,
setCursor,
setDropTarget,
setEnabled,
setForeground,
setLocale,
setLocation,
setLocation,
setName,
setSize,
setSize,
setVisible,
show,
show,
size,
toString,
transferFocus |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
Field Detail |
java.lang.Thread animator
Environment.RunningThingContainer theThings
static int xSize
static int ySize
Environment.RunningThing pick
Environment.RunningThing lastPick
boolean running
boolean suspended
java.awt.Image offscreen
java.awt.Dimension offscreensize
java.awt.Graphics offgraphics
Constructor Detail |
Environment()
Method Detail |
public void stop()
public void suspend()
public void resume()
public void createAndAddAgent(java.lang.String type)
type
- the type of the agent we want to create.public void deleteAgent()
void fixCoords(Observation l)
public void takeAction(int agentID, Action a)
agentID
- the agent taking the actiona
- the actionpublic java.util.Vector getInput(int agentID, double range)
public void sendMessage(Message m, double range)
m
- the message to sendrange
- the radius, in pixelspublic Message getMessage(int agentID)
agentID
- the agentpublic void scramble()
public void shake()
void stopThreads()
void startThreads()
public void start()
public void init()
public void die()
public void run()
public void update(java.awt.Graphics g)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |