@Override
	public Dimension render(Graphics2D graphics)
	{
		Font originalFont = null;
		if (font != null)
		{
			originalFont = graphics.getFont();
			graphics.setFont(font);
		}

		final FontMetrics fontMetrics = graphics.getFontMetrics();

		Matcher matcher = COL_TAG_PATTERN.matcher(text);
		Color textColor = color;
		int idx = 0;
		int width = 0;
		while (matcher.find())
		{
			String color = matcher.group(1);
			String s = text.substring(idx, matcher.start());
			idx = matcher.end();

			renderText(graphics, textColor, position.x + width, position.y, s);
			width += fontMetrics.stringWidth(s);

			textColor = Color.decode("#" + color);
		}

		{
			String s = text.substring(idx);
			renderText(graphics, textColor, position.x + width, position.y, s);
			width += fontMetrics.stringWidth(s);
		}

		int height = fontMetrics.getHeight();

		if (originalFont != null)
		{
			graphics.setFont(originalFont);
		}

		return new Dimension(width, height);
	}
@Test
	public void testRender()
	{
		TextComponent textComponent = new TextComponent();
		textComponent.setText("test");
		textComponent.setColor(Color.RED);
		textComponent.render(graphics);
		verify(graphics, times(2)).drawString(eq("test"), anyInt(), anyInt());
		verify(graphics).setColor(Color.RED);
	}