Source Code Cross Referenced for GenSvg.java in  » UML » umlet » com » umlet » control » io » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » UML » umlet » com.umlet.control.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // The UMLet source code is distributed under the terms of the GPL; see license.txt
002:        package com.umlet.control.io;
003:
004:        import java.awt.*;
005:        import java.io.*;
006:        import java.util.*;
007:
008:        import org.apache.batik.dom.*;
009:        import org.apache.batik.svggen.*;
010:        import org.w3c.dom.*;
011:
012:        import com.umlet.control.*;
013:        import com.umlet.element.base.Entity;
014:
015:        public class GenSvg {
016:            private static GenSvg _instance;
017:
018:            public static GenSvg getInstance() {
019:                if (_instance == null) {
020:                    _instance = new GenSvg();
021:                }
022:                return _instance;
023:            }
024:
025:            public void paint(Graphics2D g2d) {
026:                /*g2d.setPaint(Color.red);
027:                g2d.fill(new Rectangle(10, 10, 100, 100));
028:                 */
029:                /*Actor a=new Actor();
030:                a.setSize(80,120);
031:                a.setState("Testactor");
032:                a.setLocation(40,150);*/
033:
034:                Vector v = Selector.getInstance().getAllEntitiesOnPanel();
035:
036:                for (int i = v.size() - 1; i >= 0; i--) {
037:                    Entity e = (Entity) v.elementAt(i);
038:                    g2d.translate(e.getX(), e.getY());
039:                    e.paint(g2d);
040:                    g2d.translate(-e.getX(), -e.getY());
041:                }
042:
043:                //Frame.IS_CLIPPING=true;
044:                //Frame.getInstance().getPanel().paint(g2d);
045:            }
046:
047:            public static void genSvg() {
048:                try {
049:                    // Get a DOMImplementation
050:                    DOMImplementation domImpl = GenericDOMImplementation
051:                            .getDOMImplementation();
052:
053:                    // Create an instance of org.w3c.dom.Document
054:                    Document document = domImpl.createDocument(null, "svg",
055:                            null);
056:
057:                    // Create an instance of the SVG Generator
058:                    SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
059:
060:                    // Ask the test to render into the SVG Graphics2D implementation
061:                    GenSvg test = new GenSvg();
062:                    test.paint(svgGenerator);
063:
064:                    // Finally, stream out SVG to the standard output using UTF-8
065:                    // character to byte encoding
066:                    boolean useCSS = true; // we want to use CSS style attribute
067:                    Writer out = new OutputStreamWriter(System.out, "UTF-8");
068:                    svgGenerator.stream(out, useCSS);
069:                } catch (IOException e) {
070:                    System.out.println("IO Exception.");
071:                }
072:            }
073:
074:            public static void createAndOutputSvgToFile(String filename) {
075:                try {
076:                    OutputStream ostream = new FileOutputStream(filename);
077:                    createSvgToStream(ostream);
078:                } catch (IOException e) {
079:                    System.out.println("IO Exception.");
080:                }
081:            }
082:
083:            public static void createSvgToStream(OutputStream ostream) {
084:                try {
085:                    // Get a DOMImplementation
086:                    DOMImplementation domImpl = GenericDOMImplementation
087:                            .getDOMImplementation();
088:
089:                    // Create an instance of org.w3c.dom.Document
090:                    Document document = domImpl.createDocument(null, "svg",
091:                            null);
092:
093:                    // Create an instance of the SVG Generator
094:                    SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
095:
096:                    // Ask the test to render into the SVG Graphics2D implementation
097:                    GenSvg test = new GenSvg();
098:                    test.paint(svgGenerator);
099:
100:                    // Finally, stream out SVG to the standard output using UTF-8
101:                    // character to byte encoding
102:                    boolean useCSS = true; // we want to use CSS style attribute
103:                    //
104:                    Writer out = new OutputStreamWriter(ostream, "UTF-8");
105:                    //Writer out = new OutputStreamWriter( new FileOutputStream(filename), "UTF-8");
106:                    //BufferedWriter bw = new BufferedWriter(
107:
108:                    svgGenerator.stream(out, useCSS);
109:                    //OutputStream ostream = new FileOutputStream("c:\\t\\out.pdf");
110:                    /*TranscoderOutput output = new TranscoderOutput(ostream);
111:                    // save the image
112:                    t.transcode(input, output);
113:                    // flush and close the stream then exit
114:                    ostream.flush();
115:                    ostream.close();*/
116:                } catch (Exception e) {
117:                    System.out.println("UMLet: Error: Exception in outputPdf: "
118:                            + e);
119:                }
120:            }
121:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.