xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathan wood <jonathanshaww...@gmail.com>
Subject Re: Trying to transform SVG images. What is best method using Batik?
Date Thu, 29 Aug 2013 00:26:23 GMT
Hi Mark,

This line could be the problem.  Does the url perhaps begin with C: and
maybe should be file: instead?


   svgTarget.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href",
this.getOwner().getSHIP().getImageResourceDir()+ File.separator +
image.getFilename()); //SVG File


On Wed, Aug 28, 2013 at 6:20 PM, Mark Riley <
mark.riley@seriousintegrated.com> wrote:

> Sorry for all the mailing list questions. I’m quite new to SVG and Batik
> and feel a bit overwhelmed with all the pieces.****
>
> ** **
>
> I’m trying to figure out the best way to transform SVG Images using the
> Batik Library. Our application would like to use SVG images and resize,
> scale, and rotate images. One current method I am trying is creating a new
> VG document and attaching the SVG I want to modify to it and then
> transforming the new SVG File. I’m not sure if this is the easiest or most
> correct way.****
>
> ** **
>
>             DOMImplementation newSvgTest =
> SVGDOMImplementation.getDOMImplementation();****
>
>             String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;****
>
>             Document newDoc = newSvgTest.createDocument(svgNS, "svg",
> null);****
>
>             ****
>
>             Element root = newDoc.getDocumentElement();****
>
>             root.setAttributeNS(null, "viewBox", "0 0 100 100");****
>
>             ****
>
>             Element svgTarget = newDoc.createElementNS(svgNS, "image");***
> *
>
>             svgTarget.setAttributeNS(null, "x", "0");****
>
>             svgTarget.setAttributeNS(null, "y", "0");****
>
>             svgTarget.setAttributeNS(null, "width", width.toString());****
>
>             svgTarget.setAttributeNS(null, "height", height.toString());**
> **
>
>             svgTarget.setAttributeNS(null, "transform",
> String.format("rotate(45, %f/2, %f/2)", width, height));****
>
>             svgTarget.setAttributeNS("http://www.w3.org/1999/xlink",
> "xlink:href", this.getOwner().getSHIP().getImageResourceDir()+
> File.separator + image.getFilename()); //SVG File****
>
>             ****
>
>             root.appendChild(svgTarget);****
>
> ** **
>
> But when I try to transcode this document all I get is the error:****
>
> ** **
>
>          java.lang.IllegalStateException: Unknown protocol: c****
>
>                 at
> org.apache.felix.framework.URLHandlersStreamHandlerProxy.toExternalForm(URLHandlersStreamHandlerProxy.java:481)
> ****
>
>                 at
> org.apache.felix.framework.URLHandlersStreamHandlerProxy.toExternalForm(URLHandlersStreamHandlerProxy.java:474)
> ****
>
>                 at java.net.URL.toExternalForm(URL.java:921)****
>
>                 at java.net.URL.toString(URL.java:907)****
>
>                 at
> org.apache.felix.framework.URLHandlersStreamHandlerProxy.openConnection(URLHandlersStreamHandlerProxy.java:267)
> ****
>
>                 at java.net.URL.openConnection(URL.java:971)****
>
>                 at
> org.apache.batik.util.ParsedURLData.openStreamInternal(ParsedURLData.java:517)
> ****
>
>                 at
> org.apache.batik.util.ParsedURLData.openStream(ParsedURLData.java:471)****
>
>                 at
> org.apache.batik.util.ParsedURL.openStream(ParsedURL.java:429)****
>
>                 at
> org.apache.batik.bridge.SVGImageElementBridge.openStream(SVGImageElementBridge.java:377)
> ****
>
>                 at
> org.apache.batik.bridge.SVGImageElementBridge.createImageGraphicsNode(SVGImageElementBridge.java:242)
> ****
>
>                 at
> org.apache.batik.bridge.SVGImageElementBridge.buildImageGraphicsNode(SVGImageElementBridge.java:177)
> ****
>
>                 at
> org.apache.batik.bridge.SVGImageElementBridge.createGraphicsNode(SVGImageElementBridge.java:119)
> ****
>
>                 at
> org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:213)*
> ***
>
>                 at
> org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)****
>
>                 at
> org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:82)****
>
>                 at
> org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:208)
> ****
>
>                 at
> org.apache.batik.transcoder.image.ImageTranscoder.transcode(ImageTranscoder.java:92)
> ****
>
>                 at
> org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142)
> ****
>
>                 at
> org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156)
> ****
>
>                 at
> com.seriousintegrated.ship.propertysets.ImagePropertySet.setScaledVectorImage(ImagePropertySet.java:233)
> ****
>
>                 at
> com.seriousintegrated.ship.propertysets.ImagePropertySet.mashImage(ImagePropertySet.java:153)
> ****
>
>                 at
> com.seriousintegrated.ship.propertysets.ImagePropertySet.mash(ImagePropertySet.java:401)
> ****
>
>                 at
> com.seriousintegrated.ship.objects.SHIPObject.mashProperties(SHIPObject.java:960)
> ****
>
>                 at
> com.seriousintegrated.ship.objects.SHIPObject.mash(SHIPObject.java:989)***
> *
>
>                 at
> com.seriousintegrated.ship.objects.SHIPObject.mash(SHIPObject.java:1005)**
> **
>
>                 at
> com.seriousintegrated.ship.objects.DryLandObject.mash(DryLandObject.java:101)
> ****
>
> [catch] at com.seriousintegrated.ship.base.SHIP.mash(SHIP.java:414)****
>
>                 at
> com.seriousintegrated.ship.tide.settings.project.MashWorker.doInBackground(MashWorker.java:46)
> ****
>
>                 at
> com.seriousintegrated.ship.tide.settings.project.MashWorker.doInBackground(MashWorker.java:25)
> ****
>
>                 at javax.swing.SwingWorker$1.call(SwingWorker.java:296)***
> *
>
>                 at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)****
>
>                 at java.util.concurrent.FutureTask.run(FutureTask.java:166)
> ****
>
>                 at javax.swing.SwingWorker.run(SwingWorker.java:335)****
>
>                 at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> ****
>
>                 at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> ****
>
>                 at java.lang.Thread.run(Thread.java:724)****
>
> ** **
>
> Thanks,****
>
> Mark****
>

Mime
View raw message