@Override protected void paintComponent(Graphics g) {
g.setColor(getBackground());
g.fillRect(0, 0, getWidth(), getHeight());
int w = image.getWidth(this);
int h = image.getHeight(this);
if (mode == Flip.VERTICAL) {
AffineTransform at = AffineTransform.getScaleInstance(1d, -1d);
at.translate(0, -h);
Graphics2D g2 = (Graphics2D) g.create();
g2.drawImage(image, at, this);
g2.dispose();
} else if (mode == Flip.HORIZONTAL) {
AffineTransform at = AffineTransform.getScaleInstance(-1d, 1d);
at.translate(-w, 0);
AffineTransformOp atOp = new AffineTransformOp(at, null);
g.drawImage(atOp.filter(image, null), 0, 0, w, h, this);
} else {
g.drawImage(image, 0, 0, w, h, this);
}
}
};