Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordstadnik2008-08-04 08:45:29 -0400
committerdstadnik2008-08-04 08:45:29 -0400
commitb5da282e5f64bdcdf5dce192ca16ecef49cfb7cc (patch)
treeaab5c83cb2adb54efda87ab578accd7661069727
parentbb8073be02583ac9b0ced24f49bb2d25284da418 (diff)
downloadorg.eclipse.gmf-tooling-b5da282e5f64bdcdf5dce192ca16ecef49cfb7cc.tar.gz
org.eclipse.gmf-tooling-b5da282e5f64bdcdf5dce192ca16ecef49cfb7cc.tar.xz
org.eclipse.gmf-tooling-b5da282e5f64bdcdf5dce192ca16ecef49cfb7cc.zip
[243052] add prop to force safe rendering
-rw-r--r--plugins/org.eclipse.gmf.runtime.lite.svg/src/org/eclipse/gmf/runtime/lite/svg/SVGFigure.java37
1 files changed, 36 insertions, 1 deletions
diff --git a/plugins/org.eclipse.gmf.runtime.lite.svg/src/org/eclipse/gmf/runtime/lite/svg/SVGFigure.java b/plugins/org.eclipse.gmf.runtime.lite.svg/src/org/eclipse/gmf/runtime/lite/svg/SVGFigure.java
index 5e9b9b554..52d5195eb 100644
--- a/plugins/org.eclipse.gmf.runtime.lite.svg/src/org/eclipse/gmf/runtime/lite/svg/SVGFigure.java
+++ b/plugins/org.eclipse.gmf.runtime.lite.svg/src/org/eclipse/gmf/runtime/lite/svg/SVGFigure.java
@@ -44,11 +44,17 @@ public class SVGFigure extends Figure {
private String uri;
private Document document;
private boolean failedToLoadDocument;
+ private boolean safeRendering;
+ private boolean directRenderingSucceeded;
public final String getURI() {
return uri;
}
+ public final void setURI(String uri) {
+ setURI(uri, true);
+ }
+
public void setURI(String uri, boolean loadOnDemand) {
this.uri = uri;
document = null;
@@ -83,6 +89,13 @@ public class SVGFigure extends Figure {
return document;
}
+ /**
+ * 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()));
@@ -118,10 +131,19 @@ public class SVGFigure extends Figure {
protected void paintFigure(Graphics graphics) {
super.paintFigure(graphics);
Document document = getDocument();
- if (document != null) {
+ if (document == null) {
+ return;
+ }
+ directRenderingSucceeded = false;
+ if (safeRendering) {
+ paintUsingAWT(graphics, document);
+ } else {
+ // Try to paint directly on provided graphics with fallback to
+ // safe routine.
try {
graphics.pushState();
paintDirectly(graphics, document);
+ directRenderingSucceeded = true;
} catch (RuntimeException e) {
Activator.log(IStatus.INFO, "Failed to paint SVG image directly", e);
graphics.restoreState();
@@ -160,4 +182,17 @@ public class SVGFigure extends Figure {
}
}
}
+
+ public final boolean isDirectRenderingSucceeded() {
+ return directRenderingSucceeded;
+ }
+
+ public final boolean isSafeRendering() {
+ return safeRendering;
+ }
+
+ public void setSafeRendering(boolean safeRendering) {
+ this.safeRendering = safeRendering;
+ repaint();
+ }
}

Back to the top