Author: objectiser
Date: 2010-08-05 10:58:07 -0400 (Thu, 05 Aug 2010)
New Revision: 903
Added:
trunk/console/bpel2svg/src/main/java/org/jboss/
trunk/console/bpel2svg/src/main/java/org/jboss/soa/
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/BPEL2SVGUtil.java
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/SVGImageTransformer.java
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/SVGToJPEGImageTransformer.java
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/SVGToPNGImageTransformer.java
Modified:
trunk/console/bpel2svg/
trunk/console/bpel2svg/pom.xml
trunk/console/bpel2svg/src/main/java/org/wso2/carbon/bpel/ui/bpel2svg/SVGInterface.java
trunk/console/pom.xml
trunk/pom.xml
Log:
RIFTSAW-92 - further work to integrate the BPEL to SVG generation.
Property changes on: trunk/console/bpel2svg
___________________________________________________________________
Name: svn:ignore
- target
+ target
.classpath
.project
.settings
Modified: trunk/console/bpel2svg/pom.xml
===================================================================
--- trunk/console/bpel2svg/pom.xml 2010-08-04 15:48:21 UTC (rev 902)
+++ trunk/console/bpel2svg/pom.xml 2010-08-05 14:58:07 UTC (rev 903)
@@ -36,6 +36,11 @@
</dependency>
<dependency>
<groupId>batik</groupId>
+ <artifactId>batik-svggen</artifactId>
+ <version>${batik.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>batik</groupId>
<artifactId>batik-util</artifactId>
<version>${batik.version}</version>
</dependency>
@@ -85,10 +90,25 @@
<version>${batik.version}</version>
</dependency>
<dependency>
+ <groupId>batik</groupId>
+ <artifactId>batik-anim</artifactId>
+ <version>${batik.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>batik</groupId>
+ <artifactId>batik-codec</artifactId>
+ <version>${batik.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
- <artifactId>axiom</artifactId>
+ <artifactId>axiom-impl</artifactId>
<version>${axiom.version}</version>
</dependency>
+ <dependency>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis-ext</artifactId>
+ <version>1.3.04</version>
+ </dependency>
<!--
<dependency>
<groupId>xerces</groupId>
Added: trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/BPEL2SVGUtil.java
===================================================================
--- trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/BPEL2SVGUtil.java
(rev 0)
+++
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/BPEL2SVGUtil.java 2010-08-05
14:58:07 UTC (rev 903)
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Portions licensed by WSO2, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.jboss.soa.bpel.bpel2svg;
+
+import org.apache.axiom.om.OMElement;
+import org.wso2.carbon.bpel.ui.bpel2svg.*;
+import org.wso2.carbon.bpel.ui.bpel2svg.impl.BPELImpl;
+import org.wso2.carbon.bpel.ui.bpel2svg.impl.SVGImpl;
+
+/**
+ * This class provides the utility for converting a BPEL process description
+ * into a SVG format, which can then optionally be transformed into a range of
+ * alternative supported image types.
+ *
+ */
+public class BPEL2SVGUtil {
+
+ private static final String JPEG_IMAGE = "jpeg";
+ private static final String PNG_IMAGE = "png";
+ private static java.util.Map<String, SVGImageTransformer> m_transformers=
+ new java.util.HashMap<String, SVGImageTransformer>();
+
+ static {
+ m_transformers.put(PNG_IMAGE, new SVGToPNGImageTransformer());
+ m_transformers.put(JPEG_IMAGE, new SVGToJPEGImageTransformer());
+ }
+
+ public static void main(String[] args) {
+ if (args.length < 2 || args.length > 3) {
+ System.err.println("Usage: BPEL2SVGUtil <bpelFile> <outputFile> [
<transformType> ]");
+ System.err.println("(transformerType values are:
"+PNG_IMAGE+","+JPEG_IMAGE+")");
+ System.exit(1);
+ }
+
+ SVGImageTransformer transformer=null;
+
+ if (args.length == 3) {
+ transformer = BPEL2SVGUtil.getTransformer(args[2]);
+
+ if (transformer == null) {
+ System.err.println("Unknown transformerType '"+args[2]+
+ "', valid values are: "+PNG_IMAGE+","+JPEG_IMAGE);
+ System.exit(1);
+ }
+ }
+
+ try {
+ java.io.FileInputStream fis=new java.io.FileInputStream(args[0]);
+
+ java.io.FileOutputStream os=new java.io.FileOutputStream(args[1]);
+
+ BPEL2SVGUtil.generate(fis, os, transformer);
+
+ fis.close();
+ os.close();
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * This method generates a SVG representation of a supplied BPEL description,
+ * and optionally transforms it into an image format. If an image
+ * transformer is not specified, then the SVG representation will be
+ * returned in the output stream.
+ *
+ * @param is The textual representation of a BPEL description
+ * @param os The output stream for the SVG or image representation
+ * @param transformer The optional image transformer
+ * @throws java.io.IOException Failed to generate the representation
+ */
+ public static void generate(java.io.InputStream is, java.io.OutputStream os,
+ SVGImageTransformer transformer) throws java.io.IOException {
+
+ byte[] b=new byte[is.available()];
+ is.read(b);
+
+ BPELInterface bpel = new BPELImpl();
+ OMElement bpelStr = bpel.load(new String(b));
+
+ bpel.processBpelString(bpelStr);
+
+ LayoutManager layoutManager = BPEL2SVGFactory.getInstance().getLayoutManager();
+ layoutManager.setVerticalLayout(true);
+ layoutManager.layoutSVG(bpel.getRootActivity());
+
+ SVGImpl svg = new SVGImpl();
+ svg.setRootActivity(bpel.getRootActivity());
+
+ if (transformer == null) {
+ String str=svg.getHeaders()+svg.generateSVGString();
+ os.write(str.getBytes());
+ } else {
+ transformer.transform(svg, os);
+ }
+ }
+
+ /**
+ * This method returns the SVG image transformer associated with the
+ * supplied code.
+ *
+ * @param code The image transformer code
+ * @return The transformer, or null if not found
+ */
+ public static SVGImageTransformer getTransformer(String code) {
+ return(m_transformers.get(code));
+ }
+}
Added:
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/SVGImageTransformer.java
===================================================================
---
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/SVGImageTransformer.java
(rev 0)
+++
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/SVGImageTransformer.java 2010-08-05
14:58:07 UTC (rev 903)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Portions licensed by WSO2, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.jboss.soa.bpel.bpel2svg;
+
+import java.io.IOException;
+
+/**
+ * This interface represents a transformer from the SVG document object model
+ * to an output stream representing the image to be displayed.
+ *
+ */
+public interface SVGImageTransformer {
+
+ /**
+ * This method transforms a supplied SVG document into an image written
+ * to the supplied output stream.
+ *
+ * @param svg The SVG document
+ * @param os The output stream
+ * @throws IOException Failed to transform the SVG doc into an image
+ */
+ public void transform(org.wso2.carbon.bpel.ui.bpel2svg.SVGInterface svg,
+ java.io.OutputStream os) throws IOException;
+
+}
Added:
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/SVGToJPEGImageTransformer.java
===================================================================
---
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/SVGToJPEGImageTransformer.java
(rev 0)
+++
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/SVGToJPEGImageTransformer.java 2010-08-05
14:58:07 UTC (rev 903)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Portions licensed by WSO2, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.jboss.soa.bpel.bpel2svg;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.apache.batik.transcoder.TranscoderException;
+import org.apache.batik.transcoder.TranscoderInput;
+import org.apache.batik.transcoder.TranscoderOutput;
+import org.apache.batik.transcoder.image.JPEGTranscoder;
+
+/**
+ * This class represents the transformer from the SVG document object model
+ * to an output stream representing the image to be displayed.
+ *
+ */
+public class SVGToJPEGImageTransformer implements SVGImageTransformer {
+
+ /**
+ * This method transforms a supplied SVG document into an image written
+ * to the supplied output stream.
+ *
+ * @param svg The SVG document
+ * @param os The output stream
+ * @throws IOException Failed to transform the SVG doc into an image
+ */
+ public void transform(org.wso2.carbon.bpel.ui.bpel2svg.SVGInterface svg,
+ java.io.OutputStream os) throws IOException {
+ // Create a JPEG transcoder
+ JPEGTranscoder jpegTranscoder = new JPEGTranscoder();
+ // Set the transcoding hints.
+ jpegTranscoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(0.8));
+ // Create the transcoder input.
+ String inputString = svg.getHeaders() + svg.generateSVGString();
+
+ Reader stringReader = new StringReader(inputString);
+ TranscoderInput transcoderInput2 = new TranscoderInput(stringReader);
+
+ TranscoderOutput transcoderOutput = new TranscoderOutput(os);
+ try {
+ jpegTranscoder.transcode(transcoderInput2, transcoderOutput);
+ } catch (TranscoderException e) {
+ throw new IOException("Transcoder error", e);
+ }
+ }
+
+}
Added:
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/SVGToPNGImageTransformer.java
===================================================================
---
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/SVGToPNGImageTransformer.java
(rev 0)
+++
trunk/console/bpel2svg/src/main/java/org/jboss/soa/bpel/bpel2svg/SVGToPNGImageTransformer.java 2010-08-05
14:58:07 UTC (rev 903)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Portions licensed by WSO2, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.jboss.soa.bpel.bpel2svg;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.apache.batik.transcoder.TranscoderException;
+import org.apache.batik.transcoder.TranscoderInput;
+import org.apache.batik.transcoder.TranscoderOutput;
+import org.apache.batik.transcoder.image.PNGTranscoder;
+
+/**
+ * This class represents the transformer from the SVG document object model
+ * to an output stream representing the image to be displayed.
+ *
+ */
+public class SVGToPNGImageTransformer implements SVGImageTransformer {
+
+ /**
+ * This method transforms a supplied SVG document into an image written
+ * to the supplied output stream.
+ *
+ * @param svg The SVG document
+ * @param os The output stream
+ * @throws IOException Failed to transform the SVG doc into an image
+ */
+ public void transform(org.wso2.carbon.bpel.ui.bpel2svg.SVGInterface svg,
+ java.io.OutputStream os) throws IOException {
+ // Create a PNG transcoder
+ PNGTranscoder pngTranscoder = new PNGTranscoder();
+
+ // Create the transcoder input.
+ String inputString = svg.getHeaders() + svg.generateSVGString();
+
+ //SVGDocument svgDoc = svg.getRootActivity().getSVGDocument();
+
+ //TranscoderInput transcoderInput = new TranscoderInput(svgDoc);
+ Reader stringReader = new StringReader(inputString);
+ TranscoderInput transcoderInput = new TranscoderInput(stringReader);
+
+ // Create the transcoder output.
+ TranscoderOutput transcoderOutput = new TranscoderOutput(os);
+ try {
+ pngTranscoder.transcode(transcoderInput, transcoderOutput);
+ } catch (TranscoderException e) {
+ throw new IOException("Transcoder error", e);
+ }
+ }
+
+}
Modified:
trunk/console/bpel2svg/src/main/java/org/wso2/carbon/bpel/ui/bpel2svg/SVGInterface.java
===================================================================
---
trunk/console/bpel2svg/src/main/java/org/wso2/carbon/bpel/ui/bpel2svg/SVGInterface.java 2010-08-04
15:48:21 UTC (rev 902)
+++
trunk/console/bpel2svg/src/main/java/org/wso2/carbon/bpel/ui/bpel2svg/SVGInterface.java 2010-08-05
14:58:07 UTC (rev 903)
@@ -17,4 +17,6 @@
public byte[] toPNGBytes();
+ public String getHeaders();
+
}
Modified: trunk/console/pom.xml
===================================================================
--- trunk/console/pom.xml 2010-08-04 15:48:21 UTC (rev 902)
+++ trunk/console/pom.xml 2010-08-05 14:58:07 UTC (rev 903)
@@ -18,7 +18,7 @@
<modules>
<module>integration</module>
<module>identity</module>
- <!--module>bpel2svg</module-->
+ <module>bpel2svg</module>
</modules>
</project>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-08-04 15:48:21 UTC (rev 902)
+++ trunk/pom.xml 2010-08-05 14:58:07 UTC (rev 903)
@@ -92,8 +92,8 @@
<cxf.version>2.2.6</cxf.version>
<saxon.version>9.1.0.8</saxon.version>
<spring.version>2.5.6.SEC01</spring.version> <!-- This version must
match the version used by the ESB -->
- <batik.version>1.6</batik.version>
- <axiom.version>1.2.5</axiom.version>
+ <batik.version>1.7</batik.version>
+ <axiom.version>1.2.8</axiom.version>
<commons.codec.version>1.4</commons.codec.version>
</properties>