Package org.apache.batik.swing

Examples of org.apache.batik.swing.JSVGCanvas$ToolTipModifier


        rectangle.setAttributeNS(null, "height", "200");
        rectangle.setAttributeNS(null, "fill", "red");
        rectangle.setAttributeNS(null, "id", "miId");
        svgRoot.appendChild(rectangle);
       
        final JSVGCanvas canvas = new JSVGCanvas();
        //UpdateManager um;
        canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
        canvas.setEnablePanInteractor(false);
        canvas.addGVTTreeRendererListener(new GVTTreeRendererListener() {
            public void gvtRenderingPrepare(GVTTreeRendererEvent gVTTreeRendererEvent) {
            }

            public void gvtRenderingStarted(GVTTreeRendererEvent gVTTreeRendererEvent) {
            }

            public void gvtRenderingCompleted(GVTTreeRendererEvent gVTTreeRendererEvent) {
                um = canvas.getUpdateManager();
            }

            public void gvtRenderingCancelled(GVTTreeRendererEvent gVTTreeRendererEvent) {
            }

            public void gvtRenderingFailed(GVTTreeRendererEvent gVTTreeRendererEvent) {
            }
        });
       
        JFrame f = new JFrame();
        f.setLayout(new BorderLayout());
        f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
        f.add(canvas, BorderLayout.CENTER);
        f.add(new JButton(new Action() {
            public Object getValue(String key) {
                return null;
            }

            public void putValue(String key, Object value) {
            }

            public void setEnabled(boolean b) {
            }

            public boolean isEnabled() {
                return true;
            }

            public void addPropertyChangeListener(PropertyChangeListener listener) {
            }

            public void removePropertyChangeListener(PropertyChangeListener listener) {
            }

            public void actionPerformed(ActionEvent e) {
        System.out.println("agregar rectangulo");
        um.getUpdateRunnableQueue().invokeLater(new Runnable() {
            public void run() {
        Element rectangle = doc.createElementNS(svgNS, "rect");
        rectangle.setAttributeNS(null, "x", "10");
        rectangle.setAttributeNS(null, "y", "12");
        rectangle.setAttributeNS(null, "width", "10");
        rectangle.setAttributeNS(null, "height", "20");
        rectangle.setAttributeNS(null, "fill", "green");
        svgRoot.appendChild(rectangle);
        rectangle = doc.createElementNS(svgNS, "rect");
        rectangle.setAttributeNS(null, "x", "12");
        rectangle.setAttributeNS(null, "y", "16");
        rectangle.setAttributeNS(null, "width", "6");
        rectangle.setAttributeNS(null, "height", "12");
        rectangle.setAttributeNS(null, "fill", "white");
        rectangle.setAttributeNS(null, "cursor", "pointer");
       
        EventTarget et = (EventTarget) rectangle;
        et.addEventListener("mouseover", new EventListener() {
            public void handleEvent(Event evt) {
                System.out.println("event " + evt.getType());
                System.out.println("target " + evt.getTarget());
                System.out.println("x " + ((Element) evt.getTarget()).getAttributeNodeNS(null, "x").getValue());
                System.out.println("y " + ((Element) evt.getTarget()).getAttributeNodeNS(null, "y").getValue());
            }
        }, false);
        et.addEventListener("mouseout", new EventListener() {
            public void handleEvent(Event evt) {
                System.out.println("event " + evt.getType());
                System.out.println("target " + evt.getTarget());
                System.out.println("x " + ((Element) evt.getTarget()).getAttributeNodeNS(null, "x").getValue());
                System.out.println("y " + ((Element) evt.getTarget()).getAttributeNodeNS(null, "y").getValue());
            }
        }, false);
       
        svgRoot.appendChild(rectangle);
       
        doc.getElementById("miId").getAttributeNodeNS(null, "x").setValue("30");
            }
        });
            }}), BorderLayout.SOUTH);
        canvas.setSVGDocument((SVGDocument) doc);
        f.pack();
        f.setVisible(true);
    }
View Full Code Here


        //
        // Set the frame's maximum size so that content
        // bigger than the screen does not cause the creation
        // of unnecessary large images.
        //
        svgCanvas = new JSVGCanvas(userAgent, true, true){
                Dimension screenSize;
               
                {
                    screenSize = Toolkit.getDefaultToolkit().getScreenSize();
                    setMaximumSize(screenSize);
View Full Code Here

        initDialog.setSize(ds);
        initDialog.setVisible(true);

        final JSVGViewerFrame v = new JSVGViewerFrame(this);
        JSVGCanvas c = v.getJSVGCanvas();
        c.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter() {
            public void documentLoadingStarted(SVGDocumentLoaderEvent e) {
                pb.setValue(1);
            }
            public void documentLoadingCompleted(SVGDocumentLoaderEvent e) {
                pb.setValue(2);
            }
        });
        c.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
            public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
                pb.setValue(3);
            }
        });
        c.addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
            public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
                initDialog.dispose();
                v.dispose();
                System.gc();
                run();
            }
        });

        c.setSize(100, 100);
        svgInitializationURI = Main.class.getResource(SVG_INITIALIZATION).toString();
        c.loadSVGDocument(svgInitializationURI);
    }
View Full Code Here

*/
public class JSVG extends JFrame{
    static int windowCount=0;
    public JSVG(String url) {
        super(url);
        JSVGCanvas canvas = new JSVGCanvas(new SVGUserAgentGUIAdapter(this),
                                           true, true) {
                /**
                 * This method is called when the component knows the desired
                 * size of the window (based on width/height of outermost SVG
                 * element). We override it to immediately pack this frame.
                 */
                public void setMySize(Dimension d) {
                    setPreferredSize(d);
                    invalidate();
                    JSVG.this.pack();
                }
            };

        getContentPane().add(canvas, BorderLayout.CENTER);
        canvas.setURI(url);
        setVisible(true);
        addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    windowCount--;
                    if (windowCount == 0)
View Full Code Here

    }
   
    public JSVGCanvasHandler createCanvasHandler() {
        return new JSVGCanvasHandler(this, this) {
                public JSVGCanvas createCanvas() {
                    JSVGCanvas ret = new JSVGCanvas();
                    ret.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
                    return ret;
                }
            };
    }
View Full Code Here

        }
       
        //
        // Now, transcode SVG to a BufferedImage
        //
        JSVGCanvas svgCanvas = new JSVGCanvas();
        LoaderListener l = new LoaderListener();
        svgCanvas.addSVGDocumentLoaderListener(l);

        try{
            svgCanvas.setURI(tmpFile.toURL().toString());
            synchronized(l.sem){
                l.sem.wait();
            }
        }catch(Exception e){
            e.printStackTrace();
View Full Code Here

    }

    public JFrame getFrame()     { return frame; }
    public JSVGCanvas getCanvas() { return canvas; }

    public JSVGCanvas createCanvas() { return new JSVGCanvas(); }
View Full Code Here

        initDialog.setSize(ds);
        initDialog.setVisible(true);

        final JSVGViewerFrame v = new JSVGViewerFrame(this);
        JSVGCanvas c = v.getJSVGCanvas();
        c.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter() {
            public void documentLoadingStarted(SVGDocumentLoaderEvent e) {
                pb.setValue(1);
            }
            public void documentLoadingCompleted(SVGDocumentLoaderEvent e) {
                pb.setValue(2);
            }
        });
        c.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
            public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
                pb.setValue(3);
            }
        });
        c.addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
            public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
                initDialog.dispose();
                v.dispose();
                System.gc();
                run();
            }
        });

        c.setSize(100, 100);
        svgInitializationURI = Main.class.getResource(SVG_INITIALIZATION).toString();
        c.loadSVGDocument(svgInitializationURI);
    }
View Full Code Here

            public void windowClosing(WindowEvent e) {
                application.closeJSVGViewerFrame(JSVGViewerFrame.this);
            }
        });

        svgCanvas = new JSVGCanvas(userAgent, true, true);
        svgCanvas.setDoubleBufferedRendering(true);

        listeners.put(ABOUT_ACTION, new AboutAction());
        listeners.put(OPEN_ACTION, new OpenAction());
        listeners.put(OPEN_LOCATION_ACTION, new OpenLocationAction());
View Full Code Here

        }
       
        //
        // Now, transcode SVG to a BufferedImage
        //
        JSVGCanvas svgCanvas = new JSVGCanvas();
        LoaderListener l = new LoaderListener();
        svgCanvas.addSVGDocumentLoaderListener(l);

        try{
            svgCanvas.setURI(tmpFile.toURL().toString());
            synchronized(l.sem){
                l.sem.wait();
            }
        }catch(Exception e){
            e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.apache.batik.swing.JSVGCanvas$ToolTipModifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.