Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2013-11-05 09:22:39 -0500
committerCamille Letavernier2013-11-05 12:40:38 -0500
commitde96c1c4072efb59679f2d80e5f046359454c800 (patch)
tree56b7b15d064a76f567b749993c58aa9ba727e712 /plugins
parent391a97ee66d460e113b7c19a3e4e72213e584f5f (diff)
downloadorg.eclipse.papyrus-de96c1c4072efb59679f2d80e5f046359454c800.tar.gz
org.eclipse.papyrus-de96c1c4072efb59679f2d80e5f046359454c800.tar.xz
org.eclipse.papyrus-de96c1c4072efb59679f2d80e5f046359454c800.zip
421099: [All Diagrams - Symbols] Papyrus shall support dynamic
expressions in SVG Shapes https://bugs.eclipse.org/bugs/show_bug.cgi?id=421099
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.classpath2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF12
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml1
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/schema/svgPostProcessors.exsd102
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/NodeEditPart.java53
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/BorderedScalableImageFigure.java36
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/SVGNodePlateFigure.java198
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/AbstractShapeProvider.java53
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/GetSVGDocumentForViewOperation.java9
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/IShapeProvider.java6
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/SVGPostProcessor.java47
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/SVGPostProcessorImpl.java66
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java24
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/.classpath2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/META-INF/MANIFEST.MF9
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/ActorShapeProvider.java45
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/StereotypedElementShapeProvider.java63
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/TypedElementShapeProvider.java80
20 files changed, 587 insertions, 234 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.classpath b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.classpath
index 2d1a4302f04..8a8f1668cdc 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.classpath
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..f287d53cf45
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
index d3d69b1c721..0af5873c0fb 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
@@ -20,7 +20,7 @@ Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Bundle-Name: %pluginName
Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.emf.edit.ui;bundle-version="2.5.0",
org.eclipse.emf.ecore.edit;bundle-version="2.5.0",
org.eclipse.papyrus.infra.core;bundle-version="0.10.1",
@@ -46,12 +46,12 @@ Require-Bundle: org.eclipse.emf.edit.ui;bundle-version="2.5.0",
org.eclipse.gmf.runtime.draw2d.ui.render;bundle-version="1.4.1",
org.eclipse.core.expressions,
org.eclipse.papyrus.uml.tools;bundle-version="0.10.1",
- org.apache.batik.dom.svg,
- org.apache.batik.util,
- org.apache.batik.svggen,
- org.apache.batik.dom,
+ org.apache.batik.util;bundle-version="[1.6.0,1.7.0)",
+ org.apache.batik.svggen;bundle-version="[1.6.0,1.7.0)",
org.w3c.dom.svg,
- org.apache.batik.css
+ org.apache.batik.dom.svg;bundle-version="[1.6.0,1.7.0)",
+ org.apache.batik.dom;bundle-version="1.6.0",
+ org.apache.batik.xml;bundle-version="[1.6.0,1.7.0)"
Bundle-Vendor: %providerName
Bundle-Version: 0.10.1.qualifier
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
index c20846643c8..af729be666e 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
@@ -6,6 +6,7 @@
<extension-point id="initializeView" name="initializeView" schema="schema/initializeView.exsd"/>
<extension-point id="shapeProvider" name="ShapeProvider" schema="schema/shapeProvider.exsd"/>
<extension-point id="notationTypesMapping" name="notationTypesMapping" schema="schema/notationTypesMapping.exsd"/>
+ <extension-point id="svgPostProcessors" name="svgPostProcessors" schema="schema/svgPostProcessors.exsd"/>
<extension
point="org.eclipse.papyrus.infra.core.papyrusDiagram">
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/schema/svgPostProcessors.exsd b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/schema/svgPostProcessors.exsd
new file mode 100644
index 00000000000..06ab7e9421e
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/schema/svgPostProcessors.exsd
@@ -0,0 +1,102 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.infra.gmfdiag.common" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.papyrus.infra.gmfdiag.common" id="svgPostProcessors" name="svgPostProcessors"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="postProcessor"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="postProcessor">
+ <complexType>
+ <attribute name="implementation" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.gmfdiag.common.service.shape.SVGPostProcessor"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/NodeEditPart.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/NodeEditPart.java
index 01ed696dd85..b6c93841b1f 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/NodeEditPart.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/NodeEditPart.java
@@ -14,7 +14,8 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.editpart;
-import org.apache.batik.dom.svg.SVGOMDocument;
+import java.util.List;
+
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.StackLayout;
import org.eclipse.emf.common.notify.Notification;
@@ -32,18 +33,21 @@ import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure;
import org.eclipse.papyrus.infra.gmfdiag.common.service.shape.ShapeService;
import org.eclipse.swt.graphics.Color;
+import org.w3c.dom.svg.SVGDocument;
/**
- * this edit part can refresh shadow and gradient.
+ * this edit part can refresh shadow and gradient.
*/
public abstract class NodeEditPart extends AbstractBorderedShapeEditPart implements IPapyrusEditPart {
private SVGNodePlateFigure svgNodePlate;
+
protected IFigure shape;
+
/**
*
* Constructor.
- *
+ *
* @param view
*/
public NodeEditPart(View view) {
@@ -58,28 +62,24 @@ public abstract class NodeEditPart extends AbstractBorderedShapeEditPart impleme
return createNodeFigure();
}
- protected void refreshSVGPath(){
+ protected void refreshSVGPath() {
View view = getNotationView();
- if( svgNodePlate!=null){
+ if(svgNodePlate != null) {
BooleanValueStyle followStyle = (BooleanValueStyle)view.getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), FollowSVGSymbolEditPolicy.FOLLOW_SVG_SYMBOL);
if(followStyle != null && followStyle.isBooleanValue()) {
- if(ShapeService.getInstance().hasShapeToDisplay(getNotationView())){
- int DocumentNumber=ShapeService.getInstance().getSVGDocumentToDisplay(getNotationView()).size();
- SVGOMDocument svgdoc=null;
- if( DocumentNumber>1){
- svgdoc=ShapeService.getInstance().getSVGDocumentToDisplay(getNotationView()).get(DocumentNumber-1);
- }
- else if(DocumentNumber==1 ){
- svgdoc=ShapeService.getInstance().getSVGDocumentToDisplay(getNotationView()).get(0);
+ if(ShapeService.getInstance().hasShapeToDisplay(getNotationView())) {
+ List<SVGDocument> svgToDisplay = ShapeService.getInstance().getSVGDocumentToDisplay(getNotationView());
+ int documentNumber = svgToDisplay.size();
+ SVGDocument svgdoc = null;
+ if(documentNumber > 0) {
+ svgdoc = svgToDisplay.get(documentNumber - 1);
}
svgNodePlate.setSVGDocument(svgdoc);
- }
- else{
+ } else {
svgNodePlate.setSVGDocument(null);
}
- }
- else{
+ } else {
svgNodePlate.setSVGDocument(null);
}
}
@@ -220,19 +220,22 @@ public abstract class NodeEditPart extends AbstractBorderedShapeEditPart impleme
super.createDefaultEditPolicies();
installEditPolicy(BorderDisplayEditPolicy.BORDER_DISPLAY_EDITPOLICY, new BorderDisplayEditPolicy());
}
+
/**
*
* @return the figure that represent the shape, this class is generated by the GMF tooling
*/
- protected abstract IFigure createNodePlate();
+ protected abstract IFigure createNodePlate();
+
/**
*
* @return the figure that represent the shape, this class is generated by the GMF tooling
*/
- protected abstract IFigure createNodeShape();
+ protected abstract IFigure createNodeShape();
/**
* this method installs the content pane in the node shape to add compartment for example
+ *
* @param nodeShape
* @return the figure that is the the node shape
*/
@@ -242,13 +245,14 @@ public abstract class NodeEditPart extends AbstractBorderedShapeEditPart impleme
/**
* Now the method create node plate is not used,
* If you want to overlad it you must overload createSVGNodePlate
+ *
* @return the figure that allow following border of shape
*/
protected NodeFigure createSVGNodePlate() {
- svgNodePlate= new SVGNodePlateFigure(-1, -1);
+ svgNodePlate = new SVGNodePlateFigure(-1, -1);
svgNodePlate.setDefaultNodePlate(createNodePlate());
- return svgNodePlate;
+ return svgNodePlate;
}
/**
@@ -271,11 +275,10 @@ public abstract class NodeEditPart extends AbstractBorderedShapeEditPart impleme
@Override
public IFigure getContentPane() {
- if( shape!=null){
- IFigure contentPane=setupContentPane(shape);
+ if(shape != null) {
+ IFigure contentPane = setupContentPane(shape);
return contentPane;
- }
- else {
+ } else {
return super.getContentPane();
}
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/BorderedScalableImageFigure.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/BorderedScalableImageFigure.java
index 19c2f14ce6b..865dbf006a3 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/BorderedScalableImageFigure.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/BorderedScalableImageFigure.java
@@ -1,24 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.figure.node;
-import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.gmf.runtime.draw2d.ui.render.RenderedImage;
import org.eclipse.gmf.runtime.draw2d.ui.render.figures.ScalableImageFigure;
/**
- * Scalable Image figure that will be aligned in the middle/center and keep its own ratio.
+ * Scalable Image figure that will be aligned in the middle/center and keep its own ratio.
*
- * It is also used to serve as specific implementation in Papyrus, as debug items can be easily added.
+ * It is also used to serve as specific implementation in Papyrus, as debug items can be easily added.
*/
public class BorderedScalableImageFigure extends ScalableImageFigure {
- public BorderedScalableImageFigure(RenderedImage renderedImage, boolean useDefaultImageSize, boolean useOriginalColors, boolean antiAlias) {
- super(renderedImage, useDefaultImageSize, useOriginalColors, antiAlias);
- //setBorder(new LineBorder(ColorConstants.red, 2));
- setAlignment(PositionConstants.CENTER|PositionConstants.MIDDLE);
- setMaintainAspectRatio(true);
- //setBackgroundColor(ColorConstants.green);
- //setForegroundColor(ColorConstants.red);
- }
-
+ public BorderedScalableImageFigure(RenderedImage renderedImage, boolean useDefaultImageSize, boolean useOriginalColors, boolean antiAlias) {
+ super(renderedImage, useDefaultImageSize, useOriginalColors, antiAlias);
+ //setBorder(new LineBorder(ColorConstants.red, 2));
+ setAlignment(PositionConstants.CENTER | PositionConstants.MIDDLE);
+ setMaintainAspectRatio(true);
+ //setBackgroundColor(ColorConstants.green);
+ //setForegroundColor(ColorConstants.red);
}
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/SVGNodePlateFigure.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/SVGNodePlateFigure.java
index ac9fa7590b9..8f5725d5e72 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/SVGNodePlateFigure.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/SVGNodePlateFigure.java
@@ -15,17 +15,16 @@ package org.eclipse.papyrus.infra.gmfdiag.common.figure.node;
import java.util.ArrayList;
import org.apache.batik.dom.svg.AbstractSVGPathSegList.SVGPathSegMovetoLinetoItem;
-import org.apache.batik.dom.svg.SVGOMPathElement;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.PrecisionPoint;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.ScalableCompartmentFigure;
import org.w3c.dom.Element;
import org.w3c.dom.svg.SVGAnimatedLength;
import org.w3c.dom.svg.SVGDocument;
import org.w3c.dom.svg.SVGLength;
+import org.w3c.dom.svg.SVGPathElement;
import org.w3c.dom.svg.SVGPathSeg;
import org.w3c.dom.svg.SVGPathSegList;
import org.w3c.dom.svg.SVGSVGElement;
@@ -37,41 +36,45 @@ import org.w3c.dom.svg.SVGSVGElement;
*/
public class SVGNodePlateFigure extends DefaultSizeNodeFigure {
- protected SVGPathSegList pathSegList=null;
- protected SVGDocument svgDocument=null;
+ protected SVGPathSegList pathSegList = null;
+
+ protected SVGDocument svgDocument = null;
+
protected DefaultSizeNodeFigure defaultNodePlate;
/**
* associate the SVG document that represent the SVG
- * @param svgDocument the SVG document
+ *
+ * @param svgDocument
+ * the SVG document
*/
public void setSVGDocument(SVGDocument svgDocument) {
- if(svgDocument==null){
+ if(svgDocument == null) {
this.svgDocument = null;
- this.pathSegList=null;
- }
- else{
+ this.pathSegList = null;
+ } else {
this.svgDocument = svgDocument;
- Element path=svgDocument.getElementById("PapyrusPath");
- if( path!=null){
- SVGOMPathElement svgPath=(SVGOMPathElement)path;
- SVGPathSegList segmentList=svgPath.getPathSegList();
+ Element path = svgDocument.getElementById("PapyrusPath");
+ if(path != null) {
+ SVGPathElement svgPath = (SVGPathElement)path;
+ SVGPathSegList segmentList = svgPath.getPathSegList();
this.setSegemntList(segmentList);
}
}
}
-
+
/**
* set the node plate that is wrapped by it.
+ *
* @param defaultNodePlate
*/
- public void setDefaultNodePlate(IFigure defaultNodePlate){
- if( defaultNodePlate instanceof DefaultSizeNodeFigure){
- this.defaultNodePlate=(DefaultSizeNodeFigure)defaultNodePlate;
+ public void setDefaultNodePlate(IFigure defaultNodePlate) {
+ if(defaultNodePlate instanceof DefaultSizeNodeFigure) {
+ this.defaultNodePlate = (DefaultSizeNodeFigure)defaultNodePlate;
this.setDefaultSize(((DefaultSizeNodeFigure)defaultNodePlate).getDefaultSize());
}
- if( defaultNodePlate instanceof ICustomNodePlate){
+ if(defaultNodePlate instanceof ICustomNodePlate) {
((ICustomNodePlate)this.defaultNodePlate).setSVGNodePlateContainer(this);
}
}
@@ -79,27 +82,29 @@ public class SVGNodePlateFigure extends DefaultSizeNodeFigure {
/**
*
* Constructor.
- *
+ *
* @param width
* @param height
*/
public SVGNodePlateFigure(int width, int height) {
super(width, height);
}
+
/**
* set the papyrus path to follow the shape
+ *
* @param pathSegList
*/
- public void setSegemntList(SVGPathSegList pathSegList ){
- this.pathSegList= pathSegList;
+ public void setSegemntList(SVGPathSegList pathSegList) {
+ this.pathSegList = pathSegList;
}
- public boolean containShapeCompatment(){
- if( this.getChildren().size()>0&& this.getChildren().get(0) instanceof IFigure){
- IFigure primaryShape= (IFigure)this.getChildren().get(0);
+ public boolean containShapeCompatment() {
+ if(this.getChildren().size() > 0 && this.getChildren().get(0) instanceof IFigure) {
+ IFigure primaryShape = (IFigure)this.getChildren().get(0);
for(Object subFigure : primaryShape.getChildren()) {
- if(subFigure instanceof ScalableCompartmentFigure ){
+ if(subFigure instanceof ScalableCompartmentFigure) {
return true;
}
}
@@ -107,11 +112,11 @@ public class SVGNodePlateFigure extends DefaultSizeNodeFigure {
return false;
}
- public IFigure getShapeCompatment(){
- if( this.getChildren().size()>0&& this.getChildren().get(0) instanceof IFigure){
- IFigure primaryShape= (IFigure)this.getChildren().get(0);
+ public IFigure getShapeCompatment() {
+ if(this.getChildren().size() > 0 && this.getChildren().get(0) instanceof IFigure) {
+ IFigure primaryShape = (IFigure)this.getChildren().get(0);
for(Object subFigure : primaryShape.getChildren()) {
- if(subFigure instanceof ScalableCompartmentFigure ){
+ if(subFigure instanceof ScalableCompartmentFigure) {
return (IFigure)subFigure;
}
}
@@ -123,26 +128,26 @@ public class SVGNodePlateFigure extends DefaultSizeNodeFigure {
// This returns as the anchoring area only the central line
@Override
public PointList getPolygonPoints() {
- if (this.pathSegList==null){
- if (defaultNodePlate!=null){
+ if(this.pathSegList == null) {
+ if(defaultNodePlate != null) {
defaultNodePlate.setBounds(this.getBounds());
return defaultNodePlate.getPolygonPoints();
}
return super.getPolygonPoints();
}
- double svgWidth=0;
- double svgHeight=0;
- SVGSVGElement svgElement=svgDocument.getRootElement();
- if(svgElement!=null ){
- SVGAnimatedLength widthALength=svgElement.getWidth();
- SVGAnimatedLength heightALength=svgElement.getHeight();
- if( widthALength!=null &&heightALength!=null){
- SVGLength svgWidthLength =widthALength.getBaseVal();
- SVGLength svgHeightLength =heightALength.getBaseVal();
- if( svgWidthLength!=null &&svgHeightLength!=null){
+ double svgWidth = 0;
+ double svgHeight = 0;
+ SVGSVGElement svgElement = svgDocument.getRootElement();
+ if(svgElement != null) {
+ SVGAnimatedLength widthALength = svgElement.getWidth();
+ SVGAnimatedLength heightALength = svgElement.getHeight();
+ if(widthALength != null && heightALength != null) {
+ SVGLength svgWidthLength = widthALength.getBaseVal();
+ SVGLength svgHeightLength = heightALength.getBaseVal();
+ if(svgWidthLength != null && svgHeightLength != null) {
// if( width.getUnitType()==width.SVG_LENGTHTYPE_PX){
- svgWidth= svgWidthLength.getValueInSpecifiedUnits();
- svgHeight= svgHeightLength.getValueInSpecifiedUnits();
+ svgWidth = svgWidthLength.getValueInSpecifiedUnits();
+ svgHeight = svgHeightLength.getValueInSpecifiedUnits();
// }
}
}
@@ -150,81 +155,80 @@ public class SVGNodePlateFigure extends DefaultSizeNodeFigure {
//transform coordinate to absolute in the context of the SVG
//getBounds
- ArrayList<PrecisionPoint> pointList=new ArrayList<PrecisionPoint>();
+ ArrayList<PrecisionPoint> pointList = new ArrayList<PrecisionPoint>();
//current absolute coordinates
- float currentAbsoluteSVGPositionX=0;
- float currentAbsoluteSVGPositionY=0;
- for (int i=0; i<pathSegList.getNumberOfItems();i++){
- SVGPathSeg seg=pathSegList.getItem(i);
- if( seg instanceof SVGPathSegMovetoLinetoItem){
- SVGPathSegMovetoLinetoItem linetoItem=(SVGPathSegMovetoLinetoItem) seg;
+ float currentAbsoluteSVGPositionX = 0;
+ float currentAbsoluteSVGPositionY = 0;
+ for(int i = 0; i < pathSegList.getNumberOfItems(); i++) {
+ SVGPathSeg seg = pathSegList.getItem(i);
+ if(seg instanceof SVGPathSegMovetoLinetoItem) {
+ SVGPathSegMovetoLinetoItem linetoItem = (SVGPathSegMovetoLinetoItem)seg;
//short value =linetoItem.getPathSegType();
- String letter= linetoItem.getPathSegTypeAsLetter();
- float x= (float)linetoItem.getX();
- float y=(float) linetoItem.getY();
+ String letter = linetoItem.getPathSegTypeAsLetter();
+ float x = linetoItem.getX();
+ float y = linetoItem.getY();
// System.out.println("value="+value +" letter="+letter+ " x="+ x+ " y="+y);
- if( letter.equals("M")){
- currentAbsoluteSVGPositionX=x;
- currentAbsoluteSVGPositionY=y;
- pointList.add(new PrecisionPoint(currentAbsoluteSVGPositionX,currentAbsoluteSVGPositionY));
- }
- else if( letter.equals("m")){
- currentAbsoluteSVGPositionX=currentAbsoluteSVGPositionX+x;
- currentAbsoluteSVGPositionY=currentAbsoluteSVGPositionY+y;
- pointList.add(new PrecisionPoint(currentAbsoluteSVGPositionX,currentAbsoluteSVGPositionY));
- }
- else if( letter.equals("L")){
- currentAbsoluteSVGPositionX=x;
- currentAbsoluteSVGPositionY=y;
- pointList.add(new PrecisionPoint(currentAbsoluteSVGPositionX,currentAbsoluteSVGPositionY));
- }
- else if( letter.equals("l")){
- currentAbsoluteSVGPositionX=currentAbsoluteSVGPositionX+x;
- currentAbsoluteSVGPositionY=currentAbsoluteSVGPositionY+y;
- pointList.add(new PrecisionPoint(currentAbsoluteSVGPositionX,currentAbsoluteSVGPositionY));
+ if(letter.equals("M")) {
+ currentAbsoluteSVGPositionX = x;
+ currentAbsoluteSVGPositionY = y;
+ pointList.add(new PrecisionPoint(currentAbsoluteSVGPositionX, currentAbsoluteSVGPositionY));
+ } else if(letter.equals("m")) {
+ currentAbsoluteSVGPositionX = currentAbsoluteSVGPositionX + x;
+ currentAbsoluteSVGPositionY = currentAbsoluteSVGPositionY + y;
+ pointList.add(new PrecisionPoint(currentAbsoluteSVGPositionX, currentAbsoluteSVGPositionY));
+ } else if(letter.equals("L")) {
+ currentAbsoluteSVGPositionX = x;
+ currentAbsoluteSVGPositionY = y;
+ pointList.add(new PrecisionPoint(currentAbsoluteSVGPositionX, currentAbsoluteSVGPositionY));
+ } else if(letter.equals("l")) {
+ currentAbsoluteSVGPositionX = currentAbsoluteSVGPositionX + x;
+ currentAbsoluteSVGPositionY = currentAbsoluteSVGPositionY + y;
+ pointList.add(new PrecisionPoint(currentAbsoluteSVGPositionX, currentAbsoluteSVGPositionY));
}
- }else
- {
- System.err.println("this is not i linear segment "+i);
+ } else {
+ System.err.println("this is not i linear segment " + i);
}
}
//get the original size of SVG
- double maxWitdh=0;
- double maxHeight=0;
- if(svgWidth!=0 && svgHeight!=0){
- maxWitdh= (double)svgWidth;
- maxHeight= (double)svgHeight;
- }
- else{
- for (int i=0; i<pointList.size();i++){
- PrecisionPoint point=pointList.get(i);
- if(point.preciseX()>maxWitdh){maxWitdh=point.preciseX();}
- if(point.preciseY()>maxHeight){maxHeight=point.preciseY();}
+ double maxWitdh = 0;
+ double maxHeight = 0;
+ if(svgWidth != 0 && svgHeight != 0) {
+ maxWitdh = svgWidth;
+ maxHeight = svgHeight;
+ } else {
+ for(int i = 0; i < pointList.size(); i++) {
+ PrecisionPoint point = pointList.get(i);
+ if(point.preciseX() > maxWitdh) {
+ maxWitdh = point.preciseX();
+ }
+ if(point.preciseY() > maxHeight) {
+ maxHeight = point.preciseY();
+ }
}
}
//System.out.println("Size of the SVG figure is= "+maxHeight +" "+maxHeight);
PointList points = new PointList(5);
- Rectangle anchorableRectangle=null;
- if(containShapeCompatment()){
- anchorableRectangle =getShapeCompatment().getBounds();
+ Rectangle anchorableRectangle = null;
+ if(containShapeCompatment()) {
+ anchorableRectangle = getShapeCompatment().getBounds();
}
- else{
+ else {
anchorableRectangle = getHandleBounds();
}
- double ratioX=anchorableRectangle.width/maxWitdh;
- double ratioY=anchorableRectangle.height/maxHeight;
+ double ratioX = anchorableRectangle.width / maxWitdh;
+ double ratioY = anchorableRectangle.height / maxHeight;
//PackageFigure packageFigure = getPackageFigure();
//System.out.println("Begin-------------" );
- for (int i=0; i<pointList.size();i++){
- PrecisionPoint point=pointList.get(i);
- double x= point.preciseX()*ratioX;
- double y=point.preciseY()*ratioY;
- points.addPoint(anchorableRectangle.x +(int)x, anchorableRectangle.y+(int)y);
+ for(int i = 0; i < pointList.size(); i++) {
+ PrecisionPoint point = pointList.get(i);
+ double x = point.preciseX() * ratioX;
+ double y = point.preciseY() * ratioY;
+ points.addPoint(anchorableRectangle.x + (int)x, anchorableRectangle.y + (int)y);
//System.out.println("add point x="+x +" y=" +y +" ratioX= "+ratioX+" ratioY="+ratioY );
}
//System.out.println("End-------------" );
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/AbstractShapeProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/AbstractShapeProvider.java
index 356ad8ff526..555f81d48a7 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/AbstractShapeProvider.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/AbstractShapeProvider.java
@@ -13,13 +13,19 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.service.shape;
+import java.io.IOException;
+import java.io.StringWriter;
+
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
-import org.apache.batik.dom.svg.SVGOMDocument;
+import org.apache.batik.dom.util.DOMUtilities;
import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.draw2d.ui.render.RenderedImage;
+import org.eclipse.gmf.runtime.draw2d.ui.render.factory.RenderedImageFactory;
import org.w3c.dom.Document;
+import org.w3c.dom.svg.SVGDocument;
/**
* Abstract implementation of the shape provider interface.
@@ -71,6 +77,7 @@ public abstract class AbstractShapeProvider extends AbstractProvider implements
/**
* {@inheritDoc}
*/
+ @Override
public String getId() {
return id;
}
@@ -88,6 +95,7 @@ public abstract class AbstractShapeProvider extends AbstractProvider implements
/**
* @{inheritDoc
*/
+ @Override
public boolean provides(IOperation operation) {
return (operation instanceof GetAllShapeProvidersOperation || operation instanceof GetShapeProviderByIdentifierOperation);
}
@@ -95,6 +103,7 @@ public abstract class AbstractShapeProvider extends AbstractProvider implements
/**
* {@inheritDoc}
*/
+ @Override
public void setConfiguration(IConfigurationElement element) {
name = element.getAttribute(NAME);
id = element.getAttribute(ID);
@@ -107,17 +116,23 @@ public abstract class AbstractShapeProvider extends AbstractProvider implements
* @param location
* @return the Document SVG from its location, can return null if this is not a svg
*/
- public SVGOMDocument getSVGDocument(String location){
- if (!location.endsWith(".svg")){
+ protected SVGDocument getSVGDocument(String location) {
+ int extensionIndex = location.lastIndexOf('.');
+ if(extensionIndex == 0) {
+ return null;
+ }
+ String fileExtension = location.substring(extensionIndex);
+ if(!fileExtension.equalsIgnoreCase(".svg")) {
return null;
}
- URI svgURI=URI.createURI(location);
+
String parser = org.apache.batik.util.XMLResourceDescriptor.getXMLParserClassName();
- SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
-
+
try {
- Document doc = f.createDocument(svgURI.toString());
- SVGOMDocument svgDocument=(SVGOMDocument)doc;
+ SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
+
+ Document doc = f.createDocument(location);
+ SVGDocument svgDocument = (SVGDocument)doc;
return svgDocument;
} catch (Exception e) {
@@ -125,4 +140,24 @@ public abstract class AbstractShapeProvider extends AbstractProvider implements
}
return null;
}
+
+ protected RenderedImage renderSVGDocument(EObject view, SVGDocument document) throws IOException {
+ postProcess(view, document);
+ String svgAsText = toString(document);
+ byte[] buffer = svgAsText.getBytes();
+
+ return RenderedImageFactory.getInstance(buffer);
+ }
+
+ protected void postProcess(EObject view, SVGDocument document) {
+ SVGPostProcessor.instance.postProcess(view, document);
+ }
+
+ protected String toString(SVGDocument domDocument) throws IOException {
+ StringWriter writer = new StringWriter();
+
+ DOMUtilities.writeDocument(domDocument, writer);
+
+ return writer.toString();
+ }
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/GetSVGDocumentForViewOperation.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/GetSVGDocumentForViewOperation.java
index 4f765742456..d31f7535060 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/GetSVGDocumentForViewOperation.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/GetSVGDocumentForViewOperation.java
@@ -13,13 +13,13 @@ package org.eclipse.papyrus.infra.gmfdiag.common.service.shape;
import java.util.List;
-import org.apache.batik.dom.svg.SVGOMDocument;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.common.core.service.IProvider;
+import org.w3c.dom.svg.SVGDocument;
/**
- * Operation to find a list of shapes, given a view
+ * Operation to find a list of shapes, given a view
*/
public class GetSVGDocumentForViewOperation implements IOperation, IShapeProviderOperation {
@@ -40,12 +40,13 @@ public class GetSVGDocumentForViewOperation implements IOperation, IShapeProvide
/**
* @{inheritDoc
*/
- public List<SVGOMDocument> execute(IProvider provider) {
+ @Override
+ public List<SVGDocument> execute(IProvider provider) {
if(!(provider instanceof IShapeProvider)) {
return null;
}
IShapeProvider shapeProvider = (IShapeProvider)provider;
- return shapeProvider.getSVGOMDocument(getView());
+ return shapeProvider.getSVGDocument(getView());
}
/**
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/IShapeProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/IShapeProvider.java
index 5682aea6537..6aff23f42b9 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/IShapeProvider.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/IShapeProvider.java
@@ -15,13 +15,13 @@ package org.eclipse.papyrus.infra.gmfdiag.common.service.shape;
import java.util.List;
-import org.apache.batik.dom.svg.SVGOMDocument;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.service.IProvider;
import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
import org.eclipse.gmf.runtime.draw2d.ui.render.RenderedImage;
+import org.w3c.dom.svg.SVGDocument;
/**
* Interface implemented by all providers to the {@link ShapeService}
@@ -51,7 +51,7 @@ public interface IShapeProvider extends IProvider {
* @return the list of shapes or <code>null</code> if no shapes have to be displayed by this provider
*/
List<RenderedImage> getShapes(EObject view);
-
+
/**
* Returns the list of SVG Documents proposed by this provider
*
@@ -59,7 +59,7 @@ public interface IShapeProvider extends IProvider {
* the view for which shapes are looked for
* @return the list of SVG DOCUMENT or <code>null</code> if no shapes have to be displayed by this provider
*/
- List<SVGOMDocument> getSVGOMDocument(EObject view);
+ List<SVGDocument> getSVGDocument(EObject view);
/**
* Returns <code>true</code> if the provider can display shapes.
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/SVGPostProcessor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/SVGPostProcessor.java
new file mode 100644
index 00000000000..70551902080
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/SVGPostProcessor.java
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.common.service.shape;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.gmfdiag.common.Activator;
+import org.w3c.dom.svg.SVGDocument;
+
+/**
+ * A Post-Processor for SVG Documents
+ *
+ * Can be used to apply transformations before the SVGDocument is displayed on the diagram
+ *
+ * @author Camille Letavernier
+ *
+ */
+public interface SVGPostProcessor {
+
+ public static final String EXTENSION_POINT = Activator.ID + ".svgPostProcessors";
+
+ public static final String EXTENSION_CLASS_NAME_ATTRIBUTE = "implementation";
+
+ /**
+ * Singleton instance of the composite SVGPostProcessor. It aggregates all post-processors
+ * declared via the {@link #EXTENSION_POINT} extension point
+ */
+ public SVGPostProcessor instance = new SVGPostProcessorImpl();
+
+ /**
+ * Apply a transformation on the given SVGDocument before it is rendered
+ * The view can be used as the context of the transformation
+ *
+ * @param view
+ * @param document
+ */
+ public void postProcess(EObject view, SVGDocument document);
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/SVGPostProcessorImpl.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/SVGPostProcessorImpl.java
new file mode 100644
index 00000000000..45f885f150a
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/SVGPostProcessorImpl.java
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.common.service.shape;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.gmfdiag.common.Activator;
+import org.w3c.dom.svg.SVGDocument;
+
+/**
+ * Aggregation of all SVGPostProcessors declared via the {@link #EXTENSION_POINT} extension point
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class SVGPostProcessorImpl implements SVGPostProcessor {
+
+ protected final List<SVGPostProcessor> processors;
+
+ public SVGPostProcessorImpl() {
+ processors = new LinkedList<SVGPostProcessor>();
+ loadPostProcessors();
+ }
+
+ protected void loadPostProcessors() {
+
+ IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT);
+
+ for(IConfigurationElement e : config) {
+ try {
+ Object postProcessorObject = e.createExecutableExtension(EXTENSION_CLASS_NAME_ATTRIBUTE);
+
+ if(!(postProcessorObject instanceof SVGPostProcessor)) {
+ Activator.log.warn(String.format("Plug-in %s contributed an invalid SVG post-processor: %s", e.getContributor(), e.getAttribute(EXTENSION_CLASS_NAME_ATTRIBUTE))); //$NON-NLS-1$
+ continue;
+ }
+
+ processors.add((SVGPostProcessor)postProcessorObject);
+ } catch (Throwable t) {
+ Activator.log.error(String.format("Plug-in %s contributed an invalid SVG post-processor", e.getContributor()), t);
+ continue;
+ }
+ }
+ }
+
+ @Override
+ public void postProcess(EObject view, SVGDocument document) {
+ for(SVGPostProcessor processor : processors) {
+ processor.postProcess(view, document);
+ }
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java
index cd2f7a6a718..07708c2f559 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java
@@ -17,7 +17,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.apache.batik.dom.svg.SVGOMDocument;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.emf.ecore.EObject;
@@ -30,6 +29,7 @@ import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
import org.eclipse.gmf.runtime.draw2d.ui.render.RenderedImage;
import org.eclipse.papyrus.infra.gmfdiag.common.Activator;
+import org.w3c.dom.svg.SVGDocument;
/**
* Service that manages shape.
@@ -53,7 +53,7 @@ public class ShapeService extends org.eclipse.gmf.runtime.common.core.service.Se
*/
public boolean hasShapeToDisplay(EObject view) {
@SuppressWarnings("unchecked")
- List<RenderedImage> images = (List<RenderedImage>)execute(ExecutionStrategy.REVERSE, new GetShapesForViewOperation(view));
+ List<RenderedImage> images = execute(ExecutionStrategy.REVERSE, new GetShapesForViewOperation(view));
return images != null && images.size() > 0;
}
@@ -66,7 +66,7 @@ public class ShapeService extends org.eclipse.gmf.runtime.common.core.service.Se
*/
public List<RenderedImage> getShapesToDisplay(EObject view) {
@SuppressWarnings("unchecked")
- List<List<RenderedImage>> listOfListOfImages = (List<List<RenderedImage>>)execute(ExecutionStrategy.REVERSE, new GetShapesForViewOperation(view));
+ List<List<RenderedImage>> listOfListOfImages = execute(ExecutionStrategy.REVERSE, new GetShapesForViewOperation(view));
List<RenderedImage> images = new ArrayList<RenderedImage>();
for(List<RenderedImage> listOfImages : listOfListOfImages) {
if(listOfImages != null && !listOfImages.isEmpty()) {
@@ -75,8 +75,8 @@ public class ShapeService extends org.eclipse.gmf.runtime.common.core.service.Se
}
return images;
}
-
-
+
+
/**
* Returns the shape to be displayed
*
@@ -84,11 +84,11 @@ public class ShapeService extends org.eclipse.gmf.runtime.common.core.service.Se
* the EObject for which the shape is computed
* @return the shape to be displayed
*/
- public List<SVGOMDocument> getSVGDocumentToDisplay(EObject view) {
+ public List<SVGDocument> getSVGDocumentToDisplay(EObject view) {
@SuppressWarnings("unchecked")
- List<List<SVGOMDocument>> listOfListOfImages = (List<List<SVGOMDocument>>)execute(ExecutionStrategy.REVERSE, new GetSVGDocumentForViewOperation(view));
- List<SVGOMDocument> images = new ArrayList<SVGOMDocument>();
- for(List<SVGOMDocument> listOfImages : listOfListOfImages) {
+ List<List<SVGDocument>> listOfListOfImages = execute(ExecutionStrategy.REVERSE, new GetSVGDocumentForViewOperation(view));
+ List<SVGDocument> images = new ArrayList<SVGDocument>();
+ for(List<SVGDocument> listOfImages : listOfListOfImages) {
if(listOfImages != null && !listOfImages.isEmpty()) {
images.addAll(listOfImages);
}
@@ -108,7 +108,7 @@ public class ShapeService extends org.eclipse.gmf.runtime.common.core.service.Se
*/
protected List<ProviderNotificationManager> createProviderNotificationManagers(DiagramEventBroker diagramEventBroker, EObject view, NotificationListener notificationListener) {
@SuppressWarnings("unchecked")
- List<ProviderNotificationManager> providerNotificationManagers = (List<ProviderNotificationManager>)execute(ExecutionStrategy.REVERSE, new CreateProviderNotificationManagersOperation(diagramEventBroker, view, notificationListener));
+ List<ProviderNotificationManager> providerNotificationManagers = execute(ExecutionStrategy.REVERSE, new CreateProviderNotificationManagersOperation(diagramEventBroker, view, notificationListener));
return providerNotificationManagers;
}
@@ -154,7 +154,7 @@ public class ShapeService extends org.eclipse.gmf.runtime.common.core.service.Se
*/
public IShapeProvider getProvider(String id) {
@SuppressWarnings("unchecked")
- List<IShapeProvider> providers = (List<IShapeProvider>)execute(ExecutionStrategy.REVERSE, new GetShapeProviderByIdentifierOperation(id));
+ List<IShapeProvider> providers = execute(ExecutionStrategy.REVERSE, new GetShapeProviderByIdentifierOperation(id));
if(providers == null) {
return null;
}
@@ -202,7 +202,7 @@ public class ShapeService extends org.eclipse.gmf.runtime.common.core.service.Se
if(!(operation instanceof IShapeProviderOperation)) {
return false;
}
-
+
if(operation instanceof GetShapeProviderByIdentifierOperation) {
return providerConfiguration.getId().equals(((GetShapeProviderByIdentifierOperation)operation).getIdentifier());
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/.classpath b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/.classpath
index 2d1a4302f04..8a8f1668cdc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/.classpath
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/.settings/org.eclipse.jdt.core.prefs b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/.settings/org.eclipse.jdt.core.prefs
index 060c5ee3d2e..54e493c07c9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/.settings/org.eclipse.jdt.core.prefs
@@ -1,11 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/META-INF/MANIFEST.MF
index 7f6d6c17d59..246e03c661a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/META-INF/MANIFEST.MF
@@ -17,12 +17,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.uml.diagram.common;bundle-version="0.10.1",
org.eclipse.papyrus.uml.appearance;bundle-version="0.10.1",
org.eclipse.papyrus.infra.emf;bundle-version="0.10.1",
- org.apache.batik.dom.svg,
- org.apache.batik.util,
- org.apache.batik.svggen,
- org.apache.batik.dom,
- org.w3c.dom.svg,
- org.apache.batik.css
+ org.w3c.dom.svg
Export-Package: org.eclipse.papyrus.uml.diagram.symbols,
org.eclipse.papyrus.uml.diagram.symbols.provider
Bundle-Vendor: %Bundle-Vendor
@@ -33,5 +28,5 @@ Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.uml.diagram.symbols.Activator
Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.symbols;singleton
:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/ActorShapeProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/ActorShapeProvider.java
index 0bef48763c5..ec7442c26c0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/ActorShapeProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/ActorShapeProvider.java
@@ -13,18 +13,17 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.symbols.provider;
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.io.IOException;
import java.util.Arrays;
+import java.util.LinkedList;
import java.util.List;
-import org.apache.batik.dom.svg.SVGOMDocument;
import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
import org.eclipse.gmf.runtime.draw2d.ui.render.RenderedImage;
-import org.eclipse.gmf.runtime.draw2d.ui.render.factory.RenderedImageFactory;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.emf.utils.BusinessModelResolver;
import org.eclipse.papyrus.infra.gmfdiag.common.service.shape.AbstractShapeProvider;
@@ -34,6 +33,7 @@ import org.eclipse.uml2.uml.Actor;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.TypedElement;
import org.eclipse.uml2.uml.UMLPackage;
+import org.w3c.dom.svg.SVGDocument;
/**
@@ -44,14 +44,22 @@ public class ActorShapeProvider extends AbstractShapeProvider {
/**
* {@inheritDoc}
*/
+ @Override
public List<RenderedImage> getShapes(EObject view) {
if(providesShapes(view)) {
- URL url;
- try {
- url = new URL("platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/symbols/actor.svg"); //$NON-NLS-1$
- return Arrays.asList(RenderedImageFactory.getInstance(url));
- } catch (MalformedURLException e) {
- Activator.log.error(e);
+ List<SVGDocument> documents = getSVGDocument(view);
+
+ if(documents != null) {
+ List<RenderedImage> result = new LinkedList<RenderedImage>();
+ for(SVGDocument document : documents) {
+ try {
+ result.add(renderSVGDocument(view, document));
+ } catch (IOException ex) {
+ Activator.log.error(ex);
+ continue;
+ }
+ }
+ return result;
}
}
return null;
@@ -60,6 +68,7 @@ public class ActorShapeProvider extends AbstractShapeProvider {
/**
* {@inheritDoc}
*/
+ @Override
public boolean providesShapes(EObject view) {
if(!(view instanceof View)) {
return false;
@@ -76,6 +85,7 @@ public class ActorShapeProvider extends AbstractShapeProvider {
/**
* {@inheritDoc}
*/
+ @Override
public ProviderNotificationManager createProviderNotificationManager(DiagramEventBroker diagramEventBroker, EObject view, NotificationListener listener) {
// retrieve semantic element from the view and add a notification listener on the Type feature if the semantic element is a TypedElement
if(view == null || !(view instanceof View)) {
@@ -137,6 +147,7 @@ public class ActorShapeProvider extends AbstractShapeProvider {
/**
* {@inheritDoc}
*/
+ @Override
public void notifyChanged(Notification notification) {
if(listener == null) {
return;
@@ -147,16 +158,20 @@ public class ActorShapeProvider extends AbstractShapeProvider {
}
}
- public List<SVGOMDocument> getSVGOMDocument(EObject view) {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<SVGDocument> getSVGDocument(EObject view) {
if(providesShapes(view)) {
- String path ="platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/symbols/actor.svg"; //$NON-NLS-1$
- SVGOMDocument document=getSVGDocument(path);
- if(document==null){
+ URI uri = URI.createPlatformPluginURI(org.eclipse.papyrus.uml.diagram.common.Activator.ID + "/icons/symbols/actor.svg", true);
+ String path = uri.toString();
+ SVGDocument document = getSVGDocument(path);
+ if(document == null) {
return null;
}
return Arrays.asList(getSVGDocument(path));
}
return null;
}
-
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/StereotypedElementShapeProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/StereotypedElementShapeProvider.java
index 8b8bf732480..d71cd86b69f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/StereotypedElementShapeProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/StereotypedElementShapeProvider.java
@@ -1,12 +1,23 @@
+/*****************************************************************************
+ * Copyright (c) 2012-2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
package org.eclipse.papyrus.uml.diagram.symbols.provider;
-import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
-import org.apache.batik.dom.svg.SVGOMDocument;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EObject;
@@ -25,6 +36,7 @@ import org.eclipse.papyrus.uml.diagram.symbols.Activator;
import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
+import org.w3c.dom.svg.SVGDocument;
/**
* This provider is linked to the {@link ShapeService}. It returns the shapes for a given element corresponding to the stereotypes applied on the
@@ -37,6 +49,7 @@ public class StereotypedElementShapeProvider extends AbstractShapeProvider {
/**
* {@inheritDoc}
*/
+ @Override
public List<RenderedImage> getShapes(EObject view) {
if(!(view instanceof View)) {
return null;
@@ -45,26 +58,32 @@ public class StereotypedElementShapeProvider extends AbstractShapeProvider {
if(element instanceof Element) {
List<RenderedImage> images = new ArrayList<RenderedImage>();
// it has already been checked that
- URL url;
- try {
- String stereotypesToDisplay = AppliedStereotypeHelper.getStereotypesToDisplay((View)view);
- StringTokenizer tokenizer = new StringTokenizer(stereotypesToDisplay, ",");
- while(tokenizer.hasMoreTokens()) {
+
+ String stereotypesToDisplay = AppliedStereotypeHelper.getStereotypesToDisplay((View)view);
+ StringTokenizer tokenizer = new StringTokenizer(stereotypesToDisplay, ",");
+ while(tokenizer.hasMoreTokens()) {
+ try {
String stereotypeName = tokenizer.nextToken();
Stereotype stereotype = ((Element)element).getAppliedStereotype(stereotypeName);
org.eclipse.uml2.uml.Image icon = ElementUtil.getStereotypeImage(((Element)element), stereotype, SHAPE_CONSTANT);
if(icon != null) {
- if(icon.getLocation() != "" && icon.getLocation() != null) {
- url = new URL(icon.getLocation());
- images.add(RenderedImageFactory.getInstance(url));
+ if(!"".equals(icon.getLocation()) && icon.getLocation() != null) {
+ SVGDocument document = getSVGDocument(icon.getLocation());
+ if(document != null) {
+ images.add(renderSVGDocument(view, document));
+ } else {
+ URL url = new URL(icon.getLocation());
+ images.add(RenderedImageFactory.getInstance(url));
+ }
}
}
+ } catch (Exception ex) {
+ Activator.log.error(ex);
+ continue;
}
-
- return images;
- } catch (MalformedURLException e) {
- Activator.log.error(e);
}
+
+ return images;
}
return null;
}
@@ -72,6 +91,7 @@ public class StereotypedElementShapeProvider extends AbstractShapeProvider {
/**
* {@inheritDoc}
*/
+ @Override
public boolean providesShapes(EObject view) {
if(!(view instanceof View)) {
return false;
@@ -98,13 +118,18 @@ public class StereotypedElementShapeProvider extends AbstractShapeProvider {
return false;
}
- public List<SVGOMDocument> getSVGOMDocument(EObject view) {
+ /**
+ * {@inheritDoc}
+ *
+ */
+ @Override
+ public List<SVGDocument> getSVGDocument(EObject view) {
if(!(view instanceof View)) {
return null;
}
EObject element = ((View)view).getElement();
if(element instanceof Element) {
- List<SVGOMDocument> images = new ArrayList<SVGOMDocument>();
+ List<SVGDocument> images = new ArrayList<SVGDocument>();
// it has already been checked that
String stereotypesToDisplay = AppliedStereotypeHelper.getStereotypesToDisplay((View)view);
StringTokenizer tokenizer = new StringTokenizer(stereotypesToDisplay, ",");
@@ -114,8 +139,8 @@ public class StereotypedElementShapeProvider extends AbstractShapeProvider {
org.eclipse.uml2.uml.Image icon = ElementUtil.getStereotypeImage(((Element)element), stereotype, SHAPE_CONSTANT);
if(icon != null) {
if(icon.getLocation() != "" && icon.getLocation() != null) {
- SVGOMDocument document=getSVGDocument(icon.getLocation());
- if(document!=null){
+ SVGDocument document = getSVGDocument(icon.getLocation());
+ if(document != null) {
images.add(document);
}
}
@@ -130,6 +155,7 @@ public class StereotypedElementShapeProvider extends AbstractShapeProvider {
/**
* {@inheritDoc}
*/
+ @Override
public ProviderNotificationManager createProviderNotificationManager(DiagramEventBroker diagramEventBroker, EObject view, NotificationListener listener) {
// retrieve semantic element from the view and add a notification listener on the Type feature if the semantic element is a TypedElement
if(view == null || !(view instanceof View)) {
@@ -185,6 +211,7 @@ public class StereotypedElementShapeProvider extends AbstractShapeProvider {
/**
* {@inheritDoc}
*/
+ @Override
public void notifyChanged(Notification notification) {
if(listener == null) {
return;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/TypedElementShapeProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/TypedElementShapeProvider.java
index b59dd2b48bf..ba54ee4b8be 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/TypedElementShapeProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/TypedElementShapeProvider.java
@@ -14,15 +14,17 @@
package org.eclipse.papyrus.uml.diagram.symbols.provider;
import java.io.File;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
+import java.util.LinkedList;
import java.util.List;
-import org.apache.batik.dom.svg.SVGOMDocument;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
import org.eclipse.gmf.runtime.draw2d.ui.render.RenderedImage;
@@ -38,20 +40,42 @@ import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.TypedElement;
import org.eclipse.uml2.uml.UMLPackage;
+import org.w3c.dom.svg.SVGDocument;
/**
- * This provider is linked to the {@link ShapeService}. It returns the shapes for a given typed element corresponding to the stereotypes applied on
- * the business element.
+ * This provider is linked to the {@link ShapeService}. It returns the shapes
+ * for a given typed element corresponding to the stereotypes applied on the
+ * business element.
*/
public class TypedElementShapeProvider extends AbstractShapeProvider {
/**
* {@inheritDoc}
*/
+ @Override
public List<RenderedImage> getShapes(EObject view) {
Type type = getType(view);
String path = getSymbolPath(type);
if(path != null && path.length() > 0) {
+
+ List<SVGDocument> documents = getSVGDocument(view);
+ if(!documents.isEmpty()) {
+ List<RenderedImage> result = new LinkedList<RenderedImage>();
+ for(SVGDocument document : documents) {
+ if(document == null) {
+ continue;
+ }
+ try {
+ result.add(renderSVGDocument(view, document));
+ } catch (IOException ex) {
+ Activator.log.error(ex);
+ }
+ }
+ if(!result.isEmpty()) {
+ return result;
+ }
+ }
+
URL url;
try {
url = new URL(path);
@@ -61,6 +85,7 @@ public class TypedElementShapeProvider extends AbstractShapeProvider {
if(typeResourceURI != null) {
String workspaceRelativeFolderPath = typeResourceURI.trimSegments(1).toPlatformString(true);
try {
+
url = new URL("platform:/resource/" + workspaceRelativeFolderPath + File.separatorChar + path);
return Arrays.asList(RenderedImageFactory.getInstance(url));
} catch (MalformedURLException e1) {
@@ -72,26 +97,29 @@ public class TypedElementShapeProvider extends AbstractShapeProvider {
return null;
}
-
- public List<SVGOMDocument> getSVGOMDocument(EObject view) {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<SVGDocument> getSVGDocument(EObject view) {
Type type = getType(view);
String path = getSymbolPath(type);
if(path != null && path.length() > 0) {
- URL url;
try {
- url = new URL(path);
- SVGOMDocument document=getSVGDocument(path);
- if(document!=null){
+ new URL(path);
+ SVGDocument document = getSVGDocument(path);
+ if(document != null) {
return Arrays.asList(document);
}
- return Arrays.asList(getSVGDocument(path));
+
+ return null;
} catch (MalformedURLException e) {
- URI typeResourceURI = type.eResource().getURI();
+ URI typeResourceURI = EcoreUtil.getURI(type).trimFragment();
if(typeResourceURI != null) {
String workspaceRelativeFolderPath = typeResourceURI.trimSegments(1).toPlatformString(true);
- String newPath = "platform:/resource/" + workspaceRelativeFolderPath + File.separatorChar + path;
- SVGOMDocument document=getSVGDocument(newPath);
- if(document!=null){
+ String newPath = URI.createPlatformResourceURI(workspaceRelativeFolderPath + File.separatorChar + path, false).toString();
+ SVGDocument document = getSVGDocument(newPath);
+ if(document != null) {
return Arrays.asList(document);
}
}
@@ -103,6 +131,7 @@ public class TypedElementShapeProvider extends AbstractShapeProvider {
/**
* {@inheritDoc}
*/
+ @Override
public boolean providesShapes(EObject view) {
Type type = getType(view);
String path = getSymbolPath(type);
@@ -117,7 +146,8 @@ public class TypedElementShapeProvider extends AbstractShapeProvider {
*
* @param view
* the view from which type should be looked
- * @return the type of the semantic element or <code>null</code> if none was found
+ * @return the type of the semantic element or <code>null</code> if none was
+ * found
*/
protected Type getType(EObject view) {
if(!(view instanceof View)) {
@@ -161,6 +191,7 @@ public class TypedElementShapeProvider extends AbstractShapeProvider {
/**
* {@inheritDoc}
*/
+ @Override
public ProviderNotificationManager createProviderNotificationManager(DiagramEventBroker diagramEventBroker, EObject view, NotificationListener listener) {
if(view == null || !(view instanceof View)) {
return null;
@@ -178,9 +209,11 @@ public class TypedElementShapeProvider extends AbstractShapeProvider {
* Creates a new StereotypedElementShapeProviderNotificationManager.
*
* @param diagramEventBroker
- * event broker specific to the diargam displaying the shapes.
+ * event broker specific to the diargam displaying the
+ * shapes.
* @param view
- * the view from which all elements to listen will be computed.
+ * the view from which all elements to listen will be
+ * computed.
* @param listener
* the listener to which notifications will be forwarded.
*/
@@ -196,8 +229,10 @@ public class TypedElementShapeProvider extends AbstractShapeProvider {
if(view == null || !(view instanceof View)) {
return;
}
- // should register this listener on the type, to listen for stereotype modification
- // should listen to new value of the typedElement_type feature, in order to remove/add the stereotype listener...
+ // should register this listener on the type, to listen for
+ // stereotype modification
+ // should listen to new value of the typedElement_type feature, in
+ // order to remove/add the stereotype listener...
Object semanticElement = ((View)view).getElement();
if(semanticElement instanceof Type) {
diagramEventBroker.addNotificationListener((Type)semanticElement, this);
@@ -235,6 +270,7 @@ public class TypedElementShapeProvider extends AbstractShapeProvider {
/**
* {@inheritDoc}
*/
+ @Override
public void notifyChanged(Notification notification) {
if(listener == null) {
return;
@@ -245,7 +281,8 @@ public class TypedElementShapeProvider extends AbstractShapeProvider {
// add/remove stereotype listener if needed...
Object oldValue = notification.getOldValue();
if(oldValue instanceof Type) {
- // a type was removed => remove the listener from this old type
+ // a type was removed => remove the listener from this old
+ // type
diagramEventBroker.removeNotificationListener((Type)oldValue, this);
}
Object newValue = notification.getNewValue();
@@ -254,7 +291,8 @@ public class TypedElementShapeProvider extends AbstractShapeProvider {
diagramEventBroker.removeNotificationListener((Type)newValue, this);
}
} else if(notification instanceof StereotypeCustomNotification) {
- // call refresh for all stereotype notifications. could target specific modification on the stereotype Symbol definition
+ // call refresh for all stereotype notifications. could target
+ // specific modification on the stereotype Symbol definition
listener.notifyChanged(notification);
}

Back to the top