00001 package org.math.plot.plotObjects;
00002
00009 import java.awt.*;
00010
00011 import org.math.plot.render.*;
00012
00013 public class BasePlot implements BaseDependant {
00014
00015 public static Color DEFAULT_COLOR = Color.DARK_GRAY;
00016
00017 protected Base base;
00018
00019 protected Axis[] axis;
00020
00021 protected boolean visible = true;
00022
00023 protected Color color;
00024
00025 public BasePlot(Base b, String... as) {
00026 this(b, DEFAULT_COLOR, as);
00027 }
00028
00029 public BasePlot(Base b, Color c, Axis... a) {
00030 base = b;
00031 axis = a;
00032 color = c;
00033 }
00034
00035 public BasePlot(Base b, Color c, String... as) {
00036 base = b;
00037 if (as.length != base.dimension) {
00038 throw new IllegalArgumentException("String array of axes names must have " + base.dimension + " elements.");
00039 }
00040 color = c;
00041 axis = new Axis[base.dimension];
00042 for (int i = 0; i < base.dimension; i++) {
00043 axis[i] = new Axis(base, as[i], color, i);
00044 }
00045
00046 }
00047
00048 public void setVisible(boolean v) {
00049 visible = v;
00050 }
00051
00052 public void setVisible(int i, boolean v) {
00053 axis[i].setVisible(v);
00054 }
00055
00056 public void setGridVisible(int i, boolean v) {
00057 axis[i].setGridVisible(v);
00058 }
00059
00060 public boolean getVisible() {
00061 return visible;
00062 }
00063
00064 public void setColor(Color c) {
00065 color = c;
00066 for (int i = 0; i < axis.length; i++) {
00067 axis[i].setColor(c);
00068 }
00069 }
00070
00071 public Color getColor() {
00072 return color;
00073 }
00074
00075 public void setLegend(String[] as) {
00076 if (as.length != base.dimension) {
00077 throw new IllegalArgumentException("String array of axes names must have " + base.dimension + " elements.");
00078 }
00079 for (int i = 0; i < axis.length; i++) {
00080 axis[i].setLegend(as[i]);
00081 }
00082
00083 }
00084
00085 public void setLegend(int i, String as) {
00086 axis[i].setLegend(as);
00087
00088 }
00089
00090 public String[] getLegend() {
00091 String[] array = new String[axis.length];
00092 for (int i = 0; i < array.length; i++) {
00093 array[i] = axis[i].getLegend();
00094 }
00095 return array;
00096 }
00097
00098 public String getLegend(int i) {
00099 return axis[i].getLegend();
00100 }
00101
00102 public void setBase(Base b) {
00103 base = b;
00104 for (int i = 0; i < axis.length; i++) {
00105 axis[i].base = base;
00106 }
00107 resetBase();
00108 }
00109
00110 public void plot(AbstractDrawer draw) {
00111 if (!visible)
00112 return;
00113
00114 for (int i = 0; i < axis.length; i++)
00115 axis[i].plot(draw);
00116 }
00117
00118 public Axis getAxis(int i) {
00119 return axis[i];
00120 }
00121
00122 public Axis[] getAxis() {
00123 return axis;
00124 }
00125
00126 public void resetBase() {
00127
00128 for (int i = 0; i < axis.length; i++) {
00129 axis[i].resetBase();
00130
00131 }
00132 }
00133
00134 }