@@ -0,0 +1,1576 @@
+/**%0A *%0A */%0Apackage com.github.apixandru.games.rummikub.ui;%0A%0Aimport java.awt.Color;%0Aimport java.awt.Dimension;%0Aimport java.awt.Graphics;%0A%0Aimport javax.swing.JLabel;%0Aimport javax.swing.JPanel;%0Aimport javax.swing.border.LineBorder;%0A%0Aimport com.github.apixandru.games.rummikub.model.Card;%0Aimport com.github.apixandru.games.rummikub.model.Cards;%0A%0A/**%0A * @author Alexandru-Constantin Bledea%0A * @since Oct 10, 2015%0A */%0Apublic final class CardUi extends JPanel %7B%0A%0A%09private static final Dimension dimension = new Dimension(60, 96);%0A%0A%09private final Color color;%0A%09private final Card card;%0A%09private static final int RADIUS = 20;%0A%0A%09/**%0A%09 * @param card%0A%09 */%0A%09public CardUi(final Card card) %7B%0A%09%09this.card = card;%0A%09%09setMinimumSize(dimension);%0A%09%09setMaximumSize(dimension);%0A%09%09setPreferredSize(dimension);%0A%09%09setBorder(new LineBorder(Color.BLACK));%0A%09%09final boolean joker = Cards.isJoker(card);%0A%09%09final JLabel label = new JLabel();%0A%09%09label.setFont(UiUtil.CARD_FONT);%0A%09%09this.color = UiUtil.getColor(card.getColor());%0A%09%09label.setForeground(color);%0A%09%09setBackground(Color.WHITE);%0A//%09%09label.setOpaque(true);%0A%09%09if (joker) %7B%0A%09%09%09label.setText(%22J%22);%0A%09%09%7D else %7B%0A%09%09%09final int number = card.getRank().ordinal() + 1;%0A%09%09%09label.setText(String.valueOf(number));%0A%09%09%7D%0A%09%09add(label);%0A%09%7D%0A%0A%09/* (non-Javadoc)%0A%09 * @see javax.swing.JComponent#paint(java.awt.Graphics)%0A%09 */%0A%09@Override%0A%09public void paint(final Graphics g) %7B%0A%09%09super.paint(g);%0A%09%09final Color color = g.getColor();%0A%09%09g.setColor(this.color);%0A%09%09g.fillOval((getWidth() - RADIUS) / 2, (int) (getHeight() - RADIUS * 1.7), RADIUS, RADIUS);%0A%09%09g.setColor(color);%0A%09%7D%0A%7D%0A

add card ui