You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Th...@Dornier.eads.net on 2002/08/21 12:58:25 UTC

JSVGCanvas as JTree nodes

Config:
Win2000, JDK1.31, Batik1.1/1.5b

Hi,
I try to display SVGs as JTree nodes. Therefore I wrote a TreeRenderer like
this:

public class SVGTreeRenderer extends JSVGCanvas implements TreeCellRenderer
{

  public SVGTreeRenderer() {
    File f = new File("d:\\img1.svg");
    try {
      this.setURI(f.toURL().toString());
    } catch (Exception ex) {
      //...
    }
  }
  public Component getTreeCellRendererComponent(JTree tree, ...) {
    return this;
  }
}

Running this Code I get the following Exception:

java.awt.geom.NoninvertibleTransformException: Determinant is 0

     at
java.awt.geom.AffineTransform.createInverse(AffineTransform.java:1898)

     at
org.apache.batik.swing.gvt.JGVTComponent.setRenderingTransform(Unknown
Source)

     at
org.apache.batik.swing.svg.JSVGComponent.computeRenderingTransform(Unknown
Source)

     at org.apache.batik.swing.gvt.JGVTComponent.setGraphicsNode(Unknown
Source)

     at org.apache.batik.swing.svg.JSVGComponent.access$601(Unknown Source)

     at
org.apache.batik.swing.svg.JSVGComponent$SVGListener.gvtBuildCompleted(Unknown

Source)

     at org.apache.batik.swing.svg.GVTTreeBuilder$2.run(Unknown Source)

     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)

     at java.awt.EventQueue.dispatchEvent(EventQueue.java:337)

     at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)

     at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)

     at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)

     at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)


At the end, there are no SVGs displayed in the JTree. Does anyone has a
solution for this problem?

cheers,

Thomas


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


Re: JSVGCanvas as JTree nodes

Posted by James McArthur <ja...@pcorp.com.au>.
Hi,

On Wed, 2002-08-21 at 20:28, Thomas.Bitzer@Dornier.eads.net wrote:
> Running this Code I get the following Exception:
> 
> java.awt.geom.NoninvertibleTransformException: Determinant is 0

In my experience, the best way to get around this was to extend the
JSVGComponent, and not the JSVGCanvas.

I tried a whole heap of things to make this problem disappear, ranging
from simple acts like adjusting the viewBox attribute of my SVG so that
all of the points were contained within those dimensions, through to
changing the units I used inside the SVG from pixels-to-milimeters and
v.v.

I even had the SVG displayed in a window that was the *exact* size of
the SVG itself (so I'd imagine there'd be no scaling/rotating or any
other transformation required) but I'd still get that error.

In the end, changing to JSVGComponent fixed it.

YMMV.

James

RE: JSVGCanvas as JTree nodes

Posted by Danny Ayers <da...@virgilio.it>.
The experienced guys might be able to pin down something more specific, but
my next step here would be to try putting the same JSVGCanvas code on top of
a regular component like JFrame, to make sure that the file is actually
being read ok (I've had trouble in the past with file locations on windows,
I don't know if it would make any difference but substituting "d:/img1.svg"
might be worth a try). Maybe even just try inserting

System.out.println(f.exists());

Cheers,
Danny.

>I try to display SVGs as JTree nodes. Therefore I wrote a TreeRenderer like
>this:
>
>public class SVGTreeRenderer extends JSVGCanvas implements TreeCellRenderer
>{
>
>  public SVGTreeRenderer() {
>    File f = new File("d:\\img1.svg");
>    try {
>      this.setURI(f.toURL().toString());
>    } catch (Exception ex) {
>      //...
>    }
>  }
>  public Component getTreeCellRendererComponent(JTree tree, ...) {
>    return this;
>  }
>}
>
>Running this Code I get the following Exception:
>
>java.awt.geom.NoninvertibleTransformException: Determinant is 0
>
>     at
>java.awt.geom.AffineTransform.createInverse(AffineTransform.java:1898)
>
>     at
>org.apache.batik.swing.gvt.JGVTComponent.setRenderingTransform(Unknown
>Source)
>
>     at
>org.apache.batik.swing.svg.JSVGComponent.computeRenderingTransform(Unknown
>Source)
>
>     at org.apache.batik.swing.gvt.JGVTComponent.setGraphicsNode(Unknown
>Source)
>
>     at org.apache.batik.swing.svg.JSVGComponent.access$601(Unknown Source)
>
>     at
>org.apache.batik.swing.svg.JSVGComponent$SVGListener.gvtBuildComple
>ted(Unknown
>
>Source)
>
>     at org.apache.batik.swing.svg.GVTTreeBuilder$2.run(Unknown Source)
>
>     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
>
>     at java.awt.EventQueue.dispatchEvent(EventQueue.java:337)
>
>     at
>java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatch
>Thread.java:131)
>
>     at
>java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchTh
>read.java:98)
>
>     at
>java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
>
>     at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
>
>
>At the end, there are no SVGs displayed in the JTree. Does anyone has a
>solution for this problem?
>
>cheers,
>
>Thomas
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: batik-users-help@xml.apache.org
>


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