com.panayotis.gnuplot.dataset
Class PointDataSet<N extends java.lang.Number>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<Point<N>>
              extended by com.panayotis.gnuplot.dataset.PointDataSet<N>
All Implemented Interfaces:
DataSet, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Point<N>>, java.util.Collection<Point<N>>, java.util.List<Point<N>>, java.util.RandomAccess

public class PointDataSet<N extends java.lang.Number>
extends java.util.ArrayList<Point<N>>
implements DataSet

Store data sets in a dynamic Generics ArrayList of Points. Prefer this object instead of ArrayDataSet if you plan to alter the points of this data sets afterwards its creation.

If your data are not only numerical, consider using a GenericDataSet instead.

See Also:
GenericDataSet, Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
PointDataSet()
          Create an empty PointDataSet
PointDataSet(java.util.Collection<? extends Point<N>> pts)
          Create a new PointDataSet from a previous collection of Points
PointDataSet(int initial)
          Create an empty PointDataSet with a specified initial capacity
 
Method Summary
 void add(int index, Point<N> point)
          Add a new point to this DataSet at a specified position
 boolean add(Point<N> point)
          Add a new point to this DataSet
 boolean addAll(java.util.Collection<? extends Point<N>> pts)
          Add a collection of points to this DataSet
 boolean addAll(int index, java.util.Collection<? extends Point<N>> pts)
          Add a collection of points to this DataSet starting at a specified position if there are data at the specified position, these will be shifted
 void addPoint(N... coords)
          Add a new point to the data set, given the values for each dimension.
static
<N extends java.lang.Number>
PointDataSet<N>
constructDataSet(java.lang.Class<N> objclass, java.lang.Object array)
          This is a convinient method to transform a statically defined primitive array to PointDataSet object.
 int getDimensions()
          Retrieve how many dimensions this dataset refers to.
 java.lang.String getPointValue(int point, int dimension)
          Retrieve data information from a point.
 Point<N> set(int index, Point<N> point)
          Replace the Point at the specified position with the provided one
 
Methods inherited from class java.util.ArrayList
clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.panayotis.gnuplot.dataset.DataSet
size
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

PointDataSet

public PointDataSet()
Create an empty PointDataSet


PointDataSet

public PointDataSet(int initial)
Create an empty PointDataSet with a specified initial capacity

Parameters:
initial - The initial capacity of this PointDataSet

PointDataSet

public PointDataSet(java.util.Collection<? extends Point<N>> pts)
             throws java.lang.NumberFormatException
Create a new PointDataSet from a previous collection of Points

Parameters:
pts - The collection of Points to use as a model
Throws:
java.lang.NumberFormatException - If the given collection is not in the correct format
Method Detail

add

public boolean add(Point<N> point)
            throws java.lang.NumberFormatException
Add a new point to this DataSet

Specified by:
add in interface java.util.Collection<Point<N extends java.lang.Number>>
Specified by:
add in interface java.util.List<Point<N extends java.lang.Number>>
Overrides:
add in class java.util.ArrayList<Point<N extends java.lang.Number>>
Parameters:
point - The point to add to this DataSet
Returns:
Whether the collection changed with this call
Throws:
java.lang.NumberFormatException - If the given collection is not in the correct format

add

public void add(int index,
                Point<N> point)
         throws java.lang.NumberFormatException
Add a new point to this DataSet at a specified position

Specified by:
add in interface java.util.List<Point<N extends java.lang.Number>>
Overrides:
add in class java.util.ArrayList<Point<N extends java.lang.Number>>
Parameters:
index - Where to add this point
point - The point to add to this DataSet
Throws:
java.lang.NumberFormatException - If the given collection is not in the correct format

addAll

public boolean addAll(java.util.Collection<? extends Point<N>> pts)
               throws java.lang.NumberFormatException
Add a collection of points to this DataSet

Specified by:
addAll in interface java.util.Collection<Point<N extends java.lang.Number>>
Specified by:
addAll in interface java.util.List<Point<N extends java.lang.Number>>
Overrides:
addAll in class java.util.ArrayList<Point<N extends java.lang.Number>>
Parameters:
pts - The points colelction
Returns:
Whether the collection changed with this call
Throws:
java.lang.NumberFormatException - If the given collection is not in the correct format

addAll

public boolean addAll(int index,
                      java.util.Collection<? extends Point<N>> pts)
               throws java.lang.NumberFormatException
Add a collection of points to this DataSet starting at a specified position if there are data at the specified position, these will be shifted

Specified by:
addAll in interface java.util.List<Point<N extends java.lang.Number>>
Overrides:
addAll in class java.util.ArrayList<Point<N extends java.lang.Number>>
Parameters:
index - Where to start adding point data.
pts - The point collection to add
Returns:
Whether the collection changed with this call
Throws:
java.lang.NumberFormatException - If the given collection is not in the correct format

set

public Point<N> set(int index,
                    Point<N> point)
                                      throws java.lang.NumberFormatException
Replace the Point at the specified position with the provided one

Specified by:
set in interface java.util.List<Point<N extends java.lang.Number>>
Overrides:
set in class java.util.ArrayList<Point<N extends java.lang.Number>>
Parameters:
index - The position of the point to be altered
point - The point to use
Returns:
The Point previously found in the specified position
Throws:
java.lang.NumberFormatException - If the given collection is not in the correct format

addPoint

public void addPoint(N... coords)
Add a new point to the data set, given the values for each dimension.

Parameters:
coords - a list of primitive data of the same type of this collection. Could also be boxed variables too.

getDimensions

public int getDimensions()
Retrieve how many dimensions this dataset refers to.

Specified by:
getDimensions in interface DataSet
Returns:
the number of dimensions
See Also:
DataSet.getDimensions()

getPointValue

public java.lang.String getPointValue(int point,
                                      int dimension)
Retrieve data information from a point.

Specified by:
getPointValue in interface DataSet
Parameters:
point - The point number
dimension - The point dimension (or "column") to request data from
Returns:
the point data for this dimension
See Also:
DataSet.getPointValue(int,int)

constructDataSet

public static final <N extends java.lang.Number> PointDataSet<N> constructDataSet(java.lang.Class<N> objclass,
                                                                                  java.lang.Object array)
                                                                       throws java.lang.ArrayStoreException
This is a convinient method to transform a statically defined primitive array to PointDataSet object. Use this method if your oroginal data is in a static primitive array but you want to take advantage of the flexibility of PointDataSet, instead od ArrayDataSet.

Parameters:
objclass - The class of this PointDataSet. For example for Double precision numbers, this parameter should be Double.class
array - The array containing the primitive data
Returns:
The produced PointDataSet of class objclass
Throws:
java.lang.ArrayStoreException - If some misconfiguration is performed on the provided array object