var a = new Base(); a.bar(); //outputs "Hello" to the console var b = new Child(); b.bar(); //outputs "World" to the console //The Base instance that is the prototype of b has the bar method changed above
@Override public void componentResized(ComponentEvent e) { if (graphics != null) { base.initBaseCoord(); graphics.projection.reset(); baseGrid.setBase(base); } repaint(); }
/** * 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(); }
/** * Create a plot canvas with the contour plot of given data. * @param z a matrix. */ public static PlotCanvas plot(double[][] z, double[] levels, Color[] palette) { double[] lowerBound = {0, 0}; double[] upperBound = {z[0].length, z.length}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new Contour(z, levels, palette)); canvas.getAxis(0).setLabelVisible(false); canvas.getAxis(1).setLabelVisible(false); return canvas; }
/** * Initialize the Graphics object. */ private void initGraphics() { if (base.dimension == 2) { graphics = new Graphics(new Projection2D(this)); } else { graphics = new Graphics(new Projection3D(this)); } }
/** * 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(); }
/** * Sets the label/legend of an axis. */ public PlotCanvas setAxisLabel(int axis, String label) { baseGrid.setAxisLabel(axis, label); repaint(); return this; }
/** * Draw poly line. The logical coordinates are proportional to the base * coordinates. */ public void drawLineBaseRatio(double[]... coord) { int[][] sc = new int[coord.length][]; for (int i = 0; i < sc.length; i++) { sc[i] = projection.screenProjectionBaseRatio(coord[i]); } drawLine(sc); }
/** * Draw poly line. The coordinates are in logical coordinates. */ public void drawLine(double[]... coord) { int[][] sc = new int[coord.length][]; for (int i = 0; i < sc.length; i++) { sc[i] = projection.screenProjection(coord[i]); } drawLine(sc); }
/** * 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; }