thomas.deweese wrote:
> 
> 
>     I suspect you need to call 'EventTarget.removeEventListener'
> 

I delete the code of "onUpAction" and "onMoveAction" in this way the code
become simpler...then, how you say, i remove Event listener but the the
problem is not solved:

private JButton getPolygonButton() {
                        if (polygonButton == null) {
                                polygonButton = new JButton();
                                polygonButton.setText("polygon");
                                polygonButton.addActionListener(new 
java.awt.event.ActionListener() {
                                        public void 
actionPerformed(java.awt.event.ActionEvent e) {     
                                                move = false;                   
                
                                                elem = 6;
                                                create = true;
                                                flag = true;
                                                points = "";
                               
svgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
Runnable() {
                                                        public void run() {
                                                                        
SVGElement svgRoot = svgCanvas.getSVGDocument().getRootElement();
                                                                        
svgRoot.setAttributeNS(null, "cursor", "crosshair");
                                                                        
EventTarget t = (EventTarget)svgRoot;
                                                                        
//t.addEventListener("mousemove", new OnMoveAction(), false);
                                                                        
t.addEventListener("mousedown", new OnDownAction(), false);
                                                                        
//t.addEventListener("mouseup", new OnUpAction(), false);
                                                        }
                                });
                                        }

                                });
                        }
                        return polygonButton;
                }


            private class OnDownAction implements EventListener {
                public void handleEvent(Event evt) {
                        Element svgRoot = 
svgCanvas.getSVGDocument().getRootElement();
                        if(move == true){
                    DOMMouseEvent elEvt = (DOMMouseEvent)evt;  
                    actionNode = elEvt.getTarget();
                    action = DRAG;
                    Node n = ((Element)elEvt.getTarget());
                    startPt = localPt((Element)n, elEvt.getClientX(),
elEvt.getClientY());
                        }else if(create == true){
                                DOMMouseEvent elEvt = (DOMMouseEvent)evt;  
                            actionNode = elEvt.getTarget();
                            action = DRAG;
                            Node n = ((Element)elEvt.getTarget());
                            startPt = localPt((Element)n, elEvt.getClientX(),
elEvt.getClientY());
                                switch(elem){
                            case 1: 
                                        ...
                            case 2:
                                        ...
                            case 3:
                                      ...
                            case 4: 
                                     ....
                           case 6:
                                  if(flag = true){

                                points = 
points+startPt.getX()+","+startPt.getY()+" ";                                  
                                System.out.println(points);

                                        if(elEvt.getDetail() == 2){   
                                                flag = false;
                                                polygon = 
svgCanvas.getSVGDocument().createElementNS(svgNS,
"polygon");
                                        polygon.setAttributeNS(null, "id", 
"bgpolygon");
                                                
                                        polygon.setAttributeNS(null, "points", 
points);
                                        polygon.setAttributeNS(null, "style", 
"fill:rgb("+
newColor.getRed()+ "," + newColor.getGreen()+","+newColor.getBlue()+");
stroke:none; stroke-width:0");
                                
                                        svgRoot.appendChild(polygon);
                                        create = false;
                                        actionNode = null;
                                        elem = 0;
                                        points = "";
                                        
                                                        
                                                EventTarget t = 
(EventTarget)svgRoot;
                                                        
//t.removeEventListener("mousemove", new OnMoveAction(), false);
                                                
t.removeEventListener("mousedown", new OnDownAction(), false);
                                                        
//t.removeEventListener("mouseup", new OnUpAction(), false);
                                        }
                                        
                                   }                                    
                                break;
                        }                               
                        }
                }
            }

-- 
View this message in context: 
http://www.nabble.com/insert-polygon-tf2810417.html#a7853464
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