private Rectangle getRectangle(int x, int y, int w, int h, int location) {

		switch (location) {
			case SwingConstants.NORTH:
				return new Rectangle(x + w / 2 - dist / 2, y, dist, dist);
			case SwingConstants.SOUTH:
				return new Rectangle(x + w / 2 - dist / 2, y + h - dist, dist, dist);
			case SwingConstants.WEST:
				return new Rectangle(x, y + h / 2 - dist / 2, dist, dist);
			case SwingConstants.EAST:
				return new Rectangle(x + w - dist, y + h / 2 - dist / 2, dist, dist);
			case SwingConstants.NORTH_WEST:
				return new Rectangle(x, y, dist, dist);
			case SwingConstants.NORTH_EAST:
				return new Rectangle(x + w - dist, y, dist, dist);
			case SwingConstants.SOUTH_WEST:
				return new Rectangle(x, y + h - dist, dist, dist);
			case SwingConstants.SOUTH_EAST:
				return new Rectangle(x + w - dist, y + h - dist, dist, dist);
		}

		return null;
	}