class RenderedImageIcon implements Icon {

	public void paintIcon(Component c, Graphics g, int x, int y) {
		if (!(g instanceof Graphics2D)) {
			throw new IllegalStateException("paintIcon() only works on Graphics2D.");
		}
		Graphics2D g2d = (Graphics2D) g;
		AffineTransform scale = AffineTransform.getScaleInstance((double) (width) / renderedImage.getWidth(),
				(double) (height) / renderedImage.getHeight());
		AffineTransform translate = AffineTransform.getTranslateInstance(x, y);
		translate.concatenate(scale);
		g2d.drawRenderedImage(renderedImage, translate);
	}

	public  RenderedImageIcon(RenderedImage renderedImage, int width, int height);

}