diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-08-10 06:41:51 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-08-10 06:41:51 +0000 |
commit | 8b11d455da750618fec1f0b387ca7d5a94c638c7 (patch) | |
tree | 27b3fae96e873e5a5e56e4cb199fd6077752a3a4 /collaboration | |
parent | 319920adc5a91d5c714b1ac2cb9ce926ec5e387c (diff) |
Remove the use of the intermediate file
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1156046 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'collaboration')
2 files changed, 15 insertions, 33 deletions
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramShellPlugin/src/main/java/org/apache/tuscany/sca/diagram/shell/DrawShellCommand.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramShellPlugin/src/main/java/org/apache/tuscany/sca/diagram/shell/DrawShellCommand.java index 6fb8d06fd6..7124525c92 100644 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramShellPlugin/src/main/java/org/apache/tuscany/sca/diagram/shell/DrawShellCommand.java +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramShellPlugin/src/main/java/org/apache/tuscany/sca/diagram/shell/DrawShellCommand.java @@ -19,22 +19,12 @@ package org.apache.tuscany.sca.diagram.shell;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
import jline.Completor;
import jline.NullCompletor;
import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.xml.Utils;
-import org.apache.tuscany.sca.impl.NodeImpl;
import org.apache.tuscany.sca.impl.diagram.DiagramGenerator;
-import org.apache.tuscany.sca.impl.io.XMLWriter;
import org.apache.tuscany.sca.impl.layout.CompositeEntity;
-import org.apache.tuscany.sca.impl.layout.EntityBuilder;
import org.apache.tuscany.sca.impl.layout.TuscanyCompositeEntityBuilder;
import org.apache.tuscany.sca.shell.Command;
import org.apache.tuscany.sca.shell.Shell;
@@ -70,26 +60,13 @@ public class DrawShellCommand implements Command { public boolean invoke(String[] args) throws Exception {
- NodeImpl node = (NodeImpl)shell.getNode();
- Composite composite = node.getContribution(args[0]).getArtifactModel(args[1]);
-
- //TODO: really all we want is to pass the Tuscany Composite object to the SVG drawing code,
- // but for now as that requires an XML file to the Composite to XML:
-
-// String compositeXML = Utils.modelToXML(composite, false, node.getExtensionPointRegistry());
-// DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-// Document doc = db.parse(new ByteArrayInputStream(compositeXML.getBytes()));
-// EntityBuilder eb = new EntityBuilder(doc);
-
+ Composite composite = shell.getNode().getContribution(args[0]).getArtifactModel(args[1]);
TuscanyCompositeEntityBuilder eb = new TuscanyCompositeEntityBuilder(composite);
CompositeEntity comp = eb.buildCompositeEntity();
DiagramGenerator dg = new DiagramGenerator(comp);
Document svg = dg.buildSVGDocument();
- File outFile = File.createTempFile("tmp", ".svg");
- XMLWriter writer = new XMLWriter();
- writer.fileWriter(svg, outFile);
- new SVGViewer(outFile.toURI().toURL().toString());
+ new SVGViewer(svg);
return true;
}
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramShellPlugin/src/main/java/org/apache/tuscany/sca/diagram/shell/SVGViewer.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramShellPlugin/src/main/java/org/apache/tuscany/sca/diagram/shell/SVGViewer.java index e0d3b39fa5..4eb26d9e61 100644 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramShellPlugin/src/main/java/org/apache/tuscany/sca/diagram/shell/SVGViewer.java +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramShellPlugin/src/main/java/org/apache/tuscany/sca/diagram/shell/SVGViewer.java @@ -37,20 +37,23 @@ import org.apache.batik.swing.svg.GVTTreeBuilderAdapter; import org.apache.batik.swing.svg.GVTTreeBuilderEvent;
import org.apache.batik.swing.svg.SVGDocumentLoaderAdapter;
import org.apache.batik.swing.svg.SVGDocumentLoaderEvent;
+import org.w3c.dom.Document;
public class SVGViewer {
public static void main(String[] args) {
- new SVGViewer("../CompositeDiagramGeneratorUsingBatik/output/Calculator_diagram.svg");
+// new SVGViewer("../CompositeDiagramGeneratorUsingBatik/output/Calculator_diagram.svg");
}
protected JFrame frame;
protected JLabel label = new JLabel();
protected JSVGCanvas svgCanvas = new JSVGCanvas();
protected String svgFile;
+ private Document doc;
- public SVGViewer(String svgFile) {
- this.svgFile = svgFile;
+ public SVGViewer(Document doc) {
+// this.svgFile = svgFile;
+ this.doc = doc;
this.frame = new JFrame("Batik");
frame.getContentPane().add(createComponents());
frame.addWindowListener(new WindowAdapter() {
@@ -65,11 +68,13 @@ public class SVGViewer { public JComponent createComponents() {
final JPanel panel = new JPanel(new BorderLayout());
panel.add("Center", svgCanvas);
- try {
- svgCanvas.setURI(new File(svgFile).toURI().toURL().toString());
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
+// try {
+// svgCanvas.setURI(new File(svgFile).toURI().toURL().toString());
+// } catch (MalformedURLException e) {
+// e.printStackTrace();
+// }
+
+ svgCanvas.setDocument(doc);
svgCanvas.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter() {
public void documentLoadingStarted(SVGDocumentLoaderEvent e) {
|