Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: gef/src/org/tigris/gef/base SelectionManager.java ModeModify.java

gef
Discussion topic

Back to topic list

CVS update: gef/src/org/tigris/gef/base SelectionManager.java ModeModify.java

Reply

Author 1sturm
Full name Thorsten Sturm
Date 2001-01-05 04:14:48 PST
Message User: 1sturm
  Date: 01/01/05 04:14:48

  Modified: src/org/tigris/gef/base SelectionManager.java
                        ModeModify.java
  Log:
  fixes for bug #292
  Obtained from:Ed Lyons
  Submitted by: Thorsten
  Reviewed by: Thorsten
  
  Revision Changes Path
  1.2 +39 -1 gef/src/org/tigris/g​ef/base/SelectionMan​ager.java
  
  Index: SelectionManager.java
  ====================​====================​====================​=======
  RCS file: /cvs/gef/src/org/tig​ris/gef/base/Selecti​onManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SelectionManager.java 2000/09/04 12:38:46 1.1
  +++ SelectionManager.java 2001/01/05 12:14:48 1.2
  @@ -27,7 +27,7 @@
   // File: SelectionManager.java
   // Classes: SelectionManager
   // Original Author: jrobbins at ics dot uci dot edu
  -// $Id: SelectionManager.java,v 1.1 2000/09/04 12:38:46 1sturm Exp $
  +// $Id: SelectionManager.java,v 1.2 2001/01/05 12:14:48 1sturm Exp $
   
   package org.tigris.gef.base;
   
  @@ -290,6 +290,44 @@
       }
       return r;
     }
  +
  + /**
  + * This method will return the upper-left coordinate point
  + * of the entire selection by iterating through the figs
  + *
  + * @return Point - the point for that upper left corner
  + *
  + */
  + public Point getLocation() {
  +
  + int size = _selections.size();
  +
  + if (size < 1) return new Point(0,0);
  +
  + Selection sel = null;
  +
  + // I just set these to two unbelievably big numbers
  +
  + int lowestX = 32000;
  + int lowestY = 32000;
  +
  + Point pt = null;
  +
  + for (int i = 0; i < size; i++) {
  + sel = (Selection) _selections.elementAt(i);
  + pt = sel.getLocation();
  + if (pt.getX() < lowestX)
  + { lowestX = (int) pt.getX(); }
  + if (pt.getY() < lowestY)
  + { lowestY = (int) pt.getY(); }
  + }
  +
  + pt = null;
  + sel = null;
  +
  + return new Point(lowestX,lowestY);
  + }
  +
   
   // /** Align the selected Fig's relative to each other */
   // /* needs-more-work: more of this logic should be in ActionAlign */
  
  
  
  1.3 +72 -2 gef/src/org/tigris/g​ef/base/ModeModify.j​ava
  
  Index: ModeModify.java
  ====================​====================​====================​=======
  RCS file: /cvs/gef/src/org/tig​ris/gef/base/ModeMod​ify.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ModeModify.java 2000/10/16 12:04:47 1.2
  +++ ModeModify.java 2001/01/05 12:14:48 1.3
  @@ -24,7 +24,7 @@
   // File: ModeModify.java
   // Classes: ModeModify
   // Original Author: ics125 spring 1996
  -// $Id: ModeModify.java,v 1.2 2000/10/16 12:04:47 1sturm Exp $
  +// $Id: ModeModify.java,v 1.3 2001/01/05 12:14:48 1sturm Exp $
   
   package org.tigris.gef.base;
   
  @@ -159,7 +159,7 @@
       sm.startTrans();
       if (_curHandle.index == -1) {
         setCursor(Cursor.get​PredefinedCursor(Cur​sor.MOVE_CURSOR));
  - if (legal(dx, dy, sm, me)) {
  + if (legal(dx, dy, sm, me) && !outOfBounds(dx,dy,me,sm)) {
       sm.translate(dx, dy);
       _lastX = snapX; _lastY = snapY;
         }
  @@ -320,5 +320,75 @@
       }
       return true;
     }
  +
  + /**
  + * This method will check to see if the selection bein moved will end up
  + * off the screen and off the diagram. There is just no easy way to do this
  + * especially because there could be more than one fig selected!
  + *
  + * @param dx - horizontal distance to move
  + * @param dy - vertical distance to move
  + * @param me - the mouse event
  + * @param sm - the selection manager
  + * @returns boolean - is it out of bounds? ( T / F )
  + */
  + protected boolean outOfBounds(int dx, int dy, MouseEvent me, SelectionManager sm) {
  +
  + Rectangle selectionBox = sm.getContentBounds();
  +
  + int selectionHeight = (int)selectionBox.getHeight();
  + int selectionWidth = (int)selectionBox.getWidth();
  +
  + // Get top-left most point of the whole selection
  + Point selectionOrigin = sm.getLocation();
  +
  + int selectionOriginX = (int)selectionOrigin.getX();
  + int selectionOriginY = (int)selectionOrigin.getY();
  +
  + int targetY = me.getY();
  + int targetX = me.getX();
  +
  + // These offsets tell us where the drag point is in relation to
  + // the selection it is in. We need this information so that we don't
  + // let varying parts of the selection go outside the bounds just because
  + // the drag point was in different parts of the selection
  +
  + int topVerticalOffset = _lastY - selectionOriginY;
  + int bottomVerticalOffset = selectionOriginY + selectionHeight - _lastY;
  +
  + int leftHorizontalOffset = _lastX - selectionOriginX;
  + int rightHorizontalOffset = selectionOriginX + selectionWidth - _lastX;
  +
  + /*
  + * OK, what we're saying here is that if the destination point is less than
  + * zero, forget it. But if you move less than zero, but part of your figure
  + * would be in the negative zone, you cannot do that either.
  + */
  +
  + // Check top
  + if ((targetY < 0 ) || (targetY < topVerticalOffset) ) return true;
  +
  + // Check bottom
  +
  + int canvasBottomEdge = me.getComponent().getHeight();
  +
  + if ((targetY > canvasBottomEdge ) ||
  + ((targetY + bottomVerticalOffset) > canvasBottomEdge ) ) return true;
  +
  + // Check left
  + if ((targetX < 0 ) || (targetX < leftHorizontalOffset) ) return true;
  +
  + // Check right
  +
  + int canvasRightEdge = me.getComponent().getWidth();
  +
  + if ((targetX > canvasRightEdge ) ||
  + ((targetX + rightHorizontalOffset) > canvasRightEdge ) ) return true;
  +
  +
  + // Otherwise we're ok!
  + return false;
  + }
  +
   } /* end class ModeModify */

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: gef/src/org/tigris/gef/base SelectionManager.java ModeModify.java 1sturm Thorsten Sturm 2001-01-05 04:14:48 PST
Messages per page: