/** * Writes this map to a JPG file. * * @param filename the path and name of the file to create. */ public void writeToJPGFile(String filename) throws IOException { this.prepareToDraw(); BufferedImage buffImage = new BufferedImage(p.getWidth(), p.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D graphics2D = buffImage.createGraphics(); try { p.draw(graphics2D); System.out.println("Writing picture to " + filename); ImageIO.write(buffImage, "JPG", new File(filename)); } finally { graphics2D.dispose(); } }
/** * Overridden paint component method. Update the size, then repaint the plasmid * * @param g graphics object */ public void paintComponent(Graphics g) { // super.paintComponent(g); System.out.println("paint component called"); // if((previousWidth == -1 && previousHeight == -1) || (homePanel.getWidth() != previousWidth) // || (homePanel.getHeight() != previousHeight)) { super.paintComponent(g); System.out.println("calling paint component because " + previousWidth + " " + previousHeight); setSize(homePanel.getWidth(), homePanel.getHeight()); cgview.setWidth(getWidth()); cgview.setHeight(getHeight()); cgview.setBackboneRadius(Math.min(getWidth(), getHeight()) * 0.28); cgview.setTitleFont(new Font("Georgia", Font.PLAIN, 16)); // updateCgviewSize(); cgview.draw((Graphics2D) g); previousWidth = homePanel.getWidth(); previousHeight = homePanel.getHeight(); // } }