forked from LupusNobilis/java-org.hwo.ui
75 lines
1.1 KiB
Java
75 lines
1.1 KiB
Java
package org.hwo.ui.diagram;
|
|
|
|
import java.util.Arrays;
|
|
|
|
public class Plot {
|
|
|
|
private Diagram diagram;
|
|
|
|
private String label;
|
|
|
|
private Float[] values;
|
|
|
|
protected Plot(Diagram diagram){
|
|
this.diagram = diagram;
|
|
this.values = new Float[0];
|
|
}
|
|
|
|
public Diagram getDiagram() {
|
|
return diagram;
|
|
}
|
|
|
|
public String getLabel() {
|
|
return label;
|
|
}
|
|
public void setLabel(String label) {
|
|
this.label = label;
|
|
}
|
|
|
|
public Float[] getValues() {
|
|
return this.values;
|
|
};
|
|
public void setValues(Float[] values) {
|
|
this.values = values;
|
|
}
|
|
|
|
public Float getValue(int index){
|
|
return this.values[index];
|
|
}
|
|
public void setValue(int index,Float value){
|
|
this.values[index] = value;
|
|
}
|
|
|
|
public Float getMin(){
|
|
Float min = Float.MAX_VALUE;
|
|
|
|
for (Float f: values)
|
|
if (f < min)
|
|
min = f;
|
|
|
|
return min;
|
|
};
|
|
public Float getMax(){
|
|
Float max = Float.MIN_VALUE;
|
|
|
|
for (Float f: values)
|
|
if (f > max)
|
|
max = f;
|
|
|
|
return max;
|
|
};
|
|
|
|
|
|
|
|
|
|
void resize(int points){
|
|
int l = Math.min(this.values.length,points);
|
|
Float[] nv = new Float[points];
|
|
System.arraycopy(this.values, 0, nv, 0, l);
|
|
this.values = nv;
|
|
}
|
|
|
|
|
|
|
|
}
|