Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14742
Modified Files:
MoveTool.java
Log Message:
added some snap to the free move mode
Index: MoveTool.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MoveTool.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** MoveTool.java 7 Feb 2006 12:49:55 -0000 1.32
--- MoveTool.java 9 Feb 2006 15:01:48 -0000 1.33
***************
*** 42,52 ****
/** The axis restricted movement mode */
! private static final int AXIS_RESTRICTED = 0;
/** The free snap movement mode */
! private static final int FREE_SNAP = 1;
/** The 3 clicks movement mode */
! private static final int THREE_CLICK = 2;
/** The initial movepoint */
--- 42,52 ----
/** The axis restricted movement mode */
! public static final int AXIS_RESTRICTED = 0;
/** The free snap movement mode */
! public static final int FREE_SNAP = 1;
/** The 3 clicks movement mode */
! public static final int THREE_CLICK = 2;
/** The initial movepoint */
***************
*** 83,87 ****
private Edge threeClickConst;
! /**
/**
--- 83,91 ----
private Edge threeClickConst;
! /** The entity that is being snapped to */
! private Entity snapEntity;
!
! /** The Collection of entities being moved */
! private Collection moveEntities;
/**
***************
*** 94,97 ****
--- 98,102 ----
moveConstructors = null;
restrictionVector = null;
+ snapEntity = null;
numberOfClicks = 1;
moveMode = AXIS_RESTRICTED;
***************
*** 134,137 ****
--- 139,143 ----
vertices = new HashSet();
+ moveEntities = selection;
collect(selection, vertices);
} else {
***************
*** 261,265 ****
Vertex delta = parentPos.minus(from);
//Restricting movement to fit movement mode.
! delta = restrict(delta);
if (log.isDebugEnabled()) {
--- 267,271 ----
Vertex delta = parentPos.minus(from);
//Restricting movement to fit movement mode.
! delta = restrict(delta, e);
if (log.isDebugEnabled()) {
***************
*** 306,312 ****
* given a desired movement vector.
* @param delta the movement vector.
* @return the restricted movement vector.
*/
! private Vertex restrict(Vertex delta) {
if (moveMode == AXIS_RESTRICTED) {
Vertex restrictCopy = restrictionVector.copy();
--- 312,319 ----
* given a desired movement vector.
* @param delta the movement vector.
+ * @param e the mouseEvent for this restriction
* @return the restricted movement vector.
*/
! private Vertex restrict(Vertex delta, MouseEvent e) {
if (moveMode == AXIS_RESTRICTED) {
Vertex restrictCopy = restrictionVector.copy();
***************
*** 314,317 ****
--- 321,334 ----
restrictCopy.scale(delta.dot(restrictCopy));
delta = restrictCopy;
+ } else if (moveMode == FREE_SNAP) {
+ List objects = glv.getView().getObjectAtPoint(e.getX(), e.getY(), moveEntities);
+ Iterator it = objects.iterator();
+ if (it.hasNext()) {
+ Object o = it.next();
+ if (o != null) {
+ snapEntity = (Entity)o;
+ delta = findInitial(snapEntity, e).minus(from);
+ }
+ }
}
return delta;
***************
*** 577,579 ****
--- 594,604 ----
glv.repaint(true);
}
+
+ /**
+ * sets movemode
+ * @param mode the mode
+ */
+ public void setMoveMode(int mode) {
+ moveMode = mode;
+ }
}
|