xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bishop, Michael W. CONTR J9C880" <Michael.Bis...@je.jfcom.mil>
Subject RE: insert a rect into JSVGCanvas
Date Tue, 07 Nov 2006 13:47:24 GMT
The short answer is yes.  You'd record the point on mousePressed, record the point on mouseReleased
and then transform them from screen coordinates to document coordinates and render the rectangle
accordingly.
 
Michael Bishop

________________________________

From: Peppe [mailto:peppe.delia@gmail.com]
Sent: Tue 11/7/2006 4:09 AM
To: batik-users@xmlgraphics.apache.org
Subject: RE: insert a rect into JSVGCanvas





Finally with this code a rect shows in my JSVGCanvas; but in this way rect
shows in x=10 and y=10 position, there is a method where i can specify the
position and dimension via mouse?

private JButton getProva() {
                if (prova == null) {
                        prova = new JButton();
                        prova.setBounds(new Rectangle(446, 13, 110, 35));
                        prova.setText("rect");
                        prova.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent e)
{
                                        JSVGCanvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
Runnable() {
                                                public void run() {
                                                                SVGDocument doc = JSVGCanvas.getSVGDocument();
                                                                SVGElement svgRoot = doc.getRootElement();
                                                                JSVGCanvas.setDocument(doc);
                                                                String svgNS = "http://www.w3.org/2000/svg";
                                                                Element elem = doc.createElementNS(svgNS,
"rect");
                                                                elem.setAttributeNS(null,
"id", "bgrectangle");
                                                                elem.setAttributeNS(null,
"x","10");
                                                                elem.setAttributeNS(null,
"y","10");
                                                                elem.setAttributeNS(null,
"width", "50");
                                                                elem.setAttributeNS(null,
"height", "50");
                                                                elem.setAttributeNS(null,
"pointer-events", "fill");
                                                                elem.setAttributeNS(null,
"style", "fill:red;stroke:none");
                                                                svgRoot.appendChild(elem);
                                        }
                                });
                                        JSVGCanvas.repaint();
                                }
                        });
                }
                return prova;
        }
--
View this message in context: http://www.nabble.com/insert-a-rect-into-JSVGCanvas-tf2578737.html#a7214836
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org



Mime
View raw message