Exemplo n.º 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);
     }
   }
 }
Exemplo n.º 2
0
  public TestFrame() {
    super("Control Window");
    setLayout(new BorderLayout());
    setSize(400, 300);
    setLocation(500, 10);
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    panel = new JPanel();
    getContentPane().add(panel, BorderLayout.NORTH);
    makeSHButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            makeSHButtonActionPerformed(e);
          }
        });
    panel.add(makeSHButton);

    JButton graphButton = new JButton("morph");
    graphButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            graphButtonActionPerformed(evt);
          }
        });
    panel.add(graphButton);

    pushAllSHButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            pushAllSHButtonActionPerformed(e);
          }
        });
    panel.add(pushAllSHButton);

    makeRelationsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            makeRelationsButtonActionPerformed(e);
          }
        });
    panel.add(makeRelationsButton);

    panel.setPreferredSize(new java.awt.Dimension(20, 80));
    panel.setBorder(new LineBorder(Color.black));
    JFrame frame = new JFrame("Relationship Frame");
    frame.setSize(500, 500);
    frame.setLocation(10, 10);
    frame.getContentPane().add(testPanel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }