@Override
	public void paint(Graphics g)
	{
		// Preconditions.
		assertNotNull("Graphics object not given.", g);
		
		// We'll try to paint a lot. If there's contention, simply give up.
		if (visualizerLock.tryLock())
		{
			
			// Ensure the graphics object knows that we don't need anything pretty, if possible.
			if (g instanceof Graphics2D)
			{
				Graphics2D g2d = ((Graphics2D)g);
				g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
				g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);
			}
			
			// Start recording time for FPS
			long startTime = System.currentTimeMillis();
			
			// Draw the backdrop.
			g.setColor(getBackground());
			g.fillRect(0, 0, getWidth(), getHeight());
			
			// If we need to clear the view only, reset the flag and do nothing.
			if (clearView)
			{
				clearView = false;
			}
			else
			{
				// Otherwise, draw the simulation - if one exists.
				final IReadableWorld NO_SIMULATION = null;
				if (simulation != NO_SIMULATION)
				{
					BufferedImage toDraw = simulationVisualizer.visualize(
							simulation, 
							coordinateVisualizer,
							new Rectangle(0,0,getWidth(), getHeight()));
					
					final ImageObserver NO_OBSERVER_NECESSARY = null;
					g.drawImage((Image)toDraw, 0, 0, NO_OBSERVER_NECESSARY);
					
				}
			}
		
			// Determine & show the FPS if there is one.
			// (assuming we can draw it - in test mode, the component isn't drawn, hence we can't get a font.
			// It's just the way that this works).
			// TODO: Clean this up.
			long endTime = System.currentTimeMillis();
			long timeElapsed = endTime - startTime;
			double fps;
			g.setColor(Color.red);
			final Font GUI_NOT_LOADED_YET = null;
			if (g.getFont() == GUI_NOT_LOADED_YET)
			{
				return;
			}
			if (timeElapsed != 0 && simulation != null)
			{
				fps = Math.floor(1000.0 / (double)simulation.getLastUpdateTime());
				g.drawString("FPS:\t\t\t" + fps, 50, 50);
				g.drawString("Paint Time:\t" + timeElapsed + "ms", 50, 60);
			}
			else
			{
				g.drawString("FPS:\t\t\t" + Double.POSITIVE_INFINITY, 50, 50);
			}
			
			visualizerLock.unlock();
		}
		
	}