package jas2.hist;
import jas2.plot.CoordinateTransformation;
import jas2.plot.DateCoordinateTransformation;
import jas2.plot.DoubleCoordinateTransformation;
import jas2.plot.MutableLegendEntry;
import jas2.plot.Overlay;
import jas2.plot.PlotGraphics;
import jas2.plot.Transformation;
import java.awt.BasicStroke;
import java.io.IOException;
import java.io.Serializable;
import java.util.Observable;
public class JASHist1DFunctionData extends JASHistData implements Serializable
{
private double lowerBound = Double.NaN;
private double upperBound = Double.NaN;
public JASHist1DFunctionData(DataManager parent, Basic1DFunction ds)
{
super(parent);
dataSource = ds;
style = new JASHist1DFunctionStyle();
style.addObserver(this);
}
public void setStyle(JASHistStyle style)
{
if (!(style instanceof JASHist1DFunctionStyle))
throw new IllegalArgumentException("Style is not subclass of JASHist1DFunctionStyle");
if (this.style != null) this.style.deleteObserver(this);
this.style = (JASHist1DFunctionStyle) style;
style.addObserver(this);
}
public void update (Observable o, Object arg)
{
// Dragons: Likely to be called by different thread
if (o == dataSource) ((SupportsFunctions) parent).update(this);
else if (o == style) ((SupportsFunctions) parent).update(this); // overkill, we really just need a repaint
}
public void axisChanged()
{
((SupportsFunctions) parent).update(this);
}
public void setXBounds(double xmin, double xmax) {
this.lowerBound = xmin;
this.upperBound = xmax;
}
void setXRange(double xmin, double xmax)
{
if ( ! Double.isNaN(lowerBound) )
xmin = xmin < lowerBound ? lowerBound : xmin;
if ( ! Double.isNaN(upperBound) )
xmax = xmax > upperBound ? upperBound : xmax;
if ( xmin > xmax )
xmin = xmax;
if (overlay instanceof JASHistFunctionOverlay) ((JASHistFunctionOverlay) overlay).setXRange(xmin,xmax);
}
public String getTitle()
{
return dataSource.getTitle();
}
Overlay createOverlay()
{
return new JASHistFunctionOverlay(this,style);
}
public JASHistStyle getStyle()
{
return style;
}
public DataSource getDataSource()
{
return dataSource;
}
void normalizationChanged(boolean now)
{
}
public void writeAsXML(XMLPrintWriter pw, boolean snapshot)
{
pw.setAttribute("axis","y"+getYAxis());
//TODO: getTitle is not correct, fix this
pw.setAttribute("type",dataSource.getTitle());
pw.openTag("function1d");
String[] pNames = dataSource.getParameterNames();
double[] pValue = dataSource.getParameterValues();
for (int i=0; i (width/2)) flw = (width > 2) ? (float) (width/2 -1) : 1;
BasicStroke s = new BasicStroke(flw,BasicStroke.CAP_SQUARE,BasicStroke.JOIN_ROUND,10,lineStyles[style.getLineStyle()],0);
g.setStroke(s);
g.setStroke(s);
g.drawLine(1, height/2, width-2, height/2);
g.setStroke(null);
}
private JASHist1DFunctionStyle style;
private JASHist1DFunctionData source;
private double xmin, xmax;
}
Ads help maintain this website.