public void draw(Object obj, Component comp, Graphics2D g2)
    {
        Color color;
        if (obj == null)
            color = null;
        else
            color = (Color) getProperty(obj, "color");
        String imageSuffix = (String) getProperty(obj, "imageSuffix");
        if (imageSuffix == null)
            imageSuffix = "";
        // Compose image with color using an image filter.
        Image tinted = tintedVersions.get(color + imageSuffix);
        if (tinted == null) // not cached, need new filter for color
        {
            Image untinted = tintedVersions.get(imageSuffix);
            if (untinted == null) // not cached, need to fetch
            {
                try
                {
                    URL url = cl.getClassLoader().getResource(
                            imageFilename + imageSuffix + imageExtension);
                    if (url == null)
                        throw new FileNotFoundException(imageFilename
                                + imageSuffix + imageExtension + " not found.");
                    untinted = ImageIO.read(url);
                    tintedVersions.put(imageSuffix, untinted);
                }
                catch (IOException ex)
                {
                    untinted = tintedVersions.get("");
                }
            }
            if (color == null)
                tinted = untinted;
            else
            {
                FilteredImageSource src = new FilteredImageSource(untinted
                    .getSource(), new TintFilter(color));
                tinted = comp.createImage(src);
                // Cache tinted image in map by color, we're likely to need it
                // again.
                tintedVersions.put(color + imageSuffix, tinted);
            }
        }
        int width = tinted.getWidth(null);
        int height = tinted.getHeight(null);
        int size = Math.max(width, height);
        
        // Scale to shrink or enlarge the image to fit the size 1x1 cell.
        g2.scale(1.0 / size, 1.0 / size);
        g2.clip(new Rectangle(-width / 2, -height / 2, width, height));
        g2.drawImage(tinted, -width / 2, -height / 2, null);
    }