synchronized public void paintComponent(Graphics g) {
		g.setColor(Color.white);
		g.fillRect(0, 0, width * tileWidth, height * tileHeight);
		if(hasBackground) {
			g.drawImage(img.getImage(), 0, map.offsetTop, img.getIconWidth(), img.getIconHeight(), null);
		}

		// as the tiles are drawn with the origin at the
		// bottom right, but the component's origin is the top left,
		// we need to set the offset so we can see the tiles
		if (hideLayers) {
			map.render(g, viewport.getViewPosition(), viewport.getSize(),
					activeLayer);
		} else {
			map.render(g, viewport.getViewPosition(), viewport.getSize());
		}

		// map.render(g, -tileWidth, -tileHeight);
		if (showGrid) {
			g.setColor(Color.gray);
			for (int i = 0; i < width; i++) {
				g.drawLine(i * tileWidth, 0, i * tileWidth, height * tileHeight);
			}

			for (int j = 0; j < height; j++) {
				g.drawLine(0, j * tileHeight, width * tileWidth, j * tileHeight);
			}
		}
		((Graphics2D) g).setStroke(new BasicStroke(2));
		g.setColor(Color.black);
		g.drawLine(0, 0, width * tileWidth, 0);
		g.drawLine(0, 0, 0, height * tileHeight);
		g.drawLine(width * tileWidth, 0, width * tileWidth, height * tileHeight);
		g.drawLine(0, height * tileHeight, width * tileWidth, height
				* tileHeight);

	}