@Override
	public void paint(Graphics g) {
		Graphics2D g2d = (Graphics2D) g;
		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
		                     RenderingHints.VALUE_ANTIALIAS_ON);
		g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, 
		                     RenderingHints.VALUE_FRACTIONALMETRICS_ON);
		g2d.setRenderingHint(RenderingHints.KEY_RENDERING, 
		                     RenderingHints.VALUE_RENDER_QUALITY);
		g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, 
		                     RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

		Rectangle bounds = getBounds();
		int margin = 10;
		double startx = bounds.getX()+margin;
		double endx = bounds.getX()+bounds.getWidth()-margin*2;
		double maxlength = endx-startx;

		double scale = maxlength/length;
		double ymid = bounds.getY()+bounds.getHeight()/2;

		long start = 0;
		// Draw each domain
		g2d.setStroke(new BasicStroke(0.5f));
		g2d.setFont(labelFont);
		for (int domain = 0; domain < sizes.size(); domain++) {
			long size = sizes.get(domain);
			Color color = colorList.get(domain);
			if (!color.equals(Color.lightGray)) {
				double x = scaleX(startx, scale, start);
				double width = size*scale;
				RoundRectangle2D d = new RoundRectangle2D.Double(x, ymid-20, width, 40, 20, 20);
				g2d.setPaint(color);
				g2d.fill(d);
				g2d.setColor(Color.BLACK);
				g2d.draw(d);
			}
			start = start+size;
		}

		// Draw the labels.  We do this in a separate path
		// to avoid one domain overwriting the label of another
		start = 0;
		for (int domain = 0; domain < sizes.size(); domain++) {
			long size = sizes.get(domain);
			Color color = colorList.get(domain);
			if (!color.equals(Color.lightGray)) {
				/* Convert the color to a contrasting color
				float[] hsbColor = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
				hsbColor[0] = hsbColor[0]+0.5f;
				if (hsbColor[0]>1.0f) hsbColor[0] = hsbColor[0] - 1.0f;
				color = Color.getHSBColor(hsbColor[0], hsbColor[1], hsbColor[2]);
				g2d.setColor(color);
				*/
				String label = labelList.get(domain);
				double x = scaleX(startx, scale, start);
				double width = size*scale;
				int stringWidth = g2d.getFontMetrics().stringWidth(label);
				double offset = (width-stringWidth)/2;
				if ((int)(x+offset) < 0)
					g2d.drawString(label, 1, (int)(ymid-6));
				else
					g2d.drawString(label, (int)(x+offset), (int)(ymid-6));
			}
			start = start+size;
		}

		// Draw the axis
		g2d.setFont(axisFont);
		g2d.setStroke(new BasicStroke(1));
		g2d.setColor(Color.BLACK);
		g2d.drawLine((int)startx, 
								 (int)ymid,
								 (int)endx,
								 (int)ymid);


		// Draw a tick every 50 bp
		g2d.setColor(Color.DARK_GRAY);
		for (int i = 50; i < length; i=i+50) {
			drawTick(g2d, i, startx, ymid, scale);
		}

		g2d.setColor(Color.BLACK);
		drawTick(g2d, 0, startx, ymid, scale);
		drawTick(g2d, (int)length, startx, ymid, scale);
	}