Exemplo n.º 1
0
 protected void fileSaveXML() {
   JFileChooser chooser = null;
   if (currentFile == null) {
     chooser = new JFileChooser(startDirectory);
   } else {
     chooser = new JFileChooser(currentFile);
   }
   int returnVal = chooser.showSaveDialog(gw);
   if (returnVal == JFileChooser.APPROVE_OPTION) {
     currentFile = chooser.getSelectedFile();
     generalXML.saveGraph(currentFile);
   }
 }
Exemplo n.º 2
0
  protected void fileOpenXML() {
    JFileChooser chooser = null;
    if (currentFile == null) {
      chooser = new JFileChooser(startDirectory);
    } else {
      chooser = new JFileChooser(currentFile);
    }

    int returnVal = chooser.showOpenDialog(gw);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      currentFile = chooser.getSelectedFile();
      generalXML.loadGraph(currentFile);
    }
    gp.update(gp.getGraphics());
  }
Exemplo n.º 3
0
 protected void fileSaveSimple() {
   JFileChooser chooser = null;
   if (currentFile == null) {
     chooser = new JFileChooser(startDirectory);
   } else {
     chooser = new JFileChooser(currentFile);
     if (!currentFile.isDirectory()) {
       chooser.setSelectedFile(currentFile);
     }
   }
   int returnVal = chooser.showSaveDialog(gw);
   if (returnVal == JFileChooser.APPROVE_OPTION) {
     currentFile = chooser.getSelectedFile();
     graph.saveSimple(currentFile);
   }
 }
Exemplo n.º 4
0
  protected void filePNG() {

    JFileChooser chooser = null;
    File pngFile = null;
    if (currentFile == null) {
      chooser = new JFileChooser(startDirectory);
    } else {
      pngFile = new File(currentFile.getName() + ".png");
      chooser = new JFileChooser(pngFile);
      if (!currentFile.isDirectory()) {
        chooser.setSelectedFile(currentFile);
      }
    }

    if (pngFile == null) return;
    try {
      BufferedImage image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
      paint(image.getGraphics());
      ImageIO.write(image, "png", pngFile);
    } catch (Exception e) {
    }
    return;
    /*		JFileChooser chooser = null;
    		File pngFile = null;
    		if (currentFile == null) {
    			chooser = new JFileChooser(startDirectory);
    		} else {
    			pngFile = new File(currentFile.getName()+".png");
    			chooser = new JFileChooser(pngFile);
    			if (!currentFile.isDirectory()) {
    				chooser.setSelectedFile(currentFile);
    			}
    		}
    		int returnVal = chooser.showSaveDialog(gw);
    		if (returnVal == JFileChooser.APPROVE_OPTION) {
    			File pngFile = chooser.getSelectedFile();

    			int maxX = Integer.MIN_VALUE;
    			int minX = Integer.MAX_VALUE;
    			int maxY = Integer.MIN_VALUE;
    			int minY = Integer.MAX_VALUE;

    			while(Node node : getNodes()) {
    				if(node.getX() > maxX) {
    					maxX = node.getX();
    				}
    				if(node.getX() < minX) {
    					minX = node.getX();
    				}
    				if(node.getY() > maxY) {
    					maxY = node.getY();
    				}
    				if(node.getY() < minY) {
    					minY = node.getY();
    				}
    			}

    			BufferedImage image = new BufferedImage(maxX-minX+50,maxY-minY+50,BufferedImage.TYPE_INT_RGB);



    			ImageIO.write(image,"png",pngFile);
    		}
    */ }