com.cometway.swing
Class LightBox

java.lang.Object
  extended by com.cometway.props.Props
      extended by com.cometway.ak.Agent
          extended by com.cometway.swing.AbstractJFrameAgent
              extended by com.cometway.swing.AbstractJFrameController
                  extended by com.cometway.swing.LightBox
All Implemented Interfaces:
AgentInterface, HasStateMachineModel

public class LightBox
extends AbstractJFrameController

This agent displays a frame that contains Lights, or more accurately colored squares, that are drawn in a grid style array. The LightBox agent registers itself with the Service Manager so that it may be found and used by other agents to display state information.


Field Summary
static int BLACK
           
static int BLUE
           
static int BLUE0
           
static int BLUE1
           
static int BLUE2
           
static int BLUE3
           
static int BLUE4
           
static int DIM_BLUE
           
static int DIM_GREEN
           
static int DIM_RED
           
static int GREEN
           
static int GREEN0
           
static int GREEN1
           
static int GREEN2
           
static int GREEN3
           
static int GREEN4
           
static int RED
           
static int RED0
           
static int RED1
           
static int RED2
           
static int RED3
           
static int RED4
           
static int WHITE
           
static int YELLOW
           
 
Fields inherited from class com.cometway.swing.AbstractJFrameAgent
frame, menu, menuActionListener, menuBar, windowListener
 
Fields inherited from class com.cometway.ak.Agent
agent_id, agentController, CREATING_STATE, debugReporter, DESTROYED_STATE, DESTROYING_STATE, errorReporter, FAILED_STATE, printlnReporter, props, RUNNING_STATE, STARTING_STATE, STOPPED_STATE, STOPPING_STATE, warningReporter
 
Constructor Summary
LightBox()
           
 
Method Summary
protected  void drawCell(java.awt.Graphics g, int h, int v)
          This method draws a single cell based on its stored state.
protected  void drawCells(java.awt.Graphics g, boolean changedOnly)
          This method draws all of the cells.
 void drawChangedCells()
          Called by clients to immediately draw all changed cells.
 void drawFrame(java.awt.Graphics g)
          This method is called to draw the entire frame contents.
 int getCellIndex(int h, int v)
          Returns the index of the specified cell.
 int getCellState(int index)
          Returns the current state of the specified cell.
 int getCellState(int h, int v)
          Returns the current state of the specified cell.
 int getRandomEmptyCell()
          Returns the index of a random empty cell.
 void initProps()
          Initializes the Props for this agent.
protected  void openFrame()
          Creates and initializes the JFrame used to display the Light Box.
 void setCellState(int index, int newState)
          Called by clients to set the state of a specific cell designated by its index in the array of cells.
 void setCellState(int h, int v, int newState)
          Called by clients to set the state of a specific cell designated by horizontal and vertical coordinates.
 void start()
          Opens the LightBox frame and registers this agent with the Service Manager.
 
Methods inherited from class com.cometway.swing.AbstractJFrameController
createFrame, getFrame, stop
 
Methods inherited from class com.cometway.swing.AbstractJFrameAgent
closeFrame, createMenu, createMenuActionListener, createWindowListener, setLookAndFeel, setMenuBar
 
Methods inherited from class com.cometway.ak.Agent
currentStateEquals, debug, destroy, error, error, getAgentController, getDateTimeStr, getProps, getServiceImpl, getStateMachineModel, println, register, registerService, setAgentController, setProps, toString, unregister, unregisterService, warning, warning
 
Methods inherited from class com.cometway.props.Props
addListener, append, copy, copyFrom, copyTo, decrementInteger, dump, enableListeners, enumerateKeys, format, getBoolean, getByteArray, getCharacter, getDate, getDate, getDateString, getDouble, getFloat, getHexString, getInteger, getKeys, getLong, getNextKey, getProperty, getProperty, getPropsContainer, getSize, getString, getString, getTokens, getTokens, getTrimmedString, getVector, hasProperty, incrementInteger, insertProps, loadProps, notifyPropsChanged, notifyPropsChangedIgnore, notifyPropsChangedIgnore, parse, propertyMatchesRegEx, readFromFile, regExPropertyMatches, removeAll, removeListener, removeProperty, resumeNotify, saveProps, set, setBoolean, setCharacter, setDefault, setDouble, setFloat, setInteger, setLong, setProperty, setProperty, setProperty, setPropsContainer, suspendNotify, writeToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BLACK

public static final int BLACK
See Also:
Constant Field Values

WHITE

public static final int WHITE
See Also:
Constant Field Values

RED

public static final int RED
See Also:
Constant Field Values

GREEN

public static final int GREEN
See Also:
Constant Field Values

BLUE

public static final int BLUE
See Also:
Constant Field Values

YELLOW

public static final int YELLOW
See Also:
Constant Field Values

DIM_RED

public static final int DIM_RED
See Also:
Constant Field Values

DIM_GREEN

public static final int DIM_GREEN
See Also:
Constant Field Values

DIM_BLUE

public static final int DIM_BLUE
See Also:
Constant Field Values

RED0

public static final int RED0
See Also:
Constant Field Values

RED1

public static final int RED1
See Also:
Constant Field Values

RED2

public static final int RED2
See Also:
Constant Field Values

RED3

public static final int RED3
See Also:
Constant Field Values

RED4

public static final int RED4
See Also:
Constant Field Values

GREEN0

public static final int GREEN0
See Also:
Constant Field Values

GREEN1

public static final int GREEN1
See Also:
Constant Field Values

GREEN2

public static final int GREEN2
See Also:
Constant Field Values

GREEN3

public static final int GREEN3
See Also:
Constant Field Values

GREEN4

public static final int GREEN4
See Also:
Constant Field Values

BLUE0

public static final int BLUE0
See Also:
Constant Field Values

BLUE1

public static final int BLUE1
See Also:
Constant Field Values

BLUE2

public static final int BLUE2
See Also:
Constant Field Values

BLUE3

public static final int BLUE3
See Also:
Constant Field Values

BLUE4

public static final int BLUE4
See Also:
Constant Field Values
Constructor Detail

LightBox

public LightBox()
Method Detail

initProps

public void initProps()
Initializes the Props for this agent.

Specified by:
initProps in interface AgentInterface
Overrides:
initProps in class AbstractJFrameController

start

public void start()
Opens the LightBox frame and registers this agent with the Service Manager.

Specified by:
start in interface AgentInterface
Overrides:
start in class AbstractJFrameController

getCellState

public int getCellState(int index)
Returns the current state of the specified cell.


getCellState

public int getCellState(int h,
                        int v)
Returns the current state of the specified cell.


getCellIndex

public int getCellIndex(int h,
                        int v)
Returns the index of the specified cell.


getRandomEmptyCell

public int getRandomEmptyCell()
Returns the index of a random empty cell.


openFrame

protected void openFrame()
Creates and initializes the JFrame used to display the Light Box.

Overrides:
openFrame in class AbstractJFrameAgent

drawFrame

public void drawFrame(java.awt.Graphics g)
This method is called to draw the entire frame contents.

Specified by:
drawFrame in class AbstractJFrameController

drawCell

protected void drawCell(java.awt.Graphics g,
                        int h,
                        int v)
This method draws a single cell based on its stored state.


drawCells

protected void drawCells(java.awt.Graphics g,
                         boolean changedOnly)
This method draws all of the cells. It will only draw changed ones if specified.


drawChangedCells

public void drawChangedCells()
Called by clients to immediately draw all changed cells.


setCellState

public void setCellState(int index,
                         int newState)
Called by clients to set the state of a specific cell designated by its index in the array of cells.


setCellState

public void setCellState(int h,
                         int v,
                         int newState)
Called by clients to set the state of a specific cell designated by horizontal and vertical coordinates.