@Override
	public void paintComponent(Graphics g)
	{					
		int width = getWidth();
		int height = getHeight();
		
		if (mScale == 0.0f)
		{			
			int xExtent = Math.max(Math.abs(mCellSheet.getCurrentMaxX()), Math.abs(mCellSheet.getCurrentMinX()));
			int yExtent = Math.max(Math.abs(mCellSheet.getCurrentMaxY()), Math.abs(mCellSheet.getCurrentMinY()));
			mScale = Math.min(width / (xExtent * 2), height / (yExtent * 2));				
		}							
		
//		minX = Math.min(minX, mCellSheet.getCurrentMinX());
//		maxX = Math.min(maxY, mCellSheet.getCurrentMaxX());
//		minY = Math.min(minY, mCellSheet.getCurrentMinY());
//		maxY = Math.min(maxY, mCellSheet.getCurrentMaxY());							
				
		List<Pair> drawList = mCellSheet.getDrawList();
		if (drawList == null)
		{
			synchronized(this)
			{
				g.setColor(mColors.get(0));
				g.fillRect(0, 0, width, height);
			
				int minX = (int)Math.floor((-width/2 + mXOffset) / mScale);
				int maxX = (int)Math.ceil((width/2 + mXOffset) / mScale);
				int minY = (int)Math.floor((-height/2 + mYOffset) / mScale);
				int maxY = (int)Math.ceil((height/2 + mYOffset) / mScale);
				
				for (int y = minY; y < maxY; y++)
				{			
					for (int x = minX; x < maxX; x++)
					{								
						drawPoint(g, x, y, width, height);
					}
				}
			}
		}
		else
		{
			for (Pair pair : drawList)
			{
				drawPoint(g, pair.mX, pair.mY, width, height);
			}
		}				
	}