/** * Extend lower and upper bounds. */ public void extendBound(double[] lowerBound, double[] upperBound) { base.extendBound(lowerBound, upperBound); baseGrid.setBase(base); repaint(); }
/** * Reset base coordinates. Round/extend lower and upper bounds if necessary. */ public void reset() { for (int i = 0; i < dimension; i++) { lowerBound[i] = originalLowerBound[i]; upperBound[i] = originalUpperBound[i]; setPrecisionUnit(i); } // setup rounded base. for (int i = 0; i < dimension; i++) { if (extendBound[i]) { extendBound(i); } } initBaseCoord(); }
/** * Create a plot canvas with the poly line plot of given data. * @param id the id of the plot. * @param y a data vector that describes y coordinates of points. The x * coordinates will be [0, n), where n is the length of y. */ public static PlotCanvas plot(String id, double[] y) { double[] lowerBound = {0, Math.min(y)}; double[] upperBound = {y.length, Math.max(y)}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.base.extendBound(1); double[][] data = new double[y.length][2]; for (int i = 0; i < data.length; i++) { data[i][0] = i; data[i][1] = y[i]; } LinePlot plot = new LinePlot(data); plot.setID(id); canvas.add(plot); return canvas; }
/** * Create a plot canvas with the poly line plot of given data. * @param id the id of the plot. * @param y a data vector that describes y coordinates of points. The x * coordinates will be [0, n), where n is the length of y. * @param style the stroke style of line. */ public static PlotCanvas plot(String id, double[] y, Line.Style style) { double[] lowerBound = {0, Math.min(y)}; double[] upperBound = {y.length, Math.max(y)}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.base.extendBound(1); double[][] data = new double[y.length][2]; for (int i = 0; i < data.length; i++) { data[i][0] = i; data[i][1] = y[i]; } LinePlot plot = new LinePlot(data, style); plot.setID(id); canvas.add(plot); return canvas; }
/** * Create a plot canvas with the poly line plot of given data. * @param id the id of the plot. * @param y a data vector that describes y coordinates of points. The x * coordinates will be [0, n), where n is the length of y. * @param style the stroke style of line. * @param color the color of line. */ public static PlotCanvas plot(String id, double[] y, Line.Style style, Color color) { double[] lowerBound = {0, Math.min(y)}; double[] upperBound = {y.length, Math.max(y)}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.base.extendBound(1); double[][] data = new double[y.length][2]; for (int i = 0; i < data.length; i++) { data[i][0] = i; data[i][1] = y[i]; } LinePlot plot = new LinePlot(data, style); plot.setID(id); plot.setColor(color); canvas.add(plot); return canvas; }