org.jscience.architecture.traffic.simulation.statistics
Class TrackingView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by org.jscience.architecture.traffic.simulation.statistics.TrackingView
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.Observer, javax.accessibility.Accessible
Direct Known Subclasses:
AllQueuesTrackingView, ExtendedTrackingView, NetTunnelSendQueueTrackingView, SpecialNodeQueueTrackingView

public abstract class TrackingView
extends java.awt.Canvas
implements java.util.Observer

A TrackingView shows a certain tracking graph.

See Also:
Serialized Form

Nested Class Summary
protected  class TrackingView.MyMouseListener
          Listens to mouse clicks on this TrackingView.
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.awt.image.BufferedImage buffer
          The back buffer
protected  java.awt.Color[] colors
          Colors used to draw the graph.
protected  int curIndex
          Current index in trackData[][].
protected  int endCycle
          The cycle the end of the x-axis currently represents
protected  java.lang.String highlightCycle
          String containing highlighted cycle text
protected  int highlightIndex
          Index to the point in trackData to highlight.
protected  java.lang.String[] highlightText
          Strings to draw in upper right corner.
protected static int MAX_DATA
          Determines how many samples are tracked.
protected  int MAX_TRACK
          Determines how many different data flows can be tracked.
protected  float maximum
          Highest valued sampled.
static java.lang.String SEP
          The separator used when saving data.
protected  boolean[] show
          Determines whether a graph is drawn or not.
protected  int startCycle
          The cycle this view started tracking
protected  int trackCount
          Current count: sample if trackCount == trackRate.
protected  float[][] trackData
          The history of tracking data
protected  int trackRate
          Sample rate: each trackRate cycles, a sample is taken.
protected  float xStep
          Used to determine where the user clicked the mouse.
 
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
TrackingView(int _startCycle)
          Creates a new TrackingView.
 
Method Summary
protected  void collapseData()
          Collapses trackData and changes other variables accordingly.
 void drawBuffer()
          Draws the buffer.
protected  java.awt.Color[] getColors()
          Determines the colors of the tracking graphs.
abstract  java.lang.String getDescription()
          Returns the description for this tracking window.
protected  int getMaxTrack()
          Determines the number of tracking graphs.
protected abstract  java.lang.String getSourceDesc(int sourceIndex)
          Returns a short description of the specified source.
 int getStartCycle()
          Returns the cycle this window started tracking
protected abstract  java.lang.String getYLabel()
          Returns the Y-axis label
protected  void init(int _startCycle)
          DOCUMENT ME!
protected abstract  float nextSample(int sourceIndex)
          Returns the next sample to be 'tracked'.
 void paint(java.awt.Graphics g)
          Draws the data in the graphics buffer onto the screen.
 void redraw()
          Redraws the buffer and paints it to the screen.
 void reset()
          DOCUMENT ME!
 void saveData(java.lang.String filename, SimModel model)
          Save data to a CSV file.
 void setBounds(int x, int y, int width, int height)
          DOCUMENT ME!
 void setSize(int width, int height)
          Sets the size for this View
 void setStartCycle(int cycle)
          Sets the cycle this window started tracking
 void showGraph(int index, boolean b)
          Either shows or hides tracking graph index.
 void update(java.awt.Graphics g)
          Override default update() to avoid flickering.
 void update(java.util.Observable o, java.lang.Object arg)
          This method is called by the notifyObservers() method in the Model representing the infrastructure.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SEP

public static java.lang.String SEP
The separator used when saving data.


MAX_DATA

protected static final int MAX_DATA
Determines how many samples are tracked.

See Also:
Constant Field Values

MAX_TRACK

protected int MAX_TRACK
Determines how many different data flows can be tracked.


colors

protected java.awt.Color[] colors
Colors used to draw the graph.


show

protected boolean[] show
Determines whether a graph is drawn or not.


buffer

protected java.awt.image.BufferedImage buffer
The back buffer


trackData

protected float[][] trackData
The history of tracking data


startCycle

protected int startCycle
The cycle this view started tracking


endCycle

protected int endCycle
The cycle the end of the x-axis currently represents


xStep

protected float xStep
Used to determine where the user clicked the mouse.


highlightIndex

protected int highlightIndex
Index to the point in trackData to highlight.


highlightText

protected java.lang.String[] highlightText
Strings to draw in upper right corner.


highlightCycle

protected java.lang.String highlightCycle
String containing highlighted cycle text


curIndex

protected int curIndex
Current index in trackData[][].


maximum

protected float maximum
Highest valued sampled.


trackRate

protected int trackRate
Sample rate: each trackRate cycles, a sample is taken.


trackCount

protected int trackCount
Current count: sample if trackCount == trackRate.

Constructor Detail

TrackingView

public TrackingView(int _startCycle)
Creates a new TrackingView. A TrackingView is a component displaying a tracking graph.

Parameters:
_startCycle - The cycle this view starts tracking.
Method Detail

init

protected void init(int _startCycle)
DOCUMENT ME!

Parameters:
_startCycle - DOCUMENT ME!

reset

public void reset()
DOCUMENT ME!


getStartCycle

public int getStartCycle()
Returns the cycle this window started tracking

Returns:
DOCUMENT ME!

setStartCycle

public void setStartCycle(int cycle)
Sets the cycle this window started tracking

Parameters:
cycle - DOCUMENT ME!

getMaxTrack

protected int getMaxTrack()
Determines the number of tracking graphs.

Returns:
DOCUMENT ME!

getColors

protected java.awt.Color[] getColors()
Determines the colors of the tracking graphs.

Returns:
DOCUMENT ME!

showGraph

public void showGraph(int index,
                      boolean b)
Either shows or hides tracking graph index.

Parameters:
index - DOCUMENT ME!
b - DOCUMENT ME!

nextSample

protected abstract float nextSample(int sourceIndex)
Returns the next sample to be 'tracked'.

Parameters:
sourceIndex - DOCUMENT ME!
Returns:
DOCUMENT ME!

getSourceDesc

protected abstract java.lang.String getSourceDesc(int sourceIndex)
Returns a short description of the specified source.

Parameters:
sourceIndex - DOCUMENT ME!
Returns:
DOCUMENT ME!

getDescription

public abstract java.lang.String getDescription()
Returns the description for this tracking window.

Returns:
DOCUMENT ME!

getYLabel

protected abstract java.lang.String getYLabel()
Returns the Y-axis label

Returns:
DOCUMENT ME!

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
This method is called by the notifyObservers() method in the Model representing the infrastructure.

Specified by:
update in interface java.util.Observer
Parameters:
o - The observed Model.
arg - Optional arguments.

redraw

public void redraw()
Redraws the buffer and paints it to the screen.


drawBuffer

public void drawBuffer()
Draws the buffer.


update

public void update(java.awt.Graphics g)
Override default update() to avoid flickering.

Overrides:
update in class java.awt.Canvas
Parameters:
g - DOCUMENT ME!

paint

public void paint(java.awt.Graphics g)
Draws the data in the graphics buffer onto the screen.

Overrides:
paint in class java.awt.Canvas
Parameters:
g - the Graphics objects of this view.

setSize

public void setSize(int width,
                    int height)
Sets the size for this View

Overrides:
setSize in class java.awt.Component
Parameters:
width - the new width
height - the new height

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
DOCUMENT ME!

Overrides:
setBounds in class java.awt.Component
Parameters:
x - DOCUMENT ME!
y - DOCUMENT ME!
width - DOCUMENT ME!
height - DOCUMENT ME!

collapseData

protected void collapseData()
Collapses trackData and changes other variables accordingly.


saveData

public void saveData(java.lang.String filename,
                     SimModel model)
              throws java.io.IOException
Save data to a CSV file.

Parameters:
filename - DOCUMENT ME!
model - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!