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 "Baron, Randy {PRG~Basel}" <RA...@Roche.COM> on 2002/11/26 18:18:20 UTC

batik JSVGCanvas won't display

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
 

RE: batik JSVGCanvas won't display

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "BR" == Baron, Randy {PRG~Basel} <RA...@Roche.COM> writes:

 
BR> but get an error like this:
 
BR> java.lang.NullPointerException at
BR> org.apache.batik.bridge.CSSUtilities.getComputedStyle(Unknown
BR> Source) at
    
    You are not setting the CSSEngine on the BridgeContext.

BR> The source that corresponds to this error comes from this method:
 
          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)
 
BR>   I thought of and tried to test for various things like maybe
BR> there wasn't a big enough Frame or JSVGCanvas or something funny
BR> was happening with the timing of the JSVGCanvas creation, but
BR> haven't had an luck.  I suspect it has something to do with the
BR> BridgeContext or maybe UserAgent, but don't really know.
 
BR> Any ideas would be appreciated.
 
 You could provide a CSSEngine but I wonder why you are bothering to
build this second SVG tree?  Why not just query the tree you already
have?

        BridgeContext context = /* get the BridgeContext used to build
                                   gvt tree possibly by subclassing
                                   JSVGCanvas */

        GraphicsNode aTextElementNode = context.getGraphicsNode(aTextElement);
        /*...*/


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