@@ -0,0 +1,1533 @@
+/**%0D%0A *%0D%0A */%0D%0Apackage com.github.apixandru.games.rummikub.ui;%0D%0A%0D%0Aimport java.awt.Color;%0D%0Aimport java.awt.Dimension;%0D%0Aimport java.awt.Font;%0D%0A%0D%0Aimport javax.swing.JButton;%0D%0Aimport javax.swing.JComponent;%0D%0A%0D%0A/**%0D%0A * @author apixandru%0D%0A * @since Aug 11, 2015%0D%0A */%0D%0Apublic final class UiUtil %7B%0D%0A%0D%0A%09public static final Font CARD_FONT = new Font(null, Font.BOLD, 32);%0D%0A%0D%0A%0D%0A%09/**%0D%0A%09 * @param c%0D%0A%09 * @param d%0D%0A%09 * @return%0D%0A%09 */%0D%0A%09public static Dimension max(final Dimension c, final Dimension d) %7B%0D%0A%09%09if (c.getWidth() %3E d.getWidth() && c.getHeight() %3E d.getHeight()) %7B%0D%0A%09%09%09return c;%0D%0A%09%09%7D%0D%0A%09%09return d;%0D%0A%09%7D%0D%0A%0D%0A%09/**%0D%0A%09 * @param color%0D%0A%09 * @return%0D%0A%09 */%0D%0A%09public static Color getColor(final com.github.apixandru.games.rummikub.model.Color color) %7B%0D%0A%09%09if (null == color) %7B%0D%0A%09%09%09return Color.BLACK;%0D%0A%09%09%7D%0D%0A%09%09switch (color) %7B%0D%0A%09%09%09case BLACK:%0D%0A%09%09%09%09return Color.BLACK;%0D%0A%09%09%09case BLUE:%0D%0A%09%09%09%09return Color.BLUE;%0D%0A%09%09%09case RED:%0D%0A%09%09%09%09return Color.RED;%0D%0A%09%09%09case YELLOW:%0D%0A%09%09%09%09return Color.ORANGE;%0D%0A%09%09%09default:%0D%0A%09%09%09%09throw new IllegalArgumentException(String.valueOf(color));%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A%09/**%0D%0A%09 * @param rows%0D%0A%09 * @param cols%0D%0A%09 * @param preferredSize%0D%0A%09 * @return%0D%0A%09 */%0D%0A%09public static final JComponent%5B%5D%5B%5D createGridOfSquares(final int rows, final int cols, final Dimension preferredSize) %7B%0D%0A%09%09final JComponent%5B%5D%5B%5D grid = new JComponent%5Brows%5D%5Bcols%5D;%0D%0A%09%09for (int x = 0; x %3C cols; x++) %7B%0D%0A%09%09%09for (int y = 0; y %3C rows; y++) %7B%0D%0A%09%09%09%09final JComponent b = new JButton();%0D%0A%09%09%09%09b.setPreferredSize(preferredSize);%0D%0A%09%09%09%09grid%5By%5D%5Bx%5D = b;%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%09%09return grid;%0D%0A%09%7D%0D%0A%0D%0A%7D%0D%0A

add ui utilities