1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
public JLabel handToHiddenHand(IHand h, double sens) {
int width = Card.HIDDEN_WIDTH * (h.getSize() - 1) + Card.WIDTH;
BufferedImage buffer = new BufferedImage(width,
Card.HEIGHT,
BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D graph = buffer.createGraphics();
int x = 0;
for (int i = 0; i < h.getSize(); i++) {
try {
Card c = (Card) h.at(i);
graph.drawImage(c.verso(), x, 0, this);
x += Card.HIDDEN_WIDTH;
} catch (IOException e) {
JOptionPane w = new JOptionPane();
w.showMessageDialog(this,
"Fatal error during loading file.",
"Error",
JOptionPane.ERROR_MESSAGE);
}
}
AffineTransform transform = AffineTransform.getRotateInstance(sens);
graph.transform(transform);
graph.dispose();
return new JLabel(new ImageIcon(buffer));
} |