package jrummikub; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.swing.UIManager; import jrummikub.model.Position; import jrummikub.model.Stone; import jrummikub.model.StoneColor; import jrummikub.model.StoneSet; import jrummikub.util.IListener; import jrummikub.util.IListener1; import jrummikub.view.IView; public class JRummikub { /** * @param args */ public static void main(String[] args) { String nativeLF = UIManager.getSystemLookAndFeelClassName(); try { UIManager.setLookAndFeel(nativeLF); } catch (Exception e) { } IView view = new jrummikub.view.impl.View(); view.getPlayerPanel().setCurrentPlayerName("Player 1"); view.getPlayerPanel().setTimeLeft(42); view.getTable().setLeftPlayerName("Player 2"); view.getTable().setTopPlayerName("Player 3"); view.getTable().setRightPlayerName("Player 4"); view.getPlayerPanel().getSortByNumberEvent().add(new IListener() { @Override public void fire() { System.out.println("'Sort by number' fired"); }}); view.getPlayerPanel().getSortByColorEvent().add(new IListener() { @Override public void fire() { System.out.println("'Sort by color' fired"); }}); view.getPlayerPanel().getEndTurnEvent().add(new IListener() { @Override public void fire() { System.out.println("'End turn' fired"); }}); //stones on the board Map stones = new HashMap(); stones.put(new Stone(1, StoneColor.ORANGE, false), new Position(0, 0)); stones.put(new Stone(10, StoneColor.BLUE, false), new Position(1, 0)); stones.put(new Stone(9, StoneColor.RED, false), new Position(0.5f, 1)); stones.put(new Stone(7, StoneColor.BLACK, false), new Position(1.75f, 1)); Stone stoneJoker = new Stone(0, StoneColor.RED, true); stones.put(stoneJoker, new Position(2.5f, 0)); stones.put(new Stone(0, StoneColor.BLACK, true), new Position(3.5f, 0)); view.getPlayerPanel().getBoard().setStones(stones); view.getPlayerPanel().getBoard().getClickEvent().add(new IListener1(){ @Override public void fire(Position value) { System.out.println("Board clicked at "+value); }}); view.getTable().getClickEvent().add(new IListener1(){ @Override public void fire(Position value) { System.out.println("Table clicked at "+value); }}); //stoneSets on the table Map stoneSets = new HashMap(); stoneSets.put(new StoneSet(new Stone(5, StoneColor.ORANGE, false)), new Position(0.5f, 1)); List stoneList = new ArrayList(); stoneList.add(new Stone(7, StoneColor.BLACK, false)); Stone stone8 = new Stone(8, StoneColor.BLACK, false); stoneList.add(stone8); stoneList.add(new Stone(9, StoneColor.BLACK, false)); stoneList.add(new Stone(10, StoneColor.BLACK, false)); stoneSets.put(new StoneSet(stoneList), new Position(3.5f, 4)); view.getTable().setStoneSets(stoneSets); view.setSelectedStones(Arrays.asList(stoneJoker, stone8)); } }