/** * Returns the i-<i>th</i> axis. */ public Axis getAxis(int i) { return baseGrid.getAxis(i); }
/** * 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; }
/** * Returns the label/legend of an axis. */ public String getAxisLabel(int axis) { return baseGrid.getAxis(axis).getAxisLabel(); }
@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(); }
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]);
/** * 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(); }