[Picross-commit] SF.net SVN: picross:[94] trunk
Status: Pre-Alpha
Brought to you by:
yvan_norsa
From: <yva...@us...> - 2011-06-29 13:03:08
|
Revision: 94 http://picross.svn.sourceforge.net/picross/?rev=94&view=rev Author: yvan_norsa Date: 2011-06-29 13:02:58 +0000 (Wed, 29 Jun 2011) Log Message: ----------- big reorganisation Modified Paths: -------------- trunk/services/picross.game.GameMode trunk/src/picross/Picross.java trunk/src/picross/app/MainMenuAppUI.java trunk/src/picross/app/PicrossApp.java trunk/src/picross/app/PicrossAppUI.java trunk/src/picross/applet/MainMenuAppletUI.java trunk/src/picross/applet/PicrossApplet.java trunk/src/picross/game/GameMode.java trunk/src/picross/game/random/RandomGameMode.java trunk/src/picross/game/random/RandomPicrossModel.java trunk/src/picross/game/simple/SimpleGameMode.java trunk/src/picross/game/simple/XBMModel.java trunk/src/picross/grid/CompletedHints.java trunk/src/picross/grid/GridAction.java trunk/src/picross/grid/GridModel.java trunk/test/picross/PicrossTest.java trunk/test/picross/game/random/RandomPicrossModelTest.java trunk/test/picross/game/simple/XBMModelTest.java trunk/test/picross/grid/BoxTest.java trunk/test/picross/grid/GridModelTest.java Added Paths: ----------- trunk/src/picross/game/AbstractPicrossModel.java trunk/src/picross/game/random/ui/ trunk/src/picross/game/random/ui/RandomGameController.java trunk/src/picross/game/random/ui/RandomGameMediator.java trunk/src/picross/game/random/ui/RandomGameModeUI.java trunk/src/picross/game/random/ui/RandomGameUI.java trunk/src/picross/game/simple/ui/ trunk/src/picross/game/simple/ui/LevelMenuController.java trunk/src/picross/game/simple/ui/LevelMenuMediator.java trunk/src/picross/game/simple/ui/LevelMenuModel.java trunk/src/picross/game/simple/ui/LevelMenuUI.java trunk/src/picross/game/simple/ui/LevelsListCommand.java trunk/src/picross/game/simple/ui/SelectSizeCommand.java trunk/src/picross/game/simple/ui/SimpleGameMediator.java trunk/src/picross/game/simple/ui/SimpleGameModeUI.java trunk/src/picross/game/simple/ui/SizesListCommand.java trunk/src/picross/game/ui/ trunk/src/picross/game/ui/GameCommand.java trunk/src/picross/game/ui/GameController.java trunk/src/picross/game/ui/GameMediator.java trunk/src/picross/game/ui/GameUI.java trunk/src/picross/game/ui/GameView.java trunk/src/picross/game/ui/UIGameMode.java trunk/src/picross/grid/PicrossGrid.java trunk/src/picross/grid/ui/ trunk/src/picross/grid/ui/FillCommand.java trunk/src/picross/grid/ui/GridController.java trunk/src/picross/grid/ui/GridMediator.java trunk/src/picross/grid/ui/GridUI.java trunk/src/picross/grid/ui/GridView.java trunk/src/picross/grid/ui/HintBoxInfos.java trunk/src/picross/grid/ui/IGridMediator.java trunk/src/picross/grid/ui/PaintCommand.java trunk/src/picross/grid/ui/RepaintLeftHintsCommand.java trunk/src/picross/grid/ui/RepaintTopHintsCommand.java trunk/src/picross/grid/ui/UIBox.java trunk/src/picross/ui/ trunk/src/picross/ui/GameMenuMediator.java trunk/src/picross/ui/GameMenuModel.java trunk/src/picross/ui/GameMenuUI.java trunk/src/picross/ui/MainMenuMediator.java trunk/src/picross/ui/MainMenuUI.java trunk/src/picross/ui/MenuCommand.java trunk/src/picross/ui/MenuController.java trunk/src/picross/ui/MenuMediator.java trunk/src/picross/ui/MenuUI.java trunk/src/picross/ui/MissingImageException.java trunk/src/picross/ui/PicrossButton.java trunk/src/picross/ui/PicrossController.java trunk/src/picross/ui/PicrossMediator.java trunk/src/picross/ui/PicrossUI.java trunk/src/picross/ui/PicrossUIHelper.java trunk/src/picross/ui/PicrossView.java trunk/src/picross/ui/WaitMenuMediator.java trunk/src/picross/ui/WaitMenuUI.java trunk/test/picross/grid/ui/ trunk/test/picross/grid/ui/FillCommandTest.java trunk/test/picross/grid/ui/IGridMediatorStub.java trunk/test/picross/grid/ui/PaintCommandTest.java trunk/test/picross/grid/ui/UIBoxTest.java trunk/test/picross/ui/ trunk/test/picross/ui/PicrossUIHelperTest.java Removed Paths: ------------- trunk/src/picross/AbstractPicrossModel.java trunk/src/picross/MissingImageException.java trunk/src/picross/PicrossController.java trunk/src/picross/PicrossGrid.java trunk/src/picross/PicrossMediator.java trunk/src/picross/PicrossUI.java trunk/src/picross/PicrossView.java trunk/src/picross/game/GameCommand.java trunk/src/picross/game/GameController.java trunk/src/picross/game/GameMediator.java trunk/src/picross/game/GameUI.java trunk/src/picross/game/GameView.java trunk/src/picross/game/random/RandomGameController.java trunk/src/picross/game/random/RandomGameMediator.java trunk/src/picross/game/random/RandomGameUI.java 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 trunk/src/picross/game/simple/SimpleGameMediator.java trunk/src/picross/game/simple/SizesListCommand.java trunk/src/picross/grid/Box.java trunk/src/picross/grid/FillCommand.java trunk/src/picross/grid/GridController.java trunk/src/picross/grid/GridMediator.java trunk/src/picross/grid/GridUI.java trunk/src/picross/grid/GridView.java trunk/src/picross/grid/HintBoxInfos.java trunk/src/picross/grid/IGridMediator.java trunk/src/picross/grid/PaintCommand.java trunk/src/picross/grid/RepaintLeftHintsCommand.java trunk/src/picross/grid/RepaintTopHintsCommand.java trunk/src/picross/menus/ trunk/test/picross/grid/FillCommandTest.java trunk/test/picross/grid/IGridMediatorStub.java trunk/test/picross/grid/PaintCommandTest.java Modified: trunk/services/picross.game.GameMode =================================================================== --- trunk/services/picross.game.GameMode 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/services/picross.game.GameMode 2011-06-29 13:02:58 UTC (rev 94) @@ -1,2 +1,2 @@ -picross.game.random.RandomGameMode -picross.game.simple.SimpleGameMode +picross.game.random.ui.RandomGameModeUI +picross.game.simple.ui.SimpleGameModeUI Deleted: trunk/src/picross/AbstractPicrossModel.java =================================================================== --- trunk/src/picross/AbstractPicrossModel.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/AbstractPicrossModel.java 2011-06-29 13:02:58 UTC (rev 94) @@ -1,268 +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; - -/** - * Model handling the puzzle data. - * - * @author Y. Norsa - */ -public class AbstractPicrossModel implements PicrossGrid { - /*** Fields ***/ - - /** Grid width. */ - protected int width; - - /** Grid height. */ - protected int height; - - /** Grid content. */ - protected boolean[][] data; - - /*** Constructor ***/ - - /** Constructor. */ - /* - PicrossModel() { - this.width = 19; - this.height = 14; - - this.data = new boolean[this.width][this.height]; - - this.data[0][7] = true; - this.data[0][8] = true; - this.data[0][13] = true; - - this.data[1][6] = true; - this.data[1][7] = true; - this.data[1][8] = true; - this.data[1][9] = true; - this.data[1][12] = true; - this.data[1][13] = true; - - this.data[2][6] = true; - this.data[2][7] = true; - this.data[2][8] = true; - this.data[2][9] = true; - this.data[2][12] = true; - this.data[2][13] = true; - - this.data[3][5] = true; - this.data[3][6] = true; - this.data[3][8] = true; - this.data[3][9] = true; - this.data[3][10] = true; - this.data[3][11] = true; - this.data[3][12] = true; - this.data[3][13] = true; - - this.data[4][5] = true; - this.data[4][6] = true; - this.data[4][7] = true; - this.data[4][8] = true; - this.data[4][9] = true; - this.data[4][10] = true; - this.data[4][11] = true; - this.data[4][12] = true; - this.data[4][13] = true; - - this.data[5][0] = true; - this.data[5][1] = true; - this.data[5][2] = true; - this.data[5][3] = true; - this.data[5][4] = true; - this.data[5][5] = true; - this.data[5][6] = true; - this.data[5][7] = true; - this.data[5][8] = true; - this.data[5][9] = true; - this.data[5][10] = true; - this.data[5][11] = true; - this.data[5][12] = true; - this.data[5][13] = true; - - this.data[6][0] = true; - this.data[6][1] = true; - this.data[6][2] = true; - this.data[6][3] = true; - this.data[6][4] = true; - this.data[6][5] = true; - this.data[6][6] = true; - this.data[6][7] = true; - this.data[6][8] = true; - this.data[6][9] = true; - this.data[6][10] = true; - this.data[6][11] = true; - this.data[6][12] = true; - this.data[6][13] = true; - - this.data[7][1] = true; - this.data[7][2] = true; - this.data[7][3] = true; - this.data[7][4] = true; - this.data[7][5] = true; - this.data[7][6] = true; - this.data[7][7] = true; - this.data[7][8] = true; - this.data[7][9] = true; - this.data[7][10] = true; - this.data[7][11] = true; - this.data[7][12] = true; - this.data[7][13] = true; - - this.data[8][8] = true; - this.data[8][9] = true; - this.data[8][10] = true; - this.data[8][11] = true; - this.data[8][12] = true; - this.data[8][13] = true; - - this.data[9][7] = true; - this.data[9][8] = true; - this.data[9][9] = true; - this.data[9][10] = true; - this.data[9][11] = true; - this.data[9][12] = true; - this.data[9][13] = true; - - this.data[10][7] = true; - this.data[10][8] = true; - this.data[10][9] = true; - this.data[10][10] = true; - this.data[10][11] = true; - this.data[10][12] = true; - this.data[10][13] = true; - - this.data[11][6] = true; - this.data[11][7] = true; - this.data[11][8] = true; - this.data[11][9] = true; - this.data[11][10] = true; - this.data[11][11] = true; - this.data[11][12] = true; - this.data[11][13] = true; - - this.data[12][6] = true; - this.data[12][7] = true; - this.data[12][8] = true; - this.data[12][9] = true; - this.data[12][10] = true; - this.data[12][11] = true; - this.data[12][12] = true; - this.data[12][13] = true; - - this.data[13][6] = true; - this.data[13][7] = true; - this.data[13][8] = true; - this.data[13][9] = true; - this.data[13][10] = true; - this.data[13][11] = true; - this.data[13][12] = true; - this.data[13][13] = true; - - this.data[14][6] = true; - this.data[14][7] = true; - this.data[14][8] = true; - this.data[14][9] = true; - this.data[14][10] = true; - this.data[14][11] = true; - this.data[14][12] = true; - this.data[14][13] = true; - - this.data[15][7] = true; - this.data[15][8] = true; - this.data[15][9] = true; - this.data[15][10] = true; - this.data[15][11] = true; - this.data[15][12] = true; - this.data[15][13] = true; - - this.data[16][9] = true; - this.data[16][10] = true; - this.data[16][11] = true; - this.data[16][12] = true; - this.data[16][13] = true; - - this.data[17][8] = true; - this.data[17][9] = true; - this.data[17][10] = true; - this.data[17][11] = true; - this.data[17][12] = true; - this.data[17][13] = true; - - this.data[18][9] = true; - this.data[18][10] = true; - this.data[18][11] = true; - this.data[18][12] = true; - } - */ - /*** Accessors ***/ - - /** - * Returns the width. - * - * @return grid width - */ - public final int getWidth() { - return this.width; - } - - /** - * Returns the height. - * - * @return grid height - */ - public final int getHeight() { - return this.height; - } - - /** - * Returns the content. - * - * @return grid content - */ - public final boolean[][] getData() { - boolean[][] dataCopy = new boolean[this.data.length][]; - - for (int i = 0; i < this.data.length; i++) { - dataCopy[i] = new boolean[this.data[i].length]; - System.arraycopy(this.data[i], 0, - dataCopy[i], 0, - this.data[i].length); - } - - return dataCopy; - } -} - Deleted: trunk/src/picross/MissingImageException.java =================================================================== --- trunk/src/picross/MissingImageException.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/MissingImageException.java 2011-06-29 13:02:58 UTC (rev 94) @@ -1,58 +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; - -/** - * Exception thrown when an image file is not found. - * - * @author Y. Norsa - */ -public final class MissingImageException extends RuntimeException { - /*** Constant ***/ - - /** Serialisation ID. */ - private static final long serialVersionUID = 7805399363197308654L; - - /*** Constructor ***/ - - /** - * Constructor. - * - * @param cause parent exception - */ - MissingImageException(Throwable cause) { - super(cause); - } -} - Modified: trunk/src/picross/Picross.java =================================================================== --- trunk/src/picross/Picross.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/Picross.java 2011-06-29 13:02:58 UTC (rev 94) @@ -41,8 +41,6 @@ import java.util.Locale; -import javax.swing.ImageIcon; - //import org.apache.log4j.Logger; /** @@ -51,18 +49,11 @@ * @author Y. Norsa */ public final class Picross { - /*** Constants ***/ + /*** Constant ***/ - /** Images directory. */ - private static final String IMAGES_DIR = "/picross/images/"; - /** Data directory. */ private static final String DATA_DIR = "/picross/data/"; - /** Images directory corresponding to the default locale. */ - private static final String LOCAL_IMAGES_PATH = Picross.IMAGES_DIR - + Locale.getDefault().getLanguage() + "/"; - /*** Static field ***/ /** The class' logger. */ @@ -82,7 +73,7 @@ * @return URL of the file * @throws FileNotFoundException if the file can't be found */ - private static URL getFile(String path) throws FileNotFoundException { + public static URL getFile(String path) throws FileNotFoundException { URL fileUrl = Picross.class.getResource(path); if (fileUrl == null) { @@ -93,55 +84,6 @@ } /** - * Loads an image. - * - * @param path path of the image - * @return the image - * @throws MissingImageException if the image file can't be found - */ - private static ImageIcon loadImage(String path) { - try { - return new ImageIcon(Picross.getFile(path)); - } catch (FileNotFoundException fileEx) { - throw new MissingImageException(fileEx); - } - } - - /** - * Returns an image. - * - * @param name image filename - * @return the image - * @throws IllegalArgumentException if <code>name</code> - * is <code>null</code> or empty - * @throws MissingImageException if the image file can't be found - */ - public static ImageIcon getImage(String name) { - if (name == null || name.equals("")) { - throw new IllegalArgumentException("name can't be null or empty"); - } - - return Picross.loadImage(Picross.IMAGES_DIR + name); - } - - /** - * Returns the localized version of an image. - * - * @param name image filename - * @return the image - * @throws IllegalArgumentException if <code>name</code> - * is <code>null</code> or empty - * @throws MissingImageException if the image file can't be found - */ - public static ImageIcon getLocalizedImage(String name) { - if (name == null || name.equals("")) { - throw new IllegalArgumentException("name can't be null or empty"); - } - - return Picross.loadImage(Picross.LOCAL_IMAGES_PATH + name); - } - - /** * Loads a data file. * * @param name filename Deleted: trunk/src/picross/PicrossController.java =================================================================== --- trunk/src/picross/PicrossController.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/PicrossController.java 2011-06-29 13:02:58 UTC (rev 94) @@ -1,107 +0,0 @@ -/* - * $Id$ - * - * 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, - * 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; - -import fr.cle.mmvcs.Controller; -import fr.cle.mmvcs.SimpleEvent; - -//import org.apache.log4j.Logger; - -/** - * Application controller. - * - * @author Y. Norsa - */ -public final class PicrossController extends Controller { - /*** Constants ***/ - - /** Play command. */ - public static final String PLAY_CMD = "PLAY_CMD"; - - /** Command used to display a menu. */ - public static final String MENU_CMD = "MENU_CMD"; - - /** Exit command. */ - public static final String EXIT_CMD = "EXIT_CMD"; - - /** Command used to quit a game. */ - public static final String QUIT_CMD = "QUIT_CMD"; - - /*** Static field ***/ - - /** The class's logger. */ - //private static Logger log = Logger.getLogger(PicrossController.class); - - /*** Field ***/ - - /** The view to which this controller is attached. */ - private PicrossUI view = null; - - /*** Method overloaded from the class Controller ***/ - - /** {@inheritDoc} */ - @Override - public void eventPerformed(SimpleEvent e) { - //PicrossController.log.debug("eventPerformed(" + e + ")"); - - String cmd = e.getCommandName(); - - if (cmd.equals(PicrossController.MESSAGE_CMD)) { - this.view.displayMessage(e.getComment()); - return; - } - - if (cmd.equals(PicrossController.ERROR_CMD)) { - this.view.displayError(e.getComment()); - return; - } - - if (cmd.equals(PicrossController.DISPOSE_CMD)) { - this.view.exit(); - return; - } - } - - /*** Accessor ***/ - - /** - * Allows to define the view. - * - * @param view the view to which this controller is to be attached - */ - void setView(PicrossUI view) { - this.view = view; - } -} - Deleted: trunk/src/picross/PicrossGrid.java =================================================================== --- trunk/src/picross/PicrossGrid.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/PicrossGrid.java 2011-06-29 13:02:58 UTC (rev 94) @@ -1,62 +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; - -/** - * Interface for classes able to provide a grid. - * - * @author Y. Norsa - */ -public interface PicrossGrid { - /** - * Returns the width. - * - * @return grid width (always > 0) - */ - int getWidth(); - - /** - * Returns the height. - * - * @return grid height (always > 0) - */ - int getHeight(); - - /** - * Returns the content. - * - * @return grid content (of size width * height) - */ - boolean[][] getData(); -} Deleted: trunk/src/picross/PicrossMediator.java =================================================================== --- trunk/src/picross/PicrossMediator.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/PicrossMediator.java 2011-06-29 13:02:58 UTC (rev 94) @@ -1,238 +0,0 @@ -/* - * $Id$ - * - * 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, - * 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; - -import bundleHelper.BundleHelper; - -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 picross.game.GameCommand; -import picross.game.GameMediator; - -import picross.grid.GridController; - -import picross.menus.GameMenuMediator; -import picross.menus.MainMenuMediator; -import picross.menus.MenuCommand; -import picross.menus.MenuMediator; -import picross.menus.WaitMenuMediator; - -/** - * Application mediator. - * - * @author Y. Norsa - */ -public final class PicrossMediator extends Mediateur { - /*** Static field ***/ - - /** Class' logger. */ - //private static Logger log = Logger.getLogger(PicrossMediator.class); - - /*** Fields ***/ - - /** Main view. */ - private PicrossUI view; - - /** - * Boolean used to display a loading screen when we init the grid stuff. - */ - private boolean firstTime = true; - - /*** Constructor ***/ - - /** - * Constructor. - * - * @param view the main UI - */ - public PicrossMediator(PicrossUI view) { - BundleHelper.loadBundle("picross.properties.messages_picross"); - - this.view = view; - - PicrossController controller = new PicrossController(); - controller.setView(this.view); - this.addSimpleListener(controller); - - this.displayMenu(MainMenuMediator.class); - - this.view.showUI(); - } - - /*** Method overloaded from the Mediateur class ***/ - - /** {@inheritDoc} */ - @Override - public void eventPerformed(SimpleEvent e) { - //PicrossMediator.log.debug("eventPerformed(" + e + ")"); - - String cmd = e.getCommandName(); - - if (cmd.equals(PicrossController.PLAY_CMD)) { - this.displayGameMenu(); - return; - } - - if (cmd.equals(PicrossController.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; - } - - if (cmd.equals(GridController.GRID_FILLED_CMD)) { - this.fireEventPerformed(PicrossController.MESSAGE_CMD, - BundleHelper.getString(this, "victory")); - return; - } - - if (cmd.equals(PicrossController.QUIT_CMD)) { - this.displayGameMenu(); - return; - } - } - - /*** Methods ***/ - - /** Exits the application. */ - private void exit() { - this.fireEventPerformed(PicrossController.DISPOSE_CMD); - } - - /** Displays the game menu. */ - private void displayGameMenu() { - this.displayMenu(GameMenuMediator.class); - } - - /** Displays the loading screen only the first time. */ - private void displayWaitScreen() { - if (this.firstTime) { - this.displayMenu(WaitMenuMediator.class); - this.firstTime = false; - } - } - - /** - * Helper method to display a menu. - * - * @param menuClass the menu's mediator class - */ - private void displayMenu(Class<? extends MenuMediator> menuClass) { - MenuMediator menu = null; - - try { - try { - menu = menuClass.getConstructor().newInstance(); - } catch (NoSuchMethodException methodEx) { - throw new PicrossException(methodEx); - } catch (InstantiationException instantiationEx) { - throw new PicrossException(instantiationEx); - } catch (IllegalAccessException accessEx) { - throw new PicrossException(accessEx); - } catch (InvocationTargetException targetEx) { - throw new PicrossException(targetEx); - } - - menu.init(this.view); - } catch (PicrossException picrossEx) { - this.fireEventPerformed(PicrossController.ERROR_CMD, - picrossEx.getMessage()); - - this.exit(); - return; - } - - menu.addSimpleListener(this); - this.view.setContent(menu.getView()); - } - - /** - * Method launching a game. - * - * @param game game the launch - */ - private void startGame(final GameMediator game) { - Thread worker = new Thread() { - public void run() { - try { - game.init(); - PicrossMediator.this.gameLoaded(game); - } catch (PicrossException picrossEx) { - PicrossMediator.this.view - .displayError(picrossEx.getMessage()); - return; - } - } - }; - - worker.start(); - } - - /** - * 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()); - } - }); - } -} - Deleted: trunk/src/picross/PicrossUI.java =================================================================== --- trunk/src/picross/PicrossUI.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/PicrossUI.java 2011-06-29 13:02:58 UTC (rev 94) @@ -1,76 +0,0 @@ -/* - * $Id$ - * - * 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, - * 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; - -/** - * Main window. - * - * @author Y. Norsa - */ -public interface PicrossUI { - /** - * Sets the content panel. - * - * @param content new content panel - */ - void setContent(PicrossView content); - - /** - * Displays a message box. - * - * @param msg message to be displayed - */ - void displayMessage(String msg); - - /** - * Displays an error message. - * - * @param msg error message - */ - void displayError(String msg); - - /** - * Returns the name of the main menu class. - * - * @return name of the main menu class - */ - String getMainMenuClass(); - - /** Method called when the application is displayed. */ - void showUI(); - - /** Method called when the application exits. */ - void exit(); -} - Deleted: trunk/src/picross/PicrossView.java =================================================================== --- trunk/src/picross/PicrossView.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/PicrossView.java 2011-06-29 13:02:58 UTC (rev 94) @@ -1,58 +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; - -/** - * @author Y. Norsa - */ -public interface PicrossView { - /*** Constante ***/ - - /*** Champ statique ***/ - - /*** Champ ***/ - - /*** Constructeur ***/ - - /** - * Constructeur. - */ - /* - PicrossView() { - } - */ - - /*** M\xE9thode ***/ -} - Modified: trunk/src/picross/app/MainMenuAppUI.java =================================================================== --- trunk/src/picross/app/MainMenuAppUI.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/app/MainMenuAppUI.java 2011-06-29 13:02:58 UTC (rev 94) @@ -35,10 +35,9 @@ import java.awt.event.ActionListener; -import picross.PicrossController; +import picross.ui.MainMenuUI; +import picross.ui.PicrossController; -import picross.menus.MainMenuUI; - /** * Main menu for the application version. * Modified: trunk/src/picross/app/PicrossApp.java =================================================================== --- trunk/src/picross/app/PicrossApp.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/app/PicrossApp.java 2011-06-29 13:02:58 UTC (rev 94) @@ -37,7 +37,7 @@ import org.apache.log4j.PropertyConfigurator; -import picross.PicrossMediator; +import picross.ui.PicrossMediator; /** * Main class of the application version. Modified: trunk/src/picross/app/PicrossAppUI.java =================================================================== --- trunk/src/picross/app/PicrossAppUI.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/app/PicrossAppUI.java 2011-06-29 13:02:58 UTC (rev 94) @@ -38,8 +38,8 @@ import javax.swing.JFrame; import javax.swing.JOptionPane; -import picross.PicrossUI; -import picross.PicrossView; +import picross.ui.PicrossUI; +import picross.ui.PicrossView; /** * Main window of the application version. Modified: trunk/src/picross/applet/MainMenuAppletUI.java =================================================================== --- trunk/src/picross/applet/MainMenuAppletUI.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/applet/MainMenuAppletUI.java 2011-06-29 13:02:58 UTC (rev 94) @@ -37,7 +37,7 @@ import java.awt.event.ActionListener; -import picross.menus.MainMenuUI; +import picross.ui.MainMenuUI; /** * Main menu for the applet version. Modified: trunk/src/picross/applet/PicrossApplet.java =================================================================== --- trunk/src/picross/applet/PicrossApplet.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/applet/PicrossApplet.java 2011-06-29 13:02:58 UTC (rev 94) @@ -39,9 +39,9 @@ import javax.swing.JOptionPane; import javax.swing.SwingUtilities; -import picross.PicrossMediator; -import picross.PicrossUI; -import picross.PicrossView; +import picross.ui.PicrossMediator; +import picross.ui.PicrossUI; +import picross.ui.PicrossView; /** * Main class of the applet version. Copied: trunk/src/picross/game/AbstractPicrossModel.java (from rev 88, trunk/src/picross/AbstractPicrossModel.java) =================================================================== --- trunk/src/picross/game/AbstractPicrossModel.java (rev 0) +++ trunk/src/picross/game/AbstractPicrossModel.java 2011-06-29 13:02:58 UTC (rev 94) @@ -0,0 +1,270 @@ +/* + * $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.game; + +import picross.grid.PicrossGrid; + +/** + * Model handling the puzzle data. + * + * @author Y. Norsa + */ +public class AbstractPicrossModel implements PicrossGrid { + /*** Fields ***/ + + /** Grid width. */ + protected int width; + + /** Grid height. */ + protected int height; + + /** Grid content. */ + protected boolean[][] data; + + /*** Constructor ***/ + + /** Constructor. */ + /* + PicrossModel() { + this.width = 19; + this.height = 14; + + this.data = new boolean[this.width][this.height]; + + this.data[0][7] = true; + this.data[0][8] = true; + this.data[0][13] = true; + + this.data[1][6] = true; + this.data[1][7] = true; + this.data[1][8] = true; + this.data[1][9] = true; + this.data[1][12] = true; + this.data[1][13] = true; + + this.data[2][6] = true; + this.data[2][7] = true; + this.data[2][8] = true; + this.data[2][9] = true; + this.data[2][12] = true; + this.data[2][13] = true; + + this.data[3][5] = true; + this.data[3][6] = true; + this.data[3][8] = true; + this.data[3][9] = true; + this.data[3][10] = true; + this.data[3][11] = true; + this.data[3][12] = true; + this.data[3][13] = true; + + this.data[4][5] = true; + this.data[4][6] = true; + this.data[4][7] = true; + this.data[4][8] = true; + this.data[4][9] = true; + this.data[4][10] = true; + this.data[4][11] = true; + this.data[4][12] = true; + this.data[4][13] = true; + + this.data[5][0] = true; + this.data[5][1] = true; + this.data[5][2] = true; + this.data[5][3] = true; + this.data[5][4] = true; + this.data[5][5] = true; + this.data[5][6] = true; + this.data[5][7] = true; + this.data[5][8] = true; + this.data[5][9] = true; + this.data[5][10] = true; + this.data[5][11] = true; + this.data[5][12] = true; + this.data[5][13] = true; + + this.data[6][0] = true; + this.data[6][1] = true; + this.data[6][2] = true; + this.data[6][3] = true; + this.data[6][4] = true; + this.data[6][5] = true; + this.data[6][6] = true; + this.data[6][7] = true; + this.data[6][8] = true; + this.data[6][9] = true; + this.data[6][10] = true; + this.data[6][11] = true; + this.data[6][12] = true; + this.data[6][13] = true; + + this.data[7][1] = true; + this.data[7][2] = true; + this.data[7][3] = true; + this.data[7][4] = true; + this.data[7][5] = true; + this.data[7][6] = true; + this.data[7][7] = true; + this.data[7][8] = true; + this.data[7][9] = true; + this.data[7][10] = true; + this.data[7][11] = true; + this.data[7][12] = true; + this.data[7][13] = true; + + this.data[8][8] = true; + this.data[8][9] = true; + this.data[8][10] = true; + this.data[8][11] = true; + this.data[8][12] = true; + this.data[8][13] = true; + + this.data[9][7] = true; + this.data[9][8] = true; + this.data[9][9] = true; + this.data[9][10] = true; + this.data[9][11] = true; + this.data[9][12] = true; + this.data[9][13] = true; + + this.data[10][7] = true; + this.data[10][8] = true; + this.data[10][9] = true; + this.data[10][10] = true; + this.data[10][11] = true; + this.data[10][12] = true; + this.data[10][13] = true; + + this.data[11][6] = true; + this.data[11][7] = true; + this.data[11][8] = true; + this.data[11][9] = true; + this.data[11][10] = true; + this.data[11][11] = true; + this.data[11][12] = true; + this.data[11][13] = true; + + this.data[12][6] = true; + this.data[12][7] = true; + this.data[12][8] = true; + this.data[12][9] = true; + this.data[12][10] = true; + this.data[12][11] = true; + this.data[12][12] = true; + this.data[12][13] = true; + + this.data[13][6] = true; + this.data[13][7] = true; + this.data[13][8] = true; + this.data[13][9] = true; + this.data[13][10] = true; + this.data[13][11] = true; + this.data[13][12] = true; + this.data[13][13] = true; + + this.data[14][6] = true; + this.data[14][7] = true; + this.data[14][8] = true; + this.data[14][9] = true; + this.data[14][10] = true; + this.data[14][11] = true; + this.data[14][12] = true; + this.data[14][13] = true; + + this.data[15][7] = true; + this.data[15][8] = true; + this.data[15][9] = true; + this.data[15][10] = true; + this.data[15][11] = true; + this.data[15][12] = true; + this.data[15][13] = true; + + this.data[16][9] = true; + this.data[16][10] = true; + this.data[16][11] = true; + this.data[16][12] = true; + this.data[16][13] = true; + + this.data[17][8] = true; + this.data[17][9] = true; + this.data[17][10] = true; + this.data[17][11] = true; + this.data[17][12] = true; + this.data[17][13] = true; + + this.data[18][9] = true; + this.data[18][10] = true; + this.data[18][11] = true; + this.data[18][12] = true; + } + */ + /*** Accessors ***/ + + /** + * Returns the width. + * + * @return grid width + */ + public final int getWidth() { + return this.width; + } + + /** + * Returns the height. + * + * @return grid height + */ + public final int getHeight() { + return this.height; + } + + /** + * Returns the content. + * + * @return grid content + */ + public final boolean[][] getData() { + boolean[][] dataCopy = new boolean[this.data.length][]; + + for (int i = 0; i < this.data.length; i++) { + dataCopy[i] = new boolean[this.data[i].length]; + System.arraycopy(this.data[i], 0, + dataCopy[i], 0, + this.data[i].length); + } + + return dataCopy; + } +} + Deleted: trunk/src/picross/game/GameCommand.java =================================================================== --- trunk/src/picross/game/GameCommand.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/game/GameCommand.java 2011-06-29 13:02:58 UTC (rev 94) @@ -1,78 +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.game; - -import fr.cle.mmvcs.NamedCommand; - -/** - * Command used to launch a game. - * - * @author Y. Norsa - */ -public final class GameCommand extends NamedCommand { - /*** Constant ***/ - - /** Command requiring the game launch. */ - public static final String GAME_CMD = "GAME_CMD"; - - /*** Field ***/ - - /** The game to launch. */ - private GameMediator game; - - /*** Constructor ***/ - - /** - * Constructor. - * - * @param gameMediator the game to launch - */ - public GameCommand(GameMediator gameMediator) { - super(GameCommand.GAME_CMD); - - this.game = gameMediator; - } - - /*** Accessor ***/ - - /** - * Returns the game. - * - * @return the game to launch - */ - public GameMediator getGame() { - return this.game; - } -} - Deleted: trunk/src/picross/game/GameController.java =================================================================== --- trunk/src/picross/game/GameController.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/game/GameController.java 2011-06-29 13:02:58 UTC (rev 94) @@ -1,78 +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.game; - -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 game. - * - * @author Y. Norsa - */ -public class GameController extends Controller implements ActionListener { - /*** Static field ***/ - - /** The class' logger. */ - //private static Logger log = Logger.getLogger(GameController.class); - - /*** Method overloaded from the class Controller ***/ - - /** {@inheritDoc} */ - @Override - public void eventPerformed(SimpleEvent e) { } - - /*** Method implanted from the interface ActionListener ***/ - - /** {@inheritDoc} */ - @Override - public void actionPerformed(ActionEvent e) { - //GameController.log.debug("actionPerformed(" + e + ")"); - - String cmd = e.getActionCommand(); - - if (cmd.equals(PicrossController.QUIT_CMD)) { - this.fireEventPerformed(cmd); - return; - } - } -} - Deleted: trunk/src/picross/game/GameMediator.java =================================================================== --- trunk/src/picross/game/GameMediator.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/game/GameMediator.java 2011-06-29 13:02:58 UTC (rev 94) @@ -1,155 +0,0 @@ -/* - * $Id$ - * - * 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, - * 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.Mediateur; -import fr.cle.mmvcs.SimpleEvent; - -import java.awt.event.ActionListener; - -import javax.swing.SwingUtilities; - -//import org.apache.log4j.Logger; - -import picross.PicrossException; -import picross.PicrossGrid; - -import picross.grid.GridMediator; -import picross.grid.GridView; -import picross.grid.IGridMediator; - -/** - * Handles a game. - * - * @author Y. Norsa - */ -public abstract class GameMediator extends Mediateur { - /*** Static field ***/ - - /** The class' logger. */ - //private static Logger log = Logger.getLogger(GameMediator.class); - - /*** Fields ***/ - - /** The game view. */ - private GameUI view; - - /** The game grid. */ - private IGridMediator grid; - - /*** Abstrac method ***/ - - /** - * Creates the model. - * - * @return grid model - * @throws PicrossException if there is a problem - */ - protected abstract PicrossGrid initModel() throws PicrossException; - - /*** Method overloaded from the class Mediator ***/ - - /** {@inheritDoc} */ - @Override - public void eventPerformed(SimpleEvent e) { - //GameMediator.log.debug("eventPerformed(" + e + ")"); - - this.fireEventPerformed(e); - } - - /*** Methods ***/ - - /** - * Inits the game. - * - * @throws PicrossException if there is a problem loading the grid model - * or building the view - */ - public final void init() throws PicrossException { - PicrossGrid model = this.initModel(); - - final int width = model.getWidth(); - final int height = model.getHeight(); - - this.grid = new GridMediator(width, height, - model.getData()); - this.grid.addSimpleListener(this); - - final GameController controller = this.initController(); - controller.addSimpleListener(this); - - // 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, - GameMediator.this.grid.getView(), - controller); - } - }); - } - - /** - * Creates the view. - * - * @param width the grid width - * @param height the grid height - * @param gridView the grid itself - * @param controller controller for the grid buttons - * @return view containing the grid - */ - protected GameUI initView(int width, int height, GridView gridView, - ActionListener controller) { - return new GameUI(width, height, gridView, controller); - } - - /** - * Initialises the controller. - * - * @return the created controller - */ - protected GameController initController() { - return new GameController(); - } - - /** - * Returns the game view. - * - * @return the view - */ - public final GameView getView() { - return this.view; - } -} Modified: trunk/src/picross/game/GameMode.java =================================================================== --- trunk/src/picross/game/GameMode.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/game/GameMode.java 2011-06-29 13:02:58 UTC (rev 94) @@ -33,21 +33,12 @@ package picross.game; -import fr.cle.core.gui.SimpleButton; - -import javax.swing.JButton; - /** * Service describing a game mode. * * @author Y. Norsa */ public interface GameMode { - /** - * Button used to access this game mode. - * - * @return a button that can be added to a menu - */ - SimpleButton<JButton> getButton(); + String getModeName(); } Deleted: trunk/src/picross/game/GameUI.java =================================================================== --- trunk/src/picross/game/GameUI.java 2011-06-28 12:29:00 UTC (rev 93) +++ trunk/src/picross/game/GameUI.java 2011-06-29 13:02:58 UTC (rev 94... [truncated message content] |