/** * Set the color for title. */ public PlotCanvas setTitleColor(Color color) { this.titleColor = color; repaint(); return this; }
/** * Set the main title of canvas. */ public PlotCanvas setTitle(String title) { this.title = title; repaint(); return this; }
/** * Set the font for title. */ public PlotCanvas setTitleFont(Font font) { this.titleFont = font; repaint(); return this; }
/** * Remove a graphical shape from the canvas. */ public void remove(Shape p) { shapes.remove(p); repaint(); }
/** * Add a graphical shape to the canvas. */ public void add(Shape p) { shapes.add(p); repaint(); }
/** * Remove all graphic plots from the canvas. */ public void clear() { shapes.clear(); repaint(); }
/** * Sets the size of margin in [0.0, 0.3] on each side. Currently, all four * sides have the same margin size. * @param margin the size of margin. */ public PlotCanvas setMargin(double margin) { if (margin < 0.0 || margin >= 0.3) { throw new IllegalArgumentException("Invalid margin: " + margin); } this.margin = margin; repaint(); return this; }
/** * Sets the labels/legends of axes. */ public PlotCanvas setAxisLabels(String... labels) { baseGrid.setAxisLabel(labels); repaint(); return this; }
/** * Sets the label/legend of an axis. */ public PlotCanvas setAxisLabel(int axis, String label) { baseGrid.setAxisLabel(axis, label); repaint(); return this; }
/** * Remove a graphical shape from the canvas. */ public void remove(Plot p) { shapes.remove(p); JComponent[] tb = p.getToolBar(); if (tb != null) { for (JComponent comp : tb) { toolbar.remove(comp); } } repaint(); }
/** * Add a graphical shape to the canvas. */ public void add(Plot p) { shapes.add(p); JComponent[] tb = p.getToolBar(); if (tb != null) { toolbar.addSeparator(); for (JComponent comp : tb) { toolbar.add(comp); } } repaint(); }
/** * Extend lower bounds. */ public void extendLowerBound(double[] bound) { base.extendLowerBound(bound); baseGrid.setBase(base); repaint(); }
/** * Extend upper bounds. */ public void extendUpperBound(double[] bound) { base.extendUpperBound(bound); baseGrid.setBase(base); repaint(); }
/** * Extend lower and upper bounds. */ public void extendBound(double[] lowerBound, double[] upperBound) { base.extendBound(lowerBound, upperBound); baseGrid.setBase(base); repaint(); }
@Override public void actionPerformed(ActionEvent e) { if (margin < 0.3) { margin += 0.05; graphics.projection.reset(); repaint(); } if (margin >= 0.3) { setEnabled(false); } if (!enlargePlotAreaAction.isEnabled()) { enlargePlotAreaAction.setEnabled(true); } } }
@Override public void actionPerformed(ActionEvent e) { if (margin > 0.05) { margin -= 0.05; graphics.projection.reset(); repaint(); } if (margin <= 0.05) { setEnabled(false); } if (!shrinkPlotAreaAction.isEnabled()) { shrinkPlotAreaAction.setEnabled(true); } } }