picross-commit Mailing List for picross (Page 4)
Status: Pre-Alpha
Brought to you by:
yvan_norsa
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(40) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
(30) |
May
(15) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(10) |
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2013 |
Jan
(38) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
(1) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <yva...@us...> - 2008-04-28 09:07:16
|
Revision: 66
http://picross.svn.sourceforge.net/picross/?rev=66&view=rev
Author: yvan_norsa
Date: 2008-04-28 02:07:21 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
clean-up
Modified Paths:
--------------
trunk/src/picross/PicrossMediator.java
trunk/src/picross/game/simple/SimpleGameMode.java
trunk/src/picross/menus/MenuController.java
trunk/src/picross/menus/MenuMediator.java
trunk/src/picross/menus/MenuUI.java
Added Paths:
-----------
trunk/src/picross/game/simple/LevelMenuController.java
trunk/src/picross/game/simple/LevelMenuMediator.java
trunk/src/picross/game/simple/LevelMenuModel.java
trunk/src/picross/game/simple/LevelMenuUI.java
trunk/src/picross/game/simple/LevelsListCommand.java
trunk/src/picross/game/simple/SelectSizeCommand.java
Removed Paths:
-------------
trunk/src/picross/menus/LevelMenuController.java
trunk/src/picross/menus/LevelMenuMediator.java
trunk/src/picross/menus/LevelMenuModel.java
trunk/src/picross/menus/LevelMenuUI.java
trunk/src/picross/menus/LevelsListCommand.java
trunk/src/picross/menus/SelectSizeCommand.java
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2008-04-28 08:58:35 UTC (rev 65)
+++ trunk/src/picross/PicrossMediator.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -54,7 +54,7 @@
import picross.grid.GridController;
import picross.menus.GameMenuMediator;
-import picross.menus.LevelMenuMediator;
+//import picross.menus.LevelMenuMediator;
import picross.menus.MainMenuMediator;
import picross.menus.MenuCommand;
import picross.menus.MenuMediator;
@@ -121,10 +121,12 @@
return;
}
+ /*
if (cmd.equals(PicrossController.SELECT_LEVEL_CMD)) {
this.displaySelectLevelMenu();
return;
}
+ */
/*
if (cmd.equals(PicrossController.LEVEL_CMD)) {
@@ -176,9 +178,11 @@
}
/** Displays the level selection menu. */
+ /*
private void displaySelectLevelMenu() {
this.displayMenu(LevelMenuMediator.class);
}
+ */
private void displayWaitScreen() {
this.displayMenu(WaitMenuMediator.class);
Copied: trunk/src/picross/game/simple/LevelMenuController.java (from rev 63, trunk/src/picross/menus/LevelMenuController.java)
===================================================================
--- trunk/src/picross/game/simple/LevelMenuController.java (rev 0)
+++ trunk/src/picross/game/simple/LevelMenuController.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -0,0 +1,89 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.simple;
+
+import fr.cle.mmvcs.SimpleEvent;
+
+import picross.menus.MenuController;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author Y. Norsa
+ */
+class LevelMenuController extends MenuController {
+ /*** Constante ***/
+
+ static final String SIZE_CMD = "SIZE_CMD";
+
+ static final String LEVELS_LIST_CMD = "LEVELS_LIST_CMD";
+
+ /*** Champ statique ***/
+
+ private static Logger log = Logger.getLogger(LevelMenuController.class);
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ LevelMenuController() {
+ }
+ */
+
+ /*** M\xE9thode ***/
+
+ public void eventPerformed(SimpleEvent e) {
+ LevelMenuController.log.debug("eventPerformed(" + e + ")");
+
+ String cmd = e.getCommandName();
+
+ if (cmd.equals(picross.game.GameCommand.GAME_CMD)) {
+ return;
+ }
+
+ if (cmd.equals(LevelMenuController.LEVELS_LIST_CMD)) {
+ LevelsListCommand command = (LevelsListCommand) e.getCommand();
+ ((LevelMenuUI) this.getView()).displayLevels(this, command.getList());
+
+ return;
+ }
+
+ super.eventPerformed(e);
+ }
+}
+
Copied: trunk/src/picross/game/simple/LevelMenuMediator.java (from rev 63, trunk/src/picross/menus/LevelMenuMediator.java)
===================================================================
--- trunk/src/picross/game/simple/LevelMenuMediator.java (rev 0)
+++ trunk/src/picross/game/simple/LevelMenuMediator.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -0,0 +1,114 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.simple;
+
+import fr.cle.mmvcs.SimpleEvent;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import picross.PicrossException;
+import picross.PicrossUI;
+
+import picross.menus.MenuController;
+import picross.menus.MenuMediator;
+import picross.menus.MenuUI;
+
+/**
+ * Level selection menu.
+ *
+ * @author Y. Norsa
+ */
+public class LevelMenuMediator extends MenuMediator {
+ private static Logger log = Logger.getLogger(LevelMenuMediator.class);
+
+ private LevelMenuModel model;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @param ui reference to the main UI
+ * @throws PicrossException if the instantiation of the view fails
+ */
+ public LevelMenuMediator(PicrossUI ui) throws PicrossException {
+ super(ui);
+ }
+
+ /*** Method overloaded from the class MenuMediator ***/
+
+ protected MenuController initController() {
+ MenuController controller = new LevelMenuController();
+ this.addSimpleListener(controller);
+
+ return controller;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected MenuUI initView(PicrossUI ui, MenuController controller)
+ throws PicrossException {
+
+ this.model = new LevelMenuModel();
+ //return new LevelMenuUI(controller, model.getLevelsList());
+ return new LevelMenuUI(controller, this.model.getSizesList());
+ }
+
+ public void eventPerformed(SimpleEvent e) {
+ LevelMenuMediator.log.debug("eventPerformed(" + e + ")");
+
+ String cmd = e.getCommandName();
+
+ if (cmd.equals(LevelMenuController.SIZE_CMD)) {
+ SelectSizeCommand command = (SelectSizeCommand) e.getCommand();
+ this.displayLevels(this.model.getLevels(command.getSize()));
+
+ return;
+ }
+
+ if (cmd.equals(picross.PicrossController.LEVEL_CMD)) {
+ this.fireEventPerformed(new picross.game.GameCommand(new picross.game.simple.SimpleGameMediator(e.getComment())));
+ return;
+ }
+
+ super.eventPerformed(e);
+ }
+
+ private void displayLevels(List<String> levels) {
+ this.fireEventPerformed(new LevelsListCommand(levels));
+ }
+}
+
Copied: trunk/src/picross/game/simple/LevelMenuModel.java (from rev 63, trunk/src/picross/menus/LevelMenuModel.java)
===================================================================
--- trunk/src/picross/game/simple/LevelMenuModel.java (rev 0)
+++ trunk/src/picross/game/simple/LevelMenuModel.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -0,0 +1,110 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.simple;
+
+import java.awt.Dimension;
+
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import picross.Picross;
+import picross.PicrossException;
+
+import picross.game.simple.LevelInfo;
+
+/**
+ * Model for the level selection menu.
+ *
+ * @author Y. Norsa
+ */
+class LevelMenuModel {
+ /*** Field ***/
+
+ /** Level list. */
+ //private List<String> levels;
+
+ private Map<Dimension, List<String>> levels;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @throws PicrossException if an error arises during the levels listing
+ */
+ LevelMenuModel() throws PicrossException {
+ this.levels = new HashMap<Dimension, List<String>>();
+
+ List<LevelInfo> infos = null;
+
+ try {
+ //this.levels = Picross.listDataFiles();
+ infos = Picross.listDataFiles();
+ } catch (IOException ioEx) {
+ throw new PicrossException(ioEx);
+ }
+
+ for (LevelInfo info : infos) {
+ Dimension levelSize = info.getDimension();
+ List<String> levelsList = this.levels.get(levelSize);
+
+ if (levelsList == null) {
+ levelsList = new ArrayList<String>();
+ this.levels.put(levelSize, levelsList);
+ }
+
+ levelsList.add(info.getName());
+ }
+ }
+
+ /*** Method ***/
+
+ /**
+ * Returns the levels list.
+ *
+ * @return list of the level files
+ */
+ List<String> getLevels(Dimension size) {
+ return this.levels.get(size);
+ }
+
+ List<Dimension> getSizesList() {
+ return new ArrayList<Dimension>(this.levels.keySet());
+ }
+}
+
Copied: trunk/src/picross/game/simple/LevelMenuUI.java (from rev 64, trunk/src/picross/menus/LevelMenuUI.java)
===================================================================
--- trunk/src/picross/game/simple/LevelMenuUI.java (rev 0)
+++ trunk/src/picross/game/simple/LevelMenuUI.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -0,0 +1,113 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.simple;
+
+import fr.cle.mmvcs.SimpleEvent;
+import fr.cle.mmvcs.SimpleListener;
+
+import java.awt.Dimension;
+
+import java.util.List;
+
+import picross.PicrossController;
+
+import picross.menus.MenuUI;
+
+/**
+ * UI for the level selection menu.
+ *
+ * @author Y. Norsa
+ */
+class LevelMenuUI extends MenuUI {
+ /*** Constant ***/
+
+ /** Serialisation ID. */
+ private static final long serialVersionUID = 6178785913505637523L;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @param listener listener for the buttons
+ * @param levels levels list
+ */
+ //LevelMenuUI(SimpleListener listener, List<String> levels) {
+ LevelMenuUI(SimpleListener listener, List<Dimension> sizes) {
+ super();
+
+ int x = 150;
+ int y = 150;
+
+ int nbSizes = sizes.size();
+
+ for (int i = 0; i < nbSizes; i++) {
+ Dimension currentDim = sizes.get(i);
+ String size = (int) currentDim.getWidth() + "x"
+ + (int) currentDim.getHeight();
+
+ SimpleEvent event = new SimpleEvent(new SelectSizeCommand(currentDim));
+ this.addSimpleButton(size, event, listener, x, y);
+
+ y += 75;
+
+ if (y == 375) {
+ x = 250;
+ y = 150;
+ }
+ }
+ }
+
+ void displayLevels(SimpleListener listener, List<String> levels) {
+ this.removeAll();
+
+ int x = 50;
+ int y = 150;
+
+ for (String level : levels) {
+ SimpleEvent event = new SimpleEvent(PicrossController.LEVEL_CMD, level);
+ this.addSimpleButton(level, event, listener, x, y);
+
+ y += 75;
+
+ if (y == 375) {
+ x = 250;
+ y = 150;
+ }
+ }
+
+ this.repaint();
+ }
+}
+
Copied: trunk/src/picross/game/simple/LevelsListCommand.java (from rev 63, trunk/src/picross/menus/LevelsListCommand.java)
===================================================================
--- trunk/src/picross/game/simple/LevelsListCommand.java (rev 0)
+++ trunk/src/picross/game/simple/LevelsListCommand.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -0,0 +1,69 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.simple;
+
+import fr.cle.mmvcs.NamedCommand;
+
+import java.util.List;
+
+/**
+ * @author Y. Norsa
+ */
+class LevelsListCommand extends NamedCommand {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private List<String> list;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ LevelsListCommand(List<String> levels) {
+ super(LevelMenuController.LEVELS_LIST_CMD);
+
+ this.list = levels;
+ }
+
+ /*** M\xE9thode ***/
+
+ List<String> getList() {
+ return this.list;
+ }
+}
+
Copied: trunk/src/picross/game/simple/SelectSizeCommand.java (from rev 63, trunk/src/picross/menus/SelectSizeCommand.java)
===================================================================
--- trunk/src/picross/game/simple/SelectSizeCommand.java (rev 0)
+++ trunk/src/picross/game/simple/SelectSizeCommand.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -0,0 +1,69 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.simple;
+
+import fr.cle.mmvcs.NamedCommand;
+
+import java.awt.Dimension;
+
+/**
+ * @author Y. Norsa
+ */
+class SelectSizeCommand extends NamedCommand {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private Dimension size;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ SelectSizeCommand(Dimension dim) {
+ super(LevelMenuController.SIZE_CMD);
+
+ this.size = dim;
+ }
+
+ /*** M\xE9thode ***/
+
+ Dimension getSize() {
+ return this.size;
+ }
+}
+
Modified: trunk/src/picross/game/simple/SimpleGameMode.java
===================================================================
--- trunk/src/picross/game/simple/SimpleGameMode.java 2008-04-28 08:58:35 UTC (rev 65)
+++ trunk/src/picross/game/simple/SimpleGameMode.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -78,7 +78,7 @@
public SimpleButton<JButton> getButton() {
ImageIcon icon =
Picross.getLocalizedImage(SimpleGameMode.SELECT_BUTTON_IMAGE);
- SimpleEvent event = new SimpleEvent(new picross.menus.MenuCommand(picross.menus.LevelMenuMediator.class));
+ SimpleEvent event = new SimpleEvent(new picross.menus.MenuCommand(LevelMenuMediator.class));
SimpleButton<JButton> button = new SimpleButton<JButton>("", event) { };
button.getButton().setIcon(icon);
Deleted: trunk/src/picross/menus/LevelMenuController.java
===================================================================
--- trunk/src/picross/menus/LevelMenuController.java 2008-04-28 08:58:35 UTC (rev 65)
+++ trunk/src/picross/menus/LevelMenuController.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -1,87 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (c) 2008
- *
- * This software is governed by the CeCILL license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL license and that you accept its terms.
- */
-
-
-package picross.menus;
-
-import fr.cle.mmvcs.SimpleEvent;
-
-import org.apache.log4j.Logger;
-
-/**
- * @author Y. Norsa
- */
-class LevelMenuController extends MenuController {
- /*** Constante ***/
-
- static final String SIZE_CMD = "SIZE_CMD";
-
- static final String LEVELS_LIST_CMD = "LEVELS_LIST_CMD";
-
- /*** Champ statique ***/
-
- private static Logger log = Logger.getLogger(LevelMenuController.class);
-
- /*** Champ ***/
-
- /*** Constructeur ***/
-
- /**
- * Constructeur.
- */
- /*
- LevelMenuController() {
- }
- */
-
- /*** M\xE9thode ***/
-
- public void eventPerformed(SimpleEvent e) {
- LevelMenuController.log.debug("eventPerformed(" + e + ")");
-
- String cmd = e.getCommandName();
-
- if (cmd.equals(picross.game.GameCommand.GAME_CMD)) {
- return;
- }
-
- if (cmd.equals(LevelMenuController.LEVELS_LIST_CMD)) {
- LevelsListCommand command = (LevelsListCommand) e.getCommand();
- ((LevelMenuUI) this.getView()).displayLevels(this, command.getList());
-
- return;
- }
-
- super.eventPerformed(e);
- }
-}
-
Deleted: trunk/src/picross/menus/LevelMenuMediator.java
===================================================================
--- trunk/src/picross/menus/LevelMenuMediator.java 2008-04-28 08:58:35 UTC (rev 65)
+++ trunk/src/picross/menus/LevelMenuMediator.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -1,110 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (c) 2008
- *
- * This software is governed by the CeCILL license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL license and that you accept its terms.
- */
-
-
-package picross.menus;
-
-import fr.cle.mmvcs.SimpleEvent;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import picross.PicrossException;
-import picross.PicrossUI;
-
-/**
- * Level selection menu.
- *
- * @author Y. Norsa
- */
-public class LevelMenuMediator extends MenuMediator {
- private static Logger log = Logger.getLogger(LevelMenuMediator.class);
-
- private LevelMenuModel model;
-
- /*** Constructor ***/
-
- /**
- * Constructor.
- *
- * @param ui reference to the main UI
- * @throws PicrossException if the instantiation of the view fails
- */
- public LevelMenuMediator(PicrossUI ui) throws PicrossException {
- super(ui);
- }
-
- /*** Method overloaded from the class MenuMediator ***/
-
- protected MenuController initController() {
- MenuController controller = new LevelMenuController();
- this.addSimpleListener(controller);
-
- return controller;
- }
-
- /** {@inheritDoc} */
- @Override
- protected MenuUI initView(PicrossUI ui, MenuController controller)
- throws PicrossException {
-
- this.model = new LevelMenuModel();
- //return new LevelMenuUI(controller, model.getLevelsList());
- return new LevelMenuUI(controller, this.model.getSizesList());
- }
-
- public void eventPerformed(SimpleEvent e) {
- LevelMenuMediator.log.debug("eventPerformed(" + e + ")");
-
- String cmd = e.getCommandName();
-
- if (cmd.equals(LevelMenuController.SIZE_CMD)) {
- SelectSizeCommand command = (SelectSizeCommand) e.getCommand();
- this.displayLevels(this.model.getLevels(command.getSize()));
-
- return;
- }
-
- if (cmd.equals(picross.PicrossController.LEVEL_CMD)) {
- this.fireEventPerformed(new picross.game.GameCommand(new picross.game.simple.SimpleGameMediator(e.getComment())));
- return;
- }
-
- super.eventPerformed(e);
- }
-
- private void displayLevels(List<String> levels) {
- this.fireEventPerformed(new LevelsListCommand(levels));
- }
-}
-
Deleted: trunk/src/picross/menus/LevelMenuModel.java
===================================================================
--- trunk/src/picross/menus/LevelMenuModel.java 2008-04-28 08:58:35 UTC (rev 65)
+++ trunk/src/picross/menus/LevelMenuModel.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -1,110 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (c) 2008
- *
- * This software is governed by the CeCILL license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL license and that you accept its terms.
- */
-
-
-package picross.menus;
-
-import java.awt.Dimension;
-
-import java.io.IOException;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import picross.Picross;
-import picross.PicrossException;
-
-import picross.game.simple.LevelInfo;
-
-/**
- * Model for the level selection menu.
- *
- * @author Y. Norsa
- */
-class LevelMenuModel {
- /*** Field ***/
-
- /** Level list. */
- //private List<String> levels;
-
- private Map<Dimension, List<String>> levels;
-
- /*** Constructor ***/
-
- /**
- * Constructor.
- *
- * @throws PicrossException if an error arises during the levels listing
- */
- LevelMenuModel() throws PicrossException {
- this.levels = new HashMap<Dimension, List<String>>();
-
- List<LevelInfo> infos = null;
-
- try {
- //this.levels = Picross.listDataFiles();
- infos = Picross.listDataFiles();
- } catch (IOException ioEx) {
- throw new PicrossException(ioEx);
- }
-
- for (LevelInfo info : infos) {
- Dimension levelSize = info.getDimension();
- List<String> levelsList = this.levels.get(levelSize);
-
- if (levelsList == null) {
- levelsList = new ArrayList<String>();
- this.levels.put(levelSize, levelsList);
- }
-
- levelsList.add(info.getName());
- }
- }
-
- /*** Method ***/
-
- /**
- * Returns the levels list.
- *
- * @return list of the level files
- */
- List<String> getLevels(Dimension size) {
- return this.levels.get(size);
- }
-
- List<Dimension> getSizesList() {
- return new ArrayList<Dimension>(this.levels.keySet());
- }
-}
-
Deleted: trunk/src/picross/menus/LevelMenuUI.java
===================================================================
--- trunk/src/picross/menus/LevelMenuUI.java 2008-04-28 08:58:35 UTC (rev 65)
+++ trunk/src/picross/menus/LevelMenuUI.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -1,111 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (c) 2008
- *
- * This software is governed by the CeCILL license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL license and that you accept its terms.
- */
-
-
-package picross.menus;
-
-import fr.cle.mmvcs.SimpleEvent;
-import fr.cle.mmvcs.SimpleListener;
-
-import java.awt.Dimension;
-
-import java.util.List;
-
-import picross.PicrossController;
-
-/**
- * UI for the level selection menu.
- *
- * @author Y. Norsa
- */
-class LevelMenuUI extends MenuUI {
- /*** Constant ***/
-
- /** Serialisation ID. */
- private static final long serialVersionUID = 6178785913505637523L;
-
- /*** Constructor ***/
-
- /**
- * Constructor.
- *
- * @param listener listener for the buttons
- * @param levels levels list
- */
- //LevelMenuUI(SimpleListener listener, List<String> levels) {
- LevelMenuUI(SimpleListener listener, List<Dimension> sizes) {
- super();
-
- int x = 150;
- int y = 150;
-
- int nbSizes = sizes.size();
-
- for (int i = 0; i < nbSizes; i++) {
- Dimension currentDim = sizes.get(i);
- String size = (int) currentDim.getWidth() + "x"
- + (int) currentDim.getHeight();
-
- SimpleEvent event = new SimpleEvent(new SelectSizeCommand(currentDim));
- this.addSimpleButton(size, event, listener, x, y);
-
- y += 75;
-
- if (y == 375) {
- x = 250;
- y = 150;
- }
- }
- }
-
- void displayLevels(SimpleListener listener, List<String> levels) {
- this.removeAll();
-
- int x = 50;
- int y = 150;
-
- for (String level : levels) {
- SimpleEvent event = new SimpleEvent(PicrossController.LEVEL_CMD, level);
- this.addSimpleButton(level, event, listener, x, y);
-
- y += 75;
-
- if (y == 375) {
- x = 250;
- y = 150;
- }
- }
-
- this.repaint();
- }
-}
-
Deleted: trunk/src/picross/menus/LevelsListCommand.java
===================================================================
--- trunk/src/picross/menus/LevelsListCommand.java 2008-04-28 08:58:35 UTC (rev 65)
+++ trunk/src/picross/menus/LevelsListCommand.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -1,69 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (c) 2008
- *
- * This software is governed by the CeCILL license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL license and that you accept its terms.
- */
-
-
-package picross.menus;
-
-import fr.cle.mmvcs.NamedCommand;
-
-import java.util.List;
-
-/**
- * @author Y. Norsa
- */
-class LevelsListCommand extends NamedCommand {
- /*** Constante ***/
-
- /*** Champ statique ***/
-
- /*** Champ ***/
-
- private List<String> list;
-
- /*** Constructeur ***/
-
- /**
- * Constructeur.
- */
- LevelsListCommand(List<String> levels) {
- super(LevelMenuController.LEVELS_LIST_CMD);
-
- this.list = levels;
- }
-
- /*** M\xE9thode ***/
-
- List<String> getList() {
- return this.list;
- }
-}
-
Modified: trunk/src/picross/menus/MenuController.java
===================================================================
--- trunk/src/picross/menus/MenuController.java 2008-04-28 08:58:35 UTC (rev 65)
+++ trunk/src/picross/menus/MenuController.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -44,7 +44,7 @@
/**
* @author Y. Norsa
*/
-class MenuController extends Controller implements ActionListener {
+public class MenuController extends Controller implements ActionListener {
private static Logger log = Logger.getLogger(MenuController.class);
private MenuUI view;
Modified: trunk/src/picross/menus/MenuMediator.java
===================================================================
--- trunk/src/picross/menus/MenuMediator.java 2008-04-28 08:58:35 UTC (rev 65)
+++ trunk/src/picross/menus/MenuMediator.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -65,7 +65,7 @@
* @param ui reference to the main UI
* @throws PicrossException if the instantiation of the view fails
*/
- MenuMediator(PicrossUI ui) throws PicrossException {
+ public MenuMediator(PicrossUI ui) throws PicrossException {
//MenuController controller = new MenuController();
MenuController controller = this.initController();
controller.addSimpleListener(this);
Modified: trunk/src/picross/menus/MenuUI.java
===================================================================
--- trunk/src/picross/menus/MenuUI.java 2008-04-28 08:58:35 UTC (rev 65)
+++ trunk/src/picross/menus/MenuUI.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -60,7 +60,7 @@
*
* @author Y. Norsa
*/
-abstract class MenuUI extends JPanel {
+public abstract class MenuUI extends JPanel {
/*** Constants ***/
/** Background image. */
@@ -85,7 +85,7 @@
/*** Constructor ***/
/** Constructor. */
- MenuUI() {
+ public MenuUI() {
try {
ImageIcon icon = Picross.getImage(MenuUI.BACKGROUND_IMAGE);
this.setPreferredSize(new Dimension(icon.getIconWidth(),
Deleted: trunk/src/picross/menus/SelectSizeCommand.java
===================================================================
--- trunk/src/picross/menus/SelectSizeCommand.java 2008-04-28 08:58:35 UTC (rev 65)
+++ trunk/src/picross/menus/SelectSizeCommand.java 2008-04-28 09:07:21 UTC (rev 66)
@@ -1,69 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (c) 2008
- *
- * This software is governed by the CeCILL license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL license and that you accept its terms.
- */
-
-
-package picross.menus;
-
-import fr.cle.mmvcs.NamedCommand;
-
-import java.awt.Dimension;
-
-/**
- * @author Y. Norsa
- */
-class SelectSizeCommand extends NamedCommand {
- /*** Constante ***/
-
- /*** Champ statique ***/
-
- /*** Champ ***/
-
- private Dimension size;
-
- /*** Constructeur ***/
-
- /**
- * Constructeur.
- */
- SelectSizeCommand(Dimension dim) {
- super(LevelMenuController.SIZE_CMD);
-
- this.size = dim;
- }
-
- /*** M\xE9thode ***/
-
- Dimension getSize() {
- return this.size;
- }
-}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-28 08:58:29
|
Revision: 65
http://picross.svn.sourceforge.net/picross/?rev=65&view=rev
Author: yvan_norsa
Date: 2008-04-28 01:58:35 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
added some XBM files
Modified Paths:
--------------
trunk/data/contents.txt
Added Paths:
-----------
trunk/data/apple.xbm
trunk/data/asterix.xbm
trunk/data/xmas_tree.xbm
Added: trunk/data/apple.xbm
===================================================================
--- trunk/data/apple.xbm (rev 0)
+++ trunk/data/apple.xbm 2008-04-28 08:58:35 UTC (rev 65)
@@ -0,0 +1,6 @@
+#define apples_width 16
+#define apples_height 16
+static char apples_bits[] = {
+ 0x00, 0x00, 0x00, 0x04, 0x00, 0x06, 0x00, 0x03, 0x30, 0x09, 0xf8, 0x1f,
+ 0xfc, 0x1f, 0xfc, 0x0f, 0xfc, 0x07, 0xfc, 0x07, 0xfc, 0x0f, 0xf8, 0x1f,
+ 0xf8, 0x0f, 0x30, 0x06, 0x00, 0x00, 0x00, 0x00};
Added: trunk/data/asterix.xbm
===================================================================
--- trunk/data/asterix.xbm (rev 0)
+++ trunk/data/asterix.xbm 2008-04-28 08:58:35 UTC (rev 65)
@@ -0,0 +1,6 @@
+#define noname_width 16
+#define noname_height 16
+static char noname_bits[] = {
+ 0x80,0x03,0xc0,0x07,0xc0,0x07,0xce,0x07,0x9f,0x73,0x9f,0xf9,0xbf,0xfd,0xfe,
+ 0xff,0xf8,0x7f,0xe0,0x03,0x70,0x07,0x7c,0x1f,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,
+ 0x1c,0x1c};
Modified: trunk/data/contents.txt
===================================================================
--- trunk/data/contents.txt 2008-04-24 13:36:06 UTC (rev 64)
+++ trunk/data/contents.txt 2008-04-28 08:58:35 UTC (rev 65)
@@ -1,3 +1,5 @@
+apple.xbm : 16x16
+asterix.xbm : 16x16
audio.xbm : 32x32
batman2.xbm : 32x32
bunny.xbm : 16x16
@@ -4,3 +6,4 @@
halloween.xbm : 16x16
squares.xbm : 16x16
star.xbm : 16x16
+xmas_tree.xbm : 32x32
Added: trunk/data/xmas_tree.xbm
===================================================================
--- trunk/data/xmas_tree.xbm (rev 0)
+++ trunk/data/xmas_tree.xbm 2008-04-28 08:58:35 UTC (rev 65)
@@ -0,0 +1,12 @@
+#define noname_width 32
+#define noname_height 32
+static char noname_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0xc0,0x01,
+ 0x00,0x00,0xe0,0x03,0x00,0x00,0xd8,0x0d,0x00,0x00,0x60,0x03,0x00,0x00,0xf0,
+ 0x07,0x00,0x00,0xd8,0x0d,0x00,0x00,0x7e,0x3f,0x00,0x00,0xf0,0x07,0x00,0x00,
+ 0xf0,0x07,0x00,0x00,0xe8,0x0b,0x00,0x00,0xbc,0x1e,0x00,0x00,0xfe,0x3f,0x00,
+ 0x80,0xfb,0xef,0x00,0x00,0xee,0x3b,0x00,0x00,0xbe,0x3e,0x00,0x00,0xff,0x7f,
+ 0x00,0xe0,0xfd,0xdf,0x03,0x80,0x6f,0xfb,0x00,0x80,0xff,0xff,0x00,0xc0,0xff,
+ 0xff,0x01,0xf0,0xff,0xff,0x07,0xfc,0xff,0xff,0x1f,0xf8,0x7d,0xdf,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x1f,0x00,0x00,0xf8,0x0f,0x00,0x00,0xf0,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-24 13:36:01
|
Revision: 64
http://picross.svn.sourceforge.net/picross/?rev=64&view=rev
Author: yvan_norsa
Date: 2008-04-24 06:36:06 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
support for more XBM files
Modified Paths:
--------------
trunk/data/contents.txt
trunk/src/picross/game/simple/XBMModel.java
trunk/src/picross/menus/LevelMenuUI.java
Added Paths:
-----------
trunk/data/star.xbm
Modified: trunk/data/contents.txt
===================================================================
--- trunk/data/contents.txt 2008-04-23 19:13:48 UTC (rev 63)
+++ trunk/data/contents.txt 2008-04-24 13:36:06 UTC (rev 64)
@@ -3,3 +3,4 @@
bunny.xbm : 16x16
halloween.xbm : 16x16
squares.xbm : 16x16
+star.xbm : 16x16
Added: trunk/data/star.xbm
===================================================================
--- trunk/data/star.xbm (rev 0)
+++ trunk/data/star.xbm 2008-04-24 13:36:06 UTC (rev 64)
@@ -0,0 +1,7 @@
+#define group_width 16
+#define group_height 16
+static char group_bits[] = {
+ 0x0, 0x0, 0x80, 0x1, 0x80, 0x1, 0xc0, 0x3,
+ 0xc0, 0x3, 0xff, 0xff, 0xfe, 0x7f, 0xfc, 0x3f,
+ 0xf8, 0x1f, 0xf0, 0xf, 0xf0, 0xf, 0xf8, 0x1f,
+ 0x78, 0x1e, 0x3c, 0x3c, 0xc, 0x30, 0x0, 0x0};
Modified: trunk/src/picross/game/simple/XBMModel.java
===================================================================
--- trunk/src/picross/game/simple/XBMModel.java 2008-04-23 19:13:48 UTC (rev 63)
+++ trunk/src/picross/game/simple/XBMModel.java 2008-04-24 13:36:06 UTC (rev 64)
@@ -148,12 +148,30 @@
String[] values = line.split(XBMModel.VALUE_SEPARATOR);
for (int i = 0; i < values.length; i++) {
- //XBMModel.log.debug("values[" + i + "] = "
- //+ values[i]);
+ if (values[i].contains(XBMModel.HEX_LEADING)) {
+ values[i] = values[i].trim();
- if (values[i].contains(XBMModel.HEX_LEADING)) {
+ //XBMModel.log.debug("values[" + i + "] = "
+ // + values[i]);
+
+ if ((values[i].length()
+ < XBMModel.VALUE_END_POS)
+ || !Character
+ .isLetterOrDigit(values[i]
+ .charAt(XBMModel
+ .VALUE_END_POS
+ - 1))) {
+ values[i] = values[i]
+ .substring(0,
+ XBMModel.VALUE_BEGINNING_POS)
+ + 0
+ + values[i]
+ .substring(XBMModel
+ .VALUE_BEGINNING_POS);
+ }
+
String byteStr =
- values[i].trim()
+ values[i]
.substring(XBMModel.VALUE_BEGINNING_POS,
XBMModel.VALUE_END_POS);
byteValues.add(byteStr);
Modified: trunk/src/picross/menus/LevelMenuUI.java
===================================================================
--- trunk/src/picross/menus/LevelMenuUI.java 2008-04-23 19:13:48 UTC (rev 63)
+++ trunk/src/picross/menus/LevelMenuUI.java 2008-04-24 13:36:06 UTC (rev 64)
@@ -90,7 +90,7 @@
void displayLevels(SimpleListener listener, List<String> levels) {
this.removeAll();
- int x = 150;
+ int x = 50;
int y = 150;
for (String level : levels) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-23 19:13:54
|
Revision: 63
http://picross.svn.sourceforge.net/picross/?rev=63&view=rev
Author: yvan_norsa
Date: 2008-04-23 12:13:48 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
fixed rollover and highlight end conditions
Modified Paths:
--------------
trunk/src/picross/grid/GridController.java
trunk/src/picross/grid/GridUI.java
Modified: trunk/src/picross/grid/GridController.java
===================================================================
--- trunk/src/picross/grid/GridController.java 2008-04-23 16:40:40 UTC (rev 62)
+++ trunk/src/picross/grid/GridController.java 2008-04-23 19:13:48 UTC (rev 63)
@@ -42,7 +42,7 @@
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
-//import org.apache.log4j.Logger;
+import org.apache.log4j.Logger;
/**
* Grid controller.
@@ -84,7 +84,7 @@
/*** Static field ***/
/** The class' logger. */
- //private static Logger log = Logger.getLogger(GridController.class);
+ private static Logger log = Logger.getLogger(GridController.class);
/*** Field ***/
@@ -133,7 +133,11 @@
public void mouseEntered(MouseEvent e) { }
/** {@inheritDoc} */
- public void mouseExited(MouseEvent e) { }
+ public void mouseExited(MouseEvent e) {
+ //GridController.log.debug("mouseExited()");
+ this.view.rolloverEnded();
+ this.view.highlightEnded();
+ }
/** {@inheritDoc} */
public void mousePressed(MouseEvent e) {
@@ -203,6 +207,8 @@
new FillCommand(row, column, type));
this.view.rolloverHighlight(row, column);
+ } else {
+ this.view.highlightEnded();
}
}
Modified: trunk/src/picross/grid/GridUI.java
===================================================================
--- trunk/src/picross/grid/GridUI.java 2008-04-23 16:40:40 UTC (rev 62)
+++ trunk/src/picross/grid/GridUI.java 2008-04-23 19:13:48 UTC (rev 63)
@@ -703,8 +703,18 @@
this.rollover = null;
this.repaint(rect);
}
+
+ this.highlightEnded();
}
+ void highlightEnded() {
+ this.repaintColHints(this.rolloverColumn);
+ this.repaintRowHints(this.rolloverRow);
+
+ this.rolloverColumn = -1;
+ this.rolloverRow = -1;
+ }
+
/** Repaints top hints. */
void repaintColHints(int col) {
if (col < 0 || col >= this.width) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-23 16:40:42
|
Revision: 62
http://picross.svn.sourceforge.net/picross/?rev=62&view=rev
Author: yvan_norsa
Date: 2008-04-23 09:40:40 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
updated applet HTML stuff
Modified Paths:
--------------
trunk/applet/index.html
Modified: trunk/applet/index.html
===================================================================
--- trunk/applet/index.html 2008-04-23 12:05:30 UTC (rev 61)
+++ trunk/applet/index.html 2008-04-23 16:40:40 UTC (rev 62)
@@ -8,7 +8,7 @@
<body>
<h1>Picross</h1>
- <!--"CONVERTED_APPLET"-->
+<!--"CONVERTED_APPLET"-->
<!-- HTML CONVERTER -->
<script language="JavaScript" type="text/javascript"><!--
var _info = navigator.userAgent;
@@ -24,9 +24,9 @@
</comment>
<script language="JavaScript" type="text/javascript"><!--
- if (_ie == true) document.writeln('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "900" HEIGHT = "900" codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,3"><noembed><xmp>');
+ if (_ie == true) document.writeln('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "900" HEIGHT = "900" codebase="http://java.sun.com/update/1.6.0/jinstall-6u60-windows-i586.cab#Version=6,0,0,2"><noembed><xmp>');
else if (_ns == true && _ns6 == false) document.writeln('<embed ' +
- 'type="application/x-java-applet;version=1.5" \
+ 'type="application/x-java-applet;version=1.6" \
CODE = "picross.applet.PicrossApplet" \
ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar,simpleButton.jar" \
WIDTH = "900" \
@@ -37,7 +37,7 @@
<applet CODE = "picross.applet.PicrossApplet" ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar,simpleButton.jar" WIDTH = "900" HEIGHT = "900"></xmp>
<PARAM NAME = CODE VALUE = "picross.applet.PicrossApplet" >
<PARAM NAME = ARCHIVE VALUE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar,simpleButton.jar" >
- <param name="type" value="application/x-java-applet;version=1.5">
+ <param name="type" value="application/x-java-applet;version=1.6">
<param name="scriptable" value="false">
@@ -45,6 +45,7 @@
</noembed>
</embed>
</object>
+
<!--
<APPLET CODE = "picross.applet.PicrossApplet" ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar,simpleButton.jar" WIDTH = "900" HEIGHT = "900">
@@ -52,6 +53,8 @@
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
+
+
<br />
<br />
<a href="http://sourceforge.net/projects/picross"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=197480&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></a>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-23 12:05:23
|
Revision: 61
http://picross.svn.sourceforge.net/picross/?rev=61&view=rev
Author: yvan_norsa
Date: 2008-04-23 05:05:30 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
size-based level selection ; dynamic game modes
Modified Paths:
--------------
trunk/build.xml
trunk/data/contents.txt
trunk/lib/mmvcs.jar
trunk/src/picross/Picross.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/game/GameMediator.java
trunk/src/picross/game/random/RandomGameMediator.java
trunk/src/picross/game/simple/SimpleGameMediator.java
trunk/src/picross/menus/GameMenuMediator.java
trunk/src/picross/menus/GameMenuUI.java
trunk/src/picross/menus/LevelMenuMediator.java
trunk/src/picross/menus/LevelMenuModel.java
trunk/src/picross/menus/LevelMenuUI.java
trunk/src/picross/menus/MenuController.java
trunk/src/picross/menus/MenuMediator.java
trunk/src/picross/menus/MenuUI.java
Added Paths:
-----------
trunk/list_contents.sh
trunk/services/
trunk/services/picross.game.GameMode
trunk/src/picross/game/GameCommand.java
trunk/src/picross/game/GameMode.java
trunk/src/picross/game/random/RandomGameMode.java
trunk/src/picross/game/simple/FileInfo.java
trunk/src/picross/game/simple/LevelInfo.java
trunk/src/picross/game/simple/SimpleGameMode.java
trunk/src/picross/menus/GameMenuModel.java
trunk/src/picross/menus/LevelMenuController.java
trunk/src/picross/menus/LevelsListCommand.java
trunk/src/picross/menus/MenuCommand.java
trunk/src/picross/menus/SelectSizeCommand.java
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/build.xml 2008-04-23 12:05:30 UTC (rev 61)
@@ -95,6 +95,10 @@
<fileset dir="data" />
</copy>
+ <copy todir="${build.dir}/META-INF/services">
+ <fileset dir="services" />
+ </copy>
+
<jar destfile="${jar.name}"
basedir="${build.dir}" />
</target>
Modified: trunk/data/contents.txt
===================================================================
--- trunk/data/contents.txt 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/data/contents.txt 2008-04-23 12:05:30 UTC (rev 61)
@@ -1,5 +1,5 @@
-audio.xbm
-batman2.xbm
-bunny.xbm
-halloween.xbm
-squares.xbm
+audio.xbm : 32x32
+batman2.xbm : 32x32
+bunny.xbm : 16x16
+halloween.xbm : 16x16
+squares.xbm : 16x16
Modified: trunk/lib/mmvcs.jar
===================================================================
(Binary files differ)
Added: trunk/list_contents.sh
===================================================================
--- trunk/list_contents.sh (rev 0)
+++ trunk/list_contents.sh 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,10 @@
+#!/bin/tcsh
+
+set dest = data/contents.txt
+rm $dest
+
+foreach file (`ls data/*.xbm`)
+ set width = `awk '/width/ {print $3}' $file`
+ set height = `awk '/height/ {print $3}' $file`
+ echo "$file:t : $width"x"$height" >> $dest
+end
Property changes on: trunk/list_contents.sh
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/services/picross.game.GameMode
===================================================================
--- trunk/services/picross.game.GameMode (rev 0)
+++ trunk/services/picross.game.GameMode 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,2 @@
+picross.game.random.RandomGameMode
+picross.game.simple.SimpleGameMode
Modified: trunk/src/picross/Picross.java
===================================================================
--- trunk/src/picross/Picross.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/Picross.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -49,6 +49,9 @@
import org.apache.log4j.Logger;
+import picross.game.simple.FileInfo;
+import picross.game.simple.LevelInfo;
+
/**
* Helper class.
*
@@ -168,8 +171,10 @@
return Picross.getFile(Picross.DATA_DIR + name).openStream();
}
- public static List<String> listDataFiles() throws IOException {
- List<String> list = new ArrayList<String>();
+ //public static List<String> listDataFiles() throws IOException {
+ public static List<LevelInfo> listDataFiles() throws IOException {
+ //List<String> list = new ArrayList<String>();
+ List<LevelInfo> list = new ArrayList<LevelInfo>();
BufferedReader in = null;
@@ -179,7 +184,11 @@
String line = null;
while ((line = in.readLine()) != null) {
- list.add(line);
+ //list.add(line);
+ String[] lineData = line.split(":");
+ String[] sizeData = lineData[1].trim().split("x");
+
+ list.add(new FileInfo(lineData[0].trim(), Integer.parseInt(sizeData[0]), Integer.parseInt(sizeData[1])));
}
} catch (IOException ioEx) {
throw ioEx;
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/PicrossMediator.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -44,6 +44,7 @@
import org.apache.log4j.Logger;
+import picross.game.GameCommand;
import picross.game.GameMediator;
import picross.game.random.RandomGameMediator;
@@ -55,6 +56,7 @@
import picross.menus.GameMenuMediator;
import picross.menus.LevelMenuMediator;
import picross.menus.MainMenuMediator;
+import picross.menus.MenuCommand;
import picross.menus.MenuMediator;
import picross.menus.WaitMenuMediator;
@@ -106,11 +108,13 @@
return;
}
+ /*
if (cmd.equals(PicrossController.RANDOM_GAME_CMD)) {
this.displayWaitScreen();
this.startRandomGame();
return;
}
+ */
if (cmd.equals(PicrossController.NEXT_RANDOM_GAME_CMD)) {
this.startRandomGame();
@@ -122,12 +126,30 @@
return;
}
+ /*
if (cmd.equals(PicrossController.LEVEL_CMD)) {
this.displayWaitScreen();
this.startGame(e.getComment());
return;
}
+ */
+ if (cmd.equals("MENU_CMD")) {
+ MenuCommand command = (MenuCommand) e.getCommand();
+ this.displayMenu(command.getMenuClass());
+
+ return;
+ }
+
+ if (cmd.equals(GameCommand.GAME_CMD)) {
+ this.displayWaitScreen();
+
+ GameCommand command = (GameCommand) e.getCommand();
+ this.startGame(command.getGame());
+
+ return;
+ }
+
if (cmd.equals(PicrossController.EXIT_CMD)) {
this.exit();
return;
@@ -196,6 +218,24 @@
this.view.setContent(menu.getView());
}
+ private void startGame(final GameMediator game) {
+ Thread worker = new Thread() {
+ public void run() {
+ try {
+ //game = new RandomGameMediator();
+ game.start();
+ PicrossMediator.this.gameLoaded(game);
+ } catch (PicrossException picrossEx) {
+ PicrossMediator.this.view
+ .displayError(picrossEx.getMessage());
+ return;
+ }
+ }
+ };
+
+ worker.start();
+ }
+
/** Starts a random game. */
private void startRandomGame() {
Thread worker = new Thread() {
@@ -204,6 +244,7 @@
try {
game = new RandomGameMediator();
+ game.start();
PicrossMediator.this.gameLoaded(game);
} catch (PicrossException picrossEx) {
PicrossMediator.this.view
@@ -217,6 +258,7 @@
}
/** Starts a new game. */
+ /*
private void startGame(final String level) {
PicrossMediator.log.debug("startGame(" + level + ")");
@@ -241,6 +283,7 @@
worker.start();
}
+ */
/**
* Callback used to display the game view.
Added: trunk/src/picross/game/GameCommand.java
===================================================================
--- trunk/src/picross/game/GameCommand.java (rev 0)
+++ trunk/src/picross/game/GameCommand.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,69 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game;
+
+import fr.cle.mmvcs.NamedCommand;
+
+/**
+ * @author Y. Norsa
+ */
+public class GameCommand extends NamedCommand {
+ /*** Constante ***/
+
+ public static final String GAME_CMD = "GAME_CMD";
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private GameMediator game;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ public GameCommand(GameMediator gameMediator) {
+ super(GameCommand.GAME_CMD);
+
+ this.game = gameMediator;
+ }
+
+ /*** M\xE9thode ***/
+
+ public GameMediator getGame() {
+ return this.game;
+ }
+}
+
Property changes on: trunk/src/picross/game/GameCommand.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/game/GameMediator.java
===================================================================
--- trunk/src/picross/game/GameMediator.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/game/GameMediator.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -113,6 +113,10 @@
*/
protected abstract PicrossGrid initModel() throws PicrossException;
+ public void start() throws PicrossException {
+ this.init();
+ }
+
/*** Method overloaded from the class Mediator ***/
/** {@inheritDoc} */
Added: trunk/src/picross/game/GameMode.java
===================================================================
--- trunk/src/picross/game/GameMode.java (rev 0)
+++ trunk/src/picross/game/GameMode.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,46 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game;
+
+import fr.cle.core.gui.SimpleButton;
+
+import javax.swing.JButton;
+
+/**
+ * @author Y. Norsa
+ */
+public interface GameMode {
+ SimpleButton<JButton> getButton();
+}
+
Property changes on: trunk/src/picross/game/GameMode.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/game/random/RandomGameMediator.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMediator.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/game/random/RandomGameMediator.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -65,9 +65,9 @@
* @throws PicrossException if there is a problem loading the grid model
* or building the view
*/
- public RandomGameMediator() throws PicrossException {
+ public RandomGameMediator() {//throws PicrossException {
//super();
- this.init();
+ //this.init();
}
/*** Methods overloaded from the class GameMediator ***/
Added: trunk/src/picross/game/random/RandomGameMode.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMode.java (rev 0)
+++ trunk/src/picross/game/random/RandomGameMode.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,86 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.random;
+
+import fr.cle.core.gui.SimpleButton;
+
+import fr.cle.mmvcs.SimpleEvent;
+
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+
+import picross.Picross;
+
+import picross.game.GameMode;
+
+/**
+ * @author Y. Norsa
+ */
+public class RandomGameMode implements GameMode {
+ /*** Constante ***/
+
+ /** Image for the "random" button. */
+ private static final String RANDOM_BUTTON_IMAGE = "button-random.png";
+
+ /** "Random" button X coordinate. */
+ private static final int RANDOM_BUTTON_X = 150;
+
+ /** "Random" button Y coordinate. */
+ private static final int RANDOM_BUTTON_Y = 175;
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ RandomGameMode() {
+ }
+ */
+ /*** M\xE9thode ***/
+
+ public SimpleButton<JButton> getButton() {
+ ImageIcon icon = Picross.getLocalizedImage(RandomGameMode.RANDOM_BUTTON_IMAGE);
+ SimpleEvent event = new SimpleEvent(new picross.game.GameCommand(new RandomGameMediator()));
+ SimpleButton<JButton> button = new SimpleButton<JButton>(null, event) { };
+ button.getButton().setIcon(icon);
+
+ return button;
+ }
+}
+
Property changes on: trunk/src/picross/game/random/RandomGameMode.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/game/simple/FileInfo.java
===================================================================
--- trunk/src/picross/game/simple/FileInfo.java (rev 0)
+++ trunk/src/picross/game/simple/FileInfo.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,71 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.simple;
+
+import java.awt.Dimension;
+
+/**
+ * @author Y. Norsa
+ */
+public class FileInfo implements LevelInfo {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private String name;
+ private Dimension dimension;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ public FileInfo(String levelName, int width, int height) {
+ this.name = levelName;
+ this.dimension = new Dimension(width, height);
+ }
+
+ /*** M\xE9thode ***/
+
+ public String getName() {
+ return this.name;
+ }
+
+ public Dimension getDimension() {
+ return this.dimension;
+ }
+}
+
Property changes on: trunk/src/picross/game/simple/FileInfo.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/game/simple/LevelInfo.java
===================================================================
--- trunk/src/picross/game/simple/LevelInfo.java (rev 0)
+++ trunk/src/picross/game/simple/LevelInfo.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,45 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.simple;
+
+import java.awt.Dimension;
+
+/**
+ * @author Y. Norsa
+ */
+public interface LevelInfo {
+ String getName();
+ Dimension getDimension();
+}
+
Property changes on: trunk/src/picross/game/simple/LevelInfo.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/game/simple/SimpleGameMediator.java
===================================================================
--- trunk/src/picross/game/simple/SimpleGameMediator.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/game/simple/SimpleGameMediator.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -57,11 +57,11 @@
* @throws PicrossException if there is a problem loading the grid model
* or building the view
*/
- public SimpleGameMediator(String levelName) throws PicrossException {
+ public SimpleGameMediator(String levelName) {//throws PicrossException {
//super();
this.level = levelName;
- this.init();
+ //this.init();
}
/*** Method overloaded from the class GameMediator ***/
Added: trunk/src/picross/game/simple/SimpleGameMode.java
===================================================================
--- trunk/src/picross/game/simple/SimpleGameMode.java (rev 0)
+++ trunk/src/picross/game/simple/SimpleGameMode.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,88 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.simple;
+
+import fr.cle.core.gui.SimpleButton;
+
+import fr.cle.mmvcs.SimpleEvent;
+
+import picross.Picross;
+
+import picross.game.GameMode;
+
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+
+/**
+ * @author Y. Norsa
+ */
+public class SimpleGameMode implements GameMode {
+ /*** Constante ***/
+
+ /** Image for the "select" button. */
+ private static final String SELECT_BUTTON_IMAGE = "button-select.png";
+
+ /** "Select" button X coordinate. */
+ private static final int SELECT_BUTTON_X = 150;
+
+ /** "Select" button Y coordinate. */
+ private static final int SELECT_BUTTON_Y = 250;
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ SimpleGameMode() {
+ }
+ */
+
+ /*** M\xE9thode ***/
+
+ public SimpleButton<JButton> getButton() {
+ ImageIcon icon =
+ Picross.getLocalizedImage(SimpleGameMode.SELECT_BUTTON_IMAGE);
+ SimpleEvent event = new SimpleEvent(new picross.menus.MenuCommand(picross.menus.LevelMenuMediator.class));
+ SimpleButton<JButton> button = new SimpleButton<JButton>("", event) { };
+ button.getButton().setIcon(icon);
+
+ return button;
+ }
+}
+
Property changes on: trunk/src/picross/game/simple/SimpleGameMode.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/menus/GameMenuMediator.java
===================================================================
--- trunk/src/picross/menus/GameMenuMediator.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/menus/GameMenuMediator.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -66,7 +66,7 @@
protected MenuUI initView(PicrossUI ui, MenuController controller)
throws PicrossException {
- return new GameMenuUI(controller);
+ return new GameMenuUI(controller, new GameMenuModel().getGameModes());
}
}
Added: trunk/src/picross/menus/GameMenuModel.java
===================================================================
--- trunk/src/picross/menus/GameMenuModel.java (rev 0)
+++ trunk/src/picross/menus/GameMenuModel.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,67 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+import picross.game.GameMode;
+
+/**
+ * @author Y. Norsa
+ */
+class GameMenuModel {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ GameMenuModel() {
+ }
+ */
+
+ /*** M\xE9thode ***/
+
+ /*Iterator*/ServiceLoader<GameMode> getGameModes() {
+ return ServiceLoader.load(GameMode.class);//.iterator();
+ }
+}
+
Property changes on: trunk/src/picross/menus/GameMenuModel.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/menus/GameMenuUI.java
===================================================================
--- trunk/src/picross/menus/GameMenuUI.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/menus/GameMenuUI.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -37,8 +37,14 @@
import java.io.FileNotFoundException;
+import java.util.Iterator;
+
+import org.apache.log4j.Logger;
+
import picross.PicrossController;
+import picross.game.GameMode;
+
/**
* UI for the game menu.
*
@@ -51,23 +57,25 @@
private static final long serialVersionUID = 4472277675596865332L;
/** Image for the "random" button. */
- private static final String RANDOM_BUTTON_IMAGE = "button-random.png";
+ //private static final String RANDOM_BUTTON_IMAGE = "button-random.png";
/** "Random" button X coordinate. */
- private static final int RANDOM_BUTTON_X = 150;
+ //private static final int RANDOM_BUTTON_X = 150;
/** "Random" button Y coordinate. */
- private static final int RANDOM_BUTTON_Y = 175;
+ //private static final int RANDOM_BUTTON_Y = 175;
/** Image for the "select" button. */
- private static final String SELECT_BUTTON_IMAGE = "button-select.png";
+ //private static final String SELECT_BUTTON_IMAGE = "button-select.png";
/** "Select" button X coordinate. */
- private static final int SELECT_BUTTON_X = 150;
+ //private static final int SELECT_BUTTON_X = 150;
/** "Select" button Y coordinate. */
- private static final int SELECT_BUTTON_Y = 250;
+ //private static final int SELECT_BUTTON_Y = 250;
+ private static Logger log = Logger.getLogger(GameMenuUI.class);
+
/*** Constructor ***/
/**
@@ -76,9 +84,10 @@
* @param listener listener for the buttons
* @throws MissingImageException if a button image can't be found
*/
- GameMenuUI(ActionListener listener) {
+ GameMenuUI(MenuController listener, /*Iterator*/java.util.ServiceLoader<GameMode> modes) {
super();
+ /*
this.addButton(GameMenuUI.RANDOM_BUTTON_IMAGE,
PicrossController.RANDOM_GAME_CMD,
listener,
@@ -87,6 +96,21 @@
PicrossController.SELECT_LEVEL_CMD,
listener,
GameMenuUI.SELECT_BUTTON_X, GameMenuUI.SELECT_BUTTON_Y);
+ */
+
+ int x = 150;
+ int y = 175;
+
+ //while (modes.hasNext()) {
+
+ GameMenuUI.log.debug("listing des modes...");
+
+ for (GameMode mode : modes) {
+ GameMenuUI.log.debug("mode : " + mode);
+ this.addButton(mode/*s.next()*/.getButton(), listener, x, y);
+
+ y += 75;
+ }
}
}
Added: trunk/src/picross/menus/LevelMenuController.java
===================================================================
--- trunk/src/picross/menus/LevelMenuController.java (rev 0)
+++ trunk/src/picross/menus/LevelMenuController.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,87 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import fr.cle.mmvcs.SimpleEvent;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author Y. Norsa
+ */
+class LevelMenuController extends MenuController {
+ /*** Constante ***/
+
+ static final String SIZE_CMD = "SIZE_CMD";
+
+ static final String LEVELS_LIST_CMD = "LEVELS_LIST_CMD";
+
+ /*** Champ statique ***/
+
+ private static Logger log = Logger.getLogger(LevelMenuController.class);
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ LevelMenuController() {
+ }
+ */
+
+ /*** M\xE9thode ***/
+
+ public void eventPerformed(SimpleEvent e) {
+ LevelMenuController.log.debug("eventPerformed(" + e + ")");
+
+ String cmd = e.getCommandName();
+
+ if (cmd.equals(picross.game.GameCommand.GAME_CMD)) {
+ return;
+ }
+
+ if (cmd.equals(LevelMenuController.LEVELS_LIST_CMD)) {
+ LevelsListCommand command = (LevelsListCommand) e.getCommand();
+ ((LevelMenuUI) this.getView()).displayLevels(this, command.getList());
+
+ return;
+ }
+
+ super.eventPerformed(e);
+ }
+}
+
Property changes on: trunk/src/picross/menus/LevelMenuController.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/menus/LevelMenuMediator.java
===================================================================
--- trunk/src/picross/menus/LevelMenuMediator.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/menus/LevelMenuMediator.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -33,6 +33,12 @@
package picross.menus;
+import fr.cle.mmvcs.SimpleEvent;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
import picross.PicrossException;
import picross.PicrossUI;
@@ -42,6 +48,10 @@
* @author Y. Norsa
*/
public class LevelMenuMediator extends MenuMediator {
+ private static Logger log = Logger.getLogger(LevelMenuMediator.class);
+
+ private LevelMenuModel model;
+
/*** Constructor ***/
/**
@@ -56,13 +66,45 @@
/*** Method overloaded from the class MenuMediator ***/
+ protected MenuController initController() {
+ MenuController controller = new LevelMenuController();
+ this.addSimpleListener(controller);
+
+ return controller;
+ }
+
/** {@inheritDoc} */
@Override
protected MenuUI initView(PicrossUI ui, MenuController controller)
throws PicrossException {
- LevelMenuModel model = new LevelMenuModel();
- return new LevelMenuUI(controller, model.getLevelsList());
+ this.model = new LevelMenuModel();
+ //return new LevelMenuUI(controller, model.getLevelsList());
+ return new LevelMenuUI(controller, this.model.getSizesList());
}
+
+ public void eventPerformed(SimpleEvent e) {
+ LevelMenuMediator.log.debug("eventPerformed(" + e + ")");
+
+ String cmd = e.getCommandName();
+
+ if (cmd.equals(LevelMenuController.SIZE_CMD)) {
+ SelectSizeCommand command = (SelectSizeCommand) e.getCommand();
+ this.displayLevels(this.model.getLevels(command.getSize()));
+
+ return;
+ }
+
+ if (cmd.equals(picross.PicrossController.LEVEL_CMD)) {
+ this.fireEventPerformed(new picross.game.GameCommand(new picross.game.simple.SimpleGameMediator(e.getComment())));
+ return;
+ }
+
+ super.eventPerformed(e);
+ }
+
+ private void displayLevels(List<String> levels) {
+ this.fireEventPerformed(new LevelsListCommand(levels));
+ }
}
Modified: trunk/src/picross/menus/LevelMenuModel.java
===================================================================
--- trunk/src/picross/menus/LevelMenuModel.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/menus/LevelMenuModel.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -33,13 +33,20 @@
package picross.menus;
+import java.awt.Dimension;
+
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import picross.Picross;
import picross.PicrossException;
+import picross.game.simple.LevelInfo;
+
/**
* Model for the level selection menu.
*
@@ -49,8 +56,10 @@
/*** Field ***/
/** Level list. */
- private List<String> levels;
+ //private List<String> levels;
+ private Map<Dimension, List<String>> levels;
+
/*** Constructor ***/
/**
@@ -59,11 +68,28 @@
* @throws PicrossException if an error arises during the levels listing
*/
LevelMenuModel() throws PicrossException {
+ this.levels = new HashMap<Dimension, List<String>>();
+
+ List<LevelInfo> infos = null;
+
try {
- this.levels = Picross.listDataFiles();
+ //this.levels = Picross.listDataFiles();
+ infos = Picross.listDataFiles();
} catch (IOException ioEx) {
throw new PicrossException(ioEx);
}
+
+ for (LevelInfo info : infos) {
+ Dimension levelSize = info.getDimension();
+ List<String> levelsList = this.levels.get(levelSize);
+
+ if (levelsList == null) {
+ levelsList = new ArrayList<String>();
+ this.levels.put(levelSize, levelsList);
+ }
+
+ levelsList.add(info.getName());
+ }
}
/*** Method ***/
@@ -73,8 +99,12 @@
*
* @return list of the level files
*/
- List<String> getLevelsList() {
- return this.levels;
+ List<String> getLevels(Dimension size) {
+ return this.levels.get(size);
}
+
+ List<Dimension> getSizesList() {
+ return new ArrayList<Dimension>(this.levels.keySet());
+ }
}
Modified: trunk/src/picross/menus/LevelMenuUI.java
===================================================================
--- trunk/src/picross/menus/LevelMenuUI.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/menus/LevelMenuUI.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -36,6 +36,8 @@
import fr.cle.mmvcs.SimpleEvent;
import fr.cle.mmvcs.SimpleListener;
+import java.awt.Dimension;
+
import java.util.List;
import picross.PicrossController;
@@ -59,15 +61,40 @@
* @param listener listener for the buttons
* @param levels levels list
*/
- LevelMenuUI(SimpleListener listener, List<String> levels) {
+ //LevelMenuUI(SimpleListener listener, List<String> levels) {
+ LevelMenuUI(SimpleListener listener, List<Dimension> sizes) {
super();
- int x = 50;
+ int x = 150;
int y = 150;
+ int nbSizes = sizes.size();
+
+ for (int i = 0; i < nbSizes; i++) {
+ Dimension currentDim = sizes.get(i);
+ String size = (int) currentDim.getWidth() + "x"
+ + (int) currentDim.getHeight();
+
+ SimpleEvent event = new SimpleEvent(new SelectSizeCommand(currentDim));
+ this.addSimpleButton(size, event, listener, x, y);
+
+ y += 75;
+
+ if (y == 375) {
+ x = 250;
+ y = 150;
+ }
+ }
+ }
+
+ void displayLevels(SimpleListener listener, List<String> levels) {
+ this.removeAll();
+
+ int x = 150;
+ int y = 150;
+
for (String level : levels) {
- SimpleEvent event = new SimpleEvent(PicrossController.LEVEL_CMD,
- level);
+ SimpleEvent event = new SimpleEvent(PicrossController.LEVEL_CMD, level);
this.addSimpleButton(level, event, listener, x, y);
y += 75;
@@ -77,6 +104,8 @@
y = 150;
}
}
+
+ this.repaint();
}
}
Added: trunk/src/picross/menus/LevelsListCommand.java
===================================================================
--- trunk/src/picross/menus/LevelsListCommand.java (rev 0)
+++ trunk/src/picross/menus/LevelsListCommand.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,69 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import fr.cle.mmvcs.NamedCommand;
+
+import java.util.List;
+
+/**
+ * @author Y. Norsa
+ */
+class LevelsListCommand extends NamedCommand {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private List<String> list;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ LevelsListCommand(List<String> levels) {
+ super(LevelMenuController.LEVELS_LIST_CMD);
+
+ this.list = levels;
+ }
+
+ /*** M\xE9thode ***/
+
+ List<String> getList() {
+ return this.list;
+ }
+}
+
Property changes on: trunk/src/picross/menus/LevelsListCommand.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/MenuCommand.java
===================================================================
--- trunk/src/picross/menus/MenuCommand.java (rev 0)
+++ trunk/src/picross/menus/MenuCommand.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,67 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import fr.cle.mmvcs.NamedCommand;
+
+/**
+ * @author Y. Norsa
+ */
+public class MenuCommand extends NamedCommand {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private Class<? extends MenuMediator> menuClass;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ public MenuCommand(Class<? extends MenuMediator> mediatorClass) {
+ super("MENU_CMD");
+
+ this.menuClass = mediatorClass;
+ }
+
+ /*** M\xE9thode ***/
+
+ public Class<? extends MenuMediator> getMenuClass() {
+ return this.menuClass;
+ }
+}
+
Property changes on: trunk/src/picross/menus/MenuCommand.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/menus/MenuController.java
===================================================================
--- trunk/src/picross/menus/MenuController.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/menus/MenuController.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -39,15 +39,23 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import org.apache.log4j.Logger;
+
/**
* @author Y. Norsa
*/
class MenuController extends Controller implements ActionListener {
+ private static Logger log = Logger.getLogger(MenuController.class);
+
+ private MenuUI view;
+
/*** Method overloaded from the class Controller ***/
/** {@inheritDoc} */
@Override
public void eventPerformed(SimpleEvent e) {
+ MenuController.log.debug("eventPerformed(" + e + ")");
+
this.fireEventPerformed(e);
}
@@ -58,5 +66,13 @@
String cmd = e.getActionCommand();
this.fireEventPerformed(cmd);
}
+
+ void setView(MenuUI ui) {
+ this.view = ui;
+ }
+
+ protected MenuUI getView() {
+ return this.view;
+ }
}
Modified: trunk/src/picross/menus/MenuMediator.java
===================================================================
--- trunk/src/picross/menus/MenuMediator.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/menus/MenuMediator.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -66,12 +66,20 @@
* @throws PicrossException if the instantiation of the view fails
*/
MenuMediator(PicrossUI ui) throws PicrossException {
- MenuController controller = new MenuController();
+ //MenuController controller = new MenuController();
+ MenuController controller = this.initController();
controller.addSimpleListener(this);
this.view = this.initView(ui, controller);
+
+ MenuMediator.log.debug("controller.setView()");
+ controller.setView(this.view);
}
+ protected MenuController initController() {
+ return new MenuController();
+ }
+
/*** Abstract method ***/
/**
Modified: trunk/src/picross/menus/MenuUI.java
===================================================================
--- trunk/src/picross/menus/MenuUI.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/menus/MenuUI.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -151,6 +151,13 @@
this.putButton(button.getButton(), x, y, 150, 50);
}
+ protected void addButton(SimpleButton<JButton> button, SimpleListener listener,
+ int x, int y) {
+ button.addSimpleListener(listener);
+ button.getButton().setBorder(null);
+ this.putButton(button.getButton(), x, y, button.getButton().getIcon().getIconWidth(), button.getButton().getIcon().getIconHeight());
+ }
+
private void putButton(JButton button, int x, int y, int width, int height) {
button.setBounds(x, y, width, height);
this.add(button);
Added: trunk/src/picross/menus/SelectSizeCommand.java
===================================================================
--- trunk/src/picross/menus/SelectSizeCommand.java (rev 0)
+++ trunk/src/picross/menus/SelectSizeCommand.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,69 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import fr.cle.mmvcs.NamedCommand;
+
+import java.awt.Dimension;
+
+/**
+ * @author Y. Norsa
+ */
+class SelectSizeCommand extends NamedCommand {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private Dimension size;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ SelectSizeCommand(Dimension dim) {
+ super(LevelMenuController.SIZE_CMD);
+
+ this.size = dim;
+ }
+
+ /*** M\xE9thode ***/
+
+ Dimension getSize() {
+ return this.size;
+ }
+}
+
Property changes on: trunk/src/picross/menus/SelectSizeCommand.java
___________________________________________________________________
Name: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-22 12:46:13
|
Revision: 60
http://picross.svn.sourceforge.net/picross/?rev=60&view=rev
Author: yvan_norsa
Date: 2008-04-22 05:46:19 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
loading screen
Modified Paths:
--------------
trunk/src/picross/PicrossController.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/game/random/RandomGameController.java
trunk/src/picross/game/random/RandomGameMediator.java
Added Paths:
-----------
trunk/images/en/label-wait.png
trunk/images/fr/label-wait.png
trunk/src/picross/menus/WaitMenuMediator.java
trunk/src/picross/menus/WaitMenuUI.java
Added: trunk/images/en/label-wait.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/en/label-wait.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/images/fr/label-wait.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/fr/label-wait.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/picross/PicrossController.java
===================================================================
--- trunk/src/picross/PicrossController.java 2008-04-22 12:23:45 UTC (rev 59)
+++ trunk/src/picross/PicrossController.java 2008-04-22 12:46:19 UTC (rev 60)
@@ -52,6 +52,8 @@
/** Random game command. */
public static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD";
+ public static final String NEXT_RANDOM_GAME_CMD = "NEXT_RANDOM_GAME_CMD";
+
/** Select level command. */
public static final String SELECT_LEVEL_CMD = "SELECT_LEVEL_CMD";
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2008-04-22 12:23:45 UTC (rev 59)
+++ trunk/src/picross/PicrossMediator.java 2008-04-22 12:46:19 UTC (rev 60)
@@ -56,6 +56,7 @@
import picross.menus.LevelMenuMediator;
import picross.menus.MainMenuMediator;
import picross.menus.MenuMediator;
+import picross.menus.WaitMenuMediator;
/**
* Application mediator.
@@ -106,16 +107,23 @@
}
if (cmd.equals(PicrossController.RANDOM_GAME_CMD)) {
+ this.displayWaitScreen();
this.startRandomGame();
return;
}
+ if (cmd.equals(PicrossController.NEXT_RANDOM_GAME_CMD)) {
+ this.startRandomGame();
+ return;
+ }
+
if (cmd.equals(PicrossController.SELECT_LEVEL_CMD)) {
this.displaySelectLevelMenu();
return;
}
if (cmd.equals(PicrossController.LEVEL_CMD)) {
+ this.displayWaitScreen();
this.startGame(e.getComment());
return;
}
@@ -150,6 +158,10 @@
this.displayMenu(LevelMenuMediator.class);
}
+ private void displayWaitScreen() {
+ this.displayMenu(WaitMenuMediator.class);
+ }
+
/**
* Helper method to display a menu.
*
Modified: trunk/src/picross/game/random/RandomGameController.java
===================================================================
--- trunk/src/picross/game/random/RandomGameController.java 2008-04-22 12:23:45 UTC (rev 59)
+++ trunk/src/picross/game/random/RandomGameController.java 2008-04-22 12:46:19 UTC (rev 60)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
Modified: trunk/src/picross/game/random/RandomGameMediator.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMediator.java 2008-04-22 12:23:45 UTC (rev 59)
+++ trunk/src/picross/game/random/RandomGameMediator.java 2008-04-22 12:46:19 UTC (rev 60)
@@ -93,7 +93,7 @@
String cmd = e.getCommandName();
if (cmd.equals(RandomGameController.NEXT_CMD)) {
- this.fireEventPerformed(PicrossController.RANDOM_GAME_CMD);
+ this.fireEventPerformed(PicrossController.NEXT_RANDOM_GAME_CMD);
return;
}
Added: trunk/src/picross/menus/WaitMenuMediator.java
===================================================================
--- trunk/src/picross/menus/WaitMenuMediator.java (rev 0)
+++ trunk/src/picross/menus/WaitMenuMediator.java 2008-04-22 12:46:19 UTC (rev 60)
@@ -0,0 +1,66 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import picross.PicrossException;
+import picross.PicrossUI;
+
+/**
+ * @author Y. Norsa
+ */
+public class WaitMenuMediator extends MenuMediator {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ public WaitMenuMediator(PicrossUI ui) throws PicrossException {
+ super(ui);
+ }
+
+ /*** M\xE9thode ***/
+
+ protected MenuUI initView(PicrossUI ui, MenuController controller)
+ throws PicrossException {
+
+ return new WaitMenuUI();
+ }
+}
+
Property changes on: trunk/src/picross/menus/WaitMenuMediator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/WaitMenuUI.java
===================================================================
--- trunk/src/picross/menus/WaitMenuUI.java (rev 0)
+++ trunk/src/picross/menus/WaitMenuUI.java 2008-04-22 12:46:19 UTC (rev 60)
@@ -0,0 +1,68 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+
+import picross.Picross;
+
+/**
+ * @author Y. Norsa
+ */
+class WaitMenuUI extends MenuUI {
+ /*** Constante ***/
+ static final long serialVersionUID = -6083373008192848638L;
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ WaitMenuUI() {
+ super();
+
+ ImageIcon labelIcon = Picross.getLocalizedImage("label-wait.png");
+ JLabel label = new JLabel(labelIcon);
+ label.setBorder(null);
+ label.setBounds(75, 225,
+ labelIcon.getIconWidth(), labelIcon.getIconHeight());
+ this.add(label);
+ }
+}
+
Property changes on: trunk/src/picross/menus/WaitMenuUI.java
___________________________________________________________________
Name: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-22 12:29:54
|
Revision: 59
http://picross.svn.sourceforge.net/picross/?rev=59&view=rev
Author: yvan_norsa
Date: 2008-04-22 05:23:45 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
wrong copyright
Modified Paths:
--------------
trunk/src/picross/grid/RepaintLeftHintsCommand.java
trunk/src/picross/grid/RepaintTopHintsCommand.java
Modified: trunk/src/picross/grid/RepaintLeftHintsCommand.java
===================================================================
--- trunk/src/picross/grid/RepaintLeftHintsCommand.java 2008-04-22 12:18:30 UTC (rev 58)
+++ trunk/src/picross/grid/RepaintLeftHintsCommand.java 2008-04-22 12:23:45 UTC (rev 59)
@@ -1,45 +1,33 @@
/*
* $Id$
- * \xC9crit le 22/04/2008 par Y. Norsa
*
* Copyright (c) 2008
- * Projet Carte Lorraine de l'Etudiant (CLE)
*
- * Universit\xE9 Henri Poincar\xE9, Nancy
- * Universit\xE9 Nancy2
- * Institut National Polytechnique de Lorraine
- * Universit\xE9 Paul Verlaine, Metz
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
*
- * Ce projet regroupe les d\xE9veloppements concernant la production
- * et l'exploitation de la Carte Lorraine de l'Etudiant
- * (carte \xE0 puce sans contact Mifare).
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
*
- * Ce logiciel est r\xE9gi par la licence CeCILL soumise au droit fran\xE7ais et
- * respectant les principes de diffusion des logiciels libres. Vous pouvez
- * utiliser, modifier et/ou redistribuer ce programme sous les conditions
- * de la licence CeCILL telle que diffus\xE9e par le CEA, le CNRS et l'INRIA
- * sur le site "http://www.cecill.info".
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
*
- * En contrepartie de l'accessibilit\xE9 au code source et des droits de copie,
- * de modification et de redistribution accord\xE9s par cette licence, il n'est
- * offert aux utilisateurs qu'une garantie limit\xE9e. Pour les m\xEAmes raisons,
- * seule une responsabilit\xE9 restreinte p\xE8se sur l'auteur du programme, le
- * titulaire des droits patrimoniaux et les conc\xE9dants successifs.
- *
- * A cet \xE9gard l'attention de l'utilisateur est attir\xE9e sur les risques
- * associ\xE9s au chargement, \xE0 l'utilisation, \xE0 la modification et/ou au
- * d\xE9veloppement et \xE0 la reproduction du logiciel par l'utilisateur \xE9tant
- * donn\xE9 sa sp\xE9cificit\xE9 de logiciel libre, qui peut le rendre complexe \xE0
- * manipuler et qui le r\xE9serve donc \xE0 des d\xE9veloppeurs et des professionnels
- * avertis poss\xE9dant des connaissances informatiques approfondies. Les
- * utilisateurs sont donc invit\xE9s \xE0 charger et tester l'ad\xE9quation du
- * logiciel \xE0 leurs besoins dans des conditions permettant d'assurer la
- * s\xE9curit\xE9 de leurs syst\xE8mes et ou de leurs donn\xE9es et, plus g\xE9n\xE9ralement,
- * \xE0 l'utiliser et l'exploiter dans les m\xEAmes conditions de s\xE9curit\xE9.
- *
- * Le fait que vous puissiez acc\xE9der \xE0 cet en-t\xEAte signifie que vous avez
- * pris connaissance de la licence CeCILL, et que vous en avez accept\xE9 les
- * termes.
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
*/
Modified: trunk/src/picross/grid/RepaintTopHintsCommand.java
===================================================================
--- trunk/src/picross/grid/RepaintTopHintsCommand.java 2008-04-22 12:18:30 UTC (rev 58)
+++ trunk/src/picross/grid/RepaintTopHintsCommand.java 2008-04-22 12:23:45 UTC (rev 59)
@@ -1,45 +1,33 @@
/*
* $Id$
- * \xC9crit le 22/04/2008 par Y. Norsa
*
* Copyright (c) 2008
- * Projet Carte Lorraine de l'Etudiant (CLE)
*
- * Universit\xE9 Henri Poincar\xE9, Nancy
- * Universit\xE9 Nancy2
- * Institut National Polytechnique de Lorraine
- * Universit\xE9 Paul Verlaine, Metz
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
*
- * Ce projet regroupe les d\xE9veloppements concernant la production
- * et l'exploitation de la Carte Lorraine de l'Etudiant
- * (carte \xE0 puce sans contact Mifare).
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
*
- * Ce logiciel est r\xE9gi par la licence CeCILL soumise au droit fran\xE7ais et
- * respectant les principes de diffusion des logiciels libres. Vous pouvez
- * utiliser, modifier et/ou redistribuer ce programme sous les conditions
- * de la licence CeCILL telle que diffus\xE9e par le CEA, le CNRS et l'INRIA
- * sur le site "http://www.cecill.info".
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
*
- * En contrepartie de l'accessibilit\xE9 au code source et des droits de copie,
- * de modification et de redistribution accord\xE9s par cette licence, il n'est
- * offert aux utilisateurs qu'une garantie limit\xE9e. Pour les m\xEAmes raisons,
- * seule une responsabilit\xE9 restreinte p\xE8se sur l'auteur du programme, le
- * titulaire des droits patrimoniaux et les conc\xE9dants successifs.
- *
- * A cet \xE9gard l'attention de l'utilisateur est attir\xE9e sur les risques
- * associ\xE9s au chargement, \xE0 l'utilisation, \xE0 la modification et/ou au
- * d\xE9veloppement et \xE0 la reproduction du logiciel par l'utilisateur \xE9tant
- * donn\xE9 sa sp\xE9cificit\xE9 de logiciel libre, qui peut le rendre complexe \xE0
- * manipuler et qui le r\xE9serve donc \xE0 des d\xE9veloppeurs et des professionnels
- * avertis poss\xE9dant des connaissances informatiques approfondies. Les
- * utilisateurs sont donc invit\xE9s \xE0 charger et tester l'ad\xE9quation du
- * logiciel \xE0 leurs besoins dans des conditions permettant d'assurer la
- * s\xE9curit\xE9 de leurs syst\xE8mes et ou de leurs donn\xE9es et, plus g\xE9n\xE9ralement,
- * \xE0 l'utiliser et l'exploiter dans les m\xEAmes conditions de s\xE9curit\xE9.
- *
- * Le fait que vous puissiez acc\xE9der \xE0 cet en-t\xEAte signifie que vous avez
- * pris connaissance de la licence CeCILL, et que vous en avez accept\xE9 les
- * termes.
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-22 12:19:07
|
Revision: 58
http://picross.svn.sourceforge.net/picross/?rev=58&view=rev
Author: yvan_norsa
Date: 2008-04-22 05:18:30 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
highlight current row and column
Modified Paths:
--------------
trunk/lib/mmvcs.jar
trunk/src/picross/grid/GridController.java
trunk/src/picross/grid/GridMediator.java
trunk/src/picross/grid/GridModel.java
trunk/src/picross/grid/GridUI.java
trunk/src/picross/grid/IGridMediator.java
trunk/src/picross/grid/tests/IGridMediatorStub.java
Added Paths:
-----------
trunk/src/picross/grid/RepaintLeftHintsCommand.java
trunk/src/picross/grid/RepaintTopHintsCommand.java
Modified: trunk/lib/mmvcs.jar
===================================================================
(Binary files differ)
Modified: trunk/src/picross/grid/GridController.java
===================================================================
--- trunk/src/picross/grid/GridController.java 2008-04-18 12:58:30 UTC (rev 57)
+++ trunk/src/picross/grid/GridController.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -112,12 +112,14 @@
}
if (cmd.equals(GridController.REPAINT_TOP_HINTS_CMD)) {
- this.view.repaintColHints();
+ int col = ((RepaintTopHintsCommand) e.getCommand()).getColumn();
+ this.view.repaintColHints(col);
return;
}
if (cmd.equals(GridController.REPAINT_LEFT_HINTS_CMD)) {
- this.view.repaintRowHints();
+ int row = ((RepaintLeftHintsCommand) e.getCommand()).getRow();
+ this.view.repaintRowHints(row);
return;
}
}
@@ -200,6 +202,7 @@
this.fireEventPerformed(GridController.FILL_CMD,
new FillCommand(row, column, type));
+ this.view.rolloverHighlight(row, column);
}
}
Modified: trunk/src/picross/grid/GridMediator.java
===================================================================
--- trunk/src/picross/grid/GridMediator.java 2008-04-18 12:58:30 UTC (rev 57)
+++ trunk/src/picross/grid/GridMediator.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -157,13 +157,15 @@
}
/** Asks to repaint the column hints. */
- public void repaintColHints() {
- this.fireEventPerformed(GridController.REPAINT_TOP_HINTS_CMD);
+ public void repaintColHints(int column) {
+ this.fireEventPerformed(//GridController.REPAINT_TOP_HINTS_CMD);
+ new RepaintTopHintsCommand(column));
}
/** Asks to repaint the row hints. */
- public void repaintRowHints() {
- this.fireEventPerformed(GridController.REPAINT_LEFT_HINTS_CMD);
+ public void repaintRowHints(int row) {
+ this.fireEventPerformed(//GridController.REPAINT_LEFT_HINTS_CMD);
+ new RepaintLeftHintsCommand(row));
}
/*** Accessor ***/
Modified: trunk/src/picross/grid/GridModel.java
===================================================================
--- trunk/src/picross/grid/GridModel.java 2008-04-18 12:58:30 UTC (rev 57)
+++ trunk/src/picross/grid/GridModel.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -581,7 +581,7 @@
this.completedHints.setCompleteRowHint(row, index);
}
- this.mediator.repaintRowHints();
+ this.mediator.repaintRowHints(row);
}
/**
@@ -748,7 +748,7 @@
this.completedHints.setCompleteColHint(column, index);
}
- this.mediator.repaintColHints();
+ this.mediator.repaintColHints(column);
}
/** Checks wether the grid is finished. */
Modified: trunk/src/picross/grid/GridUI.java
===================================================================
--- trunk/src/picross/grid/GridUI.java 2008-04-18 12:58:30 UTC (rev 57)
+++ trunk/src/picross/grid/GridUI.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -151,17 +151,17 @@
/** Position of the bottom end of the grid. */
private int bottomBoundary;
- /** Rectangle occupied by the top hints. */
- private Rectangle topHintsRect;
+ /** Rectangles occupied by the top hints. */
+ private Rectangle[] topHintsRects;
- /** Precomputed image containing the top hints boxes. */
- private transient BufferedImage topHintsBoxes;
+ /** Precomputed images containing the top hints boxes. */
+ private transient BufferedImage[] topHintsBoxes;
- /** Rectangle occupied by the left hints. */
- private Rectangle leftHintsRect;
+ /** Rectangles occupied by the left hints. */
+ private Rectangle[] leftHintsRects;
- /** Precomputed image containing the left hints boxes. */
- private transient BufferedImage leftHintsBoxes;
+ /** Precomputed images containing the left hints boxes. */
+ private transient BufferedImage[] leftHintsBoxes;
/** Current state of the grid. */
private transient Box[][] boxes;
@@ -253,12 +253,16 @@
Rectangle clipRect = newG.getClipBounds();
- if (this.topHintsRect.intersects(clipRect)) {
- this.drawTopHints(newG);
+ for (int i = 0; i < this.topHintsRects.length; i++) {
+ if (this.topHintsRects[i].intersects(clipRect)) {
+ this.drawTopHints(newG, i);
+ }
}
- if (this.leftHintsRect.intersects(clipRect)) {
- this.drawLeftHints(newG);
+ for (int i = 0; i < this.leftHintsRects.length; i++) {
+ if (this.leftHintsRects[i].intersects(clipRect)) {
+ this.drawLeftHints(newG, i);
+ }
}
// Paints the boxes
@@ -337,15 +341,22 @@
+ (this.height * GridUI.BOX_HEIGHT);
// Space occupied by the hints
+ this.topHintsRects = new Rectangle[this.width];
- this.topHintsRect = new Rectangle(this.leftBoundary, 0,
- this.width * GridUI.BOX_WIDTH,
- this.topBoundary);
- this.leftHintsRect = new Rectangle(0, this.topBoundary,
- this.leftBoundary,
- this.height
- * GridUI.BOX_HEIGHT);
+ for (int i = 0; i < this.topHintsRects.length; i++) {
+ this.topHintsRects[i] =
+ new Rectangle(this.leftBoundary + (i * GridUI.BOX_WIDTH), 0,
+ GridUI.BOX_WIDTH, this.topBoundary);
+ }
+ this.leftHintsRects = new Rectangle[this.height];
+
+ for (int i = 0; i < this.leftHintsRects.length; i++) {
+ this.leftHintsRects[i] =
+ new Rectangle(0, this.topBoundary + (i * GridUI.BOX_HEIGHT),
+ this.leftBoundary, GridUI.BOX_HEIGHT);
+ }
+
this.topHintsX = this.leftBoundary
+ (GridUI.BOX_WIDTH / 2) - (hintBoxWidth / 2);
@@ -446,27 +457,28 @@
* @param topHintsStart coordinate where the boxes begin
*/
private void initTopHints(int topHintsStart) {
- this.topHintsBoxes = new BufferedImage(this.topHintsRect.width,
- this.topHintsRect.height,
- BufferedImage.TYPE_INT_RGB);
- Graphics2D g2d = this.topHintsBoxes.createGraphics();
- g2d.setColor(Color.WHITE);
- g2d.fillRect(0, 0, this.topHintsRect.width, this.topHintsRect.height);
+ this.topHintsBoxes = new BufferedImage[this.width];
- int y = 0;
+ for (int k = 0; k < this.topHintsBoxes.length; k++) {
+ this.topHintsBoxes[k] =
+ new BufferedImage(GridUI.BOX_WIDTH, this.topBoundary,
+ BufferedImage.TYPE_INT_RGB);
- for (int i = this.colData[0].length - 1; i >= 0; i--) {
- int x = topHintsStart;
+ Graphics2D g2d = this.topHintsBoxes[k].createGraphics();
+ g2d.setColor(Color.WHITE);
+ g2d.fillRect(0, 0,
+ this.topHintsRects[k].width,
+ this.topHintsRects[k].height);
- for (int j = 0; j < this.colData.length; j++) {
- if (this.colData[j][i] != GridModel.EMPTY_HINT) {
- this.hintBoxIcon.paintIcon(this, g2d, x, y);
+ int y = 0;
+
+ for (int i = (this.colData[0].length - 1); i >= 0; i--) {
+ if (this.colData[k][i] != GridModel.EMPTY_HINT) {
+ this.hintBoxIcon.paintIcon(this, g2d, topHintsStart, y);
}
- x += GridUI.BOX_WIDTH;
+ y += this.topHintsDecal;
}
-
- y += this.topHintsDecal;
}
}
@@ -476,28 +488,28 @@
* @param leftHintsStart coordinate where the boxes begin
*/
private void initLeftHints(int leftHintsStart) {
- this.leftHintsBoxes = new BufferedImage(this.leftHintsRect.width,
- this.leftHintsRect.height,
- BufferedImage.TYPE_INT_RGB);
- Graphics2D g2d = this.leftHintsBoxes.createGraphics();
- g2d.setColor(Color.WHITE);
- g2d.fillRect(0, 0,
- this.leftHintsRect.width, this.leftHintsRect.height);
+ this.leftHintsBoxes = new BufferedImage[this.height];
- int y = leftHintsStart;
+ for (int k = 0; k < this.leftHintsBoxes.length; k++) {
+ this.leftHintsBoxes[k] =
+ new BufferedImage(this.leftBoundary, GridUI.BOX_HEIGHT,
+ BufferedImage.TYPE_INT_RGB);
- for (int i = 0; i < this.rowData.length; i++) {
+ Graphics2D g2d = this.leftHintsBoxes[k].createGraphics();
+ g2d.setColor(Color.WHITE);
+ g2d.fillRect(0, 0,
+ this.leftHintsRects[k].width,
+ this.leftHintsRects[k].height);
+
int x = 0;
- for (int j = 0; j < this.rowData[i].length; j++) {
- if (this.rowData[i][j] != GridModel.EMPTY_HINT) {
- this.hintBoxIcon.paintIcon(this, g2d, x, y);
+ for (int j = 0; j < this.rowData[k].length; j++) {
+ if (this.rowData[k][j] != GridModel.EMPTY_HINT) {
+ this.hintBoxIcon.paintIcon(this, g2d, x, leftHintsStart);
}
x += this.leftHintsDecal;
}
-
- y += GridUI.BOX_HEIGHT;
}
}
@@ -506,24 +518,23 @@
*
* @param g the graphics context
*/
- private void drawTopHints(Graphics g) {
- g.drawImage(this.topHintsBoxes,
- this.topHintsRect.x, this.topHintsRect.y, null);
+ private void drawTopHints(Graphics g, int col) {
+ //GridUI.log.debug("drawTopHints(g, " + col + ")");
+ g.drawImage(this.topHintsBoxes[col],
+ this.topHintsRects[col].x, this.topHintsRects[col].y,
+ null);
+
g.setFont(GridUI.HINT_FONT);
+ int x = topHintsX + (col * GridUI.BOX_WIDTH);
int y = 0;
for (int i = this.colData[0].length - 1; i >= 0; i--) {
- int x = this.topHintsX;
-
- for (int j = 0; j < this.colData.length; j++) {
- if (this.colData[j][i] != GridModel.EMPTY_HINT) {
- this.drawHint(g, this.colData[j][i], x, y,
- this.completedHints.isColHintComplete(j, i));
- }
-
- x += GridUI.BOX_WIDTH;
+ if (this.colData[col][i] != GridModel.EMPTY_HINT) {
+ this.drawHint(g, this.colData[col][i], x, y,
+ this.completedHints.isColHintComplete(col, i),
+ (this.rolloverColumn == col));
}
y += this.topHintsDecal;
@@ -535,27 +546,24 @@
*
* @param g the graphics context
*/
- private void drawLeftHints(Graphics g) {
- g.drawImage(this.leftHintsBoxes,
- this.leftHintsRect.x, this.leftHintsRect.y, null);
+ private void drawLeftHints(Graphics g, int row) {
+ g.drawImage(this.leftHintsBoxes[row],
+ this.leftHintsRects[row].x, this.leftHintsRects[row].y,
+ null);
g.setFont(GridUI.HINT_FONT);
- int y = this.leftHintsY;
+ int y = this.leftHintsY + (row * GridUI.BOX_HEIGHT);
+ int x = 0;
- for (int i = 0; i < this.rowData.length; i++) {
- int x = 0;
-
- for (int j = 0; j < this.rowData[i].length; j++) {
- if (this.rowData[i][j] != GridModel.EMPTY_HINT) {
- this.drawHint(g, this.rowData[i][j], x, y,
- this.completedHints.isRowHintComplete(i, j));
- }
-
- x += this.leftHintsDecal;
+ for (int j = 0; j < this.rowData[row].length; j++) {
+ if (this.rowData[row][j] != GridModel.EMPTY_HINT) {
+ this.drawHint(g, this.rowData[row][j], x, y,
+ this.completedHints.isRowHintComplete(row, j),
+ (this.rolloverRow == row));
}
- y += GridUI.BOX_HEIGHT;
+ x += this.leftHintsDecal;
}
}
@@ -568,11 +576,19 @@
* @param y Y coordinate
*/
private void drawHint(Graphics g, int value, int x, int y,
- boolean complete) {
- if (complete) {
- g.setColor(GridUI.COMPLETED_HINT_COLOR);
+ boolean complete, boolean rollover) {
+ if (!rollover) {
+ if (complete) {
+ g.setColor(GridUI.COMPLETED_HINT_COLOR);
+ } else {
+ g.setColor(GridUI.HINT_TEXT_COLOR);
+ }
} else {
- g.setColor(GridUI.HINT_TEXT_COLOR);
+ if (complete) {
+ g.setColor(new Color(255, 122, 0));
+ } else {
+ g.setColor(Color.ORANGE);
+ }
}
y += this.centerHintHeight;
@@ -643,6 +659,9 @@
this.repaint(this.boxes[column][row].getRect());
}
+ private int rolloverRow = -1;
+ private int rolloverColumn = -1;
+
/**
* Allows to set the current rolled-over box.
*
@@ -655,10 +674,25 @@
this.rolloverEnded();
this.rollover = this.boxes[column][row];
this.repaint(this.rollover.getRect());
+
+ this.rolloverHighlight(row, column);
}
+ void rolloverHighlight(int row, int column) {
+ if ((this.rolloverColumn != column) || (this.rolloverRow != row)) {
+ this.repaintColHints(this.rolloverColumn);
+ this.repaintRowHints(this.rolloverRow);
+
+ this.rolloverColumn = column;
+ this.rolloverRow = row;
+
+ this.repaintColHints(this.rolloverColumn);
+ this.repaintRowHints(this.rolloverRow);
+ }
+ }
+
/** Indicates that no box is currently rolled over. */
- void rolloverEnded() {
+ void rolloverEnded() {
if (this.rollover != null) {
/*
* Save the old rolled-over box so we can draw it
@@ -672,12 +706,20 @@
}
/** Repaints top hints. */
- void repaintColHints() {
- this.repaint(this.topHintsRect);
+ void repaintColHints(int col) {
+ if (col < 0 || col >= this.width) {
+ return;
+ }
+
+ this.repaint(this.topHintsRects[col]);
}
/** Repaints left hints. */
- void repaintRowHints() {
- this.repaint(this.leftHintsRect);
+ void repaintRowHints(int row) {
+ if (row < 0 || row >= this.height) {
+ return;
+ }
+
+ this.repaint(this.leftHintsRects[row]);
}
}
Modified: trunk/src/picross/grid/IGridMediator.java
===================================================================
--- trunk/src/picross/grid/IGridMediator.java 2008-04-18 12:58:30 UTC (rev 57)
+++ trunk/src/picross/grid/IGridMediator.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -46,10 +46,10 @@
void repaint(int row, int column);
/** Asks to repaint the column hints. */
- void repaintColHints();
+ void repaintColHints(int col);
/** Asks to repaint the row hints. */
- void repaintRowHints();
+ void repaintRowHints(int row);
/** Tells the application mediator the grid has been filled. */
void congratulations();
Added: trunk/src/picross/grid/RepaintLeftHintsCommand.java
===================================================================
--- trunk/src/picross/grid/RepaintLeftHintsCommand.java (rev 0)
+++ trunk/src/picross/grid/RepaintLeftHintsCommand.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -0,0 +1,79 @@
+/*
+ * $Id$
+ * \xC9crit le 22/04/2008 par Y. Norsa
+ *
+ * Copyright (c) 2008
+ * Projet Carte Lorraine de l'Etudiant (CLE)
+ *
+ * Universit\xE9 Henri Poincar\xE9, Nancy
+ * Universit\xE9 Nancy2
+ * Institut National Polytechnique de Lorraine
+ * Universit\xE9 Paul Verlaine, Metz
+ *
+ * Ce projet regroupe les d\xE9veloppements concernant la production
+ * et l'exploitation de la Carte Lorraine de l'Etudiant
+ * (carte \xE0 puce sans contact Mifare).
+ *
+ * Ce logiciel est r\xE9gi par la licence CeCILL soumise au droit fran\xE7ais et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffus\xE9e par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilit\xE9 au code source et des droits de copie,
+ * de modification et de redistribution accord\xE9s par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limit\xE9e. Pour les m\xEAmes raisons,
+ * seule une responsabilit\xE9 restreinte p\xE8se sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les conc\xE9dants successifs.
+ *
+ * A cet \xE9gard l'attention de l'utilisateur est attir\xE9e sur les risques
+ * associ\xE9s au chargement, \xE0 l'utilisation, \xE0 la modification et/ou au
+ * d\xE9veloppement et \xE0 la reproduction du logiciel par l'utilisateur \xE9tant
+ * donn\xE9 sa sp\xE9cificit\xE9 de logiciel libre, qui peut le rendre complexe \xE0
+ * manipuler et qui le r\xE9serve donc \xE0 des d\xE9veloppeurs et des professionnels
+ * avertis poss\xE9dant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invit\xE9s \xE0 charger et tester l'ad\xE9quation du
+ * logiciel \xE0 leurs besoins dans des conditions permettant d'assurer la
+ * s\xE9curit\xE9 de leurs syst\xE8mes et ou de leurs donn\xE9es et, plus g\xE9n\xE9ralement,
+ * \xE0 l'utiliser et l'exploiter dans les m\xEAmes conditions de s\xE9curit\xE9.
+ *
+ * Le fait que vous puissiez acc\xE9der \xE0 cet en-t\xEAte signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accept\xE9 les
+ * termes.
+ */
+
+
+package picross.grid;
+
+import fr.cle.mmvcs.NamedCommand;
+
+/**
+ * @author Y. Norsa
+ */
+class RepaintLeftHintsCommand extends NamedCommand {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private int row;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ RepaintLeftHintsCommand(int rowNumber) {
+ super(GridController.REPAINT_LEFT_HINTS_CMD);
+
+ this.row = rowNumber;
+ }
+
+ /*** M\xE9thode ***/
+
+ int getRow() {
+ return this.row;
+ }
+}
+
Property changes on: trunk/src/picross/grid/RepaintLeftHintsCommand.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/grid/RepaintTopHintsCommand.java
===================================================================
--- trunk/src/picross/grid/RepaintTopHintsCommand.java (rev 0)
+++ trunk/src/picross/grid/RepaintTopHintsCommand.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -0,0 +1,79 @@
+/*
+ * $Id$
+ * \xC9crit le 22/04/2008 par Y. Norsa
+ *
+ * Copyright (c) 2008
+ * Projet Carte Lorraine de l'Etudiant (CLE)
+ *
+ * Universit\xE9 Henri Poincar\xE9, Nancy
+ * Universit\xE9 Nancy2
+ * Institut National Polytechnique de Lorraine
+ * Universit\xE9 Paul Verlaine, Metz
+ *
+ * Ce projet regroupe les d\xE9veloppements concernant la production
+ * et l'exploitation de la Carte Lorraine de l'Etudiant
+ * (carte \xE0 puce sans contact Mifare).
+ *
+ * Ce logiciel est r\xE9gi par la licence CeCILL soumise au droit fran\xE7ais et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffus\xE9e par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilit\xE9 au code source et des droits de copie,
+ * de modification et de redistribution accord\xE9s par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limit\xE9e. Pour les m\xEAmes raisons,
+ * seule une responsabilit\xE9 restreinte p\xE8se sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les conc\xE9dants successifs.
+ *
+ * A cet \xE9gard l'attention de l'utilisateur est attir\xE9e sur les risques
+ * associ\xE9s au chargement, \xE0 l'utilisation, \xE0 la modification et/ou au
+ * d\xE9veloppement et \xE0 la reproduction du logiciel par l'utilisateur \xE9tant
+ * donn\xE9 sa sp\xE9cificit\xE9 de logiciel libre, qui peut le rendre complexe \xE0
+ * manipuler et qui le r\xE9serve donc \xE0 des d\xE9veloppeurs et des professionnels
+ * avertis poss\xE9dant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invit\xE9s \xE0 charger et tester l'ad\xE9quation du
+ * logiciel \xE0 leurs besoins dans des conditions permettant d'assurer la
+ * s\xE9curit\xE9 de leurs syst\xE8mes et ou de leurs donn\xE9es et, plus g\xE9n\xE9ralement,
+ * \xE0 l'utiliser et l'exploiter dans les m\xEAmes conditions de s\xE9curit\xE9.
+ *
+ * Le fait que vous puissiez acc\xE9der \xE0 cet en-t\xEAte signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accept\xE9 les
+ * termes.
+ */
+
+
+package picross.grid;
+
+import fr.cle.mmvcs.NamedCommand;
+
+/**
+ * @author Y. Norsa
+ */
+class RepaintTopHintsCommand extends NamedCommand {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private int column;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ RepaintTopHintsCommand(int col) {
+ super(GridController.REPAINT_TOP_HINTS_CMD);
+
+ this.column = col;
+ }
+
+ /*** M\xE9thode ***/
+
+ int getColumn() {
+ return this.column;
+ }
+}
+
Property changes on: trunk/src/picross/grid/RepaintTopHintsCommand.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/grid/tests/IGridMediatorStub.java
===================================================================
--- trunk/src/picross/grid/tests/IGridMediatorStub.java 2008-04-18 12:58:30 UTC (rev 57)
+++ trunk/src/picross/grid/tests/IGridMediatorStub.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -59,9 +59,9 @@
public void repaint(int row, int column) { }
- public void repaintColHints() { }
+ public void repaintColHints(int col) { }
- public void repaintRowHints() { }
+ public void repaintRowHints(int row) { }
public void congratulations() { }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-18 12:58:25
|
Revision: 57
http://picross.svn.sourceforge.net/picross/?rev=57&view=rev
Author: yvan_norsa
Date: 2008-04-18 05:58:30 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
cleanup
Modified Paths:
--------------
trunk/src/picross/grid/GridController.java
Modified: trunk/src/picross/grid/GridController.java
===================================================================
--- trunk/src/picross/grid/GridController.java 2008-04-18 12:58:07 UTC (rev 56)
+++ trunk/src/picross/grid/GridController.java 2008-04-18 12:58:30 UTC (rev 57)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -166,7 +166,6 @@
} else {
this.view.rolloverEnded();
}
-
}
/*** Methods ***/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-18 12:58:01
|
Revision: 56
http://picross.svn.sourceforge.net/picross/?rev=56&view=rev
Author: yvan_norsa
Date: 2008-04-18 05:58:07 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
marks empty rows and columns as completed
Modified Paths:
--------------
trunk/src/picross/grid/CompletedHints.java
trunk/src/picross/grid/GridModel.java
Modified: trunk/src/picross/grid/CompletedHints.java
===================================================================
--- trunk/src/picross/grid/CompletedHints.java 2008-04-18 11:55:47 UTC (rev 55)
+++ trunk/src/picross/grid/CompletedHints.java 2008-04-18 12:58:07 UTC (rev 56)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -152,6 +152,17 @@
}
/**
+ * Marks a whole column as complete.
+ *
+ * @param col column number
+ */
+ void setCompleteCol(int col) {
+ for (int i = 0; i < this.completedCols[col].length; i++) {
+ this.setCompleteColHint(col, i);
+ }
+ }
+
+ /**
* Tells wether a specific row hint is complete.
*
* @param x row number
@@ -190,7 +201,6 @@
return res;
}
-
/**
* Resets the state of a hint.
*
@@ -210,5 +220,16 @@
void setCompleteRowHint(int row, int index) {
this.completedRows[row][index] = true;
}
+
+ /**
+ * Marks a whole row as complete.
+ *
+ * @param row row number
+ */
+ void setCompleteRow(int row) {
+ for (int i = 0; i < this.completedRows[row].length; i++) {
+ this.setCompleteRowHint(row, i);
+ }
+ }
}
Modified: trunk/src/picross/grid/GridModel.java
===================================================================
--- trunk/src/picross/grid/GridModel.java 2008-04-18 11:55:47 UTC (rev 55)
+++ trunk/src/picross/grid/GridModel.java 2008-04-18 12:58:07 UTC (rev 56)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -36,7 +36,7 @@
import java.util.ArrayList;
import java.util.List;
-//import org.apache.log4j.Logger;
+import org.apache.log4j.Logger;
/**
* The grid model.
@@ -52,7 +52,7 @@
/*** Static field ***/
/** The class' logger. */
- //private static Logger log = Logger.getLogger(GridModel.class);
+ private static Logger log = Logger.getLogger(GridModel.class);
/*** Fields ***/
@@ -260,6 +260,20 @@
this.completedHints =
new CompletedHints(data.length, this.colData[0].length,
data[0].length, this.rowData[0].length);
+
+ // Marks the empty rows and columns as completed
+
+ for (int i = 0; i < this.rowData.length; i++) {
+ if (this.emptyRow(i)) {
+ this.completedHints.setCompleteRow(i);
+ }
+ }
+
+ for (int i = 0; i < this.colData.length; i++) {
+ if (this.emptyCol(i)) {
+ this.completedHints.setCompleteCol(i);
+ }
+ }
}
/*** Static methods ***/
@@ -414,11 +428,29 @@
}
/**
+ * Checks if a row is empty.
+ *
+ * @param row row number
+ * @return boolean stating wether the row is empty or not
+ */
+ private boolean emptyRow(int row) {
+ int index = this.getFirstHintIndex(this.rowData[row]);
+
+ return (index == this.getLastHintIndex(this.rowData[row]))
+ && (this.rowData[row][index] == 0);
+ }
+
+ /**
* Checks if a hint has been completed in a row.
*
* @param row row number to check
*/
private void checkRow(int row) {
+ if (this.emptyRow(row)) {
+ this.completedHints.setCompleteRow(row);
+ return;
+ }
+
// Contains the completed hints
List<Integer> completedRowHints = new ArrayList<Integer>();
@@ -553,6 +585,19 @@
}
/**
+ * Checks if a column is empty.
+ *
+ * @param col column number
+ * @return boolean stating wether the column is empty or not
+ */
+ private boolean emptyCol(int col) {
+ int index = this.getFirstHintIndex(this.colData[col]);
+
+ return (index == this.getLastHintIndex(this.colData[col]))
+ && (this.colData[col][index] == 0);
+ }
+
+ /**
* Checks if a hint has been completed in a column.
*
* @param column column number to check
@@ -560,6 +605,11 @@
private void checkColumn(int column) {
//GridModel.log.debug("checkColumn(" + column + ")");
+ if (this.emptyCol(column)) {
+ this.completedHints.setCompleteCol(column);
+ return;
+ }
+
List<Integer> completedColHints = new ArrayList<Integer>();
/*
for (int i = 0; i < this.colData[column].length; i++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-18 11:55:48
|
Revision: 55
http://picross.svn.sourceforge.net/picross/?rev=55&view=rev
Author: yvan_norsa
Date: 2008-04-18 04:55:47 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
new xbm files
Modified Paths:
--------------
trunk/data/contents.txt
trunk/src/picross/menus/LevelMenuUI.java
Added Paths:
-----------
trunk/data/audio.xbm
trunk/data/batman2.xbm
Added: trunk/data/audio.xbm
===================================================================
--- trunk/data/audio.xbm (rev 0)
+++ trunk/data/audio.xbm 2008-04-18 11:55:47 UTC (rev 55)
@@ -0,0 +1,12 @@
+#define audio_width 32
+#define audio_height 32
+static char audio_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0xc0,0x07,0x00,0x00,0xe0,
+ 0x07,0x00,0x00,0xf8,0x06,0x00,0x00,0x7c,0x06,0x00,0x00,0x1f,0x06,0x00,0x80,
+ 0x0f,0x06,0x00,0xe0,0x03,0x06,0x00,0xf0,0x01,0x06,0x00,0x30,0x00,0x06,0x00,
+ 0x30,0x00,0x06,0x00,0x30,0x00,0x06,0x00,0x30,0x00,0x06,0x00,0x30,0xf0,0x06,
+ 0x00,0x30,0xf8,0x07,0x00,0x30,0xfc,0x07,0x00,0x30,0xfe,0x07,0x00,0x30,0xfe,
+ 0x07,0x00,0x30,0xfe,0x07,0x00,0x30,0xfe,0x07,0x00,0x30,0xfc,0x03,0x80,0x37,
+ 0xf8,0x01,0xc0,0x3f,0xf0,0x00,0xe0,0x3f,0x00,0x00,0xf0,0x3f,0x00,0x00,0xf0,
+ 0x3f,0x00,0x00,0xf0,0x3f,0x00,0x00,0xf0,0x3f,0x00,0x00,0xe0,0x1f,0x00,0x00,
+ 0xc0,0x0f,0x00,0x00,0x80,0x07,0x00,0x00};
Added: trunk/data/batman2.xbm
===================================================================
--- trunk/data/batman2.xbm (rev 0)
+++ trunk/data/batman2.xbm 2008-04-18 11:55:47 UTC (rev 55)
@@ -0,0 +1,12 @@
+#define t/batman_width 32
+#define t/batman_height 32
+static char t/batman_bits[] = {
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0xf0,0xff,0xff,0x63,
+ 0xc6,0xff,0xff,0xd8,0x1b,0xff,0x3f,0xc7,0xe3,0xfc,0xbf,0xc3,0xc3,0xfd,0xdf,
+ 0xc3,0xc3,0xfb,0xef,0xc7,0xe3,0xf7,0xef,0xff,0xff,0xf7,0xe7,0xff,0xff,0xe7,
+ 0xf7,0xff,0xff,0xef,0xf7,0xff,0xff,0xef,0xf7,0xff,0xff,0xef,0xf7,0xff,0xff,
+ 0xef,0xf7,0xff,0xff,0xef,0xe7,0xff,0xff,0xe7,0xef,0xdd,0xbb,0xf7,0xef,0x88,
+ 0x11,0xf7,0xdf,0x89,0x91,0xfb,0xff,0x81,0x80,0xff,0x3f,0x83,0xc0,0xfc,0xff,
+ 0x8c,0x30,0xff,0xff,0xf3,0xcf,0xff,0xff,0x0f,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
Modified: trunk/data/contents.txt
===================================================================
--- trunk/data/contents.txt 2008-04-18 11:54:01 UTC (rev 54)
+++ trunk/data/contents.txt 2008-04-18 11:55:47 UTC (rev 55)
@@ -1,3 +1,5 @@
+audio.xbm
+batman2.xbm
bunny.xbm
halloween.xbm
squares.xbm
Modified: trunk/src/picross/menus/LevelMenuUI.java
===================================================================
--- trunk/src/picross/menus/LevelMenuUI.java 2008-04-18 11:54:01 UTC (rev 54)
+++ trunk/src/picross/menus/LevelMenuUI.java 2008-04-18 11:55:47 UTC (rev 55)
@@ -62,7 +62,7 @@
LevelMenuUI(SimpleListener listener, List<String> levels) {
super();
- int x = 150;
+ int x = 50;
int y = 150;
for (String level : levels) {
@@ -71,6 +71,11 @@
this.addSimpleButton(level, event, listener, x, y);
y += 75;
+
+ if (y == 375) {
+ x = 250;
+ y = 150;
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-18 11:54:00
|
Revision: 54
http://picross.svn.sourceforge.net/picross/?rev=54&view=rev
Author: yvan_norsa
Date: 2008-04-18 04:54:01 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
updated applet parameters
Modified Paths:
--------------
trunk/applet/index.html
Modified: trunk/applet/index.html
===================================================================
--- trunk/applet/index.html 2008-04-18 08:34:27 UTC (rev 53)
+++ trunk/applet/index.html 2008-04-18 11:54:01 UTC (rev 54)
@@ -28,15 +28,15 @@
else if (_ns == true && _ns6 == false) document.writeln('<embed ' +
'type="application/x-java-applet;version=1.5" \
CODE = "picross.applet.PicrossApplet" \
- ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar" \
+ ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar,simpleButton.jar" \
WIDTH = "900" \
HEIGHT = "900" ' +
'scriptable=false ' +
'pluginspage="http://java.sun.com/products/plugin/index.html#download"><noembed><xmp>');
//--></script>
-<applet CODE = "picross.applet.PicrossApplet" ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar" WIDTH = "900" HEIGHT = "900"></xmp>
+<applet CODE = "picross.applet.PicrossApplet" ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar,simpleButton.jar" WIDTH = "900" HEIGHT = "900"></xmp>
<PARAM NAME = CODE VALUE = "picross.applet.PicrossApplet" >
- <PARAM NAME = ARCHIVE VALUE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar" >
+ <PARAM NAME = ARCHIVE VALUE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar,simpleButton.jar" >
<param name="type" value="application/x-java-applet;version=1.5">
<param name="scriptable" value="false">
@@ -46,7 +46,7 @@
</embed>
</object>
<!--
-<APPLET CODE = "picross.applet.PicrossApplet" ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar" WIDTH = "900" HEIGHT = "900">
+<APPLET CODE = "picross.applet.PicrossApplet" ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar,simpleButton.jar" WIDTH = "900" HEIGHT = "900">
</APPLET>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-18 08:34:20
|
Revision: 53
http://picross.svn.sourceforge.net/picross/?rev=53&view=rev
Author: yvan_norsa
Date: 2008-04-18 01:34:27 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
pretty buttons
Modified Paths:
--------------
trunk/images/en/button-random.png
trunk/images/en/button-select.png
trunk/images/fr/button-random.png
trunk/images/fr/button-select.png
trunk/src/picross/menus/LevelMenuUI.java
trunk/src/picross/menus/MenuUI.java
Added Paths:
-----------
trunk/images/empty-button.png
Added: trunk/images/empty-button.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/empty-button.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/images/en/button-random.png
===================================================================
(Binary files differ)
Modified: trunk/images/en/button-select.png
===================================================================
(Binary files differ)
Modified: trunk/images/fr/button-random.png
===================================================================
(Binary files differ)
Modified: trunk/images/fr/button-select.png
===================================================================
(Binary files differ)
Modified: trunk/src/picross/menus/LevelMenuUI.java
===================================================================
--- trunk/src/picross/menus/LevelMenuUI.java 2008-04-18 07:42:20 UTC (rev 52)
+++ trunk/src/picross/menus/LevelMenuUI.java 2008-04-18 08:34:27 UTC (rev 53)
@@ -62,7 +62,7 @@
LevelMenuUI(SimpleListener listener, List<String> levels) {
super();
- int x = 50;
+ int x = 150;
int y = 150;
for (String level : levels) {
@@ -71,11 +71,6 @@
this.addSimpleButton(level, event, listener, x, y);
y += 75;
-
- if (y == 375) {
- x = 250;
- y = 150;
- }
}
}
}
Modified: trunk/src/picross/menus/MenuUI.java
===================================================================
--- trunk/src/picross/menus/MenuUI.java 2008-04-18 07:42:20 UTC (rev 52)
+++ trunk/src/picross/menus/MenuUI.java 2008-04-18 08:34:27 UTC (rev 53)
@@ -140,9 +140,14 @@
protected void addSimpleButton(String label, SimpleEvent event,
SimpleListener listener,
int x, int y) {
- SimpleButton<JButton> button = new SimpleButton<JButton>(label, event) { };
+ SimpleButton<JButton> button = new SimpleButton<JButton>(label,
+ event) { };
button.addSimpleListener(listener);
+ button.getButton().setIcon(Picross.getImage("empty-button.png"));
+ button.getButton().setHorizontalTextPosition(JButton.CENTER);
+ button.getButton().setVerticalTextPosition(JButton.CENTER);
+
this.putButton(button.getButton(), x, y, 150, 50);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-18 07:42:14
|
Revision: 52
http://picross.svn.sourceforge.net/picross/?rev=52&view=rev
Author: yvan_norsa
Date: 2008-04-18 00:42:20 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
level selection menu
Modified Paths:
--------------
trunk/build.xml
trunk/lib/mmvcs.jar
trunk/src/picross/Picross.java
trunk/src/picross/PicrossController.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/game/GameMediator.java
trunk/src/picross/game/random/RandomGameMediator.java
trunk/src/picross/game/simple/SimpleGameMediator.java
trunk/src/picross/menus/GameMenuUI.java
trunk/src/picross/menus/MenuController.java
trunk/src/picross/menus/MenuMediator.java
trunk/src/picross/menus/MenuUI.java
Added Paths:
-----------
trunk/data/contents.txt
trunk/images/en/button-select.png
trunk/images/fr/button-select.png
trunk/lib/simpleButton.jar
trunk/src/picross/menus/LevelMenuMediator.java
trunk/src/picross/menus/LevelMenuModel.java
trunk/src/picross/menus/LevelMenuUI.java
Removed Paths:
-------------
trunk/data/anchor.xbm
trunk/data/bart.xbm
trunk/data/blarg.xbm
trunk/data/candle.xbm
trunk/data/crab.xbm
trunk/data/ghost_left.xbm
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/build.xml 2008-04-18 07:42:20 UTC (rev 52)
@@ -27,6 +27,8 @@
value="${lib.dir}/log4j.jar" />
<property name="mmvcs.jar"
value="${lib.dir}/mmvcs.jar" />
+ <property name="simpleButton.jar"
+ value="${lib.dir}/simpleButton.jar" />
<target name="-init"
depends="-setmode">
@@ -62,6 +64,7 @@
<pathelement location="${junit.jar}" />
<pathelement location="${log4j.jar}" />
<pathelement location="${mmvcs.jar}" />
+ <pathelement location="${simpleButton.jar}" />
</path>
<target name="compile"
@@ -107,6 +110,7 @@
<pathelement location="${bundleHelper.jar}" />
<pathelement location="${log4j.jar}" />
<pathelement location="${mmvcs.jar}" />
+ <pathelement location="${simpleButton.jar}" />
</classpath>
</java>
</target>
@@ -123,6 +127,7 @@
<pathelement location="${log4j.jar}" />
<pathelement location="${mmvcs.jar}" />
<pathelement location="${debug.jar}" />
+ <pathelement location="${simpleButton.jar}" />
</classpath>
</java>
</target>
Deleted: trunk/data/anchor.xbm
===================================================================
--- trunk/data/anchor.xbm 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/data/anchor.xbm 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,6 +0,0 @@
-#define anchor.xbm_width 16
-#define anchor.xbm_height 16
-static char anchor.xbm_bits[] = {
- 0x00, 0x00, 0xe0, 0x07, 0xe0, 0x07, 0x80, 0x05, 0x80, 0x05, 0x80, 0x05,
- 0x80, 0x03, 0x80, 0x01, 0x9e, 0x79, 0x8e, 0x71, 0x8e, 0x71, 0x8a, 0x51,
- 0x90, 0x09, 0xe0, 0x07, 0x80, 0x01, 0x00, 0x00};
Deleted: trunk/data/bart.xbm
===================================================================
--- trunk/data/bart.xbm 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/data/bart.xbm 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,27 +0,0 @@
-#define noname_width 43
-#define noname_height 58
-static char noname_bits[] = {
- 0x00,0x00,0x00,0xc4,0x00,0x00,0x00,0x00,0xc0,0xca,0x00,0x00,0x00,0x00,0xc0,
- 0xb2,0x00,0x00,0x00,0x00,0x4c,0xb3,0x00,0x00,0x00,0xc0,0x34,0x82,0x00,0x00,
- 0x00,0x4c,0x35,0x80,0x00,0x00,0x80,0x54,0x26,0x80,0x00,0x00,0x80,0x67,0x04,
- 0x80,0x00,0x00,0xb0,0x4c,0x00,0x80,0x00,0x00,0xd0,0x08,0x00,0x00,0x01,0x00,
- 0x90,0x01,0x00,0x00,0x01,0x00,0x17,0x00,0x00,0x00,0x01,0x00,0x39,0x00,0x00,
- 0x00,0x01,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00,0x02,0x00,
- 0x04,0x00,0x00,0x00,0x02,0x00,0x08,0x00,0x00,0x00,0x02,0x00,0x08,0x00,0x00,
- 0x00,0x0c,0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x1f,0x00,
- 0x20,0x00,0x00,0x80,0x20,0x00,0x20,0x00,0x80,0x43,0x40,0x00,0x40,0x00,0x60,
- 0x2c,0x80,0x00,0x40,0x00,0x18,0x10,0x80,0x00,0x40,0x00,0x04,0x20,0x8c,0x00,
- 0x80,0x00,0x04,0x40,0x8c,0x00,0x80,0x00,0x02,0x40,0x40,0x00,0x00,0x01,0x01,
- 0x40,0x70,0x00,0x00,0x01,0xc1,0xc0,0x8f,0x00,0x00,0x02,0xc1,0x40,0x00,0x01,
- 0x00,0x02,0x02,0x20,0x00,0x01,0x00,0x02,0x02,0x10,0x00,0x01,0x00,0x04,0x04,
- 0x10,0x00,0x01,0x00,0x04,0x08,0x0c,0x80,0x00,0x00,0x04,0xf0,0x03,0x40,0x00,
- 0x00,0x08,0x00,0x00,0xbe,0x00,0x00,0x08,0x00,0x00,0x80,0x00,0x00,0x30,0x00,
- 0x00,0x80,0x00,0x00,0x48,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00,0x01,
- 0x00,0x74,0x00,0x00,0x00,0x02,0x00,0x2a,0x00,0x00,0x00,0x04,0x00,0x6a,0x40,
- 0x00,0x00,0x03,0x00,0x04,0x20,0x00,0xc0,0x00,0x00,0x88,0x70,0x00,0x3e,0x00,
- 0x00,0x70,0x90,0xff,0x01,0x00,0x00,0x20,0x10,0x80,0x00,0x00,0x00,0x20,0x00,
- 0x80,0x00,0x00,0x00,0x20,0x00,0x60,0x00,0x00,0x00,0x20,0x00,0x10,0x00,0x00,
- 0x00,0x20,0x00,0x08,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x10,0x00,
- 0x08,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x60,0x00,0x08,0x00,0x00,
- 0x00,0x80,0x01,0x08,0x00,0x00,0x00,0x00,0x06,0x04,0x00,0x00,0x00,0x00,0xf8,
- 0x03,0x00,0x00};
Deleted: trunk/data/blarg.xbm
===================================================================
--- trunk/data/blarg.xbm 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/data/blarg.xbm 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,5 +0,0 @@
-#define test_width 16
-#define test_height 7
-static char test_bits[] = {
-0x13, 0x00, 0x15, 0x00, 0x93, 0xcd, 0x55, 0xa5, 0x93, 0xc5, 0x00, 0x80,
-0x00, 0x60, };
Deleted: trunk/data/candle.xbm
===================================================================
--- trunk/data/candle.xbm 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/data/candle.xbm 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,8 +0,0 @@
-#define noname_width 16
-#define noname_height 33
-static char noname_bits[] = {
- 0x00,0x01,0x00,0x03,0x00,0x03,0x00,0x03,0x80,0x06,0x40,0x06,0x40,0x06,0x40,
- 0x06,0x40,0x03,0x80,0x01,0xf0,0x0f,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,
- 0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,
- 0x0c,0x10,0x0c,0xfe,0x7f,0x01,0xc0,0x02,0x60,0x0c,0x38,0x10,0x0c,0x10,0x0c,
- 0x20,0x06,0x20,0x06,0x10,0x0c};
Added: trunk/data/contents.txt
===================================================================
--- trunk/data/contents.txt (rev 0)
+++ trunk/data/contents.txt 2008-04-18 07:42:20 UTC (rev 52)
@@ -0,0 +1,3 @@
+bunny.xbm
+halloween.xbm
+squares.xbm
Deleted: trunk/data/crab.xbm
===================================================================
--- trunk/data/crab.xbm 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/data/crab.xbm 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,7 +0,0 @@
-#define crab_width 16
-#define crab_height 16
-
-static char crab_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x70, 0x0e, 0x78, 0x1e, 0x18, 0x18, 0x44, 0x22,
- 0xc4, 0x23, 0xf8, 0x1f, 0xe0, 0x07, 0xf8, 0x1f, 0xe4, 0x27, 0xd0, 0x0b,
- 0x08, 0x10, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 };
Deleted: trunk/data/ghost_left.xbm
===================================================================
--- trunk/data/ghost_left.xbm 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/data/ghost_left.xbm 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,6 +0,0 @@
-#define pacman_left_width 16
-#define pacman_left_height 16
-static char pacman_left_bits[] = {
- 0xf0,0x07,0x0c,0x18,0x02,0x20,0x3a,0x2e,0x45,0x51,0x5d,0x57,0x5d,0x57,0x5d,
- 0x57,0x45,0x51,0x39,0x4e,0x01,0x40,0x01,0x40,0x11,0x44,0x29,0x4a,0x45,0x51,
- 0x82,0x20};
Added: trunk/images/en/button-select.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/en/button-select.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:keywords
+ Id
Added: trunk/images/fr/button-select.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/fr/button-select.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:keywords
+ Id
Modified: trunk/lib/mmvcs.jar
===================================================================
(Binary files differ)
Added: trunk/lib/simpleButton.jar
===================================================================
(Binary files differ)
Property changes on: trunk/lib/simpleButton.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:keywords
+ Id
Modified: trunk/src/picross/Picross.java
===================================================================
--- trunk/src/picross/Picross.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/Picross.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -33,17 +33,21 @@
package picross;
+import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Locale;
import javax.swing.ImageIcon;
-//import org.apache.log4j.Logger;
+import org.apache.log4j.Logger;
/**
* Helper class.
@@ -66,7 +70,7 @@
/*** Static field ***/
/** The class' logger. */
- //private static Logger log = Logger.getLogger(Picross.class);
+ private static Logger log = Logger.getLogger(Picross.class);
/*** Constructor ***/
@@ -163,5 +167,27 @@
return Picross.getFile(Picross.DATA_DIR + name).openStream();
}
+
+ public static List<String> listDataFiles() throws IOException {
+ List<String> list = new ArrayList<String>();
+
+ BufferedReader in = null;
+
+ try {
+ in = new BufferedReader(new InputStreamReader(Picross.loadDataFile("contents.txt")));
+
+ String line = null;
+
+ while ((line = in.readLine()) != null) {
+ list.add(line);
+ }
+ } catch (IOException ioEx) {
+ throw ioEx;
+ } finally {
+ in.close();
+ }
+
+ return list;
+ }
}
Modified: trunk/src/picross/PicrossController.java
===================================================================
--- trunk/src/picross/PicrossController.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/PicrossController.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -55,6 +55,8 @@
/** Select level command. */
public static final String SELECT_LEVEL_CMD = "SELECT_LEVEL_CMD";
+ public static final String LEVEL_CMD = "LEVEL_CMD";
+
/** Exit command. */
public static final String EXIT_CMD = "EXIT_CMD";
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/PicrossMediator.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -38,17 +38,24 @@
import fr.cle.mmvcs.Mediateur;
import fr.cle.mmvcs.SimpleEvent;
+import java.lang.reflect.InvocationTargetException;
+
import javax.swing.SwingUtilities;
-//import org.apache.log4j.Logger;
+import org.apache.log4j.Logger;
import picross.game.GameMediator;
+import picross.game.random.RandomGameMediator;
+
+import picross.game.simple.SimpleGameMediator;
+
import picross.grid.GridController;
import picross.menus.GameMenuMediator;
-
+import picross.menus.LevelMenuMediator;
import picross.menus.MainMenuMediator;
+import picross.menus.MenuMediator;
/**
* Application mediator.
@@ -59,7 +66,7 @@
/*** Static field ***/
/** Class' logger. */
- //private static Logger log = Logger.getLogger(PicrossMediator.class);
+ private static Logger log = Logger.getLogger(PicrossMediator.class);
/*** Field ***/
@@ -76,24 +83,10 @@
PicrossController controller = new PicrossController();
controller.setView(view);
-
this.addSimpleListener(controller);
- MainMenuMediator mediator = null;
+ this.displayMenu(MainMenuMediator.class);
- try {
- mediator = new MainMenuMediator(this.view);
- } catch (PicrossException picrossEx) {
- this.fireEventPerformed(PicrossController.ERROR_CMD,
- picrossEx.getMessage());
-
- this.exit();
- return;
- }
-
- mediator.addSimpleListener(this);
-
- this.view.setContent(mediator.getView());
this.view.showUI();
}
@@ -117,6 +110,16 @@
return;
}
+ if (cmd.equals(PicrossController.SELECT_LEVEL_CMD)) {
+ this.displaySelectLevelMenu();
+ return;
+ }
+
+ if (cmd.equals(PicrossController.LEVEL_CMD)) {
+ this.startGame(e.getComment());
+ return;
+ }
+
if (cmd.equals(PicrossController.EXIT_CMD)) {
this.exit();
return;
@@ -139,10 +142,36 @@
/** Displays the game menu. */
private void displayGameMenu() {
- GameMenuMediator menu = null;
+ this.displayMenu(GameMenuMediator.class);
+ }
+ /** Displays the level selection menu. */
+ private void displaySelectLevelMenu() {
+ this.displayMenu(LevelMenuMediator.class);
+ }
+
+ /**
+ * Helper method to display a menu.
+ *
+ * @param menuClass the menu's mediator class
+ */
+ private void displayMenu(Class<? extends MenuMediator> menuClass) {
+ MenuMediator menu = null;
+
try {
- menu = new GameMenuMediator(this.view);
+ try {
+ menu = menuClass.getConstructor(PicrossUI.class)
+ .newInstance(this.view);
+ } catch (NoSuchMethodException methodEx) {
+ throw new PicrossException(methodEx);
+ } catch (InstantiationException instantiationEx) {
+ throw new PicrossException(instantiationEx);
+ } catch (IllegalAccessException accessEx) {
+ throw new PicrossException(accessEx);
+ } catch (InvocationTargetException targetEx) {
+ targetEx.printStackTrace();
+ throw (PicrossException) targetEx.getCause();
+ }
} catch (PicrossException picrossEx) {
this.fireEventPerformed(PicrossController.ERROR_CMD,
picrossEx.getMessage());
@@ -162,15 +191,13 @@
GameMediator game = null;
try {
- game =
- new picross.game.random.RandomGameMediator();
+ game = new RandomGameMediator();
+ PicrossMediator.this.gameLoaded(game);
} catch (PicrossException picrossEx) {
PicrossMediator.this.view
.displayError(picrossEx.getMessage());
return;
}
-
- PicrossMediator.this.gameLoaded(game);
}
};
@@ -178,21 +205,25 @@
}
/** Starts a new game. */
- private void startGame() {
+ private void startGame(final String level) {
+ PicrossMediator.log.debug("startGame(" + level + ")");
+
Thread worker = new Thread() {
public void run() {
GameMediator game = null;
try {
- game =
- new picross.game.simple.SimpleGameMediator();
- } catch (PicrossException picrossEx) {
- PicrossMediator.this.view
- .displayError(picrossEx.getMessage());
- return;
+ game = new SimpleGameMediator(level);
+ PicrossMediator.this.gameLoaded(game);
+ } catch (final PicrossException picrossEx) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ PicrossMediator.this.view
+ .displayError(picrossEx.getMessage());
+ return;
+ }
+ });
}
-
- PicrossMediator.this.gameLoaded(game);
}
};
Modified: trunk/src/picross/game/GameMediator.java
===================================================================
--- trunk/src/picross/game/GameMediator.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/game/GameMediator.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -70,7 +70,8 @@
* @throws PicrossException if there is a problem loading the grid model
* or building the view
*/
- public GameMediator() throws PicrossException {
+ //public GameMediator() throws PicrossException {
+ protected void init() throws PicrossException {
PicrossGrid model = this.initModel();
final int width = model.getWidth();
Modified: trunk/src/picross/game/random/RandomGameMediator.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMediator.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/game/random/RandomGameMediator.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -66,7 +66,8 @@
* or building the view
*/
public RandomGameMediator() throws PicrossException {
- super();
+ //super();
+ this.init();
}
/*** Methods overloaded from the class GameMediator ***/
Modified: trunk/src/picross/game/simple/SimpleGameMediator.java
===================================================================
--- trunk/src/picross/game/simple/SimpleGameMediator.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/game/simple/SimpleGameMediator.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -47,6 +47,8 @@
* @author Y. Norsa
*/
public final class SimpleGameMediator extends GameMediator {
+ private String level;
+
/*** Constructor ***/
/**
@@ -55,8 +57,11 @@
* @throws PicrossException if there is a problem loading the grid model
* or building the view
*/
- public SimpleGameMediator() throws PicrossException {
- super();
+ public SimpleGameMediator(String levelName) throws PicrossException {
+ //super();
+
+ this.level = levelName;
+ this.init();
}
/*** Method overloaded from the class GameMediator ***/
@@ -64,7 +69,7 @@
/** {@inheritDoc} */
protected PicrossGrid initModel() throws PicrossException {
try {
- return new XBMModel(Picross.loadDataFile("halloween.xbm"));
+ return new XBMModel(Picross.loadDataFile(this.level));
} catch (IOException ioEx) {
throw new PicrossException(ioEx);
}
Modified: trunk/src/picross/menus/GameMenuUI.java
===================================================================
--- trunk/src/picross/menus/GameMenuUI.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/menus/GameMenuUI.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -59,19 +59,34 @@
/** "Random" button Y coordinate. */
private static final int RANDOM_BUTTON_Y = 175;
+ /** Image for the "select" button. */
+ private static final String SELECT_BUTTON_IMAGE = "button-select.png";
+
+ /** "Select" button X coordinate. */
+ private static final int SELECT_BUTTON_X = 150;
+
+ /** "Select" button Y coordinate. */
+ private static final int SELECT_BUTTON_Y = 250;
+
/*** Constructor ***/
/**
* Constructor.
*
- * @param listener listener for the button
- * @throws MissingImageException if the button image can't be found
+ * @param listener listener for the buttons
+ * @throws MissingImageException if a button image can't be found
*/
GameMenuUI(ActionListener listener) {
+ super();
+
this.addButton(GameMenuUI.RANDOM_BUTTON_IMAGE,
PicrossController.RANDOM_GAME_CMD,
listener,
GameMenuUI.RANDOM_BUTTON_X, GameMenuUI.RANDOM_BUTTON_Y);
+ this.addButton(GameMenuUI.SELECT_BUTTON_IMAGE,
+ PicrossController.SELECT_LEVEL_CMD,
+ listener,
+ GameMenuUI.SELECT_BUTTON_X, GameMenuUI.SELECT_BUTTON_Y);
}
}
Added: trunk/src/picross/menus/LevelMenuMediator.java
===================================================================
--- trunk/src/picross/menus/LevelMenuMediator.java (rev 0)
+++ trunk/src/picross/menus/LevelMenuMediator.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -0,0 +1,68 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import picross.PicrossException;
+import picross.PicrossUI;
+
+/**
+ * Level selection menu.
+ *
+ * @author Y. Norsa
+ */
+public class LevelMenuMediator extends MenuMediator {
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @param ui reference to the main UI
+ * @throws PicrossException if the instantiation of the view fails
+ */
+ public LevelMenuMediator(PicrossUI ui) throws PicrossException {
+ super(ui);
+ }
+
+ /*** Method overloaded from the class MenuMediator ***/
+
+ /** {@inheritDoc} */
+ @Override
+ protected MenuUI initView(PicrossUI ui, MenuController controller)
+ throws PicrossException {
+
+ LevelMenuModel model = new LevelMenuModel();
+ return new LevelMenuUI(controller, model.getLevelsList());
+ }
+}
+
Property changes on: trunk/src/picross/menus/LevelMenuMediator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/LevelMenuModel.java
===================================================================
--- trunk/src/picross/menus/LevelMenuModel.java (rev 0)
+++ trunk/src/picross/menus/LevelMenuModel.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -0,0 +1,80 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import java.io.IOException;
+
+import java.util.List;
+
+import picross.Picross;
+import picross.PicrossException;
+
+/**
+ * Model for the level selection menu.
+ *
+ * @author Y. Norsa
+ */
+class LevelMenuModel {
+ /*** Field ***/
+
+ /** Level list. */
+ private List<String> levels;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @throws PicrossException if an error arises during the levels listing
+ */
+ LevelMenuModel() throws PicrossException {
+ try {
+ this.levels = Picross.listDataFiles();
+ } catch (IOException ioEx) {
+ throw new PicrossException(ioEx);
+ }
+ }
+
+ /*** Method ***/
+
+ /**
+ * Returns the levels list.
+ *
+ * @return list of the level files
+ */
+ List<String> getLevelsList() {
+ return this.levels;
+ }
+}
+
Property changes on: trunk/src/picross/menus/LevelMenuModel.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/LevelMenuUI.java
===================================================================
--- trunk/src/picross/menus/LevelMenuUI.java (rev 0)
+++ trunk/src/picross/menus/LevelMenuUI.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -0,0 +1,82 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import fr.cle.mmvcs.SimpleEvent;
+import fr.cle.mmvcs.SimpleListener;
+
+import java.util.List;
+
+import picross.PicrossController;
+
+/**
+ * UI for the level selection menu.
+ *
+ * @author Y. Norsa
+ */
+class LevelMenuUI extends MenuUI {
+ /*** Constant ***/
+
+ /** Serialisation ID. */
+ private static final long serialVersionUID = 6178785913505637523L;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @param listener listener for the buttons
+ * @param levels levels list
+ */
+ LevelMenuUI(SimpleListener listener, List<String> levels) {
+ super();
+
+ int x = 50;
+ int y = 150;
+
+ for (String level : levels) {
+ SimpleEvent event = new SimpleEvent(PicrossController.LEVEL_CMD,
+ level);
+ this.addSimpleButton(level, event, listener, x, y);
+
+ y += 75;
+
+ if (y == 375) {
+ x = 250;
+ y = 150;
+ }
+ }
+ }
+}
+
Property changes on: trunk/src/picross/menus/LevelMenuUI.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/menus/MenuController.java
===================================================================
--- trunk/src/picross/menus/MenuController.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/menus/MenuController.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -48,6 +48,7 @@
/** {@inheritDoc} */
@Override
public void eventPerformed(SimpleEvent e) {
+ this.fireEventPerformed(e);
}
/*** Method implanted from the interface ActionListener ***/
Modified: trunk/src/picross/menus/MenuMediator.java
===================================================================
--- trunk/src/picross/menus/MenuMediator.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/menus/MenuMediator.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -46,7 +46,7 @@
*
* @author Y. Norsa
*/
-abstract class MenuMediator extends Mediateur {
+public abstract class MenuMediator extends Mediateur {
/*** Static field ***/
/** This class' logger. */
Modified: trunk/src/picross/menus/MenuUI.java
===================================================================
--- trunk/src/picross/menus/MenuUI.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/menus/MenuUI.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -33,6 +33,11 @@
package picross.menus;
+import fr.cle.core.gui.SimpleButton;
+
+import fr.cle.mmvcs.SimpleEvent;
+import fr.cle.mmvcs.SimpleListener;
+
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
@@ -123,9 +128,26 @@
button.setActionCommand(command);
button.addActionListener(controller);
button.setBorder(null);
+ /*
button.setBounds(x, y,
buttonIcon.getIconWidth(),
buttonIcon.getIconHeight());
this.add(button);
+ */
+ this.putButton(button, x, y, buttonIcon.getIconWidth(), buttonIcon.getIconHeight());
}
+
+ protected void addSimpleButton(String label, SimpleEvent event,
+ SimpleListener listener,
+ int x, int y) {
+ SimpleButton<JButton> button = new SimpleButton<JButton>(label, event) { };
+ button.addSimpleListener(listener);
+
+ this.putButton(button.getButton(), x, y, 150, 50);
+ }
+
+ private void putButton(JButton button, int x, int y, int width, int height) {
+ button.setBounds(x, y, width, height);
+ this.add(button);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-18 07:32:16
|
Revision: 51
http://picross.svn.sourceforge.net/picross/?rev=51&view=rev
Author: yvan_norsa
Date: 2008-04-18 00:32:24 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
fixed XBM loading
Modified Paths:
--------------
trunk/src/picross/game/simple/XBMModel.java
Modified: trunk/src/picross/game/simple/XBMModel.java
===================================================================
--- trunk/src/picross/game/simple/XBMModel.java 2008-04-17 12:05:40 UTC (rev 50)
+++ trunk/src/picross/game/simple/XBMModel.java 2008-04-18 07:32:24 UTC (rev 51)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -121,6 +121,8 @@
try {
while ((line = in.readLine()) != null) {
+ line = line.trim();
+
if (line.startsWith(XBMModel.DEFINE_DIRECTIVE)
&& line.contains(XBMModel.WIDTH_KEYWORD)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-17 12:05:41
|
Revision: 50
http://picross.svn.sourceforge.net/picross/?rev=50&view=rev
Author: yvan_norsa
Date: 2008-04-17 05:05:40 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
menus factorisation
Modified Paths:
--------------
trunk/src/picross/PicrossController.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/app/MainMenuAppUI.java
trunk/src/picross/menus/GameMenuMediator.java
trunk/src/picross/menus/GameMenuUI.java
trunk/src/picross/menus/MainMenuMediator.java
Added Paths:
-----------
trunk/src/picross/menus/MenuController.java
trunk/src/picross/menus/MenuMediator.java
Removed Paths:
-------------
trunk/src/picross/menus/GameMenuController.java
trunk/src/picross/menus/MainMenuController.java
Modified: trunk/src/picross/PicrossController.java
===================================================================
--- trunk/src/picross/PicrossController.java 2008-04-17 09:38:09 UTC (rev 49)
+++ trunk/src/picross/PicrossController.java 2008-04-17 12:05:40 UTC (rev 50)
@@ -52,6 +52,12 @@
/** Random game command. */
public static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD";
+ /** Select level command. */
+ public static final String SELECT_LEVEL_CMD = "SELECT_LEVEL_CMD";
+
+ /** Exit command. */
+ public static final String EXIT_CMD = "EXIT_CMD";
+
/*** Static field ***/
/** The class's logger. */
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2008-04-17 09:38:09 UTC (rev 49)
+++ trunk/src/picross/PicrossMediator.java 2008-04-17 12:05:40 UTC (rev 50)
@@ -48,7 +48,6 @@
import picross.menus.GameMenuMediator;
-import picross.menus.MainMenuController;
import picross.menus.MainMenuMediator;
/**
@@ -83,7 +82,7 @@
MainMenuMediator mediator = null;
try {
- mediator = new MainMenuMediator(view);
+ mediator = new MainMenuMediator(this.view);
} catch (PicrossException picrossEx) {
this.fireEventPerformed(PicrossController.ERROR_CMD,
picrossEx.getMessage());
@@ -118,7 +117,7 @@
return;
}
- if (cmd.equals(MainMenuController.EXIT_CMD)) {
+ if (cmd.equals(PicrossController.EXIT_CMD)) {
this.exit();
return;
}
@@ -143,7 +142,7 @@
GameMenuMediator menu = null;
try {
- menu = new GameMenuMediator();
+ menu = new GameMenuMediator(this.view);
} catch (PicrossException picrossEx) {
this.fireEventPerformed(PicrossController.ERROR_CMD,
picrossEx.getMessage());
Modified: trunk/src/picross/app/MainMenuAppUI.java
===================================================================
--- trunk/src/picross/app/MainMenuAppUI.java 2008-04-17 09:38:09 UTC (rev 49)
+++ trunk/src/picross/app/MainMenuAppUI.java 2008-04-17 12:05:40 UTC (rev 50)
@@ -41,8 +41,8 @@
import javax.swing.JButton;
import picross.Picross;
+import picross.PicrossController;
-import picross.menus.MainMenuController;
import picross.menus.MainMenuUI;
/**
@@ -83,7 +83,7 @@
super(controller);
this.addButton(MainMenuAppUI.EXIT_BUTTON_IMAGE,
- MainMenuController.EXIT_CMD,
+ PicrossController.EXIT_CMD,
controller,
MainMenuAppUI.EXIT_BUTTON_X,
MainMenuAppUI.EXIT_BUTTON_Y);
Deleted: trunk/src/picross/menus/GameMenuController.java
===================================================================
--- trunk/src/picross/menus/GameMenuController.java 2008-04-17 09:38:09 UTC (rev 49)
+++ trunk/src/picross/menus/GameMenuController.java 2008-04-17 12:05:40 UTC (rev 50)
@@ -1,68 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (c) 2008
- *
- * This software is governed by the CeCILL license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL license and that you accept its terms.
- */
-
-
-package picross.menus;
-
-import fr.cle.mmvcs.Controller;
-import fr.cle.mmvcs.SimpleEvent;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import picross.PicrossController;
-
-/**
- * Controller for the game menu.
- *
- * @author Y. Norsa
- */
-class GameMenuController extends Controller implements ActionListener {
- /*** Method overloaded from the class Controller ***/
-
- /** {@inheritDoc} */
- @Override
- public void eventPerformed(SimpleEvent e) { }
-
- /*** Method implanted from the interface ActionListener ***/
-
- /** {@inheritDoc} */
- public void actionPerformed(ActionEvent e) {
- String cmd = e.getActionCommand();
-
- if (cmd.equals(PicrossController.RANDOM_GAME_CMD)) {
- this.fireEventPerformed(cmd);
- return;
- }
- }
-}
-
Modified: trunk/src/picross/menus/GameMenuMediator.java
===================================================================
--- trunk/src/picross/menus/GameMenuMediator.java 2008-04-17 09:38:09 UTC (rev 49)
+++ trunk/src/picross/menus/GameMenuMediator.java 2008-04-17 12:05:40 UTC (rev 50)
@@ -39,47 +39,34 @@
import java.io.FileNotFoundException;
import picross.PicrossException;
+import picross.PicrossUI;
/**
* Mediator for the game menu.
*
* @author Y. Norsa
*/
-public class GameMenuMediator extends Mediateur {
- /*** Field ***/
-
- /** View of the menu. */
- private GameMenuUI view;
-
+public class GameMenuMediator extends MenuMediator {
/*** Constructor ***/
/**
* Constructor.
+ *
+ * @param ui reference to the main UI
+ * @throws PicrossException if the instantiation of the view fails
*/
- public GameMenuMediator() throws PicrossException {
- GameMenuController controller = new GameMenuController();
- controller.addSimpleListener(this);
-
- this.view = new GameMenuUI(controller);
+ public GameMenuMediator(PicrossUI ui) throws PicrossException {
+ super(ui);
}
- /*** Method overloaded from the Mediateur class ***/
+ /*** Method overloaded from the class MenuMediator ***/
- /** {@inheritDoc} */
+ /** {@inheritDoc}\xA0*/
@Override
- public void eventPerformed(SimpleEvent e) {
- this.fireEventPerformed(e);
- }
+ protected MenuUI initView(PicrossUI ui, MenuController controller)
+ throws PicrossException {
- /*** Accessor ***/
-
- /**
- * Returns the view.
- *
- * @return the view
- */
- public GameMenuUI getView() {
- return this.view;
+ return new GameMenuUI(controller);
}
}
Modified: trunk/src/picross/menus/GameMenuUI.java
===================================================================
--- trunk/src/picross/menus/GameMenuUI.java 2008-04-17 09:38:09 UTC (rev 49)
+++ trunk/src/picross/menus/GameMenuUI.java 2008-04-17 12:05:40 UTC (rev 50)
@@ -45,22 +45,33 @@
* @author Y. Norsa
*/
class GameMenuUI extends MenuUI {
- /*** Constant ***/
+ /*** Constants ***/
/** Serialisation ID. */
private static final long serialVersionUID = 4472277675596865332L;
+ /** Image for the "random" button. */
+ private static final String RANDOM_BUTTON_IMAGE = "button-random.png";
+
+ /** "Random" button X coordinate. */
+ private static final int RANDOM_BUTTON_X = 150;
+
+ /** "Random" button Y coordinate. */
+ private static final int RANDOM_BUTTON_Y = 175;
+
/*** Constructor ***/
/**
* Constructor.
*
* @param listener listener for the button
- * @throws MissingImageException if a button image can't be found
+ * @throws MissingImageException if the button image can't be found
*/
GameMenuUI(ActionListener listener) {
- this.addButton("button-random.png", PicrossController.RANDOM_GAME_CMD,
- listener, 150, 225);
+ this.addButton(GameMenuUI.RANDOM_BUTTON_IMAGE,
+ PicrossController.RANDOM_GAME_CMD,
+ listener,
+ GameMenuUI.RANDOM_BUTTON_X, GameMenuUI.RANDOM_BUTTON_Y);
}
}
Deleted: trunk/src/picross/menus/MainMenuController.java
===================================================================
--- trunk/src/picross/menus/MainMenuController.java 2008-04-17 09:38:09 UTC (rev 49)
+++ trunk/src/picross/menus/MainMenuController.java 2008-04-17 12:05:40 UTC (rev 50)
@@ -1,87 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (c) 2007
- *
- * This software is governed by the CeCILL license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL license and that you accept its terms.
- */
-
-
-package picross.menus;
-
-import fr.cle.mmvcs.Controller;
-import fr.cle.mmvcs.SimpleEvent;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import org.apache.log4j.Logger;
-
-import picross.PicrossController;
-
-/**
- * Controller for the main menu.
- *
- * @author Y. Norsa
- */
-public class MainMenuController extends Controller implements ActionListener {
- /*** Constant ***/
-
- /** Exit command. */
- public static final String EXIT_CMD = "EXIT_CMD";
-
- /*** Static field ***/
-
- /** The class' logger. */
- private static Logger log = Logger.getLogger(MainMenuController.class);
-
- /*** Method overloaded from the class Controller ***/
-
- /** {@inheritDoc} */
- public void eventPerformed(SimpleEvent e) {
- MainMenuController.log.debug("eventPerformed(" + e + ")");
- }
-
- /*** Method implanted from the interface ActionListener ***/
-
- /** {@inheritDoc} */
- public void actionPerformed(ActionEvent e) {
- //MainMenuController.log.debug("actionPerformed(" + e + ")");
-
- String cmd = e.getActionCommand();
-
- //javax.swing.JOptionPane.showMessageDialog(null, "click : " + cmd);
-
- if (cmd.equals(PicrossController.PLAY_CMD)
- || cmd.equals(MainMenuController.EXIT_CMD)) {
-
- this.fireEventPerformed(cmd);
- return;
- }
- }
-}
-
Modified: trunk/src/picross/menus/MainMenuMediator.java
===================================================================
--- trunk/src/picross/menus/MainMenuMediator.java 2008-04-17 09:38:09 UTC (rev 49)
+++ trunk/src/picross/menus/MainMenuMediator.java 2008-04-17 12:05:40 UTC (rev 50)
@@ -50,30 +50,28 @@
*
* @author Y. Norsa
*/
-public class MainMenuMediator extends Mediateur {
- /*** Static field ***/
-
- /** The class' logger. */
- private static Logger log = Logger.getLogger(MainMenuMediator.class);
-
- /*** Field ***/
-
- /** The menu view. */
- private MainMenuUI view;
-
+public class MainMenuMediator extends MenuMediator {
/*** Constructor ***/
/**
* Constructor.
*
+ * @param ui reference to the main UI
* @throws PicrossException if the instantiation of the main menu UI fails
*/
public MainMenuMediator(PicrossUI ui) throws PicrossException {
- MainMenuController controller = new MainMenuController();
- controller.addSimpleListener(this);
+ super(ui);
+ }
+ /*** Method overloaded from the class MenuMediator ***/
+
+ /** {@inheritDoc} */
+ @Override
+ protected MenuUI initView(PicrossUI ui, MenuController controller)
+ throws PicrossException {
+
try {
- this.view = (MainMenuUI) Class.forName(ui.getMainMenuClass())
+ return (MainMenuUI) Class.forName(ui.getMainMenuClass())
.getConstructor(ActionListener.class).newInstance(controller);
} catch (ClassNotFoundException classEx) {
throw new PicrossException(classEx);
@@ -87,25 +85,5 @@
throw new PicrossException(targetEx.getCause());
}
}
-
- /*** Method overloaded from the class Mediateur ***/
-
- /** {@inheritDoc} */
- public void eventPerformed(SimpleEvent e) {
- MainMenuMediator.log.debug("eventPerformed(" + e + ")");
-
- this.fireEventPerformed(e);
- }
-
- /*** Accessor ***/
-
- /**
- * Returns the view.
- *
- * @return the view
- */
- public MainMenuUI getView() {
- return this.view;
- }
}
Added: trunk/src/picross/menus/MenuController.java
===================================================================
--- trunk/src/picross/menus/MenuController.java (rev 0)
+++ trunk/src/picross/menus/MenuController.java 2008-04-17 12:05:40 UTC (rev 50)
@@ -0,0 +1,61 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import fr.cle.mmvcs.Controller;
+import fr.cle.mmvcs.SimpleEvent;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+/**
+ * @author Y. Norsa
+ */
+class MenuController extends Controller implements ActionListener {
+ /*** Method overloaded from the class Controller ***/
+
+ /** {@inheritDoc} */
+ @Override
+ public void eventPerformed(SimpleEvent e) {
+ }
+
+ /*** Method implanted from the interface ActionListener ***/
+
+ /** {@inheritDoc} */
+ public void actionPerformed(ActionEvent e) {
+ String cmd = e.getActionCommand();
+ this.fireEventPerformed(cmd);
+ }
+}
+
Property changes on: trunk/src/picross/menus/MenuController.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/MenuMediator.java
===================================================================
--- trunk/src/picross/menus/MenuMediator.java (rev 0)
+++ trunk/src/picross/menus/MenuMediator.java 2008-04-17 12:05:40 UTC (rev 50)
@@ -0,0 +1,108 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import fr.cle.mmvcs.Mediateur;
+import fr.cle.mmvcs.SimpleEvent;
+
+import org.apache.log4j.Logger;
+
+import picross.PicrossException;
+import picross.PicrossUI;
+
+/**
+ * Mediator of a menu.
+ *
+ * @author Y. Norsa
+ */
+abstract class MenuMediator extends Mediateur {
+ /*** Static field ***/
+
+ /** This class' logger. */
+ private static Logger log = Logger.getLogger(MenuMediator.class);
+
+ /*** Field ***/
+
+ /** The menu's view. */
+ private MenuUI view;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @param ui reference to the main UI
+ * @throws PicrossException if the instantiation of the view fails
+ */
+ MenuMediator(PicrossUI ui) throws PicrossException {
+ MenuController controller = new MenuController();
+ controller.addSimpleListener(this);
+
+ this.view = this.initView(ui, controller);
+ }
+
+ /*** Abstract method ***/
+
+ /**
+ * Builds the menu's view.
+ *
+ * @param ui reference to the main UI
+ * @param controller the controller for the menu
+ * @return the menu's view
+ * @throws PicrossException if a problem arises during the building
+ */
+ protected abstract MenuUI initView(PicrossUI ui, MenuController controller)
+ throws PicrossException;
+
+ /*** Method overloaded from the class Mediateur ***/
+
+ /** {@inheritDoc} */
+ public void eventPerformed(SimpleEvent e) {
+ MenuMediator.log.debug("eventPerformed(" + e + ")");
+
+ this.fireEventPerformed(e);
+ }
+
+ /*** Accessor ***/
+
+ /**
+ * Returns the view.
+ *
+ * @return the view
+ */
+ public MenuUI getView() {
+ return this.view;
+ }
+}
+
Property changes on: trunk/src/picross/menus/MenuMediator.java
___________________________________________________________________
Name: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-17 09:38:05
|
Revision: 49
http://picross.svn.sourceforge.net/picross/?rev=49&view=rev
Author: yvan_norsa
Date: 2008-04-17 02:38:09 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
exception when an image is missing
Modified Paths:
--------------
trunk/src/picross/Picross.java
trunk/src/picross/app/MainMenuAppUI.java
trunk/src/picross/applet/MainMenuAppletUI.java
trunk/src/picross/grid/Box.java
trunk/src/picross/menus/GameMenuMediator.java
trunk/src/picross/menus/GameMenuUI.java
trunk/src/picross/menus/MainMenuUI.java
trunk/src/picross/menus/MenuUI.java
trunk/src/picross/tests/PicrossTest.java
Added Paths:
-----------
trunk/src/picross/MissingImageException.java
Added: trunk/src/picross/MissingImageException.java
===================================================================
--- trunk/src/picross/MissingImageException.java (rev 0)
+++ trunk/src/picross/MissingImageException.java 2008-04-17 09:38:09 UTC (rev 49)
@@ -0,0 +1,58 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross;
+
+/**
+ * Exception thrown when an image file is not found.
+ *
+ * @author Y. Norsa
+ */
+public class MissingImageException extends RuntimeException {
+ /*** Constant ***/
+
+ /** Serialisation ID. */
+ private static final long serialVersionUID = 7805399363197308654L;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @param cause parent exception
+ */
+ MissingImageException(Throwable cause) {
+ super(cause);
+ }
+}
+
Property changes on: trunk/src/picross/MissingImageException.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/Picross.java
===================================================================
--- trunk/src/picross/Picross.java 2008-04-17 09:11:28 UTC (rev 48)
+++ trunk/src/picross/Picross.java 2008-04-17 09:38:09 UTC (rev 49)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -97,12 +97,14 @@
*
* @param path path of the image
* @return the image
- * @throws FileNotFoundException if the file can't be found
+ * @throws MissingImageException if the image file can't be found
*/
- private static ImageIcon loadImage(String path)
- throws FileNotFoundException {
-
- return new ImageIcon(Picross.getFile(path));
+ private static ImageIcon loadImage(String path) {
+ try {
+ return new ImageIcon(Picross.getFile(path));
+ } catch (FileNotFoundException fileEx) {
+ throw new MissingImageException(fileEx);
+ }
}
/**
@@ -112,10 +114,10 @@
* @return the image
* @throws IllegalArgumentException if <code>name</code>
* is <code>null</code> or empty
- * @throws FileNotFoundException if the file can't be found
+ * @throws MissingImageException if the image file can't be found
*/
public static ImageIcon getImage(String name)
- throws IllegalArgumentException, FileNotFoundException {
+ throws IllegalArgumentException {
if (name == null || name.equals("")) {
throw new IllegalArgumentException("name can't be null or empty");
@@ -131,10 +133,10 @@
* @return the image
* @throws IllegalArgumentException if <code>name</code>
* is <code>null</code> or empty
- * @throws FileNotFoundException if the file can't be found
+ * @throws MissingImageException if the image file can't be found
*/
public static ImageIcon getLocalizedImage(String name)
- throws IllegalArgumentException, FileNotFoundException {
+ throws IllegalArgumentException {
if (name == null || name.equals("")) {
throw new IllegalArgumentException("name can't be null or empty");
Modified: trunk/src/picross/app/MainMenuAppUI.java
===================================================================
--- trunk/src/picross/app/MainMenuAppUI.java 2008-04-17 09:11:28 UTC (rev 48)
+++ trunk/src/picross/app/MainMenuAppUI.java 2008-04-17 09:38:09 UTC (rev 49)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -77,11 +77,9 @@
* Constructor.
*
* @param controller controller for the buttons
- * @throws FileNotFoundException if a button image can't be found
+ * @throws MissingImageException if a button image can't be found
*/
- public MainMenuAppUI(ActionListener controller)
- throws FileNotFoundException {
-
+ public MainMenuAppUI(ActionListener controller) {
super(controller);
this.addButton(MainMenuAppUI.EXIT_BUTTON_IMAGE,
Modified: trunk/src/picross/applet/MainMenuAppletUI.java
===================================================================
--- trunk/src/picross/applet/MainMenuAppletUI.java 2008-04-17 09:11:28 UTC (rev 48)
+++ trunk/src/picross/applet/MainMenuAppletUI.java 2008-04-17 09:38:09 UTC (rev 49)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -64,11 +64,9 @@
* Constructor.
*
* @param controller controller for the buttons
- * @throws FileNotFoundException if a button image can't be found
+ * @throws MissingImageException if a button image can't be found
*/
- public MainMenuAppletUI(ActionListener controller)
- throws FileNotFoundException {
-
+ public MainMenuAppletUI(ActionListener controller) {
super(controller);
this.setBackground(Color.WHITE);
Modified: trunk/src/picross/grid/Box.java
===================================================================
--- trunk/src/picross/grid/Box.java 2008-04-17 09:11:28 UTC (rev 48)
+++ trunk/src/picross/grid/Box.java 2008-04-17 09:38:09 UTC (rev 49)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -35,14 +35,13 @@
import java.awt.Rectangle;
-import java.io.FileNotFoundException;
-
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import javax.swing.ImageIcon;
+import picross.MissingImageException;
import picross.Picross;
//import org.apache.log4j.Logger;
@@ -128,8 +127,8 @@
Box.images.put(state, img);
}
- } catch (FileNotFoundException fileEx) {
- throw new ExceptionInInitializerError(fileEx);
+ } catch (MissingImageException imageEx) {
+ throw new ExceptionInInitializerError(imageEx);
}
}
Modified: trunk/src/picross/menus/GameMenuMediator.java
===================================================================
--- trunk/src/picross/menus/GameMenuMediator.java 2008-04-17 09:11:28 UTC (rev 48)
+++ trunk/src/picross/menus/GameMenuMediator.java 2008-04-17 09:38:09 UTC (rev 49)
@@ -48,6 +48,7 @@
public class GameMenuMediator extends Mediateur {
/*** Field ***/
+ /** View of the menu. */
private GameMenuUI view;
/*** Constructor ***/
@@ -59,11 +60,7 @@
GameMenuController controller = new GameMenuController();
controller.addSimpleListener(this);
- try {
- this.view = new GameMenuUI(controller);
- } catch (FileNotFoundException fileEx) {
- throw new PicrossException(fileEx);
- }
+ this.view = new GameMenuUI(controller);
}
/*** Method overloaded from the Mediateur class ***/
Modified: trunk/src/picross/menus/GameMenuUI.java
===================================================================
--- trunk/src/picross/menus/GameMenuUI.java 2008-04-17 09:11:28 UTC (rev 48)
+++ trunk/src/picross/menus/GameMenuUI.java 2008-04-17 09:38:09 UTC (rev 49)
@@ -54,8 +54,11 @@
/**
* Constructor.
+ *
+ * @param listener listener for the button
+ * @throws MissingImageException if a button image can't be found
*/
- GameMenuUI(ActionListener listener) throws FileNotFoundException {
+ GameMenuUI(ActionListener listener) {
this.addButton("button-random.png", PicrossController.RANDOM_GAME_CMD,
listener, 150, 225);
}
Modified: trunk/src/picross/menus/MainMenuUI.java
===================================================================
--- trunk/src/picross/menus/MainMenuUI.java 2008-04-17 09:11:28 UTC (rev 48)
+++ trunk/src/picross/menus/MainMenuUI.java 2008-04-17 09:38:09 UTC (rev 49)
@@ -68,9 +68,9 @@
* Constructor.
*
* @param controller controller for the buttons
- * @throws FileNotFoundException if a button image can't be found
+ * @throws MissingImageException if a button image can't be found
*/
- public MainMenuUI(ActionListener controller) throws FileNotFoundException {
+ public MainMenuUI(ActionListener controller) {
super();
this.addButton(MainMenuUI.PLAY_BUTTON_IMAGE,
Modified: trunk/src/picross/menus/MenuUI.java
===================================================================
--- trunk/src/picross/menus/MenuUI.java 2008-04-17 09:11:28 UTC (rev 48)
+++ trunk/src/picross/menus/MenuUI.java 2008-04-17 09:38:09 UTC (rev 49)
@@ -45,6 +45,9 @@
import javax.swing.JButton;
import javax.swing.JPanel;
+import org.apache.log4j.Logger;
+
+import picross.MissingImageException;
import picross.Picross;
/**
@@ -53,11 +56,22 @@
* @author Y. Norsa
*/
abstract class MenuUI extends JPanel {
- /*** Constant ***/
+ /*** Constants ***/
/** Background image. */
private static final String BACKGROUND_IMAGE = "background.png";
+ /** Default width to be used if the background file can't be found. */
+ private static final int DEFAULT_WIDTH = 450;
+
+ /** Default height to be used if the background file can't be found. */
+ private static final int DEFAULT_HEIGHT = 375;
+
+ /*** Static field ***/
+
+ /** This class' logger. */
+ private static Logger log = Logger.getLogger(MenuUI.class);
+
/*** Field ***/
/** Background image. */
@@ -65,16 +79,18 @@
/*** Constructor ***/
- /**
- * Constructor.
- *
- * @throws FileNotFoundException if the background image can't be found
- */
- MenuUI() throws FileNotFoundException {
- ImageIcon icon = Picross.getImage(MenuUI.BACKGROUND_IMAGE);
- this.setPreferredSize(new Dimension(icon.getIconWidth(),
- icon.getIconHeight()));
- this.image = icon.getImage();
+ /** Constructor. */
+ MenuUI() {
+ try {
+ ImageIcon icon = Picross.getImage(MenuUI.BACKGROUND_IMAGE);
+ this.setPreferredSize(new Dimension(icon.getIconWidth(),
+ icon.getIconHeight()));
+ this.image = icon.getImage();
+ } catch (MissingImageException imageEx) {
+ MenuUI.log.info(imageEx.getMessage());
+ this.setPreferredSize(new Dimension(MenuUI.DEFAULT_WIDTH,
+ MenuUI.DEFAULT_HEIGHT));
+ }
this.setLayout(null);
}
@@ -98,12 +114,10 @@
* @param controller listener for the button
* @param x x position for the button
* @param y y position for the button
- * @throws FileNotFoundException if a button image can't be found
+ * @throws MissingImageException if a button image can't be found
*/
protected void addButton(String image, String command,
- ActionListener controller, int x, int y)
- throws FileNotFoundException {
-
+ ActionListener controller, int x, int y) {
ImageIcon buttonIcon = Picross.getLocalizedImage(image);
JButton button = new JButton(buttonIcon);
button.setActionCommand(command);
Modified: trunk/src/picross/tests/PicrossTest.java
===================================================================
--- trunk/src/picross/tests/PicrossTest.java 2008-04-17 09:11:28 UTC (rev 48)
+++ trunk/src/picross/tests/PicrossTest.java 2008-04-17 09:38:09 UTC (rev 49)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -42,6 +42,7 @@
import org.junit.Assert;
import org.junit.Test;
+import picross.MissingImageException;
import picross.Picross;
/**
@@ -74,10 +75,10 @@
/**
* Tests the method getImage().
*
- * @throws FileNotFoundException if a file loading fails.
+ * @throws MissingImageException if a file loading fails.
*/
@Test
- public void testGetImage() throws FileNotFoundException {
+ public void testGetImage() {
try {
Picross.getImage(null);
Assert.fail("name = null");
@@ -91,7 +92,7 @@
try {
Picross.getImage("fakeFile");
Assert.fail("Fake file");
- } catch (FileNotFoundException fileEx) { }
+ } catch (MissingImageException imageEx) { }
ImageIcon icon = Picross.getImage("empty.png");
PicrossTest.testIcon(icon, 25, 25);
@@ -100,10 +101,10 @@
/**
* Tests the method getLocalizedImage().
*
- * @throws FileNotFoundException if a file loading fails.
+ * @throws MissingImageException if a file loading fails.
*/
@Test
- public void getLocalizedImage() throws FileNotFoundException {
+ public void getLocalizedImage() {
try {
Picross.getLocalizedImage(null);
Assert.fail("name = null");
@@ -117,7 +118,7 @@
try {
Picross.getImage("fakeFile");
Assert.fail("Fake file");
- } catch (FileNotFoundException fileEx) { }
+ } catch (MissingImageException imageEx) { }
ImageIcon icon = Picross.getLocalizedImage("button-play.png");
PicrossTest.testIcon(icon, 150, 50);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-17 09:11:23
|
Revision: 48
http://picross.svn.sourceforge.net/picross/?rev=48&view=rev
Author: yvan_norsa
Date: 2008-04-17 02:11:28 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
game menu
Modified Paths:
--------------
trunk/src/picross/PicrossController.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/app/MainMenuAppUI.java
trunk/src/picross/game/random/RandomGameMediator.java
trunk/src/picross/menus/MainMenuUI.java
Added Paths:
-----------
trunk/images/en/button-random.png
trunk/images/fr/button-random.png
trunk/src/picross/menus/GameMenuController.java
trunk/src/picross/menus/GameMenuMediator.java
trunk/src/picross/menus/GameMenuUI.java
trunk/src/picross/menus/MenuUI.java
Added: trunk/images/en/button-random.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/en/button-random.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/images/fr/button-random.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/fr/button-random.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/picross/PicrossController.java
===================================================================
--- trunk/src/picross/PicrossController.java 2008-04-17 08:50:24 UTC (rev 47)
+++ trunk/src/picross/PicrossController.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -44,11 +44,14 @@
* @author Y. Norsa
*/
public final class PicrossController extends Controller {
- /*** Constant ***/
+ /*** Constants ***/
/** Play command. */
public static final String PLAY_CMD = "PLAY_CMD";
+ /** Random game command. */
+ public static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD";
+
/*** Static field ***/
/** The class's logger. */
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2008-04-17 08:50:24 UTC (rev 47)
+++ trunk/src/picross/PicrossMediator.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -46,6 +46,8 @@
import picross.grid.GridController;
+import picross.menus.GameMenuMediator;
+
import picross.menus.MainMenuController;
import picross.menus.MainMenuMediator;
@@ -105,32 +107,14 @@
String cmd = e.getCommandName();
if (cmd.equals(PicrossController.PLAY_CMD)) {
- //this.view.setContent(grid.getView());
+ //this.startGame();
+ this.displayGameMenu();
- //GameMediator game = new picross.game.random.RandomGameMediator();
- //GameMediator game = null;
+ return;
+ }
- Thread worker = new Thread() {
- public void run() {
- GameMediator game = null;
-
- try {
- game =
- new picross.game.simple.SimpleGameMediator();
- } catch (PicrossException picrossEx) {
- PicrossMediator.this.view
- .displayError(picrossEx.getMessage());
- return;
- }
-
- //game.addSimpleListener(this);
- //this.view.setContent(game.getView());
- PicrossMediator.this.gameLoaded(game);
- }
- };
-
- worker.start();
-
+ if (cmd.equals(PicrossController.RANDOM_GAME_CMD)) {
+ this.startRandomGame();
return;
}
@@ -154,6 +138,68 @@
this.fireEventPerformed(PicrossController.DISPOSE_CMD);
}
+ /** Displays the game menu. */
+ private void displayGameMenu() {
+ GameMenuMediator menu = null;
+
+ try {
+ menu = new GameMenuMediator();
+ } catch (PicrossException picrossEx) {
+ this.fireEventPerformed(PicrossController.ERROR_CMD,
+ picrossEx.getMessage());
+
+ this.exit();
+ return;
+ }
+
+ menu.addSimpleListener(this);
+ this.view.setContent(menu.getView());
+ }
+
+ /** Starts a random game. */
+ private void startRandomGame() {
+ Thread worker = new Thread() {
+ public void run() {
+ GameMediator game = null;
+
+ try {
+ game =
+ new picross.game.random.RandomGameMediator();
+ } catch (PicrossException picrossEx) {
+ PicrossMediator.this.view
+ .displayError(picrossEx.getMessage());
+ return;
+ }
+
+ PicrossMediator.this.gameLoaded(game);
+ }
+ };
+
+ worker.start();
+ }
+
+ /** Starts a new game. */
+ private void startGame() {
+ Thread worker = new Thread() {
+ public void run() {
+ GameMediator game = null;
+
+ try {
+ game =
+ new picross.game.simple.SimpleGameMediator();
+ } catch (PicrossException picrossEx) {
+ PicrossMediator.this.view
+ .displayError(picrossEx.getMessage());
+ return;
+ }
+
+ PicrossMediator.this.gameLoaded(game);
+ }
+ };
+
+ worker.start();
+ }
+
/**
* Callback used to display the game view.
*
Modified: trunk/src/picross/app/MainMenuAppUI.java
===================================================================
--- trunk/src/picross/app/MainMenuAppUI.java 2008-04-17 08:50:24 UTC (rev 47)
+++ trunk/src/picross/app/MainMenuAppUI.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -84,17 +84,11 @@
super(controller);
- ImageIcon exitIcon =
- Picross.getLocalizedImage(MainMenuAppUI.EXIT_BUTTON_IMAGE);
- JButton exitButton = new JButton(exitIcon);
- exitButton.setActionCommand(MainMenuController.EXIT_CMD);
- exitButton.addActionListener(controller);
- exitButton.setBorder(null);
- exitButton.setBounds(MainMenuAppUI.EXIT_BUTTON_X,
- MainMenuAppUI.EXIT_BUTTON_Y,
- exitIcon.getIconWidth(),
- exitIcon.getIconHeight());
- this.add(exitButton);
+ this.addButton(MainMenuAppUI.EXIT_BUTTON_IMAGE,
+ MainMenuController.EXIT_CMD,
+ controller,
+ MainMenuAppUI.EXIT_BUTTON_X,
+ MainMenuAppUI.EXIT_BUTTON_Y);
}
/*** Methods overloaded from MainMenuUI ***/
Modified: trunk/src/picross/game/random/RandomGameMediator.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMediator.java 2008-04-17 08:50:24 UTC (rev 47)
+++ trunk/src/picross/game/random/RandomGameMediator.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -65,7 +65,7 @@
* @throws PicrossException if there is a problem loading the grid model
* or building the view
*/
- RandomGameMediator() throws PicrossException {
+ public RandomGameMediator() throws PicrossException {
super();
}
@@ -92,7 +92,7 @@
String cmd = e.getCommandName();
if (cmd.equals(RandomGameController.NEXT_CMD)) {
- this.fireEventPerformed(PicrossController.PLAY_CMD);
+ this.fireEventPerformed(PicrossController.RANDOM_GAME_CMD);
return;
}
Added: trunk/src/picross/menus/GameMenuController.java
===================================================================
--- trunk/src/picross/menus/GameMenuController.java (rev 0)
+++ trunk/src/picross/menus/GameMenuController.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -0,0 +1,68 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import fr.cle.mmvcs.Controller;
+import fr.cle.mmvcs.SimpleEvent;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import picross.PicrossController;
+
+/**
+ * Controller for the game menu.
+ *
+ * @author Y. Norsa
+ */
+class GameMenuController extends Controller implements ActionListener {
+ /*** Method overloaded from the class Controller ***/
+
+ /** {@inheritDoc} */
+ @Override
+ public void eventPerformed(SimpleEvent e) { }
+
+ /*** Method implanted from the interface ActionListener ***/
+
+ /** {@inheritDoc} */
+ public void actionPerformed(ActionEvent e) {
+ String cmd = e.getActionCommand();
+
+ if (cmd.equals(PicrossController.RANDOM_GAME_CMD)) {
+ this.fireEventPerformed(cmd);
+ return;
+ }
+ }
+}
+
Property changes on: trunk/src/picross/menus/GameMenuController.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/GameMenuMediator.java
===================================================================
--- trunk/src/picross/menus/GameMenuMediator.java (rev 0)
+++ trunk/src/picross/menus/GameMenuMediator.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -0,0 +1,88 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import fr.cle.mmvcs.Mediateur;
+import fr.cle.mmvcs.SimpleEvent;
+
+import java.io.FileNotFoundException;
+
+import picross.PicrossException;
+
+/**
+ * Mediator for the game menu.
+ *
+ * @author Y. Norsa
+ */
+public class GameMenuMediator extends Mediateur {
+ /*** Field ***/
+
+ private GameMenuUI view;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ */
+ public GameMenuMediator() throws PicrossException {
+ GameMenuController controller = new GameMenuController();
+ controller.addSimpleListener(this);
+
+ try {
+ this.view = new GameMenuUI(controller);
+ } catch (FileNotFoundException fileEx) {
+ throw new PicrossException(fileEx);
+ }
+ }
+
+ /*** Method overloaded from the Mediateur class ***/
+
+ /** {@inheritDoc} */
+ @Override
+ public void eventPerformed(SimpleEvent e) {
+ this.fireEventPerformed(e);
+ }
+
+ /*** Accessor ***/
+
+ /**
+ * Returns the view.
+ *
+ * @return the view
+ */
+ public GameMenuUI getView() {
+ return this.view;
+ }
+}
+
Property changes on: trunk/src/picross/menus/GameMenuMediator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/GameMenuUI.java
===================================================================
--- trunk/src/picross/menus/GameMenuUI.java (rev 0)
+++ trunk/src/picross/menus/GameMenuUI.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -0,0 +1,63 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import java.awt.event.ActionListener;
+
+import java.io.FileNotFoundException;
+
+import picross.PicrossController;
+
+/**
+ * UI for the game menu.
+ *
+ * @author Y. Norsa
+ */
+class GameMenuUI extends MenuUI {
+ /*** Constant ***/
+
+ /** Serialisation ID. */
+ private static final long serialVersionUID = 4472277675596865332L;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ */
+ GameMenuUI(ActionListener listener) throws FileNotFoundException {
+ this.addButton("button-random.png", PicrossController.RANDOM_GAME_CMD,
+ listener, 150, 225);
+ }
+}
+
Property changes on: trunk/src/picross/menus/GameMenuUI.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/menus/MainMenuUI.java
===================================================================
--- trunk/src/picross/menus/MainMenuUI.java 2008-04-17 08:50:24 UTC (rev 47)
+++ trunk/src/picross/menus/MainMenuUI.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -53,23 +53,15 @@
*
* @author Y. Norsa
*/
-public abstract class MainMenuUI extends JPanel {
+public abstract class MainMenuUI extends MenuUI {
/*** Constants ***/
/** Serialisation ID. */
private static final long serialVersionUID = -505088917693050187L;
- /** Background image. */
- private static final String BACKGROUND_IMAGE = "background.png";
-
/** Image for the "play" button. */
private static final String PLAY_BUTTON_IMAGE = "button-play.png";
- /*** Field ***/
-
- /** Background image. */
- private Image image;
-
/*** Constructor ***/
/**
@@ -79,23 +71,11 @@
* @throws FileNotFoundException if a button image can't be found
*/
public MainMenuUI(ActionListener controller) throws FileNotFoundException {
- ImageIcon icon = Picross.getImage(MainMenuUI.BACKGROUND_IMAGE);
- this.setPreferredSize(new Dimension(icon.getIconWidth(),
- icon.getIconHeight()));
- this.image = icon.getImage();
+ super();
- this.setLayout(null);
-
- ImageIcon playIcon =
- Picross.getLocalizedImage(MainMenuUI.PLAY_BUTTON_IMAGE);
- JButton playButton = new JButton(playIcon);
- playButton.setActionCommand(PicrossController.PLAY_CMD);
- playButton.addActionListener(controller);
- playButton.setBorder(null);
- playButton.setBounds(this.getPlayButtonX(), this.getPlayButtonY(),
- playIcon.getIconWidth(),
- playIcon.getIconHeight());
- this.add(playButton);
+ this.addButton(MainMenuUI.PLAY_BUTTON_IMAGE,
+ PicrossController.PLAY_CMD, controller,
+ this.getPlayButtonX(), this.getPlayButtonY());
}
/*** Abstract methods ***/
@@ -113,14 +93,5 @@
* @return Y position of the "play" button
*/
protected abstract int getPlayButtonY();
-
- /*** Method overloaded from the class JPanel ***/
-
- /** {@inheritDoc} */
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
-
- g.drawImage(this.image, 0, 0, null);
- }
}
Added: trunk/src/picross/menus/MenuUI.java
===================================================================
--- trunk/src/picross/menus/MenuUI.java (rev 0)
+++ trunk/src/picross/menus/MenuUI.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -0,0 +1,117 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Image;
+
+import java.awt.event.ActionListener;
+
+import java.io.FileNotFoundException;
+
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+
+import picross.Picross;
+
+/**
+ * Base class for menus.
+ *
+ * @author Y. Norsa
+ */
+abstract class MenuUI extends JPanel {
+ /*** Constant ***/
+
+ /** Background image. */
+ private static final String BACKGROUND_IMAGE = "background.png";
+
+ /*** Field ***/
+
+ /** Background image. */
+ private Image image;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @throws FileNotFoundException if the background image can't be found
+ */
+ MenuUI() throws FileNotFoundException {
+ ImageIcon icon = Picross.getImage(MenuUI.BACKGROUND_IMAGE);
+ this.setPreferredSize(new Dimension(icon.getIconWidth(),
+ icon.getIconHeight()));
+ this.image = icon.getImage();
+
+ this.setLayout(null);
+ }
+
+ /*** Method overloaded from the class JPanel ***/
+
+ /** {@inheritDoc} */
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
+
+ g.drawImage(this.image, 0, 0, null);
+ }
+
+ /*** M\xE9thod ***/
+
+ /**
+ * Helper method to add a button to the menu.
+ *
+ * @param image the image name
+ * @param command the command linked to the button
+ * @param controller listener for the button
+ * @param x x position for the button
+ * @param y y position for the button
+ * @throws FileNotFoundException if a button image can't be found
+ */
+ protected void addButton(String image, String command,
+ ActionListener controller, int x, int y)
+ throws FileNotFoundException {
+
+ ImageIcon buttonIcon = Picross.getLocalizedImage(image);
+ JButton button = new JButton(buttonIcon);
+ button.setActionCommand(command);
+ button.addActionListener(controller);
+ button.setBorder(null);
+ button.setBounds(x, y,
+ buttonIcon.getIconWidth(),
+ buttonIcon.getIconHeight());
+ this.add(button);
+ }
+}
Property changes on: trunk/src/picross/menus/MenuUI.java
___________________________________________________________________
Name: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-17 08:50:17
|
Revision: 47
http://picross.svn.sourceforge.net/picross/?rev=47&view=rev
Author: yvan_norsa
Date: 2008-04-17 01:50:24 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
EDT stuff
Modified Paths:
--------------
trunk/src/picross/grid/GridMediator.java
trunk/src/picross/grid/GridUI.java
Modified: trunk/src/picross/grid/GridMediator.java
===================================================================
--- trunk/src/picross/grid/GridMediator.java 2008-04-16 10:44:37 UTC (rev 46)
+++ trunk/src/picross/grid/GridMediator.java 2008-04-17 08:50:24 UTC (rev 47)
@@ -38,6 +38,8 @@
import java.io.FileNotFoundException;
+import java.lang.reflect.InvocationTargetException;
+
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
@@ -89,27 +91,29 @@
final CompletedHints hints = this.model.getCompletedHints();
try {
- SwingUtilities.invokeLater(new Runnable() {
+ SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
- try {
- GridMediator.this.view = new GridUI(width, height,
- boxes,
- colData,
- rowData,
- hints,
- controller);
- } catch (FileNotFoundException fileEx) {
- //throw new PicrossException(fileEx);
- throw new
- RuntimeException(new PicrossException(fileEx));
- }
-
- controller.setView(GridMediator.this.view);
+ GridMediator.this.view = new GridUI(width, height,
+ boxes,
+ colData,
+ rowData,
+ hints,
+ controller);
}
});
- } catch (RuntimeException runtimeEx) {
- throw ((PicrossException) runtimeEx.getCause());
+ } catch (InterruptedException intEx) {
+ intEx.printStackTrace();
+ } catch (InvocationTargetException targetEx) {
+ targetEx.printStackTrace();
}
+
+ try {
+ this.view.init();
+ } catch (FileNotFoundException fileEx) {
+ throw new PicrossException(fileEx);
+ }
+
+ controller.setView(this.view);
}
/*** Method overloaded from the class Mediateur ***/
Modified: trunk/src/picross/grid/GridUI.java
===================================================================
--- trunk/src/picross/grid/GridUI.java 2008-04-16 10:44:37 UTC (rev 46)
+++ trunk/src/picross/grid/GridUI.java 2008-04-17 08:50:24 UTC (rev 47)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -214,14 +214,13 @@
* @param rowData rows hints
* @param completedHints list of completed hints
* @param controller controller for the grid
- * @throws FileNotFoundException if an image is missing
*/
GridUI(int width, int height,
Box[][] boxes,
int[][] colData,
int[][] rowData,
CompletedHints completedHints,
- GridController controller) throws FileNotFoundException {
+ GridController controller) {
super(true);
this.controller = controller;
@@ -240,6 +239,67 @@
this.completedHints = completedHints;
+ // Contain the state of the grid
+ this.boxes = boxes;
+ }
+
+ /*** Method overloaded from JPanel ***/
+
+ /** {@inheritDoc} */
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
+
+ Graphics2D newG = (Graphics2D) g.create();
+
+ Rectangle clipRect = newG.getClipBounds();
+
+ if (this.topHintsRect.intersects(clipRect)) {
+ this.drawTopHints(newG);
+ }
+
+ if (this.leftHintsRect.intersects(clipRect)) {
+ this.drawLeftHints(newG);
+ }
+
+ // Paints the boxes
+ for (int i = 0; i < this.width; i++) {
+ for (int j = 0; j < this.height; j++) {
+ //GridUI.log.debug("currentRect : " + i + "," + j);
+
+ Rectangle currentRect = this.boxes[i][j].getRect();
+
+ if (currentRect.intersects(clipRect)) {
+ if (this.boxes[i][j] == this.rollover) {
+ this.boxes[i][j].getRolloverIcon()
+ .paintIcon(this, newG,
+ currentRect.x, currentRect.y);
+ } else {
+ this.boxes[i][j].getIcon().paintIcon(this, newG,
+ currentRect.x,
+ currentRect.y);
+ }
+ }
+ }
+ }
+
+ // Draws the blocks
+ newG.setColor(GridUI.BLOCKS_COLOR);
+
+ for (Line2D line : this.blocksLines) {
+ newG.draw(line);
+ }
+
+ newG.dispose();
+ }
+
+ /*** Methods ***/
+
+ /**
+ * Initializes various stuff.
+ *
+ * @throws FileNotFoundException if an image is missing
+ */
+ void init() throws FileNotFoundException {
// Computes the size of a hint
FontRenderContext frc = new FontRenderContext(null, true, true);
@@ -299,9 +359,6 @@
this.centerHighHintWidth =
(hintBoxWidth / 2) - (highHintWidth / 2);
- // Contain the state of the grid
- this.boxes = boxes;
-
for (int i = 0; i < this.width; i++) {
for (int j = 0; j < this.height; j++) {
/*
@@ -332,57 +389,6 @@
+ GridUI.BOTTOM_SPACE));
}
- /*** Method overloaded from JPanel ***/
-
- /** {@inheritDoc} */
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
-
- Graphics2D newG = (Graphics2D) g.create();
-
- Rectangle clipRect = newG.getClipBounds();
-
- if (this.topHintsRect.intersects(clipRect)) {
- this.drawTopHints(newG);
- }
-
- if (this.leftHintsRect.intersects(clipRect)) {
- this.drawLeftHints(newG);
- }
-
- // Paints the boxes
- for (int i = 0; i < this.width; i++) {
- for (int j = 0; j < this.height; j++) {
- //GridUI.log.debug("currentRect : " + i + "," + j);
-
- Rectangle currentRect = this.boxes[i][j].getRect();
-
- if (currentRect.intersects(clipRect)) {
- if (this.boxes[i][j] == this.rollover) {
- this.boxes[i][j].getRolloverIcon()
- .paintIcon(this, newG,
- currentRect.x, currentRect.y);
- } else {
- this.boxes[i][j].getIcon().paintIcon(this, newG,
- currentRect.x,
- currentRect.y);
- }
- }
- }
- }
-
- // Draws the blocks
- newG.setColor(GridUI.BLOCKS_COLOR);
-
- for (Line2D line : this.blocksLines) {
- newG.draw(line);
- }
-
- newG.dispose();
- }
-
- /*** Methods ***/
-
/** Precomputes the blocks lines. */
private void initBlocks() {
this.blocksLines = new ArrayList<Line2D>();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-16 10:44:29
|
Revision: 46
http://picross.svn.sourceforge.net/picross/?rev=46&view=rev
Author: yvan_norsa
Date: 2008-04-16 03:44:37 -0700 (Wed, 16 Apr 2008)
Log Message:
-----------
EDT stuff
Modified Paths:
--------------
trunk/src/picross/PicrossMediator.java
trunk/src/picross/app/PicrossApp.java
trunk/src/picross/game/GameMediator.java
trunk/src/picross/grid/GridMediator.java
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2008-04-16 09:32:18 UTC (rev 45)
+++ trunk/src/picross/PicrossMediator.java 2008-04-16 10:44:37 UTC (rev 46)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -38,6 +38,8 @@
import fr.cle.mmvcs.Mediateur;
import fr.cle.mmvcs.SimpleEvent;
+import javax.swing.SwingUtilities;
+
//import org.apache.log4j.Logger;
import picross.game.GameMediator;
@@ -106,18 +108,29 @@
//this.view.setContent(grid.getView());
//GameMediator game = new picross.game.random.RandomGameMediator();
- GameMediator game = null;
+ //GameMediator game = null;
- try {
- game = new picross.game.simple.SimpleGameMediator();
- } catch (PicrossException picrossEx) {
- this.view.displayError(picrossEx.getMessage());
- return;
- }
+ Thread worker = new Thread() {
+ public void run() {
+ GameMediator game = null;
- game.addSimpleListener(this);
- this.view.setContent(game.getView());
+ try {
+ game =
+ new picross.game.simple.SimpleGameMediator();
+ } catch (PicrossException picrossEx) {
+ PicrossMediator.this.view
+ .displayError(picrossEx.getMessage());
+ return;
+ }
+ //game.addSimpleListener(this);
+ //this.view.setContent(game.getView());
+ PicrossMediator.this.gameLoaded(game);
+ }
+ };
+
+ worker.start();
+
return;
}
@@ -134,11 +147,26 @@
}
}
- /*** Method ***/
+ /*** Methods ***/
/** Exits the application. */
private void exit() {
this.fireEventPerformed(PicrossController.DISPOSE_CMD);
}
+
+ /**
+ * Callback used to display the game view.
+ *
+ * @param game game reference
+ */
+ private void gameLoaded(final GameMediator game) {
+ game.addSimpleListener(this);
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ PicrossMediator.this.view.setContent(game.getView());
+ }
+ });
+ }
}
Modified: trunk/src/picross/app/PicrossApp.java
===================================================================
--- trunk/src/picross/app/PicrossApp.java 2008-04-16 09:32:18 UTC (rev 45)
+++ trunk/src/picross/app/PicrossApp.java 2008-04-16 10:44:37 UTC (rev 46)
@@ -66,9 +66,10 @@
* @param args command line parameters
*/
public static void main(String[] args) {
+ PicrossApp.setupDebugging();
+
SwingUtilities.invokeLater(new Runnable() {
public void run() {
- PicrossApp.setupDebugging();
new PicrossApp();
}
});
Modified: trunk/src/picross/game/GameMediator.java
===================================================================
--- trunk/src/picross/game/GameMediator.java 2008-04-16 09:32:18 UTC (rev 45)
+++ trunk/src/picross/game/GameMediator.java 2008-04-16 10:44:37 UTC (rev 46)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -37,6 +37,7 @@
import fr.cle.mmvcs.SimpleEvent;
import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
//import org.apache.log4j.Logger;
@@ -72,14 +73,21 @@
public GameMediator() throws PicrossException {
PicrossGrid model = this.initModel();
- int width = model.getWidth();
- int height = model.getHeight();
+ final int width = model.getWidth();
+ final int height = model.getHeight();
- GridMediator grid = new GridMediator(width, height,
+ final GridMediator grid = new GridMediator(width, height,
model.getData());
grid.addSimpleListener(this);
- this.view = this.initView(width, height, grid.getView());
+ // The view has to be init'ed on the EDT
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ GameMediator.this.view =
+ GameMediator.this.initView(width, height,
+ grid.getView());
+ }
+ });
}
/*** Abstract methods ***/
Modified: trunk/src/picross/grid/GridMediator.java
===================================================================
--- trunk/src/picross/grid/GridMediator.java 2008-04-16 09:32:18 UTC (rev 45)
+++ trunk/src/picross/grid/GridMediator.java 2008-04-16 10:44:37 UTC (rev 46)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -39,6 +39,7 @@
import java.io.FileNotFoundException;
import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
//import org.apache.log4j.Logger;
@@ -73,27 +74,42 @@
* @param data grid content
* @throws PicrossException if there is a probleme while building the view
*/
- public GridMediator(int width, int height, boolean[][] data)
+ public GridMediator(final int width, final int height, boolean[][] data)
throws PicrossException {
this.model = new GridModel(this, data);
- GridController controller = new GridController();
+ final GridController controller = new GridController();
controller.addSimpleListener(this);
this.addSimpleListener(controller);
+ final Box[][] boxes = this.model.getBoxes();
+ final int[][] colData = this.model.getColData();
+ final int[][] rowData = this.model.getRowData();
+ final CompletedHints hints = this.model.getCompletedHints();
+
try {
- this.view = new GridUI(width, height,
- this.model.getBoxes(),
- this.model.getColData(),
- this.model.getRowData(),
- this.model.getCompletedHints(),
- controller);
- } catch (FileNotFoundException fileEx) {
- throw new PicrossException(fileEx);
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ try {
+ GridMediator.this.view = new GridUI(width, height,
+ boxes,
+ colData,
+ rowData,
+ hints,
+ controller);
+ } catch (FileNotFoundException fileEx) {
+ //throw new PicrossException(fileEx);
+ throw new
+ RuntimeException(new PicrossException(fileEx));
+ }
+
+ controller.setView(GridMediator.this.view);
+ }
+ });
+ } catch (RuntimeException runtimeEx) {
+ throw ((PicrossException) runtimeEx.getCause());
}
-
- controller.setView(this.view);
}
/*** Method overloaded from the class Mediateur ***/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-16 09:32:11
|
Revision: 45
http://picross.svn.sourceforge.net/picross/?rev=45&view=rev
Author: yvan_norsa
Date: 2008-04-16 02:32:18 -0700 (Wed, 16 Apr 2008)
Log Message:
-----------
fixed cast
Modified Paths:
--------------
trunk/src/picross/app/PicrossApp.java
Modified: trunk/src/picross/app/PicrossApp.java
===================================================================
--- trunk/src/picross/app/PicrossApp.java 2008-04-16 09:31:04 UTC (rev 44)
+++ trunk/src/picross/app/PicrossApp.java 2008-04-16 09:32:18 UTC (rev 45)
@@ -82,10 +82,10 @@
Class managerClass = Class.forName(
"org.jdesktop.swinghelper.debug.CheckThreadViolationRepaintManager");
java.lang.reflect.Constructor construct =
- managerClass.getConstructor((Class) null);
+ managerClass.getConstructor((Class[]) null);
javax.swing.RepaintManager manag =
(javax.swing.RepaintManager) construct
- .newInstance((Class) null);
+ .newInstance((Object[]) null);
javax.swing.RepaintManager.setCurrentManager(manag);
} catch (ClassNotFoundException classEx) {
} catch (NoSuchMethodException methodEx) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-16 09:31:03
|
Revision: 44
http://picross.svn.sourceforge.net/picross/?rev=44&view=rev
Author: yvan_norsa
Date: 2008-04-16 02:31:04 -0700 (Wed, 16 Apr 2008)
Log Message:
-----------
added debug target
Modified Paths:
--------------
trunk/build.xml
trunk/src/picross/app/PicrossApp.java
Added Paths:
-----------
trunk/lib/debug.jar
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-04-16 09:24:40 UTC (rev 43)
+++ trunk/build.xml 2008-04-16 09:31:04 UTC (rev 44)
@@ -19,6 +19,8 @@
<property name="bundleHelper.jar"
value="${lib.dir}/bundleHelper.jar" />
+ <property name="debug.jar"
+ value="${lib.dir}/debug.jar" />
<property name="junit.jar"
value="${lib.dir}/junit.jar" />
<property name="log4j.jar"
@@ -109,6 +111,22 @@
</java>
</target>
+ <target name="run-debug"
+ depends="dist">
+ <java classname="picross.app.PicrossApp"
+ failonerror="true"
+ fork="true"
+ dir=".">
+ <classpath>
+ <pathelement location="${jar.name}" />
+ <pathelement location="${bundleHelper.jar}" />
+ <pathelement location="${log4j.jar}" />
+ <pathelement location="${mmvcs.jar}" />
+ <pathelement location="${debug.jar}" />
+ </classpath>
+ </java>
+ </target>
+
<target name="test"
depends="dist">
<junit haltonfailure="yes"
Added: trunk/lib/debug.jar
===================================================================
(Binary files differ)
Property changes on: trunk/lib/debug.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/picross/app/PicrossApp.java
===================================================================
--- trunk/src/picross/app/PicrossApp.java 2008-04-16 09:24:40 UTC (rev 43)
+++ trunk/src/picross/app/PicrossApp.java 2008-04-16 09:31:04 UTC (rev 44)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -68,9 +68,50 @@
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
+ PicrossApp.setupDebugging();
new PicrossApp();
}
});
}
+
+ /*** Static method ***/
+
+ /** Tries to load the debugging tools from debug.jar. */
+ private static void setupDebugging() {
+ try {
+ Class managerClass = Class.forName(
+ "org.jdesktop.swinghelper.debug.CheckThreadViolationRepaintManager");
+ java.lang.reflect.Constructor construct =
+ managerClass.getConstructor((Class) null);
+ javax.swing.RepaintManager manag =
+ (javax.swing.RepaintManager) construct
+ .newInstance((Class) null);
+ javax.swing.RepaintManager.setCurrentManager(manag);
+ } catch (ClassNotFoundException classEx) {
+ } catch (NoSuchMethodException methodEx) {
+ methodEx.printStackTrace();
+ } catch (InstantiationException instantiationEx) {
+ instantiationEx.printStackTrace();
+ } catch (IllegalAccessException accessEx) {
+ accessEx.printStackTrace();
+ } catch (java.lang.reflect.InvocationTargetException targetEx) {
+ targetEx.printStackTrace();
+ }
+
+ try {
+ Class monitorClass = Class.forName(
+ "org.jdesktop.swinghelper.debug.EventDispatchThreadHangMonitor");
+ java.lang.reflect.Method method =
+ monitorClass.getMethod("initMonitoring");
+ method.invoke(null);
+ } catch (ClassNotFoundException classEx) {
+ } catch (NoSuchMethodException methodEx) {
+ methodEx.printStackTrace();
+ } catch (IllegalAccessException accessEx) {
+ accessEx.printStackTrace();
+ } catch (java.lang.reflect.InvocationTargetException targetEx) {
+ targetEx.printStackTrace();
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-16 09:24:35
|
Revision: 43
http://picross.svn.sourceforge.net/picross/?rev=43&view=rev
Author: yvan_norsa
Date: 2008-04-16 02:24:40 -0700 (Wed, 16 Apr 2008)
Log Message:
-----------
indentation fix
Modified Paths:
--------------
trunk/build.xml
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2007-06-29 07:02:39 UTC (rev 42)
+++ trunk/build.xml 2008-04-16 09:24:40 UTC (rev 43)
@@ -54,12 +54,12 @@
</target>
<path id="classpath">
- <pathelement location="${build.dir}" />
+ <pathelement location="${build.dir}" />
- <pathelement location="${bundleHelper.jar}" />
- <pathelement location="${junit.jar}" />
- <pathelement location="${log4j.jar}" />
- <pathelement location="${mmvcs.jar}" />
+ <pathelement location="${bundleHelper.jar}" />
+ <pathelement location="${junit.jar}" />
+ <pathelement location="${log4j.jar}" />
+ <pathelement location="${mmvcs.jar}" />
</path>
<target name="compile"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2007-06-29 07:02:43
|
Revision: 42
http://picross.svn.sourceforge.net/picross/?rev=42&view=rev
Author: yvan_norsa
Date: 2007-06-29 00:02:39 -0700 (Fri, 29 Jun 2007)
Log Message:
-----------
unit tests
Modified Paths:
--------------
trunk/build.xml
trunk/src/picross/game/random/RandomPicrossModel.java
trunk/src/picross/grid/Box.java
trunk/src/picross/grid/CompletedHints.java
trunk/src/picross/grid/FillCommand.java
trunk/src/picross/grid/GridController.java
trunk/src/picross/grid/GridMediator.java
trunk/src/picross/grid/GridModel.java
trunk/src/picross/grid/PaintCommand.java
Added Paths:
-----------
trunk/src/picross/grid/BoxTest.java
trunk/src/picross/grid/CompletedHintsTest.java
trunk/src/picross/grid/FillCommandTest.java
trunk/src/picross/grid/GridAction.java
trunk/src/picross/grid/GridModelTest.java
trunk/src/picross/grid/IGridMediator.java
trunk/src/picross/grid/PaintCommandTest.java
trunk/src/picross/grid/tests/
trunk/src/picross/grid/tests/IGridMediatorStub.java
Removed Paths:
-------------
trunk/src/picross/grid/CompletedCommand.java
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/build.xml 2007-06-29 07:02:39 UTC (rev 42)
@@ -149,10 +149,10 @@
<target name="doc"
depends="compile">
<!-- FIXME test classes which are not in a "tests" subpackage
- shouldn't be included in the generated Javadoc -->
- <javadoc destdir="${doc.dir}"
- link="http://java.sun.com/j2se/1.5.0/docs/api">
- <packageset dir="${src.dir}"
+ shouldn't be included in the generated Javadoc -->
+ <javadoc destdir="${doc.dir}" access="private"
+ link="http://java.sun.com/j2se/1.5.0/docs/api">
+ <packageset dir="${src.dir}"
defaultexcludes="yes">
<exclude name="**/tests/**" />
</packageset>
Modified: trunk/src/picross/game/random/RandomPicrossModel.java
===================================================================
--- trunk/src/picross/game/random/RandomPicrossModel.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/game/random/RandomPicrossModel.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -69,9 +69,17 @@
this.data = new boolean[this.width][this.height];
- for (int i = 0; i < this.width; i++) {
- for (int j = 0; j < this.height; j++) {
- this.data[i][j] = rand.nextBoolean();
+ boolean gridOK = false;
+
+ while (!gridOK) {
+ for (int i = 0; i < this.width; i++) {
+ for (int j = 0; j < this.height; j++) {
+ this.data[i][j] = rand.nextBoolean();
+
+ if (this.data[i][j]) {
+ gridOK = true;
+ }
+ }
}
}
}
Modified: trunk/src/picross/grid/Box.java
===================================================================
--- trunk/src/picross/grid/Box.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/grid/Box.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -233,8 +233,14 @@
* Permits to define the rectangle occupied by the box.
*
* @param rect rectangle of the box
+ * @throws IllegalArgumentException if <code>rect</code>
+ * is <code>null</code>
*/
- void setRect(Rectangle rect) {
+ void setRect(Rectangle rect) throws IllegalArgumentException {
+ if (rect == null) {
+ throw new IllegalArgumentException("rect cannot be null");
+ }
+
this.rect = rect;
}
Added: trunk/src/picross/grid/BoxTest.java
===================================================================
--- trunk/src/picross/grid/BoxTest.java (rev 0)
+++ trunk/src/picross/grid/BoxTest.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -0,0 +1,156 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.grid;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Y. Norsa
+ */
+public class BoxTest {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private Box box = null;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ BoxTest() {
+ }
+ */
+ /*** M\xE9thode ***/
+
+ @Before
+ public void setUp() {
+ this.box = new Box();
+ }
+
+ @Test
+ public void testCheck() {
+ this.box.check();
+ Assert.assertTrue("box unchecked", this.box.isChecked());
+ }
+
+ @Test
+ public void testCross() {
+ this.box.cross();
+ Assert.assertTrue("box not crossed", this.box.isCrossed());
+ }
+
+ @Test
+ public void testEmpty() {
+ this.box.empty();
+ Assert.assertTrue("box not empty", this.box.isEmpty());
+ }
+
+ @Test
+ public void testEquals() {
+ Assert.assertFalse("this.box = null", this.box.equals(null));
+ Assert.assertTrue("box != box", this.box.equals(this.box));
+
+ this.box.check();
+
+ Box box2 = new Box();
+ Assert.assertFalse("box = box2", this.box.equals(box2));
+
+ box2.check();
+
+ Assert.assertTrue("box != box2", this.box.equals(box2));
+ }
+
+ @Test
+ public void testgetIcon() {
+ Assert.assertNotNull("empty icon = null", this.box.getIcon());
+
+ this.box.check();
+ Assert.assertNotNull("checked icon = null", this.box.getIcon());
+
+ this.box.cross();
+ Assert.assertNotNull("crossed icon = null", this.box.getIcon());
+ }
+
+ @Test
+ public void testGetRolloverIcon() {
+ Assert.assertNotNull("rollover empty icon = null",
+ this.box.getRolloverIcon());
+
+ this.box.check();
+ Assert.assertNotNull("rollover checked icon = null",
+ this.box.getRolloverIcon());
+
+ this.box.cross();
+ Assert.assertNotNull("rollover crossed icon = null",
+ this.box.getRolloverIcon());
+ }
+
+ @Test
+ public void testIsChecked() {
+ this.box.check();
+
+ Assert.assertFalse("box crossed AND checked", this.box.isCrossed());
+ Assert.assertFalse("box empty AND checked", this.box.isEmpty());
+ }
+
+ @Test
+ public void testIsCrossed() {
+ this.box.cross();
+
+ Assert.assertFalse("box checked AND crossed", this.box.isChecked());
+ Assert.assertFalse("box empty AND crossed", this.box.isEmpty());
+ }
+
+ @Test
+ public void testIsEmpty() {
+ Assert.assertFalse("box checked AND empty", this.box.isChecked());
+ Assert.assertFalse("box crossed AND empty", this.box.isCrossed());
+ }
+
+ @Test
+ public void testSetRect() {
+ try {
+ this.box.setRect(null);
+ Assert.fail("box.setRect(null)");
+ } catch (IllegalArgumentException argEx) { }
+ }
+}
+
Property changes on: trunk/src/picross/grid/BoxTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted: trunk/src/picross/grid/CompletedCommand.java
===================================================================
--- trunk/src/picross/grid/CompletedCommand.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/grid/CompletedCommand.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -1,107 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (c) 2007
- *
- * This software is governed by the CeCILL license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL license and that you accept its terms.
- */
-
-
-package picross.grid;
-
-import fr.cle.mmvcs.Command;
-
-/**
- * Command indicating that a hint has been completed.
- *
- * @author Y. Norsa
- */
-final class CompletedCommand extends Command {
- /*** Constants ***/
-
- /** A column hint has been completed. */
- static final int COLUMN = 0;
-
- /** A row hint has been completed. */
- static final int ROW = 1;
-
- /*** Fields ***/
-
- /** Type of hint that has been completed. */
- private int type;
-
- /** Number of the column or row. */
- private int position;
-
- /** Position of the hint in the column or row. */
- private int hintPos;
-
- /*** Constructor ***/
-
- /**
- * Constructor.
- *
- * @param type type of hint that has been completed
- * @param position number of the column or row
- * @param hintPos position of the hint in the column or row
- */
- CompletedCommand(int type, int position, int hintPos) {
- this.type = type;
- this.position = position;
- this.hintPos = hintPos;
- }
-
- /*** Accessors ***/
-
- /**
- * Returns the type of hint that has been completed.
- *
- * @return type of hint that has been completed
- */
- int getType() {
- return this.type;
- }
-
- /**
- * Returns the number of the column or row.
- *
- * @return number of the column or row
- */
- int getPosition() {
- return this.position;
- }
-
- /**
- * Returns the position of the hint in the column or row.
- *
- * @return position of the hint in the column or row
- */
- int getHintPos() {
- return this.hintPos;
- }
-}
-
Modified: trunk/src/picross/grid/CompletedHints.java
===================================================================
--- trunk/src/picross/grid/CompletedHints.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/grid/CompletedHints.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -59,9 +59,32 @@
* @param colsHintsHeight height of the column hints list
* @param rowsHintsWidth width of the row hints list
* @param rowsHintsHeight height of the row hints list
+ * @throws IllegalArgumentException if one of the parameters is <= 0
*/
CompletedHints(int colsHintsWidth, int colsHintsHeight,
- int rowsHintsWidth, int rowsHintsHeight) {
+ int rowsHintsWidth, int rowsHintsHeight)
+ throws IllegalArgumentException {
+
+ if (colsHintsWidth <= 0) {
+ throw new IllegalArgumentException("colsHintsWidth must be "
+ + "greater than 0");
+ }
+
+ if (colsHintsHeight <= 0) {
+ throw new IllegalArgumentException("colsHintsHeight must be "
+ + "greater than 0");
+ }
+
+ if (rowsHintsWidth <= 0) {
+ throw new IllegalArgumentException("rowsHintsWidth must be "
+ + "greater than 0");
+ }
+
+ if (rowsHintsHeight <= 0) {
+ throw new IllegalArgumentException("rowsHintsHeight must be "
+ + "greater than 0");
+ }
+
this.completedCols = new boolean[colsHintsWidth][colsHintsHeight];
this.completedRows = new boolean[rowsHintsWidth][rowsHintsHeight];
}
@@ -84,8 +107,19 @@
*
* @param column column number
* @return list of completed hints in the column
+ * @throws IllegalArgumentException if <code>column</code> is lesser
+ * than 0 or greater than the number of hints columns
*/
- List<Integer> getCompleteColHints(int column) {
+ List<Integer> getCompleteColHints(int column)
+ throws IllegalArgumentException {
+
+ if (column < 0 || column >= this.completedCols.length) {
+ throw new IllegalArgumentException("column must be between 0 "
+ + "and "
+ + (this.completedCols.length
+ - 1));
+ }
+
List<Integer> res = new ArrayList<Integer>();
for (int i = 0; i < this.completedCols[column].length; i++) {
@@ -133,8 +167,18 @@
*
* @param row row number
* @return list of completed hints in the row
+ * @throws IllegalArgumentException if <code>row</code> is lesser
+ * than 0 or greater than the number of hints row
*/
- List<Integer> getCompleteRowHints(int row) {
+ List<Integer> getCompleteRowHints(int row)
+ throws IllegalArgumentException {
+
+ if (row < 0 || row >= this.completedRows.length) {
+ throw new IllegalArgumentException("row must be between 0 and "
+ + (this.completedRows.length
+ - 1));
+ }
+
List<Integer> res = new ArrayList<Integer>();
for (int i = 0; i < this.completedRows[row].length; i++) {
Added: trunk/src/picross/grid/CompletedHintsTest.java
===================================================================
--- trunk/src/picross/grid/CompletedHintsTest.java (rev 0)
+++ trunk/src/picross/grid/CompletedHintsTest.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -0,0 +1,205 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.grid;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Y. Norsa
+ */
+public class CompletedHintsTest {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ CompletedHints hints = null;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ CompletedHintsTest() {
+ }
+ */
+ /*** M\xE9thode ***/
+
+ @Before
+ public void setUp() {
+ this.hints = new CompletedHints(10, 10, 10, 10);
+ }
+
+ @Test
+ public void testCompletedHints() {
+ try {
+ new CompletedHints(-1, -1, -1, -1);
+ Assert.fail("colsHintsWidth = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(0, -1, -1, -1);
+ Assert.fail("colsHintsWidth = 0");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(1, -1, -1, -1);
+ Assert.fail("colsHintsHeight = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(1, 0, -1, -1);
+ Assert.fail("colsHintsHeight = 0");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(1, 1, -1, -1);
+ Assert.fail("rowsHintsWidth = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(1, 1, 0, -1);
+ Assert.fail("rowsHintsWidth = 0");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(1, 1, 1, -1);
+ Assert.fail("rowsHintsHeight = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(1, 1, 1, 0);
+ Assert.fail("rowsHintsHeight = 0");
+ } catch (IllegalArgumentException argEx) { }
+ }
+
+ @Test
+ public void testClearColHint() {
+ this.hints.setCompleteColHint(3, 4);
+ this.hints.clearColHint(3, 4);
+ Assert.assertFalse(this.hints.isColHintComplete(3, 4));
+ }
+
+ @Test
+ public void testClearRowHint() {
+ this.hints.setCompleteRowHint(8, 2);
+ this.hints.clearRowHint(8, 2);
+ Assert.assertFalse(this.hints.isRowHintComplete(8, 2));
+ }
+
+ @Test
+ public void testGetCompleteColHints() {
+ try {
+ this.hints.getCompleteColHints(-1);
+ Assert.fail("column = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ this.hints.getCompleteColHints(42);
+ Assert.fail("column = 42");
+ } catch (IllegalArgumentException argEx) { }
+
+ List<Integer> complete = this.hints.getCompleteColHints(4);
+ Assert.assertNotNull("complete = null", complete);
+ int size = complete.size();
+ Assert.assertTrue("size = " + size, (size == 0));
+
+ this.hints.setCompleteColHint(4, 0);
+ this.hints.setCompleteColHint(4, 9);
+
+ complete = this.hints.getCompleteColHints(4);
+ Assert.assertNotNull("complete = null", complete);
+ size = complete.size();
+ Assert.assertTrue("size = " + size, (size == 2));
+
+ int nb1 = complete.get(0);
+ Assert.assertTrue("nb1 = " + nb1, (nb1 == 0));
+
+ int nb2 = complete.get(1);
+ Assert.assertTrue("nb2 = " + nb2, (nb2 == 9));
+ }
+
+ @Test
+ public void testGetCompleteRowHints() {
+ try {
+ this.hints.getCompleteRowHints(-1);
+ Assert.fail("row = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ this.hints.getCompleteRowHints(42);
+ Assert.fail("row = 42");
+ } catch (IllegalArgumentException argEx) { }
+
+ List<Integer> complete = this.hints.getCompleteRowHints(9);
+ Assert.assertNotNull("complete = null", complete);
+ int size = complete.size();
+ Assert.assertTrue("size = " + size, (size == 0));
+
+ this.hints.setCompleteRowHint(9, 3);
+ this.hints.setCompleteRowHint(9, 6);
+
+ complete = this.hints.getCompleteRowHints(9);
+ Assert.assertNotNull("complete = null", complete);
+ size = complete.size();
+ Assert.assertTrue("size = " + size, (size == 2));
+
+ int nb1 = complete.get(0);
+ Assert.assertTrue("nb1 = " + nb1, (nb1 == 3));
+
+ int nb2 = complete.get(1);
+ Assert.assertTrue("nb2 = " + nb2, (nb2 == 6));
+ }
+
+ @Test
+ public void testIsColHintCompleteAndSetCompleteColHint() {
+ Assert.assertFalse(this.hints.isColHintComplete(0, 0));
+ this.hints.setCompleteColHint(0, 0);
+ Assert.assertTrue(this.hints.isColHintComplete(0, 0));
+ }
+
+ @Test
+ public void testIsRowHintCompleteAndSetCompleteRowHint() {
+ Assert.assertFalse(this.hints.isRowHintComplete(5, 5));
+ this.hints.setCompleteRowHint(5, 5);
+ Assert.assertTrue(this.hints.isRowHintComplete(5, 5));
+ }
+}
+
Property changes on: trunk/src/picross/grid/CompletedHintsTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/grid/FillCommand.java
===================================================================
--- trunk/src/picross/grid/FillCommand.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/grid/FillCommand.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -50,7 +50,8 @@
private int column;
/** Type of the action. */
- private int type;
+ //private int type;
+ private GridAction type;
/*** Constructor ***/
@@ -60,8 +61,26 @@
* @param row row of the box to fill
* @param column column of the box to fill
* @param type type of the action
+ * @throws IllegalArgumentException if <code>row</code>
+ * or <code>column</code> is less than 0, or <code>type</code>
+ * is <code>GridAction.UNKNOWN</code>
*/
- FillCommand(int row, int column, int type) {
+ //FillCommand(int row, int column, int type) {
+ FillCommand(int row, int column, GridAction type)
+ throws IllegalArgumentException {
+
+ if (row < 0) {
+ throw new IllegalArgumentException("row can't be less than 0");
+ }
+
+ if (column < 0) {
+ throw new IllegalArgumentException("column can't be less than 0");
+ }
+
+ if (type == GridAction.UNKNOWN) {
+ throw new IllegalArgumentException("type can't be UNKNOWN");
+ }
+
this.row = row;
this.column = column;
this.type = type;
@@ -99,7 +118,8 @@
*
* @return type of the action
*/
- int getType() {
+ //int getType() {
+ GridAction getType() {
return this.type;
}
}
Added: trunk/src/picross/grid/FillCommandTest.java
===================================================================
--- trunk/src/picross/grid/FillCommandTest.java (rev 0)
+++ trunk/src/picross/grid/FillCommandTest.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -0,0 +1,80 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.grid;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author Y. Norsa
+ */
+public class FillCommandTest {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ FillCommandTest() {
+ }
+ */
+ /*** M\xE9thode ***/
+
+ @Test
+ public void testFillCommand() {
+ try {
+ new FillCommand(-1, -1, GridAction.UNKNOWN);
+ Assert.fail("row = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new FillCommand(0, -1, GridAction.UNKNOWN);
+ Assert.fail("column = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new FillCommand(0, 0, GridAction.UNKNOWN);
+ Assert.fail("UNKNOWN type");
+ } catch (IllegalArgumentException argEx) { }
+
+ new FillCommand(0, 0, GridAction.CHECK);
+ }
+}
+
Property changes on: trunk/src/picross/grid/FillCommandTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/grid/GridAction.java
===================================================================
--- trunk/src/picross/grid/GridAction.java (rev 0)
+++ trunk/src/picross/grid/GridAction.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -0,0 +1,59 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.grid;
+
+/**
+ * @author Y. Norsa
+ */
+enum GridAction {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ */
+
+ /*** M\xE9thode ***/
+ UNKNOWN,
+ CHECK,
+ CROSS
+}
+
Property changes on: trunk/src/picross/grid/GridAction.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/grid/GridController.java
===================================================================
--- trunk/src/picross/grid/GridController.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/grid/GridController.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -76,10 +76,10 @@
static final String REPAINT_LEFT_HINTS_CMD = "REPAINT_LEFT_HINTS_CMD";
/** Checking a box. */
- static final int CHECK_ACTION = 0;
+ //static final int CHECK_ACTION = 0;
/** Crossing a box. */
- static final int CROSS_ACTION = 1;
+ //static final int CROSS_ACTION = 1;
/*** Static field ***/
@@ -193,7 +193,8 @@
if (this.view.isInGrid(point)) {
int row = this.view.getRow(point);
int column = this.view.getColumn(point);
- int type = GridController.modifiersToType(modifiers);
+ //int type = GridController.modifiersToType(modifiers);
+ GridAction type = GridController.modifiersToType(modifiers);
//GridController.log.debug("type : " + type);
@@ -209,16 +210,20 @@
* @param modifiers mouse event modifiers
* @return corresponding action, or -1
*/
- private static int modifiersToType(int modifiers) {
+ //private static int modifiersToType(int modifiers) {
+ private static GridAction modifiersToType(int modifiers) {
switch (modifiers) {
case MouseEvent.BUTTON1_MASK:
- return GridController.CHECK_ACTION;
+ //return GridController.CHECK_ACTION;
+ return GridAction.CHECK;
case MouseEvent.BUTTON3_MASK:
- return GridController.CROSS_ACTION;
+ //return GridController.CROSS_ACTION;
+ return GridAction.CROSS;
default:
- return -1;
+ //return -1;
+ return GridAction.UNKNOWN;
}
}
Modified: trunk/src/picross/grid/GridMediator.java
===================================================================
--- trunk/src/picross/grid/GridMediator.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/grid/GridMediator.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -49,7 +49,7 @@
*
* @author Y. Norsa
*/
-public final class GridMediator extends Mediateur {
+public final class GridMediator extends Mediateur implements IGridMediator {
/*** Static field ***/
/** Class' logger. */
@@ -106,7 +106,7 @@
if (cmd.equals(GridController.FILL_CMD)) {
FillCommand command = (FillCommand) e.getCommand();
- this.model.checkBox(command.getRow(), command.getColumn(),
+ this.model.actOnBox(command.getRow(), command.getColumn(),
command.getType());
return;
@@ -118,10 +118,10 @@
}
}
- /*** Methods ***/
+ /*** Methods implanted from the interface IGridMediator ***/
/** Tells the application mediator the grid has been filled. */
- void congratulations() {
+ public void congratulations() {
this.fireEventPerformed(GridController.GRID_FILLED_CMD);
}
@@ -131,18 +131,18 @@
* @param row row number of the box
* @param column column number of the box
*/
- void repaint(int row, int column) {
+ public void repaint(int row, int column) {
this.fireEventPerformed(GridController.PAINT_CMD,
new PaintCommand(row, column));
}
/** Asks to repaint the column hints. */
- void repaintColHints() {
+ public void repaintColHints() {
this.fireEventPerformed(GridController.REPAINT_TOP_HINTS_CMD);
}
/** Asks to repaint the row hints. */
- void repaintRowHints() {
+ public void repaintRowHints() {
this.fireEventPerformed(GridController.REPAINT_LEFT_HINTS_CMD);
}
Modified: trunk/src/picross/grid/GridModel.java
===================================================================
--- trunk/src/picross/grid/GridModel.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/grid/GridModel.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -57,7 +57,7 @@
/*** Fields ***/
/** This model's mediator. */
- private GridMediator mediator;
+ private IGridMediator mediator;
/** The original grid. */
private boolean[][] data;
@@ -87,8 +87,38 @@
*
* @param mediator this model's mediator
* @param data grid content
+ * @throws IllegalArgumentException if <code>mediator</code>
+ * or <code>data</code> is <code>null</code>
*/
- GridModel(GridMediator mediator, boolean[][] data) {
+ GridModel(IGridMediator mediator, boolean[][] data)
+ throws IllegalArgumentException {
+
+ if (mediator == null) {
+ throw new IllegalArgumentException("mediator cannot be null");
+ }
+
+ if (data == null) {
+ throw new IllegalArgumentException("data cannot be null");
+ }
+
+ if (data.length == 0) {
+ throw new IllegalArgumentException("data cannot be empty");
+ }
+
+ int expectedSize = data[0].length;
+
+ if (expectedSize == 0) {
+ throw new IllegalArgumentException("data cannot be empty");
+ }
+
+ for (int i = 0; i < data.length; i++) {
+ if (data[i].length == 0 || data[i].length != expectedSize) {
+ throw new IllegalArgumentException("data[i].length "
+ + "is supposed to be "
+ + expectedSize);
+ }
+ }
+
this.mediator = mediator;
this.data = data;
@@ -291,13 +321,30 @@
/*** Methods ***/
/**
- * Method called during an action.
- * TODO rename this method
+ * Method called during an action. Does the action on the specified box,
+ * then checks for completed hints.
*
* @param row row of the box
* @param column column of the box
+ * @throws IllegalArgumentException if <code>row</code> or
+ * <code>column</code> is less than 0
*/
- void checkBox(int row, int column, int type) {
+ //void checkBox(int row, int column, int type) {
+ void actOnBox(int row, int column, GridAction type)
+ throws IllegalArgumentException {
+
+ if (row < 0) {
+ throw new IllegalArgumentException("row cannot be less than 0");
+ }
+
+ if (column < 0) {
+ throw new IllegalArgumentException("column cannot be less than 0");
+ }
+
+ if (type == GridAction.UNKNOWN) {
+ return;
+ }
+
//GridModel.log.debug("checkBox(" + row + ", " + column + ")");
//GridModel.log.debug("lastModified == null : "
// + (lastModified == null));
@@ -326,9 +373,9 @@
if (this.boxes[column][row].isEmpty()
&& (this.lastModified == null || !this.lastModified.isEmpty())) {
- if (type == GridController.CHECK_ACTION) {
+ if (type == GridAction.CHECK) {
this.boxes[column][row].check();
- } else { //if (type == GridController.CROSS_ACTION) {
+ } else { //if (type == GridAction.CROSS) {
this.boxes[column][row].cross();
}
@@ -340,17 +387,17 @@
if (this.boxes[column][row].isChecked()) {
//GridModel.log.debug("checked");
- if (type == GridController.CHECK_ACTION) {
+ if (type == GridAction.CHECK) {
this.boxes[column][row].empty();
- } else { //if (type == GridController.CROSS_ACTION) {
+ } else { //if (type == GridAction.CROSS) {
this.boxes[column][row].cross();
}
} else { //if (this.boxes[column][row].isCrossed()) {
//GridModel.log.debug("crossed");
- if (type == GridController.CROSS_ACTION) {
+ if (type == GridAction.CROSS) {
this.boxes[column][row].empty();
- } else {
+ } else { //if (type == GridAction.CHECK) {
//GridModel.log.debug("check()");
this.boxes[column][row].check();
Added: trunk/src/picross/grid/GridModelTest.java
===================================================================
--- trunk/src/picross/grid/GridModelTest.java (rev 0)
+++ trunk/src/picross/grid/GridModelTest.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -0,0 +1,110 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.grid;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import picross.grid.tests.IGridMediatorStub;
+
+/**
+ * @author Y. Norsa
+ */
+public class GridModelTest {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private GridModel model = null;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ GridModelTest() {
+ }*/
+
+ /*** M\xE9thode ***/
+
+ @Before
+ public void setUp() {
+ this.model = new GridModel(new IGridMediatorStub(), new boolean[3][5]);
+ }
+
+ @Test
+ public void testGridModel() {
+ try {
+ new GridModel(null, null);
+ Assert.fail("mediator = null");
+ } catch (IllegalArgumentException argEx) { }
+
+ IGridMediator stub = new IGridMediatorStub();
+
+ try {
+ new GridModel(stub, null);
+ Assert.fail("data = null");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new GridModel(stub, new boolean[0][0]);
+ Assert.fail("empty data");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new GridModel(stub, new boolean[1][0]);
+ Assert.fail("empty data");
+ } catch (IllegalArgumentException argEx) { }
+ }
+
+ @Test
+ public void testActOnBox() {
+ try {
+ this.model.actOnBox(-1, -1, GridAction.CHECK);
+ Assert.fail("row = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ this.model.actOnBox(0, -1, GridAction.CHECK);
+ Assert.fail("column = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ this.model.actOnBox(0, 0, GridAction.CHECK);
+ }
+}
+
Property changes on: trunk/src/picross/grid/GridModelTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/grid/IGridMediator.java
===================================================================
--- trunk/src/picross/grid/IGridMediator.java (rev 0)
+++ trunk/src/picross/grid/IGridMediator.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -0,0 +1,57 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.grid;
+
+/**
+ * @author Y. Norsa
+ */
+public interface IGridMediator {
+ /**
+ * Asks to repaint a box.
+ *
+ * @param row row number of the box
+ * @param column column number of the box
+ */
+ void repaint(int row, int column);
+
+ /** Asks to repaint the column hints. */
+ void repaintColHints();
+
+ /** Asks to repaint the row hints. */
+ void repaintRowHints();
+
+ /** Tells the application mediator the grid has been filled. */
+ void congratulations();
+}
+
Property changes on: trunk/src/picross/grid/IGridMediator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/grid/PaintCommand.java
===================================================================
--- trunk/src/picross/grid/PaintCommand.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/grid/PaintCommand.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -56,8 +56,18 @@
*
* @param row row number of the box
* @param column column number of the box
+ * @throws IllegalArgumentException if <code>row</code>
+ * or <code>column</code> is less than 0
*/
- PaintCommand(int row, int column) {
+ PaintCommand(int row, int column) throws IllegalArgumentException {
+ if (row < 0) {
+ throw new IllegalArgumentException("row can't be less than 0");
+ }
+
+ if (column < 0) {
+ throw new IllegalArgumentException("column can't be less than 0");
+ }
+
this.row = row;
this.column = column;
}
Added: trunk/src/picross/grid/PaintCommandTest.java
===================================================================
--- trunk/src/picross/grid/PaintCommandTest.java (rev 0)
+++ trunk/src/picross/grid/PaintCommandTest.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -0,0 +1,58 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.grid;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author Y. Norsa
+ */
+public class PaintCommandTest {
+ @Test
+ public void testPaintCommand() {
+ try {
+ new PaintCommand(-1, -1);
+ Assert.fail("row = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new PaintCommand(0, -1);
+ Assert.fail("column = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ new PaintCommand(0, 0);
+ }
+}
+
Property changes on: trunk/src/picross/grid/PaintCommandTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/grid/tests/IGridMediatorStub.java
===================================================================
--- trunk/src/picross/grid/tests/IGridMediatorStub.java (rev 0)
+++ trunk/src/picross/grid/tests/IGridMediatorStub.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -0,0 +1,68 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.grid.tests;
+
+import picross.grid.IGridMediator;
+
+/**
+ * @author Y. Norsa
+ */
+public class IGridMediatorStub implements IGridMediator {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ IGridMediatorStub() {
+ }
+ */
+
+ /*** M\xE9thode ***/
+
+ public void repaint(int row, int column) { }
+
+ public void repaintColHints() { }
+
+ public void repaintRowHints() { }
+
+ public void congratulations() { }
+}
+
Property changes on: trunk/src/picross/grid/tests/IGridMediatorStub.java
___________________________________________________________________
Name: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|