/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package systole.view.charts;
import java.awt.Color;
import java.util.Observable;
import java.util.Observer;
import java.util.Vector;
import org.jfree.chart.plot.XYPlot;
import systole.domain.analysis.results.AnalysisResult;
import systole.domain.analysis.results.Parameter;
import systole.view.tabs.controllers.ResultsModel;
/**
*
* @author user
*/
public class XYParameterList implements Observer {
private Vector<XYParameter> list;
private XYPlot plot;
public XYParameterList(XYPlot plot, ResultsModel resultModel) {
resultModel.addObserver(this);
this.list = new Vector<XYParameter>();
this.plot = plot;
this.buildChartParameters(resultModel.getCurrentResults());
}
public void buildChartParameters(AnalysisResult analysisResult) {
if (analysisResult != null) {
this.list.removeAllElements();
this.addXYParameter(analysisResult.getAod(), Color.BLUE); //agregando parametro amplitud onda diastolica
this.addXYParameter(analysisResult.getAos(), Color.GREEN); //agregando parametro ancho onda sistolica
this.addXYParameter(analysisResult.getT(), Color.MAGENTA); //agregando parametro T
this.addXYParameter(analysisResult.getIar(), Color.ORANGE); //agregando parametro IAR
}
}
public void addXYParameter(Parameter param, Color fill) {
XYParameter gParam = new XYParameter(param, fill);
this.list.add(gParam);
}
public void showParameter(int index) {
this.removeParameters();
XYParameter xyp = this.list.get(index);
xyp.paintInChart(this.plot);
}
public void removeParameters() {
this.plot.clearAnnotations();
}
public void update(Observable o, Object arg) {
this.list.removeAllElements();
AnalysisResult analysisResult = (AnalysisResult) arg;
this.buildChartParameters(analysisResult);
}
}