76 lines
1.4 KiB
Java
76 lines
1.4 KiB
Java
package org.hwo.ui.diagram;
|
|
|
|
import java.awt.Color;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
|
|
public class SimplePlotProvider implements PlotProvider {
|
|
|
|
int points;
|
|
int xmin;
|
|
|
|
ArrayList<Float[]> plots;
|
|
ArrayList<String> labels;
|
|
Color[] colors;
|
|
|
|
public SimplePlotProvider(int plots,int points) {
|
|
this.points = points;
|
|
this.plots = new ArrayList<Float[]>();
|
|
this.labels = new ArrayList<String>();
|
|
this.xmin = 0;
|
|
this.colors = new Color[plots];
|
|
|
|
for (int i=0;i<plots;i++){
|
|
this.plots.add(new Float[points]);
|
|
this.labels.add(String.format("Plot %d", i));
|
|
Arrays.fill(this.plots.get(i), 0.0f);
|
|
this.colors[i] = new Color(255,0,0);
|
|
}
|
|
}
|
|
|
|
public int getXmin() {
|
|
return xmin;
|
|
}
|
|
public void setXmin(int xmin) {
|
|
this.xmin = xmin;
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
public int getPoints() {
|
|
return this.points;
|
|
}
|
|
|
|
@Override
|
|
public int getPlots() {
|
|
return this.plots.size();
|
|
}
|
|
|
|
@Override
|
|
public Float[][] getMatrix() {
|
|
return this.plots.toArray(new Float[][]{});
|
|
}
|
|
|
|
@Override
|
|
public String getLabel(int plot) {
|
|
return this.labels.get(plot);
|
|
}
|
|
|
|
@Override
|
|
public String getPointLabel(int point) {
|
|
return String.format("%d", (this.xmin + point));
|
|
}
|
|
|
|
@Override
|
|
public Color[] getColors() {
|
|
return this.colors;
|
|
}
|
|
|
|
public void setPlot(int plot,Float[] values){
|
|
Float[] cv = Arrays.copyOf(values, points);
|
|
this.plots.set(plot, cv);
|
|
}
|
|
|
|
}
|