}
}
public void paint(Graphics2D graphics) {
ImageView imageView = (ImageView)getComponent();
Image image = imageView.getImage();
int width = getWidth();
int height = getHeight();
if (backgroundColor != null) {
graphics.setPaint(backgroundColor);
graphics.fillRect(0, 0, width, height);
}
if (image != null) {
Graphics2D imageGraphics = (Graphics2D)graphics.create();
imageGraphics.translate(imageX, imageY);
imageGraphics.scale(scaleX, scaleY);
// Apply an alpha composite if the opacity value is less than
// the current alpha
float alpha = 1.0f;
Composite composite = imageGraphics.getComposite();
if (composite instanceof AlphaComposite) {
AlphaComposite alphaComposite = (AlphaComposite)composite;
alpha = alphaComposite.getAlpha();
}
if (opacity < alpha) {
imageGraphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity));
}
image.paint(imageGraphics);
imageGraphics.dispose();
}
}