[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool MoveTool.java,1.30,1.31
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2006-02-01 17:26:59
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29715 Modified Files: MoveTool.java Log Message: three-click type of move added, implementation a little messy so still needs some clean up. Index: MoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MoveTool.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** MoveTool.java 30 Jan 2006 14:48:44 -0000 1.30 --- MoveTool.java 1 Feb 2006 17:26:50 -0000 1.31 *************** *** 47,50 **** --- 47,53 ---- private static final int FREE_SNAP = 1; + /** The 3 clicks movement mode */ + private static final int THREE_CLICK = 2; + /** The initial movepoint */ private Vertex initial; *************** *** 74,77 **** --- 77,88 ---- private int moveMode; + /** Number of clicks when in 3 click mode */ + private int numberOfClicks; + + /** The Three click constructors edge */ + private Edge threeClickConst; + + /** + /** * The Constructor *************** *** 83,86 **** --- 94,98 ---- moveConstructors = null; restrictionVector = null; + numberOfClicks = 1; moveMode = AXIS_RESTRICTED; } *************** *** 109,124 **** */ protected void pressed(MouseEvent e) { ! super.pressed(e); ! clearConstructors(moveConstructors); ! if (target != null) { ! initial = findInitial(target, e); ! from = initial.copy(); ! ! setupConstructors(); ! displayConstructors(moveConstructors); ! vertices = new HashSet(); ! collect(selection, vertices); } } --- 121,162 ---- */ protected void pressed(MouseEvent e) { ! findTarget(e); clearConstructors(moveConstructors); ! if (target != null) { ! if (moveMode != THREE_CLICK) { ! super.pressed(e); ! initial = findInitial(target, e); ! from = initial.copy(); ! setupConstructors(); ! displayConstructors(moveConstructors); ! ! vertices = new HashSet(); ! collect(selection, vertices); ! } else { ! threeClickMove(e); ! } ! } ! } ! ! /** Talking care of the three-click mode ! * @param e the MouseEvent object ! */ ! private void threeClickMove(MouseEvent e) { ! vertices = new HashSet(); ! collect(selection, vertices); ! if (numberOfClicks == 1) { ! from = findInitial(target, e); ! threeClickConst = new Edge(from, from); ! threeClickConst.setConstructor(true); ! glv.getView().addTempEdge(threeClickConst); ! numberOfClicks = 2; ! } else if (numberOfClicks == 2) { ! Vertex movement = findInitial(target, e).minus(from); ! move(vertices, movement); ! glv.getView().removeTempEdge(threeClickConst); ! threeClickConst = null; ! update(); ! numberOfClicks = 1; } } *************** *** 137,140 **** --- 175,180 ---- } else if (moveMode == FREE_SNAP) { moveConstructors = makeXYZConerConstructors(initial); + } else if (moveMode == THREE_CLICK) { + moveConstructors = new HashSet(); } } *************** *** 184,187 **** --- 224,243 ---- number = ""; } + + /** + * Invoked when the mouse cursor has been moved + * @param e The MouseEvent object + */ + protected void moved(MouseEvent e) { + super.moved(e); + if (moveMode == THREE_CLICK && threeClickConst != null) { + if (target != null) { + Vertex to = findInitial(target, e); + if (to != null) { + threeClickConst.setTo(to); + } + } + } + } /** *************** *** 313,317 **** /** * Creates the surface spanned by two edges connected ! * at one point. * @param edge1 the first edge. * @param edge2 the second edge. --- 369,373 ---- /** * Creates the surface spanned by two edges connected ! * at one point.Used in finding restrictions for the FREE_SNAP mode. * @param edge1 the first edge. * @param edge2 the second edge. *************** *** 457,466 **** } else if (e.getKeyCode() == KeyEvent.VK_M) { if (dragPlane == null) { ! if (moveMode == AXIS_RESTRICTED) { ! moveMode = FREE_SNAP; ! } else { ! moveMode = AXIS_RESTRICTED; ! } } } else if (lastRestriction != null && initial != null && --- 513,519 ---- } else if (e.getKeyCode() == KeyEvent.VK_M) { if (dragPlane == null) { ! moveMode = (moveMode + 1) % 3; } + numberOfClicks = 1; } else if (lastRestriction != null && initial != null && |