/** * Initialize a coordinate base. */ private void initBase(double[] lowerBound, double[] upperBound, String[] axisLabels) { base = new Base(lowerBound, upperBound); backupBase = base; baseGrid = new BaseGrid(base, axisLabels); }
/** * Returns the i-<i>th</i> axis. */ public Axis getAxis(int i) { return baseGrid.getAxis(i); }
/** * Sets the label/legend of an axis. */ public PlotCanvas setAxisLabel(int axis, String label) { baseGrid.setAxisLabel(axis, label); repaint(); return this; }
/** * Zooms in/out the plot. * @param inout true if zoom in. Otherwise, zoom out. */ public void zoom(boolean inout) { for (int i = 0; i < base.dimension; i++) { int s = baseGrid.getAxis(i).getLinearSlices(); double r = inout ? -1.0 / s : 1.0 / s; double d = (base.upperBound[i] - base.lowerBound[i]) * r; base.lowerBound[i] -= d; base.upperBound[i] += d; } for (int i = 0; i < base.dimension; i++) { base.setPrecisionUnit(i); } base.initBaseCoord(); graphics.projection.reset(); baseGrid.setBase(base); canvas.repaint(); }
/** * Extend lower bounds. */ public void extendLowerBound(double[] bound) { base.extendLowerBound(bound); baseGrid.setBase(base); repaint(); }
g2d.fillRect(0, 0, getSize().width, getSize().height); g2d.setColor(color); baseGrid.paint(graphics);
@Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.getWheelRotation() == 0) { return; } for (int i = 0; i < base.dimension; i++) { int s = baseGrid.getAxis(i).getLinearSlices(); double r = e.getWheelRotation() > 0 ? 1.0 / s : -1.0 / s; if (r > -0.5) { double d = (base.upperBound[i] - base.lowerBound[i]) * r; base.lowerBound[i] -= d; base.upperBound[i] += d; } } for (int i = 0; i < base.dimension; i++) { base.setPrecisionUnit(i); } base.initBaseCoord(); graphics.projection.reset(); baseGrid.setBase(base); repaint(); e.consume(); }
/** * Extend upper bounds. */ public void extendUpperBound(double[] bound) { base.extendUpperBound(bound); baseGrid.setBase(base); repaint(); }
double x = mouseClickX - e.getX(); if (Math.abs(x) > 20) { int s = baseGrid.getAxis(0).getLinearSlices(); x = x > 0 ? 1.0 / s : -1.0 / s; x *= (backupBase.upperBound[0] - backupBase.lowerBound[0]); int s = baseGrid.getAxis(1).getLinearSlices(); y = y > 0 ? -1.0 / s : 1.0 / s; y *= (backupBase.upperBound[1] - backupBase.lowerBound[1]); baseGrid.setBase(base); repaint(); } else {
/** * Extend lower and upper bounds. */ public void extendBound(double[] lowerBound, double[] upperBound) { base.extendBound(lowerBound, upperBound); baseGrid.setBase(base); repaint(); }
/** * Initialize a coordinate base. */ private void initBase(double[] lowerBound, double[] upperBound, boolean extendBound) { base = new Base(lowerBound, upperBound, extendBound); backupBase = base; baseGrid = new BaseGrid(base); }
/** * Returns the labels/legends of axes. */ public String[] getAxisLabels() { String[] labels = new String[base.dimension]; for (int i = 0; i < base.dimension; i++) { labels[i] = baseGrid.getAxis(i).getAxisLabel(); } return labels; }
/** * Sets the labels/legends of axes. */ public PlotCanvas setAxisLabels(String... labels) { baseGrid.setAxisLabel(labels); repaint(); return this; }
@Override public void componentResized(ComponentEvent e) { if (graphics != null) { base.initBaseCoord(); graphics.projection.reset(); baseGrid.setBase(base); } repaint(); }
/** * Initialize a coordinate base. */ private void initBase(double[] lowerBound, double[] upperBound) { base = new Base(lowerBound, upperBound); backupBase = base; baseGrid = new BaseGrid(base); }
/** * Returns the label/legend of an axis. */ public String getAxisLabel(int axis) { return baseGrid.getAxis(axis).getAxisLabel(); }
/** * Resets the plot. */ public void reset() { base.reset(); graphics.projection.reset(); baseGrid.setBase(base); if (graphics.projection instanceof Projection3D) { ((Projection3D) graphics.projection).setDefaultView(); } canvas.repaint(); }
/** * Initialize a coordinate base. */ private void initBase(double[] lowerBound, double[] upperBound, String[] axisLabels, boolean extendBound) { base = new Base(lowerBound, upperBound, extendBound); backupBase = base; baseGrid = new BaseGrid(base, axisLabels); }
baseGrid.setBase(base);
baseGrid.setBase(base);