if (notYetDragged) if (view.isSelected(hilitedObject)) markPositionSelection(); else ((VisibleObject)hilitedObject).markPosition();
public void mouseDragged(MouseEvent e) {	ViewState view = ViewState.getInstance();	int px = e.getX()-view.getX0();	int py = e.getY()-view.getY0();		if (resetDraggedPosition)	{		pressedX = draggedX = px;		pressedY = draggedY = py;		resetDraggedPosition = false;	}			if ((px>0) && (py>0) && (px<width) && (py<height)) {			switch (mouseOperation) {			case NAVIGATOR_MOVE : //System.out.println("Dragged: NAVIGATOR_MOVE");				if (navigator.contains(e.getX(), e.getY()))	{					double navigatorScale = navigatorView.getScale();					double scale = view.getScale();										int dx = (int)((px-pressedX)/navigatorScale*scale); 					int dy = (int)((py-pressedY)/navigatorScale*scale);					if (view.moveOrigin(dx, dy)) {						recalculateNavigatorPosition();						repaint();						pressedX=px; pressedY=py;					}				}				break;			case ORIGIN_MOVE : {//System.out.println("Dragged: ORIGIN_MOVE");				int f = Settings.getInstance().getWindowsPan() ? -1 : 1;				int dx = f*(px-pressedX);				int dy = f*(py-pressedY);				if (view.moveOrigin(dx, dy)) {					recalculateNavigatorPosition();					blockNavigatorRedrawOnce = true;					repaint();					pressedX=px; pressedY=py;				}				break; }						case OBJECT_MOVE : {//System.out.println("Dragged: OBJECT_MOVE");								if (fastMove) { //fast move					draggedX=px; draggedY=py;					repaint();					break;							} 				int rdx = px-draggedX;				int rdy = py-draggedY;								double scale = view.getScale();				int dx = (int)(rdx/scale); 				int dy = (int)(rdy/scale);				Movable hilitedObject = (Movable)view.getHilitedObject();								// initial snap to grid (if needed)				if (notYetDragged && Settings.getInstance().getSnapToGrid())					if (view.isSelected(hilitedObject))						snapToGridSelection();					else						((VisibleObject)hilitedObject).snapToGrid();								// discrete move for snapping				if (Settings.getInstance().getSnapToGrid())				{					dx -= dx % Constants.GRID_SIZE;					dy -= dy % Constants.GRID_SIZE;				}				if (dx == 0 && dy == 0) {					// needed to show the initial snap					if (notYetDragged)						repaint();					break;				}								if (view.isSelected(hilitedObject)) {					if (moveSelection(dx, dy)) {			// move selection						blockNavigatorRedrawOnce = true;	/// !!! performance						repaint();						if (dx!=0) draggedX=px-(int)(rdx-dx*scale);						if (dy!=0) draggedY=py-(int)(rdy-dy*scale);					}				}				else if (hilitedObject.move(dx, dy)) {					alsoDrawHilitedOnce = true;					blockNavigatorRedrawOnce = true;	/// !!! performance					repaint();					if (dx!=0) draggedX=px-(int)(rdx-dx*scale);					if (dy!=0) draggedY=py-(int)(rdy-dy*scale);				}								break;			}							case OBJECT_SELECTION : 			case ZOOM_SELECTION : //System.out.println("Dragged: OBJECT_SELECTION/ZOOM_SELECTION"); 			    draggedX=px; draggedY=py; 			    repaint();			    break;		    			case LINK_OPERATION ://System.out.println("Dragged: LINK_OPERATION"); 			    draggedX=px; draggedY=py;				break;				}		}	// panning	else if ((mouseOperation==OBJECT_MOVE) ||			 (mouseOperation==OBJECT_SELECTION) ||			 (mouseOperation==ZOOM_SELECTION))	{		int dx = 0;		int dy = 0;				if (px<0) 			dx = -view.getGridSize();		else if (px>width) 			dx = view.getGridSize();				if (py<0)			dy = -view.getGridSize();		else if (py>height)			dy = view.getGridSize();				if (view.moveOrigin(dx, dy))		{			if (mouseOperation==OBJECT_MOVE)			{				double scale = view.getScale();				int mdx = (int)(dx/scale); 				int mdy = (int)(dy/scale);								if (!Settings.getInstance().getFastMove()) {					Movable hilitedObject = (Movable)view.getHilitedObject();					if (view.isSelected(hilitedObject))					{						moveSelection(mdx, mdy);					}					else					{						hilitedObject.move(mdx, mdy);						alsoDrawHilitedOnce=true;					}					pressedX+=dx; pressedY+=dy;				} else {					pressedX-=dx; pressedY-=dy;				}							}			else /*if ((mouseOperation==OBJECT_SELECTION) ||					(mouseOperation==ZOOM_SELECTION))*/			{				pressedX-=dx; pressedY-=dy;			}			forceRedraw=true;	//		fastDrawing = false;						recalculateNavigatorPosition();			blockNavigatorRedrawOnce = true;			repaint();		}	}		notYetDragged = false;	}