@Override
	public void refreshView(Graphics2D g2d) {

		if (controller.getDisplayImage() && imageModel.getPixels() != null) {
			AffineTransform original = g2d.getTransform();
			g2d.setTransform(viewport.getWorldToView());

			BufferedImage image = new BufferedImage(imageModel.getWidth(),
					imageModel.getHeight(), BufferedImage.TYPE_BYTE_GRAY);

			for (int i = 0; i < image.getHeight(); i++) {
				for (int j = 0; j < image.getWidth(); j++) {
					image.getRaster().setPixel(j, i,
							new int[] { imageModel.getPixels()[i][j] });
				}
			}

			g2d.drawImage(image, 1024 - image.getWidth() / 2,
					1024 - image.getHeight() / 2, image.getWidth(),
					image.getHeight(), null);

			g2d.setTransform(original);
		}

		List<Shape> shapes = model.getShapes();

		for (Shape s : shapes) {

			g2d.setColor(s.getColor());

			if (s instanceof Line) {

				AffineTransform original = g2d.getTransform();

				AffineTransform transform = new AffineTransform();

				transform.concatenate(viewport.getWorldToView());

				g2d.setTransform(transform);

				Line line = (Line) s;
				drawLine(g2d, line);
				g2d.setTransform(original);

				continue;
			}

			AffineTransform original = g2d.getTransform();

			AffineTransform transform = new AffineTransform();

			transform.concatenate(viewport.getWorldToView());

			transform.concatenate(new AffineTransform(new double[] { 1, 0, 0,
					1, s.getX(), s.getY() }));

			transform.concatenate(new AffineTransform(new double[] {
					Math.cos(s.getRotation()), Math.sin(s.getRotation()),
					-Math.sin(s.getRotation()), Math.cos(s.getRotation()) }));

			g2d.setTransform(transform);

			if (s instanceof Square) {

				Square square = (Square) s;
				drawSquare(g2d, square);
			}

			else if (s instanceof Rectangle) {

				Rectangle rectangle = (Rectangle) s;
				drawRectangle(g2d, rectangle);
			}

			else if (s instanceof Circle) {

				Circle circle = (Circle) s;
				drawCircle(g2d, circle);
			}

			else if (s instanceof Ellipse) {

				Ellipse ellipse = (Ellipse) s;
				drawEllipse(g2d, ellipse);
			}

			else if (s instanceof Triangle) {

				Triangle triangle = (Triangle) s;
				drawTriangle(g2d, triangle);
			}

			g2d.setTransform(original);
		}

		drawSelectedOutline(g2d);

		if (controller.getDisplay3D()) {
			g2d.setStroke(new BasicStroke((float) (1 / viewport.getScale())));
			g2d.setTransform(viewport.getWorldToView());
			render3D.draw(g2d);
		}
	}