| 406 | | |
|---|
| | 413 | |
|---|
| | 414 | JButton exportButton = new JButton ("Export Image to .eps File"); |
|---|
| | 415 | exportButton.setMnemonic(KeyEvent.VK_E); |
|---|
| | 416 | exportButton.setActionCommand("export"); |
|---|
| | 417 | |
|---|
| | 418 | exportButton.addActionListener(new ActionListener() { |
|---|
| | 419 | public void actionPerformed(ActionEvent e) { |
|---|
| | 420 | if ("export".equals(e.getActionCommand())) { |
|---|
| | 421 | int option = chooser.showSaveDialog(frame); |
|---|
| | 422 | if(option == JFileChooser.APPROVE_OPTION) { |
|---|
| | 423 | Properties properties = new Properties(); |
|---|
| | 424 | properties.setProperty("PageSize", "A5"); |
|---|
| | 425 | |
|---|
| | 426 | try { |
|---|
| | 427 | |
|---|
| | 428 | |
|---|
| | 429 | //display.saveImage(new FileOutputStream(chooser.getSelectedFile()), "eps", 1.0); |
|---|
| | 430 | |
|---|
| | 431 | |
|---|
| | 432 | //Rectangle2D bounds = visualization.getBounds(all); |
|---|
| | 433 | |
|---|
| | 434 | VectorGraphics graphics = new PSGraphics2D(chooser.getSelectedFile(), display.getSize()); |
|---|
| | 435 | graphics.setProperties(properties); |
|---|
| | 436 | graphics.startExport(); |
|---|
| | 437 | display.printAll(graphics); |
|---|
| | 438 | graphics.endExport(); |
|---|
| | 439 | } catch (FileNotFoundException e1) { |
|---|
| | 440 | // TODO Auto-generated catch block |
|---|
| | 441 | e1.printStackTrace(); |
|---|
| | 442 | } |
|---|
| | 443 | } |
|---|
| | 444 | |
|---|
| | 445 | } |
|---|
| | 446 | |
|---|
| | 447 | } |
|---|
| | 448 | |
|---|
| | 449 | }); |
|---|
| | 450 | |
|---|
| 410 | | //JPanel wrapper = new JPanel(new BorderLayout()); |
|---|
| 411 | | //wrapper.add(scrollPane, BorderLayout.CENTER); |
|---|
| 412 | | |
|---|
| 413 | | //let the given visualization layout the frame as desired |
|---|
| 414 | | this.arrangeComponents(frame, display, scrollPane); |
|---|
| 415 | | |
|---|
| | 454 | JPanel wrapper = new JPanel(new BorderLayout()); |
|---|
| | 455 | wrapper.add(exportButton, BorderLayout.NORTH); |
|---|
| | 456 | wrapper.add(scrollPane, BorderLayout.CENTER); |
|---|
| | 457 | wrapper.addKeyListener(keyAdapter); |
|---|
| | 458 | |
|---|
| | 459 | //let the given visualization layout the frame as desired |
|---|
| | 460 | // this.arrangeComponents(frame, display, scrollPane); |
|---|
| | 461 | this.arrangeComponents(frame, display, wrapper); |
|---|