public CPCanvas(CPController ctrl) {
		this.controller = ctrl;
		artwork = ctrl.getArtwork();

		buffer = artwork.getDisplayBM().getData();

		int w = artwork.width;
		int h = artwork.height;

		imgSource = new MemoryImageSource(w, h, buffer, 0, w);
		imgSource.setAnimated(true);
		// imgSource.setFullBufferUpdates(false);
		img = createImage(imgSource);

		centerCanvas();

		ctrl.setCanvas(this);

		int[] pixels = new int[16 * 16];
		Image image = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(16, 16, pixels, 0, 16));
		hideCursor = Toolkit.getDefaultToolkit().createCustomCursor(image, new Point(0, 0), "invisiblecursor");
		defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR);
		moveCursor = new Cursor(Cursor.MOVE_CURSOR);
		crossCursor = new Cursor(Cursor.CROSSHAIR_CURSOR);

		// Creates the checkboard pattern seen in transparent areas
		checkerboardPattern = new BufferedImage(64, 64, BufferedImage.TYPE_INT_RGB);
		pixels = new int[64 * 64];
		for (int j = 0; j < 64; j++) {
			for (int i = 0; i < 64; i++) {
				if ((i & 0x8) != 0 ^ (j & 0x8) != 0) {
					pixels[i + j * 64] = 0xffffffff;
				} else {
					pixels[i + j * 64] = 0xffcccccc;
				}
			}
		}
		checkerboardPattern.setRGB(0, 0, 64, 64, pixels, 0, 64);

		/*
		 * KeyStroke escapeKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, false); Action escapeAction = new
		 * AbstractAction() { public void actionPerformed(ActionEvent e) { controller.setAlpha((int)(.5f*255)); } };
		 * 
		 * getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW). put(escapeKeyStroke, "SPACE"); getActionMap().put("SPACE",
		 * escapeAction);
		 */

		// register as a listener for Mouse & MouseMotion events
		addMouseListener(this);
		addMouseMotionListener(this);
		addMouseWheelListener(this);
		addComponentListener(this);
		addKeyListener(this);

		controller.addToolListener(this);
		controller.addModeListener(this);

		artwork.addListener(this);

		// We'll need to refresh the whole thing at least once
		updateRegion = new CPRect(w, h);

		// So that the tab key will work
		setFocusTraversalKeysEnabled(false);
	}