public void update(Graphics g) {

		Graphics2D g2 = (Graphics2D) g;
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

		Dimension dim = getSize();
		int width = dim.width;
		int height = dim.height;
		g2.setColor(getBackground());
		g2.fillRect(0, 0, width, height);
		g2.setFont(font);

		bound.setRect(width / 10, height / 10, width / 3, width / 3);
		int r = bound.x + bound.width + 20;
		int s = bound.y + 10;

		int legendX1 = width / 8;
		int legendX2 = width / 4;

		float t = 0.0f;
		int n = percent.length;
		for (int i = 0; i < n; i++) {
			g2.setColor(colors[i]);
			arcs[i].setArc(bound, t, percent[i] * 360.0f, Arc2D.PIE);
			if (isEnabled()) {
				if (i < n - 1) {
					endPoint = arcs[i].getEndPoint();
					hotspots[i].x = (float) (endPoint.getX() - hotspots[i].width * 0.5);
					hotspots[i].y = (float) (endPoint.getY() - hotspots[i].height * 0.5);
				}
			}
			g2.fill(arcs[i]);
			g2.fillRect(r, s + i * 20, 20, 10);
			g2.setColor(Color.black);
			g2.draw(arcs[i]);
			g2.drawRect(r, s + i * 20, 20, 10);
			g2.drawString(legends[i], r + legendX1, s + 10 + i * 20);
			if (total == 0) {
				g2.drawString(format.format(percent[i] * 100.0) + "%", r + legendX2, s + 10 + i * 20);
			}
			else {
				g2.drawString(format.format(percent[i] * 100.0) + "% (" + format.format(percent[i] * total) + ")", r
						+ legendX2, s + 10 + i * 20);
			}
			t += percent[i] * 360.0f;
		}

		if (isEnabled()) {
			for (int i = 0; i < hotspots.length; i++) {
				g2.setColor(Color.white);
				g2.fill(hotspots[i]);
				g2.setColor(Color.black);
				g2.draw(hotspots[i]);
			}
		}

		if (text != null) {
			g2.setColor(Color.black);
			for (int i = 0; i < legends.length; i++) {
				if (text[i] != null)
					g2.drawString(text[i], bound.x, bound.y + bound.height + 30 + 20 * i);
			}
		}

	}