/** * Draws the axes in the drawing panel. * * @param panel * @param g */ public void draw(DrawingPanel panel, Graphics g) { if (!visible) { return; } if (interiorColor != null) { g.setColor(interiorColor); int gw = panel.getLeftGutter() + panel.getRightGutter(); int gh = panel.getTopGutter() + panel.getBottomGutter(); g.fillRect( panel.getLeftGutter(), panel.getTopGutter(), panel.getWidth() - gw, panel.getHeight() - gh); g.setColor(Color.lightGray); g.drawRect( panel.getLeftGutter(), panel.getTopGutter(), panel.getWidth() - gw, panel.getHeight() - gh); } xaxis.draw(panel, g); yaxis.draw(panel, g); titleLine.setX((panel.getXMax() + panel.getXMin()) / 2); if (panel.getTopGutter() > 20) { titleLine.setY(panel.getYMax() + 5 / panel.getYPixPerUnit()); } else { titleLine.setY(panel.getYMax() - 25 / panel.getYPixPerUnit()); } titleLine.draw(panel, g); }
/** * Draws the image and the grid. * * @param panel * @param g */ public void draw(DrawingPanel panel, Graphics g) { if (scaleFactor < 1) { g.drawImage( image.getScaledInstance( (int) (scaleFactor * image.getWidth()), (int) (scaleFactor * image.getHeight()), java.awt.Image.SCALE_REPLICATE), panel.getLeftGutter(), panel.getTopGutter(), panel); } else { // g.drawImage(image, 1+panel.xToPix(xmin), 1+panel.yToPix(ymax), panel); g.drawImage(image, panel.getLeftGutter(), panel.getTopGutter(), panel); } }