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.
Graph
,
BareGraph
Constructor and Description |
---|
GraphDataSet()
The default constructor.
|
GraphDataSet(int cap)
The constructor with the capacity.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public GraphDataSet()
public GraphDataSet(int cap)
cap
- the capacity of this data setpublic int getCapacity()
public int getSize()
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.
v
- the new element (int)public int[] getValues()
getSize()
,
getCapacity()
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
protected void firePropertyChange(java.lang.String property, java.lang.Object old_v, java.lang.Object new_v)
property
- this will be Valuesold_v
- this is not usednew_v
- the new (added) value as IntegerremovePropertyChangeListener(java.beans.PropertyChangeListener)
,
addPropertyChangeListener(java.beans.PropertyChangeListener)
,
PropertyChangeEvent
,
PropertyChangeListener