de.invation.code.toval.graphic.diagrams.models.ScatterChartModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of TOVAL Show documentation
Show all versions of TOVAL Show documentation
TOVAL comprises a set of java classes for common programming issues. It includes utils for arrays, lists, sets and collections for convenient handling and modification, but also support for mathematic definitions concerning logic (clauses + resolution) together with some algorithms for permutations, powersets and resolution. Additionally it contains a number of types for multisets, matrices with object keys and much more.
The newest version!
package de.invation.code.toval.graphic.diagrams.models;
import java.util.HashMap;
import java.util.List;
import de.invation.code.toval.types.StatList;
public class ScatterChartModel,T extends Number & Comparable super T>> implements ChartModel {
/**
* Keeps the values for the two coordinate axes.
* The values are kept in form of StatLists and are indexable by their corresponding coordinate axes.
* @see StatList
*/
protected HashMap> values = new HashMap>(2);
public ScatterChartModel() {}
public ScatterChartModel(List xValues, List yValues, boolean equalSizes) {
setValues(xValues, yValues, equalSizes);
}
protected void setValues(List xValues, List yValues, boolean equalSizes){
if(xValues == null || yValues == null)
throw new NullPointerException();
if(equalSizes)
if(xValues.size() != yValues.size())
throw new IllegalArgumentException("Collection sizes do not match!");
values.put(ValueDimension.X, new StatList(xValues, false));
values.put(ValueDimension.Y, new StatList(yValues, false));
}
/**
* Returns the number of values maintained for the given dimension.
* @return The number of values maintained for the given dimension
*/
@Override
public int getValueCount(ValueDimension dim) {
return values.get(dim).size();
}
/**
* Returns the maintained values for the given dimension.
* @param dim Reference dimension
* @return Maintained values for the given dimension
*/
@Override
public StatList> getValues(ValueDimension dim) {
return values.get(dim);
}
public void setXValues(List xValues){
if(xValues == null)
throw new NullPointerException();
values.put(ValueDimension.X, new StatList(xValues, false));
}
public void setYValues(List yValues){
if(yValues == null)
throw new NullPointerException();
values.put(ValueDimension.Y, new StatList(yValues, false));
}
/**
* Returns the value with the given index of the given dimension.
* @param dim Reference dimension for value extraction
* @param index Index of the desired value
* @return Value with the given index of the given dimension
*/
@Override
public Number getValue(ValueDimension dim, int index) {
return values.get(dim).get(index);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy