@Override
	public void mouseDragged(MouseEvent e)
	{
		if (!e.isConsumed() && first != null)
		{
			gridEnabledEvent = graphComponent.isGridEnabledEvent(e);
			constrainedEvent = graphComponent.isConstrainedEvent(e);

			double dx = e.getX() - first.x;
			double dy = e.getY() - first.y;

			if (isLabel(index))
			{
				mxPoint pt = new mxPoint(e.getPoint());

				if (gridEnabledEvent)
				{
					pt = graphComponent.snapScaledPoint(pt);
				}

				int idx = (int) Math.round(pt.getX() - first.x);
				int idy = (int) Math.round(pt.getY() - first.y);

				if (constrainedEvent)
				{
					if (Math.abs(idx) > Math.abs(idy))
					{
						idy = 0;
					}
					else
					{
						idx = 0;
					}
				}

				Rectangle rect = state.getLabelBounds().getRectangle();
				rect.translate(idx, idy);
				preview.setBounds(rect);
			}
			else
			{
				mxGraph graph = graphComponent.getGraph();
				double scale = graph.getView().getScale();

				if (gridEnabledEvent)
				{
					dx = graph.snap(dx / scale) * scale;
					dy = graph.snap(dy / scale) * scale;
				}

				mxRectangle bounds = union(getState(), dx, dy, index);
				bounds.setWidth(bounds.getWidth() + 1);
				bounds.setHeight(bounds.getHeight() + 1);
				preview.setBounds(bounds.getRectangle());
			}

			if (!preview.isVisible() && graphComponent.isSignificant(dx, dy))
			{
				preview.setVisible(true);
			}

			e.consume();
		}
	}