Re: Trying to transform SVG images. What is best method using Batik?

2013-08-28 Thread jonathan wood
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.ri...@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
 

Re: SVG BufferedImage Quality

2013-08-27 Thread jonathan wood
Hi Mark,

  As far as I know, ImageTranscoder does not supply specific antialias
hints.  Maybe you can try a shape-rendering attribute on the svg?

http://www.w3.org/TR/SVG/painting.html#ShapeRenderingProperty




On Tue, Aug 27, 2013 at 6:27 PM, Mark Riley 
mark.ri...@seriousintegrated.com wrote:

 I’m still struggling to figure out a way to improve the quality of my SVG
 images in Batik.

 ** **

 It seems this maybe an Antialiasing issue? I can’t seem to find a
 transcoder hint that will improve this.

 ** **

 Thanks,

 Mark

 ** **

 *From:* Mark Riley [mailto:mark.ri...@seriousintegrated.com]
 *Sent:* Friday, August 23, 2013 2:41 PM
 *To:* batik-users@xmlgraphics.apache.org
 *Subject:* SVG BufferedImage Quality

 ** **

 I have a question about how to improve the quality of the images I’m
 generating for buffered images. 

 ** **

 

 ** **

 The left image is the image I generated with Batik while the right is the
 original. How do I generate a Buffered Image of the same quality? My code
 currently looks like this:

 ** **

 Float width;

 Float height;

 ** **

 try {

 ByteArrayOutputStream baos = new ByteArrayOutputStream();

 byte[] buf = new byte[image.getStream().available()];

 int n = 0;

 while ((n = image.getStream().read(buf)) = 0) {

 baos.write(buf, 0, n);

 }

 byte[] content = baos.toByteArray();

 ** **

 ** **

 String parser = XMLResourceDescriptor.getXMLParserClassName();
 

 SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);**
 **

 Document doc = f.createDocument(image.getFilename(), new
 ByteArrayInputStream(content));

 Element element = doc.getDocumentElement();

 if (element.hasAttributeNS(null, viewBox)) {

 String[] parts = element.getAttribute(viewBox).split(\\
 );

 width = new Float(parts[2]);

 height = new Float(parts[3]);

 } else if (element.hasAttributeNS(null, height) 
 element.hasAttributeNS(null, width)) {

 height = new Float(element.getAttributeNS(null, height));
 

 width = new Float(element.getAttributeNS(null, width));*
 ***

 } else {

 width = new Float(100);

 height = new Float(100);

 }

 ** **

 ShipTranscoder transcoder = new ShipTranscoder();

 TranscodingHints hints = new TranscodingHints();

 DOMImplementation impl =
 SVGDOMImplementation.getDOMImplementation();

 hints.put(ImageTranscoder.KEY_WIDTH, width);

 hints.put(ImageTranscoder.KEY_HEIGHT, height);

 hints.put(ImageTranscoder.KEY_DOM_IMPLEMENTATION, impl);

 hints.put(ImageTranscoder.KEY_DOCUMENT_ELEMENT_NAMESPACE_URI,
 SVGConstants.SVG_NAMESPACE_URI);

 hints.put(ImageTranscoder.KEY_DOCUMENT_ELEMENT_NAMESPACE_URI,
 SVGConstants.SVG_NAMESPACE_URI);

 hints.put(ImageTranscoder.KEY_DOCUMENT_ELEMENT,
 SVGConstants.SVG_SVG_TAG);

 hints.put(ImageTranscoder.KEY_XML_PARSER_VALIDATING, false);**
 **

 transcoder.setTranscodingHints(hints);

 transcoder.transcode(new TranscoderInput(new
 ByteArrayInputStream(content)), null);

 image.setImage(transcoder.getImage());

 ** **

 } catch (Throwable e) {

 Exceptions.printStackTrace(e);

 String error = Invalid input stream for SVG file type.;

 setError(SHIPPROPKEY.IMAGE_SOURCEFILE, error);

 LOGGER.log(Level.SEVERE, {0}\n, error);

 throw new MashException(getClass().getSimpleName()

 }

 ** **

 class ShipTranscoder extends ImageTranscoder {

 ** **

 private BufferedImage image = null;

 ** **

 @Override

 public BufferedImage createImage(int w, int h) {

 image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);*
 ***

 return image;

 }

 ** **

 @Override

 public void writeImage(BufferedImage img, TranscoderOutput out) {*
 ***

 }

 ** **

 public BufferedImage getImage() {

 return image;

 }

 }

 ** **

 Thanks,

 Mark

image001.png

Re: Adding links to a document

2013-08-08 Thread jonathan wood
This prob won't compile, and some methods may be misnamed, but it should be
close in spirit!

note that you need to use the xlink namespace for the xlink:href attribute
as shown below.  Since a node can only be in one place I chose to use the
shorcut of adding n to a and letting the dom remove it from n.parent.


hope it helps

...

SVGElement a = null;
for(int i=0;ilabels.getLength();i++) {
  n = labels.item(i);
  log.info(A label:+n.getFirstChild().**getNodeValue());
  //presumably, replace n with a link element that contains n?
  a = document.createElementNS(SVGNAMESPACE, a);
  a.setAttributeNS(XLINKNAMESPACE, xlink;href, my_special_url);
  n.getParentNode().appendChild(a);
  a.appendChild(n);
}
...


On Thu, Aug 8, 2013 at 6:25 PM, James Burton j.bur...@brighton.ac.ukwrote:

 I'm new to using batik, and I want to turn all text elements in an
 SVGDocument into links which pass the text to a callback. Can you point me
 to an example of something similar? I'm finding the text elements like this:

 SVGDocument doc = ...
 Element svgRoot = doc.getDocumentElement();
 NodeList labels = svgRoot.**getElementsByTagNameNS(*, text);
 Node n;
 for(int i=0;ilabels.getLength();i++) {
   n = labels.item(i);
   log.info(A label:+n.getFirstChild().**getNodeValue());
   //presumably, replace n with a link element that contains n?
 }

 Thanks in advance,

 Jim

 __**_
 This email has been scanned by MessageLabs' Email Security
 System on behalf of the University of Brighton.
 For more information see 
 http://www.brighton.ac.uk/is/**spam/http://www.brighton.ac.uk/is/spam/
 __**_

 --**--**-
 To unsubscribe, e-mail: 
 batik-users-unsubscribe@**xmlgraphics.apache.orgbatik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: 
 batik-users-help@xmlgraphics.**apache.orgbatik-users-h...@xmlgraphics.apache.org




Re: Bounding Box (getBBox())

2013-04-29 Thread jonathan wood
Hi Andy,

   Yes you can obtain a valid bbox in a headless environment.  You'll need
to boot the svg and dom css.

http://wiki.apache.org/xmlgraphics-batik/BootSvgAndCssDom




On Mon, Apr 29, 2013 at 11:22 AM, Andy Fendley a...@fendley.com wrote:

 Hi all,

 I have a question regarding using Batik in a headless environment.

 Regarding the [getBBox()   ]  method and a piece of text within an SVG
 document that is NOT rendered and is in a headless environment such as a
 web application, is there any way, knowing the text point size and having
 the font (ttf) available to determine this bounding box using the batik
 software?

 We have an [ SVGDocument ] in memory and thats it.

 Many thanks for any response in advance, and Batik is working superbly
 well for us.

 Andy



 Andy Fendley BEng (Hons) MSc
 _

 *Software Consultant*

 LinkedIN: profile http://uk.linkedin.com/pub/andy-fendley/6/2/802
 _

 skype andrewfendley
 twitter @andyfendley
 mobile +44 (0) 7590 726426
 __




Re: When is the UpdateManager definitely available?

2012-11-02 Thread jonathan wood
Hi Marco,

  I use a slightly different overload:

canvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
@Override
public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
// do stuff
}
});


On Fri, Nov 2, 2012 at 9:53 AM, Marco Herrn m...@mherrn.de wrote:

 Hi,

 I must push this mail again.
 It now happened again multiple times to me, that the the method
 canvas.getUpdataManager() returned null when the gvgTreeRenderer completed.
 It happens seldom, but it does happen.

 Please see again the code snipped in the quoted text.

 Is it a bug in batik? According to the javadoc of the getUpdateManager()
 method I would expect that it is guaranteed that getUpdateManager() won't
 return null when being called after being informed of rendering completion.

 Any help appreciated.
 Regards
 Marco


 On Fri, Jul 20, 2012 at 03:38:45PM +0200, m...@mherrn.de wrote:
  Hi I am using the following code:
 
  canvas.addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
  @Override
  public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
 
 canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(runnable);
  }
});
 
  to do some changes in the DOM of an SVG document. I expected that the
  updatemanager is definitely available when gvtRenderingCompleted was
  called.
  However, it now happened at least once that I got a NullPointerException
  on the line
 
 canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(runnable);
 
  So it seems that there is still no guarantee that the UpdateManager is
  available then. Am I missing something? Must I register on a different
  listener?

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: getBBox() returns null

2012-09-27 Thread jonathan wood
If you are using JSVGCanvas, make sure you set the document state:

canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
*
*
*
*If not using canvas, you'll need to boot the dom:

http://wiki.apache.org/xmlgraphics-batik/BootSvgAndCssDom



On Thu, Sep 27, 2012 at 8:47 AM, fireball samiib...@hotmail.com wrote:

 I have svg as shown below. Whenever I load this svg and try to get BBox of
 its text it returns null. How to properly get the BBox?

 Element eltText = document.getElementById(id3);
 SVGRect svgRect = ((SVGOMTextElement)eltText).getBBox(); -- returns null


 svg
xmlns=http://www.w3.org/2000/svg;
version=1.1
id=id
   g
  id=id1
  transform=matrix(1,0,0,1,0,0)
 rect
id=id2
width=10
height=10
fill=none
stroke=#ff/
 text
id=id3
x=10
y=10
font-style=normal
text-decoration=none
font-weight=normal
font-size=12
font-family=none
fill=red
text/text
   /g
 /svg



 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/getBBox-returns-null-tp4655273.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: getBBox() returns null

2012-09-27 Thread jonathan wood
I'd also advise the changes be made in a single runnable as Thomas
suggested.  If you want a proof of concept for that, I'd point to some
rather old, but potentially useful code I wrote awhile ago...seems to be
doing something similar to what you want...look towards the end of the
conversation for the inlined example:

http://batik.2283329.n4.nabble.com/Status-of-FlowRoot-Overflow-Detection-td2979431.html


On Thu, Sep 27, 2012 at 6:04 PM, DeWeese Thomas thomas.dewe...@gmail.comwrote:

 Hi fireball,
 I suggest that you add the content and then set the properties.

 Otherwise the result of getBBox may well be wrong. There are many
 properties that affect how text is rendered that will be inherited where
 the element is inserted in the document, so any calculation you make
 outside of it's final place in the document has a decent chance of being
 wrong.
 If you add it and set the properties in one Runnable (sent to the
 UpdateManager's RunnableQueue) then it won't be rendered until your
 runnable exits.

 If you really need to do this outside of the document (and I
 strong recommend against it in general) you can check out the link Jonathan
 gave for booting the SVG  CSS Dom.  However once again I must point out
 that for that to give you useful results the CSS context must be the same
 as where it will eventually be inserted into the document.

 Thomas

 On Sep 27, 2012, at 10:16 AM, fireball samiib...@hotmail.com wrote:

  I think I might know what is happening. Correct me if I am wrong.
 
  The BBox is computed after the text is rendered. And my understanding of
  rendering is that it happens when the text element is added to the
 canvas.
 
  What I am trying to do here is load an SVG file into a document, set some
  properties and then add it into the canvas. Since I am trying to set
  properties before adding to canvas, BBox is not computed yet.
 
  Is there a way to do that before adding to canvas?
 
 
 
  --
  View this message in context:
 http://batik.2283329.n4.nabble.com/getBBox-returns-null-tp4655273p4655276.html
  Sent from the Batik - Users mailing list archive at Nabble.com.
 
  -
  To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
  For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org
 


 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: How to create a Bar-Graph or Chart using Batik?

2012-09-25 Thread jonathan wood
Hi Arihant,

  There is not a specific api in batik for charts/graphs, but since you
have full control of the svg, it can be easily accomplished.

Check out the demo applet for an example of a bar chart:

http://xmlgraphics.apache.org/batik/demo.html



On Tue, Sep 25, 2012 at 4:05 AM, arihant_ba...@amat.com wrote:

  Hi,

 ** **

 Am a new user of Batik Tool-Kit  I wish to create a Graph or Chart object
 with X-Y axis, axis labels, legends panel?

 ** **

 Is there any class within the tool-kit for the same?

 ** **

 Regards,
 Arihant Bapna

 

 ** **



Re: SVG Marker issue with batik.

2012-09-20 Thread jonathan wood
Hi Fireball,

  I believe you may be seeing an error on the javadoc build. On a fresh
checkout I see the problem there.  A target of jars or all-jar works for me.



On Thu, Sep 20, 2012 at 10:47 AM, fireball samiib...@hotmail.com wrote:

 Thanks Jonathan.

 I grabbed the source code from Batik's website. I ran 'build.bat compile'.
 I
 have compilation errors and warnings. I tried it with Xlint:unchecked and
 not much info.

 Most of errors are about missing packages such as
 'com.sun.image.codec.jped'.

 Any ideas?



 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/SVG-Marker-issue-with-batik-tp2979528p4655259.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: SVG Marker issue with batik.

2012-09-20 Thread jonathan wood
Interesting.  For the record, my output after a fresh checkout is below.
 Although not a normal thing, I can help you get the 1.8pre distro to help
continue your development.  Let's not drop this topic though as any build
issues should be resolved or result in a defect report.  Contact me
directly via email if you want to arrange dropbox or otherwise.

As advertised, my output:

 U   batik
Checked out revision 1388115.
[jwood@localhost scratch]$ cd batik/
[jwood@localhost batik]$ sh build.sh jars
Buildfile: build.xml

init:
 == Apache Batik 1.8pre build file 

JAVA_HOME: /usr/lib/jvm/java/
VM:23.2-b09, Oracle Corporation

compile-prepare:
Created dir: /home/jwood/scratch/batik/classes
debug off, optimize on, deprecation on

compile:
Compiling 1444 source files to /home/jwood/scratch/batik/classes
/home/jwood/scratch/batik/sources/org/apache/batik/apps/rasterizer/SVGConverter.java:884:
warning: [deprecation] toURL() in File has been deprecated
URL userDir = new
File(System.getProperty(user.dir)).toURL();
  ^
/home/jwood/scratch/batik/sources/org/apache/batik/apps/rasterizer/SVGConverterFileSource.java:64:
warning: [deprecation] toURL() in File has been deprecated
String uri = file.toURL().toString();
 ^
/home/jwood/scratch/batik/sources/org/apache/batik/apps/slideshow/Main.java:132:
warning: [deprecation] toURL() in File has been deprecated
String fileName = files[ i ].toURL().toString();
^
/home/jwood/scratch/batik/sources/org/apache/batik/apps/slideshow/Main.java:310:
warning: [deprecation] toURL() in File has been deprecated
URL flURL = new File(file).toURL();
  ^
/home/jwood/scratch/batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java:1258:
warning: [deprecation] toURL() in File has been deprecated
String furl = f.toURL().toString();
   ^
/home/jwood/scratch/batik/sources/org/apache/batik/apps/svgbrowser/Main.java:518:
warning: [deprecation] toURL() in File has been deprecated
   policyFile.toURL().toString());
 ^
/home/jwood/scratch/batik/sources/org/apache/batik/apps/svgbrowser/Main.java:550:
warning: [deprecation] toURL() in File has been deprecated
uri = file.toURL().toString();
  ^
/home/jwood/scratch/batik/sources/org/apache/batik/apps/svgbrowser/Main.java:849:
warning: [deprecation] toURL() in File has been deprecated
return f.toURL().toString();
^
/home/jwood/scratch/batik/sources/org/apache/batik/apps/svgbrowser/Main.java:963:
warning: [deprecation] encode(String) in URLEncoder has been deprecated
(URLEncoder.encode(lastVisited.get(i).toString()));
   ^
/home/jwood/scratch/batik/sources/org/apache/batik/apps/svgbrowser/Main.java:1016:
warning: [deprecation] decode(String) in URLDecoder has been deprecated
lastVisited.addElement(URLDecoder.decode(st.nextToken()));
 ^
/home/jwood/scratch/batik/sources/org/apache/batik/svggen/AbstractImageHandlerEncoder.java:122:
warning: [deprecation] toURL() in File has been deprecated
this.urlRoot = imageDirFile.toURL().toString();
   ^
/home/jwood/scratch/batik/sources/org/apache/batik/transcoder/print/PrintTranscoder.java:785:
warning: [deprecation] toURL() in File has been deprecated
transcoder.transcode(new TranscoderInput(new
File(args[i]).toURL().toString()),
  ^
/home/jwood/scratch/batik/sources/org/apache/batik/transcoder/wmf/tosvg/WMFTranscoder.java:262:
warning: [deprecation] toURL() in File has been deprecated
TranscoderInput input = new
TranscoderInput(inputFile.toURL().toString());
 ^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
13 warnings

determine-svn-revision-svn-info:

determine-svn-revision-transform:

determine-svn-revision-from-file:

determine-svn-revision-set:
Deleting: /home/jwood/scratch/batik/svn-info.xml

determine-svn-revision:

prepare-build:
Created dir: /home/jwood/scratch/batik/batik-1.8pre
Created dir: /home/jwood/scratch/batik/batik-1.8pre/docs
Created dir: /home/jwood/scratch/batik/batik-1.8pre/lib

ext-jar:
Building jar: /home/jwood/scratch/batik/batik-1.8pre/lib/batik-ext.jar

util-jar:
Building jar: /home/jwood/scratch/batik/batik-1.8pre/lib/batik-util.jar

awt-util-jar:
Building jar: 

Re: SVG Marker issue with batik.

2012-09-19 Thread jonathan wood
Hi Fireball,

  You'll need to check out the source and build yourself.  This should get
you started.  Run the build script once you have pulled the code and it
will give you the available build targets.

http://xmlgraphics.apache.org/batik/download.cgi#Subversion+repository


On Wed, Sep 19, 2012 at 11:28 AM, fireball samiib...@hotmail.com wrote:

 This fix seems to be old but I cannot find it in Batik 1.7. How do I get
 this
 fix?

 fireball.



 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/SVG-Marker-issue-with-batik-tp2979528p4655255.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: How to render embedded png?

2012-09-14 Thread jonathan wood
Great news!  I have to admit that after I reproduced the problem, I was a
bit stumped.  Nice work

jonathan

On Fri, Sep 14, 2012 at 12:10 PM, ali can alican1...@hotmail.com wrote:

 The problem is solved. For the sake of others who may encounter it, the
 culprit was missing batik-codec.jar and js.jar. When they were added, all
 started to work as expected.
 Thanks, Thomas and Jonathan



 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/How-to-render-embedded-png-tp4655236p4655251.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: How to render embedded png?

2012-09-12 Thread jonathan wood
You may be accessing the document before the gvt builder is complete... try
adding a listener and then loading the doc. Begin your work when the
listener is called...


canvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
@Override
public void gvtBuildCompleted(GVTTreeBuilderEvent e) {

  // do stuff here

}
});

On Wed, Sep 12, 2012 at 6:45 PM, Thomas DeWeese
thomas.dewe...@gmail.com wrote:

Hi Ali,
 Hmm, I think we misunderstood.  You have an SVG document and you
 can view most of it in the JSVGCanvas but the embedded png's don't show up.
 In that case I think you need to send a sample document that shows the
 problem for you because they should just show up (there are examples
 included in batik like 'sample/tests/spec/structure/dataProtocol.svg'.

 Thomas

 On Sep 12, 2012, at 12:11 PM, ali can wrote:

  Please excuse my ignorance but I really cannot get a grip of this. Here
 is my
  code, I can see svg, but no embed image. What is wrong?
  Thanks
 
 canvas = new JSVGCanvas();
 getContentPane().add(canvas);
 
 userAgent = new UserAgentAdapter();
 ctx   = new BridgeContext(userAgent);
 builder   = new GVTBuilder();
 try {
 // Parse the barChart.svg file into a Document.
 String parser = XMLResourceDescriptor.getXMLParserClassName();
 SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
 URL url = new URL(getCodeBase(), embedData.svg);
 doc = f.createDocument(url.toString());
 
 svg = doc.getDocumentElement();
 
 
 NodeList l =
 svg.getElementsByTagName(image) ;
 for (int i = 0; i  l.getLength(); i++)
 {
 Element n = (Element)l.item(i)   ;
 String image =
 n.getAttributeNS(XMLConstants.XLINK_NAMESPACE_URI,
  href);
 String t = n.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
 int width = Integer.parseInt(t);
 int height = Integer.parseInt(n.getAttributeNS(null,
  SVG_HEIGHT_ATTRIBUTE));
 String id = image + Integer.toString(i);
 
 // Create and initialize the new image element
 Element imageElement =
  doc.createElementNS(SVG_NAMESPACE_URI,
 SVG_IMAGE_TAG);
 imageElement.setAttributeNS(null,
  XMLConstants.XML_ID_ATTRIBUTE,
 id);
 imageElement.setAttributeNS(null, SVG_WIDTH_ATTRIBUTE,
 Integer.toString(width));
 imageElement.setAttributeNS(null, SVG_HEIGHT_ATTRIBUTE,
 Integer.toString(height));
 
  imageElement.setAttributeNS(XMLConstants.XLINK_NAMESPACE_URI,
  XMLConstants.XLINK_HREF_QNAME,
 data::image/PNG;base64, +
  base64Encode(image.getBytes()));
 doc.appendChild(imageElement);
 svg.removeChild(n);
 }
 } catch (Exception ex) {
 }
 
 
 
 
 
  --
  View this message in context:
 http://batik.2283329.n4.nabble.com/How-to-render-embedded-png-tp4655236p4655244.html
  Sent from the Batik - Users mailing list archive at Nabble.com.
 
  -
  To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
  For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org
 


 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: How to render embedded png?

2012-09-07 Thread jonathan wood
I've had success using the following:

http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/util/Base64EncoderStream.html

snippet that I use:

...
element.setAttributeNS(SVGConstants.XLINK_NAMESPACE_URI,
SVGConstants.XLINK_HREF_QNAME,
data:;base64, +
base64Encode(myimagebytearray);

...

private String base64Encode(final byte[] data) {
ByteArrayOutputStream b64out = new ByteArrayOutputStream();
Base64EncoderStream enc = new Base64EncoderStream(b64out);
try {
enc.write(data);
} catch (IOException ex) {
logger.error(null, ex);
} finally {
if (null != enc) {
try {
enc.close();
} catch (IOException ex) {
logger.error(null, ex);
}
}
}
return b64out.toString();
}


Hope this helps


On Fri, Sep 7, 2012 at 4:39 AM, ali can alican1...@hotmail.com wrote:

 I have an SVG file with an embed image(data:image protocol, png format). I
 am
 not able to find how to render this SVG file correctly. Is there a simple
 example/tutorial on how to render embed images using batik?



 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/How-to-render-embedded-png-tp4655236.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Broken image

2012-08-17 Thread jonathan wood
Hi fireball,

  You may not be resolving the url properly - You may need to call
SVGOMDocument.setDocumentURI()
or set the xml:base attribute in the svg document.



On Fri, Aug 17, 2012 at 12:11 PM, fireball samiib...@hotmail.com wrote:

 I am trying to load an svg which has a link to an image. The reslut is a
 broken image.

 My loading into canvas and the broken image is very similar to
 http://batik.2283329.n4.nabble.com/Broken-image-embedded-PNG-td3962524.html
 http://batik.2283329.n4.nabble.com/Broken-image-embedded-PNG-td3962524.html

 Note that the image resides in the same directory where the SVG file is.

 My SVG:
 svg
xmlns=http://www.w3.org/2000/svg;
xmlns:xlink=http://www.w3.org/1999/xlink;
version=1.1
   g
  id=image
  transform=matrix(1,0,0,1,0,0)
  image width=200 height=180 xlink:href=image.png/
   /g
 /svg



 When loaded it becomes:
 ...
 g id=image transform=matrix(1, 0, 0, 1, 0,0)
 image width=200 xmlns:xlink=http://www.w3.org/1999/xlink;
 xlink:href=image.png xlink:type=simple xlink:actuate=onLoad
 height=180 preserveAspectRatio=xMidYMid meet xlink:show=embed/
 /g
 ...

 Any thoughts of how to resolve this issue?



 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/Broken-image-tp4655209.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Read/Write transform values

2012-08-13 Thread jonathan wood
On Mon, Aug 13, 2012 at 11:42 AM, fireball samiib...@hotmail.com wrote:

 Thanks! Jonathan.

 This makes things much cleaner and easier to deal with.

 The only thing is rotation. It does not sound straight forward like the
 other values (translate, shear, scale).

 Is there a simple way to set/get rotate value?
 I tried something like this for setting it but it did not work:

 String strTransform = elt.getAttributeNS(null,
 SVGConstants.SVG_TRANSFORM_ATTRIBUTE);
 TransformListParser p = new TransformListParser();
 AWTTransformProducer tp = new AWTTransformProducer();
 p.setTransformListHandler(tp);
 p.parse(strTransform);
 AffineTransform at = tp.getAffineTransform();
 at.rotate(Math.toRadians(Double.valueOf(rotateAngle)));



 This looks correctdid you also replace your original transform with
this one?

Something like this:

...
el.setAttributeNS(null, SVGConstants.SVG_TRANSFORM_ATTRIBUTE,
affineTransformToString(at));


public String affineTransformToString(final AffineTransform at) {
double[] matrix = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
at.getMatrix(matrix);
return matrixArrayToString(matrix);
}

public String matrixArrayToString(double[] vals) {
return new StringBuilder(matrix().append(vals[0]).append(
).append(vals[1]).append( ).append(vals[2]).append(
).append(vals[3]).append( ).append(vals[4]).append(
).append(vals[5]).append() ).toString();
}



 For getting it I had to parse the transform string myself to get rotate
 value.

 Note that my transform is like this: transform=matrix(a,b,c,d,e,f)
 rotate(angle). Should rotate be part of the matrix?


both are correct.  I tend to use matrix only because of
 TransformListParser/AffineTransform, but that does not mean you can't
concat multiple matrices, or explicit transforms like rotate/scale...



 Any thoughts?



 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/Read-Write-transform-values-tp4655190p4655199.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Importing nodes

2012-08-13 Thread jonathan wood
for (int el = 0; el  numberOfNewElements; el++) {
Node anElement = doc2Elements.item(el);
Node copyNode = doc1.importNode(anElement, true);
 //   doc1Root.appendChild(copyNode);
doc1.getElementById(group1).appendChild(copyNode);
}

On Mon, Aug 13, 2012 at 3:29 PM, fireball samiib...@hotmail.com wrote:

 Let's say I have two documents:

 document 1:
 svg
   g id=group1
  ...
   /g
 /svg

 and

 document 2:
 svg
   g id=group2
  ...
   /g
 /svg

 If I want to import doc 2 into doc 1 I do something like this:

 Element doc1Root = doc1.getDocumentElement();
 Element doc2Root = doc2.getDocumentElement();

 NodeList doc2Elements = doc2Root.getChildNodes();
 int numberOfNewElements = doc2Elements.getLength();
 for (int el = 0; el  numberOfNewElements; el++) {
 Node anElement = doc2Elements.item(el);
 Node copyNode = doc1.importNode(anElement, true);
 doc1Root.appendChild(copyNode);
 }


 This results in two groups within doc1:
 svg
   g id=group1
  ...
   /g
   g id=group2
  ...
   /g
 /svg

 Now my question is, how do we import this doc2 into group1 of doc1. I.e.
 something like:
 svg
   g id=group1
  ...
  g id=group2
  ...
  /g
   /g
 /svg



 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/Importing-nodes-tp4655201.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Read/Write transform values

2012-08-10 Thread jonathan wood
Batik contains a lot of useful parsers for just such purposes...

http://xmlgraphics.apache.org/batik/using/parsers.html

with the TransformListParser you can produce an AffineTransform

   AffineTransform at = null;
TransformListParser tlp = new TransformListParser();
AWTTransformProducer atp = new AWTTransformProducer();
tlp.setTransformListHandler(atp);
tlp.parse(el.getAttributeNS(null,
SVGConstants.SVG_TRANSFORM_ATTRIBUTE));
at = atp.getAffineTransform();




On Fri, Aug 10, 2012 at 3:43 PM, fireball samiib...@hotmail.com wrote:

 Maybe this has been discussed before but I could not find one article that
 explains it.

 I am trying to figure out the proper way to read/write element's transform
 values. I.e. X, Y, Scale,
 Rotate, etc..

 Below is a few things I have tried. Sometimes they work and sometimes they
 don't. And I am not sure which way is correct.

 Please point me in the right direction.

 Thanks,

 fireball.



 Read
 --
 - X value:


 ((SVGOMGElement)elt).getTransform().getBaseVal().getItem(0).getMatrix().getE();
 or
 ((SVGLocatable)elt).getScreenCTM().getE();


 Write
 --
 - X value:

 elt.setAttributeNS(null, transform, matrix( + a + ,0,0, + d + , + e
 + ,
  + f + ));
 or
 ((SVGLocatable)elt).getScreenCTM().setE(e);



 - Rotation angle:


 ((SVGOMGElement)elt).getTransform().getBaseVal().getItem(0).setRotate(Float.valueOf(rotate),
 Float.valueOf(0), Float.valueOf(0));
 or
 ((SVGLocatable)elt).getScreenCTM().rotate(Float.valueOf(45));

 In the above we are setting the rotate value but how do we get(read) it?



 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/Read-Write-transform-values-tp4655190.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Issue with dragging shapes

2012-08-04 Thread jonathan wood
I've found it best to handle mousedown on the element being dragged, then
track all mm/mu on a glasspane above the elements to be dragged.

here's a very simple example in svg:

?xml version=1.0 encoding=UTF-8 standalone=no ?
svg version=1.1 width=100% height=100% xmlns=
http://www.w3.org/2000/svg; onload=init() pointer-events=all
script type=text/ecmascript
![CDATA[
var drag = false;
var svg;
var draggable;

function init(e) {
svg = document.documentElement;
var rect = document.getElementById(draggable);
rect.addEventListener(mousedown, md, false);
svg.addEventListener(mousemove, mm, false);
svg.addEventListener(mouseup, mu, false);
}

function md(e) {
drag = true;
draggable = e.currentTarget;
}

function mu(e) {
drag = false;
}

function mm(e) {
if (drag) {
var p = getPoint(e);
var m = svg.createSVGMatrix().translate(p.x, p.y);
var transform = matrix( + m.a +   + m.b +   + m.c + 
 + m.d +   + m.e +   + m.f + );
draggable.setAttributeNS(null, transform, transform);
}
}

function getPoint(e) {
var p = svg.createSVGPoint();
p.x = e.clientX;
p.y = e.clientY;
p = p.matrixTransform(svg.getScreenCTM().inverse());
return p;
}
]]
/script
rect id=background x=0 y=0 width=100% height=100%
fill=#BBB stroke=#000 /
rect id=draggable x=0 y=0 height=100 width=100
fill=cornflowerblue/
/svg

On Sat, Aug 4, 2012 at 11:48 AM, fireball samiib...@hotmail.com wrote:

 I have two issues actually, one major and one minor.

 Major: I can't drag shapes over others. I have to drag them around for it
 to
 work. Note that when I go back to the shape, the handle is still there and
 the shape will continue moving without re-clicking.
 Does it have to do with the way I add shapes to the DOM document or the way
 I handle the dragging, or is it both, or is it something else?

 Minor: Moving mouse too fast after a mousedown loses the shape (shape stops
 moving) but when I go back to it the handle is still there and the shape
 keeps moving with the mouse without re-clicking on it. Same behaviour as in
 the major case above. What would be the cause?

 I register a handler object which listens to mousedown, mousemove, and
 mouseup for any object that is draggable. I do keep track of initial points
 to re-adjust the position. Something similar to
 http://wiki.apache.org/xmlgraphics-batik/DragTutorial

 Please let me know if you need to see any code for more info.

 Thanks,

 fireball.



 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/Issue-with-dragging-shapes-tp4655175.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: receiving error rendering Corel file

2012-03-22 Thread jonathan wood
It really depends on what you want to do ...

- You could remove the offending tags via a preprocess step using xslt or
the like.  That assumes the tag is of no value to the rasterizing process.
http://xml.apache.org/xalan-j/commandline.html is a starting place

- You might consider extending Batik to handle the custom elements
http://xmlgraphics.apache.org/batik/using/extending.html#customXMLTags

- If you can control the svg output you might look to produce a spec
compliant document using metadata. Here's an rdf sample from the spec:
http://www.w3.org/TR/SVG11/metadata.html#Example



On Thu, Mar 22, 2012 at 5:23 PM, Lyman lh...@capaxglobal.com wrote:

 Hi.  Thanks for the responses.  I should add some more context.  I am
 working
 with a digital asset management system on behalf of a customer.  The SVG
 file was generated by Corel Draw programmatically.  I know that they
 accomplish the export via a VBA macro.  I can ask them if Corel gives any
 options as to the export.

 I am, of course, having worked for years in digital asset management
 surprised to hear that a vendor would use a non-standard feature :-).  I
 did
 note that IE was able to interpret the file.

 Is it possible that there is a known extensible to Batik that would know
 how
 to handle tags like this?

 Cheers,

 Lyman

 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/receiving-error-rendering-Corel-file-tp4489899p4496951.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: receiving error rendering Corel file

2012-03-20 Thread jonathan wood
A couple of things I noted while reading your post:

The transcoder is trying to create an a tag/element named odm in the svg
namespace, which does not exist.  Maybe you need an additional namespace in
your doc to help resolve this tag?

The doctype MAY be problematic, but does not appear to be at the heart of
the issue IMHO.
-- read this for the rationale behind dropping  svg/doctype:
https://jwatt.org/svg/authoring/#doctype-declaration

I don't think your classpath is an issue at the moment.  The raterizer
appears to behaving normally, although it is having issues rendering
because of missing info.

Can you provide a more complete svg example?


On Tue, Mar 20, 2012 at 2:12 PM, Lyman Hurd lh...@capaxglobal.com wrote:

  I am running the latest version of Batik and when I run the command line:



 java -jar batik-rasterizer.jar mytest.svg -m image/jpeg -q .99 -maxw 512
 -maxh 512





 About to transcode 1 SVG file(s)



 Converting mytest.svg to mytest.jpg ...
 org.apache.batik.transcoder.TranscoderEx

 ception: null

 Enclosed Exception:

 The current document is unable to create an element of the requested type
 (names

 pace: http://www.w3.org/2000/svg, name: odm).

 at
 org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstra

 ctTranscoder.java:134)

 at
 org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstra

 ctTranscoder.java:156)

 at
 org.apache.batik.apps.rasterizer.SVGConverter.transcode(SVGConverter.

 java:1001)

 at
 org.apache.batik.apps.rasterizer.SVGConverter.execute(SVGConverter.ja

 va:717)

 at org.apache.batik.apps.rasterizer.Main.execute(Main.java:938)

 at org.apache.batik.apps.rasterizer.Main.main(Main.java:992)

 ... error (SVGConverter.error.while.rasterizing.file)



 The file does render in IE and when I read the header I see that it
 appears to reference the SVG 1.1 standard (in poking around I read comments
 about the use of 1.2 features not being supported in Batik).



 ?xml version=1.0 encoding=UTF-8?

 !DOCTYPE svg PUBLIC -//W3C//DTD SVG 1.1//EN 
 http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd;

 !-- Creator: CorelDRAW X5 --



 I am using a binary distribution and I read some discussion but that not
 natively supporting extensions.  Is this something I need to consider?  I
 moved the file batik-rasterizer-ext.jar to the current directory to ensure
 it was in the classpath but that had no effect.



 Thanks for any guidance.



 Cheers,



 Lyman


  The information contained in this message is for the intended addressee
 only and may contain confidential and/or privileged information. If you are
 not the intended addressee, please delete this message and notify the
 sender, and do not copy or distribute this message or disclose its contents
 to anyone. Any views or opinions expressed in this message are those of the
 author and do not necessarily represent those of Capax Global LLC or of any
 of its associated companies. No reliance may be placed on this message
 without written confirmation from an authorised representative of the
 company. Capax Global LLC, Registered Office: 10 Sylvan Way, Parsippany, NJ
 07054 USA.



Re: PDFTranscoder is producing 0byte file

2012-02-07 Thread jonathan wood
Adding a background gives me some contrast and makes it readable...the
alignment does not look as expected though...looks like the character width
is not being respected on conversion...manually changing the font to
monospaced helps alot, but is not a complete fix

here's my invocation:

java -jar src/batik/trunk/batik-1.8pre/batik-rasterizer.jar
~/Downloads/pastie-3329528.svg -bg 255.255.255.255


On Tue, Feb 7, 2012 at 4:16 AM, mmoorman mmoor...@uos.de wrote:

 Hi,

 I've profiled the application and used HeapSpace is always below the
 allowed
 one. Also specifying a region doesn't result in a real pdf. It's still
 0byte.
 Other advices?

 Markus

 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/PDFTranscoder-is-producing-0byte-file-tp4362564p4364144.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: PDFTranscoder is producing 0byte file

2012-02-07 Thread jonathan wood
By going directly to FOP, I can render part of it in pdf  Is there a
page-width limit on FOP, does this appear to be a FOP issue limitation?
 Note that increasing the page-width in the following will eventually cause
the text to stop rendering:

fo:root xmlns:fo=http://www.w3.org/1999/XSL/Format;
  fo:layout-master-set
fo:simple-page-master page-width=400cm master-name=first
  fo:region-body margin-top=1cm/
  fo:region-before extent=1cm/
  fo:region-after extent=1.5cm/
/fo:simple-page-master
  /fo:layout-master-set

  fo:page-sequence master-reference=first
fo:flow flow-name=xsl-region-body

  fo:block

 fo:external-graphic src=url(pastie-3329528.svg)/

  /fo:block

/fo:flow
  /fo:page-sequence
/fo:root

save as my.fo and invoke fop ... # fop my.fo my.pdf (requires Markus'
pasties svg)



On Tue, Feb 7, 2012 at 11:06 AM, mmoorman mmoor...@uos.de wrote:

 converting to png and jpeg always works but the qualtiy is absolutly
 terrible. A lot of artifacts. Trying your invocation leads to the same
 issue.

 Markus

 Am 07.02.2012 15:46, schrieb jonathan wood-3 [via Batik]:

 Adding a background gives me some contrast and makes it readable...the
 alignment does not look as expected though...looks like the character width
 is not being respected on conversion...manually changing the font to
 monospaced helps alot, but is not a complete fix

  here's my invocation:

  java -jar src/batik/trunk/batik-1.8pre/batik-rasterizer.jar
 ~/Downloads/pastie-3329528.svg -bg 255.255.255.255


 On Tue, Feb 7, 2012 at 4:16 AM, mmoorman [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=4364913i=0
  wrote:

 Hi,

 I've profiled the application and used HeapSpace is always below the
 allowed
 one. Also specifying a region doesn't result in a real pdf. It's still
 0byte.
 Other advices?

 Markus

 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/PDFTranscoder-is-producing-0byte-file-tp4362564p4364144.html
  Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=4364913i=1
 For additional commands, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=4364913i=2




 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://batik.2283329.n4.nabble.com/PDFTranscoder-is-producing-0byte-file-tp4362564p4364913.html
  To unsubscribe from PDFTranscoder is producing 0byte file, click here.
 NAMLhttp://batik.2283329.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml


 --
 View this message in context: Re: PDFTranscoder is producing 0byte 
 filehttp://batik.2283329.n4.nabble.com/PDFTranscoder-is-producing-0byte-file-tp4362564p4365214.html

 Sent from the Batik - Users mailing list 
 archivehttp://batik.2283329.n4.nabble.com/Batik-Users-f2970783.htmlat 
 Nabble.com.



Re: PDFTranscoder is producing 0byte file

2012-02-06 Thread jonathan wood
Your high resolution vector image may be consuming more heap than you have
available when transcoding to raster.  You can test this by passing an AOI
to the transcode hints.  if that is the issue, you can opt to tile the
output

http://xmlgraphics.apache.org/batik/using/transcoder.html#selectAreaOfIntrest

Or cut your resolution by reducing the magnitude of your cords...

you'll get some better answers from other, more knowledgable transcoders!

On Monday, February 6, 2012, mmoorman mmoor...@uos.de wrote:
 Hi everybody,

 I'm creating an alignment of sequences and want to save this aligment. I'm
 drawing a lot of Strings (300) into the SVGGraphics2D object, which
results
 in a length of about 20.000 px. THe SVG looks good in Inkscape but I
cannot
 convert it into a pdf. Neither via the pdfTranscoder, which is producing a
 0byte file, nor via the rasterizer which produces pdf with about 1.6Mb
but I
 don't see any text.
 Do you have any advices to solve this problem?  http://pastie.org/3329528
 this  is the generated SVG.

 Thanks in advance

 --
 View this message in context:
http://batik.2283329.n4.nabble.com/PDFTranscoder-is-producing-0byte-file-tp4362564p4362564.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: org.xml.sax.SAXParseException: Invalid encoding name HP-ROMAN8

2011-11-30 Thread jonathan wood
Saw this today and thought I'd drop it here for reference ... a java5
solution to programmatic lookup:

This class handles looking up service providers on the class path. It
implements the Service Provider section of the JAR File
Specificationhttp://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html#Service%20Provider
.

The Service Provider programmatic lookup was not specified prior to Java 6
so this interface allows use of the specification prior to Java 6.
http://docs.jboss.org/seam/3/solder/latest/api/org/jboss/solder/util/service/ServiceLoader.html



On Fri, Nov 25, 2011 at 3:12 AM, jonathan wood
jonathanshaww...@gmail.comwrote:

 Note that the linked second form of newInstance(...) seems to bo 1.6
 specific


 On Fri, Nov 25, 2011 at 3:06 AM, jonathan wood jonathanshaww...@gmail.com
  wrote:


 I believe you are experiencing a ServiceLoader in your xerces jar file.
  You can test this by looking for the file
 /META-INF/services/javax.xml.parsers.SAXParserFactory.  If it exists, you
 have a few choices

 Brute force...remove the file from the xerces jar and repackage (relies
 on classpath and a one-off jar...not a good solution).

 You can manipulate the load of the service implementation by iterating
 over the options...

 ServiceLoaderSAXParserFactory serviceLoader =
 ServiceLoader.load(SAXParserFactory.class);
 serviceLoader.iterator();
 for (SAXParserFactory spf : serviceLoader) {
   // spf.???
 }

 Directly load the impl you want ...   
 SAXParserFactory.html#newInstance(java.lang.String,
 java.lang.ClassLoader)http://docs.oracle.com/javase/6/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance(java.lang.String,%20java.lang.ClassLoader)


 I'd advise reading the javadoc for both forms of newInstance


 Hope this helps



 On Thu, Nov 24, 2011 at 5:05 AM, Alex Geller a...@4js.com wrote:

 Hi,
 I am not sure if this is a Batik only issue but since I encountered it
 using
 Batik I will share the problem and the solution I have found so far.

 Description of the problem:
 If you have a program that reads XML files and you add
 xerces_2_5_0.jar to
 your CLASSPATH on a HP-UX machine (or any other machine that has
 proprietary
 XML encodings) then the program may fail with the exception
 org.xml.sax.SAXParseException: Invalid encoding name HP-ROMAN8.

 Note that the existence of this jar in the CLASSPATH is sufficient to
 make
 this happen. The following test program illustrates the issue (forgive
 the
 deprecation warning):

 import org.xml.sax.InputSource;
 import javax.xml.parsers.SAXParserFactory;
 import java.io.StringBufferInputStream;
 public class EncodingTest
 {
public static void main(String[] args) throws Exception
{

 SAXParserFactory.newInstance().newSAXParser().getXMLReader().parse(new
 InputSource(new StringBufferInputStream(?xml version=\1.0\
 encoding=\HP-ROMAN8\? )));
}
 }

 Consider the following invocations:
 Example 1:
 $(unset CLASSPATH;java -Djaxp.debug=1 EncodingTest)
 JAXP: find factoryId =javax.xml.parsers.SAXParserFactory
 JAXP: loaded from fallback value:
 com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
 JAXP: created new instance of class
 com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl using
 ClassLoader: null
 $

 Example 2:
 $(export CLASSPATH=.:$BATIKDIR/batik-1.7/lib/xerces_2_5_0.jar;java
 -Djaxp.debug=1 EncodingTest)
 JAXP: find factoryId =javax.xml.parsers.SAXParserFactory
 JAXP: found jar
 resource=META-INF/services/javax.xml.parsers.SAXParserFactory using
 ClassLoader: sun.misc.Launcher$AppClassLoader@df6ccd
 JAXP: found in resource,
 value=org.apache.xerces.jaxp.SAXParserFactoryImpl
 JAXP: created new instance of class
 org.apache.xerces.jaxp.SAXParserFactoryImpl using ClassLoader:
 sun.misc.Launcher$AppClassLoader@df6ccd
 [Fatal Error] :1:43: Invalid encoding name HP-ROMAN8.
 Exception in thread main org.xml.sax.SAXParseException: Invalid
 encoding
 name HP-ROMAN8.
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
 Source)
at EncodingTest.main(EncodingTest.java:9)
 $

 Now, the issue can be fixed by forcing the JVM to use the default
 factory by
 settings the property javax.xml.parsers.SAXParserFactory as described in

 http://docs.oracle.com/javase/6/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance()
 as follows:

 Example 3:

 $(export CLASSPATH=.:$BATIKDIR/batik-1.7/lib/xerces_2_5_0.jar;java

 -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
 -Djaxp.debug=1 EncodingTest)
 JAXP: find factoryId =javax.xml.parsers.SAXParserFactory
 JAXP: found system property,
 value=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
 JAXP: created new instance of class
 com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl using
 ClassLoader: null
 $

 Questions:
 1) Is it necessary to include xerces_2_5_0.jar in the CLASSPATH?
 2) If yes, how can I load documents with local

Re: Unable to output DOM document into SVG/XML format

2011-11-26 Thread jonathan wood
An alternate out method from Document - xml ... exceptions and proper
variable init removed...the following get's you the same place

DOMUtilities.writeDocument(doc, new FileWriter(myfile.svg));

http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/dom/util/DOMUtilities.html

On Fri, Nov 25, 2011 at 2:08 AM, jonathan wood
jonathanshaww...@gmail.comwrote:

 I noticed a couple things, but am not where I can currently
 compile/test

 Create the TextElement in the SVG namespace

 Change ...

 Element e = doc.createElement(text);
  ...to...

 Element e = doc.createElementNS(svgNS, text);

 ... append the text to the textEl...

 Change...

 svgRoot.appendChild(t);

 ...to...

 e.appendChild(t);


 On Thu, Nov 24, 2011 at 9:16 PM, Alan Pandit alan.pan...@gmail.comwrote:

 I am attempting to output the contents of a DOM Tree in XML format to
 System.out using the SVGGraphics2D class.  Essentially, I want to be able
 to see what tags I am creating as I perform calls to appendChild(), but
 when I execute the code below, I don't see Hello World or text as I
 expect to see.  Are the calls to appendChild() supposed to change the
 Document object named doc so the changes will be reflected in the streamed
 out SVG?

 String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
 DOMImplementation impl =
 SVGDOMImplementation.getDOMImplementation();
 Document doc = impl.createDocument(svgNS, svg, null);

 Element svgRoot = doc.getDocumentElement();

 Element e = doc.createElement(text);
 svgRoot.appendChild(e);

 Text t = doc.createTextNode(Hello World);

 svgRoot.appendChild(t);

 // Create an instance of the SVG Generator.
 SVGGraphics2D svgGenerator = new SVGGraphics2D(doc);
 try{


 // Finally, stream out SVG to the standard output using
 // UTF-8 encoding.
 boolean useCSS = true; // we want to use CSS style attributes
 Writer out = new OutputStreamWriter(System.out, UTF-8);
 svgGenerator.stream(out, useCSS);
 }
 catch(Exception exc) {

 System.out.println(exc+);
 }


 This is the OUTPUT I get:

 ?xml version=1.0 encoding=UTF-8?
 !DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN'
   'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'
 svg style=stroke-dasharray:none; shape-rendering:auto;
 font-family:apos;Dialogapos;; text-rendering:auto; fill-opacity:1;
 color-interpolation:auto; color-rendering:auto; font-size:12; fill:black;
 stroke:black; image-rendering:auto; stroke-miterlimit:10;
 stroke-linecap:square; stroke-linejoin:miter; font-style:normal;
 stroke-width:1; stroke-dashoffset:0; font-weight:normal; stroke-opacity:1;
 xmlns=http://www.w3.org/2000/svg; contentScriptType=text/ecmascript
 preserveAspectRatio=xMidYMid meet xmlns:xlink=
 http://www.w3.org/1999/xlink; zoomAndPan=magnify version=1.0
 contentStyleType=text/css
 !--Generated by the Batik Graphics2D SVG Generator--defs
 id=genericDefs/g//svg


 Thanks.

 Alan





Re: Unable to output DOM document into SVG/XML format

2011-11-24 Thread jonathan wood
I noticed a couple things, but am not where I can currently compile/test

Create the TextElement in the SVG namespace

Change ...

Element e = doc.createElement(text);
...to...

Element e = doc.createElementNS(svgNS, text);

... append the text to the textEl...

Change...

svgRoot.appendChild(t);

...to...

e.appendChild(t);


On Thu, Nov 24, 2011 at 9:16 PM, Alan Pandit alan.pan...@gmail.com wrote:

 I am attempting to output the contents of a DOM Tree in XML format to
 System.out using the SVGGraphics2D class.  Essentially, I want to be able
 to see what tags I am creating as I perform calls to appendChild(), but
 when I execute the code below, I don't see Hello World or text as I
 expect to see.  Are the calls to appendChild() supposed to change the
 Document object named doc so the changes will be reflected in the streamed
 out SVG?

 String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
 DOMImplementation impl =
 SVGDOMImplementation.getDOMImplementation();
 Document doc = impl.createDocument(svgNS, svg, null);

 Element svgRoot = doc.getDocumentElement();

 Element e = doc.createElement(text);
 svgRoot.appendChild(e);

 Text t = doc.createTextNode(Hello World);

 svgRoot.appendChild(t);

 // Create an instance of the SVG Generator.
 SVGGraphics2D svgGenerator = new SVGGraphics2D(doc);
 try{


 // Finally, stream out SVG to the standard output using
 // UTF-8 encoding.
 boolean useCSS = true; // we want to use CSS style attributes
 Writer out = new OutputStreamWriter(System.out, UTF-8);
 svgGenerator.stream(out, useCSS);
 }
 catch(Exception exc) {

 System.out.println(exc+);
 }


 This is the OUTPUT I get:

 ?xml version=1.0 encoding=UTF-8?
 !DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN'
   'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'
 svg style=stroke-dasharray:none; shape-rendering:auto;
 font-family:apos;Dialogapos;; text-rendering:auto; fill-opacity:1;
 color-interpolation:auto; color-rendering:auto; font-size:12; fill:black;
 stroke:black; image-rendering:auto; stroke-miterlimit:10;
 stroke-linecap:square; stroke-linejoin:miter; font-style:normal;
 stroke-width:1; stroke-dashoffset:0; font-weight:normal; stroke-opacity:1;
 xmlns=http://www.w3.org/2000/svg; contentScriptType=text/ecmascript
 preserveAspectRatio=xMidYMid meet xmlns:xlink=
 http://www.w3.org/1999/xlink; zoomAndPan=magnify version=1.0
 contentStyleType=text/css
 !--Generated by the Batik Graphics2D SVG Generator--defs
 id=genericDefs/g//svg


 Thanks.

 Alan



Re: Make Transparent SVG Transparent in JSVGCanvas

2011-08-30 Thread jonathan wood
You might find this older post about component transparencies
helpful...includes a great example from Cameron.  I'd suggest reading the
entire thread as it contains many insights

http://batik.2283329.n4.nabble.com/JSVGCanvas-setOpaque-method-not-working-td2976247.html

Hope that helps!

On Tue, Aug 30, 2011 at 8:48 AM, dieend mail.die...@gmail.com wrote:

  have SVG file that actually empty, that have no element, yet. I will
 manipulate it in the java code by adding element. The SVG file will be
 inserted in a scrollpane. The problem is even the SVG file actually empty,
 the Scrollpane not transparent even if I have already set it transparent.

 Here is the SVG file (I got it from client):



 and here is the scroll pane part (canvasDiagram is the SVGCanvas).



 The scrollpane is not transparent but white. I tried to insert the scroll
 pane content with transparent jPanel and its work so I believe the white
 content because of the canvasDiagram. Can you help me to make the empty
 part
 of canvasDiagram really transparent?

 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/Make-Transparent-SVG-Transparent-in-JSVGCanvas-tp3778622p3778622.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Exporting a RadialGradientPaint

2011-08-30 Thread jonathan wood
Hi Ryan,

  Although Batik most certainly supports radial gradients, I'm not sure that
support currently extends to the SVGGraphics2D arena.  You can likely add
support for it quickly though by extending DefaultExtensionHandler and
overriding the handlePaint method...something like this...

public class RadialGradientPaintExtensionHander extends
DefaultExtensionHandler {
@Override
public SVGPaintDescriptor handlePaint(Paint paint, SVGGeneratorContext
svggc) {
if(paint instanceof RadialGradientPaint) {
// create svg radial gradient dom elements
...
// return an extension of SVGPaintDescriptor appropriate for
this radial gradient
}
return null;
}
}

You can also use the dom directly and then transcode the resulting document,
but that is an entirely different approach.

Hope this helps,

 jonathan


On Mon, Aug 29, 2011 at 2:56 PM, Ryan Noon rmn...@gmail.com wrote:

 Hi All,

 I just started learning Batik and I'm really amazed by it so far!  I'm
 kind of new to SVG to please bear with me.

 I've got a Java 2D method that draws a circle of nodes connected by
 edges.  Each node is drawn using a java.awt.RadialGradientPaint (see
 attached circle_swing.png).

 When I try to render this to an SVG using SVGGraphics2D everything
 goes fine except that the nodes are drawn as a solid color, which I
 believe is the color of the last node.  (see attached circle_svg.png
 and circle.svg).

 How can I get the radial gradients to draw properly?  I've read that
 they exist in SVG and the Batik status list says they're supported
 currently.

 The export code I'm using is a direct port of the tutorial here:
 http://xmlgraphics.apache.org/batik/using/svg-generator.html

 I'm using the latest SVN of Batik on OS X Lion with the Apple JRE.

 Thanks!

 Ryan


 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org



Re: rendering directly to java.awt.Graphics2D

2011-08-07 Thread jonathan wood
Hi Mike,

  I've seen variations of this type thing before...  in my case a top level
svg that contains an image who's xlink:href references another document
(svg in my case).  The referenced svg document had an id'd gradient that was
in the defs...when the gradient was referenced by a shape's fill, the
transcode would fail. Seems once the DOM (GVT) is booted the calls out to
the xlnk:href are resolved. The uri for the embedded document seemed to be
null (null#id on reference)You can try to setDocumentURI(something) on the
parent...I think I tried that with no success, but needed to work-around
(base64 data uri worked fine) and move on. I can probably reproduce this
behavior in a test case if you think it will help resolve your issue.  I
have not had time to debug it further, but it is on the (long) list.

On Thu, Aug 4, 2011 at 4:36 PM, Mike Jarmy mja...@gmail.com wrote:

 On Wed, Aug 3, 2011 at 3:39 PM, Mike Jarmy mja...@gmail.com wrote:
  On Wed, Aug 3, 2011 at 1:03 PM, Mike Jarmy mja...@gmail.com wrote:
  I'm working with a custom widget toolkit that is built directly on top
  of java.awt -- in other words I'm not using Swing, or SWT, or anything
  other than a framework built on plain old AWT.
 
  I'd like to be able to render (and animate) SVG drawings directly onto
  a java.awt.Graphics2D instance.  However, I'm having a bit of trouble
  figuring out how exactly to do that with batik.  I *think* that I need
  to decode my SVG drawing into a GVT tree, and then render the tree.
  However I can't figure out which part of batik I need in order to do
  the rendering.  Transcoder and SVGGraphics2D do not seem to be quite
  what I want. Actually, I haven't yet figured out the
  decoding-to-GVT-step either, but I'm assuming that's pretty
  straightforward.
 
  So can anyone give me a pointer on how to do this?  Perhaps just point
  me to an existing example?  My first goal is to just get static images
  rendering.
 
  After that, I'll need to get animation working.  I'm assuming that
  supporting animation will entail updating the drawing's current time
  every so oftern on a separate thread, via the AnimationEngine, and
  then re-rendering the updated GVT?
 
  I *could* do all this by rendering into a static java.awt.Image, and
  then bliting the Image (i.e. roll my own double-buffering), but I'd
  prefer to figure out how to just draw directly onto a Graphics2D
  instance first.  That's because the framework I'm using already has
  some double-buffering, so I most likely wont need to do that with the
  SVG rendering.
 
  Thanks,
  Mike Jarmy
 
  P.S. FYI, I'll probably never need to support handling interactive user
 input.
 
 
  OK, I have discovered the GraphicsNode.paint(Graphics2D g2d)  method,
  which may be all I need to call once I actually get a valid GVT build.
   However, I'm having trouble building a GVT from a
  java.io.InputStream.  Here is the code I'm using:
 
 String parser = XMLResourceDescriptor.getXMLParserClassName();
 SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
  //String uri = http://www.example.org/document.svg;;
 Document document = f.createDocument(null, inputStream);
 
 UserAgent userAgent = new UserAgentAdapter();
 DocumentLoader loader = new DocumentLoader(userAgent);
 BridgeContext bctx = new BridgeContext(userAgent, loader);
 bctx.setDynamicState( BridgeContext.DYNAMIC );
 GVTBuilder builder = new GVTBuilder();
 this.gvtRoot = builder.build(bctx, document);
 
  This code fails at the call to GVTBuilder.build(), with the following
 error:
 
  Invalid CSS document.
  Unable to make sense of URL for connection
 at
 org.apache.batik.css.engine.CSSEngine.parseStyleSheet(CSSEngine.java:1149)
 at
 org.apache.batik.dom.svg.SVGDOMImplementation.createCSSEngine(SVGDOMImplementation.java:117)
 at
 org.apache.batik.dom.ExtensibleDOMImplementation.createCSSEngine(ExtensibleDOMImplementation.java:212)
 at
 org.apache.batik.bridge.BridgeContext.initializeDocument(BridgeContext.java:378)
 at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:55)
 at
 com.tridium.svg.ui.BSvgDrawing.loadDrawing(BSvgDrawing.java:305)
 
  Could that be because I'm passing a null value in for the URI when I
  create the document from the InputStream?  I have noticed that I get
  the same error no matter what I pass in for the URI.  Is there perhaps
  a better way to construct a Document from an InputStream?
 
  Thanks,
  Mike Jarmy
 

 I have this working now in a simple hello, world style, java app,
 using the following approach:

public static void main(String[] args) throws Exception
{
// make the file, along with its input stream and URI
File file = new File(D:\\aaa\\svg\\samples\\batik70.svg);
FileInputStream inputStream = new FileInputStream(file);
String uri = 

Re: Combine SVG out of single SVG files

2011-06-23 Thread jonathan wood
For completeness (and to cover the simplest solution that I didn't present
earlier)

adding svg:image elements with the xlink:hrefs pointing to the external
files would also work.

On Wed, Jun 22, 2011 at 9:45 PM, jonathan wood
jonathanshaww...@gmail.comwrote:

 Thanks for the additional info Helder.

 Note that even with a use tag, if you want to add the existing svg to a top
 level template programatically, you'd still need to follow the prior
 instructions with the following modification.  Note that this is not the use
 case specified by the requester as there is no element reuse in the
 originally described scenario.

 - uniquely id the new element
 - create a defs element and append the imported node to the defs element.
 - create and add a use element with the xlink:href attribute set to
 url(#newnodeid)


 2011/6/22 Helder Magalhães helder.magalh...@gmail.com

 Hi everyone,

  One way to do it...assumes the file was read and placed into a byte
 array by
  loadMyFile() (your implementation).
  All fluff and exception handling removed, but the basic sequence is:
 [...]

 Apart from this (good) suggestion, note that SVG also has an import
 mechanism, namely the 'use' element [1]. Just in case someone missed
 it! ;-)

 Cheers,
  Helder


 [1] http://www.w3.org/TR/SVG11/struct.html#UseElement

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org





Re: Combine SVG out of single SVG files

2011-06-22 Thread jonathan wood
One way to do it...assumes the file was read and placed into a byte array by
loadMyFile() (your implementation).

All fluff and exception handling removed, but the basic sequence is:

byte[] inFIleBytes = loadMyFile();
ByteArrayInputStream bais =  new ByteArrayInputStream(inFileBytes);
SAXSVGDocumentFactory svgDocumentFactory = new
SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName());
Element inElement = svgDocumentFactory.createDocument(null,
bais).getDocumentElement();
inElement = (Element) document.importNode(inElement, true);
svgRoot.appendChild(inElement);


On Wed, Jun 22, 2011 at 9:09 AM, sweetmovesdude dennis.ku...@tu-dortmund.de
 wrote:

 Hey everyone,

 I have some .svg files in a folder, each representing a single component.
 What I want is to create a 100x100 px SVG document with these components,
 e.g. the login.svg uses the background_green.svg and the
 login_component.svg.

 I used Batik to create a 100x100 px document, but now wonder how I can
 import SVG files from a specific path, let's say
 $home/documents/components/

 What I have so far is

 ...
 String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
 DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
 Document doc = impl.createDocument(svgNS, svg, null);

 Element svgRoot = doc.getDocumentElement();
 svgRoot.setAttributeNS(svgNS, width, 100);
 svgRoot.setAttributeNS(svgNS, height, 100);


 How can I import the SVG components and attach them to svgRoot?

 Thank you all for helping!

 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/Combine-SVG-out-of-single-SVG-files-tp3616984p3616984.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Combine SVG out of single SVG files

2011-06-22 Thread jonathan wood
Thanks for the additional info Helder.

Note that even with a use tag, if you want to add the existing svg to a top
level template programatically, you'd still need to follow the prior
instructions with the following modification.  Note that this is not the use
case specified by the requester as there is no element reuse in the
originally described scenario.

- uniquely id the new element
- create a defs element and append the imported node to the defs element.
- create and add a use element with the xlink:href attribute set to
url(#newnodeid)


2011/6/22 Helder Magalhães helder.magalh...@gmail.com

 Hi everyone,

  One way to do it...assumes the file was read and placed into a byte array
 by
  loadMyFile() (your implementation).
  All fluff and exception handling removed, but the basic sequence is:
 [...]

 Apart from this (good) suggestion, note that SVG also has an import
 mechanism, namely the 'use' element [1]. Just in case someone missed
 it! ;-)

 Cheers,
  Helder


 [1] http://www.w3.org/TR/SVG11/struct.html#UseElement

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Deadlock with gvtRenderingCompleted without Swing threads

2011-03-30 Thread jonathan wood
The lower synchronized block will likely execute before
gvtRenderingComplete() is called.  The lower block will be holding the mutex
when the upper synchonized access is attempteddeadlock

On Wed, Mar 30, 2011 at 6:35 AM, kototama kototama kotot...@gmail.comwrote:

 Hello,

 I would like to block and wait until the rendering of the SVG DOM is
 completed. What is wrong with the following code? It blocks even if no
 Swing thread is involved.

 Thanks in advance for your help.

 public class DeadLock {

private static final String svgNS =
 SVGDOMImplementation.SVG_NAMESPACE_URI;

/**
 * @param args
 */
public static void main(String[] args) {
final Object mutext = new Object();

DOMImplementation impl =
 SVGDOMImplementation.getDOMImplementation();
Document doc = impl.createDocument(svgNS, svg, null);

JSVGCanvas canvas = new JSVGCanvas();
canvas.addGVTTreeRendererListener(new
 GVTTreeRendererAdapter() {
@Override
public void
 gvtRenderingCompleted(GVTTreeRendererEvent e) {
System.out.println(completed);
synchronized (mutext) {
mutext.notifyAll();
}

}
});

synchronized (mutext) {
System.out.println(Loading document);
canvas.setDocument(doc);
System.out.println(Waiting for document to be
 loaded...);
try {
mutext.wait();
System.out.println(rendering finished);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}

 }

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Mouse EventListener on SVG group elements

2011-02-16 Thread jonathan wood
Does your g specify the attribute pointer-events= all?

http://www.w3.org/TR/SVG/interact.html#PointerEventsProperty


Jonathan

2011/2/15 André de Brito andre.br...@evolve.pt

 Sorry to insist, but does anyone have a clue on this subject? Or can you at
 least point me to some other place where I can ask for help?

 Thanks.

 ---

  Hello,

 I'm using batik to display SVG files on a JSVGCanvas and I'm trying to
 respond to mouse click events over SVG elements with tags a
 (SVGOMAElement) and g (SVGOMGElement).
 Here is the code I'm using to add the event listener to a Node:

 if ((no.getNodeName().equalsIgnoreCase(a)) ||
 (no.getNodeName().equalsIgnoreCase(g))) {
 EventTarget etr = (EventTarget) no;
 etr.addEventListener(SVGConstants.SVG_EVENT_CLICK, new EventListener()
 {
 public void handleEvent(Event evt) {
 Log.debug(HANDLE EVENT);
 }
 }, false);

 What happens is that the listener is correcly called when an a element
 is clicked, but nothing happens when a g element is clicked!
 I debuged the code above and verified that the click listener is being
 added to the both node's bubblingListeners table
 (etr-eventSupport-bubblingListeners). However, I noticed that the a
 elements seem to have two other (default) listeners - for events mouseout
 and mouseover - which are not present on the g elements. I don't believe
 this is the cause, but ...

 Any ideas on what could be causing this behaviour?

 Regards,
 ABrito





Re: Batik and JUnit

2010-12-15 Thread jonathan wood
Can you share your initialization/document load routine and the handoff to
junit?

On Tue, Dec 14, 2010 at 1:50 PM, shootist kwilson4...@gmail.com wrote:


 I am attempting to run some unit tests under JFCUnit and JUnit.  I also
 have
 a recorder that uses java robot to perform some tests.

 Anytime I modify anything, or even sometimes just starting the code without
 running any actual tests I get svg errors.  Sometimes It's just a null,
 sometimes it tells me there is an invalid attribute (for example, I get an
 error message saying lll is not a valid attribute for pointer-events),
 and sometimes I get CSS exceptions.

 I don't see anyplace in the code where I set any attribute to lll, and I
 don't have any problems running the code.  This only happens within the
 unit
 tests.

 I suspect something strange is happening with threading, and the unit tests
 are not waiting for the UpdateManager to complete, but no amount of sleep
 calls seem to help.  Has anyone experienced these problems?
 --
 View this message in context:
 http://batik.2283329.n4.nabble.com/Batik-and-JUnit-tp3087741p3087741.html
 Sent from the Batik - Users mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Batik and JUnit

2010-12-15 Thread jonathan wood
Without some context (code snippet, svg sample, etc), I'm a bit limited in
the help I can offer.

I've seen odd behavior like this in 2 cases...Yours may not fall into either
since it works outside the unit test, but it's worth a shot.

1) The document is tampered with before SVG/GVT are fully initialized.
Using the following eliminates the need for sleep/check routines for a
loaded doc.  Note the comments indicating proper/improper places to begin
document modification.

 Example:

svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
svgCanvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
@Override
public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
 //MODIFY DOCUMENT HERE
}
});

InputStream templateStream =
Canvas.class.getResourceAsStream(mydoc.svg);
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
SVGDocument doc = null;

try {
doc = f.createSVGDocument(null, templateStream);
} catch (IOException ex) {
Logger.getLogger(Canvas.class.getName()).log(Level.SEVERE, null,
ex);
} finally {
if(templateStream != null) {
try {
templateStream.close();
} catch (IOException ex) {
logger.log(Level.WARNING, null, ex);
}
}
}
doc.setDocumentURI(myuri);
// DON'T MODIFY DOCUMENT HERE


2) Modification of the document (add/remove/update any svg node) outside of
the UpdateRunnableQueue.  All modifications should be wrapped..

getUpdateManager().getUpdateRunnableQueue().invokeLater(new Runnable() {
@Override
 public void run() {
   // MODIFY DOCUMENT HERE
 }
});


feel free to share more info if your issue persists.


On Wed, Dec 15, 2010 at 11:01 AM, Martin Gainty mgai...@hotmail.com wrote:

  Hello Jonathan

 from what i've seen the invocation of the JFCUnit tests are producing the
 abending lll attribute causing the offense
 It looks as if you'll need some session-management to determine who the
 culprit is here is an example:

 execute JFCUnit-Test-Session1:
 bashgrep --files-with-matches --recursive attribute
   JFCUnit produces attributes fu

 execute JFCUnit-Test-Session2:
 bashgrep --files-with-matches --recursive attribute
JFCUnit produces attributes fubar

 execute JFCUnit-Test-Session3:
 bashgrep --files-with-matches --recursive attribute
JFCUnit produces attributes lll

 Martin Gainty
 __
 Jogi és Bizalmassági kinyilatkoztatás/Verzicht und
 Vertraulichkeitanmerkung/Note de déni et de confidentialité

 Ez az üzenet bizalmas.  Ha nem ön az akinek szánva volt, akkor kérjük, hogy
 jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának készítése
 nem megengedett.  Ez az üzenet csak ismeret cserét szolgál és semmiféle jogi
 alkalmazhatósága sincs.  Mivel az electronikus üzenetek könnyen
 megváltoztathatóak, ezért minket semmi felelöség nem terhelhet ezen üzenet
 tartalma miatt.

 Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
 Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
 Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
 dient lediglich dem Austausch von Informationen und entfaltet keine
 rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
 E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.

 Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
 destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
 l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci 
 est interdite. Ce message sert à l'information seulement et n'aura pas 
 n'importe quel effet légalement obligatoire. Étant donné que les email 
 peuvent facilement être sujets à la manipulation, nous ne pouvons accepter 
 aucune responsabilité pour le contenu fourni.






 --
 From: jonathanshaww...@gmail.com
 Date: Wed, 15 Dec 2010 10:35:49 -0500
 Subject: Re: Batik and JUnit
 To: batik-users@xmlgraphics.apache.org


 Can you share your initialization/document load routine and the handoff to
 junit?

 On Tue, Dec 14, 2010 at 1:50 PM, shootist kwilson4...@gmail.com wrote:


 I am attempting to run some unit tests under JFCUnit and JUnit.  I also
 have
 a recorder that uses java robot to perform some tests.

 Anytime I modify anything, or even sometimes just starting the code without
 running any actual tests I get svg errors.  Sometimes It's just a null,
 sometimes it tells me there is an invalid attribute (for example, I get an
 error message saying lll is not a valid attribute for pointer-events),
 and sometimes I get CSS exceptions.

 I don't see anyplace in the code where I set any attribute to lll, and 

Re: PDF Title

2010-11-04 Thread jonathan wood
I do not have any hands on experience.. beware this may not work at all:

 http://www.w3.org/TR/SVG/metadata.html
http://xmlgraphics.apache.org/fop/1.0/metadata.html

Maybe embedding the metadata for the pdf title () into the svg would work?

metadata
  rdf:RDF
   xmlns:rdf = http://www.w3.org/1999/02/22-rdf-syntax-ns#;
   xmlns:rdfs = http://www.w3.org/2000/01/rdf-schema#;
   xmlns:dc = http://purl.org/dc/elements/1.1/; 
rdf:Description about=http://example.org/myo;
 dc:title=My Title
 dc:description=...
 dc:publisher=...
 dc:date=...
 dc:language=en 
/rdf:Description
  /rdf:RDF
/metadata

Good luck and hope this helps.  Would love to hear any results as I'm
sure I'll be looking for this very item soon.

Anyone have an easier way? Maybe it is possible to gain a handle to
FOPUserAgent.setTitle()?



On Thu, Nov 4, 2010 at 1:29 PM, David Padbury dpadb...@liquidnet.com wrote:
 I’m sure this must have been asked before, but I can’t find a way of
 searching the mailing list…



 When transcoding a SVG to a PDF, how would you set the title of the PDF?
 I’ve tried putting a title element in the SVG itself, however this doesn’t
 appear in the document properties of the pdf once rendered.



 David Padbury.

-
To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org



Re: Batik problems in Cocoon 2.2

2010-10-19 Thread jonathan wood
Greetings,

  This is almost certainly a namespace issue.  I'd suggest the
following 3 things:

  - Check and/or post your parse sequence using SAXSVGDocumentFactory.
(less likely if unchange during upgrades)

  - Check and/or post(if of appropriate size) your raw input document.
(less likely if unchange during upgrades)

  - Check your classpath for duplicate (xmlparsing?) jars with
differing versions.


Happy to help further if needed... more detail always useful.


On Tue, Oct 19, 2010 at 4:05 PM, Fawzib Rojas f_ro...@spectron-msim.com wrote:
  Hello, I'm trying to get Batik 1.7 running in Cocoon 2.2. I think I should
 start from the beginning.

 I'm moving from Cocoon 2.1 to 2.2 (2.2 uses maven for everything), I created
 the webapp and tried to use the fop-block in cocoon but the fop version it
 wants to use is 0.20.5 and batik-1.6. The problem is that with that
 combination embedded SVGs wont work in fop. I downloaded the fop-ng-block
 and now have a working cocoon 2.2 with fop-1.0 and batik-1.7.

 My problem is that now the SVGSerializer (converts SVG to jpeg) part of
 cocoon does not work. It gives me the following error:

 java.lang.NullPointerException
 at
 org.apache.batik.dom.util.SAXDocumentFactory.startElement(SAXDocumentFactory.java:563)
 .

 The problem is in this part of startElement() for some reason, parser is
 null:

        if (inProlog) {
            inProlog = false;
            try {
                isStandalone =
 parser.getFeature(http://xml.org/sax/features/is-standalone;);
            } catch (SAXNotRecognizedException ex) {
            }
            try {
                xmlVersion = (String)
 parser.getProperty(http://xml.org/sax/properties/document-xml-version;);
            } catch (SAXNotRecognizedException ex) {
            }
        }

 I moved both trys to the createDocument(InputSource is) since it just saves
 those 2 values (why are those trys in startElement and not createDocument?).
 After moving both trys thingts moved along and it crashes on the transcoding
 part. The error I get is:

 java.lang.ClassCastException: org.apache.batik.dom.GenericElement cannot be
 cast to org.w3c.dom.svg.SVGSVGElement

 the code for transcode is:

    public void notify(Document doc) throws SAXException {
        try {
            TranscoderInput transInput = new TranscoderInput(doc);
            // Buffering is done by the pipeline (See shouldSetContentLength)
            TranscoderOutput transOutput = new TranscoderOutput(this.output);
            transcoder.transcode(transInput, transOutput);
        } catch (TranscoderException ex) {
          ...
        } catch (Exception ex) {
          ...
        }
    }

 after reading through a lot of posts I found one saying
 DOMUtilities.deepCloneDocument would convert dom to Batik's own DOM and do
 the transcode. I changed the TransocderInput constructor to this:

 TranscoderInput transInput = new
 TranscoderInput(DOMUtilities.deepCloneDocument(doc,SVGDOMImplementation.getDOMImplementation()));

 but it still gives me the same error, so I'm officially stuck. I hope
 someone here can help me, asked at the cocoon list 3 times and got no
 response.

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org



-
To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org



Re: Batik and XmlHttpRequest / accessing Batik objects from javascript in svg

2010-10-14 Thread jonathan wood
Hello Roland,

  I have not tried to reproduce your problem, the items below are wild
guesses...

- Change the method call order ...

  1. set always dynamic
  2. assign listener.
  3. load doc.

  This may not be the issue since your listener is called, but it may
also be fortunate timing?


-  I've found it most opportune to start my document manipulations
using the following listener override...

mysvgCanvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
@Override
public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
  // do stuff with doc here
}
}





On Thu, Oct 14, 2010 at 12:08 PM,  roland.webe...@t-systems.com wrote:
 Hi again,



 ok, maybe i should describe the problem again :-)



 What I'm doing is to use JSVGCanvas inside an applet as an svg-viewer inside
 the browser. In the applet's init()-method I create a new canvas
 (MySVGCanvas is as already explained simply derived from JSVGCanvas in order
 to have access to the protected contextBridge-field of the canvas, see
 Listing 2) and set the document of the canvas via canvas.setURI().



 So what I try to achieve is that after the SVG is loaded into the canvas,
 the canvas object itself (the java object) should be bound to the
 script-interpreter of the document (just as Thomas Deweese pointed out
 earlier in this mail-thread). This should allow me to access the
 canvas-object from inside the ecmascript of the SVG as a global variable
 named mycanvas. This is done by calling my BindToInterpreter-method of class
 MySVGCanvas inside the DocumentLoaderListener. Unfortunately, this throws an
 exception, because the internal document-field of the interpreter is not
 set, it is null (Exception was posted before). The question is: What am I
 doing wrong, why does the interpreter not have a document set (the svg is
 running perfectly inside the canvas, it is displayed correctly and the
 ecmascript is working also). I hope this disruption of the problem is more
 useful. All I want to do is bind a java-object to the interpreter in order
 to access it from inside ecmascript.



 Listing 1: The Applet



 public class IntercomApplet extends JApplet {



     protected MySVGCanvas canvas;

     protected JSObject jso;



     public void init() {

     // Create a new JSVGCanvas.

     canvas = new MySVGCanvas();

     getContentPane().add(Center, canvas);





     try {

     // Set the document by using an URI

 canvas.setURI (getWorkflowURL ());

 canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);



     // Set the JSVGCanvas listeners.

     canvas.addSVGDocumentLoaderListener(new
 SVGDocumentLoaderAdapter() {

     public void documentLoadingStarted(SVGDocumentLoaderEvent e)
 {



     }

     public void documentLoadingCompleted(SVGDocumentLoaderEvent
 e) {

       System.out.println(### Document loaded);

   // try to bind the canvas object und name myycanvas to the
 script interpreter

       canvas.bindObjectToInterpreter(text/ecmascript,
 mycanvas, canvas);

     }

     });



     } catch (Exception ex) {

         ex.printStackTrace();

     }

     }



     public String getWorkflowURL (){

       String codebase = getCodeBase().toString();

       String myurl = codebase + getParameter (svgurl);

       return myurl;

     }

 }



 Listing 2: MyCanvas



 public class MySVGCanvas extends JSVGCanvas {



   public void bindObjectToInterpreter(String language, String name,
 Object obj){

     System.out.println(### Binding Object  + obj.toString() +  to
 interpreter.);

     Interpreter interpreter =
 this.bridgeContext.getInterpreter(language);

     interpreter.bindObject(name, obj);

   }

 }



 Many thanks,

 Roland





 -Ursprüngliche Nachricht-
 Von: Helder Magalhães [mailto:helder.magalh...@gmail.com]
 Gesendet: Freitag, 8. Oktober 2010 07:20
 An: batik-users@xmlgraphics.apache.org
 Betreff: Re: Batik and XmlHttpRequest / accessing Batik objects from
 javascript in svg



 Hi there,



 Hi Roland,





 The difficulty is WHEN to bind the object. First try was to simply call it

 in the init()-Method of the Applet after using canvas.setURI(…). However,

 this method is async, so my bind-method will not yet find even a

 bridgeContext (it is null). Therefore, I thought it would be best to bind

 the object AFTER the document is loaded (via setURI) by using something

 like:

 snippet/

 Currently, this should bind the canvas (later it should be the applet) to

 the name “parentapplet” in the interpreter and I should be able to use
 this

 name as a global variable in my ecmascript, e.g. like alert(parentapplet);

 Correct?  However, an exception is thrown when binding the object:



 ### Document loaded



 ### Binding Object


 

Re: Convert SVG to Java-Shapes?

2010-10-11 Thread jonathan wood
BridgeContext ctx = (you can get it from the UpdateManager, etc);
GraphicsNode gn = ctx.getGraphicsNode(Dom node I an interested in);

The nodes you are interested will return a ShapeNode

Shape shape = ((ShapeNode)gn).getShape();




On Mon, Oct 11, 2010 at 12:48 PM, LP java.j...@gmail.com wrote:

 Hi,
 when Batik reads in a SVG document and renders it on JSVGCanvas or
 into an image via ImageTranscoder, it probably draws and fills
 java.awt.Shape Objects most of the time.

 These Shape objects exist somewhere in this drawing code and I would
 like to get them and use them for further operations.

 Is there any way to get those Shapes?

 Thanks,
 jago

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Convert SVG to Java-Shapes?

2010-10-11 Thread jonathan wood
Sorry for the terse answer...I assumed since you explicitly mentioned
JSVGCanvas and ImageTranscoder that you were familiar with both.

if you are transcodingobtain a BridgeContext using ImageTranscoder's
(SVGAbstractTranscoder's) protected ctx variable or possibly
createBridgeContext().  I'm not familiar with using the latter, although if
you are maniplulating shapes, it may be easier to extend  BridgeContext.

if using JSVGCanvas, get the BridgeContext using

myJSVGCanvas.getUpdateManager().getBridgeContext()


In either case, use your SVGDocument to find the node you are interested
in...

Element el = document.getElementById(my-circle);

Ask the previously retrieved BridgeContext for the GraphicsNode...

   GraphicsNode gn = ctx.getGraphicsNode(el);

Carefully cast a Shape out of the fray...

  Shape shape = ((ShapeNode)gn).getShape();


If I recall correctly, this only works if the BridgeContext is dynamic or
possibly interactive.  Using JSVGCanvas with dynamic
(setDocumentState(ALWAYS_DYNAMIC)) will most likely do the trick for simple
use cases.

All that said, if you are new to Batik, you may find an easier way using the
standard DOM interfaces.  Using the GVT to acquire graphics node info is
usually not required.  Did you have a specific problem you are trying to
solve?




On Mon, Oct 11, 2010 at 3:13 PM, LP java.j...@gmail.com wrote:

 Oh my...thanks but I am a total Batik Beginner. Most of what you wrote
 I cannot understand or even find.

 I managed to read in a SVG file so I am basically starting with a
 SVGDocument object.

 2010/10/11 jonathan wood jonathanshaww...@gmail.com:
 
  BridgeContext ctx = (you can get it from the UpdateManager, etc);
  GraphicsNode gn = ctx.getGraphicsNode(Dom node I an interested in);
 
  The nodes you are interested will return a ShapeNode
 
  Shape shape = ((ShapeNode)gn).getShape();
 
 
 
 
  On Mon, Oct 11, 2010 at 12:48 PM, LP java.j...@gmail.com wrote:
 
  Hi,
  when Batik reads in a SVG document and renders it on JSVGCanvas or
  into an image via ImageTranscoder, it probably draws and fills
  java.awt.Shape Objects most of the time.
 
  These Shape objects exist somewhere in this drawing code and I would
  like to get them and use them for further operations.
 
  Is there any way to get those Shapes?
 
  Thanks,
  jago
 
  -
  To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
  For additional commands, e-mail:
 batik-users-h...@xmlgraphics.apache.org
 
 
 

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Loading image data from my own InputStream

2010-10-01 Thread jonathan wood
Perhaps a custom URL Protocol?

http://xmlgraphics.apache.org/batik/using/extending.html#urlProtocols



On Fri, Oct 1, 2010 at 8:59 PM, Maass, Adam (Snapfish) adam.ma...@hp.comwrote:

  OK, so this is something of an odd request:





 I have an application in which I want to, at runtime, dynamically replace
 an embedded image:



 image xlink:href=data:image/jpeg;base64,/9j/4AAQSkZJ….



 I have a solution that works but is sub-optimal: I read the image I want to
 substitute, determine a content type for it, base-64 encode its data, and
 replace the xlink:href attribute of the image element.





 What this means is that I have at least two (usually three!)
 representations of the image data in-memory – even before a subsequent
 transcode operation! (That is, one in a ByteArrayOutputStream to accumulate
 the data, one in the byte[] that ByteArrayOutputStream returns, and a third
 in the base-64 encoded version of that byte[].) The subsequent transcode
 operation will necessarily base-64 decode the data I just encoded, create a
 bitmap out of it, and presumably blit the bits into the resulting JPG.



 This is far too many large data structures floating around! To reduce the
 count of large data structures, I really want to specify in the href element
 that the image data should come from some InputStream I have at hand. Then
 when Batik processes the image element, it reads the InputStream directly,
 and creates only the one or two copies of the image data it really truly
 needs. Is there a way to do this? If not, can someone point me in the right
 direction if I were to take this on on my own?





 -Adam Maass







Re: Problem overlaying SVG element on top of loaded file

2010-09-29 Thread jonathan wood
I have not tried your example, but you might try using the namespace aware
dom calls instead to create your elements...kinda like

Element circle =
document.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
SVGConstants.SVG_CIRCLE_TAG);

and

circle.setAttributeNS(null, Double.toString(cx));




On Wed, Sep 29, 2010 at 11:48 AM, David Eccles (programming) 
programm...@gringer.org wrote:

 I'm interested in dynamically overlaying SVG elements on a world map, and
 can't
 work out why things aren't working for me. I confess that I don't really
 understand the swing process, so have tried to change code I found
 elsewhere
 (for the invokeLater method) in order to get this working. I know I'm using
 sleeps instead of listeners in the main method -- those will change later
 on
 once I get things displaying properly:

 What should happen is that a huge white circle should appear centered on
 Atlanta. This doesn't happen, but the map displays. The map is a 1000x420
 SVG
 image of the world (
 http://user.interface.org.nz/~gringer/pics/worldmap.svghttp://user.interface.org.nz/%7Egringer/pics/worldmap.svg
 ).

 What things am I doing wrong?

 Code is shown below:

 import java.awt.BorderLayout;
 import java.io.File;
 import java.util.Vector;
 import javax.swing.JFrame;
 import org.apache.batik.swing.JSVGCanvas;
 import org.w3c.dom.Element;

 public class Pathogenic {

JSVGCanvas boardDrawing;

public Pathogenic(JSVGCanvas drawing){
boardDrawing = drawing;
}

public boolean drawCities(final VectorCity cityList){
final double mapMinX = -170;
final double mapMinY = -90;
final double mapSizeX = 1000;
final double mapSizeY = 420;
boardDrawing.getUpdateManager().getUpdateRunnableQueue().invokeLater
  (new Runnable() {
  public void run() {
  for(City tCity : cityList){
  double cx =  (tCity.getX() - mapMinX) * (mapSizeX /
 360.0);
  double cy =  (tCity.getY() - mapMinY) * (mapSizeY /
 180.0);
  Element cityCirc =
 boardDrawing.getSVGDocument().createElement(circle);
  cityCirc.setAttribute(cx, Double.toString(cx));
  cityCirc.setAttribute(cy, Double.toString(cy));
  cityCirc.setAttribute(r, 50);

 cityCirc.setAttribute(style,fill:white;stroke:black;stroke-width:3);

 boardDrawing.getSVGDocument().getRootElement().appendChild(cityCirc);
  System.out.println(Drawing  + tCity.getName() +  at
  +
 cx + , + cy);
  }
  }
  });
return true;
}

/**
 * @param args
 */
public static void main(String[] args) {

JFrame program = new JFrame(Pathogenic);
program.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
program.setLayout(new BorderLayout());
JSVGCanvas mapScreen = new JSVGCanvas();
mapScreen.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
program.add(mapScreen, BorderLayout.CENTER);
File wmFile = new File(data/worldmap.svg);
mapScreen.loadSVGDocument(wmFile.toURI().toString());
// mapScreen.setURI(wmFile.toURI().toString());
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
program.pack();
program.setVisible(true);
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Board b = new Board();
b.addCity(Atlanta, -84.39, 33.755);
Pathogenic myApp = new Pathogenic(mapScreen);
myApp.drawCities(b.getCities());
mapScreen.repaint();
}

 }

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Movable elements and events

2010-08-31 Thread jonathan wood
Here's an oversimplified example it has embedded javascript, but the
calls are virtually the same.  You'll need to merge the new translate with
the existing transform in more complex applications .

Hope it helps

?xml version=1.0 encoding=UTF-8 standalone=no ?
svg version=1.1 width=100% height=100% xmlns=
http://www.w3.org/2000/svg; onload=init() pointer-events=all
script type=text/ecmascript
![CDATA[
var drag = false;
var svg;
var draggable;

function init(e) {
svg = document.documentElement;
var rect = document.getElementById(draggable);
rect.addEventListener(mousedown, md, false);
svg.addEventListener(mousemove, mm, false);
svg.addEventListener(mouseup, mu, false);
}

function md(e) {
drag = true;
draggable = e.currentTarget;
}

function mu(e) {
drag = false;
}

function mm(e) {
if (drag) {
var p = getPoint(e);
var m = svg.createSVGMatrix().translate(p.x, p.y);
var transform = matrix( + m.a +   + m.b +   + m.c + 
 + m.d +   + m.e +   + m.f + );
draggable.setAttributeNS(null, transform, transform);
}
}

function getPoint(e) {
var p = svg.createSVGPoint();
p.x = e.clientX;
p.y = e.clientY;
p = p.matrixTransform(svg.getScreenCTM().inverse());
return p;
}
]]
/script
rect id=background x=0 y=0 width=100% height=100% fill=#BBB
stroke=#000 /
rect id=draggable x=0 y=0 height=100 width=100
fill=cornflowerblue/
/svg

On Tue, Aug 31, 2010 at 2:11 PM, shootist kwilson4...@gmail.com wrote:


 An example would be great.  I'm very new to svg and batik (I just started
 using it), and there are a number of things I need to implement if it's
 even
 possible.  I managed to get a movable element working last night, but I'm
 positive it's not the best implementation possible.

 How would you suggest setting the location of the elements?  I need to
 translate the on screen coordinates to and from a real world coordinate
 system using ratios so I will need access to some sort of concrete
 coordinate.

 As for the translation, I found some code that does it differently.  Is
 there a down side to this compared to your suggestion?

 SVGOMPoint pt = new SVGOMPoint(e.getX(), e.getY());
 SVGMatrix mat = this.getSVGDocument().getRootElement().getScreenCTM();  //
 elem - screen
 mat = mat.inverse();  // screen - elem
 pt = (SVGOMPoint) pt.matrixTransform(mat);

 Again, thank you for the help.



 jonathan wood-3 wrote:
 
  I've always had alot of success adding my draggable Elements to a parent
  g
  with pointer-events=all.  Place the mousemove listener on the
 containing
  g. If you capture the point in mousedown (p1), you can use p1 and the
  mousemove point (p2, likely transformed to the correct coord system) to
  determine the appropriate transform to apply
  (AffineTransform.getTranslateInstace(p2.x - p1.x, p2.y - p1.y)).
 
  I'd caution you against trying to use absolute x,y attribute sets as this
  approach is not feasible in complex implementations. (Just in case your
 on
  that path...)
 
  I can likely provide an example in short order if you want a spoiler
 
  On Mon, Aug 30, 2010 at 11:05 AM, shootist kwilson4...@gmail.com
 wrote:
 
 
  I tried finding a post here with a similar issue but had no luck.  I am
  attempting to create movable icons using an image element.
 
  If I add the event listener directly to the image element, it does work
  but
  if you move the mouse fast, you of course get outside the element and
  lose
  the listener (painting can not keep up with the events).
 
  If I add the event listener to the root element, and check for the
  element
  type, it managed to find the type of elements I want and change the
  cursor
  on mouseover like it should.  But, it will not move the element.
 
  Troubleshooting
  One interesting thing I noticed, is when I print ((Element)
  evt.getCurrentTarget()).getTagName() I get svg when the listener is
 added
  to
  the root, and image when the listener is added to the image element
 only.
  This would make sense to me if I wasn't able to distinguish between
  elements
  and only mouse over on the image elements (I added a tag called movable
  and
  can check that the element has that tag and only change the cursor for
  those
  elements).
 
  Any ideas as to what I'm doing wrong?  Or is there a better way to
 create
  movable elements?  Thanks in advance for any help.
 
  --
  View this message in context:
 
 http://old.nabble.com/Movable-elements-and-events-tp29573506p29573506.html
  Sent from the Batik - Users mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: batik-users-unsubscr

Re: Movable elements and events

2010-08-30 Thread jonathan wood
I've always had alot of success adding my draggable Elements to a parent g
with pointer-events=all.  Place the mousemove listener on the containing
g. If you capture the point in mousedown (p1), you can use p1 and the
mousemove point (p2, likely transformed to the correct coord system) to
determine the appropriate transform to apply
(AffineTransform.getTranslateInstace(p2.x - p1.x, p2.y - p1.y)).

I'd caution you against trying to use absolute x,y attribute sets as this
approach is not feasible in complex implementations. (Just in case your on
that path...)

I can likely provide an example in short order if you want a spoiler

On Mon, Aug 30, 2010 at 11:05 AM, shootist kwilson4...@gmail.com wrote:


 I tried finding a post here with a similar issue but had no luck.  I am
 attempting to create movable icons using an image element.

 If I add the event listener directly to the image element, it does work but
 if you move the mouse fast, you of course get outside the element and lose
 the listener (painting can not keep up with the events).

 If I add the event listener to the root element, and check for the element
 type, it managed to find the type of elements I want and change the cursor
 on mouseover like it should.  But, it will not move the element.

 Troubleshooting
 One interesting thing I noticed, is when I print ((Element)
 evt.getCurrentTarget()).getTagName() I get svg when the listener is added
 to
 the root, and image when the listener is added to the image element only.
 This would make sense to me if I wasn't able to distinguish between
 elements
 and only mouse over on the image elements (I added a tag called movable and
 can check that the element has that tag and only change the cursor for
 those
 elements).

 Any ideas as to what I'm doing wrong?  Or is there a better way to create
 movable elements?  Thanks in advance for any help.

 --
 View this message in context:
 http://old.nabble.com/Movable-elements-and-events-tp29573506p29573506.html
 Sent from the Batik - Users mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Movable elements and events

2010-08-30 Thread jonathan wood
forgot to give my 2 cents on the below...


 Troubleshooting
 One interesting thing I noticed, is when I print ((Element)
 evt.getCurrentTarget()).getTagName() I get svg when the listener is added
 to
 the root, and image when the listener is added to the image element only.
 This would make sense to me if I wasn't able to distinguish between
 elements
 and only mouse over on the image elements (I added a tag called movable
 and
 can check that the element has that tag and only change the cursor for
 those
 elements).


You are likely getting the bubbled event call on the root element.  If both
the element and root have an event listener, you may need to check the
result of event.getCurrentTarget(). Also check out event.stopPropagaton() as
it may be very useful to you.


Re: OK to rescale SVG in PDF by changing just width and height values?

2010-07-21 Thread jonathan wood
Hi Joe,

  Be aware that some illustrator versions (  CS3?) can drop viewBox's upon
export.  This may only be true for automated exports via javascript, I don't
recall.

If you are looking to add to a command line toolkit for your automated
document creation, you might look into using XSLT to modify the w/h values.
Xalan is packaged with Batik.

http://en.wikipedia.org/wiki/XSLT

http://xml.apache.org/xalan-j/


On Wed, Jul 21, 2010 at 9:24 AM, Joe Pairman joeyp2...@gmail.com wrote:

 Hi Thomas,

 On Wed, Jul 21, 2010 at 8:15 PM,  thomas.dewe...@kodak.com wrote:
  Hi Joe,
 
  Joe Pairman joeyp2...@gmail.com wrote on 07/21/2010 03:20:49 AM:
 
  Thanks for the tip, Jonathan. I tried a couple of test cases and it
  seems the default is fine for that.
 
 Just a word of caution that this will only work if the document
  has a viewBox attribute.

 Thanks. That's good to know. It *seems* that SVGs exported from
 Illustrator always have a viewBox, but I'll check.

  I have a follow-up question. Is it possible to use Batik via the
  Windows command line to change the width and height values by a
  certain percentage?
 
  I'm not aware of a way to do that.  You can set the width and
  height from the command line but you can't change them by a percentage.
 
  I read that the transcoder could change these
  values, but all the information I can find so far concerns the
  transcoder API; not anything directly accessible via the command line.
 
 If you run the rasterizer with no arguments it should print help text.

 I should have explained more clearly. I actually want to change the
 width and height values in the source SVG, as I'm using the SVG
 directly in PDFs. If Batik (from the command line) offered either a
 way to scale those by a certain percentage, or at least to get the
 original values and then change them, that would be very helpful. But
 it's looking like I need to use another tool.

 I'm using the rasterizer to convert the same SVGs for web output, not
 PDF. I just thought that as I need Batik for that, it would be neat if
 I could also use Batik to edit the source SVG for PDF output.

 Cheers,
 Joe

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: OK to rescale SVG in PDF by changing just width and height values?

2010-07-20 Thread jonathan wood
You might also keep the preserveAspectRatio attribute in mind if a viewBox
is present, although the xMidYMid default is exactly what you describe in
your use case...

http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute


On Tue, Jul 20, 2010 at 11:19 AM, Joe Pairman joeyp2...@gmail.com wrote:

 I'm including SVG graphics in PDF user guides. I need to control the
 displayed size programmatically, effectively scaling the SVG including
 all its content. The best result I've had so far is by changing only
 the values of the width and height attributes, leaving everything else
 untouched, and not even changing the viewBox. This would seem to fit
 with Martin Jacobson's description here:

 http://old.nabble.com/Affine-Transforms-on-JSVGCanvas-Objects-to25206324.html#a25209903
 The physical (ie display/print) dimensions are given by the width
 and height  attributes, while
 the drawing dimensions are described by the viewPort attribute.

 Is there anything I should beware of when using this approach to
 resize/rescale SVG? Anything I'm missing?

 Thanks for any tips.
 Joe

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: ClassCast Error

2010-07-19 Thread jonathan wood
Hi Christian,


My guess is that the container's xerces implementation differs from the one
embedded in your app/batik.  Seems the dom implementation is loaded and
resused on first reference (and by the first referencer).  Maybe try
dropping the apps xerces lib and see if the containers implementation will
work?



On Mon, Jul 19, 2010 at 4:12 PM, Christian Bockermann 
christian.bockerm...@udo.edu wrote:

 Hi!

 Thanks again for helping me out with my former problem. I got my conversion
 running in a standalone Java application. Batik is doing excellent!!

 However, as soon as I deploy my code into a web-application I run into some
 class-cast errors:

 Exception in thread Thread-17 java.lang.ExceptionInInitializerError
at
 org.apache.batik.transcoder.SVGAbstractTranscoder.init(SVGAbstractTranscoder.java:123)
at
 org.apache.batik.transcoder.image.ImageTranscoder.init(ImageTranscoder.java:75)
at
 org.apache.batik.transcoder.image.PNGTranscoder.init(PNGTranscoder.java:44)

 Caused by: java.lang.ClassCastException:
 org.apache.batik.extension.svg.BatikDomExtension cannot be cast to
 org.apache.batik.dom.DomExtension
at
 org.apache.batik.dom.ExtensibleDOMImplementation.getDomExtensions(ExtensibleDOMImplementation.java:280)
at
 org.apache.batik.dom.ExtensibleDOMImplementation.init(ExtensibleDOMImplementation.java:95)
at
 org.apache.batik.dom.svg.SVGDOMImplementation.init(SVGDOMImplementation.java:91)
at
 org.apache.batik.dom.svg.SVGDOMImplementation.clinit(SVGDOMImplementation.java:1596)
... 15 more


 I suspect this to be related to DOM implementations, e.g. one provided by
 the
 servlet-container (jetty) or the like. Does anyone have experiences with
 that?


 Best regards,

Christian
 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: SVG Colors inversion

2010-06-25 Thread jonathan wood
It's hard to say if this would be more performant, but this might be a good
use case for 
feColorMatrixElementhttp://www.w3.org/TR/SVG/filters.html#feColorMatrixElement

On Fri, Jun 25, 2010 at 6:18 AM, Julien Beghin minimoi1...@hotmail.comwrote:

  Hello to all... (and happy summer ^^)



 Im working on a project using Batik and dealing with SVG !



 One part of this project consists in a kind of color inversion of some
 elements in the displayed SVG.

 In fact, only black(resp white) have to be converted in  white(resp black).



 The first solution is to look for each SVG elements in the displayed SVG.
 For each element we can set the color to white/black.

 This solution is really slow ( more than a minute...) and this can't be
 acceptable.

 - Document state is ALWAYS_DYNAMIC if can help



 Another idea was to add an overlay, and inverting color of each pixel if
 required, but the result is not convincing, probably because of antialising
 and rendering of the graphic, which introduces gray level pixel. These pixel
 are not inverted by our overlay... and each refresh takes aout 2seconds (
 well.. depends on the screen resolution in fact ^^)



 Do one of you have an idea on how to do this in optimisng
 performance(speed) and without grahics losts ?



 ANy help would be appreciated

 --
 Votre vie privée l'est-elle vraiment ? Internet Explorer 8 vous protège
 gratuitement ! http://clk.atdmt.com/FRM/go/232102478/direct/01/



Re: How do I superimpose one SVG image onto another?

2010-06-15 Thread jonathan wood
This should be pretty straightforward...

given background.svg)

svg viewBox=0 0 308 308 xmlns:svg=http://www.w3.org/2000/svg; xmlns=
http://www.w3.org/2000/svg; xmlns:xlink=http://www.w3.org/1999/xlink;
   rect width=308 height=308 fill=#112277/
/svg


and foreground.svg

svg viewBox=-24 -24 356 356 xmlns:svg=http://www.w3.org/2000/svg;
xmlns=http://www.w3.org/2000/svg; xmlns:xlink=http://www.w3.org/1999/xlink

 rect width=308 height=308 fill=#772211/
/svg


transcoding the following will produce the overlay

?xml version=1.0 encoding=UTF-8 standalone=no?
svg xmlns:svg=http://www.w3.org/2000/svg; xmlns=
http://www.w3.org/2000/svg; xmlns:xlink=http://www.w3.org/1999/xlink;
image x=0 y=0 width=308 height=308
xlink:href=background.svg/
image x=0 y=0 width=308 height=308
xlink:href=foreground.svg/
/svg




On Tue, Jun 15, 2010 at 9:35 AM, olivierk okite...@gmail.com wrote:


 batik dom manipulation code :)
 Our application generate various types of 2D barcodes in different formats
 (BMP, JPG and PNG) and our clients have requested that we add support for
 SVG.
 I have looked at the using Batik section on Batik website but did not
 find
 any example of overlaying 2 images.


 jonathan wood-3 wrote:
 
  do you need an xml representation or batik dom manipulation code?
 
 
  On Mon, Jun 14, 2010 at 10:18 AM, olivierk okite...@gmail.com wrote:
 
 
  I have 2 SVG files I need to overlay. One file serve as the background
  image
  and is 308px by 308px while the second file (260px by 260px) is the
  foreground image that must be centered (that is at the center of the
  background image). I'd like the result of the operation to be saved in a
  third SVG file. Any suggestions?
  Thanks,
 
  Olivier.
 
  --
  View this message in context:
 
 http://old.nabble.com/How-do-I-superimpose-one-SVG-image-onto-another--tp28880111p28880111.html
  Sent from the Batik - Users mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
  For additional commands, e-mail:
 batik-users-h...@xmlgraphics.apache.org
 
 
 
 

 --
 View this message in context:
 http://old.nabble.com/How-do-I-superimpose-one-SVG-image-onto-another--tp28880111p28891380.html
 Sent from the Batik - Users mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: How do I superimpose one SVG image onto another?

2010-06-15 Thread jonathan wood
my input svg dimensions are identical, unlike your inputs...you'll need to
adjust accordingly


On Tue, Jun 15, 2010 at 5:47 PM, jonathan wood
jonathanshaww...@gmail.comwrote:


 This should be pretty straightforward...

 given background.svg)

 svg viewBox=0 0 308 308 xmlns:svg=http://www.w3.org/2000/svg; xmlns=
 http://www.w3.org/2000/svg; xmlns:xlink=http://www.w3.org/1999/xlink;
rect width=308 height=308 fill=#112277/
 /svg


 and foreground.svg

 svg viewBox=-24 -24 356 356 xmlns:svg=http://www.w3.org/2000/svg;
 xmlns=http://www.w3.org/2000/svg; xmlns:xlink=
 http://www.w3.org/1999/xlink;
  rect width=308 height=308 fill=#772211/
 /svg


 transcoding the following will produce the overlay

 ?xml version=1.0 encoding=UTF-8 standalone=no?
 svg xmlns:svg=http://www.w3.org/2000/svg; xmlns=
 http://www.w3.org/2000/svg; xmlns:xlink=http://www.w3.org/1999/xlink;
 image x=0 y=0 width=308 height=308
 xlink:href=background.svg/
 image x=0 y=0 width=308 height=308
 xlink:href=foreground.svg/
 /svg





 On Tue, Jun 15, 2010 at 9:35 AM, olivierk okite...@gmail.com wrote:


 batik dom manipulation code :)
 Our application generate various types of 2D barcodes in different formats
 (BMP, JPG and PNG) and our clients have requested that we add support for
 SVG.
 I have looked at the using Batik section on Batik website but did not
 find
 any example of overlaying 2 images.


 jonathan wood-3 wrote:
 
  do you need an xml representation or batik dom manipulation code?
 
 
  On Mon, Jun 14, 2010 at 10:18 AM, olivierk okite...@gmail.com wrote:
 
 
  I have 2 SVG files I need to overlay. One file serve as the background
  image
  and is 308px by 308px while the second file (260px by 260px) is the
  foreground image that must be centered (that is at the center of the
  background image). I'd like the result of the operation to be saved in
 a
  third SVG file. Any suggestions?
  Thanks,
 
  Olivier.
 
  --
  View this message in context:
 
 http://old.nabble.com/How-do-I-superimpose-one-SVG-image-onto-another--tp28880111p28880111.html
  Sent from the Batik - Users mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
  For additional commands, e-mail:
 batik-users-h...@xmlgraphics.apache.org
 
 
 
 

 --
 View this message in context:
 http://old.nabble.com/How-do-I-superimpose-one-SVG-image-onto-another--tp28880111p28891380.html
 Sent from the Batik - Users mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org





Re: How do I superimpose one SVG image onto another?

2010-06-14 Thread jonathan wood
do you need an xml representation or batik dom manipulation code?


On Mon, Jun 14, 2010 at 10:18 AM, olivierk okite...@gmail.com wrote:


 I have 2 SVG files I need to overlay. One file serve as the background
 image
 and is 308px by 308px while the second file (260px by 260px) is the
 foreground image that must be centered (that is at the center of the
 background image). I'd like the result of the operation to be saved in a
 third SVG file. Any suggestions?
 Thanks,

 Olivier.

 --
 View this message in context:
 http://old.nabble.com/How-do-I-superimpose-one-SVG-image-onto-another--tp28880111p28880111.html
 Sent from the Batik - Users mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: svg and opengl

2010-05-29 Thread jonathan wood
essentially, but the texture is live with respect to svg DOM changes.
Like having an animatable billboard..texture2d with backend.

On Sat, May 29, 2010 at 7:02 AM, Matthew Pocock matthew.poc...@ncl.ac.ukwrote:

 So you are rendering textures with batik and using these as textures in
 jogl?

 Matthew


 On 29 May 2010 01:41, jonathan wood jonathanshaww...@gmail.com wrote:

 Hello my non-affine friend!

 I would not say that I delegate so much as backfill with batik in
 jogl.  In this situation, batik's long load time is an advantage..I've done
 simple modeling using batik's 2d output as the fulfillment end of an async
 load (procedual texture??)works well after the initial performance hit
 (insert progress bar here).

 Any common ground?

 Jonathan

 On Fri, May 28, 2010 at 7:28 PM, Matthew Pocock matthew.poc...@ncl.ac.uk
  wrote:

 Hi,

 Is anyone working on an SVG renderer that delegates through to opengl? My
 experiencwe of uasing jogl vs java2d is that you get 50-100x performance
 gains for rendering primitives. I'd like to use batik as a the scene-graph
 for some data visualisation, but right now it will not scale to the large
 number of elements I need to render.

 If nobody is currently on to this, could I have pointers as to where I
 would start in devloping my own rendering pipeline for the svg dom.

 Thanks,

 Matthew






Re: svg and opengl

2010-05-28 Thread jonathan wood
Hello my non-affine friend!

I would not say that I delegate so much as backfill with batik in jogl.
In this situation, batik's long load time is an advantage..I've done simple
modeling using batik's 2d output as the fulfillment end of an async load
(procedual texture??)works well after the initial performance hit
(insert progress bar here).

Any common ground?

Jonathan
On Fri, May 28, 2010 at 7:28 PM, Matthew Pocock matthew.poc...@ncl.ac.ukwrote:

 Hi,

 Is anyone working on an SVG renderer that delegates through to opengl? My
 experiencwe of uasing jogl vs java2d is that you get 50-100x performance
 gains for rendering primitives. I'd like to use batik as a the scene-graph
 for some data visualisation, but right now it will not scale to the large
 number of elements I need to render.

 If nobody is currently on to this, could I have pointers as to where I
 would start in devloping my own rendering pipeline for the svg dom.

 Thanks,

 Matthew



Re: Rasterizing produces 2 empty IDAT chunks

2010-05-21 Thread jonathan wood
Thanks much Thomas.

My apologies for any confusion I may have caused.


On Fri, May 21, 2010 at 6:02 AM, thomas.dewe...@kodak.com wrote:

 Hi All,

 It's now fixed in SVN (rev 946961).

 jonathan wood jonathanshaww...@gmail.com wrote on 05/20/2010 10:41:16
 PM:


  Very much agreed.  I also think I was way offI missed the close
  () override on the underlying stream.

  On Thu, May 20, 2010 at 9:26 PM, Cameron McCormack c...@mcc.id.au
 wrote:
  Thomas DeWeese:
Really in my mind the main issue is that you should be able to call
flush whenever you want and not cause real havok which isn't the
case without the proposed patch.

  jonathan wood:
   I agree...why the closed underlying stream allows modification seems
 a bit
   perverse.

  I agree with both of those points.  The simple fix of not writing a zero
  length IDAT chunk when flush() is called seems best to me.
 
  --
  Cameron McCormack ≝ http://mcc.id.au/
 
  -
  To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
  For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Rasterizing produces 2 empty IDAT chunks

2010-05-20 Thread jonathan wood
I guess I should have been more specific about why I think this is the
correct resolution:

DataOutputStream.close()http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/DeflaterOutputStream.html#close%28%29claims
to close the underlying stream (ios).  Ios is then flush()'ed  and
close()'ed, after it has already been closed.

I think the real issue is the addition of the deflateroutputstream close to
fix the sun finalizer problem with native zlib (bug
46863http://old.nabble.com/DO-NOT-REPLY--Bug-46863--New%3A-DeflaterOutputStream-not-closed,-causes-OutOfMemoryError-td22545206.html
)

On Thu, May 20, 2010 at 8:04 AM, thomas.dewe...@kodak.com wrote:

 Hi Johnathan,.

 jonathan wood jonathanshaww...@gmail.com wrote on 05/18/2010 08:29:49
 PM:


  Looks like a double close on an output stream...

 IMHO that shouldn't be a problem...

  I believe the solution is to apply the following to org/apache/
  batik/ext/awt/image/codec/png/PNGImageEncoder.java, although I'd
  rely on Thomas DeWeese or other committer to verify.

 It seems to me the simplest (and potentially the safest)
 would be to modify the IDATOutputStream so that flush does nothing
 if no bytes have been written:

 Index:
 sources/org/apache/batik/ext/awt/image/codec/png/PNGImageEncoder.java
 ===
 --- sources/org/apache/batik/ext/awt/image/codec/png/PNGImageEncoder.java
(revision 897441)
 +++ sources/org/apache/batik/ext/awt/image/codec/png/PNGImageEncoder.java
(working copy)
 @@ -211,6 +211,8 @@
  }

  public void flush() throws IOException {
 +if (bytesWritten == 0) return;
 +
  // Length
  writeInt(bytesWritten);
  // 'IDAT' signature

  - removed ios.flush() and ios.close() since DeflaterOutputStream
  claims to complete the stream write and close the close the underlying
 stream

 It seems to me we have gotten in trouble before when we didn't
 close
 streams. It's possible that doesn't apply here but still I'd feel better
 leaving the close calls.  I don't feel quite a strongly about the flush
 as it is clear buffered data should be flushed before closing.

 Really in my mind the main issue is that you should be able to call
 flush whenever you want and not cause real havok which isn't the case
 without the proposed patch.




Re: Rasterizing produces 2 empty IDAT chunks

2010-05-20 Thread jonathan wood
Correction to the first linkit should read DeflaterOutputStream...the
target of the link is correct.

I may also be misunderstanding the javadoc.


On Thu, May 20, 2010 at 10:22 AM, jonathan wood
jonathanshaww...@gmail.comwrote:


 I guess I should have been more specific about why I think this is the
 correct resolution:

 DataOutputStream.close()http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/DeflaterOutputStream.html#close%28%29claims
  to close the underlying stream (ios).  Ios is then flush()'ed  and
 close()'ed, after it has already been closed.

 I think the real issue is the addition of the deflateroutputstream close to
 fix the sun finalizer problem with native zlib (bug 
 46863http://old.nabble.com/DO-NOT-REPLY--Bug-46863--New%3A-DeflaterOutputStream-not-closed,-causes-OutOfMemoryError-td22545206.html
 )


 On Thu, May 20, 2010 at 8:04 AM, thomas.dewe...@kodak.com wrote:

 Hi Johnathan,.

 jonathan wood jonathanshaww...@gmail.com wrote on 05/18/2010 08:29:49
 PM:


  Looks like a double close on an output stream...

 IMHO that shouldn't be a problem...

  I believe the solution is to apply the following to org/apache/
  batik/ext/awt/image/codec/png/PNGImageEncoder.java, although I'd
  rely on Thomas DeWeese or other committer to verify.

 It seems to me the simplest (and potentially the safest)
 would be to modify the IDATOutputStream so that flush does nothing
 if no bytes have been written:

 Index:
 sources/org/apache/batik/ext/awt/image/codec/png/PNGImageEncoder.java
 ===
 --- sources/org/apache/batik/ext/awt/image/codec/png/PNGImageEncoder.java
  (revision 897441)
 +++ sources/org/apache/batik/ext/awt/image/codec/png/PNGImageEncoder.java
  (working copy)
 @@ -211,6 +211,8 @@
  }

  public void flush() throws IOException {
 +if (bytesWritten == 0) return;
 +
  // Length
  writeInt(bytesWritten);
  // 'IDAT' signature

  - removed ios.flush() and ios.close() since DeflaterOutputStream
  claims to complete the stream write and close the close the underlying
 stream

 It seems to me we have gotten in trouble before when we didn't
 close
 streams. It's possible that doesn't apply here but still I'd feel better
 leaving the close calls.  I don't feel quite a strongly about the flush
 as it is clear buffered data should be flushed before closing.

 Really in my mind the main issue is that you should be able to
 call
 flush whenever you want and not cause real havok which isn't the case
 without the proposed patch.





Re: Rasterizing produces 2 empty IDAT chunks

2010-05-20 Thread jonathan wood
Apologies for not completely responding ...

Really in my mind the main issue is that you should be able to call
 flush whenever you want and not cause real havok which isn't the case
 without the proposed patch.


I agree...why the closed underlying stream allows modification seems a bit
perverse.


Re: Rasterizing produces 2 empty IDAT chunks

2010-05-20 Thread jonathan wood
Very much agreed.  I also think I was way offI missed the close()
override on the underlying stream.



On Thu, May 20, 2010 at 9:26 PM, Cameron McCormack c...@mcc.id.au wrote:

 Thomas DeWeese:
   Really in my mind the main issue is that you should be able to call
   flush whenever you want and not cause real havok which isn't the
   case without the proposed patch.

 jonathan wood:
  I agree...why the closed underlying stream allows modification seems a
 bit
  perverse.

 I agree with both of those points.  The simple fix of not writing a zero
 length IDAT chunk when flush() is called seems best to me.

 --
 Cameron McCormack ≝ http://mcc.id.au/

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Getting a bounded box

2010-05-19 Thread jonathan wood
I've always used:

SVGRedt bbox = ((SVGLocatable)element).getBBox();

you may need to account for the transforms alsouse
SVGLocatable.getTransformToElement() and SVGPoint.matrixTransform() if
needed





On Wed, May 19, 2010 at 10:14 AM, Julien Beghin minimoi1...@hotmail.comwrote:

  Hi there,



 We are dealing with a matter of bounded box :



 First of all, we are defining a link  via the use tag like following :



 use transform=translate(180,-325) xmlns:xlink=
 http://www.w3.org/1999/xlink;
 xlink:href=#6b0e597d-917e-4534-bb96-178a151a146c xlink:type=simple
 xlink:actuate=onLoad id=INSTANCE_6b0e597d-917e-4534-bb96-178a151a146c
 xlink:show=embed pointer-events=stroke/



 This link points towrds a group in the definition part :



 g id=6b0e597d-917e-4534-bb96-178a151a146c cursor=pointer
 transform=scale(1.00,-1.00) stroke-linejoin=round
 stroke-linecap=round

 desc0LHT026VE/desc

 text style=text-anchor:middle;font-size:2.5pt;font-family:monotxt
 transform=translate(0.0,-2.5) scale(1,-1) rotate(-0.0)
 scale(1.0,1)

 tspan dx=0 dy=2.5 fill=rgb(0,0,0) x=0 xml:space=preserve
 stroke=rgb(0,0,0)026VE/tspan

 /text

 path fill=none d=M -2.5 -1.5 L -2.5 1.5 L 2.5 -1.5 L 2.5 1.5
 stroke-dasharray=1.0,1.0 stroke-width=0.60
 stroke=rgb(0,0,0)/

 path fill=none stroke-width=0.80
 stroke-dasharray=1.0,1.0 d=M -2.9 1.25 A 0.4 0.4 0.0 1 1 -2.1
 1.25 A 0.4 0.4 0.0 1 1 -2.9 1.25 stroke=rgb(0,0,0)/

 /g



 What we are wanting to do is to get the bounded box of the text element, in
 this group.

 There is no problem with getting the bounded box of the whole group, but
 curiously, I can't find a way to only the text's bounded box



 Can someone help ?



 Regards,



 Julien

 --
 De nouvelles Emoticones sur Messenger ? Téléchargez les Emoticones pâte à
 modeler 
 !http://www.ilovemessenger.fr/emoticones/emoticones-pate-a-modeler.aspx



Re: Getting a bounded box

2010-05-19 Thread jonathan wood
Are you calling the method while in the update thread?  If I recall
correctly, it may be required be required

If needed, wrapper with something like:

getUpdateManager().getUpdateRunnableQueue().invokeLater(new Runnable() {
public void run() {
   get bbox
}
});


On Wed, May 19, 2010 at 11:37 AM, Julien Beghin minimoi1...@hotmail.comwrote:

  Well both of the solutions seem's to do nothing 

 The getBBox method always return null, maybe because the tesxt element is
 location under the group tag (G) and in the définition part,
 The text is not under a use tag...

 Any other idea ?

 --
 From: jonathanshaww...@gmail.com
 Date: Wed, 19 May 2010 11:24:11 -0400
 Subject: Re: Getting a bounded box
 To: batik-users@xmlgraphics.apache.org


 I've always used:

 SVGRedt bbox = ((SVGLocatable)element).getBBox();

 you may need to account for the transforms alsouse
 SVGLocatable.getTransformToElement() and SVGPoint.matrixTransform() if
 needed





 On Wed, May 19, 2010 at 10:14 AM, Julien Beghin 
 minimoi1...@hotmail.comwrote:

  Hi there,



 We are dealing with a matter of bounded box :



 First of all, we are defining a link  via the use tag like following :



 use transform=translate(180,-325) xmlns:xlink=
 http://www.w3.org/1999/xlink;
 xlink:href=#6b0e597d-917e-4534-bb96-178a151a146c xlink:type=simple
 xlink:actuate=onLoad id=INSTANCE_6b0e597d-917e-4534-bb96-178a151a146c
 xlink:show=embed pointer-events=stroke/



 This link points towrds a group in the definition part :



 g id=6b0e597d-917e-4534-bb96-178a151a146c cursor=pointer
 transform=scale(1.00,-1.00) stroke-linejoin=round
 stroke-linecap=round

 desc0LHT026VE/desc

 text style=text-anchor:middle;font-size:2.5pt;font-family:monotxt
 transform=translate(0.0,-2.5) scale(1,-1) rotate(-0.0)
 scale(1.0,1)

 tspan dx=0 dy=2.5 fill=rgb(0,0,0) x=0 xml:space=preserve
 stroke=rgb(0,0,0)026VE/tspan

 /text

 path fill=none d=M -2.5 -1.5 L -2.5 1.5 L 2.5 -1.5 L 2.5 1.5
 stroke-dasharray=1.0,1.0 stroke-width=0.60
 stroke=rgb(0,0,0)/

 path fill=none stroke-width=0.80
 stroke-dasharray=1.0,1.0 d=M -2.9 1.25 A 0.4 0.4 0.0 1 1 -2.1
 1.25 A 0.4 0.4 0.0 1 1 -2.9 1.25 stroke=rgb(0,0,0)/

 /g



 What we are wanting to do is to get the bounded box of the text element, in
 this group.

 There is no problem with getting the bounded box of the whole group, but
 curiously, I can't find a way to only the text's bounded box



 Can someone help ?



 Regards,



 Julien

 --
 De nouvelles Emoticones sur Messenger ? Téléchargez les Emoticones pâte à
 modeler 
 !http://www.ilovemessenger.fr/emoticones/emoticones-pate-a-modeler.aspx



 --
 Envie de plus d'originalité dans vos conversations ? Téléchargez
 gratuitement les Emoch'ticones 
 !http://www.ilovemessenger.fr/emoticones/telecharger-emoticones-emochticones.aspx



Re: Rasterizing produces 2 empty IDAT chunks

2010-05-18 Thread jonathan wood
  This sounds like Bug
48693https://issues.apache.org/bugzilla/show_bug.cgi?id=48693.
Can you review the current bug and verify that is is the same issue?  If so,
I may have a bit of time to investigate.



On Tue, May 18, 2010 at 11:52 AM, IsmAvatar ismava...@gmail.com wrote:

 I guess this is a Bug Report

 The subject pretty much explains it all. Using Sun JDK 6u20, and batik
 checked out from the SVN repository, I use Rasterizer (actually
 RasterizerTask, but it calls Rasterizer, and I could reproduce it with
 Rasterizer if desired) on an SVG to generate a PNG. The PNG has 2 additional
 empty IDAT chunks immediately prior to the IEND chunk. These chunks cause
 the PNG to be erroneous (and thus not display) in certain programs, such as
 IE7, as well as Java programs that try to display the image (especially, as
 is my case, if attempting to use it as a Splash Screen).

 A sample SVG which may be used to reproduce this problem:


 http://svn2.xp-dev.com/svn/LateralGM/LateralGM/trunk/org/lateralgm/main/lgm-splash.svg


 Please do let me know if/when this has been fixed. I use RasterizerTask to
 automate the creation of my splash screen for my program while the program
 is being compiled and built for release, and since Batik's been generating
 these two extra IDAT chunks, my program runs without a splash screen.



Re: Rasterizing produces 2 empty IDAT chunks

2010-05-18 Thread jonathan wood
Looks like a double close on an output stream...

I believe the solution is to apply the following to
org/apache/batik/ext/awt/image/codec/png/PNGImageEncoder.java, although I'd
rely on Thomas DeWeese or other committer to verify.

Summary of changes:

- removed DeflaterOutputStream.finish() since it is redundant
(DeflaterOutputStream.close() is called immediately after and performs the
same operation if in a single filter scenario)
- removed ios.flush() and ios.close() since DeflaterOutputStream claims to
complete the stream write and close the close the underlying stream



output of svn diff (I've only commented out the possibly offensive lines)

*Index:
sources/org/apache/batik/ext/awt/image/codec/png/PNGImageEncoder.java
===
--- sources/org/apache/batik/ext/awt/image/codec/png/PNGImageEncoder.java
(revision 938691)
+++ sources/org/apache/batik/ext/awt/image/codec/png/PNGImageEncoder.java
(working copy)
@@ -501,10 +501,10 @@
 encodePass(dos, ras, 0, 0, 1, 1);
 }

-dos.finish();
+//dos.finish();
 dos.close();
-ios.flush();
-ios.close();
+//ios.flush();
+//ios.close();
 }

 private void writeIEND() throws IOException {
*


On Tue, May 18, 2010 at 6:56 PM, jonathan wood
jonathanshaww...@gmail.comwrote:


   This sounds like Bug 
 48693https://issues.apache.org/bugzilla/show_bug.cgi?id=48693.
 Can you review the current bug and verify that is is the same issue?  If so,
 I may have a bit of time to investigate.




 On Tue, May 18, 2010 at 11:52 AM, IsmAvatar ismava...@gmail.com wrote:

 I guess this is a Bug Report

 The subject pretty much explains it all. Using Sun JDK 6u20, and batik
 checked out from the SVN repository, I use Rasterizer (actually
 RasterizerTask, but it calls Rasterizer, and I could reproduce it with
 Rasterizer if desired) on an SVG to generate a PNG. The PNG has 2 additional
 empty IDAT chunks immediately prior to the IEND chunk. These chunks cause
 the PNG to be erroneous (and thus not display) in certain programs, such as
 IE7, as well as Java programs that try to display the image (especially, as
 is my case, if attempting to use it as a Splash Screen).

 A sample SVG which may be used to reproduce this problem:


 http://svn2.xp-dev.com/svn/LateralGM/LateralGM/trunk/org/lateralgm/main/lgm-splash.svg


 Please do let me know if/when this has been fixed. I use RasterizerTask to
 automate the creation of my splash screen for my program while the program
 is being compiled and built for release, and since Batik's been generating
 these two extra IDAT chunks, my program runs without a splash screen.





Re: How to resize an svg

2010-04-27 Thread jonathan wood
  Unless an alternate view/transform is specified, I believe that JSVGCanvas
will honor the viewBox attribute.  Check your svg input file to see if a
viewBox attribute is present or insert one programmatically after it is
loaded possibly.

for instance...if you want the canvas to show all of your svg (100x100) no
matter what the canvas size, use the following:

svg viewBox=0 0 100 100 ...

For reference:

http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute


On Tue, Apr 27, 2010 at 5:46 PM, Edouard Marquez animatri...@gmail.comwrote:

  Hello !

 I have a svg file of 100x100 pixels (for example).

 If I do a :

 JSVGCanvas svg = new JSVGCanvas();


 [...]



 svg.setSize(10,10);


  It will only show this part of the 100x100picture.

 Do you know how I can display a resized svg picture ?

 Thanks [?]

330.gif

Re: How to use org.apache.batik.bridge.UpdateManager?

2010-04-25 Thread jonathan wood
Hello Rishabh, Narendra and Praveen,

A couple of observations:

   You really have no context in which to manipulate the DOM until the
document is loaded.  Your best bet is to add a GVTTreeBuilderListener.
Also, it is much easier to work directly with the DOM objects and let the
GVT take care of rendering the 2D.
  Red the attached snippet carefully...the listener code is invoked after
the document is loaded.

private void runDemo() {
svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
svgCanvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
@Override
public void gvtBuildCompleted(GVTTreeBuilderEvent e) {

svgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
Runnable() {
public void run() {
Element rect =
svgCanvas.getSVGDocument().createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
SVGConstants.SVG_RECT_TAG);
rect.setAttributeNS(null,
SVGConstants.SVG_X_ATTRIBUTE, 100);
rect.setAttributeNS(null,
SVGConstants.SVG_Y_ATTRIBUTE, 100);
rect.setAttributeNS(null,
SVGConstants.SVG_WIDTH_ATTRIBUTE, 100);
rect.setAttributeNS(null,
SVGConstants.SVG_HEIGHT_ATTRIBUTE, 100);
rect.setAttributeNS(null,
SVGConstants.SVG_FILL_ATTRIBUTE, #ee);

svgCanvas.getSVGDocument().getDocumentElement().appendChild(rect);
}
});
}
});
Document doc =
SVGDOMImplementation.getDOMImplementation().createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI,
svg, null);
svgCanvas.setSVGDocument((SVGDocument) doc);
}


On Sun, Apr 25, 2010 at 1:23 AM, Rishabh Rao rishabhs...@gmail.com wrote:

 Hello!
 We are a team 3 students who are developing an opensource application
 called Chart Glazer. The application helps the users draw charts (process
 diagrams, organization charts etc.) easily. It is very much similar to
 Microsoft Office 2007's SmartArt.
 We're using Apache Batik and Java Swing for our development. Our project is
 hosted at http://kenai.com/projects/chartglazer.
 The FAQ at http://xmlgraphics.apache.org/batik/faq.html talks about using
 the UpdateManager.
 We are facing the exact same problem, as in section 3.3 of the FAQ, When I
 change the document in Java it only updates if I move the mouse over the
 canvas?
 We have reproduced our problem into a smaller application (called
 SVGApplication), using NetBeans. It has a JButton (called
 loadDocumentJButton) and a JSVGCanvas (called myJSVGCanvas) present inside a
 JScrollPane object.
 Our requirement is that when we click this loadDocumentJButton button,
 the the myJSVGCanvas object must display the myRectangle (see code
 below.)
 Here is the actionPerformed event handler for loadDocumentJButton...
 private void loadDocumentJButtonActionPerformed(java.awt.event.ActionEvent
 evt)
 {
 DOMImplementation myDOMImplementation =
 SVGDOMImplementation.getDOMImplementation();
 Document myDocument =
 myDOMImplementation.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI,
 svg, null);
 Element svgRoot = myDocument.getDocumentElement();

 SVGGraphics2D mySVGGraphics2D = new SVGGraphics2D(myDocument);
 mySVGGraphics2D.setSVGCanvasSize(new Dimension(320, 240));

 myJSVGCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
 myJSVGCanvas.setDocument(myDocument);

 Rectangle myRectangle = new Rectangle(10, 10, 60, 40);

 mySVGGraphics2D.draw(myRectangle);

 svgRoot.appendChild(mySVGGraphics2D.getRoot());
 }
 The rectangle is being displayed only when we move the mouse over the
 myJSVGCanvas object in the Swing GUI window.

 We understand that we must use UpdateManager to solve this problem. But we
 don't know how to use it. We searched a lot on the Internet and
 mail-archives, but we are not able to figure things out. We did not find any
 example programs. If we get an example program that demonstrates the use of
 UpdateManager, we will figure it out on our own. It would be great if you
 provide us with such an example program.
 Please help us.
 We are attaching the 3 files of SVGApplication (created usingNetBeans)
 for your reference. The above event handler function is located in the
 SVGView.java. Probably, the other two files will not be required; we have
 just attached it for completeness' sake.
 Thank you very much!
 Regards,
 Rishabh Rao, Narendra G S and Praveen K S


 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org



Re: How to create a svg animate tag during runtime and animate it?

2010-03-15 Thread jonathan wood
Hi Fabian,

  Note that although the Elements in the example are created at the
beginning of the example, the listener code block runs after the document is
loaded (after theGVTTreeBuilderEvent is fired).


On Mon, Mar 15, 2010 at 5:45 AM, Fabian Unfried i...@funfried.de wrote:

 Hi Jonathan,

 first of all thanks for your reply, but if you create the elements (rect
 and
 animate) and then create the document and load it, it should be the same if
 you already drawn the elements in a svg file and open it.

 Maybe I didn't mention that exactly, my problem is that I have already
 opened
 a svg file in my application and then would like to add an animation, but
 if
 I do this like in your example, it won't be animated.


 Kind Regards,


 Fabian

  Hi Fabian,
 
It is usually a case of getting the correct attributes.  Batik tends to
 follow the standard a bit more closely that some other implementations.
  The
 following code works for me...posted sans the JFrame init...assumes a class
 member JSVGCanvas named svgCanvas.
 
  private void runDemo() {
  svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
  svgCanvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
  @Override
  public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
 
 svgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
 Runnable() {
  public void run() {
  Element rect =

 svgCanvas.getSVGDocument().createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
 SVGConstants.SVG_RECT_TAG);
  rect.setAttributeNS(null,
 SVGConstants.SVG_X_ATTRIBUTE, 100);
  rect.setAttributeNS(null,
 SVGConstants.SVG_Y_ATTRIBUTE, 100);
  rect.setAttributeNS(null,
 SVGConstants.SVG_WIDTH_ATTRIBUTE, 100);
  rect.setAttributeNS(null,
 SVGConstants.SVG_HEIGHT_ATTRIBUTE, 100);
  rect.setAttributeNS(null,
 SVGConstants.SVG_FILL_ATTRIBUTE, #ee);
  Element animate =

 svgCanvas.getSVGDocument().createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
 SVGConstants.SVG_ANIMATE_TAG);
  animate.setAttributeNS(null,
 SVGConstants.SVG_ATTRIBUTE_NAME_ATTRIBUTE,
 SVGConstants.SVG_OPACITY_ATTRIBUTE);
  animate.setAttributeNS(null,
 SVGConstants.SVG_VALUES_ATTRIBUTE, 1;0);
  animate.setAttributeNS(null,
 SVGConstants.SVG_DUR_ATTRIBUTE, 3s);
  animate.setAttributeNS(null,
 SVGConstants.SVG_REPEAT_COUNT_ATTRIBUTE, indefinite);
  rect.appendChild(animate);
 
 svgCanvas.getSVGDocument().getDocumentElement().appendChild(rect);
  }
  });
  }
  });
  Document doc =
 SVGDOMImplementation.getDOMImplementation().createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI,
 svg,
 null);
  svgCanvas.setSVGDocument((SVGDocument) doc);
  }
 
 
 
 
 
  On Fri, Mar 12, 2010 at 8:35 AM, Fabian Unfried
 i...@funfried.demailto:i...@funfried.de wrote:
  Hi,
 
  I would like to know how to handle animations with batik, especially the
  animate tag.
 
  If I put the following svg code into an svg graphic and open it with a
 java
  application with batik all works just fine and it'll be animated:
 
  rect x=100 y=100 width=500 height=500
 animate attributeType=CSS attributeName=opacity
 calcMode=discrete
  from=1 to=0 dur=1s repeatCount=indefinite /
  /rect
 
 
  But what do I have to do, if I want to do exactly this during runtime?
 
  I've tried this:
 
 
  SVGOMAnimationElement animate = (SVGOMAnimationElement)
  this.svgDocument.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
  SVG12Constants.SVG_ANIMATE_TAG);
  animate.setAttribute(dur, 1s);
  animate.setAttribute(values, 0; 0; 1; 1);
  animate.setAttribute(keyTimes, 0; 0.5; 0.7; 1.0);
  animate.setAttribute(attributeName, opacity);
  animate.setAttribute(attributeType, CSS);
  animate.setAttribute(repeatCount, indefinite);
 
  rect.appendChild(animate);
 
  animate.beginElement();
 
 
  but this didn't get animated, so I've tried to use the
 SVGAnimationEngine,
 but
  I'm not sure how to use the addAnimation() method, or even if I need to
 do
  that:
 
  SVGAnimationEngine aEngine = getSVGAnimationEngine();
  aEngine.addAnimation((AnimationTarget) rect,
  SVGAnimationEngine.ANIM_TYPE_CSS, ?, ?, AbstractAnimation???);
 
  How can I setup an AbstractAnimation?
 
 
 
  Any help is very appreciated
 
  Thanks in advance.
 
  Kind regards,
 
  Fabian
 
  -
  To unsubscribe, e-mail:
 batik-users-unsubscr...@xmlgraphics.apache.orgmailto:
 batik-users-unsubscr...@xmlgraphics.apache.org
  For additional commands, e-mail:
 batik-users-h...@xmlgraphics.apache.orgmailto:
 batik-users-h...@xmlgraphics.apache.org
 
 
 



 

Re: How to create a svg animate tag during runtime and animate it?

2010-03-14 Thread jonathan wood
Hi Fabian,

  It is usually a case of getting the correct attributes.  Batik tends to
follow the standard a bit more closely that some other implementations.  The
following code works for me...posted sans the JFrame init...assumes a class
member JSVGCanvas named svgCanvas.

private void runDemo() {
svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
svgCanvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
@Override
public void gvtBuildCompleted(GVTTreeBuilderEvent e) {

svgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
Runnable() {
public void run() {
Element rect =
svgCanvas.getSVGDocument().createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
SVGConstants.SVG_RECT_TAG);
rect.setAttributeNS(null,
SVGConstants.SVG_X_ATTRIBUTE, 100);
rect.setAttributeNS(null,
SVGConstants.SVG_Y_ATTRIBUTE, 100);
rect.setAttributeNS(null,
SVGConstants.SVG_WIDTH_ATTRIBUTE, 100);
rect.setAttributeNS(null,
SVGConstants.SVG_HEIGHT_ATTRIBUTE, 100);
rect.setAttributeNS(null,
SVGConstants.SVG_FILL_ATTRIBUTE, #ee);
Element animate =
svgCanvas.getSVGDocument().createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
SVGConstants.SVG_ANIMATE_TAG);
animate.setAttributeNS(null,
SVGConstants.SVG_ATTRIBUTE_NAME_ATTRIBUTE,
SVGConstants.SVG_OPACITY_ATTRIBUTE);
animate.setAttributeNS(null,
SVGConstants.SVG_VALUES_ATTRIBUTE, 1;0);
animate.setAttributeNS(null,
SVGConstants.SVG_DUR_ATTRIBUTE, 3s);
animate.setAttributeNS(null,
SVGConstants.SVG_REPEAT_COUNT_ATTRIBUTE, indefinite);
rect.appendChild(animate);

svgCanvas.getSVGDocument().getDocumentElement().appendChild(rect);
}
});
}
});
Document doc =
SVGDOMImplementation.getDOMImplementation().createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI,
svg, null);
svgCanvas.setSVGDocument((SVGDocument) doc);
}





On Fri, Mar 12, 2010 at 8:35 AM, Fabian Unfried i...@funfried.de wrote:

 Hi,

 I would like to know how to handle animations with batik, especially the
 animate tag.

 If I put the following svg code into an svg graphic and open it with a java
 application with batik all works just fine and it'll be animated:

 rect x=100 y=100 width=500 height=500
animate attributeType=CSS attributeName=opacity
 calcMode=discrete
 from=1 to=0 dur=1s repeatCount=indefinite /
 /rect


 But what do I have to do, if I want to do exactly this during runtime?

 I've tried this:


 SVGOMAnimationElement animate = (SVGOMAnimationElement)
 this.svgDocument.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
 SVG12Constants.SVG_ANIMATE_TAG);
 animate.setAttribute(dur, 1s);
 animate.setAttribute(values, 0; 0; 1; 1);
 animate.setAttribute(keyTimes, 0; 0.5; 0.7; 1.0);
 animate.setAttribute(attributeName, opacity);
 animate.setAttribute(attributeType, CSS);
 animate.setAttribute(repeatCount, indefinite);

 rect.appendChild(animate);

 animate.beginElement();


 but this didn't get animated, so I've tried to use the SVGAnimationEngine,
 but
 I'm not sure how to use the addAnimation() method, or even if I need to do
 that:

 SVGAnimationEngine aEngine = getSVGAnimationEngine();
 aEngine.addAnimation((AnimationTarget) rect,
 SVGAnimationEngine.ANIM_TYPE_CSS, ?, ?, AbstractAnimation???);

 How can I setup an AbstractAnimation?



 Any help is very appreciated

 Thanks in advance.

 Kind regards,

 Fabian

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: coordinate conversion

2010-02-28 Thread jonathan wood
Most of what you need can be found in SVGLocatable.  The below is not
tested, but should be close:

Point awtPoint = ...;
Element myEl = document.getElementById(my-el);
SVGPoint svgPoint = document.getRootElement.createSVGPoint();
svgPoint.setX(awtPoint.getX());
svgPoint.setY(awtPoint.getY());
SVGMatrix m = ((SVGLocatable)myEl).getScreenCTM();
m = m.inverse();
svgPoint = svgPoint.matrixTransform(m);


On Fri, Feb 26, 2010 at 8:34 AM, dao dao.ho...@gmail.com wrote:

 hello,

 Sorry for this stupid question: how do I transform coordinates from a AWT
 mouse event to the coordinates in the svg file the canvas represents?

 I mean, I have a panel with the canvas (rotated, zoomed, panned in the
 worst case) and I want to know the coordinates of the svg point my mouse
 cursor is pointing.



 --
 Dao Hodac



Re: Creating an image on the fly from a servlet

2010-02-23 Thread jonathan wood
I havent tried to duplicate using your code, but I do notice that my servlet
transcodes always set the content type before obtaining the sevlet output
stream:

response.setContentType(image/png);


worth a try?



On Tue, Feb 23, 2010 at 2:11 PM, Jan Tosovsky j.tosov...@tiscali.cz wrote:

   Although I can see the result in the target browser, I am unable to
  save the
   image on a local disk. Actually, in Firefox I can notice an attempt
  to save
   the file, but in a download manager it is of zero size and it is not
  really
   present in the target location. MSIE offers me save the PNG file in
  BMP
   format...
 
  The fact that you can see it and cannot save it very weird. Even
  weirder is the described MSIE behavior. If you are working with the
  trunk code, maybe your are getting bit by bug 48693 [1]? If you are
  working with Batik 1.7, that may be bug 46863 [2].

 Thanks for this info. It led me to try also JPEG output, but the result is
 the same. I suspect the way of closing the final stream. I think the
 browser
 can display partial data but as they are unfinished properly, it made him
 puzzled a bit.

 Transcoding via command line is Ok in all cases.

  Could you try to analyze the (supposedly PNG) raw file saved and/or
  attach it to a reply?

 No file is created in FF so there is nothing to analyze. And that MSIE BMP
 file is the standard image. It is probably a kind of the screenshot of an
 internal canvas.

 Here is the final part of my code:

 TranscoderOutput output = new TranscoderOutput(response.getOutputStream());
 t.transcode(input, output);

 // I've tried to find any closing method of the 'output' object,
 // but still without success. The following way also doesn't help
 //
 // output.getWriter().close();

 ServletOutputStream out = response.getOutputStream();
 out.flush();
 out.close();

 Any other ideas?

 Jan

  Hope this helps,
   Helder
 
 
  [1] https://issues.apache.org/bugzilla/show_bug.cgi?id=48693
  [2] https://issues.apache.org/bugzilla/show_bug.cgi?id=46863


 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: problem with batik transcoder on a headless system

2010-02-10 Thread jonathan wood
Attach to the mail is fine as far as I know.  As always, try to limit the
size.

As a long shot, since your headless are Linux,  try passing

-Dawt.toolkit=sun.awt.motif.MToolkit

when transcoding.  See
http://java.sun.com/j2se/1.5.0/docs/guide/awt/1.5/xawt.html for insight into
why this may help.

Jonathan

On Wed, Feb 10, 2010 at 7:34 AM, simon si...@333.ch wrote:
 Helder Magalhães schrieb:

 Hi everyone,


 (Simon)


 but still, any help would be very much appreciated.


 You've mentioned you were using Java6 but, probably not being the
 cause, I'd suggest giving more detail on the Java version (and
 implementor... Sun? OpenJDK? GCJ?) and also surrounding things
 (operating system/distribution version for example).


 local:
 kubuntu 8.04 (hardy)
 java version 1.6.0_17 sun

 server:
 debian lenny
 java version 1.6.0_12 resp.  i also tried to update to java version
 1.6.0_18 with the same result. (also sun)


 (Jonathan)


 As always.  The test.svg file would probably help in resolution


 Yup, a simple test case will likely help much more [1] than trying to
 explain. ;-)


 should i attach the svg file to the mail? or is there a better place?

 (Jonathan)


 Hope this helps a bit and please share anything you find!


 I subscribe to this as well. :-)


 will do so :-)

 cheers
 simon

 Cheers,
  Helder


 [1] http://www.chiark.greenend.org.uk/~sgtatham/bugs.html#showmehow

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: problem with batik transcoder on a headless system

2010-02-09 Thread jonathan wood
My previous response failed to note that Batik IS using the int
version of the Color constructor.  I would check the test svg
carefully.  Your working jvm (windows?) may be bounds checking and
correcting the input values while your headless (possibly sun?) jdk
does not (instead relies on an exception).

As always.  The test.svg file would probably help in resolution


On Tue, Feb 9, 2010 at 1:56 PM, jonathan wood
jonathanshaww...@gmail.com wrote:
 Hello Simon,

   I suspect the root of your problem is how the local vm is
 sorting/selecting the constructor for java.awt.Color.

   Your headless system is likely constructing using the float version
 of the Constructor which does something like:

 this( (int) (r*255+0.5), (int) (g*255+0.5), (int) (b*255+0.5));

 Hence, if you are passing an int as the color value (very likely), you
 will blow the values far from the acceptable 0-255 range.  The
 Constructor order seems to differ by platform and even by jdk revision
 on platforms.

 You can almost certainly verify this by check the stack while
 suspended at the exception.  If you see the float constructor called
 prior to the int version then this is almost certainly the issue.

 Of course, if you could provide the failing test.svg for inspection,
 it might help to determine a suitable work-around.

 Hope this helps a bit and please share anything you find!

 Jonathan



 On Tue, Feb 9, 2010 at 12:04 PM, simon si...@333.ch wrote:

 Helder Magalhães schrieb:

 Hi simon,


 hi helder,

 thanks very much for your response.



 i have developed a yanel resource-type which is using the batik transcoder
 to create png and jpg from svg. on my local computer everything works like 
 a
 charm. after i deployed it on a haedless server i run into a problem. i
 tried Djava.awt.headless=true and xvfb. and a real simple svg worked fine
 but for most cases i get an exception (see below). after this exception was
 thrown even the simple svg which worked before throws the exception.


 Maybe you got caught by bug 42408 [1]? Could you try downloading the
 source [2] and apply the available patch [1] locally and see if it
 helps? Please reply back (or comment on the bug report) if so. ;-)


 unfortunately i could not apply the patch to source of 1.7 and as i 
 understand the comments in the bug 42408 the patch has already been applied 
 to trunk. so i just checked out the trunk and tried the rasterizer:

 si...@debian:~/batik-test/batik-trunk/batik-1.8pre$ java  
 -Djava.awt.headless=true -jar batik-rasterizer.jar test.svg
 About to transcode 1 SVG file(s)

 Converting test.svg to test.png ... java.lang.IllegalArgumentException: 
 Color parameter outside of expected range: Alpha Green
       at java.awt.Color.testColorValueRange(Color.java:298)
       at java.awt.Color.init(Color.java:382)
       at org.apache.batik.bridge.PaintServer.convertColor(Unknown Source)
       at org.apache.batik.bridge.CSSUtilities.convertStopColor(Unknown 
 Source)
       at 
 org.apache.batik.bridge.AbstractSVGGradientElementBridge$SVGStopElementBridge.createStop(Unknown
  Source)
       at 
 org.apache.batik.bridge.AbstractSVGGradientElementBridge.extractLocalStop(Unknown
  Source)
       at 
 org.apache.batik.bridge.AbstractSVGGradientElementBridge.extractStop(Unknown 
 Source)
       at 
 org.apache.batik.bridge.AbstractSVGGradientElementBridge.createPaint(Unknown 
 Source)
       at org.apache.batik.bridge.PaintServer.convertURIPaint(Unknown Source)
       at org.apache.batik.bridge.PaintServer.convertPaint(Unknown Source)
       at org.apache.batik.bridge.PaintServer.convertFillPaint(Unknown Source)
       at org.apache.batik.bridge.PaintServer.convertFillAndStroke(Unknown 
 Source)
       at 
 org.apache.batik.bridge.SVGShapeElementBridge.createShapePainter(Unknown 
 Source)
       at 
 org.apache.batik.bridge.SVGCircleElementBridge.createShapePainter(Unknown 
 Source)
       at 
 org.apache.batik.bridge.SVGShapeElementBridge.buildGraphicsNode(Unknown 
 Source)
       at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source)
       at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
       at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source)
       at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
       at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source)
       at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
       at org.apache.batik.bridge.GVTBuilder.build(Unknown Source)
       at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown 
 Source)
       at org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown 
 Source)
       at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown 
 Source)
       at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown 
 Source)
       at org.apache.batik.apps.rasterizer.SVGConverter.transcode(Unknown 
 Source

Re: contribution advice?

2010-01-08 Thread jonathan wood
This is exactly what I was looking for.  Thanks for taking the time to put
this together!


On Fri, Jan 8, 2010 at 9:15 AM, thomas.dewe...@kodak.com wrote:

 Hi Jonathan,

 jonathan wood jonathanshaww...@gmail.com wrote on 12/31/2009 05:28:15
 PM:


  Perhaps someone familiar with the current state of batik's bug

  list (Helder???) could point me toward some validated, higher priority
  bugs so that I might attempt to resolve?

I'm not sure there are a lot of high priority bugs.  I'll list a few
 things that have been on my TODO list (for a few years now ;).

 1) Pipe all element lookups through an object associated with the
BridgeContext.  This would be to serve two purposes.  First it
would more easily enable people to 'replace' Batik's lookup/fetch
logic (replacing/augmenting ParsedURL only goes so far).  Second
if paired with 'unlookup' calls it would enable Batik to detect
complex reference loops in content (an element that references a
pattern that uses the element).

 2) Make everything use ParsedURL for references.  Currently there
are still a few places where we don't use ParsedURL (I think
mostly in CSS) this mostly means that you can't use base64
encoded URLS in these places.

 3) Add dynamic updates for referenced content. Currently in many
cases if a referenced element changes Batik doesn't notice.  I
think this is true for patterns, filters, masks, etc.  I did an
example of dependency tracking for gradients (which may not have
landed on trunk) at some point it would be nice if this was extended
to other areas.

 4) Implement ElementInstance for Use elements.  Currently we create a
shadow tree to support the use element, which is not conformant to
the SVG specification.  It would be better if we created
 ElementInstances
that could carry the CSS cascade information and then use a reference
to the actual element for DOM attributes.  This would require updating
all of the Bridges to know/handle the ElementInstance case but I think
the changes (while widespread) could be fairly simple.

These are just suggestions, let me know if these are the sorts of
 suggestions you are looking for, or if your interested lie in other areas.

My Apache ICLA has been submitted and I do understand that I will
  be limited to submitting patches that may or may not be applied by
  an individual with commit access.
 
 
Thanks,
 
  jonathan



Re: create a JSVGCanvas from an inputstream

2010-01-02 Thread jonathan wood
Hi Dao,

  I also included a load from jar in the previous examples.  The key is
the line:

InputStream templateStream =
MyClass.class.getResourceAsStream(template.svg);

getResourceAsStream will allow you to load from the classpath  (including
your jar).


to recap:

InputStream templateStream =
MyClass.class.getResourceAsStream(template.svg);
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
SVGDocument doc = null;

try {
doc = f.createSVGDocument(null, templateStream);
} catch (IOException ex) {
}

   myCanvas.setSVGDocument(doc);



On Sat, Jan 2, 2010 at 3:30 PM, dao dao.ho...@gmail.com wrote:

 to continue with this inputstream document:

 My document that I build from an inputstream references an other document
 by referencing some symbols (use xlink:href=widgets.svg#warningMask ...
 )

 How can I do to make this work:

 Either I create an other document I receive from my server which is
 widget.svg and tell me how I can reference it (is it necessary to create a
 file from the stream in the file widgets.svg?)

 Either I have the widgets.svg file in my application's jar. In that case,
 How can I reference a file in a jar?

 Do you suggest me an other way to process?


 2010/1/1 Helder Magalhães helder.magalh...@gmail.com

 Hi dao,


 Response inline...


  Added in [2]. not sure of how to reference the thread

 Great! :-)  I noticed an entry added to the how-to, but the actual
 page [1] doesn't exist yet...?

 To reference a thread, just copy a link from the archives [2]. While
 using the official archives, the trick seems to be selecting the
 desired thread or particular message and clicking on the Message
 view link in order to get the desired thread/message hyperlink. In
 this particular case, it would be [3].

 As we're at it, given than navigation/search features are not very
 user friendly in the official archives IMHO, I frequently use the
 Nabble archive [4], specially for searches... ;-)


 Hope this helps,
  Helder


 [1] http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation
 [2] http://mail-archives.apache.org/mod_mbox/
 [3]
 http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/200912.mbox/%3c272595f40912300947w60080f76ibdc29c7a1a702...@mail.gmail.com%3e
 [4] http://old.nabble.com/Batik-f308.html

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




 --
 Dao Hodac



Re: create a JSVGCanvas from an inputstream

2010-01-02 Thread jonathan wood
There may be a way to do this auto-magically, but I don't (yet) know it.

Try the jar protocol (jar:file://nn/file.svg)  (
http://docs.sun.com/source/819-0913/author/jar.html#jarprotocol)

Override/extend the existing UserAgent.openLink() functionality.  To save a
bit of hunting on your part...The appropriate code can be found in
JSVGComponent.BridgeUserAgent() (

You'll likely receive better guidance from the others on the list though.
I'll update you if I see something better.



On Sat, Jan 2, 2010 at 5:33 PM, dao dao.ho...@gmail.com wrote:

 I understand, but how can I refer to that document in an other document?
 (see the xlink:href from my mail)?

 On Sat, Jan 2, 2010 at 11:27 PM, jonathan wood jonathanshaww...@gmail.com
  wrote:

 Hi Dao,

   I also included a load from jar in the previous examples.  The key is
 the line:

 InputStream templateStream =
 MyClass.class.getResourceAsStream(template.svg);

 getResourceAsStream will allow you to load from the classpath  (including
 your jar).


 to recap:

 InputStream templateStream =
 MyClass.class.getResourceAsStream(template.svg);

 String parser = XMLResourceDescriptor.getXMLParserClassName();
 SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
 SVGDocument doc = null;

 try {
 doc = f.createSVGDocument(null, templateStream);
 } catch (IOException ex) {
 }

myCanvas.setSVGDocument(doc);



 On Sat, Jan 2, 2010 at 3:30 PM, dao dao.ho...@gmail.com wrote:

 to continue with this inputstream document:

 My document that I build from an inputstream references an other document
 by referencing some symbols (use xlink:href=widgets.svg#warningMask
 ...)

 How can I do to make this work:

 Either I create an other document I receive from my server which is
 widget.svg and tell me how I can reference it (is it necessary to create a
 file from the stream in the file widgets.svg?)

 Either I have the widgets.svg file in my application's jar. In that case,
 How can I reference a file in a jar?

 Do you suggest me an other way to process?


 2010/1/1 Helder Magalhães helder.magalh...@gmail.com

 Hi dao,


 Response inline...


  Added in [2]. not sure of how to reference the thread

 Great! :-)  I noticed an entry added to the how-to, but the actual
 page [1] doesn't exist yet...?

 To reference a thread, just copy a link from the archives [2]. While
 using the official archives, the trick seems to be selecting the
 desired thread or particular message and clicking on the Message
 view link in order to get the desired thread/message hyperlink. In
 this particular case, it would be [3].

 As we're at it, given than navigation/search features are not very
 user friendly in the official archives IMHO, I frequently use the
 Nabble archive [4], specially for searches... ;-)


 Hope this helps,
  Helder


 [1] http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation
 [2] http://mail-archives.apache.org/mod_mbox/
 [3]
 http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/200912.mbox/%3c272595f40912300947w60080f76ibdc29c7a1a702...@mail.gmail.com%3e
 [4] http://old.nabble.com/Batik-f308.html

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail:
 batik-users-h...@xmlgraphics.apache.org




 --
 Dao Hodac





 --
 Dao Hodac



contribution advice?

2009-12-31 Thread jonathan wood
Happy New Year Batikeers,

I have a few enhancements I'd like to add to batik, but I'm not quite
finished scoping/designing in that arena.  In the meantime, I'm starting to
absorb more of the core code.  I find it usually helps me if I have a goal.
Perhaps someone familiar with the current state of batik's bug list
(Helder???) could point me toward some validated, higher priority bugs so
that I might attempt to resolve?

  My Apache ICLA has been submitted and I do understand that I will be
limited to submitting patches that may or may not be applied by an
individual with commit access.


  Thanks,

jonathan


Re: create a JSVGCanvas from an inputstream

2009-12-30 Thread jonathan wood
Hi Dao,

Here are a couple of load routines I use frequently ..  Hope they help you
narrow your problem.

Load from a file on the classpath (templated)

InputStream templateStream =
Canvas.class.getResourceAsStream(template.svg);
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
SVGDocument doc = null;

try {
doc = f.createSVGDocument(null, templateStream);
} catch (IOException ex) {
}

   myCanvas.setSVGDocument(doc);


Load from a byte array version:

Element a = null;
ByteArrayInputStream bais = new
ByteArrayInputStream(myByteArray);
String parser =
XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);

try {
a = f.createDocument(null, bais).getDocumentElement();
} catch (IOException ex) {
}

a = (Element) document.importNode(a, true);




On Wed, Dec 30, 2009 at 12:47 PM, dao dao.ho...@gmail.com wrote:

 hello, I am stucked in the process of creating a JSVGCanvas from a SVG XML
 content coming from an input stream.

 What is the best practice?

 Here is the way I do that:

  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

 DocumentBuilder builder = factory.newDocumentBuilder();

 String xmlDocument = remoteEngine.getSvgDocument();

 System.out.println(xmlDocument);

 InputStream inStream = new ByteArrayInputStream(xmlDocument.getBytes());

 return builder.parse(inStream);


 I get into a ClassCastEexception when batik tries to narrow the document to
 a SVG document (I suppose so...)

 --
 Dao Hodac



Re: draw a set of points

2009-12-22 Thread jonathan wood
Use a circle or rect with a size that fits the coord system that you need to
use.  Because of scalability, the width of a point is fairly meaningless.

On Tue, Dec 22, 2009 at 8:06 AM, dao dao.ho...@gmail.com wrote:

 hello,

 Is it possible to draw a point with SVG? polylines, paths, etc... seems not
 appropriate to do that. Do I need to draw a rect or circle with a size of 0
 (or 1)?

 I want to draw a chart representing a set of points not linked together

 regards,

 --
 Dao Hodac



Re: animation code example

2009-12-22 Thread jonathan wood
Batik's animation is really just SVG
animationhttp://www.w3.org/TR/SVG11/animate.htmlwhich is mainly
SMILhttp://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimationFramework(with
 batik
additionshttp://www.w3.org/TR/SVG11/animate.html#SVGExtensionsToSMILAnimation).


Create the DOM objects just as you would build rects, etc and add them to
the target elements.

You'll find many examples by broadening your search to include javascript.
The DOM calls are the same.


On Tue, Dec 22, 2009 at 12:48 PM, dao dao.ho...@gmail.com wrote:

 hello,

 is there a tutorial of how to create animation elements with batik? do I
 need to create the elements from scratch (using DOM) or batik provides a
 animation framework? I ask because there is the package
 org.apache.batik.animhttp://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/anim/package-summary.html
  but I cannot find any code snippet with google

 --
 Dao Hodac



Re: background for text

2009-12-21 Thread jonathan wood
SVGRect bbox =
((SVGLocatable)textNode).getBBox();

Element rect =
doc.getElementById(my-bg-rect);
if (rect == null) {
rect =
doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, rect);
rect.setAttributeNS(null, id,
my-bg-rect);
rect.setAttributeNS(null, fill,
#CCDDFF);
rect.setAttributeNS(null, stroke,
#00);
rect.setAttributeNS(null,
stroke-width, 3);
}


On Mon, Dec 21, 2009 at 3:07 PM, dao dao.ho...@gmail.com wrote:

 hello,

 I'd like to highlight a text element of my svg file:

  text transform=matrix(1 0 0 1 433.8965 494.4141) style=fill:#00;
 font-family:'CourierNewPSMT'; font-size:24;00.00/text


 I cannot see any way to set the background of a text, or to get the box
 size to draw a rectangle around it.

 Do you know how I can do this?

 regards


 --
 Dao Hodac



Re: background for text

2009-12-21 Thread jonathan wood
Sorry for the very incomplete code clipping.  This is from a test case I
sent to the list a few days ago...nabble, etc will likely yield the entire
file

.here is a better cut:

SVGRect bbox =
((SVGLocatable)textNode).getBBox();

Element rect =
doc.getElementById(my-bg-rect);
if (rect == null) {
rect =
doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, rect);
rect.setAttributeNS(null, id,
my-bg-rect);
rect.setAttributeNS(null, fill,
#CCDDFF);
rect.setAttributeNS(null, stroke,
#00);
rect.setAttributeNS(null,
stroke-width, 3);
}

rect.setAttributeNS(null, x,  +
(bbox.getX() - 10) );
rect.setAttributeNS(null, y,  +
(bbox.getY() - 10) );
rect.setAttributeNS(null, width,  +
(bbox.getWidth() + 20) );
rect.setAttributeNS(null, height,  +
(bbox.getHeight() + 20) );
doc.getDocumentElement().insertBefore(rect,
textNode);




On Mon, Dec 21, 2009 at 3:41 PM, jonathan wood
jonathanshaww...@gmail.comwrote:

 SVGRect bbox =
 ((SVGLocatable)textNode).getBBox();

 Element rect =
 doc.getElementById(my-bg-rect);
 if (rect == null) {
 rect =
 doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, rect);
 rect.setAttributeNS(null, id,
 my-bg-rect);
 rect.setAttributeNS(null, fill,
 #CCDDFF);
 rect.setAttributeNS(null, stroke,
 #00);
 rect.setAttributeNS(null,
 stroke-width, 3);

 }


 On Mon, Dec 21, 2009 at 3:07 PM, dao dao.ho...@gmail.com wrote:

 hello,

 I'd like to highlight a text element of my svg file:

  text transform=matrix(1 0 0 1 433.8965 494.4141) style=fill:#00;
 font-family:'CourierNewPSMT'; font-size:24;00.00/text


 I cannot see any way to set the background of a text, or to get the box
 size to draw a rectangle around it.

 Do you know how I can do this?

 regards


 --
 Dao Hodac





Re: background for text

2009-12-21 Thread jonathan wood
The example uses direct setting of the x, y coordinates.  Your example text
node has a transform attribute.  You will likely need to transform the
background rectangle also.



On Mon, Dec 21, 2009 at 4:49 PM, dao dao.ho...@gmail.com wrote:

 that quick!!

 but the rect does not fits my locatable... it has not the right size and is
 stucked on the top left corner of my canvas...

 any idea?


 On Mon, Dec 21, 2009 at 9:44 PM, jonathan wood jonathanshaww...@gmail.com
  wrote:

 Sorry for the very incomplete code clipping.  This is from a test case I
 sent to the list a few days ago...nabble, etc will likely yield the entire
 file

 .here is a better cut:


 SVGRect bbox =
 ((SVGLocatable)textNode).getBBox();

 Element rect =
 doc.getElementById(my-bg-rect);
 if (rect == null) {
 rect =
 doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, rect);
 rect.setAttributeNS(null, id,
 my-bg-rect);
 rect.setAttributeNS(null, fill,
 #CCDDFF);
 rect.setAttributeNS(null, stroke,
 #00);
 rect.setAttributeNS(null,
 stroke-width, 3);
 }

 rect.setAttributeNS(null, x,  +
 (bbox.getX() - 10) );
 rect.setAttributeNS(null, y,  +
 (bbox.getY() - 10) );
 rect.setAttributeNS(null, width,  +
 (bbox.getWidth() + 20) );
 rect.setAttributeNS(null, height,  +
 (bbox.getHeight() + 20) );

 doc.getDocumentElement().insertBefore(rect, textNode);





 On Mon, Dec 21, 2009 at 3:41 PM, jonathan wood 
 jonathanshaww...@gmail.com wrote:

 SVGRect bbox =
 ((SVGLocatable)textNode).getBBox();

 Element rect =
 doc.getElementById(my-bg-rect);
 if (rect == null) {
 rect =
 doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, rect);
 rect.setAttributeNS(null, id,
 my-bg-rect);
 rect.setAttributeNS(null, fill,
 #CCDDFF);
 rect.setAttributeNS(null, stroke,
 #00);
 rect.setAttributeNS(null,
 stroke-width, 3);

 }


 On Mon, Dec 21, 2009 at 3:07 PM, dao dao.ho...@gmail.com wrote:

 hello,

 I'd like to highlight a text element of my svg file:

  text transform=matrix(1 0 0 1 433.8965 494.4141) style=fill:#00;
 font-family:'CourierNewPSMT'; font-size:24;00.00/text


 I cannot see any way to set the background of a text, or to get the box
 size to draw a rectangle around it.

 Do you know how I can do this?

 regards


 --
 Dao Hodac






 --
 Dao Hodac



Re: background for text

2009-12-21 Thread jonathan wood
See inlined responses below

On Mon, Dec 21, 2009 at 5:18 PM, dao dao.ho...@gmail.com wrote:

 oups, I have grabbed the transform attribute, and now, my rect is the right
 size, but its bottom left is at the center of the node.

 My node is like this:

  use xlink:href=#Horizon  width=300 height=400 x=-150 y=-200
 transform=matrix(0.6881 0 0 -0.6881 142.5107 299.9995) style=
 overflow:visible;/



This use tag contains both an explicit x, y (-150,-200) and a transform,
you'll need to account for both in the rectangles positioning.



 Furthermore, I am trying to replace the rect by a symbol reference. I
 cannot succeed in modifying its aspect ratio. is there an attribute to
 authorize this? To be more clear, I have drawn a nice rounded rectangle with
 half opacity and decorations that I want to draw on top of the targeted node
 (here horizon) with the same size.


From the spec...hoping it helps...

*If the 'use' element references a 'symbol' element:

In the generated content, the 'use' will be replaced by 'g', where all
attributes from the 'use' element except
for x, y, width, height and xlink:href are transferred to the generated 'g'
element. An additional
transformation translate(x,y) is appended to the end (i.e., right-side) of
the transform attribute on the
generated 'g', where x and y represent the values of the x and y attributes
on the 'use' element. The
referenced 'symbol' and its contents are deep-cloned into the generated
tree, with the exception that the
'symbol' is replaced by an 'svg'. This generated 'svg' will always have
explicit values for attributes width
and height. If attributes width and/or height are provided on the 'use'
element, then these attributes will be
transferred to the generated 'svg'. If attributes width and/or height are
not specified, the generated 'svg'
element will use values of 100% for these attributes.*



 the targeted node could be a text, that's why my first posted you answered
 with the bbox and the SVGLocatable.


The SVGLocatable/bbox method should work ok for any Element.



 On Mon, Dec 21, 2009 at 11:01 PM, jonathan wood 
 jonathanshaww...@gmail.com wrote:


 The example uses direct setting of the x, y coordinates.  Your example
 text node has a transform attribute.  You will likely need to transform the
 background rectangle also.




 On Mon, Dec 21, 2009 at 4:49 PM, dao dao.ho...@gmail.com wrote:

 that quick!!

 but the rect does not fits my locatable... it has not the right size and
 is stucked on the top left corner of my canvas...

 any idea?


 On Mon, Dec 21, 2009 at 9:44 PM, jonathan wood 
 jonathanshaww...@gmail.com wrote:

 Sorry for the very incomplete code clipping.  This is from a test case I
 sent to the list a few days ago...nabble, etc will likely yield the entire
 file

 .here is a better cut:


 SVGRect bbox =
 ((SVGLocatable)textNode).getBBox();

 Element rect =
 doc.getElementById(my-bg-rect);
 if (rect == null) {
 rect =
 doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, rect);
 rect.setAttributeNS(null, id,
 my-bg-rect);
 rect.setAttributeNS(null, fill,
 #CCDDFF);
 rect.setAttributeNS(null, stroke,
 #00);
 rect.setAttributeNS(null,
 stroke-width, 3);
 }

 rect.setAttributeNS(null, x,  +
 (bbox.getX() - 10) );
 rect.setAttributeNS(null, y,  +
 (bbox.getY() - 10) );
 rect.setAttributeNS(null, width,  +
 (bbox.getWidth() + 20) );
 rect.setAttributeNS(null, height,  +
 (bbox.getHeight() + 20) );

 doc.getDocumentElement().insertBefore(rect, textNode);





 On Mon, Dec 21, 2009 at 3:41 PM, jonathan wood 
 jonathanshaww...@gmail.com wrote:

 SVGRect bbox =
 ((SVGLocatable)textNode).getBBox();

 Element rect =
 doc.getElementById(my-bg-rect);
 if (rect == null) {
 rect =
 doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, rect);
 rect.setAttributeNS(null, id,
 my-bg-rect);
 rect.setAttributeNS(null, fill,
 #CCDDFF);
 rect.setAttributeNS(null, stroke,
 #00);
 rect.setAttributeNS(null,
 stroke-width, 3);

 }


 On Mon, Dec 21, 2009 at 3:07 PM, dao dao.ho...@gmail.com wrote:

 hello,

 I'd like to highlight a text element of my svg file:

  text transform=matrix(1 0 0 1 433.8965 494.4141) style=fill:#00;
 font-family:'CourierNewPSMT'; font-size:24;00.00/text


 I cannot see any

Re: Status of FlowRoot Overflow Detection?

2009-12-14 Thread jonathan wood
Thomas,

  You are correct.  The test case for this no longer fails as I previously
encountered.  My apologies for any confusion caused.

  Instead of trashing the example, here it is (excuse the ide-component
code...I did not have alot of time for further reduction).  Maybe it will
serve as an event example or a framework for other test case reductions.

  Are examples like this of use to anyone on the list currently?

 Begin Example

package textboundingbox;

import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.swing.JSVGCanvas;
import org.apache.batik.swing.svg.GVTTreeBuilderAdapter;
import org.apache.batik.swing.svg.GVTTreeBuilderEvent;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
import org.w3c.dom.svg.SVGDocument;
import org.w3c.dom.svg.SVGLocatable;
import org.w3c.dom.svg.SVGRect;

/**
 *
 * @author Jonathan Wood
 */
public class Main extends javax.swing.JFrame {

private org.apache.batik.swing.JSVGCanvas svgCanvas;
private int clickCount = 0;

private void initGlassPane() {

svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
svgCanvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
@Override
public void gvtBuildCompleted(GVTTreeBuilderEvent e) {

svgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
Runnable() {
public void run() {
final SVGDocument doc = svgCanvas.getSVGDocument();
Element glassPane =
doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, rect);
glassPane.setAttributeNS(null, id, glass-pane);
glassPane.setAttributeNS(null, x, 0);
glassPane.setAttributeNS(null, y, 0);
glassPane.setAttributeNS(null, height,  +
getHeight());
glassPane.setAttributeNS(null, width,  +
getWidth());
glassPane.setAttributeNS(null, fill, none);
glassPane.setAttributeNS(null, pointer-events,
all);
EventListener glassPaneListener = new
EventListener() {
public void handleEvent(Event event) {
String clickString = Clicks =  +
++clickCount;
Element textNode =
doc.getElementById(my-text-node);
if(textNode == null) {
textNode =
doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, text);
textNode.setAttributeNS(null, id,
my-text-node);
textNode.setAttributeNS(null, x,
50);
textNode.setAttributeNS(null, y,
50);
textNode.setAttributeNS(null,
font-size, 20);
Text t =
doc.createTextNode(clickString);
textNode.appendChild(t);

doc.getDocumentElement().appendChild(textNode);
} else {

textNode.getFirstChild().setNodeValue(clickString);
}
SVGRect bbox =
((SVGLocatable)textNode).getBBox();
Element rect =
doc.getElementById(my-bg-rect);
if (rect == null) {
rect =
doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, rect);
rect.setAttributeNS(null, id,
my-bg-rect);
rect.setAttributeNS(null, fill,
#CCDDFF);
rect.setAttributeNS(null, rx, 10);
rect.setAttributeNS(null, ry, 10);
rect.setAttributeNS(null, stroke,
#55);
rect.setAttributeNS(null,
stroke-width, 2);
}
rect.setAttributeNS(null, x,  +
(bbox.getX() - 10) );
rect.setAttributeNS(null, y,  +
(bbox.getY() - 10) );
rect.setAttributeNS(null, width,  +
(bbox.getWidth() + 20) );
rect.setAttributeNS(null, height,  +
(bbox.getHeight() + 20) );
doc.getDocumentElement().insertBefore(rect,
textNode);
}
};

((EventTarget)glassPane).addEventListener(click,
glassPaneListener, false);
doc.getDocumentElement().appendChild(glassPane);
}
});
}
});

SVGDocument startDoc = (SVGDocument

Re: Status of FlowRoot Overflow Detection?

2009-12-13 Thread jonathan wood
Hi Brendan,

  Without a complete example of the code, I'm guessing a bit here.

  I have found that when dealing with text and bounding boxes you must be
careful to never try to obtain the newly added to the DOM text's bounding
box in the same worker.

To summarize:

urq.invokeLater(new Runnable() {
public void run() {
Text t = document.createTextNode(text);
textNode.replaceChild(t, textNode.getFirstChild());
...
   SVGRect altbounds = locatable.getBBox();
}
});

Would likely fail because the text has yet to be rendered (hence the size
has not been calculated?)

You can easily get around this using 2 worker threads in succession.
Perform the Locatable bounding box operation in the second one:

urq.invokeLater(new Runnable() {
public void run() {
Text t = document.createTextNode(text);
textNode.replaceChild(t, textNode.getFirstChild());
}
});
urq.invokeLater(new Runnable() {
public void run() {
   ...
   SVGRect altbounds = locatable.getBBox();
}
});



If I've missed the mark, please try to provide some additional information.



On Sun, Dec 13, 2009 at 11:24 PM, Brendon J. Wilson 
brendon.wil...@gmail.com wrote:

 After a couple hours of Googling and hacking, it would appear time to send
 an email to this list to see if there's a solution I'm missing.

 The Desired Result: An area of text that uses the largest font size
 possible while still fitting into a given rectangle.

 The Proposed Solution: Use the 'flowroot' element, check for overflow, and
 iteratively adjust the font size of the text.

 The Problem: Based on emails from this list dating from 2006, it does not
 appear overflow events are implemented, and my alternative attempts to
 formulate my own overflow detection mechanism have been unsuccessful.

 The SVG:
 ---
 ?xml version=1.0 encoding=utf-8?
 svg version=1.2 xmlns=http://www.w3.org/2000/svg; x=0px y=0px
 width=982px height=1200px viewBox=0 0 982 1200

 ...

 flowRoot xml:space=preserve
   flowRegion vertical-align=middle
  rect x=74.472 y=376.98 width=833.958 height=296.985
 id=bounding/
   /flowRegion

   flowDiv
  flowPara justification=middle top-margin=10 left-margin=10
 right-margin=10 bottom-margin=10 fill=#331C1D
 font-family='Futura-Medium' font-size=72 id=titleflowLineSome
 interesting text/flowLine/flowPara
   /flowDiv
 /flowRoot
 /svg
 ---

 While this code allows me to get the rectangle into which I'm flowing text:
 ---
 SVGElement svgElement = (SVGElement) doc.getElementById(bounding);
 SVGLocatable locatable = (SVGLocatable) svgElement;
 SVGRect altbounds = locatable.getBBox();
 ---

 but a similar call to attempt to get the bounding box for the laid out text
 (I presume, I'm actually shooting in the dark at this point) results in an
 uncaught exception:

 ---
 SVGElement svgElement = (SVGElement) doc.getElementById(title);
 SVGLocatable locatable = (SVGLocatable) svgElement;
 SVGRect altbounds = locatable.getBBox();
 ---

 Even if I move the id=title to the flowDiv, the result is the same. So
 I'm at a bit of a loss.

 Is there another, easier way to figure out the actual dimensions of the
 laid out text in a flowDiv, or check the flowRoot for overflow? Or are
 overflow events still not implemented?

 Thanks in advance,

 Brendon
 ---
 Brendon J. Wilson
 www.brendonwilson.com


 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Batik momentum

2009-12-10 Thread jonathan wood
Hi Thomas,

   Thank you for your dead-on reply.  I will get the paperwork started
immediately.

I do have specific features I'd like to implement.  Is batik-users the
appropriate place to discuss these, or would dev be more appropriate?

  Thanks again,

  Jonathan

On Thu, Dec 10, 2009 at 6:46 AM, thomas.dewe...@kodak.com wrote:

 Hi Jonathan,

 jonathan wood jonathanshaww...@gmail.com wrote on 12/08/2009 04:11:32
 PM:


  Is Batik headed to w3c svg 1.2+?

I hope so ;)

  I need Batik 1.2 and beyond.  I will soon be implementing 1.2+
  functionality simply because we need it and it does not exist.  I
  wonder how many others are at this cusp?

Is there a stable 1.2+ to target?  Already I see a lot of
 places where the SVG WG seems happy to redefine functionality
 that was in SVG 1.0.  I would be a little wary of trying to
 track the WG too closely.

What sort of functionality are you looking at implementing?

  I'm willing to help and the effort will positively impact my
  employer.  I want to apache commit and will start the process
  tonight, but I need help...

So typically one becomes a committer by making contributions over
 time.  This is tricky in this case as I'm the only active committer
 (for some definition of active ;) so making those contributions will
 be complicated.

I'd suggest something like the following.  First off get the
 Apache paperwork out of the way (Contributor License Agreement, etc).
 Then if you can pick two or three features you are looking to implement
 you can push those to Bugzilla as a standard SVN patch file.  If
 that goes well then we can start the process of making you a committer.

  How many others would possibly backfill a 1.2 functionality push.

At this point I don't have the time to do development on Batik.

  Would the Batik 1.8pre team advise, augment and support a push to
  SVG 1.2 (current state)?

 I am supportive of Batik development (with the cautions above).
 I'd be happy to provide guidance/suggestions as wanted/needed.




Affine Transform Utility Class

2009-12-08 Thread jonathan wood
For all of those new (and possibly old) to Batik, especially those that
don't want to fret about transforms.  Please advise if this already exists
and the reference should point elsewhere:

An element level wrapper for AffineTransformations -
http://wiki.apache.org/xmlgraphics-batik/TransformUtil

Thanks to the core team for all the great work!

Jonathan


Batik momentum

2009-12-08 Thread jonathan wood
I realize this topic comes up from time to time and I think we all just muse
until the current crisis passes.

Is Batik headed to w3c svg 1.2+?

I consider Batik to be the bleeding edge of SVG.

Yes, I am often taunted in front of jeering adobe crowds...but they cannot
flash what I can batik

I realize that the current team is focused on other corporate, personal and
technological challenges.  This is normal.

I need Batik 1.2 and beyond.  I will soon be implementing 1.2+ functionality
simply because we need it and it does not exist.  I wonder how many others
are at this cusp?

I'm willing to help and the effort will positively impact my employer.  I
want to apache commit and will start the process tonight, but I need help...

How many others would possibly backfill a 1.2 functionality push.

Would the Batik 1.8pre team advise, augment and support a push to SVG 1.2
(current state)?


Re: JavaDoc

2009-12-01 Thread jonathan wood
I'm not sure where the javadoc is, but the spec will get you far here:

http://www.w3.org/TR/SVG/types.html#BasicDOMInterfaces

good luck!

On Tue, Dec 1, 2009 at 11:42 AM, mistercaste misterca...@gmail.com wrote:


 Hi
 I'm searching the org.w3c.dom.svg JavaDoc because a lot of Batik features
 are based on this.
 Is this part of the Batik project? Where can I find it?

 Thanks!
 --
 View this message in context:
 http://old.nabble.com/JavaDoc-tp26594246p26594246.html
 Sent from the Batik - Users mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: SVG elements events

2009-11-27 Thread jonathan wood
Hello Olivier,

   You should be able to find what you are looking for here:

http://www.w3.org/TR/SVG/interact.html



On Thu, Nov 26, 2009 at 5:42 AM, HODAC, Olivier olivier.ho...@airbus.comwrote:

  Hello,

 I want to register some mouse events on an SVG element. Where can I find
 the list of events I can register? I can find samples with

 EventTarget etr = (EventTarget) elt;

 etr.addEventListener(click,* 
 new*org.w3c.dom.events.EventListener() {

 but what are the other event types ? For example, I want to register a
 mouse hover to highlight an element of the SVG

 regards

 *Olivier Dao Ho Dac*

  The information in this e-mail is confidential. The contents may not be 
 disclosed or used by anyone other than the addressee. Access to this e-mail 
 by anyone else is unauthorised.
 If you are not the intended recipient, please notify Airbus immediately and 
 delete this e-mail.
 Airbus cannot accept any responsibility for the accuracy or completeness of 
 this e-mail as it has been sent over public networks. If you have any 
 concerns over the content of this message or its Accuracy or Integrity, 
 please contact Airbus immediately.
 All outgoing e-mails from Airbus are checked using regularly updated virus 
 scanning software but you should take whatever measures you deem to be 
 appropriate to ensure that this message and any attachments are virus free.




Re: Issue in setting the canvas size( Mouse click not active in whole area of the applet)

2009-09-08 Thread jonathan wood
Hi Shekhar,

  If I understand correctly, you have 1 (or more) elements on the canvas and
you would like to highlight the clicked one and unhighlight when the
background is clicked.  The below assumes that...

One method is to add a glass pane to the canvas in order to capture the
off events.

Add a g behind all other elements.
ensure that the g tag pointer-events=all or other (see
http://www.w3.org/TR/SVG/interact.html#PointerEventsProperty)
Add a listener for the g

you'll have to manage the event bubbling with this method, but it is pretty
easy to implement


Hope this helps,


Jonathan

On Tue, Sep 8, 2009 at 9:02 AM, Shekhar Bhati shekhar.bh...@gmail.comwrote:

 Can anyone suggest something regarding below mentioned issue with batik?

 Thanks,
 Shekhar


 -- Forwarded message --
 From: Shekhar Bhati shekhar.bh...@gmail.com
 Date: Fri, Sep 4, 2009 at 6:46 PM
 Subject: Issue in setting the canvas size( Mouse click not active in
 whole area of the applet)
 To: batik-users@xmlgraphics.apache.org


 Hi Batik experts,

 I am using Batik in visualizing my application images.

 I have a functionality of highlighting/unhighlighting objects ,which
 is when I click on a particular object(image) , it gets highlighted
 and if I click anywhere else on the frame(applet) it should get
 unhighlighted.

 The issue is when an object is highlighted then only between a fix
 area only the unhighlighting is working.
 Even when i try to track the mouse click action then also it is not
 able to sense the click event beside that particular area..

 Is it the problem of canvas size?

 How can I enable my mouse click event all over the applet?

 Thanks  regards,

 Shekhar

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org




Re: Issue in setting the canvas size( Mouse click not active in whole area of the applet)

2009-09-08 Thread jonathan wood
Corrections...

use a rect instead of a g for the glasspane and ensure it covers the
entire svg/viewBox

sorry for the confusion


On Tue, Sep 8, 2009 at 1:47 PM, jonathan wood jonathanshaww...@gmail.comwrote:

 Hi Shekhar,

   If I understand correctly, you have 1 (or more) elements on the canvas
 and you would like to highlight the clicked one and unhighlight when the
 background is clicked.  The below assumes that...

 One method is to add a glass pane to the canvas in order to capture the
 off events.

 Add a g behind all other elements.
 ensure that the g tag pointer-events=all or other (see
 http://www.w3.org/TR/SVG/interact.html#PointerEventsProperty)
 Add a listener for the g

 you'll have to manage the event bubbling with this method, but it is pretty
 easy to implement


 Hope this helps,


 Jonathan


 On Tue, Sep 8, 2009 at 9:02 AM, Shekhar Bhati shekhar.bh...@gmail.comwrote:

 Can anyone suggest something regarding below mentioned issue with batik?

 Thanks,
 Shekhar


 -- Forwarded message --
 From: Shekhar Bhati shekhar.bh...@gmail.com
 Date: Fri, Sep 4, 2009 at 6:46 PM
 Subject: Issue in setting the canvas size( Mouse click not active in
 whole area of the applet)
 To: batik-users@xmlgraphics.apache.org


 Hi Batik experts,

 I am using Batik in visualizing my application images.

 I have a functionality of highlighting/unhighlighting objects ,which
 is when I click on a particular object(image) , it gets highlighted
 and if I click anywhere else on the frame(applet) it should get
 unhighlighted.

 The issue is when an object is highlighted then only between a fix
 area only the unhighlighting is working.
 Even when i try to track the mouse click action then also it is not
 able to sense the click event beside that particular area..

 Is it the problem of canvas size?

 How can I enable my mouse click event all over the applet?

 Thanks  regards,

 Shekhar

 -
 To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
 For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org