Пример #1
0
 // draws an image of the current map
 public void exportToPNG() {
   JFileChooser saveFileChooser = new JFileChooser();
   int returnVal = saveFileChooser.showSaveDialog(this);
   if (returnVal == JFileChooser.APPROVE_OPTION) {
     File file = saveFileChooser.getSelectedFile();
     String filename = file.getName();
     if (!filename.contains(".")) filename = file.getPath() + ".png";
     else filename = file.getPath();
     try {
       JFrame frame = new JFrame();
       mxGraphComponent graphCpnt = new mxGraphComponent(panGraph);
       frame.setContentPane(graphCpnt);
       BufferedImage bi = ScreenImage.createImage(graphCpnt);
       ScreenImage.writeImage(bi, filename);
     } catch (IOException ex) {
       Logger.getLogger(RelationMapPanel.class.getName()).log(Level.SEVERE, null, ex);
     }
   }
 }