package fortiss.gui.listeners.helper;

import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import fortiss.gui.DesignerPanel;
import memap.helper.DirectoryConfiguration;

public class WindowSnipper {

	public WindowSnipper() {
	}

	public void createTopologySnip() {
		Dimension d = DesignerPanel.pl_ems.getSize();
		BufferedImage image = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB);
		Graphics2D g2d = image.createGraphics();
		DesignerPanel.pl_ems.print(g2d);
		g2d.dispose();
		try {
			String location = System.getProperty("user.dir") + File.separator + DirectoryConfiguration.mainDir
					+ File.separator + "topology.jpg";
			ImageIO.write(image, "jpg", new File(location));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}

@@ -763,16 +763,224 @@
 y.jpg%22;%0A
+%09%09%09File file = new File(location);%0A%09%09%09%0A%09%09%09if (!file.exists()) %7B%0A%09%09%09%09try %7B%0A%09%09%09%09%09file.getParentFile().mkdirs();%0A%09%09%09%09%09file.createNewFile();%0A%09%09%09%09%7D catch (IOException e) %7B%0A%09%09%09%09%09e.printStackTrace();%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09%0A
 %09%09%09Image
@@ -1002,34 +1002,20 @@
  %22jpg%22, 
-new File(location)
+file
 );%0A%09%09%7D c

Handle directory creation when it is not present