Moved main method to own class
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@24 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
3e6817388f
commit
4df8a8017a
2 changed files with 62 additions and 52 deletions
61
src/jrummikub/JRummikub.java
Normal file
61
src/jrummikub/JRummikub.java
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
package jrummikub;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
|
import jrummikub.model.Position;
|
||||||
|
import jrummikub.model.Stone;
|
||||||
|
import jrummikub.model.StoneColor;
|
||||||
|
import jrummikub.util.IListener;
|
||||||
|
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");
|
||||||
|
}});
|
||||||
|
|
||||||
|
Map<Stone, Position> stones = new HashMap<Stone, Position>();
|
||||||
|
stones.put(new Stone(1, StoneColor.ORANGE, false), new Position(0, 0));
|
||||||
|
stones.put(new Stone(1, StoneColor.BLUE, false), new Position(1, 0));
|
||||||
|
stones.put(new Stone(1, StoneColor.RED, false), new Position(0.5f, 1));
|
||||||
|
|
||||||
|
view.getPlayerPanel().getBoard().setStones(stones);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,16 +3,9 @@ package jrummikub.view.impl;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.UIManager;
|
|
||||||
|
|
||||||
import jrummikub.model.Position;
|
|
||||||
import jrummikub.model.Stone;
|
|
||||||
import jrummikub.model.StoneColor;
|
|
||||||
import jrummikub.util.IListener;
|
|
||||||
import jrummikub.view.IPlayerPanel;
|
import jrummikub.view.IPlayerPanel;
|
||||||
import jrummikub.view.ITable;
|
import jrummikub.view.ITable;
|
||||||
import jrummikub.view.IView;
|
import jrummikub.view.IView;
|
||||||
|
@ -49,51 +42,7 @@ public class View extends JFrame implements IView {
|
||||||
playerPanel.setBorder(new CustomBorder(Color.BLACK, 1, 0, 0, 0));
|
playerPanel.setBorder(new CustomBorder(Color.BLACK, 1, 0, 0, 0));
|
||||||
playerPanel.setPreferredSize(new Dimension(0, PLAYER_PANEL_HEIGHT+1));
|
playerPanel.setPreferredSize(new Dimension(0, PLAYER_PANEL_HEIGHT+1));
|
||||||
add(playerPanel, BorderLayout.SOUTH);
|
add(playerPanel, BorderLayout.SOUTH);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param args
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// FIXME Only test main for GUI preview
|
|
||||||
String nativeLF = UIManager.getSystemLookAndFeelClassName();
|
|
||||||
|
|
||||||
try {
|
|
||||||
UIManager.setLookAndFeel(nativeLF);
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
View view = new View();
|
setVisible(true);
|
||||||
|
|
||||||
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");
|
|
||||||
}});
|
|
||||||
|
|
||||||
Map<Stone, Position> stones = new HashMap<Stone, Position>();
|
|
||||||
stones.put(new Stone(1, StoneColor.ORANGE, false), new Position(0, 0));
|
|
||||||
stones.put(new Stone(1, StoneColor.BLUE, false), new Position(1, 0));
|
|
||||||
stones.put(new Stone(1, StoneColor.RED, false), new Position(0.5f, 1));
|
|
||||||
|
|
||||||
view.getPlayerPanel().getBoard().setStones(stones);
|
|
||||||
|
|
||||||
view.setVisible(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue