agent.example
Class ExampleProblemSolver

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byagent.base.AgentComponent
                  extended byagent.example.ExampleProblemSolver
All Implemented Interfaces:
javax.accessibility.Accessible, ActionEventListener, AgentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, MessageEventListener, PropertyEventListener, java.io.Serializable

public class ExampleProblemSolver
extends AgentComponent
implements PropertyEventListener, MessageEventListener, ActionEventListener

This is a shell JAF component which demonstrates how the various functions and stages can be used. This class extends ProblemSolver, but you can also just extend agent.base.AgentComponent to make a completely new component.

See Also:
AgentComponent, Serialized Form

Field Summary
static java.lang.String PERFORMACTIONS
           
 
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
ExampleProblemSolver()
          Default constructor.
 
Method Summary
 void actionAborted(ActionEvent e)
           
 void actionCompleted(ActionEvent e)
           
 void actionStarted(ActionEvent e)
          These are called when action events take place.
 void addExampleEventListener(ExampleEventListener l)
          This component produces an ExampleEvent stream.
 void begin()
          Called when the component is ready to execute.
 void end()
          Called when the component is ended, which basically only happens when the agent is terminated.
 void init()
          The initialization procedure.
 void messageReceived(MessageEvent me)
          Monitor any messages that might get sent out or received
 void messageSent(MessageEvent me)
           
 void propertyAdded(PropertyEvent e)
           
 void propertyChanged(PropertyEvent e)
          Watch for interesting property changes.
 void propertyRemoved(PropertyEvent e)
           
 void pulse()
          Called periodically by the Control component, either in response to actual passage of time or in response to some other stimuli it perceives as a time indicator (such as a pulse from a time controller).
 void removeExampleEventListener(ExampleEventListener l)
          Unregisters a listener.
 
Methods inherited from class agent.base.AgentComponent
addDependency, getDependencies, getDescriptor, getDescriptorString, getPreferredSize, hasClickAction, hasGUI, hasPopupMenu, paint, reset, setDescriptor, setFont, setHasGUI, startFireEvent
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, 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, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PERFORMACTIONS

public static final java.lang.String PERFORMACTIONS
See Also:
Constant Field Values
Constructor Detail

ExampleProblemSolver

public ExampleProblemSolver()
Default constructor. Component constructors should only modify things that are "constant" as far as the thread of execution is concerned and are independent of other installed components. This will typically include setting up GUIs and calculating environmental constants that aren't user- configurable. You'll also want to note your dependencies and configuration parameters here.

Method Detail

init

public void init()
The initialization procedure. Called when the system state is stable (constructors have completed). Typically, this should be used to setup component links and initialize any transient structures the component makes use of (open files, sockets, etc.) Relatively permanent inter-component relationships can also be set up here (i.e., it's ok to have a static addListener statement hooking the State component to Communications, rather than hand specifying it in the builder tool.) This will be called just once, upon system start up.


begin

public void begin()
Called when the component is ready to execute. Threads, if any, should be started here, along with any other of the "real" services a given component is responsible for.


pulse

public void pulse()
Called periodically by the Control component, either in response to actual passage of time or in response to some other stimuli it perceives as a time indicator (such as a pulse from a time controller). Use this method as you would the contents of an unbounded while loop - they will be called periodically forever, and thus can be used to effect the normal moment-to-moment behavior of a given component.


end

public void end()
Called when the component is ended, which basically only happens when the agent is terminated. This should do any cleanup or post-execution processing you might need. Note that this is separate from Java's finalize() method, and was added because finalize() is not always called upon program termination - you can still have regular finalize() methods.


addExampleEventListener

public void addExampleEventListener(ExampleEventListener l)
This component produces an ExampleEvent stream. In other words, it will "fire" ExampleEvent objects to any object which has registered itself as an ExampleEventListener. This function, and its analogue removeExampleEventListener provide the facilities for registering and unregistering from this stream.

Parameters:
l - The listener which is registering for the stream
See Also:
removeExampleEventListener(agent.example.ExampleEventListener)

removeExampleEventListener

public void removeExampleEventListener(ExampleEventListener l)
Unregisters a listener.

Parameters:
l - The listener which is registering for the stream
See Also:
addExampleEventListener(agent.example.ExampleEventListener)

propertyChanged

public void propertyChanged(PropertyEvent e)
Watch for interesting property changes. If you are trying to monitor changes to state properties, or track when a particular value is set, you can place the code here.

Specified by:
propertyChanged in interface PropertyEventListener
Parameters:
e - The event to look at

propertyAdded

public void propertyAdded(PropertyEvent e)
Specified by:
propertyAdded in interface PropertyEventListener

propertyRemoved

public void propertyRemoved(PropertyEvent e)
Specified by:
propertyRemoved in interface PropertyEventListener

messageReceived

public void messageReceived(MessageEvent me)
Monitor any messages that might get sent out or received

Specified by:
messageReceived in interface MessageEventListener
Parameters:
me - The event to look at

messageSent

public void messageSent(MessageEvent me)
Specified by:
messageSent in interface MessageEventListener

actionStarted

public void actionStarted(ActionEvent e)
These are called when action events take place. You can use these methods to track the results of activities, or to trigger reactions when particular actions are started or completed.

Specified by:
actionStarted in interface ActionEventListener
Parameters:
e - The action event which took place

actionAborted

public void actionAborted(ActionEvent e)
Specified by:
actionAborted in interface ActionEventListener

actionCompleted

public void actionCompleted(ActionEvent e)
Specified by:
actionCompleted in interface ActionEventListener