Hi,

   I’ve run into a kind of batik morass and thought maybe someone might be able to suggest a way out.

I’m not totally sure how to describe the problem , but here goes.

(batik-1.5beta4b, Java 1.4)

 

  I have two Java Jframes that display two separate JSVGCanvas’s that result from calls to two separate classes.  Each JSVGCanvas displays properly when I try to display them using a test class that has one frame and one svg canvas

 

I try to display the two canvas’s like this (just an exerpt of what I thought was relevant):

 

       SVGSpliceVariantImp svgSpliceVariant = new SVGSpliceVariantImp(testdata);

       theCanvas = svgSpliceVariant.getmRNADisplay();

       frame.getContentPane().add(theCanvas);

       frame.pack();

       frame.setSize(1000, 800);

       frame.setVisible(true); 

      

       SVGDNAImp svgDNA = new SVGDNAImp();

       theCanvas2 = svgDNA.getDNADisplay();

       frame2.getContentPane().add(theCanvas2);

       frame2.pack();

       frame2.setSize(1000, 800);

       frame2.setVisible(true);

 

but get an error like this:

 

java.lang.NullPointerException

        at org.apache.batik.bridge.CSSUtilities.getComputedStyle(Unknown Source)

        at org.apache.batik.bridge.CSSUtilities.convertDisplay(Unknown Source)

        at org.apache.batik.bridge.AbstractGraphicsNodeBridge.getDisplay(Unknown Source)

        at org.apache.batik.bridge.GVTBuilder.build(Unknown Source)

        at gui.genOrgaSVG.SVGDNAImp.svg_addLineInfo(SVGDNAImp.java:268)

        at gui.genOrgaSVG.SVGDNAImp.dna2SVG(SVGDNAImp.java:177)

        at gui.genOrgaSVG.SVGDNAImp.<init>(SVGDNAImp.java:100)

        at gui.genOrgaSVG.GenOrgaSVGTestBoth.main(GenOrgaSVGTestBoth.java:102)

Exception in thread "main"

 

The source that corresponds to this error comes from this method:

 

public Element svg_HiLightSeqSeg(String anId, Element aTextElement, long startHiLight, long endHiLight, String hiLightColor, int offset) {

 

          String elementText = aTextElement.getFirstChild().getNodeValue();

          log.debug("  the element's text: " + elementText);

          int textLength = elementText.length();

 

       // Given the Element representing the current line of sequence, find it's x0,y0 and height & width using GVT methods.

          Element overlayRect = doc.createElementNS(svgNS, "rect");

          GVTBuilder builder = new GVTBuilder();

          BridgeContext ctx = new BridgeContext(new UserAgentAdapter());

          GraphicsNode aTextElementNode = builder.build(ctx, aTextElement);

          double width = aTextElementNode.getBounds().getWidth();

          double height =  aTextElementNode.getBounds().getHeight();

          double x =  aTextElementNode.getBounds().getX();

          double y =  aTextElementNode.getBounds().getMinY();

(…code continues)

 

  I thought of and tried to test for various things like maybe there wasn’t  a big enough Frame or JSVGCanvas or something funny was happening with the timing of the JSVGCanvas creation, but haven’t had an luck.  I suspect it has something to do with the BridgeContext or maybe UserAgent, but don’t really know.

 

Any ideas would be appreciated.

 

sincerely,

Randy Baron

 

Reply via email to