I get the Element with the getElementById(String) method. It surely works, I
tried to print the result. Here is the code. I based my work on the Batik
sources. Sorry for it's longness.

canvas.getInteractors().add(new AbstractZoomInteractor() {

    ...

    @Override
    public void mouseReleased(MouseEvent e) {

        finished = true;
        JGVTComponent c = (JGVTComponent) e.getSource(); <------------- HERE
I GET THE COMPONENT
        c.getOverlays().remove(overlay);
        overlay.paint(c.getGraphics());
        xCurrent = e.getX();
        yCurrent = e.getY();

        if ((xCurrent - xStart) != 0 && (yCurrent - yStart) != 0) {
            int dx = xCurrent - xStart;
            int dy = yCurrent - yStart;

            if (dx < 0) {
                dx = -dx;
                xStart = xCurrent;
            }

            if (dy < 0) {
                dy = -dy;
                yStart = yCurrent;
            }

            Dimension size = c.getSize();
            float scaleX = size.width / (float) dx;
            float scaleY = size.height / (float) dy;
            float scale = (scaleX < scaleY) ? scaleX : scaleY;
            AffineTransform at = new AffineTransform();
            at.scale(scale, scale);
            at.translate(-xStart, -yStart);
            at.concatenate(c.getRenderingTransform());
            c.setRenderingTransform(at);

            SVGDocument docum = canvas.getSVGDocument();
            Element element = docum.getElementById("MySvgElement");  <- HERE
I GET THE SVG ELEMENT
            UpdateManager um = ((JSVGCanvas) c).getUpdateManager();  <-
JGVTComponent to JSVGCanvas
            BridgeContext bc = um.getBridgeContext();
            System.out.println("BC: " + bc.toString()); <-------------- THIS
RETURNS SOMETHING
            GraphicsNode gn = (GraphicsNode) bc.getGraphicsNode(element);
            System.out.println("GN: " + gn); <------------------------- THIS
RETURNS NULL
        }
    }
});



thx



-- 
View this message in context: 
http://www.nabble.com/Dynamic-Elements-on-zoom-tp23584458p26008288.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to