SNMP Stack 4_12

uk.co.westhawk.visual
Class GraphDataSet

java.lang.Object
  |
  +--uk.co.westhawk.visual.GraphDataSet

public class GraphDataSet
extends java.lang.Object

The class GraphDataSet holds the int data, representing a line on a Graph

Only a fixed number of elements will be saved, that is called the capacity. The oldest value is removed each time the capacity would overflow.

The capacity can not be change dynamically, only via the constructor.

Version:
$Revision: 1.5 $ $Date: 2002/10/10 15:13:58 $
Author:
Birgit Arkesteijn
See Also:
Graph, BareGraph

Constructor Summary
GraphDataSet()
          The default constructor.
GraphDataSet(int cap)
          The constructor with the capacity.
 
Method Summary
 void addElement(int v)
           Adds a value to the data set.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a property change listener.
protected  void firePropertyChange(java.lang.String property, java.lang.Object old_v, java.lang.Object new_v)
          Fire a property event.
 int getCapacity()
          Returns the capacity.
 int getSize()
          Returns the current number of elements.
 int[] getValues()
          Returns the values of this data set.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a property change listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphDataSet

public GraphDataSet()
The default constructor. The capacity will be by default 100.

GraphDataSet

public GraphDataSet(int cap)
The constructor with the capacity.
Parameters:
cap - the capacity of this data set
Method Detail

getCapacity

public int getCapacity()
Returns the capacity. The capacity is the number of elements that this data set can hold.
Returns:
the capacity

getSize

public int getSize()
Returns the current number of elements. This is always less or equal to the capacity.
Returns:
the size

addElement

public void addElement(int v)

Adds a value to the data set. If the capacity is reached, the oldest value will be removed.

The oldest value will always the first element, the newest value always the last element. This methods fires a propertyChangeEvent.

Parameters:
v - the new element (int)

getValues

public int[] getValues()
Returns the values of this data set. The length of this array will always be the capacity. To get the actual number, call getSize().
Returns:
all the elements
See Also:
getSize(), getCapacity()

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a property change listener. This methods fires a propertyChangeEvent.
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a property change listener.
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener)

firePropertyChange

protected void firePropertyChange(java.lang.String property,
                                  java.lang.Object old_v,
                                  java.lang.Object new_v)
Fire a property event. This is done each time a new element is added and when adding a listener.
Parameters:
property - this will be Values
old_v - this is not used
new_v - the new (added) value as Integer
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener), addPropertyChangeListener(java.beans.PropertyChangeListener), PropertyChangeEvent, PropertyChangeListener

SNMP Stack 4_12