@Override
	public mxRectangle getBounds(mxCellState state)
	{
		boolean isEdge = state.getView().getGraph().getModel()
				.isEdge(state.getCell());
		double s = state.getView().getScale();
		mxPoint pt = null;

		int w = imageIcon.getIconWidth();
		int h = imageIcon.getIconHeight();

		if (isEdge)
		{
			int n = state.getAbsolutePointCount();

			if (n % 2 == 1)
			{
				pt = state.getAbsolutePoint(n / 2 + 1);
			}
			else
			{
				int idx = n / 2;
				mxPoint p0 = state.getAbsolutePoint(idx - 1);
				mxPoint p1 = state.getAbsolutePoint(idx);
				pt = new mxPoint(p0.getX() + (p1.getX() - p0.getX()) / 2,
						p0.getY() + (p1.getY() - p0.getY()) / 2);
			}
		}
		else
		{
			pt = new mxPoint();

			if (align.equals(mxConstants.ALIGN_LEFT))
			{
				pt.setX(state.getX());
			}
			else if (align.equals(mxConstants.ALIGN_CENTER))
			{
				pt.setX(state.getX() + state.getWidth() / 2);
			}
			else
			{
				pt.setX(state.getX() + state.getWidth());
			}

			if (verticalAlign.equals(mxConstants.ALIGN_TOP))
			{
				pt.setY(state.getY());
			}
			else if (verticalAlign.equals(mxConstants.ALIGN_MIDDLE))
			{
				pt.setY(state.getY() + state.getHeight() / 2);
			}
			else
			{
				pt.setY(state.getY() + state.getHeight());
			}
		}

		return new mxRectangle(pt.getX() - w * defaultOverlap * s, pt.getY()
				- h * defaultOverlap * s, w * s, h * s);
	}