01: // The UMLet source code is distributed under the terms of the GPL; see license.txt
02: /*
03: * Created on 18.02.2004
04: *
05: * To change the template for this generated file go to
06: * Window>Preferences>Java>Code Generation>Code and Comments
07: */
08: package com.umlet.control.io;
09:
10: import java.awt.*;
11: import java.io.*;
12: import java.util.*;
13: import org.jibble.epsgraphics.*;
14: import com.umlet.control.*;
15: import com.umlet.element.base.Entity;
16:
17: public class GenEps {
18: private static GenEps _instance;
19:
20: public static GenEps getInstance() {
21: if (_instance == null) {
22: _instance = new GenEps();
23: }
24: return _instance;
25: }
26:
27: private GenEps() {
28: }
29:
30: public void paint(Graphics2D g2d) { //perform drawing operations
31: Vector v = Selector.getInstance().getAllEntitiesOnPanel();
32: for (int i = v.size() - 1; i >= 0; i--) {
33: Entity e = (Entity) v.elementAt(i);
34: g2d.translate(e.getX(), e.getY());
35: e.paint(g2d);
36: g2d.translate(-e.getX(), -e.getY());
37: }
38: }
39:
40: public void createAndOutputEPSToFile(String filename) {
41: try {
42: OutputStream ostream = new FileOutputStream(filename);
43: createEpsToStream(ostream);
44: } catch (Exception e) {
45: System.out.println("IO Exception.");
46: }
47: }
48:
49: public void createEpsToStream(OutputStream outputStream) { //create and write stream to file
50: try {
51: PrintWriter bw = new PrintWriter(outputStream);
52: EpsGraphics2D g = new EpsGraphics2D("umlet_diagram");
53: paint(g);
54: bw.print(g.toString());
55: bw.flush();
56: bw.close();
57: } catch (Exception fnfe) {
58: System.out
59: .println("UMLet: Error: Exception in createEpsToStream: "
60: + fnfe);
61: }
62: }
63: }
|