From 12a0686cb3fa183aa8e4829ad4cab25798bc7cf5 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Mon, 3 Mar 2014 19:27:27 +0100 Subject: Add web interface and clean project dir --- .classpath | 5 +- .gitignore | 15 +- .project | 17 ++ src/esieequest/Main.java | 22 +- src/esieequest/controller/GameEngine.java | 17 +- src/esieequest/controller/Interpreter.java | 6 +- src/esieequest/controller/Parser.java | 19 +- src/esieequest/controller/Performer.java | 25 +- src/esieequest/controller/package-info.java | 8 - src/esieequest/esieequest.gwt.xml | 35 +++ src/esieequest/model/Game.java | 9 +- src/esieequest/model/command/package-info.java | 8 - src/esieequest/model/package-info.java | 8 - src/esieequest/package-info.java | 11 - src/esieequest/view/Applet.java | 27 -- src/esieequest/view/Console.java | 61 ---- src/esieequest/view/UserInterface.java | 247 ----------------- src/esieequest/view/View.java | 16 +- src/esieequest/view/Window.java | 35 --- src/esieequest/view/app/Applet.java | 27 ++ src/esieequest/view/app/UserInterface.java | 263 ++++++++++++++++++ src/esieequest/view/app/Window.java | 35 +++ src/esieequest/view/console/Console.java | 59 ++++ src/esieequest/view/package-info.java | 8 - src/esieequest/view/web/Main.java | 18 ++ src/esieequest/view/web/WebInterface.java | 123 ++++++++ src/esieequest/view/web/WebInterface.ui.xml | 97 +++++++ .../nikiroo/utils/gui/JBackgroundPanel.java | 308 --------------------- war/WEB-INF/web.xml | 13 + war/esieequest.css | 53 ++++ war/esieequest.html | 37 +++ 31 files changed, 843 insertions(+), 789 deletions(-) delete mode 100644 src/esieequest/controller/package-info.java create mode 100644 src/esieequest/esieequest.gwt.xml delete mode 100644 src/esieequest/model/command/package-info.java delete mode 100644 src/esieequest/model/package-info.java delete mode 100644 src/esieequest/package-info.java delete mode 100644 src/esieequest/view/Applet.java delete mode 100644 src/esieequest/view/Console.java delete mode 100644 src/esieequest/view/UserInterface.java delete mode 100644 src/esieequest/view/Window.java create mode 100644 src/esieequest/view/app/Applet.java create mode 100644 src/esieequest/view/app/UserInterface.java create mode 100644 src/esieequest/view/app/Window.java create mode 100644 src/esieequest/view/console/Console.java delete mode 100644 src/esieequest/view/package-info.java create mode 100644 src/esieequest/view/web/Main.java create mode 100644 src/esieequest/view/web/WebInterface.java create mode 100644 src/esieequest/view/web/WebInterface.ui.xml delete mode 100644 src/net/homelinux/nikiroo/utils/gui/JBackgroundPanel.java create mode 100644 war/WEB-INF/web.xml create mode 100644 war/esieequest.css create mode 100644 war/esieequest.html diff --git a/.classpath b/.classpath index 32d0130..8836eed 100644 --- a/.classpath +++ b/.classpath @@ -2,6 +2,7 @@ - - + + + diff --git a/.gitignore b/.gitignore index a819b04..315195b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ target/ *.class # Package Files # -*.jar +#*.jar *.war *.ear *.db @@ -83,4 +83,15 @@ local.properties ###################### report/out/** -report/tmp/** \ No newline at end of file +report/tmp/** + +###################### +# GWT +###################### + +.gwt +gwt-unitCache +war/esieequest +war/WEB-INF/classes +war/WEB-INF/deploy +war/WEB-INF/lib diff --git a/.project b/.project index fb4b1d7..6b191a9 100644 --- a/.project +++ b/.project @@ -10,14 +10,31 @@ + + org.eclipse.wst.common.project.facet.core.builder + + + org.eclipse.jdt.core.javabuilder + + com.google.gdt.eclipse.core.webAppProjectValidator + + + + + com.google.gwt.eclipse.core.gwtProjectValidator + + + net.sourceforge.texlipse.builder.TexlipseNature org.eclipse.jdt.core.javanature + com.google.gwt.eclipse.core.gwtNature + org.eclipse.wst.common.project.facet.core.nature diff --git a/src/esieequest/Main.java b/src/esieequest/Main.java index add0fb1..5a08f1d 100755 --- a/src/esieequest/Main.java +++ b/src/esieequest/Main.java @@ -1,13 +1,15 @@ package esieequest; +import java.util.Arrays; + import javax.swing.JApplet; import esieequest.controller.GameEngine; import esieequest.model.Game; -import esieequest.view.Applet; -import esieequest.view.Console; import esieequest.view.View; -import esieequest.view.Window; +import esieequest.view.app.Applet; +import esieequest.view.app.Window; +import esieequest.view.console.Console; /** * This class instantiates the game and makes it possible to run it via the @@ -28,9 +30,8 @@ public class Main extends JApplet { public void init() { // applet Game vGame = new Game(); - Applet vApplet = new Applet(vGame, this); - vGame.addObserver(vApplet); - GameEngine vGameEngine = new GameEngine(vGame, vApplet); + Applet vApplet = new Applet(this); + new GameEngine(vGame, vApplet); } public static void main(final String[] pArgs) { @@ -38,15 +39,14 @@ public class Main extends JApplet { Game vGame = new Game(); View vView; - if (pArgs.length != 0) { - vView = new Console(vGame); + if (Arrays.asList(pArgs).contains("--nogui")) { + vView = new Console(); } else { - vView = new Window(vGame); + vView = new Window(); } - vGame.addObserver(vView); - GameEngine vGameEngine = new GameEngine(vGame, vView); + new GameEngine(vGame, vView); } } diff --git a/src/esieequest/controller/GameEngine.java b/src/esieequest/controller/GameEngine.java index 72de63a..3999cd0 100644 --- a/src/esieequest/controller/GameEngine.java +++ b/src/esieequest/controller/GameEngine.java @@ -1,8 +1,5 @@ package esieequest.controller; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - import esieequest.model.Game; import esieequest.view.View; @@ -15,7 +12,7 @@ import esieequest.view.View; * * @version February 2014 */ -public class GameEngine implements ActionListener { +public class GameEngine { private Game aGame; private View aView; @@ -26,9 +23,10 @@ public class GameEngine implements ActionListener { this.aGame = pGame; this.aView = pView; - this.aInterpreter = new Interpreter(this.aGame, this.aView); + this.aView.setModel(pGame); + this.aView.setController(this); - this.aView.setActionListener(this); + this.aInterpreter = new Interpreter(this.aGame, this.aView); this.startGame(); this.startView(); @@ -40,12 +38,11 @@ public class GameEngine implements ActionListener { } private void startView() { - this.aView.start(); + this.aView.enable(); } - @Override - public void actionPerformed(final ActionEvent pActionEvent) { - this.aInterpreter.interpret(pActionEvent.getActionCommand()); + public void interpret(final String pCommandString) { + this.aInterpreter.interpret(pCommandString); } } diff --git a/src/esieequest/controller/Interpreter.java b/src/esieequest/controller/Interpreter.java index 1e2937b..b4fbb3e 100644 --- a/src/esieequest/controller/Interpreter.java +++ b/src/esieequest/controller/Interpreter.java @@ -3,10 +3,6 @@ */ package esieequest.controller; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.StringTokenizer; - import esieequest.model.Game; import esieequest.model.command.Command; import esieequest.view.View; @@ -62,7 +58,7 @@ public class Interpreter { return; } } - this.aPerformer.showMessage("Unknown command."); + this.aPerformer.echo("Unknown command."); return; } } diff --git a/src/esieequest/controller/Parser.java b/src/esieequest/controller/Parser.java index bd36041..c9095fe 100644 --- a/src/esieequest/controller/Parser.java +++ b/src/esieequest/controller/Parser.java @@ -1,7 +1,5 @@ package esieequest.controller; -import java.util.StringTokenizer; - import esieequest.model.command.Command; public class Parser { @@ -10,22 +8,23 @@ public class Parser { } public Command getCommand(final String pCommandString) { - StringTokenizer vTokenizer = new StringTokenizer(pCommandString); + String[] vElements = pCommandString.split(" "); String vAction = null; String vOption = null; - if (vTokenizer.hasMoreTokens()) { - vAction = vTokenizer.nextToken(); - if (vTokenizer.hasMoreTokens()) { - vOption = vTokenizer.nextToken(); - } + if (vElements.length > 0) { + vAction = vElements[0]; + } + if (vElements.length > 1) { + vOption = vElements[1]; } + return new Command(vAction, vOption); } - + private void validateCommand() { - + // TODO } } diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java index db52c4f..c56ef39 100644 --- a/src/esieequest/controller/Performer.java +++ b/src/esieequest/controller/Performer.java @@ -21,53 +21,52 @@ public class Performer { this.aView = pView; } - public void showMessage(final String pString) { - this.aView.showMessage(pString); + public void echo(final String pString) { + this.aView.echo(pString); } public void newGame() { // this.loadGame(default game); - this.aView - .showMessage(this.aGame.getWelcomeMessage() + "\n" + this.aGame.getLocationInfo()); + this.aView.echo(this.aGame.getWelcomeMessage() + "\n" + this.aGame.getLocationInfo()); } public void loadGame() { - this.aView.showMessage("Not implemented."); + this.aView.echo("Not implemented."); } public void saveGame() { - this.aView.showMessage("Not implemented."); + this.aView.echo("Not implemented."); } public void toggleSound() { - this.aView.showMessage("Not implemented."); + this.aView.echo("Not implemented."); } public void quitGame() { - this.aView.showMessage(this.aGame.getQuitMessage()); + this.aView.echo(this.aGame.getQuitMessage()); this.aGame.setRunning(false); } public void showHelp() { - this.aView.showMessage(this.aGame.getHelpMessage()); + this.aView.echo(this.aGame.getHelpMessage()); } public void goTo(final String pDirection) { Room vNextRoom = this.aGame.getRoomExit(pDirection); if (vNextRoom != null) { this.aGame.goToRoom(vNextRoom); - this.aView.showMessage(this.aGame.getLocationInfo()); + this.aView.echo(this.aGame.getLocationInfo()); } else { - this.aView.showMessage(this.aGame.getNoExitMessage()); + this.aView.echo(this.aGame.getNoExitMessage()); } } public void look() { - this.aView.showMessage(this.aGame.getLocationInfo()); + this.aView.echo(this.aGame.getLocationInfo()); } public void eat() { - this.aView.showMessage(this.aGame.getEatMessage()); + this.aView.echo(this.aGame.getEatMessage()); } } diff --git a/src/esieequest/controller/package-info.java b/src/esieequest/controller/package-info.java deleted file mode 100644 index 4d6616c..0000000 --- a/src/esieequest/controller/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * - */ -/** - * @author pacien - * - */ -package esieequest.controller; \ No newline at end of file diff --git a/src/esieequest/esieequest.gwt.xml b/src/esieequest/esieequest.gwt.xml new file mode 100644 index 0000000..b97b0a2 --- /dev/null +++ b/src/esieequest/esieequest.gwt.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java index ed7c3df..668a7f9 100644 --- a/src/esieequest/model/Game.java +++ b/src/esieequest/model/Game.java @@ -1,6 +1,5 @@ package esieequest.model; -import java.util.Observable; import java.util.HashMap; /** @@ -10,7 +9,7 @@ import java.util.HashMap; * * @version February 2014 */ -public class Game extends Observable { +public class Game { private boolean aRunning; private HashMap aRooms; @@ -168,8 +167,6 @@ public class Game extends Observable { public void setRunning(final boolean pState) { this.aRunning = pState; - this.setChanged(); - this.notifyObservers("state"); } public boolean isRunning() { @@ -178,14 +175,10 @@ public class Game extends Observable { public void goToRoom(final Room pRoom) { this.aCurrentRoom = pRoom; - this.setChanged(); - this.notifyObservers("room"); } public void goToRoom(final String pRoomName) { this.aCurrentRoom = this.aRooms.get(pRoomName); - this.setChanged(); - this.notifyObservers("room"); } public Room getRoomExit(final String pDirection) { diff --git a/src/esieequest/model/command/package-info.java b/src/esieequest/model/command/package-info.java deleted file mode 100644 index 38be480..0000000 --- a/src/esieequest/model/command/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * - */ -/** - * @author pacien - * - */ -package esieequest.model.command; \ No newline at end of file diff --git a/src/esieequest/model/package-info.java b/src/esieequest/model/package-info.java deleted file mode 100644 index a3e2ceb..0000000 --- a/src/esieequest/model/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * - */ -/** - * @author pacien - * - */ -package esieequest.model; \ No newline at end of file diff --git a/src/esieequest/package-info.java b/src/esieequest/package-info.java deleted file mode 100644 index 13db6f7..0000000 --- a/src/esieequest/package-info.java +++ /dev/null @@ -1,11 +0,0 @@ -/** - * "ESIEEquest" is a very simple, text based adventure game. - */ -/** - * @author Pacien TRAN-GIRARD - * @author Benoît LUBRANO DI SBARAGLIONE - * - * @version February 2014 - * - */ -package esieequest; \ No newline at end of file diff --git a/src/esieequest/view/Applet.java b/src/esieequest/view/Applet.java deleted file mode 100644 index 0537b71..0000000 --- a/src/esieequest/view/Applet.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * - */ -package esieequest.view; - -import javax.swing.JApplet; - -import esieequest.model.Game; - -/** - * @author pacien - * - */ -public class Applet extends UserInterface { - - private JApplet aApplet; - - public Applet(final Game pGame, final JApplet pApplet) { - this.aGame = pGame; - this.aApplet = pApplet; - } - - public void start() { - this.aApplet.add(this.getLayout()); - } - -} diff --git a/src/esieequest/view/Console.java b/src/esieequest/view/Console.java deleted file mode 100644 index 9a24d01..0000000 --- a/src/esieequest/view/Console.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * - */ -package esieequest.view; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.Observable; -import java.util.Scanner; - -import esieequest.model.Game; - -/** - * @author pacien - * - */ -public class Console implements View { - - private ArrayList aActionListeners; - - private Game aGame; - private Scanner aScanner; - - public Console(final Game pGame) { - this.aActionListeners = new ArrayList(); - this.aGame = pGame; - this.aScanner = new Scanner(System.in); - } - - public void start() { - this.play(); - } - - public void update(final Observable pObservable, final Object pArgument) { - this.showMessage(this.aGame.getLocationInfo()); - } - - private void play(){ - while (this.aGame.isRunning()) { - System.out.print("> "); - String vString = this.aScanner.nextLine(); - this.sendEvent(new ActionEvent(this, 0, vString)); - } - } - - private void sendEvent(final ActionEvent pActionEvent) { - for (ActionListener vActionListener : this.aActionListeners) { - vActionListener.actionPerformed(pActionEvent); - } - } - - public void showMessage(final String pMessage) { - System.out.println(pMessage); - } - - public void setActionListener(final ActionListener pActionListener) { - this.aActionListeners.add(pActionListener); - } - -} diff --git a/src/esieequest/view/UserInterface.java b/src/esieequest/view/UserInterface.java deleted file mode 100644 index 10e0c69..0000000 --- a/src/esieequest/view/UserInterface.java +++ /dev/null @@ -1,247 +0,0 @@ -package esieequest.view; - -import javax.swing.JPanel; -import javax.swing.JButton; -import javax.swing.JTextPane; -import javax.swing.JLabel; -import javax.swing.border.EmptyBorder; - -import esieequest.model.Game; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionListener; -import java.net.URL; -import java.util.HashMap; -import java.util.Observable; - -import javax.swing.JTextField; - -import net.homelinux.nikiroo.utils.gui.JBackgroundPanel; - -import com.wordpress.tipsforjava.swing.StretchIcon; - -import java.awt.Font; -import javax.swing.JTabbedPane; -import javax.swing.JEditorPane; -import javax.swing.JLayeredPane; - -public abstract class UserInterface implements View { - - protected Game aGame; - - private JPanel aLayout; - - private JTextPane aQuestTextPane; - private JTextPane aInfoTextPane; - - private JLabel aImageLabel; - - private HashMap aGameButtons; - private HashMap aControlButtons; - private JTextField aInputField; - - /** - * Create the panel. - */ - public UserInterface() { - - this.aLayout = new JPanel(); - this.aLayout.setLayout(new BorderLayout(0, 0)); - - JPanel vMenuPanel = new JPanel(); - this.aLayout.add(vMenuPanel, BorderLayout.NORTH); - vMenuPanel.setLayout(new BorderLayout(0, 0)); - - JPanel vQuestPanel = new JPanel(); - vMenuPanel.add(vQuestPanel, BorderLayout.CENTER); - - this.aQuestTextPane = new JTextPane(); - this.aQuestTextPane.setEditable(false); - this.aQuestTextPane.setText("ESIEEquest"); - vQuestPanel.add(this.aQuestTextPane); - - JPanel vGamePanel = new JPanel(); - vMenuPanel.add(vGamePanel, BorderLayout.WEST); - - JButton vNewButton = new JButton("New"); - vNewButton.setToolTipText("New game"); - vGamePanel.add(vNewButton); - - JButton vSoundButton = new JButton("Sound"); - vSoundButton.setToolTipText("Toggle sound"); - vGamePanel.add(vSoundButton); - - JPanel filePanel = new JPanel(); - vMenuPanel.add(filePanel, BorderLayout.EAST); - - JButton vLoadButton = new JButton("Load"); - vLoadButton.setToolTipText("Load a game"); - filePanel.add(vLoadButton); - - JButton vSaveButton = new JButton("Save"); - vSaveButton.setToolTipText("Save the current game"); - filePanel.add(vSaveButton); - - JPanel vImagePanel = new JPanel(); - aLayout.add(vImagePanel, BorderLayout.CENTER); - vImagePanel.setLayout(new BorderLayout(0, 0)); - - this.aImageLabel = new JLabel(); - vImagePanel.add(this.aImageLabel); - - JPanel vUserPanel = new JPanel(); - this.aLayout.add(vUserPanel, BorderLayout.SOUTH); - vUserPanel.setLayout(new BorderLayout(0, 0)); - - JPanel vDispPanel = new JPanel(); - vDispPanel.setBorder(new EmptyBorder(5, 5, 5, 0)); - vUserPanel.add(vDispPanel, BorderLayout.CENTER); - vDispPanel.setLayout(new BorderLayout(0, 0)); - - this.aInfoTextPane = new JTextPane(); - this.aInfoTextPane.setEditable(false); - this.aInfoTextPane.setText("Welcome to ESIEEquest!"); - vDispPanel.add(this.aInfoTextPane); - - aInputField = new JTextField(); - vDispPanel.add(aInputField, BorderLayout.SOUTH); - aInputField.setColumns(10); - - JPanel vControlPanel = new JPanel(); - vControlPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); - vUserPanel.add(vControlPanel, BorderLayout.EAST); - vControlPanel.setLayout(new BorderLayout(0, 0)); - - JPanel vTopControlPanel = new JPanel(); - vControlPanel.add(vTopControlPanel, BorderLayout.NORTH); - vTopControlPanel.setLayout(new BorderLayout(0, 0)); - - JButton vForwardButton = new JButton("↥"); - vForwardButton.setFont(new Font("Dialog", Font.BOLD, 19)); - vForwardButton.setToolTipText("Go forward"); - vTopControlPanel.add(vForwardButton, BorderLayout.CENTER); - - JButton vInventoryButton = new JButton("⇱"); - vInventoryButton.setFont(new Font("Dialog", Font.BOLD, 19)); - vInventoryButton.setToolTipText("Use item"); - vTopControlPanel.add(vInventoryButton, BorderLayout.WEST); - - JButton vActionButton = new JButton("⇲"); - vActionButton.setFont(new Font("Dialog", Font.BOLD, 19)); - vActionButton.setToolTipText("Talk/Take item"); - vTopControlPanel.add(vActionButton, BorderLayout.EAST); - - JPanel vBottomControlPanel = new JPanel(); - vControlPanel.add(vBottomControlPanel, BorderLayout.SOUTH); - vBottomControlPanel.setLayout(new BorderLayout(0, 0)); - - JButton vBackButton = new JButton("↧"); - vBackButton.setFont(new Font("Dialog", Font.BOLD, 19)); - vBackButton.setToolTipText("Go back"); - vBottomControlPanel.add(vBackButton, BorderLayout.CENTER); - - JButton vLeftButton = new JButton("↰"); - vLeftButton.setFont(new Font("Dialog", Font.BOLD, 19)); - vLeftButton.setToolTipText("Turn left"); - vBottomControlPanel.add(vLeftButton, BorderLayout.WEST); - - JButton vRightButton = new JButton("↱"); - vRightButton.setFont(new Font("Dialog", Font.BOLD, 19)); - vRightButton.setToolTipText("Turn right"); - vBottomControlPanel.add(vRightButton, BorderLayout.EAST); - - Dimension vSquareButton = new Dimension(50, 50); - vForwardButton.setPreferredSize(vSquareButton); - vInventoryButton.setPreferredSize(vSquareButton); - vActionButton.setPreferredSize(vSquareButton); - vBackButton.setPreferredSize(vSquareButton); - vLeftButton.setPreferredSize(vSquareButton); - vRightButton.setPreferredSize(vSquareButton); - - vNewButton.setActionCommand("new"); - vSoundButton.setActionCommand("sound"); - vLoadButton.setActionCommand("load"); - vSaveButton.setActionCommand("save"); - - vForwardButton.setActionCommand("forward"); - vInventoryButton.setActionCommand("inventory"); - vActionButton.setActionCommand("do"); - vBackButton.setActionCommand("back"); - vLeftButton.setActionCommand("turn left"); - vRightButton.setActionCommand("turn right"); - - this.aGameButtons = new HashMap(); - - this.aGameButtons.put("vNewButton", vNewButton); - this.aGameButtons.put("vSoundButton", vSoundButton); - this.aGameButtons.put("vLoadButton", vLoadButton); - this.aGameButtons.put("vSaveButton", vSaveButton); - - this.aControlButtons = new HashMap(); - - this.aControlButtons.put("vForwardButton", vForwardButton); - this.aControlButtons.put("vInventoryButton", vInventoryButton); - this.aControlButtons.put("vActionButton", vActionButton); - this.aControlButtons.put("vBackButton", vBackButton); - this.aControlButtons.put("vLeftButton", vLeftButton); - this.aControlButtons.put("vRightButton", vRightButton); - - } - - @Override - public void update(final Observable pObservable, final Object pArgument) { - // TODO Auto-generated method stub - this.clearInputField(); - this.updateIllustration(); - this.setControlsState(this.aGame.isRunning()); - } - - public JPanel getLayout() { - return this.aLayout; - } - - private void setActionListener(final HashMap vHashMap, - final ActionListener pActionListener) { - for (JButton vButton : vHashMap.values()) { - vButton.addActionListener(pActionListener); - } - } - - public void setActionListener(final ActionListener pActionListener) { - this.aInputField.addActionListener(pActionListener); - this.setActionListener(this.aGameButtons, pActionListener); - this.setActionListener(this.aControlButtons, pActionListener); - } - - private void clearInputField() { - this.aInputField.setText(null); - } - - private void setControlsState(final boolean pState) { - this.aInputField.setEnabled(pState); - for (JButton vButton : this.aControlButtons.values()) { - vButton.setEnabled(pState); - } - } - - private void setQuest(final String pQuest) { - this.aQuestTextPane.setText(pQuest); - } - - public void showMessage(final String pMessage) { - this.aInfoTextPane.setText(pMessage); - this.clearInputField(); - } - - private void updateIllustration() { - String vImageName = this.aGame.getLocationImageName(); - if (vImageName == null) { - vImageName = "res/img/placeholder.jpg"; - } - URL vImageURL = this.getClass().getClassLoader().getResource(vImageName); - StretchIcon vImageIcon = new StretchIcon(vImageURL, true); - this.aImageLabel.setIcon(vImageIcon); - } - -} diff --git a/src/esieequest/view/View.java b/src/esieequest/view/View.java index 3061b47..ad84b61 100644 --- a/src/esieequest/view/View.java +++ b/src/esieequest/view/View.java @@ -3,21 +3,23 @@ */ package esieequest.view; -import java.awt.event.ActionListener; -import java.util.Observer; +import esieequest.controller.GameEngine; +import esieequest.model.Game; /** * @author pacien * */ -public interface View extends Observer { +public interface View { - public void setActionListener(final ActionListener pActionListener); + public void setModel(final Game pGame); - public void start(); + public void setController(final GameEngine pGameEngine); - //public void quit(); + public void enable(); - public void showMessage(final String pMessage); + public void refresh(); + + public void echo(final String pMessage); } diff --git a/src/esieequest/view/Window.java b/src/esieequest/view/Window.java deleted file mode 100644 index bacc8bf..0000000 --- a/src/esieequest/view/Window.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * - */ -package esieequest.view; - -import javax.swing.JFrame; - -import esieequest.model.Game; - -/** - * @author pacien - * - */ -public class Window extends UserInterface { - - private JFrame aWindow; - - /** - * Create the frame. - * - * @wbp.parser.entryPoint - */ - public Window(final Game pGame) { - this.aGame = pGame; - this.aWindow = new JFrame("ESIEEquest"); - this.aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.aWindow.setBounds(100, 100, 700, 500); - this.aWindow.setContentPane(this.getLayout()); - } - - public void start() { - this.aWindow.setVisible(true); - } - -} diff --git a/src/esieequest/view/app/Applet.java b/src/esieequest/view/app/Applet.java new file mode 100644 index 0000000..f472b06 --- /dev/null +++ b/src/esieequest/view/app/Applet.java @@ -0,0 +1,27 @@ +/** + * + */ +package esieequest.view.app; + +import javax.swing.JApplet; + +import esieequest.model.Game; + +/** + * @author pacien + * + */ +public class Applet extends UserInterface { + + private JApplet aApplet; + + public Applet(final JApplet pApplet) { + //this.aGame = pGame; + this.aApplet = pApplet; + } + + public void enable() { + this.aApplet.add(this.getLayout()); + } + +} diff --git a/src/esieequest/view/app/UserInterface.java b/src/esieequest/view/app/UserInterface.java new file mode 100644 index 0000000..36b928e --- /dev/null +++ b/src/esieequest/view/app/UserInterface.java @@ -0,0 +1,263 @@ +package esieequest.view.app; + +import javax.swing.JPanel; +import javax.swing.JButton; +import javax.swing.JTextPane; +import javax.swing.JLabel; +import javax.swing.border.EmptyBorder; + +import esieequest.controller.GameEngine; +import esieequest.model.Game; +import esieequest.view.View; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.URL; +import java.util.HashMap; + +import javax.swing.JTextField; + +import com.wordpress.tipsforjava.swing.StretchIcon; + +import java.awt.Font; + +public abstract class UserInterface implements View, ActionListener { + + protected Game aGame; + private GameEngine aGameEngine; + + private JPanel aLayout; + + private JTextPane aQuestTextPane; + private JTextPane aInfoTextPane; + + private JLabel aImageLabel; + + private HashMap aGameButtons; + private HashMap aControlButtons; + private JTextField aInputField; + + /** + * Create the panel. + */ + public UserInterface() { + this.buildUI(); + this.aInputField.addActionListener(this); + this.setControlsState(false); + aInputField.setEnabled(true); + } + + private void buildUI() { + this.aLayout = new JPanel(); + this.aLayout.setLayout(new BorderLayout(0, 0)); + + JPanel vMenuPanel = new JPanel(); + this.aLayout.add(vMenuPanel, BorderLayout.NORTH); + vMenuPanel.setLayout(new BorderLayout(0, 0)); + + JPanel vQuestPanel = new JPanel(); + vMenuPanel.add(vQuestPanel, BorderLayout.CENTER); + + this.aQuestTextPane = new JTextPane(); + this.aQuestTextPane.setEditable(false); + this.aQuestTextPane.setText("ESIEEquest"); + vQuestPanel.add(this.aQuestTextPane); + + JPanel vGamePanel = new JPanel(); + vMenuPanel.add(vGamePanel, BorderLayout.WEST); + + JButton vNewButton = new JButton("New"); + vNewButton.setToolTipText("New game"); + vGamePanel.add(vNewButton); + + JButton vSoundButton = new JButton("Sound"); + vSoundButton.setToolTipText("Toggle sound"); + vGamePanel.add(vSoundButton); + + JPanel filePanel = new JPanel(); + vMenuPanel.add(filePanel, BorderLayout.EAST); + + JButton vLoadButton = new JButton("Load"); + vLoadButton.setToolTipText("Load a game"); + filePanel.add(vLoadButton); + + JButton vSaveButton = new JButton("Save"); + vSaveButton.setToolTipText("Save the current game"); + filePanel.add(vSaveButton); + + JPanel vImagePanel = new JPanel(); + aLayout.add(vImagePanel, BorderLayout.CENTER); + vImagePanel.setLayout(new BorderLayout(0, 0)); + + this.aImageLabel = new JLabel(); + vImagePanel.add(this.aImageLabel); + + JPanel vUserPanel = new JPanel(); + this.aLayout.add(vUserPanel, BorderLayout.SOUTH); + vUserPanel.setLayout(new BorderLayout(0, 0)); + + JPanel vDispPanel = new JPanel(); + vDispPanel.setBorder(new EmptyBorder(5, 5, 5, 0)); + vUserPanel.add(vDispPanel, BorderLayout.CENTER); + vDispPanel.setLayout(new BorderLayout(0, 0)); + + this.aInfoTextPane = new JTextPane(); + this.aInfoTextPane.setEditable(false); + this.aInfoTextPane.setText("Welcome to ESIEEquest!"); + vDispPanel.add(this.aInfoTextPane); + + aInputField = new JTextField(); + vDispPanel.add(aInputField, BorderLayout.SOUTH); + aInputField.setColumns(10); + + JPanel vControlPanel = new JPanel(); + vControlPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + vUserPanel.add(vControlPanel, BorderLayout.EAST); + vControlPanel.setLayout(new BorderLayout(0, 0)); + + JPanel vTopControlPanel = new JPanel(); + vControlPanel.add(vTopControlPanel, BorderLayout.NORTH); + vTopControlPanel.setLayout(new BorderLayout(0, 0)); + + JButton vForwardButton = new JButton("↥"); + vForwardButton.setFont(new Font("Dialog", Font.BOLD, 19)); + vForwardButton.setToolTipText("Go forward"); + vTopControlPanel.add(vForwardButton, BorderLayout.CENTER); + + JButton vInventoryButton = new JButton("⇱"); + vInventoryButton.setFont(new Font("Dialog", Font.BOLD, 19)); + vInventoryButton.setToolTipText("Use item"); + vTopControlPanel.add(vInventoryButton, BorderLayout.WEST); + + JButton vActionButton = new JButton("⇲"); + vActionButton.setFont(new Font("Dialog", Font.BOLD, 19)); + vActionButton.setToolTipText("Talk/Take item"); + vTopControlPanel.add(vActionButton, BorderLayout.EAST); + + JPanel vBottomControlPanel = new JPanel(); + vControlPanel.add(vBottomControlPanel, BorderLayout.SOUTH); + vBottomControlPanel.setLayout(new BorderLayout(0, 0)); + + JButton vBackButton = new JButton("↧"); + vBackButton.setFont(new Font("Dialog", Font.BOLD, 19)); + vBackButton.setToolTipText("Go back"); + vBottomControlPanel.add(vBackButton, BorderLayout.CENTER); + + JButton vLeftButton = new JButton("↰"); + vLeftButton.setFont(new Font("Dialog", Font.BOLD, 19)); + vLeftButton.setToolTipText("Turn left"); + vBottomControlPanel.add(vLeftButton, BorderLayout.WEST); + + JButton vRightButton = new JButton("↱"); + vRightButton.setFont(new Font("Dialog", Font.BOLD, 19)); + vRightButton.setToolTipText("Turn right"); + vBottomControlPanel.add(vRightButton, BorderLayout.EAST); + + Dimension vSquareButton = new Dimension(50, 50); + vForwardButton.setPreferredSize(vSquareButton); + vInventoryButton.setPreferredSize(vSquareButton); + vActionButton.setPreferredSize(vSquareButton); + vBackButton.setPreferredSize(vSquareButton); + vLeftButton.setPreferredSize(vSquareButton); + vRightButton.setPreferredSize(vSquareButton); + + vNewButton.setActionCommand("new"); + vSoundButton.setActionCommand("sound"); + vLoadButton.setActionCommand("load"); + vSaveButton.setActionCommand("save"); + + vForwardButton.setActionCommand("forward"); + vInventoryButton.setActionCommand("inventory"); + vActionButton.setActionCommand("do"); + vBackButton.setActionCommand("back"); + vLeftButton.setActionCommand("turn left"); + vRightButton.setActionCommand("turn right"); + + this.aGameButtons = new HashMap(); + + this.aGameButtons.put("vNewButton", vNewButton); + this.aGameButtons.put("vSoundButton", vSoundButton); + this.aGameButtons.put("vLoadButton", vLoadButton); + this.aGameButtons.put("vSaveButton", vSaveButton); + + this.aControlButtons = new HashMap(); + + this.aControlButtons.put("vForwardButton", vForwardButton); + this.aControlButtons.put("vInventoryButton", vInventoryButton); + this.aControlButtons.put("vActionButton", vActionButton); + this.aControlButtons.put("vBackButton", vBackButton); + this.aControlButtons.put("vLeftButton", vLeftButton); + this.aControlButtons.put("vRightButton", vRightButton); + } + + public void actionPerformed(final ActionEvent pActionEvent) { + this.aGameEngine.interpret(pActionEvent.getActionCommand()); + } + + public JPanel getLayout() { + return this.aLayout; + } + + private void setActionListener(final HashMap vHashMap, + final ActionListener pActionListener) { + for (JButton vButton : vHashMap.values()) { + vButton.addActionListener(pActionListener); + } + } + + public void setActionListener(final ActionListener pActionListener) { + this.aInputField.addActionListener(pActionListener); + this.setActionListener(this.aGameButtons, pActionListener); + this.setActionListener(this.aControlButtons, pActionListener); + } + + private void clearInputField() { + this.aInputField.setText(null); + } + + private void setControlsState(final boolean pState) { + this.aInputField.setEnabled(pState); + for (JButton vButton : this.aControlButtons.values()) { + vButton.setEnabled(pState); + } + } + + private void setQuest(final String pQuest) { + this.aQuestTextPane.setText(pQuest); + } + + private void updateIllustration() { + String vImageName = this.aGame.getLocationImageName(); + if (vImageName == null) { + vImageName = "res/img/placeholder.jpg"; + } + URL vImageURL = this.getClass().getClassLoader().getResource(vImageName); + StretchIcon vImageIcon = new StretchIcon(vImageURL, true); + this.aImageLabel.setIcon(vImageIcon); + } + + @Override + public void setModel(Game pGame) { + this.aGame = pGame; + } + + @Override + public void setController(GameEngine pGameEngine) { + this.aGameEngine = pGameEngine; + } + + @Override + public void echo(final String pMessage) { + this.aInfoTextPane.setText(pMessage); + this.clearInputField(); + } + + @Override + public void refresh() { + // TODO Auto-generated method stub + + } + +} diff --git a/src/esieequest/view/app/Window.java b/src/esieequest/view/app/Window.java new file mode 100644 index 0000000..ad20ce7 --- /dev/null +++ b/src/esieequest/view/app/Window.java @@ -0,0 +1,35 @@ +/** + * + */ +package esieequest.view.app; + +import javax.swing.JFrame; + +import esieequest.model.Game; + +/** + * @author pacien + * + */ +public class Window extends UserInterface { + + private JFrame aWindow; + + /** + * Create the frame. + * + * @wbp.parser.entryPoint + */ + public Window() { + //this.aGame = pGame; + this.aWindow = new JFrame("ESIEEquest"); + this.aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.aWindow.setBounds(100, 100, 700, 500); + this.aWindow.setContentPane(this.getLayout()); + } + + public void enable() { + this.aWindow.setVisible(true); + } + +} diff --git a/src/esieequest/view/console/Console.java b/src/esieequest/view/console/Console.java new file mode 100644 index 0000000..90cde08 --- /dev/null +++ b/src/esieequest/view/console/Console.java @@ -0,0 +1,59 @@ +/** + * + */ +package esieequest.view.console; + +import java.util.Scanner; + +import esieequest.controller.GameEngine; +import esieequest.model.Game; +import esieequest.view.View; + +/** + * @author pacien + * + */ +public class Console implements View { + + private Game aGame; + private GameEngine aGameEngine; + private Scanner aScanner; + + public Console() { + this.aScanner = new Scanner(System.in); + } + + private void play() { + while (this.aGame.isRunning()) { + System.out.print("> "); + String vInputString = this.aScanner.nextLine(); + this.aGameEngine.interpret(vInputString); + } + } + + @Override + public void setModel(Game pGame) { + this.aGame = pGame; + } + + @Override + public void setController(GameEngine pGameEngine) { + this.aGameEngine = pGameEngine; + } + + @Override + public void enable() { + this.play(); + } + + @Override + public void refresh() { + this.echo(this.aGame.getLocationInfo()); + } + + @Override + public void echo(String pMessage) { + System.out.println(pMessage); + } + +} diff --git a/src/esieequest/view/package-info.java b/src/esieequest/view/package-info.java deleted file mode 100644 index 283292d..0000000 --- a/src/esieequest/view/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * - */ -/** - * @author pacien - * - */ -package esieequest.view; \ No newline at end of file diff --git a/src/esieequest/view/web/Main.java b/src/esieequest/view/web/Main.java new file mode 100644 index 0000000..bf444c9 --- /dev/null +++ b/src/esieequest/view/web/Main.java @@ -0,0 +1,18 @@ +package esieequest.view.web; + +import com.google.gwt.core.client.EntryPoint; +import com.google.gwt.user.client.ui.RootLayoutPanel; + +import esieequest.controller.GameEngine; +import esieequest.model.Game; + +public class Main implements EntryPoint { + + @Override + public void onModuleLoad() { + Game vGame = new Game(); + WebInterface vWebInterface = new WebInterface(); + new GameEngine(vGame, vWebInterface); + } + +} diff --git a/src/esieequest/view/web/WebInterface.java b/src/esieequest/view/web/WebInterface.java new file mode 100644 index 0000000..516042e --- /dev/null +++ b/src/esieequest/view/web/WebInterface.java @@ -0,0 +1,123 @@ +/** + * + */ +package esieequest.view.web; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.KeyCodes; +import com.google.gwt.event.dom.client.KeyDownEvent; +import com.google.gwt.event.dom.client.KeyDownHandler; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.uibinder.client.UiHandler; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.HasText; +import com.google.gwt.user.client.ui.RootLayoutPanel; +import com.google.gwt.user.client.ui.Widget; +import com.google.gwt.user.client.ui.Label; + +import esieequest.controller.GameEngine; +import esieequest.model.Game; +import esieequest.view.View; + +import com.google.gwt.user.client.ui.TextBox; + +/** + * @author pacien + * + */ +public class WebInterface extends Composite implements View { + + private GameEngine aGameEngine; + private Game aGame; + + private static WebInterfaceUiBinder uiBinder = GWT.create(WebInterfaceUiBinder.class); + + @UiField + Label displayLabel; + @UiField + Label questLabel; + @UiField + TextBox inputField; + @UiField + Button newButton; + @UiField + Button soundButton; + @UiField + Button saveButton; + @UiField + Button loadButton; + @UiField + Button inventoryButton; + @UiField + Button forwardButton; + @UiField + Button actionButton; + @UiField + Button rightButton; + @UiField + Button backButton; + @UiField + Button leftButton; + + interface WebInterfaceUiBinder extends UiBinder { + } + + /** + * Because this class has a default constructor, it can be used as a binder + * template. In other words, it can be used in other *.ui.xml files as + * follows: + * Hello! Note that + * depending on the widget that is used, it may be necessary to implement + * HasHTML instead of HasText. + */ + public WebInterface() { + initWidget(uiBinder.createAndBindUi(this)); + + inputField.addKeyDownHandler(new KeyDownHandler() { + public void onKeyDown(KeyDownEvent event) { + if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { + aGameEngine.interpret(inputField.getText()); + inputField.setText(null); + } + } + }); + + } + + @Override + public void setModel(Game pGame) { + this.aGame = pGame; + } + + @Override + public void setController(GameEngine pGameEngine) { + this.aGameEngine = pGameEngine; + } + + @Override + public void enable() { + RootLayoutPanel.get().add(this); + } + + @Override + public void refresh() { + // TODO Auto-generated method stub + + } + + @Override + public void echo(String pMessage) { + this.displayLabel.setText(pMessage); + } + + /* + * @UiHandler("button") void onClick(ClickEvent e) { Window.alert("Hello!"); + * } + */ + +} diff --git a/src/esieequest/view/web/WebInterface.ui.xml b/src/esieequest/view/web/WebInterface.ui.xml new file mode 100644 index 0000000..755990e --- /dev/null +++ b/src/esieequest/view/web/WebInterface.ui.xml @@ -0,0 +1,97 @@ + + + + /* Add CSS here. See the GWT docs on UI Binder for more details */ + .important { + font-weight: bold; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Console + + + + Inventory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/net/homelinux/nikiroo/utils/gui/JBackgroundPanel.java b/src/net/homelinux/nikiroo/utils/gui/JBackgroundPanel.java deleted file mode 100644 index ba53b86..0000000 --- a/src/net/homelinux/nikiroo/utils/gui/JBackgroundPanel.java +++ /dev/null @@ -1,308 +0,0 @@ -package net.homelinux.nikiroo.utils.gui; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Insets; -import java.awt.LayoutManager; -import java.awt.Paint; -import java.awt.Rectangle; - -import javax.swing.ImageIcon; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JViewport; - -/** - * Support custom painting on a panel in the form of images - that can be - * scaled, tiled or painted at original size non solid painting - that - * can be done by using a Paint object Also, any component added directly - * to this panel will be made non-opaque so that the custom painting can show - * through. - */ -public class JBackgroundPanel extends JPanel { - private static final long serialVersionUID = 1L; - - public static final int SCALED = 0; - public static final int TILED = 1; - public static final int ACTUAL = 2; - public static final int RATIO = 3; - - private Paint painter; - private Image image; - private int style = SCALED; - private float alignmentX = 0.5f; - private float alignmentY = 0.5f; - private boolean isTransparentAdd = true; - - /** - * Empty {@link JBackgroundPanel}. - */ - public JBackgroundPanel() { - } - - /** - * Empty {@link JBackgroundPanel} with the given {@link LayoutManager}. - */ - public JBackgroundPanel(LayoutManager layout) { - super(layout); - } - - /* - * Set image as the background with the SCALED style - */ - public JBackgroundPanel(ImageIcon image) { - this(image.getImage()); - } - - /* - * Set image as the background with the SCALED style - */ - public JBackgroundPanel(ImageIcon image, int style) { - this(image.getImage(), style); - } - - /* - * Set image as the backround with the specified style and alignment - */ - public JBackgroundPanel(ImageIcon image, int style, float alignmentX, float alignmentY) { - this(image.getImage(), style, alignmentX, alignmentY); - } - - /* - * Set image as the background with the SCALED style - */ - public JBackgroundPanel(Image image) { - this(image, SCALED); - } - - /* - * Set image as the background with the specified style - */ - public JBackgroundPanel(Image image, int style) { - setImage(image); - setStyle(style); - setLayout(new BorderLayout()); - } - - /* - * Set image as the backround with the specified style and alignment - */ - public JBackgroundPanel(Image image, int style, float alignmentX, float alignmentY) { - setImage(image); - setStyle(style); - setImageAlignmentX(alignmentX); - setImageAlignmentY(alignmentY); - setLayout(new BorderLayout()); - } - - /* - * Use the Paint interface to paint a background - */ - public JBackgroundPanel(Paint painter) { - setPaint(painter); - setLayout(new BorderLayout()); - } - - /* - * Set the image used as the background - */ - public void setImage(Image image) { - this.image = image; - repaint(); - } - - /* - * Set the style used to paint the background image - */ - public void setStyle(int style) { - this.style = style; - repaint(); - } - - /* - * Set the Paint object used to paint the background - */ - public void setPaint(Paint painter) { - this.painter = painter; - repaint(); - } - - /* - * Specify the horizontal alignment of the image when using ACTUAL style - */ - public void setImageAlignmentX(float alignmentX) { - this.alignmentX = alignmentX > 1.0f ? 1.0f : alignmentX < 0.0f ? 0.0f : alignmentX; - repaint(); - } - - /* - * Specify the horizontal alignment of the image when using ACTUAL style - */ - public void setImageAlignmentY(float alignmentY) { - this.alignmentY = alignmentY > 1.0f ? 1.0f : alignmentY < 0.0f ? 0.0f : alignmentY; - repaint(); - } - - /* - * Override method so we can make the component transparent - */ - public void add(JComponent component) { - add(component, null); - } - - /* - * Override to provide a preferred size equal to the image size - */ - @Override - public Dimension getPreferredSize() { - if (image == null) - return super.getPreferredSize(); - else - return new Dimension(image.getWidth(null), image.getHeight(null)); - } - - /* - * Override method so we can make the component transparent - */ - public void add(JComponent component, Object constraints) { - if (isTransparentAdd) { - makeComponentTransparent(component); - } - - super.add(component, constraints); - } - - /* - * Controls whether components added to this panel should automatically be - * made transparent. That is, setOpaque(false) will be invoked. The default - * is set to true. - */ - public void setTransparentAdd(boolean isTransparentAdd) { - this.isTransparentAdd = isTransparentAdd; - } - - /* - * Try to make the component transparent. For components that use renderers, - * like JTable, you will also need to change the renderer to be transparent. - * An easy way to do this it to set the background of the table to a Color - * using an alpha value of 0. - */ - private void makeComponentTransparent(JComponent component) { - component.setOpaque(false); - - if (component instanceof JScrollPane) { - JScrollPane scrollPane = (JScrollPane) component; - JViewport viewport = scrollPane.getViewport(); - viewport.setOpaque(false); - Component c = viewport.getView(); - - if (c instanceof JComponent) { - ((JComponent) c).setOpaque(false); - } - } - } - - /* - * Add custom painting - */ - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - - // Invoke the painter for the background - - if (painter != null) { - Dimension d = getSize(); - Graphics2D g2 = (Graphics2D) g; - g2.setPaint(painter); - g2.fill(new Rectangle(0, 0, d.width, d.height)); - } - - // Draw the image - - if (image == null) - return; - - switch (style) { - case RATIO: - drawRatio(g); - break; - - case SCALED: - drawScaled(g); - break; - - case TILED: - drawTiled(g); - break; - - case ACTUAL: - drawActual(g); - break; - - default: - drawScaled(g); - } - } - - /* - * Custom painting code for drawing a SCALED image as the background - */ - private void drawScaled(Graphics g) { - Dimension d = getSize(); - g.drawImage(image, 0, 0, d.width, d.height, null); - } - - /* - * Custom painting code for drawing TILED images as the background - */ - private void drawTiled(Graphics g) { - Dimension d = getSize(); - int width = image.getWidth(null); - int height = image.getHeight(null); - - for (int x = 0; x < d.width; x += width) { - for (int y = 0; y < d.height; y += height) { - g.drawImage(image, x, y, null, null); - } - } - } - - /* - * Custom painting code for drawing the ACTUAL image as the background. The - * image is positioned in the panel based on the horizontal and vertical - * alignments specified. - */ - private void drawActual(Graphics g) { - Dimension d = getSize(); - Insets insets = getInsets(); - int width = d.width - insets.left - insets.right; - int height = d.height - insets.top - insets.left; - float x = (width - image.getWidth(null)) * alignmentX; - float y = (height - image.getHeight(null)) * alignmentY; - g.drawImage(image, (int) x + insets.left, (int) y + insets.top, this); - } - - private void drawRatio(Graphics g) { - if (image != null && g != null) { - // si la dimension actuelle est > � la preferedSize (qui est - // elle-meme a la taille de l'avatar) - int h = (this.getHeight() - image.getHeight(null)) / 2; - int w = (this.getWidth() - image.getWidth(null)) / 2; - if (h < 0) { - h = 0; - } - if (w < 0) { - w = 0; - } - // TODO: alignment, solid paint - - g.drawImage(image, w, h, null, null); - } - } -} \ No newline at end of file diff --git a/war/WEB-INF/web.xml b/war/WEB-INF/web.xml new file mode 100644 index 0000000..8c2676a --- /dev/null +++ b/war/WEB-INF/web.xml @@ -0,0 +1,13 @@ + + + + + + esieequest.html + + + diff --git a/war/esieequest.css b/war/esieequest.css new file mode 100644 index 0000000..043fd86 --- /dev/null +++ b/war/esieequest.css @@ -0,0 +1,53 @@ +/** Add css rules here for your application. */ + +body { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +button { + border: 1px solid #ccc !important; +} + +.toolbar div.gwt-Label { + margin-top: 0.35em; +} + +.toolbar button { + width: 100%; + height: 100%; +} + +.controls button { + width: 3.5em; + height: 3.5em; +} + +.gwt-Frame { + border: none !important; +} + +.console { + margin-left: 4px; + margin-right: 1px; + margin-top: 3px; + margin-bottom: 2px; +} + +.console .gwt-TabLayoutPanelContentContainer { + margin-bottom: 2px; + border: 1px solid #ccc !important; +} + +.console .gwt-TabLayoutPanelContent { + border: none !important; +} + +.gwt-TextBox { + width: calc(100% - 5px); + border: 1px solid #ccc; +} diff --git a/war/esieequest.html b/war/esieequest.html new file mode 100644 index 0000000..f96990d --- /dev/null +++ b/war/esieequest.html @@ -0,0 +1,37 @@ + + + + + + + + ESIEEquest Web View + + + + + + + + + + + + + + + + + + + + + + + Your web browser must have JavaScript enabled + in order for this application to display correctly. + + + + + -- cgit v1.2.3