diff options
author | Pierre-Charles David | 2015-09-17 14:29:38 +0000 |
---|---|---|
committer | Maxime Porhel | 2016-02-18 14:44:31 +0000 |
commit | a37147db68ae3003c9d379b2411dad96244d9d12 (patch) | |
tree | 53984026d5585dc8731dea222efadda43e71f62c | |
parent | c328957cf6a17b54234a998b1923f84026171b0f (diff) | |
download | org.eclipse.sirius-a37147db68ae3003c9d379b2411dad96244d9d12.tar.gz org.eclipse.sirius-a37147db68ae3003c9d379b2411dad96244d9d12.tar.xz org.eclipse.sirius-a37147db68ae3003c9d379b2411dad96244d9d12.zip |
[442268] Remove dead code
This is code inherited from the GMF Tooling class originally copied
here, but never actually used in the Sirius code base.
Bug: 442268
Change-Id: I1a53111508c78220bb3ed934ef463b1785acdb8f
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
3 files changed, 0 insertions, 185 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/SVGFigure.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/SVGFigure.java index 398b81e954..d78ba0dce5 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/SVGFigure.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/SVGFigure.java @@ -13,16 +13,10 @@ package org.eclipse.sirius.diagram.ui.tools.api.figure; import java.awt.RenderingHints; -import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.IOException; import java.util.WeakHashMap; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - import org.apache.batik.dom.svg.SAXSVGDocumentFactory; import org.apache.batik.util.XMLResourceDescriptor; import org.eclipse.draw2d.Figure; @@ -30,14 +24,12 @@ import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.sirius.diagram.DiagramPlugin; import org.eclipse.sirius.diagram.ui.provider.Messages; -import org.eclipse.sirius.diagram.ui.tools.internal.figure.svg.InferringNamespaceContext; import org.eclipse.sirius.diagram.ui.tools.internal.figure.svg.SVGUtils; import org.eclipse.sirius.diagram.ui.tools.internal.figure.svg.SimpleImageTranscoder; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; import org.w3c.dom.Document; -import org.w3c.dom.NodeList; //CHECKSTYLE:OFF public class SVGFigure extends Figure { @@ -93,7 +85,6 @@ public class SVGFigure extends Figure { private Document createDocument() { String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser); - return createDocument(factory, false); } @@ -137,35 +128,6 @@ public class SVGFigure extends Figure { return uri; } - /** - * Returns true if document was loaded without errors; tries to load - * document if needed. - */ - public final boolean checkContentAvailable() { - return getDocument() != null; - } - - private XPath getXPath() { - XPath xpath = XPathFactory.newInstance().newXPath(); - xpath.setNamespaceContext(new InferringNamespaceContext(getDocument().getDocumentElement())); - return xpath; - } - - /** - * Executes XPath query over the SVG document. - */ - protected final NodeList getNodes(String query) { - Document document = getDocument(); - if (document != null) { - try { - return (NodeList) getXPath().evaluate(query, document, XPathConstants.NODESET); - } catch (XPathExpressionException e) { - throw new RuntimeException(e); - } - } - return null; - } - @Override protected void paintFigure(Graphics graphics) { super.paintFigure(graphics); @@ -233,37 +195,6 @@ public class SVGFigure extends Figure { } } - public final Rectangle2D getAreaOfInterest() { - getDocument(); - return transcoder == null ? null : transcoder.getCanvasAreaOfInterest(); - } - - public void setAreaOfInterest(Rectangle2D value) { - getDocument(); - if (transcoder != null) { - transcoder.setCanvasAreaOfInterest(value); - } - repaint(); - } - - public final boolean isSpecifyCanvasWidth() { - return specifyCanvasWidth; - } - - public void setSpecifyCanvasWidth(boolean specifyCanvasWidth) { - this.specifyCanvasWidth = specifyCanvasWidth; - contentChanged(); - } - - public final boolean isSpecifyCanvasHeight() { - return specifyCanvasHeight; - } - - public void setSpecifyCanvasHeight(boolean specifyCanvasHeight) { - this.specifyCanvasHeight = specifyCanvasHeight; - contentChanged(); - } - /** * Should be called when SVG document has been changed. It will be * re-rendered and figure will be repainted. diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/svg/InferringNamespaceContext.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/svg/InferringNamespaceContext.java deleted file mode 100644 index 96fb5356d0..0000000000 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/svg/InferringNamespaceContext.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright (c) 2008 Borland Software Corporation - * - * 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: - * Dmitry Stadnik - initial API and implementation - * Obeo - Adaptations. - */ -package org.eclipse.sirius.diagram.ui.tools.internal.figure.svg; - -import java.util.Iterator; - -import javax.xml.XMLConstants; -import javax.xml.namespace.NamespaceContext; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; - -//CHECKSTYLE:OFF -public class InferringNamespaceContext implements NamespaceContext { - - private Node namespaceContext; - - public InferringNamespaceContext(Node namespaceContext) { - this.namespaceContext = namespaceContext; - } - - public String getNamespaceURI(String prefix) { - if (prefix.equals(XMLConstants.XML_NS_PREFIX)) { - return XMLConstants.XML_NS_URI; - } else if (prefix.equals(XMLConstants.XMLNS_ATTRIBUTE)) { - return XMLConstants.XMLNS_ATTRIBUTE_NS_URI; - } else { - return inferNamespaceURI(prefix); - } - } - - /* - * @see com.sun.org.apache.xml.internal.utils.PrefixResolverDefault - */ - protected String inferNamespaceURI(String prefix) { - Node parent = namespaceContext; - String namespace = null; - int type; - while ((null != parent) && (null == namespace) && (((type = parent.getNodeType()) == Node.ELEMENT_NODE) || (type == Node.ENTITY_REFERENCE_NODE))) { - if (type == Node.ELEMENT_NODE) { - if (parent.getNodeName().indexOf(prefix + ":") == 0) { //$NON-NLS-1$ - return parent.getNamespaceURI(); - } - NamedNodeMap nnm = parent.getAttributes(); - for (int i = 0; i < nnm.getLength(); i++) { - Node attr = nnm.item(i); - String aname = attr.getNodeName(); - boolean isPrefix = aname.startsWith("xmlns:"); //$NON-NLS-1$ - if (isPrefix || aname.equals("xmlns")) { //$NON-NLS-1$ - int index = aname.indexOf(':'); - String p = isPrefix ? aname.substring(index + 1) : ""; //$NON-NLS-1$ - if (p.equals(prefix)) { - namespace = attr.getNodeValue(); - break; - } - } - } - } - parent = parent.getParentNode(); - } - return namespace; - } - - public String getPrefix(String namespaceURI) { - return null; - } - - public Iterator getPrefixes(String namespaceURI) { - return null; - } -} -// CHECKSTYLE:ON diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/svg/SVGUtils.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/svg/SVGUtils.java index 9648d95839..dcb935b154 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/svg/SVGUtils.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/svg/SVGUtils.java @@ -15,21 +15,9 @@ package org.eclipse.sirius.diagram.ui.tools.internal.figure.svg; import java.awt.image.BufferedImage; import java.awt.image.WritableRaster; -import org.apache.batik.svggen.SVGColor; -import org.apache.batik.svggen.SVGGeneratorContext; -import org.apache.batik.svggen.SVGPaintDescriptor; -import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Device; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.PaletteData; -import org.eclipse.swt.widgets.Display; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.css.CSSStyleDeclaration; -import org.w3c.dom.css.CSSValue; -import org.w3c.dom.css.RGBColor; -import org.w3c.dom.css.ViewCSS; -import org.w3c.dom.svg.SVGPaint; //CHECKSTYLE:OFF public class SVGUtils { @@ -37,28 +25,6 @@ public class SVGUtils { private SVGUtils() { } - public static String toSVGColor(Document document, Color color) { - java.awt.Color awtColor = new java.awt.Color(color.getRed(), color.getGreen(), color.getBlue()); - SVGGeneratorContext svgContext = SVGGeneratorContext.createDefault(document); - SVGPaintDescriptor paint = SVGColor.toSVG(awtColor, svgContext); - return paint.getPaintValue(); - } - - public static Color toSWTColor(Element element, String attributeName) { - Document document = element.getOwnerDocument(); - ViewCSS viewCSS = (ViewCSS) document.getDocumentElement(); - CSSStyleDeclaration computedStyle = viewCSS.getComputedStyle(element, null); - SVGPaint svgPaint = (SVGPaint) computedStyle.getPropertyCSSValue(attributeName); - if (svgPaint.getPaintType() == SVGPaint.SVG_PAINTTYPE_RGBCOLOR) { - RGBColor rgb = svgPaint.getRGBColor(); - float red = rgb.getRed().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE); - float green = rgb.getGreen().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE); - float blue = rgb.getBlue().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE); - return new Color(Display.getCurrent(), (int) red, (int) green, (int) blue); - } - return null; - } - /** * Converts an AWT based buffered image into an SWT <code>Image</code>. This * will always return an <code>Image</code> that has 24 bit depth regardless |