src/org/math/plot/plots/Plot.java

00001 package org.math.plot.plots;
00002 
00003 import java.awt.Color;
00004 import java.util.LinkedList;
00005 
00006 import org.math.plot.canvas.PlotCanvas;
00007 import org.math.plot.plotObjects.Editable;
00008 import org.math.plot.plotObjects.Noteable;
00009 import org.math.plot.plotObjects.Plotable;
00010 import org.math.plot.render.AbstractDrawer;
00011 
00012 public abstract class Plot implements Plotable, Noteable, Editable {
00013 
00014         public String name;
00015 
00016         public Color color;
00017 
00018         public boolean visible = true;
00019 
00020         public LinkedList<LayerPlot> layers;
00021 
00022         public boolean noted = false;
00023 
00024         //public boolean forcenoted = false;
00025 
00026         public int note_precision = 5;
00027 
00028         public Plot(String n, Color c) {
00029                 name = n;
00030                 color = c;
00031                 layers = new LinkedList<LayerPlot>();
00032 
00033         }
00034 
00035         public void addLayer(LayerPlot q) {
00036                 layers.add(q);
00037         }
00038 
00039         public void addQuantile(QuantileLayerPlot q) {
00040                 layers.add(q);
00041         }
00042 
00043         public void addQuantile(int a, double r, double[] q, boolean symetric) {
00044                 layers.add(new QuantileLayerPlot(this, a, q, r, symetric));
00045         }
00046 
00047         public void addQuantile(int a, double r, double q, boolean symetric) {
00048                 layers.add(new QuantileLayerPlot(this, a, q, r, symetric));
00049         }
00050 
00051         public void addQuantiles(int a, double[][] q) {
00052                 layers.add(new DensityLayerPlot(this, a, q));
00053         }
00054 
00055         public void addQuantiles(int a, double[] q) {
00056                 layers.add(new DensityLayerPlot(this, a, q));
00057         }
00058 
00059         public void addGaussQuantiles(int a, double[] s) {
00060                 layers.add(new GaussianDensityLayerPlot(this, a, s));
00061         }
00062 
00063         public void addGaussQuantiles(int a, double s) {
00064                 layers.add(new GaussianDensityLayerPlot(this, a, s));
00065         }
00066 
00067         /*public void addQuantiles(double[][][] q,boolean _symetric) {
00068                 for (int i = 0; i < q[0].length; i++) {
00069                         addQuantile(i, Array.getColumnCopy(q, i, 0),_symetric);
00070                         addQuantile(i, Array.getColumnCopy(q, i, 1),_symetric);
00071                 }
00072         }*/
00073 
00074         /*public void addQuantiles(double[][] q,boolean _symetric) {
00075                 for (int i = 0; i < q[0].length; i++) {
00076                         addQuantile(i, Array.getColumnCopy(q, i),_symetric);
00077                 }
00078         }*/
00079 
00080         public void addVector(double[][] v) {
00081                 layers.add(new VectorLayerPlot(this, v));
00082 
00083         }
00084 
00085         public abstract void setData(double[][] d);
00086 
00087         public abstract double[][] getData();
00088 
00089         public void setVisible(boolean v) {
00090                 visible = v;
00091         }
00092 
00093         public boolean getVisible() {
00094                 return visible;
00095         }
00096 
00097         public void setName(String n) {
00098                 name = n;
00099         }
00100 
00101         public String getName() {
00102                 return name;
00103         }
00104 
00105         /*
00106          * public String getType() { return type; }
00107          */
00108 
00109         public Color getColor() {
00110                 return color;
00111         }
00112 
00113         public void setColor(Color c) {
00114                 color = c;
00115         }
00116 
00117         public abstract double[] isSelected(int[] screenCoordTest, AbstractDrawer draw);
00118 
00119         public void note(AbstractDrawer draw) {
00120                 plot(draw, PlotCanvas.NOTE_COLOR);
00121                 plotLayerPlots(draw, PlotCanvas.NOTE_COLOR);
00122         }
00123 
00124         public abstract void plot(AbstractDrawer draw, Color c);
00125 
00126         public void plot(AbstractDrawer draw) {
00127                 //if (layers.size() > 0)
00128                 plotLayerPlots(draw, color);
00129                 //else
00130                 plot(draw, color);
00131         }
00132 
00133         public void plotLayerPlots(AbstractDrawer draw, Color c) {
00134                 for (int i = 0; i < layers.size(); i++)
00135                         layers.get(i).plot(draw, c);
00136 
00137         }
00138 
00139         public void edit(Object src) {
00140                 ((PlotCanvas) src).displayDatasFrame(((PlotCanvas) src).getPlotIndex(this));
00141         }
00142 
00143         public void editnote(AbstractDrawer draw) {
00144                 plot(draw, PlotCanvas.EDIT_COLOR);
00145                 plotLayerPlots(draw, PlotCanvas.EDIT_COLOR);
00146         }
00147 }

Generated on Wed Sep 5 21:44:02 2007 for jmathplot by  doxygen 1.5.1