I have a problem using the getPointAtLength and getTotalLength where it keeps 
throwing a Null Pointer exception or a ClassCast exception depending on how 
much of the Batik source I put in my test program.

I've heard that it has been implemented in 1.6, but I can't seem to make it 
work.

I thought at first that it had similar issues to getBBox. (Have to use a 
GraphicsNode and create it with the data before issuing a call to getBBox.) T

Any help would be appreciated. I tired to go with getTotalLength after 
everything failed for getPointAtLength. This code has been stepped through 
with a debugger so comments about when something is good, or gets populated 
are from evidence in the debugger.

Code follows:
        // Use your favorite method to create a 'doc' variable. I used 
        // a local method that returns an empty SVGDocument. That 
        // method returns a valid document.
        SVGOMPathElement pe = null;
        pe = new SVGOMPathElement(null, (AbstractDocument) doc);
        pe.setAttribute("d", "M1 1 L15 15 L25 25 L40 40 A30 30 -30 0 1 60 
60");

        pe.setSVGContext(new SVGPathElementBridge());
        
        SVGPathSegList pl = pe.getPathSegList();
        
        float len = 0;
        
        // this is good. When this is done the array of items (pl) is finally
        // populated.
        int size = pl.getNumberOfItems();
        
<<<<<<<<<<<<<<<<< Problems start.
        // Try to create the GraphicsNode. NOTE: I put this code in because
        // a simple call to any element in the SVGPathSegList to getTotalSize
        // blew up.
        SVGPathElementBridge pathCtx = (SVGPathElementBridge)
                 pe.getSVGContext();
        
        GVTBuilder gvt = new GVTBuilder();
        // OK
        UserAgentAdapter userAgentAdapter = new UserAgentAdapter();
        // OK
        BridgeContext bridgeContext = new BridgeContext(userAgentAdapter);
        // OK
        GraphicsNode gn = gvt.build(bridgeContext, doc);

        // now blows up here! Class cast exception
        pathCtx.buildGraphicsNode(bridgeContext, pe, gn);
        
        // still blows up here!
        len = pathCtx.getTotalLength();

<<<<<<<<<<<<<<<<< This didn't work either
        // The following replaces from "Try to create the GraphicsNode" on...
        // This didn't work -- returns null!
        SVGPoint sp = pe.getPointAtLength(10);
        
<<<<<<<<<<<<<<<<< This didn't work either
        // This didn't work either:
        if(size > 0) {
            // still blows up here!
           len = SVGPathSupport.getTotalLength(pe);
        }
        


-- 
Roy Hollinger
Senior Software Engineer
ProLogic, Inc.
[EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to