/** * Get the Minimum Y value of all attached DataSets. * * @return The minimum value */ public double getYmin() { DataSet d; double min = 0.0; if (dataset == null | dataset.isEmpty()) return min; for (int i = 0; i < dataset.size(); i++) { d = ((DataSet) dataset.elementAt(i)); if (i == 0) min = d.getYmin(); else min = Math.min(min, d.getYmin()); } return min; }
/** * Load and Attach a DataSet from an array. The method loads the data into a DataSet class and * attaches the class to the graph for plotting. * * <p>The data is assumed to be stored in the form x,y,x,y,x,y.... A local copy of the data is * made. * * @param data The data to be loaded in the form x,y,x,y,... * @param n The number of (x,y) data points. This means that the minimum length of the data array * is 2*n. * @return The DataSet constructed containing the data read. */ public DataSet loadDataSet(double data[], int n) { DataSet d; try { d = new DataSet(data, n); dataset.addElement(d); d.g2d = this; } catch (Exception e) { System.out.println("Failed to load Data set "); e.printStackTrace(); return null; } return d; }
/** * Get the Maximum Y value of all attached DataSets. * * @return The maximum value */ public double getYmax() { DataSet d; double max = 0.0; if (dataset == null | dataset.isEmpty()) return max; for (int i = 0; i < dataset.size(); i++) { d = ((DataSet) dataset.elementAt(i)); if (i == 0) max = d.getYmax(); else max = Math.max(max, d.getYmax()); } return max; }
/** * Attach a DataSet to the graph. By attaching the data set the class can draw the data through * its paint method. */ public void attachDataSet(DataSet d) { if (d != null) { dataset.addElement(d); d.g2d = this; } }
/** * Define a Vector legend in the graph window * * @param x data position of the legend. * @param y data position of the legend. * @param text text to display in the legend */ public void legend(double x, double y, String text) { super.legend(x, y, text); drawlegend = true; }
/** * Define a Vector legend in the graph window * * @param x pixel position of the legend. * @param y pixel position of the legend. * @param text text to display in the legend */ public void legend(int x, int y, String text) { super.legend(x, y, text); drawlegend = true; }
/** * Define a Vector legend in the graph window. The legend will be placed above the data window in * the center * * @param text text to display in the legend */ public void legend(String text) { super.legend(-1, -1, text); drawlegend = true; }
/** * Draw a Vector legend in the graph window. The legend will be placed above the data window in * the center */ public void legend() { super.legend(-1, -1, null); drawlegend = true; }