Hi V,
vyang <[EMAIL PROTECTED]> wrote on 12/05/2006 09:31:30 AM:
> However, all I'm getting is the orginal coordinates.
> Here is my test coding:
I don't see anything that is changing the location
of the rectangles below. How are you moving the
rects? If you are updating the transform then
you probably need to use something like 'getScreenCTM()'
to map the X/Y back to screen coords.
> Yes, I tried something like that. Coding is:
>
> Element e = document.getElementById("arect");
> Double x = Double.parseDouble(e.getAttributeNS(null, "x"));
> System.out.println(x);
> public class SVGApplication implements MouseListener {
>
> public static void main(String[] args) {
> new SVGApplication();
> }
>
> JFrame frame;
> JSVGCanvas canvas;
> Document document;
> Window window;
> int pressed;
> UpdateManager um;
>
> JLabel label = new JLabel();
>
> public SVGApplication() {
> SVGTest svgTest = new SVGTest();
> svgTest.testing();
> document = svgTest.getDocument();
> document.setDocumentURI(svgTest.getSVGNS());
>
> frame = new JFrame("SVG Application");
> canvas = new JSVGCanvas();
> JPanel jPanelA = new JPanel(new BorderLayout());
> JPanel jPanelB = new JPanel(new
FlowLayout(FlowLayout.TRAILING));
>
> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> canvas.setDisableInteractions(false);
> jPanelB.add(label);
> jPanelB.setBackground(Color.WHITE);
> jPanelA.add(jPanelB, BorderLayout.PAGE_END);
> jPanelA.add(canvas, BorderLayout.CENTER);
>
> canvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
> public void gvtBuildStarted(GVTTreeBuilderEvent e) {
> label.setText("Build Started...");
> }
> public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
> label.setText("Build Completed...");
> //frame.pack();
> }
> });
>
> canvas.addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
> public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
> label.setText("Rendering Started...");
> }
> public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
> label.setText("Rendering Completed...");
>
> um = canvas.getUpdateManager();
> um.getUpdateRunnableQueue().invokeLater(new Runnable(){
> public void run() {
> update();
>
> }
> });
> }
> });
>
> canvas.addMouseListener(this);
>
> frame.addWindowListener(new WindowAdapter() {
> public void windowClosing(WindowEvent e) {
> System.exit(0);
> }
> });
>
> frame.getContentPane().add(jPanelA);
> frame.setSize(400,400);
> frame.setVisible(true);
> canvas.setDocument(document);
> }
>
> public void mousePressed(MouseEvent e) {
> pressed += e.getClickCount();
> label.setText("Mouse Pressed " + pressed + " times!!!");
>
> um.getUpdateRunnableQueue().invokeLater(new Runnable(){
> public void run() {
>
> update();
> }
> });
> }
>
> public void mouseReleased(MouseEvent e) {
>
> }
>
> public void mouseEntered(MouseEvent e) {
>
> }
>
> public void mouseExited(MouseEvent e) {
>
> }
>
> public void mouseClicked(MouseEvent e) {
>
> }
>
> public void update() {
> Element e = document.getElementById("arect");
> Double x = Double.parseDouble(e.getAttributeNS(null, "x"));
> System.out.println(x);
> }
>
> }
>
> What am I doing wrong?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]