if (imageRect == null) {
if (currentRect == null) {
		public void mouseDragged(MouseEvent e) {			if (imageRect == null) {				return;			}			if (cacheRect == null) {				movingEdge = 0;			}			int modifiers = e.getModifiersEx();			Point2D p;			switch (movingEdge) {				case SwingConstants.TOP:					p = validate(new Point(cacheRect.x, (int) (e.getPoint().getY())));					modifiers = 0;					break;				case SwingConstants.BOTTOM:					p = validate(new Point(cacheRect.x + cacheRect.width, (int) (e.getPoint().getY())));					modifiers = 0;					break;				case SwingConstants.LEFT:					p = validate(new Point((int) (e.getPoint().getX()), cacheRect.y));					modifiers = 0;					break;				case SwingConstants.RIGHT:					p = validate(new Point((int) (e.getPoint().getX()), cacheRect.y + cacheRect.height));					modifiers = 0;					break;				case 5:					double dx = e.getPoint().getX() - moveCropStart.getX();					double dy = e.getPoint().getY() - moveCropStart.getY();					start = validate(new Point((int) (cacheRect.x + dx), (int) (cacheRect.y + dy)));					p = new Point((int) (cacheRect.x + cacheRect.width + dx), (int) (cacheRect.y + cacheRect.height + dy));					modifiers = 0;					break;				default:					// new rectangle					p = validate(e.getPoint());					break;			}			double px = p.getX();			double py = p.getY();			if ((modifiers & InputEvent.SHIFT_DOWN_MASK) == InputEvent.SHIFT_DOWN_MASK) {				// constrain to a square				double dx = px - start.getX();				double dy = py - start.getY();				if (Math.abs(dx) < Math.abs(dy)) {					py = start.getY() + (dy*dx > 0?dx:-dx);				} else {					px = start.getX() + (dx*dy > 0?dy:-dy);				}				p.setLocation(px, py);			} else if ((modifiers & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK) {				// constrain to same aspect ratio				int dx = (int) (px - start.getX());				int dy = (int) (py - start.getY());				// reverse rectangle				Dimension target;				int sameOrientation = (Math.abs(dx) - Math.abs(dy)) * (imageRect.width - imageRect.height);				if (sameOrientation > 0) {					target = new Dimension(dx, dy);				} else {					target = new Dimension(dy, dx);				}				Dimension d = ImageUtils.getSizeKeepRatio(imageRect.getSize(),						target, false);				if (sameOrientation > 0) {					p.setLocation(start.getX() + d.width, start.getY() + d.height);				} else {					p.setLocation(start.getX() + d.height, start.getY() + d.width);				}			}			centerMode = (modifiers & InputEvent.ALT_DOWN_MASK) == InputEvent.ALT_DOWN_MASK;			end = validate(p);			updateRect();		}