boolean hasFocus,
TableRow row,
String key)
throws GUIException {
Label label = new Label(null, null);
ImageIcon icon = (ImageIcon) value;
Image inImage = icon.getImage();
/* Resize the image */
double scale = (double) maxImageSize / (double) inImage.getHeight(null);
if (inImage.getWidth(null) > inImage.getHeight(null)) {
scale = (double) maxImageSize / (double) inImage.getWidth(null);
}
int scaledW = (int) (scale * inImage.getWidth(null));
int scaledH = (int) (scale * inImage.getHeight(null));
BufferedImage outImage = new BufferedImage(scaledW, scaledH, BufferedImage.TYPE_INT_RGB);
AffineTransform tx = new AffineTransform();
if (scale < 1.0d) {
tx.scale(scale, scale);
}
Color bgColor = null;
Graphics2D g2d = outImage.createGraphics();
g2d.setColor(bgColor);
g2d.fillRect(0, 0, scaledW, scaledH);
g2d.drawImage(inImage, tx, null);
g2d.dispose();
label.setIcon(new ImageIcon(outImage));
label.setProperty("horizontalAlignment", new Integer(JLabel.CENTER));
label.setProperty("opaque", Boolean.TRUE);
return label;
}