1 31 32 package org.antlr.xjlib.appkit.gview.event; 33 34 import org.antlr.xjlib.appkit.gview.GView; 35 import org.antlr.xjlib.appkit.gview.object.GElement; 36 import org.antlr.xjlib.appkit.gview.object.GLink; 37 38 import java.awt.*; 39 import java.awt.event.MouseEvent ; 40 41 public class GEventModifyLinkElement extends GAbstractEvent { 42 43 public GElement selectedLink = null; 44 45 public GEventModifyLinkElement(GView view) { 46 super(view); 47 } 48 49 public void mousePressed(MouseEvent e, Point mousePosition) { 50 if(hasExclusiveValue(GEventManager.EXCLUSIVE_DRAG_VALUE)) 51 return; 52 53 if(e.getClickCount() != 1) 54 return; 55 56 selectedLink = delegate.eventQueryElementAtPoint(mousePosition); 57 58 if(selectedLink == null || !(selectedLink instanceof GLink)) { 59 selectedLink = null; 60 return; 61 } 62 63 addExclusiveValue(GEventManager.EXCLUSIVE_DRAG_VALUE); 64 } 65 66 public void mouseReleased(MouseEvent e, Point mousePosition) { 67 removeExclusiveValue(GEventManager.EXCLUSIVE_DRAG_VALUE); 68 selectedLink = null; 69 } 70 71 public void mouseDragged(MouseEvent e, Point mousePosition) { 72 if(selectedLink == null) 73 return; 74 75 ((GLink)selectedLink).setMousePosition(mousePosition); 76 77 delegate.eventChangeDone(); 78 delegate.eventShouldRepaint(); 79 } 80 81 public boolean shouldFocusOnElement(GElement element) { 82 return selectedLink == null; 83 } 84 } 85 | Popular Tags |