SVG images no longer show in the GUI
@@ -27,11 +27,11 @@ import org.apache.batik.gvt.GraphicsNode;
import org.apache.batik.util.XMLResourceDescriptor;
import org.apache.hop.core.Const;
import org.apache.hop.core.exception.HopException;
+import org.apache.hop.core.vfs.HopVfs;
import org.w3c.dom.svg.SVGDocument;
import org.w3c.dom.svg.SVGSVGElement;
import java.awt.geom.Rectangle2D;
-import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
@@ -57,11 +57,11 @@ public class SvgCache {
return instance;
}
- public synchronized static SvgCacheEntry findSvg( String filename ) {
+ public static synchronized SvgCacheEntry findSvg(String filename) {
return getInstance().fileDocumentMap.get(filename);
}
- public synchronized static SvgCacheEntry loadSvg( SvgFile svgFile ) throws HopException {
+ public static synchronized SvgCacheEntry loadSvg(SvgFile svgFile) throws HopException {
SvgCacheEntry cacheEntry = findSvg(svgFile.getFilename());
if (cacheEntry != null) {
@@ -73,10 +73,9 @@ public class SvgCache {
SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser);
InputStream svgStream = svgFile.getClassLoader().getResourceAsStream(svgFile.getFilename());
if (svgStream == null) {
-
// Retry on the regular filesystem...
//
- svgStream = new FileInputStream( svgFile.getFilename() );
+ svgStream = HopVfs.getInputStream(svgFile.getFilename());
}
SVGDocument svgDocument = factory.createSVGDocument(svgFile.getFilename(), svgStream);
SVGSVGElement elSVG = svgDocument.getRootElement();
@@ -125,10 +124,18 @@ public class SvgCache {
}
if (width <= 1 || height <= 1) {
- throw new HopException("Couldn't determine width or height of file : "+ svgFile.getFilename());
+ throw new HopException(
+ "Couldn't determine width or height of file : " + svgFile.getFilename());
}
- cacheEntry = new SvgCacheEntry( svgFile.getFilename(), svgDocument, Math.round(width), Math.round(height), Math.round( x ), Math.round( y ) );
+ cacheEntry =
+ new SvgCacheEntry(
+ svgFile.getFilename(),
+ svgDocument,
+ Math.round(width),
+ Math.round(height),
+ Math.round(x),
+ Math.round(y));
getInstance().fileDocumentMap.put(svgFile.getFilename(), cacheEntry);
return cacheEntry;
} catch (Exception e) {
@@ -136,8 +143,10 @@ public class SvgCache {
}
}
- public synchronized static void addSvg( String filename, SVGDocument svgDocument, int width, int height, int x, int y ) {
- getInstance().fileDocumentMap.put( filename, new SvgCacheEntry( filename, svgDocument, width, height, x, y ) );
+ public static synchronized void addSvg(
+ String filename, SVGDocument svgDocument, int width, int height, int x, int y) {
+ getInstance()
+ .fileDocumentMap
+ .put(filename, new SvgCacheEntry(filename, svgDocument, width, height, x, y));
}
-
}
