xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Armstrong" <armstr...@intalio.com>
Subject pixels vs. pt in JSVGComponent
Date Tue, 10 Jul 2001 00:49:26 GMT
Hi all,

I'm using a JSVGComponent in my Swing application and when the SVG document
it is based on uses pixels, such as the following:

<svg  width="132.646" height="56.696" viewBox="0 0 132.646 56.696"
xml:space="preserve">

everything is fine.  But when it uses points, such as the following:

<svg  width="132.646pt" height="56.696pt" viewBox="0 0 132.646 56.696"
xml:space="preserve">

I crash and burn with the following exception trace:

Exception occurred during event dispatching:
java.lang.InternalError: Determinant is 0
	at
org.apache.batik.swing.gvt.JGVTComponent.renderGVTTree(JGVTComponent.java:46
0)
	at
org.apache.batik.swing.gvt.JGVTComponent.scheduleGVTRendering(JGVTComponent.
java:527)
	at
org.apache.batik.swing.gvt.JGVTComponent.setRenderingTransform(JGVTComponent
.java:399)
	at mypackage.SVGShape.zoomToSize(SVGShape.java:737)
	at mypackage.SVGShape.computeRenderingTransform(SVGShape.java:724)
	at
org.apache.batik.swing.gvt.JGVTComponent.setGraphicsNode(JGVTComponent.java:
286)
	at
org.apache.batik.swing.svg.JSVGComponent.access$201(JSVGComponent.java:70)
	at
org.apache.batik.swing.svg.JSVGComponent$SVGListener.gvtBuildCompleted(JSVGC
omponent.java:499)
	at org.apache.batik.swing.svg.GVTTreeBuilder$2.run(GVTTreeBuilder.java:154)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:317)
	at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)

Now, this image works fine (both with and without the "pt") in the Batik
svg-browser, so obviously I am not doing something that it is doing to
handle non-pixel units correctly.  However, I can't figure out what exactly
I need to do.

What I have determined is that my zoomToSize() method below is encountering
an _imageWidth and an _imageHeight of 0, which makes my scaleW and scaleH
have the value of Infinity.

    public void zoomToSize() {
        double scaleW = ((double)getWidth()) / _imageWidth;
        double scaleH = ((double)getHeight()) / _imageHeight;
        if (renderingTransform == null) {
            renderingTransform = new AffineTransform();
        }
        renderingTransform.setToScale(scaleW, scaleH);
        setRenderingTransform(renderingTransform);
    }

The code that sets _imageWidth and _imageHeight (which works with pixels in
the SVG file but not with points) is below.

        SVGSVGElement elt = _doc.getRootElement();
        try {
            float w, h;
            _imageWidth = elt.getWidth().getBaseVal().getValue();
            _imageHeight = elt.getHeight().getBaseVal().getValue();

But this is where I'm stuck.  Has anyone had similar problems?  This might
has something to do with the SVGUserAgent.  I tried passing in null to get
the default one, and I tried writing my own (whose getPixelToMM() method
returned 0.26458333333333333333333333333333f), and in both cases I get the
same exception.  I have also looked through some of the Batik sources but I
can't figure out what it is that they do that I need to do to be able to
handle point measurements correctly but I haven't found it.

Thanks in advance,
Peter Armstrong


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message