1 18 19 package org.objectweb.jac.ide.diagrams; 20 21 import CH.ifa.draw.framework.DrawingEditor; 22 import CH.ifa.draw.framework.Figure; 23 import CH.ifa.draw.standard.AbstractTool; 24 import org.objectweb.jac.aspects.gui.DisplayContext; 25 import java.awt.event.MouseEvent ; 26 27 public abstract class AbstractActionTool extends AbstractTool { 28 29 protected DisplayContext context; 30 Class figureClass; 31 32 37 public AbstractActionTool(DrawingEditor drawingEditor, 38 DisplayContext context, 39 Class figureClass) { 40 super(drawingEditor); 41 this.context = context; 42 this.figureClass = figureClass; 43 } 44 45 49 public void mouseDown(MouseEvent e, int x, int y) { 50 Figure target = drawing().findFigure(x, y); 51 if (target != null && figureClass.isAssignableFrom(target.getClass())) { 52 view().addToSelection(target); 53 action(target); 54 } 55 } 56 57 public void mouseUp(MouseEvent e, int x, int y) { 58 editor().toolDone(); 59 } 60 61 public abstract void action(Figure figure); 62 63 public boolean isActive() { 64 return editor().tool() == this; 67 } 68 } 69 70 | Popular Tags |