Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/svg/SimpleImageTranscoder.java')
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/svg/SimpleImageTranscoder.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/svg/SimpleImageTranscoder.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/svg/SimpleImageTranscoder.java
index d5282e40d3..c4cfe2439b 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/svg/SimpleImageTranscoder.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/svg/SimpleImageTranscoder.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2008, 2016 Borland Software Corporation and others.
+ * Copyright (c) 2008, 2022 Borland Software Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -19,6 +19,10 @@ import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
+import org.apache.batik.bridge.EmbededExternalResourceSecurity;
+import org.apache.batik.bridge.ExternalResourceSecurity;
+import org.apache.batik.bridge.UserAgent;
+import org.apache.batik.bridge.UserAgentAdapter;
import org.apache.batik.gvt.renderer.ImageRenderer;
import org.apache.batik.gvt.renderer.StaticRenderer;
import org.apache.batik.transcoder.SVGAbstractTranscoder;
@@ -26,10 +30,11 @@ import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.image.ImageTranscoder;
+import org.apache.batik.util.ParsedURL;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.PrecisionRectangle;
import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.sirius.diagram.DiagramPlugin;
+import org.eclipse.sirius.diagram.tools.api.DiagramPlugin;
import org.eclipse.sirius.diagram.ui.provider.Messages;
import org.eclipse.sirius.diagram.ui.tools.api.figure.SVGFigure;
import org.eclipse.swt.graphics.Image;
@@ -52,13 +57,23 @@ public class SimpleImageTranscoder extends SVGAbstractTranscoder {
renderingHints = new RenderingHints(null);
}
+ @Override
+ protected UserAgent createUserAgent() {
+ return new UserAgentAdapter() {
+ @Override
+ public ExternalResourceSecurity getExternalResourceSecurity(ParsedURL resourceURL, ParsedURL docURL) {
+ return new EmbededExternalResourceSecurity(resourceURL);
+ }
+ };
+ }
+
public final Document getDocument() {
return document;
}
public int getImageHeight() {
int height = 0;
- if (canvasHeight == -1) {
+ if (canvasHeight == -1 && getBufferedImage() != null) {
height = getBufferedImage().getHeight();
} else {
height = canvasHeight;
@@ -68,7 +83,7 @@ public class SimpleImageTranscoder extends SVGAbstractTranscoder {
public int getImageWidth() {
int width = 0;
- if (canvasWidth == -1) {
+ if (canvasWidth == -1 && getBufferedImage() != null) {
width = getBufferedImage().getWidth();
} else {
width = canvasWidth;

Back to the top