package jasext.jhplotserver;
import jas2.hist.HasScatterPlotData;
import jas2.hist.HasStatistics;
import jas2.hist.HasStyle;
import jas2.hist.JASHist1DHistogramStyle;
import jas2.hist.JASHistStyle;
import jas2.hist.ScatterEnumeration;
import jas2.hist.Statistics;
import jas2.hist.XYDataSource;
import jhplot.P1D;
public class RefP1D extends ScatterDataWithType implements XYDataSource, HasStyle, HasStatistics, Statistics {
protected double[] x;
protected double[] y;
protected double npoints;
private P1D h;
final private String type = "scatter";
public RefP1D(final P1D h) {
super();
this.h = h;
/*
npoints=h.size();
x = new double[h.size()];
y = new double[h.size()];
for (int i = 0; i < h.size(); i++) {
x[i] = h.getX(i);
y[i] = h.getY(i);
}
*/
}
public int getSize() {
return h.size();
}
/*
public double[][][] rebin(int xbins, double p2, double p3, int ybins, double p6, double p7, boolean p4, boolean p5, boolean p8)
{
int nn= h.size();
double[][] newHeights = new double[2][nn];
double[][] newErrors = new double[2][nn];
for (int i = 0; i = xmin && x[n] < xmax && y[n] >= ymin
&& y[n] < ymax) {
d[0] = x[n];
d[1] = y[n];
n++;
return true;
}
n++;
}
return false;
} else {
if (n == npoints)
return false;
d[0] = x[n];
d[1] = y[n];
n++;
return true;
}
}
public void resetEndPoint() {
// ??
}
public void restart() {
n = 0;
}
private int n = 0;
private boolean limits;
private double ymin, ymax, xmin, xmax;
}
@Override
public int getNPoints() {
// TODO Auto-generated method stub
return h.size();
}
@Override
public double getX(int index) {
return h.getX(index);
}
@Override
public double getY(int index) {
return h.getY(index);
}
@Override
public double getPlusError(int index) {
return h.getYupper(index);
}
@Override
public double getMinusError(int index) {
if (h.getDimension()>3) return h.getYlower(index);
return h.getYupper(index);
}
@Override
public int getAxisType() {
// TODO Auto-generated method stub
return DOUBLE;
}
@Override
public JASHistStyle getStyle() {
JASHist1DHistogramStyle style = new JASHist1DHistogramStyle();
style.setShowHistogramBars(false);
style.setShowDataPoints(true);
style.setShowLinesBetweenPoints(false);
style.setShowErrorBars(true);
return style;
}
}
Ads help maintain this website.