Hello all,

I'm wondering how one /should/ go about getting the position of a
character (e.g., in a TextNode).  Currently, I'm trying to use the
BridgeContext to get a Bridge for the node, then using
TextBridge.getStartPositionOfChar(int) to get its location.  If I do that,
though, I get a NullPointerException somewhere deep within the guts of
Batik:

        public void updateCaret()
        {
            SVGTextElementBridge textBridge = (SVGTextElementBridge) 
bridgeContext.getBridge(bridgeContext.getElement(caretMark.getTextNode()));

//            Rectangle2D charBounds = textBridge.getExtentOfChar(caretPosition);
            Point2D charStart = textBridge.getStartPositionOfChar(caretPosition);

            caretOverlay.setShape(new Line2D.Double(0, 0, charStart.getX(), 
charStart.getY()));
            svgEditor.repaint();
        }



results in:



java.lang.NullPointerException
        at 
org.apache.batik.bridge.SVGTextElementBridge.getStartPositionOfChar(SVGTextElementBridge.java:2316)
        at 
org.apache.batik.bridge.SVGTextElementBridge.getStartPositionOfChar(SVGTextElementBridge.java:2128)
        at 
org.globalcircle.svg.modehandlers.TextModeHandler$EditableTextSelector.updateCaret(TextModeHandler.java:132)
        at 
org.globalcircle.svg.modehandlers.TextModeHandler$EditableTextSelector.keyPressed(TextModeHandler.java:238)
        at 
org.globalcircle.svg.modehandlers.TextModeHandler$EditableTextSelectionManager$KeyListener.keyPressed(TextModeHandler.java:50)
        at 
org.apache.batik.gvt.event.AWTEventDispatcher.processKeyEvent(AWTEventDispatcher.java:550)
        at 
org.apache.batik.gvt.event.AWTEventDispatcher.dispatchKeyEvent(AWTEventDispatcher.java:369)
        at 
org.apache.batik.gvt.event.AWTEventDispatcher.dispatchEvent(AWTEventDispatcher.java:357)
        at 
org.apache.batik.gvt.event.AWTEventDispatcher.keyPressed(AWTEventDispatcher.java:220)
        at 
org.apache.batik.swing.svg.JSVGComponent$SVGListener$10.run(JSVGComponent.java:1758)
        at org.apache.batik.util.RunnableQueue.run(RunnableQueue.java:162)
        at java.lang.Thread.run(Thread.java:534)


(using Batik-1.5.1rc2; but the same thing happens with Batik-1.5).

Thank you for any and all help.  It is appreciated.


Sincerely,
Bob Sahu


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

Reply via email to