Hi Selva --

I did the opposite, I put a background rectangle into the document and
run the mouse move handler off that.

I added a component listener to the JSVGCanvas to catch resize events
so I can adjust the background to exactly fill the window.   You can
probably use the same code to adjust your transparent glass pane:

       svgCanvas.addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent e) {
                        if (svgDoc != null) {
                        final SVGRectElement bkgd =
(SVGRectElement)getElementById("background");
                                final GraphViewport view = getViewport();
                        if (bkgd != null && view != null) {
                                runInUpdateThread(new Runnable() {
                                        public void run() {
                                                bkgd.setAttributeNS(null, "x", 
Float.toString(view.getOriginX()));
                                                bkgd.setAttributeNS(null, "y", 
Float.toString(view.getOriginY()));
                                                bkgd.setAttributeNS(null, 
"width",
Float.toString(view.getWidth()));
                                                bkgd.setAttributeNS(null, 
"height",
Float.toString(view.getHeight()));
                                        }
                                });
                        }
                }
        }
       });

I compute the viewport like this:

        public GraphViewport getViewport() {
                // take the viewing transform, invert and apply to the screen 
rectangle,
                // this should be the screen rectangle in the SVG coordinates.
                final Rectangle2D r = svgCanvas.getVisibleRect();
                try {
                        AffineTransform v = 
svgCanvas.getViewingTransform().createInverse();
                        double coords[] = { r.getX(), r.getY(), 
r.getX()+r.getWidth(),
r.getY()+r.getHeight(),
                                        0, 0, 0, 0 };
                        v.inverseTransform(coords, 0, coords, 4, 4);
                        final float x = (float)coords[4];
                        final float y = (float)coords[5];
                        final float width = (float)coords[6];
                        final float height = (float)coords[7];
                        // System.err.println("viewport: "+x+", "+y+", "+width+", 
"+height);
                        return new GraphViewport() {
                                public float getOriginX() { return x; }
                                public float getOriginY() { return y; }
                                public float getWidth() { return width; }
                                public float getHeight() { return height; }
                        };
                } catch(Exception e) {
                        return new GraphViewport() {
                                public float getOriginX() { return 
(float)r.getX(); }
                                public float getOriginY() { return 
(float)r.getY(); }
                                public float getWidth() { return 
(float)r.getWidth(); }
                                public float getHeight() { return 
(float)r.getHeight(); }
                        };
                }
        }

-- rec --

On 5/3/06, Selva <[EMAIL PROTECTED]> wrote:

Hi All,

I have added glass pane in my SVGApplication to smoothen the mouse move
events. But while Zoom In/Zoom Out the SVGCanvas, it not zooming in/Zooming
out the glass pane to whole view port. So elements in SVGCanvas not able to
move in entire SVGCavas. So anybody please help me to resolve this problem.

My glass pane code snippet:
Element rect = _document.createElementNS(SVGGraphView.svgNS, "rect");
rect.setAttributeNS(null, "id", "bgrectangle");
rect.setAttributeNS(null, "x", "0");
rect.setAttributeNS(null, "y", "0");
rect.setAttributeNS(null, "width", "100%");
rect.setAttributeNS(null, "height", "100%");
rect.setAttributeNS(null, "pointer-events", "fill");
rect.setAttributeNS(null, "style", "fill:none;stroke:none");

Thanks,
Selva

--
View this message in context: 
http://www.nabble.com/Zoom-In-Zoom-Out-problem-for-glass-pane-t1551519.html#a4214771
Sent from the Batik - Users forum at Nabble.com.


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



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

Reply via email to