@Override
	public void mouseClicked(MouseEvent e) {

		if (e.getButton() != MouseEvent.BUTTON1)
			return;

		Point2D worldPoint = Transformation.viewToWorld(viewport, e.getX(),
				e.getY());

		if (mode == Mode.TRIANGLE) {
			if (clicks == 0) {
				x1 = worldPoint.getX();
				y1 = worldPoint.getY();
				clicks = 1;
			} else if (clicks == 1) {
				x2 = worldPoint.getX();
				y2 = worldPoint.getY();
				clicks = 2;
			} else if (clicks == 2) {
				double centerX = (x1 + x2 + worldPoint.getX()) / 3;
				double centerY = (y1 + y2 + worldPoint.getY()) / 3;
				shape = new Triangle(color, centerX, centerY, x1 - centerX, y1
						- centerY, x2 - centerX, y2 - centerY,
						worldPoint.getX() - centerX, worldPoint.getY()
								- centerY);
				model.addShape(shape);
				shape = null;
				clicks = 0;
				GUIFunctions.refresh();
			}
		}
	}