protected void updateOrigin()
	{
		mxRectangle bounds = getGraphBounds();

		if (bounds != null)
		{
			double scale = getView().getScale();
			double x = bounds.getX() / scale - getBorder();
			double y = bounds.getY() / scale - getBorder();

			if (x < 0 || y < 0)
			{
				double x0 = Math.min(0, x);
				double y0 = Math.min(0, y);

				origin.setX(origin.getX() + x0);
				origin.setY(origin.getY() + y0);

				mxPoint t = getView().getTranslate();
				getView().setTranslate(
						new mxPoint(t.getX() - x0, t.getY() - y0));
			}
			else if ((x > 0 || y > 0)
					&& (origin.getX() < 0 || origin.getY() < 0))
			{
				double dx = Math.min(-origin.getX(), x);
				double dy = Math.min(-origin.getY(), y);

				origin.setX(origin.getX() + dx);
				origin.setY(origin.getY() + dy);

				mxPoint t = getView().getTranslate();
				getView().setTranslate(
						new mxPoint(t.getX() - dx, t.getY() - dy));
			}
		}
	}