picross-commit Mailing List for picross (Page 2)
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...> - 2013-01-14 09:29:26
|
Revision: 114 http://sourceforge.net/p/picross/code/114 Author: yvan_norsa Date: 2013-01-14 09:29:22 +0000 (Mon, 14 Jan 2013) Log Message: ----------- android integration into build script Removed Paths: ------------- branches/engine_split/android/src/picross/properties/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2013-01-14 08:38:38
|
Revision: 113 http://sourceforge.net/p/picross/code/113 Author: yvan_norsa Date: 2013-01-14 08:38:33 +0000 (Mon, 14 Jan 2013) Log Message: ----------- android integration into build script Modified Paths: -------------- branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java branches/engine_split/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java branches/engine_split/android/src/picross/specific/ui/GameMenuUI.java branches/engine_split/android/src/picross/specific/ui/MenuUI.java branches/engine_split/android/src/picross/specific/ui/PicrossButton.java branches/engine_split/build.xml branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java branches/engine_split/common/src/picross/common/ui/MainMenuUI.java branches/engine_split/src/picross/app/MainMenuAppUI.java branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameModeUI.java branches/engine_split/swing/src/picross/specific/game/simple/ui/LevelMenuUI.java branches/engine_split/swing/src/picross/specific/game/simple/ui/SimpleGameModeUI.java branches/engine_split/swing/src/picross/specific/ui/MenuUI.java branches/engine_split/swing/src/picross/specific/ui/WaitMenuUI.java branches/engine_split/swing/test/picross/specific/ui/PicrossUIHelperTest.java Added Paths: ----------- branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java branches/engine_split/android/src/picross/specific/game/simple/ui/LevelMenuUI.java branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java branches/engine_split/images/empty_button.png branches/engine_split/images/en/button_back.png branches/engine_split/images/en/button_exit.png branches/engine_split/images/en/button_play.png branches/engine_split/images/en/button_random.png branches/engine_split/images/en/button_select.png branches/engine_split/images/en/label_wait.png branches/engine_split/images/fr/button_back.png branches/engine_split/images/fr/button_exit.png branches/engine_split/images/fr/button_play.png branches/engine_split/images/fr/button_random.png branches/engine_split/images/fr/button_select.png branches/engine_split/images/fr/label_wait.png Removed Paths: ------------- branches/engine_split/android/libs/bundleHelper.jar branches/engine_split/android/libs/mmvcs.jar branches/engine_split/android/libs/picross-common.jar branches/engine_split/android/libs/picross-engine.jar branches/engine_split/android/libs/simpleButton.jar branches/engine_split/android/res/drawable/background.png branches/engine_split/android/res/drawable/button_play.png branches/engine_split/android/res/drawable/button_random.png branches/engine_split/android/res/drawable/button_select.png branches/engine_split/android/servicesData/META-INF/services/ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java branches/engine_split/images/empty-button.png branches/engine_split/images/en/button-back.png branches/engine_split/images/en/button-exit.png branches/engine_split/images/en/button-play.png branches/engine_split/images/en/button-random.png branches/engine_split/images/en/button-select.png branches/engine_split/images/en/label-wait.png branches/engine_split/images/fr/button-back.png branches/engine_split/images/fr/button-exit.png branches/engine_split/images/fr/button-play.png branches/engine_split/images/fr/button-random.png branches/engine_split/images/fr/button-select.png branches/engine_split/images/fr/label-wait.png Deleted: branches/engine_split/android/libs/bundleHelper.jar =================================================================== (Binary files differ) Deleted: branches/engine_split/android/libs/mmvcs.jar =================================================================== (Binary files differ) Deleted: branches/engine_split/android/libs/picross-common.jar =================================================================== (Binary files differ) Deleted: branches/engine_split/android/libs/picross-engine.jar =================================================================== (Binary files differ) Deleted: branches/engine_split/android/libs/simpleButton.jar =================================================================== (Binary files differ) Deleted: branches/engine_split/android/res/drawable/background.png =================================================================== (Binary files differ) Deleted: branches/engine_split/android/res/drawable/button_play.png =================================================================== (Binary files differ) Deleted: branches/engine_split/android/res/drawable/button_random.png =================================================================== (Binary files differ) Deleted: branches/engine_split/android/res/drawable/button_select.png =================================================================== (Binary files differ) Modified: branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -49,10 +49,10 @@ private static final long serialVersionUID = -505088917693050187L; /** "Play" button X coordinate. */ - private static final int PLAY_BUTTON_X = 0;//50; + private static final int PLAY_BUTTON_X = 150; /** "Play" button Y coordinate. */ - private static final int PLAY_BUTTON_Y = 0;//225; + private static final int PLAY_BUTTON_Y = 225; public MainMenuActivityUI(Context androidContext) { super(androidContext); Added: branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java (rev 0) +++ branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java 2013-01-14 08:38:33 UTC (rev 113) @@ -0,0 +1,69 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.specific.game.simple.ui; + +import android.content.Context; + +import picross.common.game.simple.ui.LevelMenuMediator; + +import picross.specific.ui.MenuUI; +import picross.specific.ui.MenuController; +import picross.common.ui.PicrossUI; +import picross.engine.PicrossException; +import picross.common.game.simple.ui.LevelMenuModel; + +public final class AndroidLevelMenuMediator extends LevelMenuMediator { + private Context context; + + public AndroidLevelMenuMediator(Context context) { + LevelMenuMediator.log.debug("AndroidLevelMenuMediator(" + context + ")"); + this.context = context; + } + + /** {@inheritDoc} */ + @Override + protected MenuUI initView(PicrossUI ui, MenuController controller) + throws PicrossException { + + LevelMenuMediator.log.debug("initView()"); + + this.model = new LevelMenuModel(); + + LevelMenuMediator.log.debug("this : " + this); + LevelMenuMediator.log.debug("this.model : " + this.model); + + return new LevelMenuUI(this.context, controller, this.model.getSizesList()); + } +} + Property changes on: branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/game/simple/ui/LevelMenuUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/simple/ui/LevelMenuUI.java (rev 0) +++ branches/engine_split/android/src/picross/specific/game/simple/ui/LevelMenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -0,0 +1,192 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.specific.game.simple.ui; + +import fr.cle.mmvcs.SimpleEvent; + +import java.util.List; + +import picross.engine.game.simple.Dimensions; + +import picross.specific.ui.PicrossUIHelper; + +import picross.specific.ui.MenuController; +import picross.specific.ui.MenuUI; +import picross.common.ui.PicrossController; + +import picross.common.game.simple.ui.SelectSizeCommand; +import picross.common.game.simple.ui.LevelMenuController; + +import android.content.Context; + +import picross.specific.activities.R; + + +/** + * UI for the level selection menu. + * + * @author Y. Norsa + */ +public final class LevelMenuUI extends MenuUI { + /*** Constructor ***/ + + /** + * Constructor. + * + * @param listener listener for the buttons + * @param sizes available grid sizes + */ + public LevelMenuUI(Context context, MenuController listener, List<Dimensions> sizes) { + super(context); + + this.displaySizes(listener, sizes); + } + + /*** Method ***/ + + /** + * Displays the available level sizes. + * + * @param listener listener for the buttons + * @param sizes grid sizes + */ + void displaySizes(MenuController listener, List<Dimensions> sizes) { + // FIXME + //this.removeAll(); + + int x = 150; + int y = 150; + + for (Dimensions currentDim : sizes) { + 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; + } + } + + this.addBackButton(listener, PicrossController.PLAY_CMD); + + // FIXME + //this.repaint(); + } + + /** + * Displays the levels list. + * + * @param listener listener for the buttons + * @param levels levels to display + */ + public void displayLevels(MenuController listener, List<String> levels) { + // FIXME + /* + this.removeAll(); + + + JPanel panel = new JPanel(); + panel.setOpaque(false); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + */ + int nbLevels = levels.size(); + + for (int i = 0; i < nbLevels; i++) { + String level = levels.get(i); + + SimpleEvent event = + new SimpleEvent(LevelMenuController.LEVEL_CMD, level); + // FIXME + /* + panel.add(this.createSimpleButton(level, event, listener) + .getButton()); + + if (i != (nbLevels - 1)) { + panel.add(Box.createRigidArea(new Dimension(0, 20))); + }*/ + } + // FIXME + /* + JScrollPane scrollPane = new JScrollPane(panel); + scrollPane.setOpaque(false); + scrollPane.setBorder(null); + scrollPane.setBounds(150, 120, 294, 200); + + scrollPane.getViewport().setOpaque(false); + + this.add(scrollPane); + */ + this.addBackButton(listener, MenuController.BACK_CMD); + + // FIXME + /* + this.revalidate(); + this.repaint(); + */ + } + + /** + * Adds a "back" button. + * + * @param listener listener for the button + * @param command command associated to the button + */ + private void addBackButton(/*ActionListener*/MenuController listener, String command) { + // FIXME + /* + ImageIcon backIcon = + PicrossUIHelper.getLocalizedImage("button-back.png"); + + JButton backButton = new JButton(backIcon); + backButton.setActionCommand(command); + backButton.addActionListener(listener); + + backButton.setBorder(null); + backButton.setBounds(7, 318, + backIcon.getIconWidth(), + backIcon.getIconHeight()); + + this.add(backButton); + */ + + this.addButton(R.drawable.button_back, command, listener, 7, 318); + } +} + Property changes on: branches/engine_split/android/src/picross/specific/game/simple/ui/LevelMenuUI.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Modified: branches/engine_split/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -42,7 +42,7 @@ import picross.engine.game.simple.SimpleGameMode; import picross.specific.game.ui.UIGameMode; -import picross.common.game.simple.ui.LevelMenuMediator; +import picross.specific.game.simple.ui.AndroidLevelMenuMediator; import picross.common.ui.MenuCommand; import picross.specific.ui.PicrossButton; @@ -78,7 +78,7 @@ //ImageIcon icon = //PicrossUIHelper.getLocalizedImage(SimpleGameModeUI.SELECT_BUTTON_IMAGE); SimpleEvent event = - new SimpleEvent(new MenuCommand(LevelMenuMediator.class)); + new SimpleEvent(new MenuCommand(AndroidLevelMenuMediator.class)); return new PicrossButton(R.drawable.button_select, event); } Modified: branches/engine_split/android/src/picross/specific/ui/GameMenuUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/GameMenuUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/android/src/picross/specific/ui/GameMenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -71,8 +71,8 @@ public GameMenuUI(Context context, MenuController listener, ServiceLoader<GameMode> modes) { super(context); - int x = 0;//150; - int y = 0;//150; + int x = 150; + int y = 150; GameMenuUI.log.debug("listing des modes..."); Modified: branches/engine_split/android/src/picross/specific/ui/MenuUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/MenuUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/android/src/picross/specific/ui/MenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -338,6 +338,8 @@ button.setIcon(PicrossUIHelper.getImage(this.context.getResources(), button.getResID())); } + button.setListener(listener); + this.putButton(button, x, y, button.getIcon().getWidth(), button.getIcon().getHeight()); } @@ -409,7 +411,14 @@ && (y >= button.getY() && y <= (button.getY() + button.getHeight()))) { MenuUI.log.debug("found"); - button.getController().onPicrossEvent(new PicrossEvent(button.getCommand())); + + if (button.getController() != null) { + button.getController().onPicrossEvent(new PicrossEvent(button.getCommand())); + } + else { + button.getListener().eventPerformed(button.getEvent()); + } + return true; } } Modified: branches/engine_split/android/src/picross/specific/ui/PicrossButton.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/PicrossButton.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/android/src/picross/specific/ui/PicrossButton.java 2013-01-14 08:38:33 UTC (rev 113) @@ -34,6 +34,7 @@ package picross.specific.ui; import fr.cle.mmvcs.SimpleEvent; +import fr.cle.mmvcs.SimpleListener; import android.graphics.Bitmap; @@ -61,6 +62,10 @@ private int resID; private SimpleEvent event; + public SimpleEvent getEvent() { + return this.event; + } + public int getResID() { return this.resID; } @@ -77,6 +82,16 @@ return this.controller; } + private SimpleListener listener; + + public SimpleListener getListener() { + return this.listener; + } + + public void setListener(SimpleListener listener) { + this.listener = listener; + } + public String getCommand() { return this.command; } Modified: branches/engine_split/build.xml =================================================================== --- branches/engine_split/build.xml 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/build.xml 2013-01-14 08:38:33 UTC (rev 113) @@ -443,4 +443,39 @@ <sourcePath path="${game.src.dir}" /> </findbugs> </target> + + <!-- Android stuff --> + + <property name="android.dir" + value="android" /> + + <target name="android-dist" + depends="common-dist"> + <copy todir="${android.dir}/servicesData/META-INF/services"> + <fileset dir="services" /> + </copy> + + <copy todir="${android.dir}/libs" + file="${common.jar.name}" /> + <copy todir="${android.dir}/libs" + file="${engine.jar.name}" /> + <copy todir="${android.dir}/libs" + file="${bundleHelper.jar}" /> + <copy todir="${android.dir}/libs" + file="${mmvcs.jar}" /> + <copy todir="${android.dir}/libs" + file="${simpleButton.jar}" /> + + <copy todir="${android.dir}/res/drawable"> + <fileset dir="images" + includes="*.png" + excludes="*rollover*.png" /> + <fileset dir="images/en/" + includes="*.png" /> + </copy> + + <ant antfile="build.xml" + dir="${android.dir}" + target="debug" /> + </target> </project> Deleted: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java 2013-01-14 08:38:33 UTC (rev 113) @@ -1,140 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2008-2011 - * - * 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.common.game.simple.ui; - -import fr.cle.mmvcs.SimpleEvent; - -import java.util.List; - -import picross.engine.PicrossLogger; -import picross.engine.PicrossLogHelper; -import picross.engine.PicrossException; - -import picross.common.game.ui.GameCommand; - -import picross.specific.ui.MenuController; -import picross.common.ui.MenuMediator; -import picross.common.ui.PicrossUI; - -import picross.specific.ui.MenuUI; - -import picross.specific.game.simple.ui.LevelMenuUI; - -/** - * Level selection menu. - * - * @author Y. Norsa - */ -public final class LevelMenuMediator extends MenuMediator { - /*** Static field ***/ - - /** The class' logger. */ - private static PicrossLogger log = PicrossLogHelper.getLogger(); - - /*** Field ***/ - - /** Model containing the levels list. */ - private LevelMenuModel model = null; - - /*** Methods overloaded from the class MenuMediator ***/ - - /** {@inheritDoc} */ - @Override - protected MenuController initController() { - MenuController controller = new LevelMenuController(); - this.addSimpleListener(controller); - - return controller; - } - - /** {@inheritDoc} */ - @Override - protected MenuUI initView(PicrossUI ui, MenuController controller) - throws PicrossException { - - LevelMenuMediator.log.debug("initView()"); - - this.model = new LevelMenuModel(); - - LevelMenuMediator.log.debug("this : " + this); - LevelMenuMediator.log.debug("this.model : " + this.model); - - return new LevelMenuUI(controller, this.model.getSizesList()); - } - - /** {@inheritDoc} */ - @Override - public void eventPerformed(SimpleEvent e) { - LevelMenuMediator.log.debug("eventPerformed(" + e + ")"); - LevelMenuMediator.log.debug("this : " + this); - LevelMenuMediator.log.debug("this.model : " + this.model); - - 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(LevelMenuController.LEVEL_CMD)) { - String level = e.getComment(); - this.fireEventPerformed(new - GameCommand(new - SimpleGameMediator(level))); - return; - } - - if (cmd.equals(MenuController.BACK_CMD)) { - this.fireEventPerformed(new SizesListCommand(this.model - .getSizesList())); - return; - } - - super.eventPerformed(e); - } - - /*** Method ***/ - - /** - * Sends a message asking to display the levels list. - * - * @param levels the levels list - */ - private void displayLevels(List<String> levels) { - this.fireEventPerformed(new LevelsListCommand(levels)); - } -} - Added: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java 2013-01-14 08:38:33 UTC (rev 113) @@ -0,0 +1,140 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.simple.ui; + +import fr.cle.mmvcs.SimpleEvent; + +import java.util.List; + +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; +import picross.engine.PicrossException; + +import picross.common.game.ui.GameCommand; + +import picross.specific.ui.MenuController; +import picross.common.ui.MenuMediator; +import picross.common.ui.PicrossUI; + +import picross.specific.ui.MenuUI; + +import picross.specific.game.simple.ui.LevelMenuUI; + +/** + * Level selection menu. + * + * @author Y. Norsa + */ +public class LevelMenuMediator extends MenuMediator { + /*** Static field ***/ + + /** The class' logger. */ + protected static PicrossLogger log = PicrossLogHelper.getLogger(); + + /*** Field ***/ + + /** Model containing the levels list. */ + protected LevelMenuModel model = null; + + /*** Methods overloaded from the class MenuMediator ***/ + + /** {@inheritDoc} */ + @Override + protected MenuController initController() { + MenuController controller = new LevelMenuController(); + this.addSimpleListener(controller); + + return controller; + } + + /** {@inheritDoc} */ + @Override + protected MenuUI initView(PicrossUI ui, MenuController controller) + throws PicrossException { + + LevelMenuMediator.log.debug("initView()"); + + this.model = new LevelMenuModel(); + + LevelMenuMediator.log.debug("this : " + this); + LevelMenuMediator.log.debug("this.model : " + this.model); + + return new LevelMenuUI(controller, this.model.getSizesList()); + } + + /** {@inheritDoc} */ + @Override + public void eventPerformed(SimpleEvent e) { + LevelMenuMediator.log.debug("eventPerformed(" + e + ")"); + LevelMenuMediator.log.debug("this : " + this); + LevelMenuMediator.log.debug("this.model : " + this.model); + + 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(LevelMenuController.LEVEL_CMD)) { + String level = e.getComment(); + this.fireEventPerformed(new + GameCommand(new + SimpleGameMediator(level))); + return; + } + + if (cmd.equals(MenuController.BACK_CMD)) { + this.fireEventPerformed(new SizesListCommand(this.model + .getSizesList())); + return; + } + + super.eventPerformed(e); + } + + /*** Method ***/ + + /** + * Sends a message asking to display the levels list. + * + * @param levels the levels list + */ + private void displayLevels(List<String> levels) { + this.fireEventPerformed(new LevelsListCommand(levels)); + } +} + Modified: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java 2013-01-14 08:38:33 UTC (rev 113) @@ -54,7 +54,7 @@ * * @author Y. Norsa */ -final class LevelMenuModel { +public final class LevelMenuModel { /*** Constant ***/ /** File containing the data files list. */ @@ -72,7 +72,7 @@ * * @throws PicrossException if an error arises during the levels listing */ - LevelMenuModel() throws PicrossException { + public LevelMenuModel() throws PicrossException { this.levels = new HashMap<Dimensions, List<String>>(); List<LevelInfos> infos = null; @@ -137,7 +137,7 @@ * * @return list of all the grid sizes */ - List<Dimensions> getSizesList() { + public List<Dimensions> getSizesList() { return new ArrayList<Dimensions>(this.levels.keySet()); } Modified: branches/engine_split/common/src/picross/common/ui/MainMenuUI.java =================================================================== --- branches/engine_split/common/src/picross/common/ui/MainMenuUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/common/src/picross/common/ui/MainMenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -50,7 +50,7 @@ private static final long serialVersionUID = -505088917693050187L; /** Image for the "play" button. */ - private static final String PLAY_BUTTON_IMAGE = "button-play.png"; + private static final String PLAY_BUTTON_IMAGE = "button_play.png"; /*** Abstract methods ***/ Deleted: branches/engine_split/images/empty-button.png =================================================================== (Binary files differ) Copied: branches/engine_split/images/empty_button.png (from rev 109, branches/engine_split/images/empty-button.png) =================================================================== (Binary files differ) Deleted: branches/engine_split/images/en/button-back.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/en/button-exit.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/en/button-play.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/en/button-random.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/en/button-select.png =================================================================== (Binary files differ) Copied: branches/engine_split/images/en/button_back.png (from rev 109, branches/engine_split/images/en/button-back.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/en/button_exit.png (from rev 109, branches/engine_split/images/en/button-exit.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/en/button_play.png (from rev 109, branches/engine_split/images/en/button-play.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/en/button_random.png (from rev 109, branches/engine_split/images/en/button-random.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/en/button_select.png (from rev 109, branches/engine_split/images/en/button-select.png) =================================================================== (Binary files differ) Deleted: branches/engine_split/images/en/label-wait.png =================================================================== (Binary files differ) Copied: branches/engine_split/images/en/label_wait.png (from rev 109, branches/engine_split/images/en/label-wait.png) =================================================================== (Binary files differ) Deleted: branches/engine_split/images/fr/button-back.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/fr/button-exit.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/fr/button-play.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/fr/button-random.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/fr/button-select.png =================================================================== (Binary files differ) Copied: branches/engine_split/images/fr/button_back.png (from rev 109, branches/engine_split/images/fr/button-back.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/fr/button_exit.png (from rev 109, branches/engine_split/images/fr/button-exit.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/fr/button_play.png (from rev 109, branches/engine_split/images/fr/button-play.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/fr/button_random.png (from rev 109, branches/engine_split/images/fr/button-random.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/fr/button_select.png (from rev 109, branches/engine_split/images/fr/button-select.png) =================================================================== (Binary files differ) Deleted: branches/engine_split/images/fr/label-wait.png =================================================================== (Binary files differ) Copied: branches/engine_split/images/fr/label_wait.png (from rev 109, branches/engine_split/images/fr/label-wait.png) =================================================================== (Binary files differ) Modified: branches/engine_split/src/picross/app/MainMenuAppUI.java =================================================================== --- branches/engine_split/src/picross/app/MainMenuAppUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/src/picross/app/MainMenuAppUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -58,7 +58,7 @@ private static final int PLAY_BUTTON_Y = 225; /** Image for the "exit" button. */ - private static final String EXIT_BUTTON_IMAGE = "button-exit.png"; + private static final String EXIT_BUTTON_IMAGE = "button_exit.png"; /** "Exit" button X coordinate. */ private static final int EXIT_BUTTON_X = 250; Modified: branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameModeUI.java =================================================================== --- branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameModeUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameModeUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -59,7 +59,7 @@ /*** Constants ***/ /** 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; Modified: branches/engine_split/swing/src/picross/specific/game/simple/ui/LevelMenuUI.java =================================================================== --- branches/engine_split/swing/src/picross/specific/game/simple/ui/LevelMenuUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/swing/src/picross/specific/game/simple/ui/LevelMenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -172,7 +172,7 @@ */ private void addBackButton(ActionListener listener, String command) { ImageIcon backIcon = - PicrossUIHelper.getLocalizedImage("button-back.png"); + PicrossUIHelper.getLocalizedImage("button_back.png"); JButton backButton = new JButton(backIcon); backButton.setActionCommand(command); Modified: branches/engine_split/swing/src/picross/specific/game/simple/ui/SimpleGameModeUI.java =================================================================== --- branches/engine_split/swing/src/picross/specific/game/simple/ui/SimpleGameModeUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/swing/src/picross/specific/game/simple/ui/SimpleGameModeUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -62,7 +62,7 @@ /*** Constant ***/ /** 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; Modified: branches/engine_split/swing/src/picross/specific/ui/MenuUI.java =================================================================== --- branches/engine_split/swing/src/picross/specific/ui/MenuUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/swing/src/picross/specific/ui/MenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -170,7 +170,7 @@ SimpleListener listener) { PicrossButton button = new PicrossButton(label, - PicrossUIHelper.getImage("empty-button.png"), + PicrossUIHelper.getImage("empty_button.png"), event); button.addSimpleListener(listener); Modified: branches/engine_split/swing/src/picross/specific/ui/WaitMenuUI.java =================================================================== --- branches/engine_split/swing/src/picross/specific/ui/WaitMenuUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/swing/src/picross/specific/ui/WaitMenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -56,7 +56,7 @@ super(); ImageIcon labelIcon = - PicrossUIHelper.getLocalizedImage("label-wait.png"); + PicrossUIHelper.getLocalizedImage("label_wait.png"); JLabel label = new JLabel(labelIcon); label.setBorder(null); label.setBounds(75, 225, Modified: branches/engine_split/swing/test/picross/specific/ui/PicrossUIHelperTest.java =================================================================== --- branches/engine_split/swing/test/picross/specific/ui/PicrossUIHelperTest.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/swing/test/picross/specific/ui/PicrossUIHelperTest.java 2013-01-14 08:38:33 UTC (rev 113) @@ -109,7 +109,7 @@ @Test public void getLocalizedImage() { - ImageIcon icon = PicrossUIHelper.getLocalizedImage("button-play.png"); + ImageIcon icon = PicrossUIHelper.getLocalizedImage("button_play.png"); PicrossUIHelperTest.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...> - 2013-01-11 14:36:56
|
Revision: 112 http://sourceforge.net/p/picross/code/112 Author: yvan_norsa Date: 2013-01-11 14:36:50 +0000 (Fri, 11 Jan 2013) Log Message: ----------- android stuff Modified Paths: -------------- branches/engine_split/android/libs/picross-common.jar branches/engine_split/android/libs/picross-engine.jar branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java branches/engine_split/android/src/picross/specific/ui/MainMenuUI.java branches/engine_split/android/src/picross/specific/ui/MenuController.java branches/engine_split/android/src/picross/specific/ui/MenuUI.java branches/engine_split/android/src/picross/specific/ui/PicrossAndroidLogger.java branches/engine_split/common/src/picross/common/ui/AbstractPicrossMediator.java branches/engine_split/common/src/picross/common/ui/GameMenuModel.java branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java branches/engine_split/engine/src/picross/engine/PicrossLogger.java branches/engine_split/swing/src/picross/specific/ui/PicrossLog4jLogger.java Added Paths: ----------- branches/engine_split/android/custom_rules.xml branches/engine_split/android/res/drawable/button_play.png branches/engine_split/android/res/drawable/button_random.png branches/engine_split/android/res/drawable/button_select.png branches/engine_split/android/servicesData/ branches/engine_split/android/servicesData/META-INF/ branches/engine_split/android/servicesData/META-INF/services/ branches/engine_split/android/servicesData/META-INF/services/picross.engine.game.GameMode branches/engine_split/android/src/picross/specific/game/random/ branches/engine_split/android/src/picross/specific/game/random/ui/ branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameMediator.java branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameModeUI.java branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameUI.java branches/engine_split/android/src/picross/specific/game/simple/ branches/engine_split/android/src/picross/specific/game/simple/ui/ branches/engine_split/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java branches/engine_split/android/src/picross/specific/game/ui/GameUI.java branches/engine_split/android/src/picross/specific/game/ui/UIGameMode.java branches/engine_split/android/src/picross/specific/ui/GameMenuMediator.java branches/engine_split/android/src/picross/specific/ui/GameMenuUI.java branches/engine_split/android/src/picross/specific/ui/PicrossButton.java branches/engine_split/common/src/picross/specific/ui/GameMenuMediator.java branches/engine_split/engine/src/picross/engine/AbstractPicrossLogger.java branches/engine_split/swing/src/picross/specific/ui/GameMenuMediator.java Removed Paths: ------------- branches/engine_split/common/src/picross/common/ui/GameMenuMediator.java Added: branches/engine_split/android/custom_rules.xml =================================================================== --- branches/engine_split/android/custom_rules.xml (rev 0) +++ branches/engine_split/android/custom_rules.xml 2013-01-11 14:36:50 UTC (rev 112) @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<project name="PicrossDroid-custom"> + <target name="-post-package"> + + <jar destfile="${out.packaged.file}" update="true"> + <fileset dir="servicesData"/> + </jar> + </target> +</project> Modified: branches/engine_split/android/libs/picross-common.jar =================================================================== (Binary files differ) Modified: branches/engine_split/android/libs/picross-engine.jar =================================================================== (Binary files differ) Added: branches/engine_split/android/res/drawable/button_play.png =================================================================== (Binary files differ) Index: branches/engine_split/android/res/drawable/button_play.png =================================================================== --- branches/engine_split/android/res/drawable/button_play.png 2013-01-11 09:43:57 UTC (rev 111) +++ branches/engine_split/android/res/drawable/button_play.png 2013-01-11 14:36:50 UTC (rev 112) Property changes on: branches/engine_split/android/res/drawable/button_play.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/engine_split/android/res/drawable/button_random.png =================================================================== (Binary files differ) Index: branches/engine_split/android/res/drawable/button_random.png =================================================================== --- branches/engine_split/android/res/drawable/button_random.png 2013-01-11 09:43:57 UTC (rev 111) +++ branches/engine_split/android/res/drawable/button_random.png 2013-01-11 14:36:50 UTC (rev 112) Property changes on: branches/engine_split/android/res/drawable/button_random.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/engine_split/android/res/drawable/button_select.png =================================================================== (Binary files differ) Index: branches/engine_split/android/res/drawable/button_select.png =================================================================== --- branches/engine_split/android/res/drawable/button_select.png 2013-01-11 09:43:57 UTC (rev 111) +++ branches/engine_split/android/res/drawable/button_select.png 2013-01-11 14:36:50 UTC (rev 112) Property changes on: branches/engine_split/android/res/drawable/button_select.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/engine_split/android/servicesData/META-INF/services/picross.engine.game.GameMode =================================================================== --- branches/engine_split/android/servicesData/META-INF/services/picross.engine.game.GameMode (rev 0) +++ branches/engine_split/android/servicesData/META-INF/services/picross.engine.game.GameMode 2013-01-11 14:36:50 UTC (rev 112) @@ -0,0 +1,2 @@ +picross.specific.game.random.ui.RandomGameModeUI +picross.specific.game.simple.ui.SimpleGameModeUI Modified: branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java 2013-01-11 09:43:57 UTC (rev 111) +++ branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java 2013-01-11 14:36:50 UTC (rev 112) @@ -49,10 +49,10 @@ private static final long serialVersionUID = -505088917693050187L; /** "Play" button X coordinate. */ - private static final int PLAY_BUTTON_X = 50; + private static final int PLAY_BUTTON_X = 0;//50; /** "Play" button Y coordinate. */ - private static final int PLAY_BUTTON_Y = 225; + private static final int PLAY_BUTTON_Y = 0;//225; public MainMenuActivityUI(Context androidContext) { super(androidContext); Added: branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameMediator.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameMediator.java (rev 0) +++ branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameMediator.java 2013-01-11 14:36:50 UTC (rev 112) @@ -0,0 +1,99 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * 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.specific.game.random.ui; + +import fr.cle.mmvcs.SimpleEvent; + +import picross.engine.game.random.RandomPicrossModel; + +//import picross.specific.game.ui.GameController; +import picross.specific.game.ui.GameMediator; +import picross.specific.game.ui.GameUI; + +import picross.engine.grid.PicrossGrid; + +import picross.common.grid.ui.GridView; + +import picross.specific.ui.MenuController; + +/** + * This object handles a random grid game. + * + * @author Y. Norsa + */ +public final class RandomGameMediator extends GameMediator { + /*** Methods overloaded from the class GameMediator ***/ + + /** {@inheritDoc} */ + /* + @Override + protected GameUI initView(int width, int height, GridView gridView, + MenuController controller) { + return new RandomGameUI(width, height, gridView, + controller); + } + */ + /** {@inheritDoc} */ + // FIXME + /* + @Override + protected GameController initController() { + return new RandomGameController(); + } + */ + /** {@inheritDoc} */ + + @Override + protected PicrossGrid initModel() { + // FIXME + //return new RandomPicrossModel(); + return null; + } + + /** {@inheritDoc} */ + @Override + public void eventPerformed(SimpleEvent e) { + String cmd = e.getCommandName(); + // FIXME + /* + if (cmd.equals(RandomGameController.NEXT_CMD)) { + this.fireEventPerformed(RandomGameModeUI.getRandomGameCommand()); + + return; + } + */ + // We want to relay other events, such as GRID_FILLED_CMD + super.eventPerformed(e); + } +} Property changes on: branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameMediator.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameModeUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameModeUI.java (rev 0) +++ branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameModeUI.java 2013-01-11 14:36:50 UTC (rev 112) @@ -0,0 +1,98 @@ +/* + * $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.specific.game.random.ui; + +import fr.cle.core.gui.SimpleButton; + +import fr.cle.mmvcs.SimpleEvent; + +import picross.engine.game.random.RandomGameMode; + +import picross.common.game.ui.GameCommand; +import picross.specific.game.ui.UIGameMode; + +import picross.specific.ui.PicrossButton; +import picross.specific.ui.PicrossUIHelper; + +import picross.specific.activities.R; + +/** + * Random game mode. + * + * @author Y. Norsa + */ +public final class RandomGameModeUI extends RandomGameMode + implements UIGameMode { + + /*** Constants ***/ + + /** 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; + + /*** Static method ***/ + + /** + * Returns the command corresponding to a new random grid. + * + * @return a game command for a new random grid + */ + public static GameCommand getRandomGameCommand() { + return new GameCommand(new RandomGameMediator()); + } + + /*** Method implanted from the interface GameMode ***/ + + /** {@inheritDoc} */ + @Override + //public SimpleButton<JButton> getButton() { + public PicrossButton getButton() { + SimpleEvent event = + new SimpleEvent(RandomGameModeUI.getRandomGameCommand()); + // FIXME + /* + ImageIcon icon = + PicrossUIHelper.getLocalizedImage(RandomGameModeUI.RANDOM_BUTTON_IMAGE); + + return new PicrossButton(icon, event); + */ + return new PicrossButton(R.drawable.button_random, event); + } +} + Property changes on: branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameModeUI.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameUI.java (rev 0) +++ branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameUI.java 2013-01-11 14:36:50 UTC (rev 112) @@ -0,0 +1,79 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * 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.specific.game.random.ui; + +import bundleHelper.BundleHelper; + +import picross.specific.game.ui.GameUI; + +import picross.common.grid.ui.GridView; + +import picross.specific.ui.MenuController; + +/** + * Custom UI for a random game. + * + * @author Y. Norsa + */ +final class RandomGameUI extends GameUI { + /*** Constant ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = -5378941563835370491L; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param width the grid width + * @param height the grid height + * @param grid the grid + * @param controller the UI controller + */ + RandomGameUI(int width, int height, GridView grid, + MenuController controller) { + super(width, height, grid, controller); + + // FIXME + /* + JButton nextButton = + new JButton(BundleHelper.getString(this, "anotherGrid")); + nextButton.addActionListener(controller); + nextButton.setActionCommand(RandomGameController.NEXT_CMD); + + this.addButton(nextButton); + */ + } +} Property changes on: branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameUI.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java (rev 0) +++ branches/engine_split/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java 2013-01-11 14:36:50 UTC (rev 112) @@ -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.specific.game.simple.ui; + +import fr.cle.core.gui.SimpleButton; + +import fr.cle.mmvcs.SimpleEvent; + +import picross.engine.game.GameMode; + +import picross.engine.game.simple.SimpleGameMode; + +import picross.specific.game.ui.UIGameMode; +import picross.common.game.simple.ui.LevelMenuMediator; + +import picross.common.ui.MenuCommand; +import picross.specific.ui.PicrossButton; +import picross.specific.ui.PicrossUIHelper; + +import picross.specific.activities.R; + +/** + * Simple game mode. + * + * @author Y. Norsa + */ +public final class SimpleGameModeUI extends SimpleGameMode + implements UIGameMode { + + /*** Constant ***/ + + /** 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; + + /*** Method implanted from the interface GameMode ***/ + + /** {@inheritDoc} */ + @Override + //public SimpleButton<JButton> getButton() { + public PicrossButton getButton() { + //ImageIcon icon = + //PicrossUIHelper.getLocalizedImage(SimpleGameModeUI.SELECT_BUTTON_IMAGE); + SimpleEvent event = + new SimpleEvent(new MenuCommand(LevelMenuMediator.class)); + + return new PicrossButton(R.drawable.button_select, event); + } +} + Property changes on: branches/engine_split/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/game/ui/GameUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/ui/GameUI.java (rev 0) +++ branches/engine_split/android/src/picross/specific/game/ui/GameUI.java 2013-01-11 14:36:50 UTC (rev 112) @@ -0,0 +1,133 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * 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.specific.game.ui; + +import bundleHelper.BundleHelper; + +import picross.common.ui.PicrossController; + +import picross.common.grid.ui.GridView; + +import picross.common.game.ui.GameView; + + +import picross.specific.ui.MenuController; +import picross.specific.ui.PicrossButton; + +/** + * The game UI. + * + * @author Y. Norsa + */ +// FIXME +public class GameUI /*extends JPanel*/ implements GameView { + /*** Constant ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = 5888877041010228476L; + + /*** Field ***/ + + /** Panel holding the buttons. */ + //private JPanel buttonsPanel; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param width the grid width + * @param height the grid height + * @param grid the grid + * @param listener listener for the buttons + */ + //public GameUI(int width, int height, JPanel grid, + public GameUI(int width, int height, GridView grid, + MenuController listener) { + super(); + // FIXME + /* + this.setLayout(new BorderLayout()); + + JPanel topPanel = new JPanel(new BorderLayout()); + topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS)); + + JPanel contentPanel = new JPanel(); + contentPanel.setLayout(new BoxLayout(contentPanel, + BoxLayout.Y_AXIS)); + + JPanel infosPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + infosPanel.setBackground(Color.WHITE); + + JLabel infos = new JLabel(BundleHelper.getString(this, + "gridSize") + + " : " + width + "*" + height); + + infosPanel.add(infos); + + topPanel.add(infosPanel); + topPanel.add(new JSeparator()); + + this.buttonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + this.buttonsPanel.setBackground(Color.WHITE); + + JButton menuButton = new JButton(BundleHelper.getString(this, + "menuButton")); + menuButton.addActionListener(listener); + menuButton.setActionCommand(PicrossController.QUIT_CMD); + this.buttonsPanel.add(menuButton); + + topPanel.add(this.buttonsPanel); + topPanel.add(new JSeparator()); + + topPanel.add(contentPanel, BorderLayout.LINE_START); + + this.add(topPanel, BorderLayout.PAGE_START); + this.add((Component) grid, BorderLayout.CENTER); + */ + } + + /*** Method ***/ + + /** + * Helper method to add a button. + * + * @param button the button to add + */ + //protected void addButton(JButton button) { + protected void addButton(PicrossButton button) { + // FIXME + //this.buttonsPanel.add(button); + } +} Property changes on: branches/engine_split/android/src/picross/specific/game/ui/GameUI.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/game/ui/UIGameMode.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/ui/UIGameMode.java (rev 0) +++ branches/engine_split/android/src/picross/specific/game/ui/UIGameMode.java 2013-01-11 14:36:50 UTC (rev 112) @@ -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.specific.game.ui; + +import fr.cle.core.gui.SimpleButton; + +//import javax.swing.JButton; + +import picross.engine.game.GameMode; + +import picross.specific.ui.PicrossButton; + +/** + * Service describing a game mode. + * + * @author Y. Norsa + */ +public interface UIGameMode extends GameMode { + /** + * Button used to access this game mode. + * + * @return a button that can be added to a menu + */ + //SimpleButton<JButton> getButton(); + PicrossButton getButton(); +} + Property changes on: branches/engine_split/android/src/picross/specific/game/ui/UIGameMode.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/ui/GameMenuMediator.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/GameMenuMediator.java (rev 0) +++ branches/engine_split/android/src/picross/specific/ui/GameMenuMediator.java 2013-01-11 14:36:50 UTC (rev 112) @@ -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.specific.ui; + +import picross.engine.PicrossException; + +import picross.common.ui.MenuMediator; +import picross.common.ui.PicrossUI; +import picross.common.ui.GameMenuModel; + +import android.content.Context; + +/** + * Mediator for the game menu. + * + * @author Y. Norsa + */ +public final class GameMenuMediator extends MenuMediator { + private Context context; + + public GameMenuMediator(Context androidContext) { + picross.engine.PicrossLogHelper.getLogger().debug("GameMenuMediator(" + androidContext + ")"); + + if (androidContext == null) { + throw new IllegalArgumentException("\"androidContext\" cannot be null"); + } + + this.context = androidContext; + } + + /*** Method overloaded from the class MenuMediator ***/ + + /** {@inheritDoc} */ + @Override + protected MenuUI initView(PicrossUI ui, MenuController controller) + throws PicrossException { + + return new GameMenuUI(this.context, controller, new GameMenuModel().getGameModes()); + } +} Property changes on: branches/engine_split/android/src/picross/specific/ui/GameMenuMediator.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/ui/GameMenuUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/GameMenuUI.java (rev 0) +++ branches/engine_split/android/src/picross/specific/ui/GameMenuUI.java 2013-01-11 14:36:50 UTC (rev 112) @@ -0,0 +1,92 @@ +/* + * $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.specific.ui; + +import java.util.ServiceLoader; + +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; + +import picross.engine.game.GameMode; + +import picross.specific.game.ui.UIGameMode; + +import android.content.Context; + +/** + * UI for the game menu. + * + * @author Y. Norsa + */ +public final class GameMenuUI extends MenuUI { + /*** Constant ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = 4472277675596865332L; + + /*** Static field ***/ + + /** The class' logger. */ + private static PicrossLogger log = PicrossLogHelper.getLogger(); + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param listener listener for the buttons + * @param modes available game modes + */ + public GameMenuUI(Context context, MenuController listener, ServiceLoader<GameMode> modes) { + super(context); + + int x = 0;//150; + int y = 0;//150; + + GameMenuUI.log.debug("listing des modes..."); + + for (GameMode mode : modes) { + GameMenuUI.log.debug("mode : " + mode); + + if (mode instanceof UIGameMode) { + this.addButton(((UIGameMode) mode).getButton(), listener, x, y); + } else { + // TODO add dynamic button + } + + y += 75; + } + } +} + Property changes on: branches/engine_split/android/src/picross/specific/ui/GameMenuUI.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Modified: branches/engine_split/android/src/picross/specific/ui/MainMenuUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/MainMenuUI.java 2013-01-11 09:43:57 UTC (rev 111) +++ branches/engine_split/android/src/picross/specific/ui/MainMenuUI.java 2013-01-11 14:36:50 UTC (rev 112) @@ -40,6 +40,8 @@ import android.content.Context; +import picross.specific.activities.R; + /** * UI for the main menu. * @@ -82,7 +84,9 @@ * @param controller controller for the menu's buttons */ public void init(MenuController controller) { - this.addButton(MainMenuUI.PLAY_BUTTON_IMAGE, + // FIXME + this.addButton(//MainMenuUI.PLAY_BUTTON_IMAGE, + R.drawable.button_play, PicrossController.PLAY_CMD, controller, this.getPlayButtonX(), this.getPlayButtonY()); } Modified: branches/engine_split/android/src/picross/specific/ui/MenuController.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/MenuController.java 2013-01-11 09:43:57 UTC (rev 111) +++ branches/engine_split/android/src/picross/specific/ui/MenuController.java 2013-01-11 14:36:50 UTC (rev 112) @@ -41,22 +41,29 @@ import picross.common.ui.AbstractMenuController; +import android.view.View; +import android.view.MotionEvent; + /** * Generic controller for the menus. * * @author Y. Norsa */ -public class MenuController extends AbstractMenuController /*implements ActionListener*/ { +public class MenuController extends AbstractMenuController {//implements View.OnTouchListener { /*** Method implanted from the interface ActionListener ***/ /** {@inheritDoc} */ - // FIXME /* @Override - public void actionPerformed(ActionEvent e) { - String cmd = e.getActionCommand(); - this.fireEventPerformed(cmd); + public boolean onTouch(View view, MotionEvent e) { + //String cmd = e.getActionCommand(); + //this.fireEventPerformed(cmd); + return false; }*/ + + public void onPicrossEvent(MenuUI.PicrossEvent e) { + this.fireEventPerformed(e.getActionCommand()); + } } Modified: branches/engine_split/android/src/picross/specific/ui/MenuUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/MenuUI.java 2013-01-11 09:43:57 UTC (rev 111) +++ branches/engine_split/android/src/picross/specific/ui/MenuUI.java 2013-01-11 14:36:50 UTC (rev 112) @@ -57,6 +57,11 @@ import android.graphics.Canvas; import android.view.SurfaceHolder; +import java.util.ArrayList; +import java.util.List; + +import android.view.MotionEvent; + /** * Base class for menus. * @@ -90,6 +95,8 @@ protected Context context; private SurfaceHolder surface; + private List<PicrossButton> buttons; + /*** Constructor ***/ /** Constructor. */ @@ -126,6 +133,8 @@ this.surface = this.getHolder(); this.surface.addCallback(this); + + this.buttons = new ArrayList<PicrossButton>(); } @@ -183,13 +192,17 @@ } public void onDraw(Canvas canvas) { - MenuUI.log.debug("onDraw(" + canvas + ")"); + //MenuUI.log.debug("onDraw(" + canvas + ")"); if (canvas == null) { return; } canvas.drawBitmap(this.image, 0, 0, null); + + for (PicrossButton button : this.buttons) { + canvas.drawBitmap(button.getIcon(), button.getX(), button.getY(), null); + } } /*** Methods ***/ @@ -205,8 +218,9 @@ * @throws MissingImageException if a button image can't be found */ - protected final void addButton(String image, String command, + protected final void addButton(/*String image*/int resID, String command, MenuController controller, int x, int y) { + MenuUI.log.debug("addButton(" + image + ", " + command + ", controller, " + x + ", " + y + ")"); /* ImageIcon buttonIcon = PicrossUIHelper.getLocalizedImage(image); JButton button = new JButton(buttonIcon); @@ -217,9 +231,12 @@ this.putButton(button, x, y, buttonIcon.getIconWidth(), buttonIcon.getIconHeight()); */ + // FIXME + Bitmap buttonIcon = PicrossUIHelper.getImage( context.getResources(), resID); + this.putButton(new PicrossButton(buttonIcon, controller, command), x, y, + buttonIcon.getWidth(), buttonIcon.getHeight()); } - /** * Helper method to add a button to the menu. * @@ -232,6 +249,7 @@ protected final void addSimpleButton(String label, SimpleEvent event, SimpleListener listener, int x, int y) { + MenuUI.log.debug("addSimpleButton(" + label + ", " + event + ", listener, " + x + ", " + y + ")"); // FIXME /* PicrossButton button = @@ -303,6 +321,27 @@ } */ + protected final void addButton(PicrossButton button, + SimpleListener listener, + int x, int y) { + + // FIXME + /* + button.addSimpleListener(listener); + + JButton realButton = button.getButton(); + Icon icon = realButton.getIcon(); + + realButton.setBorder(null); + */ + if (button.getIcon() == null) { + button.setIcon(PicrossUIHelper.getImage(this.context.getResources(), button.getResID())); + } + + this.putButton(button, x, y, + button.getIcon().getWidth(), button.getIcon().getHeight()); + } + /** * Finalizes the button's setup. * @@ -320,4 +359,73 @@ this.add(button); } */ + + private void putButton(PicrossButton button, int x, int y, + int width, int height) { + MenuUI.log.debug("putButton(" + button + ", " + x + ", " + y + ", " + width + ", " + height + ")"); + //button.setBounds(x, y, width, height); + + button.setX(x); + button.setY(y); + button.setWidth(width); + button.setHeight(height); + + //button.controller + + this.add(button); + } + + //X=50, Y=225, W=150, H=50 + // X >= 50 && X <= 200 + // Y >= 225 && Y <= 275 + + + //228,226 + + //312 267 + + private void add(PicrossButton button) { + this.buttons.add(button); + } + + @Override + public boolean onTouchEvent (MotionEvent event) { + float x = event.getX(); + float y = event.getY(); + + MenuUI.log.debug("x = " + x + ", y = " + y); + + for (PicrossButton button : buttons) { + MenuUI.log.debug("Testing with X between " + button.getX() + " and " + (button.getX() + button.getWidth()) + + ", and Y between " + button.getY() + " and " + (button.getY() + button.getHeight())); + /* + MenuUI.log.debug(x >= button.x); + MenuUI.log.debug(x <= (button.x + button.width)); + MenuUI.log.debug(y >= button.y); + MenuUI.log.debug(y <= (button.y + button.height)); + */ + + if ((x >= button.getX() && x <= (button.getX() + button.getWidth())) + && (y >= button.getY() && y <= (button.getY() + button.getHeight()))) { + + MenuUI.log.debug("found"); + button.getController().onPicrossEvent(new PicrossEvent(button.getCommand())); + return true; + } + } + + return false; + } + + public static class PicrossEvent { + private String actionCommand; + + private PicrossEvent(String command) { + this.actionCommand = command; + } + + public String getActionCommand() { + return this.actionCommand; + } + } } Modified: branches/engine_split/android/src/picross/specific/ui/PicrossAndroidLogger.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/PicrossAndroidLogger.java 2013-01-11 09:43:57 UTC (rev 111) +++ branches/engine_split/android/src/picross/specific/ui/PicrossAndroidLogger.java 2013-01-11 14:36:50 UTC (rev 112) @@ -35,9 +35,9 @@ import android.util.Log; -import picross.engine.PicrossLogger; +import picross.engine.AbstractPicrossLogger; -public final class PicrossAndroidLogger implements PicrossLogger { +public final class PicrossAndroidLogger extends AbstractPicrossLogger { private static final String TAG = "PicrossAndroid"; public void debug(String msg) { Added: branches/engine_split/android/src/picross/specific/ui/PicrossButton.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/PicrossButton.java (rev 0) +++ branches/engine_split/android/src/picross/specific/ui/PicrossButton.java 2013-01-11 14:36:50 UTC (rev 112) @@ -0,0 +1,115 @@ +/* + * $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.specific.ui; + +import fr.cle.mmvcs.SimpleEvent; + +import android.graphics.Bitmap; + +public class PicrossButton { + private Bitmap icon; + private MenuController controller; + private String command; + private int x; + private int y; + private int width; + private int height; + + PicrossButton(Bitmap buttonIcon, MenuController buttonController, String cmd) { + this.icon = buttonIcon; + this.controller = buttonController; + this.command = cmd; + } + + public PicrossButton(int resID, SimpleEvent event) { + // FIXME + this.resID = resID; + this.event = event; + } + + private int resID; + private SimpleEvent event; + + public int getResID() { + return this.resID; + } + + public Bitmap getIcon() { + return this.icon; + } + + public void setIcon(Bitmap buttonIcon) { + this.icon = buttonIcon; + } + + public MenuController getController() { + return this.controller; + } + + public String getCommand() { + return this.command; + } + + public int getX() { + return this.x; + } + + public void setX(int xValue) { + this.x = xValue; + } + + public int getY() { + return this.y; + } + + public void setY(int yValue) { + this.y = yValue; + } + + public int getWidth() { + return this.width; + } + + public void setWidth(int w) { + this.width = w; + } + + public int getHeight() { + return this.height; + } + + public void setHeight(int h) { + this.height = h; + } +} Property changes on: branches/engine_split/android/src/picross/specific/ui/PicrossButton.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Modified: branches/engine_split/common/src/picross/common/ui/AbstractPicrossMediator.java =================================================================== --- branches/engine_split/common/src/picross/common/ui/AbstractPicrossMediator.java 2013-01-11 09:43:57 UTC (rev 111) +++ branches/engine_split/common/src/picross/common/ui/AbstractPicrossMediator.java 2013-01-11 14:36:50 UTC (rev 112) @@ -55,7 +55,7 @@ import picross.common.grid.ui.GridCommands; import picross.common.ui.PicrossController; import picross.common.ui.WaitMenuMediator; -import picross.common.ui.GameMenuMediator; +import picross.specific.ui.GameMenuMediator; import picross.common.ui.MenuCommand; import picross.specific.ui.MainMenuMediator; Deleted: branches/engine_split/common/src/picross/common/ui/GameMenuMediator.java =================================================================== --- branches/engine_split/common/src/picross/common/ui/GameMenuMediator.java 2013-01-11 09:43:57 UTC (rev 111) +++ branches/engine_split/common/src/picross/common/ui/GameMenuMediator.java 2013-01-11 14:36:50 UTC (rev 112) @@ -1,57 +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.common.ui; - -import picross.engine.PicrossException; - -import picross.specific.ui.GameMenuUI; -import picross.specific.ui.MenuController; -import picross.specific.ui.MenuUI; - -/** - * Mediator for the game menu. - * - * @author Y. Norsa - */ -public final class GameMenuMediator extends MenuMediator { - /*** Method overloaded from the class MenuMediator ***/ - - /** {@inheritDoc} */ - @Override - protected MenuUI initView(PicrossUI ui, MenuController controller) - throws PicrossException { - - return new GameMenuUI(controller, new GameMenuModel().getGameModes()); - } -} Modified: branches/engine_split/common/src/picross/common/ui/GameMenuModel.java =================================================================== --- branches/engine_split/common/src/picross/common/ui/GameMenuModel.java 2013-01-11 09:43:57 UTC (rev 111) +++ branches/engine_split/common/src/picross/common/ui/GameMenuModel.java 2013-01-11 14:36:50 UTC (rev 112) @@ -42,7 +42,7 @@ * * @author Y. Norsa */ -final class GameMenuModel { +public final class GameMenuModel { /*** Method ***/ /** @@ -50,7 +50,7 @@ * * @return list of <code>GameMode</code> instances */ - ServiceLoader<GameMode> getGameModes() { + public ServiceLoader<GameMode> getGameModes() { return ServiceLoader.load(GameMode.class); } } Added: branches/engine_split/common/src/picross/specific/ui/GameMenuMediator.java =================================================================== --- branches/engine_split/common/src/picross/specific/ui/GameMenuMediator.java (rev 0) +++ branches/engine_split/common/src/picross/specific/ui/GameMenuMediator.java 2013-01-11 14:36:50 UTC (rev 112) @@ -0,0 +1,47 @@ +/* + * $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.specific.ui; + +import picross.common.ui.MenuMediator; +import picross.common.ui.PicrossUI; + +import picross.engine.PicrossException; + +public class GameMenuMediator extends MenuMediator { + protected MenuUI initView(PicrossUI ui, MenuController controller) + throws PicrossException { + + return null; + } +} Property changes on: branches/engine_split/common/src/picross/specific/ui/GameMenuMediator.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/engine/src/picross/engine/AbstractPicrossLogger.java =================================================================== --- branches/engine_split/engine/src/picross/engine/AbstractPicrossLogger.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/AbstractPicrossLogger.java 2013-01-11 14:36:50 UTC (rev 112) @@ -0,0 +1,13 @@ +/* + * $Id$ + */ + + +package picross.engine; + +public abstract class AbstractPicrossLogger implements PicrossLogger { + @Override + public final void debug(Object msg) { + this.debug(msg.toString()); + } +} Property changes on: branches/engine_split/engine/src/picross/engine/AbstractPicrossLogger.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Modified: branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java =================================================================== --- branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java 2013-01-11 09:43:57 UTC (rev 111) +++ branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java 2013-01-11 14:36:50 UTC (rev 112) @@ -46,7 +46,7 @@ private PicrossLogHelper() { } - private static final class DefaultPicrossLogger implements PicrossLogger { + private static final class DefaultPicrossLogger extends AbstractPicrossLogger { @Override public void debug(String msg) { System.out.println("DEBUG " + msg); Modified: branches/engine_split/engine/src/picross/engine/PicrossLogger.java =================================================================== --- branches/engine_split/engine/src/picross/engine/PicrossLogger.java 2013-01-11 09:43:57 UTC (rev 111) +++ branches/engine_split/engine/src/picross/engine/PicrossLogger.java 2013-01-11 14:36:50 UTC (rev 112) @@ -35,6 +35,7 @@ public interface PicrossLogger { void debug(String msg); + void debug(Object msg); void info(String msg); void error(String msg); } Copied: branches/engine_split/swing/src/picross/specific/ui/GameMenuMediator.java (from rev 109, branches/engine_split/common/src/picross/common/ui/GameMenuMediator.java) =================================================================== --- branches/engine_split/swing/src/picross/specific/ui/GameMenuMediator.java (rev 0) +++ branches/engine_split/swing/src/picross/specific/ui/GameMenuMediator.java 2013-01-11 14:36:50 UTC (rev 112) @@ -0,0 +1,57 @@ +/* + * $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.specific.ui; + +import picross.engine.PicrossException; + +import picross.common.ui.MenuMediator; +import picross.common.ui.PicrossUI; +import picross.common.ui.GameMenuModel; + +/** + * Mediator for the game menu. + * + * @author Y. Norsa + */ +public final class GameMenuMediator extends MenuMediator { + /*** Method overloaded from the class MenuMediator ***/ + + /** {@inheritDoc} */ + @Override + protected MenuUI initView(PicrossUI ui, MenuController control... [truncated message content] |
From: <yva...@us...> - 2013-01-11 09:44:01
|
Revision: 111 http://sourceforge.net/p/picross/code/111 Author: yvan_norsa Date: 2013-01-11 09:43:57 +0000 (Fri, 11 Jan 2013) Log Message: ----------- cleaning Modified Paths: -------------- branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java branches/engine_split/android/src/picross/specific/activities/PicrossActivityUI.java branches/engine_split/android/src/picross/specific/ui/MenuUI.java branches/engine_split/android/src/picross/specific/ui/PicrossAndroidView.java branches/engine_split/android/src/picross/specific/ui/PicrossUIHelper.java Modified: branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java 2013-01-11 09:20:41 UTC (rev 110) +++ branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java 2013-01-11 09:43:57 UTC (rev 111) @@ -54,13 +54,10 @@ /** "Play" button Y coordinate. */ private static final int PLAY_BUTTON_Y = 225; - //private Context context; - public MainMenuActivityUI(Context androidContext) { super(androidContext); picross.engine.PicrossLogHelper.getLogger().debug("MainMenuActivityUI(" + androidContext + ")"); - //this.context = androidContext; } /** {@inheritDoc} */ Modified: branches/engine_split/android/src/picross/specific/activities/PicrossActivityUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/activities/PicrossActivityUI.java 2013-01-11 09:20:41 UTC (rev 110) +++ branches/engine_split/android/src/picross/specific/activities/PicrossActivityUI.java 2013-01-11 09:43:57 UTC (rev 111) @@ -47,7 +47,7 @@ * * @author Y. Norsa */ -public final class PicrossActivityUI /*extends android.view.View*/ implements PicrossUI { +public final class PicrossActivityUI implements PicrossUI { /*** Constants ***/ /** Main menu class. */ @@ -65,9 +65,6 @@ /** {@inheritDoc} */ @Override public void setContent(PicrossView content) { - //this.setContentPane((Container) content); - //this.pack(); - PicrossLogHelper.getLogger().debug("setContent(" + content + ")"); this.activity.setContentView((picross.specific.ui.PicrossAndroidView) content); } @@ -76,8 +73,6 @@ @Override public void displayMessage(String msg) { PicrossLogHelper.getLogger().debug("displayMessage(" + msg + ")"); - //JOptionPane.showMessageDialog(this, msg); - AlertDialog.Builder builder = new AlertDialog.Builder(this.activity); builder.setMessage(msg) .setTitle("Picross"); Modified: branches/engine_split/android/src/picross/specific/ui/MenuUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/MenuUI.java 2013-01-11 09:20:41 UTC (rev 110) +++ branches/engine_split/android/src/picross/specific/ui/MenuUI.java 2013-01-11 09:43:57 UTC (rev 111) @@ -43,8 +43,6 @@ import picross.engine.PicrossLogger; import picross.engine.PicrossLogHelper; -//import picross.specific.ui.PicrossUIHelper; - import picross.common.ui.MissingImageException; import android.view.SurfaceView; @@ -64,7 +62,7 @@ * * @author Y. Norsa */ -public abstract class MenuUI extends PicrossAndroidView implements SurfaceHolder.Callback, Runnable {//SurfaceView implements PicrossView { +public abstract class MenuUI extends PicrossAndroidView implements SurfaceHolder.Callback, Runnable { /*** Constants ***/ /** Background image. */ @@ -89,16 +87,13 @@ /** Background image. */ private Bitmap image; + protected Context context; + private SurfaceHolder surface; + /*** Constructor ***/ /** Constructor. */ - protected Context context; - private SurfaceHolder surface; - - - //private MenuUI thread; - public MenuUI(Context context) { super(context); @@ -125,87 +120,48 @@ Resources res = context.getResources(); - this.image = PicrossUIHelper.getImage(res, R.drawable.background);//BitmapFactory.decodeResource(res, - //R.drawable.earthrise); + this.image = PicrossUIHelper.getImage(res, R.drawable.background); MenuUI.log.debug("this.image: " + this.image); this.surface = this.getHolder(); this.surface.addCallback(this); - - //Thread thread = new Thread(this); - //thread.start(); - //this.start(); } - /*** Method overloaded from the class JPanel ***/ - - /** {@inheritDoc} */ - //FIXME - /* - protected final void paintComponent(Graphics g) { - super.paintComponent(g); - - g.drawImage(this.image, 0, 0, null); - } - */ - -@Override + @Override public void surfaceCreated(SurfaceHolder holder) { - MenuUI.log.debug("surfaceCreated()"); + MenuUI.log.debug("surfaceCreated()"); + this.setRunning(true); - //this.surface = holder; - - - /*thread*/this.setRunning(true); - /*thread*///this.start(); Thread thread = new Thread(this); thread.start(); + } -} + @Override + public void surfaceChanged(SurfaceHolder holder, int format, int width, + int height) { + MenuUI.log.debug("surfaceChanged"); + } -@Override -public void surfaceChanged(SurfaceHolder holder, int format, int width, - int height) { - MenuUI.log.debug("surfaceChanged"); - - //thread.setSurfaceSize(width, height); - -} private boolean running; private void setRunning(boolean run) { this.running = run; } -@Override - + @Override public void surfaceDestroyed(SurfaceHolder holder) { - MenuUI.log.debug("surfaceDestroyed"); + MenuUI.log.debug("surfaceDestroyed"); + boolean retry = true; + this.setRunning(false); + } - boolean retry = true; - /*thread*/this.setRunning(false); - /* - while (retry) { - try { - //thread.join(); - retry = false; - } catch (InterruptedException e) { - } - }*/ -} + @Override + public void run() { + MenuUI.log.debug("run()"); -@Override - public void run() { - MenuUI.log.debug("run()"); - - /* - if (!this.running) { - return; - } - */ Canvas c; while (this.running) { c = null; @@ -224,7 +180,6 @@ } } } - } public void onDraw(Canvas canvas) { @@ -235,14 +190,6 @@ } canvas.drawBitmap(this.image, 0, 0, null); - - /* - canvas.drawColor(Color.BLACK); - - Paint p = new Paint(); - p.setColor(Color.RED); - canvas.drawCircle(x, 10, 10, p); - x += 1;*/ } /*** Methods ***/ Modified: branches/engine_split/android/src/picross/specific/ui/PicrossAndroidView.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/PicrossAndroidView.java 2013-01-11 09:20:41 UTC (rev 110) +++ branches/engine_split/android/src/picross/specific/ui/PicrossAndroidView.java 2013-01-11 09:43:57 UTC (rev 111) @@ -7,20 +7,14 @@ import android.content.Context; -//import android.opengl.GLSurfaceView; import android.view.SurfaceView; import picross.common.ui.PicrossView; -public /*final */class PicrossAndroidView extends SurfaceView implements PicrossView { +public class PicrossAndroidView extends SurfaceView implements PicrossView { public PicrossAndroidView(Context context) { super(context); picross.engine.PicrossLogHelper.getLogger().debug("PicrossAndroidView(" + context + ")"); - - //this.setEGLContextClientVersion(2); - //this.setRenderer(new DroidRenderer()); - - //this.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); } } Modified: branches/engine_split/android/src/picross/specific/ui/PicrossUIHelper.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/PicrossUIHelper.java 2013-01-11 09:20:41 UTC (rev 110) +++ branches/engine_split/android/src/picross/specific/ui/PicrossUIHelper.java 2013-01-11 09:43:57 UTC (rev 111) @@ -85,14 +85,7 @@ * @throws MissingImageException if the image file can't be found */ private static Bitmap loadImage(String path) { - //try { - //return Picross.getFile(path); - //return Uri.parse(path); - return BitmapFactory.decodeFile(path); - /* - } catch (FileNotFoundException fileEx) { - throw new MissingImageException(fileEx); - }*/ + return BitmapFactory.decodeFile(path); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2013-01-11 09:20:46
|
Revision: 110 http://sourceforge.net/p/picross/code/110 Author: yvan_norsa Date: 2013-01-11 09:20:41 +0000 (Fri, 11 Jan 2013) Log Message: ----------- first android stuff Modified Paths: -------------- branches/engine_split/build.xml branches/engine_split/common/src/picross/specific/game/ui/GameMediator.java branches/engine_split/common/src/picross/specific/ui/MainMenuUI.java branches/engine_split/common/src/picross/specific/ui/MenuController.java branches/engine_split/common/src/picross/specific/ui/MenuUI.java branches/engine_split/src/picross/applet/MainMenuAppletUI.java branches/engine_split/swing/src/picross/specific/ui/MenuController.java branches/engine_split/swing/src/picross/specific/ui/MenuUI.java branches/engine_split/swing/src/picross/specific/ui/PicrossMediator.java Added Paths: ----------- branches/engine_split/android/ branches/engine_split/android/AndroidManifest.xml branches/engine_split/android/ant.properties branches/engine_split/android/assets/ branches/engine_split/android/build.xml branches/engine_split/android/libs/ branches/engine_split/android/libs/bundleHelper.jar branches/engine_split/android/libs/mmvcs.jar branches/engine_split/android/libs/picross-common.jar branches/engine_split/android/libs/picross-engine.jar branches/engine_split/android/libs/simpleButton.jar branches/engine_split/android/res/ branches/engine_split/android/res/drawable/ branches/engine_split/android/res/drawable/background.png branches/engine_split/android/res/drawable-hdpi/ branches/engine_split/android/res/drawable-hdpi/ic_launcher.png branches/engine_split/android/res/drawable-ldpi/ branches/engine_split/android/res/drawable-ldpi/ic_launcher.png branches/engine_split/android/res/drawable-mdpi/ branches/engine_split/android/res/drawable-mdpi/ic_launcher.png branches/engine_split/android/res/drawable-xhdpi/ branches/engine_split/android/res/drawable-xhdpi/ic_launcher.png branches/engine_split/android/res/layout/ branches/engine_split/android/res/layout/main.xml branches/engine_split/android/res/values/ branches/engine_split/android/res/values/strings.xml branches/engine_split/android/src/ branches/engine_split/android/src/picross/ branches/engine_split/android/src/picross/properties/ branches/engine_split/android/src/picross/properties/messages_picross.properties branches/engine_split/android/src/picross/properties/messages_picross_en.properties branches/engine_split/android/src/picross/properties/messages_picross_fr.properties branches/engine_split/android/src/picross/specific/ branches/engine_split/android/src/picross/specific/activities/ branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java branches/engine_split/android/src/picross/specific/activities/PicrossActivityUI.java branches/engine_split/android/src/picross/specific/activities/PicrossMainActivity.java branches/engine_split/android/src/picross/specific/game/ branches/engine_split/android/src/picross/specific/game/ui/ branches/engine_split/android/src/picross/specific/game/ui/GameMediator.java branches/engine_split/android/src/picross/specific/ui/ branches/engine_split/android/src/picross/specific/ui/MainMenuMediator.java branches/engine_split/android/src/picross/specific/ui/MainMenuUI.java branches/engine_split/android/src/picross/specific/ui/MenuController.java branches/engine_split/android/src/picross/specific/ui/MenuUI.java branches/engine_split/android/src/picross/specific/ui/PicrossAndroidLogger.java branches/engine_split/android/src/picross/specific/ui/PicrossAndroidView.java branches/engine_split/android/src/picross/specific/ui/PicrossMediator.java branches/engine_split/android/src/picross/specific/ui/PicrossUIHelper.java branches/engine_split/common/src/picross/common/ui/AbstractMenuController.java branches/engine_split/common/src/picross/common/ui/AbstractPicrossMediator.java branches/engine_split/common/src/picross/common/ui/MainMenuUI.java branches/engine_split/common/src/picross/specific/ui/MainMenuMediator.java branches/engine_split/src/picross/app/MainMenuAppUI.java branches/engine_split/swing/src/picross/specific/ui/MainMenuMediator.java Removed Paths: ------------- branches/engine_split/common/src/picross/common/ui/MainMenuMediator.java branches/engine_split/src/picross/app/MainMenuAppUI.java branches/engine_split/swing/src/picross/specific/ui/MainMenuUI.java Added: branches/engine_split/android/AndroidManifest.xml =================================================================== --- branches/engine_split/android/AndroidManifest.xml (rev 0) +++ branches/engine_split/android/AndroidManifest.xml 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="picross.specific.activities" + android:versionCode="1" + android:versionName="1.0"> + <application android:label="@string/app_name" android:icon="@drawable/ic_launcher"> + <activity android:name="PicrossMainActivity" + android:label="@string/app_name"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> +</manifest> Added: branches/engine_split/android/ant.properties =================================================================== --- branches/engine_split/android/ant.properties (rev 0) +++ branches/engine_split/android/ant.properties 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,17 @@ +# This file is used to override default values used by the Ant build system. +# +# This file must be checked into Version Control Systems, as it is +# integral to the build system of your project. + +# This file is only used by the Ant script. + +# You can use this to override default values such as +# 'source.dir' for the location of your java source folder and +# 'out.dir' for the location of your output folder. + +# You can also use it define how the release builds are signed by declaring +# the following properties: +# 'key.store' for the location of your keystore and +# 'key.alias' for the name of the key to use. +# The password will be asked during the build when you use the 'release' target. + Added: branches/engine_split/android/build.xml =================================================================== --- branches/engine_split/android/build.xml (rev 0) +++ branches/engine_split/android/build.xml 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project name="PicrossDroid" default="help"> + + <!-- The local.properties file is created and updated by the 'android' tool. + It contains the path to the SDK. It should *NOT* be checked into + Version Control Systems. --> + <property file="local.properties" /> + + <!-- The ant.properties file can be created by you. It is only edited by the + 'android' tool to add properties to it. + This is the place to change some Ant specific build properties. + Here are some properties you may want to change/update: + + source.dir + The name of the source directory. Default is 'src'. + out.dir + The name of the output directory. Default is 'bin'. + + For other overridable properties, look at the beginning of the rules + files in the SDK, at tools/ant/build.xml + + Properties related to the SDK location or the project target should + be updated using the 'android' tool with the 'update' action. + + This file is an integral part of the build system for your + application and should be checked into Version Control Systems. + + --> + <property file="ant.properties" /> + + <!-- if sdk.dir was not set from one of the property file, then + get it from the ANDROID_HOME env var. + This must be done before we load project.properties since + the proguard config can use sdk.dir --> + <property environment="env" /> + <condition property="sdk.dir" value="${env.ANDROID_HOME}"> + <isset property="env.ANDROID_HOME" /> + </condition> + + <!-- The project.properties file is created and updated by the 'android' + tool, as well as ADT. + + This contains project specific properties such as project target, and library + dependencies. Lower level build properties are stored in ant.properties + (or in .classpath for Eclipse projects). + + This file is an integral part of the build system for your + application and should be checked into Version Control Systems. --> + <loadproperties srcFile="project.properties" /> + + <!-- quick check on sdk.dir --> + <fail + message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable." + unless="sdk.dir" + /> + + <!-- + Import per project custom build rules if present at the root of the project. + This is the place to put custom intermediary targets such as: + -pre-build + -pre-compile + -post-compile (This is typically used for code obfuscation. + Compiled code location: ${out.classes.absolute.dir} + If this is not done in place, override ${out.dex.input.absolute.dir}) + -post-package + -post-build + -pre-clean + --> + <import file="custom_rules.xml" optional="true" /> + + <!-- Import the actual build file. + + To customize existing targets, there are two options: + - Customize only one target: + - copy/paste the target into this file, *before* the + <import> task. + - customize it to your needs. + - Customize the whole content of build.xml + - copy/paste the content of the rules files (minus the top node) + into this file, replacing the <import> task. + - customize to your needs. + + *********************** + ****** IMPORTANT ****** + *********************** + In all cases you must update the value of version-tag below to read 'custom' instead of an integer, + in order to avoid having your file be overridden by tools such as "android update project" + --> + <!-- version-tag: 1 --> + <import file="${sdk.dir}/tools/ant/build.xml" /> + +</project> Added: branches/engine_split/android/libs/bundleHelper.jar =================================================================== (Binary files differ) Index: branches/engine_split/android/libs/bundleHelper.jar =================================================================== --- branches/engine_split/android/libs/bundleHelper.jar 2013-01-10 12:27:19 UTC (rev 109) +++ branches/engine_split/android/libs/bundleHelper.jar 2013-01-11 09:20:41 UTC (rev 110) Property changes on: branches/engine_split/android/libs/bundleHelper.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/engine_split/android/libs/mmvcs.jar =================================================================== (Binary files differ) Index: branches/engine_split/android/libs/mmvcs.jar =================================================================== --- branches/engine_split/android/libs/mmvcs.jar 2013-01-10 12:27:19 UTC (rev 109) +++ branches/engine_split/android/libs/mmvcs.jar 2013-01-11 09:20:41 UTC (rev 110) Property changes on: branches/engine_split/android/libs/mmvcs.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/engine_split/android/libs/picross-common.jar =================================================================== (Binary files differ) Index: branches/engine_split/android/libs/picross-common.jar =================================================================== --- branches/engine_split/android/libs/picross-common.jar 2013-01-10 12:27:19 UTC (rev 109) +++ branches/engine_split/android/libs/picross-common.jar 2013-01-11 09:20:41 UTC (rev 110) Property changes on: branches/engine_split/android/libs/picross-common.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/engine_split/android/libs/picross-engine.jar =================================================================== (Binary files differ) Index: branches/engine_split/android/libs/picross-engine.jar =================================================================== --- branches/engine_split/android/libs/picross-engine.jar 2013-01-10 12:27:19 UTC (rev 109) +++ branches/engine_split/android/libs/picross-engine.jar 2013-01-11 09:20:41 UTC (rev 110) Property changes on: branches/engine_split/android/libs/picross-engine.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/engine_split/android/libs/simpleButton.jar =================================================================== (Binary files differ) Index: branches/engine_split/android/libs/simpleButton.jar =================================================================== --- branches/engine_split/android/libs/simpleButton.jar 2013-01-10 12:27:19 UTC (rev 109) +++ branches/engine_split/android/libs/simpleButton.jar 2013-01-11 09:20:41 UTC (rev 110) Property changes on: branches/engine_split/android/libs/simpleButton.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/engine_split/android/res/drawable/background.png =================================================================== (Binary files differ) Index: branches/engine_split/android/res/drawable/background.png =================================================================== --- branches/engine_split/android/res/drawable/background.png 2013-01-10 12:27:19 UTC (rev 109) +++ branches/engine_split/android/res/drawable/background.png 2013-01-11 09:20:41 UTC (rev 110) Property changes on: branches/engine_split/android/res/drawable/background.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/engine_split/android/res/drawable-hdpi/ic_launcher.png =================================================================== (Binary files differ) Index: branches/engine_split/android/res/drawable-hdpi/ic_launcher.png =================================================================== --- branches/engine_split/android/res/drawable-hdpi/ic_launcher.png 2013-01-10 12:27:19 UTC (rev 109) +++ branches/engine_split/android/res/drawable-hdpi/ic_launcher.png 2013-01-11 09:20:41 UTC (rev 110) Property changes on: branches/engine_split/android/res/drawable-hdpi/ic_launcher.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/engine_split/android/res/drawable-ldpi/ic_launcher.png =================================================================== (Binary files differ) Index: branches/engine_split/android/res/drawable-ldpi/ic_launcher.png =================================================================== --- branches/engine_split/android/res/drawable-ldpi/ic_launcher.png 2013-01-10 12:27:19 UTC (rev 109) +++ branches/engine_split/android/res/drawable-ldpi/ic_launcher.png 2013-01-11 09:20:41 UTC (rev 110) Property changes on: branches/engine_split/android/res/drawable-ldpi/ic_launcher.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/engine_split/android/res/drawable-mdpi/ic_launcher.png =================================================================== (Binary files differ) Index: branches/engine_split/android/res/drawable-mdpi/ic_launcher.png =================================================================== --- branches/engine_split/android/res/drawable-mdpi/ic_launcher.png 2013-01-10 12:27:19 UTC (rev 109) +++ branches/engine_split/android/res/drawable-mdpi/ic_launcher.png 2013-01-11 09:20:41 UTC (rev 110) Property changes on: branches/engine_split/android/res/drawable-mdpi/ic_launcher.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/engine_split/android/res/drawable-xhdpi/ic_launcher.png =================================================================== (Binary files differ) Index: branches/engine_split/android/res/drawable-xhdpi/ic_launcher.png =================================================================== --- branches/engine_split/android/res/drawable-xhdpi/ic_launcher.png 2013-01-10 12:27:19 UTC (rev 109) +++ branches/engine_split/android/res/drawable-xhdpi/ic_launcher.png 2013-01-11 09:20:41 UTC (rev 110) Property changes on: branches/engine_split/android/res/drawable-xhdpi/ic_launcher.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/engine_split/android/res/layout/main.xml =================================================================== --- branches/engine_split/android/res/layout/main.xml (rev 0) +++ branches/engine_split/android/res/layout/main.xml 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + > +<TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="Hello World, PicrossMainActivity" + /> +</LinearLayout> + Added: branches/engine_split/android/res/values/strings.xml =================================================================== --- branches/engine_split/android/res/values/strings.xml (rev 0) +++ branches/engine_split/android/res/values/strings.xml 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="app_name">PicrossMainActivity</string> +</resources> Added: branches/engine_split/android/src/picross/properties/messages_picross.properties =================================================================== --- branches/engine_split/android/src/picross/properties/messages_picross.properties (rev 0) +++ branches/engine_split/android/src/picross/properties/messages_picross.properties 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,9 @@ +# picross.PicrossMediator +victory = Congratulations ! + +# picross.game.GameUI +gridSize = Size +menuButton = Back to menu + +# picross.game.random.RandomGameUI +anotherGrid = Another grid Added: branches/engine_split/android/src/picross/properties/messages_picross_en.properties =================================================================== --- branches/engine_split/android/src/picross/properties/messages_picross_en.properties (rev 0) +++ branches/engine_split/android/src/picross/properties/messages_picross_en.properties 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1 @@ +link messages_picross.properties \ No newline at end of file Property changes on: branches/engine_split/android/src/picross/properties/messages_picross_en.properties ___________________________________________________________________ Added: svn:special ## -0,0 +1 ## +* \ No newline at end of property Added: branches/engine_split/android/src/picross/properties/messages_picross_fr.properties =================================================================== --- branches/engine_split/android/src/picross/properties/messages_picross_fr.properties (rev 0) +++ branches/engine_split/android/src/picross/properties/messages_picross_fr.properties 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,10 @@ +# picross.PicrossMediator +victory = F\xE9licitations ! + +# picross.game.GameUI +gridSize = Taille +menuButton = Retour au menu + +# picross.game.random.RandomGameUI +anotherGrid = Une autre grille + Added: branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java (rev 0) +++ branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,79 @@ +/* + * $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.specific.activities; + +import picross.specific.ui.MainMenuUI; + +import android.content.Context; + +/** + * UI for the main menu. + * + * @author Y. Norsa + */ +public final class MainMenuActivityUI extends MainMenuUI { + /*** Constants ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = -505088917693050187L; + + /** "Play" button X coordinate. */ + private static final int PLAY_BUTTON_X = 50; + + /** "Play" button Y coordinate. */ + private static final int PLAY_BUTTON_Y = 225; + + //private Context context; + + public MainMenuActivityUI(Context androidContext) { + super(androidContext); + + picross.engine.PicrossLogHelper.getLogger().debug("MainMenuActivityUI(" + androidContext + ")"); + //this.context = androidContext; + } + + /** {@inheritDoc} */ + @Override + protected int getPlayButtonX() { + return MainMenuActivityUI.PLAY_BUTTON_X; + } + + /** {@inheritDoc} */ + @Override + protected int getPlayButtonY() { + return MainMenuActivityUI.PLAY_BUTTON_Y; + } + +} + Property changes on: branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/activities/PicrossActivityUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/activities/PicrossActivityUI.java (rev 0) +++ branches/engine_split/android/src/picross/specific/activities/PicrossActivityUI.java 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,117 @@ +/* + * $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.specific.activities; + +import picross.engine.PicrossLogHelper; + +import android.app.Activity; + +import android.app.AlertDialog; + +import picross.common.ui.PicrossUI; +import picross.common.ui.PicrossView; + +/** + * Main window of the application version. + * + * @author Y. Norsa + */ +public final class PicrossActivityUI /*extends android.view.View*/ implements PicrossUI { + /*** Constants ***/ + + /** Main menu class. */ + private static final String MAIN_MENU_CLASS = "picross.specific.activities.MainMenuActivityUI"; + + private Activity activity; + + PicrossActivityUI(Activity picrossActivity) { + PicrossLogHelper.getLogger().debug("PicrossActivityUI(" + picrossActivity + ")"); + this.activity = picrossActivity; + } + + /*** Methods implanted from the interface PicrossUI ***/ + + /** {@inheritDoc} */ + @Override + public void setContent(PicrossView content) { + //this.setContentPane((Container) content); + //this.pack(); + + PicrossLogHelper.getLogger().debug("setContent(" + content + ")"); + this.activity.setContentView((picross.specific.ui.PicrossAndroidView) content); + } + + /** {@inheritDoc} */ + @Override + public void displayMessage(String msg) { + PicrossLogHelper.getLogger().debug("displayMessage(" + msg + ")"); + //JOptionPane.showMessageDialog(this, msg); + + AlertDialog.Builder builder = new AlertDialog.Builder(this.activity); + builder.setMessage(msg) + .setTitle("Picross"); + AlertDialog dialog = builder.create(); + } + + /** {@inheritDoc} */ + @Override + public void displayError(String msg) { + /* + JOptionPane.showMessageDialog(this, msg, + "Picross", JOptionPane.ERROR_MESSAGE); + */ + // FIXME error style ? + this.displayMessage("ERROR: " + msg); + } + + /** {@inheritDoc} */ + @Override + public void showUI() { + PicrossLogHelper.getLogger().debug("TODO showUI()"); + //this.setVisible(true); + } + + /** {@inheritDoc} */ + @Override + public void exit() { + //this.dispose(); + } + + /** {@inheritDoc} */ + @Override + public String getMainMenuClass() { + return PicrossActivityUI.MAIN_MENU_CLASS; + } +} + Property changes on: branches/engine_split/android/src/picross/specific/activities/PicrossActivityUI.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/activities/PicrossMainActivity.java =================================================================== --- branches/engine_split/android/src/picross/specific/activities/PicrossMainActivity.java (rev 0) +++ branches/engine_split/android/src/picross/specific/activities/PicrossMainActivity.java 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,54 @@ +/* + * $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.specific.activities; + +import android.app.Activity; + +import android.os.Bundle; + +import picross.specific.ui.PicrossMediator; +import picross.specific.ui.PicrossAndroidLogger; +import picross.engine.PicrossLogHelper; + +public class PicrossMainActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + PicrossLogHelper.setLogger(new PicrossAndroidLogger()); + PicrossLogHelper.getLogger().debug("TEST ##################"); + + new PicrossMediator(this, new PicrossActivityUI(this)); + } +} Property changes on: branches/engine_split/android/src/picross/specific/activities/PicrossMainActivity.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/game/ui/GameMediator.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/ui/GameMediator.java (rev 0) +++ branches/engine_split/android/src/picross/specific/game/ui/GameMediator.java 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,146 @@ +/* + * $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.specific.game.ui; + +import fr.cle.mmvcs.Mediateur; +import fr.cle.mmvcs.SimpleEvent; + +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; +import picross.engine.PicrossException; + +import picross.engine.grid.PicrossGrid; + +//import picross.specific.grid.ui.GridMediator; +import picross.common.grid.ui.GridView; +import picross.common.grid.ui.IGridMediator; + +import picross.common.game.ui.GameView; + +public abstract class GameMediator extends Mediateur { + /*** Static field ***/ + + /** The class' logger. */ + private static PicrossLogger log = PicrossLogHelper.getLogger(); + + /*** 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()); + */ + // FIXME + //this.grid.addSimpleListener(this); + + //final GameController controller = this.initController(); + // FIXME + //controller.addSimpleListener(this); + + // The view has to be init'ed on the EDT + //this.view = this.initView(width, height, 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; + }*/ + } Property changes on: branches/engine_split/android/src/picross/specific/game/ui/GameMediator.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/ui/MainMenuMediator.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/MainMenuMediator.java (rev 0) +++ branches/engine_split/android/src/picross/specific/ui/MainMenuMediator.java 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,96 @@ +/* + * $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.specific.ui; + +import java.lang.reflect.InvocationTargetException; + +import picross.engine.PicrossException; + +import picross.common.ui.MenuMediator; +import picross.common.ui.PicrossUI; +import picross.specific.ui.MainMenuUI; + +import android.content.Context; + +/** + * Mediator for the main menu. + * + * @author Y. Norsa + */ +public final class MainMenuMediator extends MenuMediator { + private Context context; + + public MainMenuMediator(Context androidContext) { + picross.engine.PicrossLogHelper.getLogger().debug("MainMenuMediator(" + androidContext + ")"); + + if (androidContext == null) { + throw new IllegalArgumentException("\"androidContext\" cannot be null"); + } + + this.context = androidContext; + } + + /*** Method overloaded from the class MenuMediator ***/ + + /** {@inheritDoc} */ + @Override + protected MenuUI initView(PicrossUI ui, MenuController controller) + throws PicrossException { + + picross.engine.PicrossLogHelper.getLogger().debug("initView(" + ui + ", " + controller + ")"); + + MainMenuUI view = null; + + try { + view = (MainMenuUI) Class.forName(ui.getMainMenuClass()) + .getConstructor(Context.class).newInstance(this.context); + } catch (ClassNotFoundException classEx) { + throw new PicrossException(classEx); + } 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 new PicrossException(targetEx.getCause()); + } + + view.init(controller); + + return view; + } +} + Property changes on: branches/engine_split/android/src/picross/specific/ui/MainMenuMediator.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/ui/MainMenuUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/MainMenuUI.java (rev 0) +++ branches/engine_split/android/src/picross/specific/ui/MainMenuUI.java 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,90 @@ +/* + * $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.specific.ui; + +import picross.common.ui.PicrossController; + +import picross.specific.ui.MenuController; +import picross.specific.ui.MenuUI; + +import android.content.Context; + +/** + * UI for the main menu. + * + * @author Y. Norsa + */ +public abstract class MainMenuUI extends MenuUI { + /*** Constants ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = -505088917693050187L; + + /** Image for the "play" button. */ + private static final String PLAY_BUTTON_IMAGE = "button-play.png"; + + public MainMenuUI(Context androidContext) { + super(androidContext); + } + + /*** Abstract methods ***/ + + /** + * Returns the "play" button X position. + * + * @return X position of the "play" button + */ + protected abstract int getPlayButtonX(); + + /** + * Returns the "play" button Y position. + * + * @return Y position of the "play" button + */ + protected abstract int getPlayButtonY(); + + /*** Method ***/ + + /** + * Initialises the menu. + * + * @param controller controller for the menu's buttons + */ + public void init(MenuController controller) { + this.addButton(MainMenuUI.PLAY_BUTTON_IMAGE, + PicrossController.PLAY_CMD, controller, + this.getPlayButtonX(), this.getPlayButtonY()); + } +} + Property changes on: branches/engine_split/android/src/picross/specific/ui/MainMenuUI.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/ui/MenuController.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/MenuController.java (rev 0) +++ branches/engine_split/android/src/picross/specific/ui/MenuController.java 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,62 @@ +/* + * $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.specific.ui; + +import fr.cle.mmvcs.Controller; +import fr.cle.mmvcs.SimpleEvent; + +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; + +import picross.common.ui.AbstractMenuController; + +/** + * Generic controller for the menus. + * + * @author Y. Norsa + */ +public class MenuController extends AbstractMenuController /*implements ActionListener*/ { + /*** Method implanted from the interface ActionListener ***/ + + /** {@inheritDoc} */ + + // FIXME + /* + @Override + public void actionPerformed(ActionEvent e) { + String cmd = e.getActionCommand(); + this.fireEventPerformed(cmd); + }*/ +} + Property changes on: branches/engine_split/android/src/picross/specific/ui/MenuController.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/ui/MenuUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/MenuUI.java (rev 0) +++ branches/engine_split/android/src/picross/specific/ui/MenuUI.java 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,376 @@ +/* + * $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.specific.ui; + +import fr.cle.core.gui.SimpleButton; + +import fr.cle.mmvcs.SimpleEvent; +import fr.cle.mmvcs.SimpleListener; + +import picross.common.ui.PicrossView; + +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; + +//import picross.specific.ui.PicrossUIHelper; + +import picross.common.ui.MissingImageException; + +import android.view.SurfaceView; +import android.net.Uri; +import java.io.File; +import android.content.Context; + +import android.graphics.Bitmap; + +import picross.specific.activities.R; +import android.content.res.Resources; +import android.graphics.Canvas; +import android.view.SurfaceHolder; + +/** + * Base class for menus. + * + * @author Y. Norsa + */ +public abstract class MenuUI extends PicrossAndroidView implements SurfaceHolder.Callback, Runnable {//SurfaceView implements PicrossView { + /*** 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; + + /** Size for buttons' text. */ + private static final float BUTTON_TEXT_SIZE = 16; + + /*** Static field ***/ + + /** This class' logger. */ + private static PicrossLogger log = PicrossLogHelper.getLogger(); + + /*** Field ***/ + + /** Background image. */ + private Bitmap image; + + /*** Constructor ***/ + + /** Constructor. */ + + protected Context context; + private SurfaceHolder surface; + + + //private MenuUI thread; + + public MenuUI(Context context) { + super(context); + + MenuUI.log.debug("MenuUI(" + context + ")"); + + this.context = context; + + // FIXME + /* + try { + ImageIcon icon = PicrossUIHelper.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); + */ + + + Resources res = context.getResources(); + + this.image = PicrossUIHelper.getImage(res, R.drawable.background);//BitmapFactory.decodeResource(res, + //R.drawable.earthrise); + + MenuUI.log.debug("this.image: " + this.image); + + this.surface = this.getHolder(); + this.surface.addCallback(this); + + //Thread thread = new Thread(this); + //thread.start(); + //this.start(); + } + + + /*** Method overloaded from the class JPanel ***/ + + /** {@inheritDoc} */ + //FIXME + /* + protected final void paintComponent(Graphics g) { + super.paintComponent(g); + + g.drawImage(this.image, 0, 0, null); + } + */ + +@Override + public void surfaceCreated(SurfaceHolder holder) { + MenuUI.log.debug("surfaceCreated()"); + + //this.surface = holder; + + + /*thread*/this.setRunning(true); + /*thread*///this.start(); + Thread thread = new Thread(this); + thread.start(); + +} + +@Override +public void surfaceChanged(SurfaceHolder holder, int format, int width, + int height) { + MenuUI.log.debug("surfaceChanged"); + + //thread.setSurfaceSize(width, height); + +} + private boolean running; + + private void setRunning(boolean run) { + this.running = run; + } + +@Override + + public void surfaceDestroyed(SurfaceHolder holder) { + MenuUI.log.debug("surfaceDestroyed"); + + + boolean retry = true; + /*thread*/this.setRunning(false); + /* + while (retry) { + try { + //thread.join(); + retry = false; + } catch (InterruptedException e) { + } + }*/ +} + +@Override + public void run() { + MenuUI.log.debug("run()"); + + /* + if (!this.running) { + return; + } + */ + Canvas c; + while (this.running) { + c = null; + try { + c = surface.lockCanvas(null); + synchronized (surface) { + onDraw(c); + + } + } finally { + // do this in a finally so that if an exception is thrown + // during the above, we don't leave the Surface in an + // inconsistent state + if (c != null) { + surface.unlockCanvasAndPost(c); + } + } + } + + } + + public void onDraw(Canvas canvas) { + MenuUI.log.debug("onDraw(" + canvas + ")"); + + if (canvas == null) { + return; + } + + canvas.drawBitmap(this.image, 0, 0, null); + + /* + canvas.drawColor(Color.BLACK); + + Paint p = new Paint(); + p.setColor(Color.RED); + canvas.drawCircle(x, 10, 10, p); + x += 1;*/ + } + + /*** Methods ***/ + + /** + * 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 coordinate for the button + * @param y Y coordinate for the button + * @throws MissingImageException if a button image can't be found + */ + + protected final void addButton(String image, String command, + MenuController controller, int x, int y) { + /* + ImageIcon buttonIcon = PicrossUIHelper.getLocalizedImage(image); + JButton button = new JButton(buttonIcon); + button.setActionCommand(command); + button.addActionListener(controller); + button.setBorder(null); + + this.putButton(button, x, y, + buttonIcon.getIconWidth(), buttonIcon.getIconHeight()); + */ + } + + + /** + * Helper method to add a button to the menu. + * + * @param label the button's label + * @param event the event linked to the button + * @param listener listener for the button + * @param x X coordinate for the button + * @param y Y coordinate for the button + */ + protected final void addSimpleButton(String label, SimpleEvent event, + SimpleListener listener, + int x, int y) { + // FIXME + /* + PicrossButton button = + this.createSimpleButton(label, event, listener); + this.putButton(button.getButton(), x, y, 150, 50); + */ + } + + /** + * Helper method to create a button. + * + * @param label the button's label + * @param event the event linked to the button + * @param listener listener for the button + * @return the created button + */ + // FIXME + /* + protected final PicrossButton createSimpleButton(String label, + SimpleEvent event, + SimpleListener listener) { + PicrossButton button = + new PicrossButton(label, + PicrossUIHelper.getImage("empty-button.png"), + event); + button.addSimpleListener(listener); + + JButton realButton = button.getButton(); + + realButton.setHorizontalTextPosition(JButton.CENTER); + realButton.setVerticalTextPosition(JButton.CENTER); + + realButton.setFont(realButton.getFont() + .deriveFont(MenuUI.BUTTON_TEXT_SIZE)); + realButton.setForeground(Color.WHITE); + + Dimension dim = new Dimension(150, 50); + realButton.setMinimumSize(dim); + realButton.setMaximumSize(dim); + realButton.setPreferredSize(dim); + + return button; + + } + */ + /** + * Helper method to add a button. + * + * @param button the button to add + * @param listener listener for the button + * @param x X ccordinate for the button + * @param y Y coordinate for the button + */ + // FIXME + + /* + protected final void addButton(SimpleButton<JButton> button, + SimpleListener listener, + int x, int y) { + + button.addSimpleListener(listener); + + JButton realButton = button.getButton(); + Icon icon = realButton.getIcon(); + + realButton.setBorder(null); + this.putButton(realButton, x, y, + icon.getIconWidth(), icon.getIconHeight()); + } + */ + + /** + * Finalizes the button's setup. + * + * @param button the button to add + * @param x X coordinate for the button + * @param y Y coordinate for the button + * @param width the button's width + * @param height the button's height + */ + // FIXME + /* + private void putButton(JButton button, int x, int y, + int width, int height) { + button.setBounds(x, y, width, height); + this.add(button); + } + */ +} Property changes on: branches/engine_split/android/src/picross/specific/ui/MenuUI.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/ui/PicrossAndroidLogger.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/PicrossAndroidLogger.java (rev 0) +++ branches/engine_split/android/src/picross/specific/ui/PicrossAndroidLogger.java 2013-01-11 09:20:41 UTC (rev 110) @@ -0,0 +1,54 @@ +/* + * $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 + * e... [truncated message content] |
From: <yva...@us...> - 2013-01-10 12:27:23
|
Revision: 109 http://sourceforge.net/p/picross/code/109 Author: yvan_norsa Date: 2013-01-10 12:27:19 +0000 (Thu, 10 Jan 2013) Log Message: ----------- cleaning Modified Paths: -------------- branches/engine_split/build.xml Removed Paths: ------------- branches/engine_split/common/src/picross/specific/grid/ Modified: branches/engine_split/build.xml =================================================================== --- branches/engine_split/build.xml 2013-01-10 12:14:00 UTC (rev 108) +++ branches/engine_split/build.xml 2013-01-10 12:27:19 UTC (rev 109) @@ -31,8 +31,6 @@ value="common/test" /> <property name="swing.test.dir" value="swing/test" /> - <property name="game.test.dir" - value="test" /> <property name="swing.jar.name" value="${dist.dir}/${ant.project.name}-swing.jar" /> @@ -129,7 +127,7 @@ </target> <target name="common-compile" - depends="-init"> + depends="-init,engine-dist"> <javac srcdir="${common.src.dir}" destdir="${common.build.dir}" deprecation="on" @@ -204,19 +202,6 @@ </javac> </target> - <target name="game-compile-test" - depends="game-compile"> - <javac srcdir="${game.test.dir}" - destdir="${game.build.dir}" - deprecation="on" - debug="on" - optimize="off"> - <compilerarg value="-Xlint:all" /> - - <classpath refid="classpath" /> - </javac> - </target> - <target name="engine-dist" depends="engine-compile"> <jar destfile="${engine.jar.name}" @@ -299,7 +284,7 @@ </target> <target name="test" - depends="engine-test,common-test,swing-test,game-test" /> + depends="engine-test,common-test,swing-test" /> <target name="engine-test" depends="dist,engine-compile-test"> @@ -361,26 +346,6 @@ </junit> </target> - <target name="game-test" - depends="dist,game-compile-test"> - <junit filtertrace="off" - showoutput="on" - printsummary="withOutAndErr"> - <formatter type="plain" - usefile="false" /> - - <batchtest fork="yes" - filtertrace="on"> - <fileset dir="${game.test.dir}"> - <include name="**/*Test.java" /> - <exclude name="**/Abstract*Test.java" /> - </fileset> - </batchtest> - - <classpath refid="classpath" /> - </junit> - </target> - <target name="clean"> <delete dir="${swing.build.dir}" /> <delete dir="${common.build.dir}" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2013-01-10 12:14:04
|
Revision: 108 http://sourceforge.net/p/picross/code/108 Author: yvan_norsa Date: 2013-01-10 12:14:00 +0000 (Thu, 10 Jan 2013) Log Message: ----------- moved tests Removed Paths: ------------- branches/engine_split/test/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2013-01-10 12:13:23
|
Revision: 107 http://sourceforge.net/p/picross/code/107 Author: yvan_norsa Date: 2013-01-10 12:13:19 +0000 (Thu, 10 Jan 2013) Log Message: ----------- moved tests Modified Paths: -------------- branches/engine_split/build.xml branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java branches/engine_split/common/src/picross/common/game/simple/ui/SimpleGameMediator.java branches/engine_split/engine/test/picross/engine/game/simple/XBMModelTest.java branches/engine_split/swing/src/picross/specific/grid/ui/UIBox.java branches/engine_split/swing/src/picross/specific/ui/PicrossUIHelper.java branches/engine_split/swing/test/picross/specific/grid/ui/IGridMediatorStub.java branches/engine_split/swing/test/picross/specific/grid/ui/UIBoxTest.java branches/engine_split/swing/test/picross/specific/ui/PicrossUIHelperTest.java Added Paths: ----------- branches/engine_split/common/test/ branches/engine_split/common/test/picross/ branches/engine_split/common/test/picross/common/ branches/engine_split/common/test/picross/common/grid/ branches/engine_split/common/test/picross/common/grid/ui/ branches/engine_split/common/test/picross/common/grid/ui/FillCommandTest.java branches/engine_split/common/test/picross/common/grid/ui/PaintCommandTest.java branches/engine_split/engine/src/picross/engine/Picross.java branches/engine_split/engine/test/picross/engine/PicrossTest.java branches/engine_split/swing/test/ branches/engine_split/swing/test/picross/ branches/engine_split/swing/test/picross/specific/ branches/engine_split/swing/test/picross/specific/grid/ branches/engine_split/swing/test/picross/specific/ui/ Removed Paths: ------------- branches/engine_split/common/src/picross/common/Picross.java branches/engine_split/swing/test/picross/specific/grid/ui/FillCommandTest.java branches/engine_split/swing/test/picross/specific/grid/ui/PaintCommandTest.java branches/engine_split/test/picross/PicrossTest.java branches/engine_split/test/picross/grid/ branches/engine_split/test/picross/ui/ Modified: branches/engine_split/build.xml =================================================================== --- branches/engine_split/build.xml 2013-01-10 11:57:14 UTC (rev 106) +++ branches/engine_split/build.xml 2013-01-10 12:13:19 UTC (rev 107) @@ -27,6 +27,10 @@ value="src" /> <property name="engine.test.dir" value="engine/test" /> + <property name="common.test.dir" + value="common/test" /> + <property name="swing.test.dir" + value="swing/test" /> <property name="game.test.dir" value="test" /> @@ -174,6 +178,32 @@ </javac> </target> + <target name="common-compile-test" + depends="common-compile"> + <javac srcdir="${common.test.dir}" + destdir="${common.build.dir}" + deprecation="on" + debug="on" + optimize="off"> + <compilerarg value="-Xlint:all" /> + + <classpath refid="classpath" /> + </javac> + </target> + + <target name="swing-compile-test" + depends="swing-compile"> + <javac srcdir="${swing.test.dir}" + destdir="${swing.build.dir}" + deprecation="on" + debug="on" + optimize="off"> + <compilerarg value="-Xlint:all" /> + + <classpath refid="classpath" /> + </javac> + </target> + <target name="game-compile-test" depends="game-compile"> <javac srcdir="${game.test.dir}" @@ -269,7 +299,7 @@ </target> <target name="test" - depends="engine-test,game-test" /> + depends="engine-test,common-test,swing-test,game-test" /> <target name="engine-test" depends="dist,engine-compile-test"> @@ -291,6 +321,46 @@ </junit> </target> + <target name="common-test" + depends="dist,common-compile-test"> + <junit filtertrace="off" + showoutput="on" + printsummary="withOutAndErr"> + <formatter type="plain" + usefile="false" /> + + <batchtest fork="yes" + filtertrace="on"> + <fileset dir="${common.test.dir}"> + <include name="**/*Test.java" /> + <exclude name="**/Abstract*Test.java" /> + </fileset> + </batchtest> + + <classpath refid="classpath" /> + </junit> + </target> + + <target name="swing-test" + depends="dist,swing-compile-test"> + <junit filtertrace="off" + showoutput="on" + printsummary="withOutAndErr"> + <formatter type="plain" + usefile="false" /> + + <batchtest fork="yes" + filtertrace="on"> + <fileset dir="${swing.test.dir}"> + <include name="**/*Test.java" /> + <exclude name="**/Abstract*Test.java" /> + </fileset> + </batchtest> + + <classpath refid="classpath" /> + </junit> + </target> + <target name="game-test" depends="dist,game-compile-test"> <junit filtertrace="off" Deleted: branches/engine_split/common/src/picross/common/Picross.java =================================================================== --- branches/engine_split/common/src/picross/common/Picross.java 2013-01-10 11:57:14 UTC (rev 106) +++ branches/engine_split/common/src/picross/common/Picross.java 2013-01-10 12:13:19 UTC (rev 107) @@ -1,95 +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.common; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; - -import java.net.URL; - -/** - * Helper class. - * - * @author Y. Norsa - */ -public final class Picross { - /*** Constant ***/ - - /** Data directory. */ - private static final String DATA_DIR = "/picross/data/"; - - /*** Constructor ***/ - - /** Fake constructor. */ - private Picross() { } - - /*** Static methods ***/ - - /** - * Loads a file. - * - * @param path file path - * @return URL of the file - * @throws FileNotFoundException if the file can't be found - */ - public static URL getFile(String path) throws FileNotFoundException { - URL fileUrl = Picross.class.getResource(path); - - if (fileUrl == null) { - throw new FileNotFoundException("\"" + path + "\" can't be found"); - } - - return fileUrl; - } - - /** - * Loads a data file. - * - * @param name filename - * @return a stream containing the loaded file - * @throws IllegalArgumentException if <code>name</code> - * is <code>null</code> or empty - * @throws IOException if there is a problem while opening the file - */ - public static InputStream loadDataFile(String name) throws IOException { - - if (name == null || name.equals("")) { - throw new IllegalArgumentException("name can't be null or empty"); - } - - return Picross.getFile(Picross.DATA_DIR + name).openStream(); - } -} - Modified: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java 2013-01-10 11:57:14 UTC (rev 106) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java 2013-01-10 12:13:19 UTC (rev 107) @@ -42,7 +42,7 @@ import java.util.List; import java.util.Map; -import picross.common.Picross; +import picross.engine.Picross; import picross.engine.PicrossException; import picross.engine.game.simple.Dimensions; Modified: branches/engine_split/common/src/picross/common/game/simple/ui/SimpleGameMediator.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/SimpleGameMediator.java 2013-01-10 11:57:14 UTC (rev 106) +++ branches/engine_split/common/src/picross/common/game/simple/ui/SimpleGameMediator.java 2013-01-10 12:13:19 UTC (rev 107) @@ -35,7 +35,7 @@ import java.io.IOException; -import picross.common.Picross; +import picross.engine.Picross; import picross.engine.PicrossException; import picross.engine.game.simple.XBMModel; Copied: branches/engine_split/common/test/picross/common/grid/ui/FillCommandTest.java (from rev 106, branches/engine_split/test/picross/grid/ui/FillCommandTest.java) =================================================================== --- branches/engine_split/common/test/picross/common/grid/ui/FillCommandTest.java (rev 0) +++ branches/engine_split/common/test/picross/common/grid/ui/FillCommandTest.java 2013-01-10 12:13:19 UTC (rev 107) @@ -0,0 +1,65 @@ +/* + * $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.common.grid.ui; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class FillCommandTest { + @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); + */ + } + +} + Copied: branches/engine_split/common/test/picross/common/grid/ui/PaintCommandTest.java (from rev 106, branches/engine_split/test/picross/grid/ui/PaintCommandTest.java) =================================================================== --- branches/engine_split/common/test/picross/common/grid/ui/PaintCommandTest.java (rev 0) +++ branches/engine_split/common/test/picross/common/grid/ui/PaintCommandTest.java 2013-01-10 12:13:19 UTC (rev 107) @@ -0,0 +1,58 @@ +/* + * $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.common.grid.ui; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class PaintCommandTest { + @Test(expected = IllegalArgumentException.class) + public void paintCommandWithInvalidRow() { + new PaintCommand(-1, 0); + } + + @Test(expected = IllegalArgumentException.class) + public void paintCommandWithInvalidCol() { + new PaintCommand(0, -1); + } + + @Test + public void testPaintCommand() { + new PaintCommand(0, 0); + } +} + Copied: branches/engine_split/engine/src/picross/engine/Picross.java (from rev 106, branches/engine_split/common/src/picross/common/Picross.java) =================================================================== --- branches/engine_split/engine/src/picross/engine/Picross.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/Picross.java 2013-01-10 12:13:19 UTC (rev 107) @@ -0,0 +1,95 @@ +/* + * $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.engine; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import java.net.URL; + +/** + * Helper class. + * + * @author Y. Norsa + */ +public final class Picross { + /*** Constant ***/ + + /** Data directory. */ + private static final String DATA_DIR = "/picross/data/"; + + /*** Constructor ***/ + + /** Fake constructor. */ + private Picross() { } + + /*** Static methods ***/ + + /** + * Loads a file. + * + * @param path file path + * @return URL of the file + * @throws FileNotFoundException if the file can't be found + */ + public static URL getFile(String path) throws FileNotFoundException { + URL fileUrl = Picross.class.getResource(path); + + if (fileUrl == null) { + throw new FileNotFoundException("\"" + path + "\" can't be found"); + } + + return fileUrl; + } + + /** + * Loads a data file. + * + * @param name filename + * @return a stream containing the loaded file + * @throws IllegalArgumentException if <code>name</code> + * is <code>null</code> or empty + * @throws IOException if there is a problem while opening the file + */ + public static InputStream loadDataFile(String name) throws IOException { + + if (name == null || name.equals("")) { + throw new IllegalArgumentException("name can't be null or empty"); + } + + return Picross.getFile(Picross.DATA_DIR + name).openStream(); + } +} + Copied: branches/engine_split/engine/test/picross/engine/PicrossTest.java (from rev 106, branches/engine_split/test/picross/PicrossTest.java) =================================================================== --- branches/engine_split/engine/test/picross/engine/PicrossTest.java (rev 0) +++ branches/engine_split/engine/test/picross/engine/PicrossTest.java 2013-01-10 12:13:19 UTC (rev 107) @@ -0,0 +1,72 @@ +/* + * $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.engine; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Tests for the static methods of the Picross class. + * + * @author Y. Norsa + */ +public class PicrossTest { + /*** Methods ***/ + + @Test(expected = IllegalArgumentException.class) + public void loadNullFile() throws IOException { + Picross.loadDataFile(null); + } + + @Test(expected = IllegalArgumentException.class) + public void loadEmptyNamedFile() throws IOException { + Picross.loadDataFile(""); + } + + @Test(expected = FileNotFoundException.class) + public void loadMissingFile() throws IOException { + Picross.loadDataFile("fakeFile"); + } + + @Test + public void loadDataFile() throws IOException { + InputStream in = Picross.loadDataFile("asterix.xbm"); + Assert.assertNotNull("in = null", in); + in.close(); + } +} Modified: branches/engine_split/engine/test/picross/engine/game/simple/XBMModelTest.java =================================================================== --- branches/engine_split/engine/test/picross/engine/game/simple/XBMModelTest.java 2013-01-10 11:57:14 UTC (rev 106) +++ branches/engine_split/engine/test/picross/engine/game/simple/XBMModelTest.java 2013-01-10 12:13:19 UTC (rev 107) @@ -42,7 +42,7 @@ import org.junit.Assert; import org.junit.Test; -import picross.Picross; +import picross.engine.Picross; import picross.engine.PicrossException; Modified: branches/engine_split/swing/src/picross/specific/grid/ui/UIBox.java =================================================================== --- branches/engine_split/swing/src/picross/specific/grid/ui/UIBox.java 2013-01-10 11:57:14 UTC (rev 106) +++ branches/engine_split/swing/src/picross/specific/grid/ui/UIBox.java 2013-01-10 12:13:19 UTC (rev 107) @@ -41,7 +41,7 @@ import javax.swing.ImageIcon; -import picross.common.Picross; +import picross.engine.Picross; import picross.engine.grid.Box; import picross.engine.grid.Box.BoxState; Modified: branches/engine_split/swing/src/picross/specific/ui/PicrossUIHelper.java =================================================================== --- branches/engine_split/swing/src/picross/specific/ui/PicrossUIHelper.java 2013-01-10 11:57:14 UTC (rev 106) +++ branches/engine_split/swing/src/picross/specific/ui/PicrossUIHelper.java 2013-01-10 12:13:19 UTC (rev 107) @@ -43,7 +43,7 @@ import javax.swing.ImageIcon; -import picross.common.Picross; +import picross.engine.Picross; import picross.common.ui.MissingImageException; Deleted: branches/engine_split/swing/test/picross/specific/grid/ui/FillCommandTest.java =================================================================== --- branches/engine_split/test/picross/grid/ui/FillCommandTest.java 2013-01-10 11:57:14 UTC (rev 106) +++ branches/engine_split/swing/test/picross/specific/grid/ui/FillCommandTest.java 2013-01-10 12:13:19 UTC (rev 107) @@ -1,65 +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.grid.ui; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Y. Norsa - */ -public class FillCommandTest { - @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); - */ - } - -} - Modified: branches/engine_split/swing/test/picross/specific/grid/ui/IGridMediatorStub.java =================================================================== --- branches/engine_split/test/picross/grid/ui/IGridMediatorStub.java 2013-01-10 11:57:14 UTC (rev 106) +++ branches/engine_split/swing/test/picross/specific/grid/ui/IGridMediatorStub.java 2013-01-10 12:13:19 UTC (rev 107) @@ -31,11 +31,14 @@ */ -package picross.grid.ui; +package picross.specific.grid.ui; import fr.cle.mmvcs.SimpleEvent; import fr.cle.mmvcs.SimpleListener; +import picross.common.grid.ui.IGridMediator; +import picross.common.grid.ui.GridView; + /** * @author Y. Norsa */ Deleted: branches/engine_split/swing/test/picross/specific/grid/ui/PaintCommandTest.java =================================================================== --- branches/engine_split/test/picross/grid/ui/PaintCommandTest.java 2013-01-10 11:57:14 UTC (rev 106) +++ branches/engine_split/swing/test/picross/specific/grid/ui/PaintCommandTest.java 2013-01-10 12:13:19 UTC (rev 107) @@ -1,58 +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.grid.ui; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Y. Norsa - */ -public class PaintCommandTest { - @Test(expected = IllegalArgumentException.class) - public void paintCommandWithInvalidRow() { - new PaintCommand(-1, 0); - } - - @Test(expected = IllegalArgumentException.class) - public void paintCommandWithInvalidCol() { - new PaintCommand(0, -1); - } - - @Test - public void testPaintCommand() { - new PaintCommand(0, 0); - } -} - Modified: branches/engine_split/swing/test/picross/specific/grid/ui/UIBoxTest.java =================================================================== --- branches/engine_split/test/picross/grid/ui/UIBoxTest.java 2013-01-10 11:57:14 UTC (rev 106) +++ branches/engine_split/swing/test/picross/specific/grid/ui/UIBoxTest.java 2013-01-10 12:13:19 UTC (rev 107) @@ -31,7 +31,7 @@ */ -package picross.grid.ui; +package picross.specific.grid.ui; import javax.swing.ImageIcon; Modified: branches/engine_split/swing/test/picross/specific/ui/PicrossUIHelperTest.java =================================================================== --- branches/engine_split/test/picross/ui/PicrossUIHelperTest.java 2013-01-10 11:57:14 UTC (rev 106) +++ branches/engine_split/swing/test/picross/specific/ui/PicrossUIHelperTest.java 2013-01-10 12:13:19 UTC (rev 107) @@ -31,7 +31,7 @@ */ -package picross.ui; +package picross.specific.ui; import java.io.FileNotFoundException; import java.io.IOException; @@ -42,6 +42,8 @@ import org.junit.Assert; import org.junit.Test; +import picross.common.ui.MissingImageException; + /** * Tests for the static methods of the Picross class. * Deleted: branches/engine_split/test/picross/PicrossTest.java =================================================================== --- branches/engine_split/test/picross/PicrossTest.java 2013-01-10 11:57:14 UTC (rev 106) +++ branches/engine_split/test/picross/PicrossTest.java 2013-01-10 12:13:19 UTC (rev 107) @@ -1,72 +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 java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; - -import org.junit.Assert; -import org.junit.Test; - -/** - * Tests for the static methods of the Picross class. - * - * @author Y. Norsa - */ -public class PicrossTest { - /*** Methods ***/ - - @Test(expected = IllegalArgumentException.class) - public void loadNullFile() throws IOException { - Picross.loadDataFile(null); - } - - @Test(expected = IllegalArgumentException.class) - public void loadEmptyNamedFile() throws IOException { - Picross.loadDataFile(""); - } - - @Test(expected = FileNotFoundException.class) - public void loadMissingFile() throws IOException { - Picross.loadDataFile("fakeFile"); - } - - @Test - public void loadDataFile() throws IOException { - InputStream in = Picross.loadDataFile("asterix.xbm"); - Assert.assertNotNull("in = null", in); - in.close(); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2013-01-10 11:57:17
|
Revision: 106 http://sourceforge.net/p/picross/code/106 Author: yvan_norsa Date: 2013-01-10 11:57:14 +0000 (Thu, 10 Jan 2013) Log Message: ----------- finished split Modified Paths: -------------- branches/engine_split/services/picross.engine.game.GameMode branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameController.java branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameMediator.java branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameModeUI.java branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameUI.java Added Paths: ----------- branches/engine_split/swing/src/picross/specific/game/random/ branches/engine_split/swing/src/picross/specific/game/simple/ui/SimpleGameModeUI.java Removed Paths: ------------- branches/engine_split/src/picross/game/ Modified: branches/engine_split/services/picross.engine.game.GameMode =================================================================== --- branches/engine_split/services/picross.engine.game.GameMode 2013-01-10 11:51:56 UTC (rev 105) +++ branches/engine_split/services/picross.engine.game.GameMode 2013-01-10 11:57:14 UTC (rev 106) @@ -1,2 +1,2 @@ -picross.game.random.ui.RandomGameModeUI -picross.game.simple.ui.SimpleGameModeUI +picross.specific.game.random.ui.RandomGameModeUI +picross.specific.game.simple.ui.SimpleGameModeUI Modified: branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameController.java =================================================================== --- branches/engine_split/src/picross/game/random/ui/RandomGameController.java 2013-01-10 11:39:09 UTC (rev 104) +++ branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameController.java 2013-01-10 11:57:14 UTC (rev 106) @@ -31,7 +31,7 @@ */ -package picross.game.random.ui; +package picross.specific.game.random.ui; import java.awt.event.ActionEvent; Modified: branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameMediator.java =================================================================== --- branches/engine_split/src/picross/game/random/ui/RandomGameMediator.java 2013-01-10 11:39:09 UTC (rev 104) +++ branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameMediator.java 2013-01-10 11:57:14 UTC (rev 106) @@ -31,7 +31,7 @@ */ -package picross.game.random.ui; +package picross.specific.game.random.ui; import fr.cle.mmvcs.SimpleEvent; Modified: branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameModeUI.java =================================================================== --- branches/engine_split/src/picross/game/random/ui/RandomGameModeUI.java 2013-01-10 11:39:09 UTC (rev 104) +++ branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameModeUI.java 2013-01-10 11:57:14 UTC (rev 106) @@ -31,7 +31,7 @@ */ -package picross.game.random.ui; +package picross.specific.game.random.ui; import fr.cle.core.gui.SimpleButton; Modified: branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameUI.java =================================================================== --- branches/engine_split/src/picross/game/random/ui/RandomGameUI.java 2013-01-10 11:39:09 UTC (rev 104) +++ branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameUI.java 2013-01-10 11:57:14 UTC (rev 106) @@ -31,7 +31,7 @@ */ -package picross.game.random.ui; +package picross.specific.game.random.ui; import bundleHelper.BundleHelper; Copied: branches/engine_split/swing/src/picross/specific/game/simple/ui/SimpleGameModeUI.java (from rev 104, branches/engine_split/src/picross/game/simple/ui/SimpleGameModeUI.java) =================================================================== --- branches/engine_split/swing/src/picross/specific/game/simple/ui/SimpleGameModeUI.java (rev 0) +++ branches/engine_split/swing/src/picross/specific/game/simple/ui/SimpleGameModeUI.java 2013-01-10 11:57:14 UTC (rev 106) @@ -0,0 +1,86 @@ +/* + * $Id: SimpleGameMode.java 71 2008-04-29 09:32:57Z yvan_norsa $ + * + * 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.specific.game.simple.ui; + +import fr.cle.core.gui.SimpleButton; + +import fr.cle.mmvcs.SimpleEvent; + +import javax.swing.ImageIcon; +import javax.swing.JButton; + +import picross.engine.game.GameMode; + +import picross.engine.game.simple.SimpleGameMode; + +import picross.specific.game.ui.UIGameMode; +import picross.common.game.simple.ui.LevelMenuMediator; + +import picross.common.ui.MenuCommand; +import picross.specific.ui.PicrossButton; +import picross.specific.ui.PicrossUIHelper; + +/** + * Simple game mode. + * + * @author Y. Norsa + */ +public final class SimpleGameModeUI extends SimpleGameMode + implements UIGameMode { + + /*** Constant ***/ + + /** 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; + + /*** Method implanted from the interface GameMode ***/ + + /** {@inheritDoc} */ + @Override + public SimpleButton<JButton> getButton() { + ImageIcon icon = + PicrossUIHelper.getLocalizedImage(SimpleGameModeUI.SELECT_BUTTON_IMAGE); + SimpleEvent event = + new SimpleEvent(new MenuCommand(LevelMenuMediator.class)); + + return new PicrossButton(icon, event); + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2013-01-10 11:51:59
|
Revision: 105 http://sourceforge.net/p/picross/code/105 Author: yvan_norsa Date: 2013-01-10 11:51:56 +0000 (Thu, 10 Jan 2013) Log Message: ----------- cleaning Removed Paths: ------------- branches/engine_split/src/picross/game/ui/ branches/engine_split/src/picross/grid/ branches/engine_split/src/picross/ui/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2013-01-10 11:40:44
|
Revision: 105 http://picross.svn.sourceforge.net/picross/?rev=105&view=rev Author: yvan_norsa Date: 2013-01-10 11:40:35 +0000 (Thu, 10 Jan 2013) Log Message: ----------- fixed classes Modified Paths: -------------- branches/engine_split/src/picross/app/MainMenuAppUI.java branches/engine_split/src/picross/applet/MainMenuAppletUI.java Modified: branches/engine_split/src/picross/app/MainMenuAppUI.java =================================================================== --- branches/engine_split/src/picross/app/MainMenuAppUI.java 2013-01-10 09:09:32 UTC (rev 104) +++ branches/engine_split/src/picross/app/MainMenuAppUI.java 2013-01-10 11:40:35 UTC (rev 105) @@ -70,7 +70,7 @@ /** {@inheritDoc} */ @Override - protected void init(/*ActionListener*/MenuController controller) { + public void init(/*ActionListener*/MenuController controller) { super.init(controller); this.addButton(MainMenuAppUI.EXIT_BUTTON_IMAGE, Modified: branches/engine_split/src/picross/applet/MainMenuAppletUI.java =================================================================== --- branches/engine_split/src/picross/applet/MainMenuAppletUI.java 2013-01-10 09:09:32 UTC (rev 104) +++ branches/engine_split/src/picross/applet/MainMenuAppletUI.java 2013-01-10 11:40:35 UTC (rev 105) @@ -62,7 +62,7 @@ /** {@inheritDoc} */ @Override - protected void init(/*ActionListener*/MenuController controller) { + public void init(/*ActionListener*/MenuController controller) { super.init(controller); this.setBackground(Color.WHITE); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2013-01-10 11:39:20
|
Revision: 104 http://sourceforge.net/p/picross/code/104 Author: yvan_norsa Date: 2013-01-10 11:39:09 +0000 (Thu, 10 Jan 2013) Log Message: ----------- merge from old SF repo Modified Paths: -------------- branches/engine_split/build.xml branches/engine_split/src/picross/app/MainMenuAppUI.java branches/engine_split/src/picross/app/PicrossApp.java branches/engine_split/src/picross/app/PicrossAppUI.java branches/engine_split/src/picross/applet/MainMenuAppletUI.java branches/engine_split/src/picross/applet/PicrossApplet.java branches/engine_split/src/picross/game/random/ui/RandomGameController.java branches/engine_split/src/picross/game/random/ui/RandomGameMediator.java branches/engine_split/src/picross/game/random/ui/RandomGameModeUI.java branches/engine_split/src/picross/game/random/ui/RandomGameUI.java branches/engine_split/src/picross/game/simple/ui/SimpleGameModeUI.java Added Paths: ----------- branches/engine_split/common/ branches/engine_split/common/src/ branches/engine_split/common/src/picross/ branches/engine_split/common/src/picross/common/ branches/engine_split/common/src/picross/common/Picross.java branches/engine_split/common/src/picross/common/game/ branches/engine_split/common/src/picross/common/game/simple/ branches/engine_split/common/src/picross/common/game/simple/ui/ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuController.java branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java branches/engine_split/common/src/picross/common/game/simple/ui/LevelsListCommand.java branches/engine_split/common/src/picross/common/game/simple/ui/SelectSizeCommand.java branches/engine_split/common/src/picross/common/game/simple/ui/SimpleGameMediator.java branches/engine_split/common/src/picross/common/game/simple/ui/SizesListCommand.java branches/engine_split/common/src/picross/common/game/ui/ branches/engine_split/common/src/picross/common/game/ui/GameCommand.java branches/engine_split/common/src/picross/common/game/ui/GameView.java branches/engine_split/common/src/picross/common/grid/ branches/engine_split/common/src/picross/common/grid/ui/ branches/engine_split/common/src/picross/common/grid/ui/FillCommand.java branches/engine_split/common/src/picross/common/grid/ui/GridCommands.java branches/engine_split/common/src/picross/common/grid/ui/GridView.java branches/engine_split/common/src/picross/common/grid/ui/IGridMediator.java branches/engine_split/common/src/picross/common/grid/ui/PaintCommand.java branches/engine_split/common/src/picross/common/grid/ui/RepaintLeftHintsCommand.java branches/engine_split/common/src/picross/common/grid/ui/RepaintTopHintsCommand.java branches/engine_split/common/src/picross/common/ui/ branches/engine_split/common/src/picross/common/ui/GameMenuMediator.java branches/engine_split/common/src/picross/common/ui/GameMenuModel.java branches/engine_split/common/src/picross/common/ui/MainMenuMediator.java branches/engine_split/common/src/picross/common/ui/MenuCommand.java branches/engine_split/common/src/picross/common/ui/MenuMediator.java branches/engine_split/common/src/picross/common/ui/MissingImageException.java branches/engine_split/common/src/picross/common/ui/PicrossController.java branches/engine_split/common/src/picross/common/ui/PicrossUI.java branches/engine_split/common/src/picross/common/ui/PicrossView.java branches/engine_split/common/src/picross/common/ui/WaitMenuMediator.java branches/engine_split/common/src/picross/specific/ branches/engine_split/common/src/picross/specific/game/ branches/engine_split/common/src/picross/specific/game/simple/ branches/engine_split/common/src/picross/specific/game/simple/ui/ branches/engine_split/common/src/picross/specific/game/simple/ui/LevelMenuUI.java branches/engine_split/common/src/picross/specific/game/ui/ branches/engine_split/common/src/picross/specific/game/ui/GameMediator.java branches/engine_split/common/src/picross/specific/grid/ branches/engine_split/common/src/picross/specific/grid/ui/ branches/engine_split/common/src/picross/specific/grid/ui/GridController.java branches/engine_split/common/src/picross/specific/ui/ branches/engine_split/common/src/picross/specific/ui/GameMenuUI.java branches/engine_split/common/src/picross/specific/ui/MainMenuUI.java branches/engine_split/common/src/picross/specific/ui/MenuController.java branches/engine_split/common/src/picross/specific/ui/MenuUI.java branches/engine_split/common/src/picross/specific/ui/WaitMenuUI.java branches/engine_split/swing/ branches/engine_split/swing/src/ branches/engine_split/swing/src/picross/ branches/engine_split/swing/src/picross/specific/ branches/engine_split/swing/src/picross/specific/game/ branches/engine_split/swing/src/picross/specific/game/simple/ branches/engine_split/swing/src/picross/specific/game/simple/ui/ branches/engine_split/swing/src/picross/specific/game/simple/ui/LevelMenuUI.java branches/engine_split/swing/src/picross/specific/game/ui/ branches/engine_split/swing/src/picross/specific/game/ui/GameController.java branches/engine_split/swing/src/picross/specific/game/ui/GameMediator.java branches/engine_split/swing/src/picross/specific/game/ui/GameUI.java branches/engine_split/swing/src/picross/specific/game/ui/UIGameMode.java branches/engine_split/swing/src/picross/specific/grid/ branches/engine_split/swing/src/picross/specific/grid/ui/ branches/engine_split/swing/src/picross/specific/grid/ui/GridController.java branches/engine_split/swing/src/picross/specific/grid/ui/GridMediator.java branches/engine_split/swing/src/picross/specific/grid/ui/GridUI.java branches/engine_split/swing/src/picross/specific/grid/ui/HintBoxInfos.java branches/engine_split/swing/src/picross/specific/grid/ui/UIBox.java branches/engine_split/swing/src/picross/specific/ui/ branches/engine_split/swing/src/picross/specific/ui/GameMenuUI.java branches/engine_split/swing/src/picross/specific/ui/MainMenuUI.java branches/engine_split/swing/src/picross/specific/ui/MenuController.java branches/engine_split/swing/src/picross/specific/ui/MenuUI.java branches/engine_split/swing/src/picross/specific/ui/PicrossButton.java branches/engine_split/swing/src/picross/specific/ui/PicrossLog4jLogger.java branches/engine_split/swing/src/picross/specific/ui/PicrossMediator.java branches/engine_split/swing/src/picross/specific/ui/PicrossUIHelper.java branches/engine_split/swing/src/picross/specific/ui/WaitMenuUI.java Removed Paths: ------------- branches/engine_split/src/picross/Picross.java branches/engine_split/src/picross/game/simple/ui/LevelMenuController.java branches/engine_split/src/picross/game/simple/ui/LevelMenuMediator.java branches/engine_split/src/picross/game/simple/ui/LevelMenuModel.java branches/engine_split/src/picross/game/simple/ui/LevelMenuUI.java branches/engine_split/src/picross/game/simple/ui/LevelsListCommand.java branches/engine_split/src/picross/game/simple/ui/SelectSizeCommand.java branches/engine_split/src/picross/game/simple/ui/SimpleGameMediator.java branches/engine_split/src/picross/game/simple/ui/SizesListCommand.java branches/engine_split/src/picross/game/ui/GameCommand.java branches/engine_split/src/picross/game/ui/GameController.java branches/engine_split/src/picross/game/ui/GameMediator.java branches/engine_split/src/picross/game/ui/GameUI.java branches/engine_split/src/picross/game/ui/GameView.java branches/engine_split/src/picross/game/ui/UIGameMode.java branches/engine_split/src/picross/grid/ui/FillCommand.java branches/engine_split/src/picross/grid/ui/GridController.java branches/engine_split/src/picross/grid/ui/GridMediator.java branches/engine_split/src/picross/grid/ui/GridUI.java branches/engine_split/src/picross/grid/ui/GridView.java branches/engine_split/src/picross/grid/ui/HintBoxInfos.java branches/engine_split/src/picross/grid/ui/IGridMediator.java branches/engine_split/src/picross/grid/ui/PaintCommand.java branches/engine_split/src/picross/grid/ui/RepaintLeftHintsCommand.java branches/engine_split/src/picross/grid/ui/RepaintTopHintsCommand.java branches/engine_split/src/picross/grid/ui/UIBox.java branches/engine_split/src/picross/ui/GameMenuMediator.java branches/engine_split/src/picross/ui/GameMenuModel.java branches/engine_split/src/picross/ui/GameMenuUI.java branches/engine_split/src/picross/ui/MainMenuMediator.java branches/engine_split/src/picross/ui/MainMenuUI.java branches/engine_split/src/picross/ui/MenuCommand.java branches/engine_split/src/picross/ui/MenuController.java branches/engine_split/src/picross/ui/MenuMediator.java branches/engine_split/src/picross/ui/MenuUI.java branches/engine_split/src/picross/ui/MissingImageException.java branches/engine_split/src/picross/ui/PicrossButton.java branches/engine_split/src/picross/ui/PicrossController.java branches/engine_split/src/picross/ui/PicrossLog4jLogger.java branches/engine_split/src/picross/ui/PicrossMediator.java branches/engine_split/src/picross/ui/PicrossUI.java branches/engine_split/src/picross/ui/PicrossUIHelper.java branches/engine_split/src/picross/ui/PicrossView.java branches/engine_split/src/picross/ui/WaitMenuMediator.java branches/engine_split/src/picross/ui/WaitMenuUI.java Modified: branches/engine_split/build.xml =================================================================== --- branches/engine_split/build.xml 2013-01-09 13:32:12 UTC (rev 103) +++ branches/engine_split/build.xml 2013-01-10 11:39:09 UTC (rev 104) @@ -3,6 +3,10 @@ <project name="picross" default="dist"> + <property name="swing.build.dir" + value="swing/build" /> + <property name="common.build.dir" + value="common/build" /> <property name="engine.build.dir" value="engine/build" /> <property name="game.build.dir" @@ -13,6 +17,10 @@ value="doc" /> <property name="lib.dir" value="lib" /> + <property name="swing.src.dir" + value="swing/src" /> + <property name="common.src.dir" + value="common/src" /> <property name="engine.src.dir" value="engine/src" /> <property name="game.src.dir" @@ -22,6 +30,10 @@ <property name="game.test.dir" value="test" /> + <property name="swing.jar.name" + value="${dist.dir}/${ant.project.name}-swing.jar" /> + <property name="common.jar.name" + value="${dist.dir}/${ant.project.name}-common.jar" /> <property name="engine.jar.name" value="${dist.dir}/${ant.project.name}-engine.jar" /> <property name="game.jar.name" @@ -44,6 +56,8 @@ <target name="-init" depends="-setmode"> + <mkdir dir="${swing.build.dir}" /> + <mkdir dir="${common.build.dir}" /> <mkdir dir="${engine.build.dir}" /> <mkdir dir="${game.build.dir}" /> <mkdir dir="${dist.dir}" /> @@ -73,6 +87,8 @@ <path id="classpath"> <pathelement location="${game.build.dir}" /> <pathelement location="${engine.build.dir}" /> + <pathelement location="${common.build.dir}" /> + <pathelement location="${swing.build.dir}" /> <pathelement location="${bundleHelper.jar}" /> <pathelement location="${easymock.jar}" /> @@ -82,6 +98,45 @@ <pathelement location="${simpleButton.jar}" /> </path> + <path id="game-classpath"> + <pathelement location="${game.build.dir}" /> + <pathelement location="${swing.jar.name}" /> + <pathelement location="${common.jar.name}" /> + <pathelement location="${engine.jar.name}" /> + <pathelement location="${bundleHelper.jar}" /> + <pathelement location="${easymock.jar}" /> + <pathelement location="${junit.jar}" /> + <pathelement location="${log4j.jar}" /> + <pathelement location="${mmvcs.jar}" /> + <pathelement location="${simpleButton.jar}" /> + </path> + + <target name="swing-compile" + depends="-init"> + <javac srcdir="${swing.src.dir}" + destdir="${swing.build.dir}" + deprecation="on" + debug="${javac.debug}" + optimize="${javac.optimize}"> + <compilerarg value="-Xlint:all" /> + + <classpath refid="classpath" /> + </javac> + </target> + + <target name="common-compile" + depends="-init"> + <javac srcdir="${common.src.dir}" + destdir="${common.build.dir}" + deprecation="on" + debug="${javac.debug}" + optimize="${javac.optimize}"> + <compilerarg value="-Xlint:all" /> + + <classpath refid="classpath" /> + </javac> + </target> + <target name="engine-compile" depends="-init"> <javac srcdir="${engine.src.dir}" @@ -94,7 +149,7 @@ </target> <target name="game-compile" - depends="-init"> + depends="swing-dist,-init"> <javac srcdir="${game.src.dir}" destdir="${game.build.dir}" deprecation="on" @@ -102,7 +157,7 @@ optimize="${javac.optimize}"> <compilerarg value="-Xlint:all" /> - <classpath refid="classpath" /> + <classpath refid="game-classpath" /> </javac> </target> @@ -138,8 +193,21 @@ basedir="${engine.build.dir}" /> </target> + <target name="swing-dist" + depends="engine-dist,swing-compile"> + <jar destfile="${swing.jar.name}" + basedir="${swing.build.dir}" /> + </target> + + <target name="common-dist" + depends="engine-dist,common-compile"> + <jar destfile="${common.jar.name}" + basedir="${common.build.dir}" + excludes="picross/specific/**" /> + </target> + <target name="dist" - depends="engine-dist,game-compile"> + depends="engine-dist,common-dist,game-compile"> <copy todir="${game.build.dir}/picross/properties" failonerror="false"> <fileset dir="${game.src.dir}/picross/properties" /> @@ -168,6 +236,8 @@ fork="true" dir="."> <classpath> + <pathelement location="${swing.jar.name}" /> + <pathelement location="${common.jar.name}" /> <pathelement location="${engine.jar.name}" /> <pathelement location="${game.jar.name}" /> <pathelement location="${bundleHelper.jar}" /> @@ -185,6 +255,9 @@ fork="true" dir="."> <classpath> + <pathelement location="${swing.jar.name}" /> + <pathelement location="${common.jar.name}" /> + <pathelement location="${engine.jar.name}" /> <pathelement location="${game.jar.name}" /> <pathelement location="${bundleHelper.jar}" /> <pathelement location="${log4j.jar}" /> @@ -239,6 +312,8 @@ </target> <target name="clean"> + <delete dir="${swing.build.dir}" /> + <delete dir="${common.build.dir}" /> <delete dir="${engine.build.dir}" /> <delete dir="${game.build.dir}" /> <delete dir="${dist.dir}" /> Added: branches/engine_split/common/src/picross/common/Picross.java =================================================================== --- branches/engine_split/common/src/picross/common/Picross.java (rev 0) +++ branches/engine_split/common/src/picross/common/Picross.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,95 @@ +/* + * $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.common; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import java.net.URL; + +/** + * Helper class. + * + * @author Y. Norsa + */ +public final class Picross { + /*** Constant ***/ + + /** Data directory. */ + private static final String DATA_DIR = "/picross/data/"; + + /*** Constructor ***/ + + /** Fake constructor. */ + private Picross() { } + + /*** Static methods ***/ + + /** + * Loads a file. + * + * @param path file path + * @return URL of the file + * @throws FileNotFoundException if the file can't be found + */ + public static URL getFile(String path) throws FileNotFoundException { + URL fileUrl = Picross.class.getResource(path); + + if (fileUrl == null) { + throw new FileNotFoundException("\"" + path + "\" can't be found"); + } + + return fileUrl; + } + + /** + * Loads a data file. + * + * @param name filename + * @return a stream containing the loaded file + * @throws IllegalArgumentException if <code>name</code> + * is <code>null</code> or empty + * @throws IOException if there is a problem while opening the file + */ + public static InputStream loadDataFile(String name) throws IOException { + + if (name == null || name.equals("")) { + throw new IllegalArgumentException("name can't be null or empty"); + } + + return Picross.getFile(Picross.DATA_DIR + name).openStream(); + } +} + Property changes on: branches/engine_split/common/src/picross/common/Picross.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuController.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuController.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuController.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,107 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.simple.ui; + +import fr.cle.mmvcs.SimpleEvent; + +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; + +import picross.common.game.ui.GameCommand; + +import picross.common.ui.PicrossController; + +import picross.specific.game.simple.ui.LevelMenuUI; + +import picross.specific.ui.MenuController; + +/** + * Controller for the level selection menu. + * + * @author Y. Norsa + */ +public final class LevelMenuController extends MenuController { + /*** Constants ***/ + + /** Command used when selecting a grid size. */ + public static final String SIZE_CMD = "SIZE_CMD"; + + /** Command used to display a levels list. */ + public static final String LEVELS_LIST_CMD = "LEVELS_LIST_CMD"; + + /** Select level command. */ + public static final String LEVEL_CMD = "LEVEL_CMD"; + + /*** Static field ***/ + + /** The class' logger. */ + private static PicrossLogger log = PicrossLogHelper.getLogger(); + + /*** Method overloaded from the class LevelMenuController ***/ + + /** {@inheritDoc} */ + @Override + public void eventPerformed(SimpleEvent e) { + LevelMenuController.log.debug("eventPerformed(" + e + ")"); + + String cmd = e.getCommandName(); + + if (cmd.equals(GameCommand.GAME_CMD)) { + return; + } + + if (cmd.equals(PicrossController.PLAY_CMD)) { + return; + } + + if (cmd.equals(LevelMenuController.LEVELS_LIST_CMD)) { + LevelsListCommand command = (LevelsListCommand) e.getCommand(); + ((LevelMenuUI) this.getView()).displayLevels(this, + command.getList()); + + return; + } + + if (cmd.equals(SizesListCommand.SIZES_CMD)) { + SizesListCommand command = (SizesListCommand) e.getCommand(); + ((LevelMenuUI) this.getView()).displaySizes(this, + command.getSizes()); + + return; + } + + super.eventPerformed(e); + } +} + Property changes on: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuController.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,140 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.simple.ui; + +import fr.cle.mmvcs.SimpleEvent; + +import java.util.List; + +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; +import picross.engine.PicrossException; + +import picross.common.game.ui.GameCommand; + +import picross.specific.ui.MenuController; +import picross.common.ui.MenuMediator; +import picross.common.ui.PicrossUI; + +import picross.specific.ui.MenuUI; + +import picross.specific.game.simple.ui.LevelMenuUI; + +/** + * Level selection menu. + * + * @author Y. Norsa + */ +public final class LevelMenuMediator extends MenuMediator { + /*** Static field ***/ + + /** The class' logger. */ + private static PicrossLogger log = PicrossLogHelper.getLogger(); + + /*** Field ***/ + + /** Model containing the levels list. */ + private LevelMenuModel model = null; + + /*** Methods overloaded from the class MenuMediator ***/ + + /** {@inheritDoc} */ + @Override + protected MenuController initController() { + MenuController controller = new LevelMenuController(); + this.addSimpleListener(controller); + + return controller; + } + + /** {@inheritDoc} */ + @Override + protected MenuUI initView(PicrossUI ui, MenuController controller) + throws PicrossException { + + LevelMenuMediator.log.debug("initView()"); + + this.model = new LevelMenuModel(); + + LevelMenuMediator.log.debug("this : " + this); + LevelMenuMediator.log.debug("this.model : " + this.model); + + return new LevelMenuUI(controller, this.model.getSizesList()); + } + + /** {@inheritDoc} */ + @Override + public void eventPerformed(SimpleEvent e) { + LevelMenuMediator.log.debug("eventPerformed(" + e + ")"); + LevelMenuMediator.log.debug("this : " + this); + LevelMenuMediator.log.debug("this.model : " + this.model); + + 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(LevelMenuController.LEVEL_CMD)) { + String level = e.getComment(); + this.fireEventPerformed(new + GameCommand(new + SimpleGameMediator(level))); + return; + } + + if (cmd.equals(MenuController.BACK_CMD)) { + this.fireEventPerformed(new SizesListCommand(this.model + .getSizesList())); + return; + } + + super.eventPerformed(e); + } + + /*** Method ***/ + + /** + * Sends a message asking to display the levels list. + * + * @param levels the levels list + */ + private void displayLevels(List<String> levels) { + this.fireEventPerformed(new LevelsListCommand(levels)); + } +} + Property changes on: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,154 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.simple.ui; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import picross.common.Picross; +import picross.engine.PicrossException; + +import picross.engine.game.simple.Dimensions; +import picross.engine.game.simple.FileInfos; +import picross.engine.game.simple.LevelInfos; + +/** + * Model for the level selection menu. + * + * @author Y. Norsa + */ +final class LevelMenuModel { + /*** Constant ***/ + + /** File containing the data files list. */ + private static final String DATA_LIST = "contents.txt"; + + /*** Field ***/ + + /** Levels list. */ + private Map<Dimensions, List<String>> levels; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @throws PicrossException if an error arises during the levels listing + */ + LevelMenuModel() throws PicrossException { + this.levels = new HashMap<Dimensions, List<String>>(); + + List<LevelInfos> infos = null; + + try { + infos = LevelMenuModel.listDataFiles(); + } catch (IOException ioEx) { + throw new PicrossException(ioEx); + } + + for (LevelInfos info : infos) { + Dimensions levelSize = info.getDimensions(); + List<String> levelsList = this.levels.get(levelSize); + + if (levelsList == null) { + levelsList = new ArrayList<String>(); + this.levels.put(levelSize, levelsList); + } + + levelsList.add(info.getName()); + } + } + + /*** Static method ***/ + + /** + * Reads the data files list and returns informations about the levels. + * + * @return informations about the available levels + * @throws IOException if a problem occurs during the operation + */ + private static List<LevelInfos> listDataFiles() throws IOException { + List<LevelInfos> list = new ArrayList<LevelInfos>(); + + BufferedReader in = null; + + try { + in = new + BufferedReader(new + InputStreamReader(Picross + .loadDataFile(LevelMenuModel + .DATA_LIST))); + + String line = null; + + while ((line = in.readLine()) != null) { + list.add(FileInfos.readFileInfos(line)); + } + } catch (IOException ioEx) { + throw ioEx; + } finally { + in.close(); + } + + return list; + } + + /*** Methods ***/ + + /** + * Returns the available sizes list. + * + * @return list of all the grid sizes + */ + List<Dimensions> getSizesList() { + return new ArrayList<Dimensions>(this.levels.keySet()); + } + + /** + * Returns the list of levels for this size. + * + * @param size desired grid size + * @return list of the corresponding level files + */ + List<String> getLevels(Dimensions size) { + return this.levels.get(size); + } +} + Property changes on: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/common/src/picross/common/game/simple/ui/LevelsListCommand.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelsListCommand.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelsListCommand.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,75 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.simple.ui; + +import fr.cle.mmvcs.NamedCommand; + +import java.util.List; + +/** + * Command containing a levels list. + * + * @author Y. Norsa + */ +final class LevelsListCommand extends NamedCommand { + /*** Field ***/ + + /** List of levels' names. */ + private List<String> list; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param levels levels' names + */ + LevelsListCommand(List<String> levels) { + super(LevelMenuController.LEVELS_LIST_CMD); + + this.list = levels; + } + + /*** Accessor ***/ + + /** + * Return the levels list. + * + * @return list of the levels + */ + List<String> getList() { + return this.list; + } +} + Property changes on: branches/engine_split/common/src/picross/common/game/simple/ui/LevelsListCommand.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/common/src/picross/common/game/simple/ui/SelectSizeCommand.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/SelectSizeCommand.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/SelectSizeCommand.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,75 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.simple.ui; + +import fr.cle.mmvcs.NamedCommand; + +import picross.engine.game.simple.Dimensions; + +/** + * Command used when a grid size has been selected. + * + * @author Y. Norsa + */ +public final class SelectSizeCommand extends NamedCommand { + /*** Field ***/ + + /** The selected grid size. */ + private Dimensions size; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param dim grid size + */ + public SelectSizeCommand(Dimensions dim) { + super(LevelMenuController.SIZE_CMD); + + this.size = dim; + } + + /*** Accessor ***/ + + /** + * Returns the grid size. + * + * @return selected grid size + */ + public Dimensions getSize() { + return this.size; + } +} + Property changes on: branches/engine_split/common/src/picross/common/game/simple/ui/SelectSizeCommand.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/common/src/picross/common/game/simple/ui/SimpleGameMediator.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/SimpleGameMediator.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/SimpleGameMediator.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,83 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * 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.common.game.simple.ui; + +import java.io.IOException; + +import picross.common.Picross; +import picross.engine.PicrossException; + +import picross.engine.game.simple.XBMModel; + +import picross.specific.game.ui.GameMediator; + +import picross.engine.grid.PicrossGrid; + +/** + * Mediator for a classic game. + * + * @author Y. Norsa + */ +public final class SimpleGameMediator extends GameMediator { + /*** Field ***/ + + /** Level to load. */ + private String level; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param levelName name of the level + */ + public SimpleGameMediator(String levelName) { + super(); + + this.level = levelName; + } + + /*** Method overloaded from the class GameMediator ***/ + + /** {@inheritDoc} */ + @Override + protected PicrossGrid initModel() throws PicrossException { + try { + return new XBMModel(Picross.loadDataFile(this.level)); + } catch (IOException ioEx) { + throw new PicrossException(ioEx); + } + } +} + Property changes on: branches/engine_split/common/src/picross/common/game/simple/ui/SimpleGameMediator.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/common/src/picross/common/game/simple/ui/SizesListCommand.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/SizesListCommand.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/SizesListCommand.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,82 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.simple.ui; + +import fr.cle.mmvcs.NamedCommand; + +import java.util.List; + +import picross.engine.game.simple.Dimensions; + +/** + * Command used to display the available grid sizes. + * + * @author Y. Norsa + */ +final class SizesListCommand extends NamedCommand { + /*** Constant ***/ + + /** Command used to display the grid sizes. */ + static final String SIZES_CMD = "SIZES_CMD"; + + /*** Field ***/ + + /** The sizes list. */ + private List<Dimensions> sizes; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param sizesList the sizes list + */ + SizesListCommand(List<Dimensions> sizesList) { + super(SizesListCommand.SIZES_CMD); + + this.sizes = sizesList; + } + + /*** Accessor ***/ + + /** + * Return the sizes list. + * + * @return available grid sizes + */ + List<Dimensions> getSizes() { + return this.sizes; + } +} + Property changes on: branches/engine_split/common/src/picross/common/game/simple/ui/SizesListCommand.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/common/src/picross/common/game/ui/GameCommand.java =================================================================== --- branches/engine_split/common/src/picross/common/game/ui/GameCommand.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/ui/GameCommand.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,80 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.ui; + +import fr.cle.mmvcs.NamedCommand; + +import picross.specific.game.ui.GameMediator; + +/** + * 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; + } +} + Property changes on: branches/engine_split/common/src/picross/common/game/ui/GameCommand.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/common/src/picross/common/game/ui/GameView.java =================================================================== --- branches/engine_split/common/src/picross/common/game/ui/GameView.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/ui/GameView.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,42 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.ui; + +import picross.common.ui.PicrossView; + +/** + * @author Y. Norsa + */ +public interface GameView extends PicrossView { } + Property changes on: branches/engine_split/common/src/picross/common/game/ui/GameView.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/common/src/picross/common/grid/ui/FillCommand.java =================================================================== --- branches/engine_split/common/src/picross/common/grid/ui/FillCommand.java (rev 0) +++ branches/engine_split/common/src/picross/common/grid/ui/FillCommand.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,129 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * 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.common.grid.ui; + +import fr.cle.mmvcs.Command; + +import picross.engine.grid.GridAction; + +/** + * Command containing informations about the box to fill. + * + * @author Y. Norsa + */ +public final class FillCommand extends Command { + /*** Fields ***/ + + /** Row of the box to fill. */ + private int row; + + /** Column of the box to fill. */ + private int column; + + /** Type of the action. */ + //private int type; + private GridAction type; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @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) { + public 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; + } + + /*** Method overloaded from the class Command ***/ + + /** {@inheritDoc} */ + @Override + public String toString() { + return this.row + "," + this.column; + } + + /*** Accessors ***/ + + /** + * Returns the row. + * + * @return row of the box to fill + */ + public int getRow() { + return this.row; + } + + /** + * Returns the column. + * + * @return column of the box to fill + */ + public int getColumn() { + return this.column; + } + + /** + * Return the type. + * + * @return type of the action + */ + //int getType() { + public GridAction getType() { + return this.type; + } +} + Property changes on: branches/engine_split/common/src/picross/common/grid/ui/FillCommand.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/common/src/picross/common/grid/ui/GridCommands.java =================================================================== --- branches/engine_split/common/src/picross/common/grid/ui/GridCommands.java (rev 0) +++ branches/engine_split/common/src/picross/common/grid/ui/GridCommands.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,36 @@ +/* + * $Id$ + */ + + +package picross.common.grid.ui; + +public final class GridCommands { + /*** Constants ***/ + + /** Fill command. */ + public static final String FILL_CMD = "FILL_CMD"; + + /** Command indicating the grid is filled. */ + public static final String GRID_FILLED_CMD = "GRID_FILLED_CMD"; + + /** Command indicating the action has reached its end. */ + public static final String END_ACTION_CMD = "END_ACTION_CMD"; + + /** Command asking to repaint part of the grid. */ + public static final String PAINT_CMD = "PAINT_CMD"; + + /** Command indicating that a hint has been completed. */ + public static final String COMPLETED_CMD = "COMPLETED_CMD"; + + /** Command asking to repaint the top hints. */ + public static final String REPAINT_TOP_HINTS_CMD = "REPAINT_TOP_HINTS_CMD"; + + /** Command asking to repaint the left hints. */ + public static final String REPAINT_LEFT_HINTS_CMD = "REPAINT_LEFT_HINTS_CMD"; + + /** Command asking to enable the Erase mode. */ + public static final String ERASE_MODE_CMD = "ERASE_MODE_CMD"; + + private GridCommands() { } +} Property changes on: branches/engine_split/common/src/picross/common/grid/ui/GridCommands.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/common/src/picross/common/grid/ui/GridView.java =================================================================== --- branches/engine_split/common/src/picross/common/grid/ui/GridView.java (rev 0) +++ branches/engine_split/common/src/picross/common/grid/ui/GridView.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,41 @@ +/* + * $Id$ + * + * Copyright (c) 2011 + * + * 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.common.grid.ui; + +/** + * @author Y. Norsa + */ +public interface GridView { } + + Property changes on: branches/engine_split/common/src/picross/common/grid/ui/GridView.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/common/src/picross/common/grid/ui/IGridMediator.java =================================================================== --- branches/engine_split/common/src/picross/common/grid/ui/IGridMediator.java (rev 0) +++ branches/engine_split/common/src/picross/common/grid/ui/IGridMediator.java 2013-01-10 11:39:09 UTC (rev 104) @@ -0,0 +1,71 @@ +/* + * $Id$ + * + * Copyright (c) 20... [truncated message content] |
From: <yva...@us...> - 2013-01-10 09:09:45
|
Revision: 104 http://picross.svn.sourceforge.net/picross/?rev=104&view=rev Author: yvan_norsa Date: 2013-01-10 09:09:32 +0000 (Thu, 10 Jan 2013) Log Message: ----------- split swing UI Modified Paths: -------------- branches/engine_split/build.xml branches/engine_split/src/picross/app/MainMenuAppUI.java branches/engine_split/src/picross/app/PicrossApp.java branches/engine_split/src/picross/app/PicrossAppUI.java branches/engine_split/src/picross/applet/MainMenuAppletUI.java branches/engine_split/src/picross/applet/PicrossApplet.java branches/engine_split/src/picross/game/random/ui/RandomGameController.java branches/engine_split/src/picross/game/random/ui/RandomGameMediator.java branches/engine_split/src/picross/game/random/ui/RandomGameModeUI.java branches/engine_split/src/picross/game/random/ui/RandomGameUI.java branches/engine_split/src/picross/game/simple/ui/SimpleGameModeUI.java Added Paths: ----------- branches/engine_split/common/ branches/engine_split/common/src/ branches/engine_split/common/src/picross/ branches/engine_split/common/src/picross/common/ branches/engine_split/common/src/picross/common/Picross.java branches/engine_split/common/src/picross/common/game/ branches/engine_split/common/src/picross/common/game/simple/ branches/engine_split/common/src/picross/common/game/simple/ui/ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuController.java branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java branches/engine_split/common/src/picross/common/game/simple/ui/LevelsListCommand.java branches/engine_split/common/src/picross/common/game/simple/ui/SelectSizeCommand.java branches/engine_split/common/src/picross/common/game/simple/ui/SimpleGameMediator.java branches/engine_split/common/src/picross/common/game/simple/ui/SizesListCommand.java branches/engine_split/common/src/picross/common/game/ui/ branches/engine_split/common/src/picross/common/game/ui/GameCommand.java branches/engine_split/common/src/picross/common/game/ui/GameView.java branches/engine_split/common/src/picross/common/grid/ branches/engine_split/common/src/picross/common/grid/ui/ branches/engine_split/common/src/picross/common/grid/ui/FillCommand.java branches/engine_split/common/src/picross/common/grid/ui/GridCommands.java branches/engine_split/common/src/picross/common/grid/ui/GridView.java branches/engine_split/common/src/picross/common/grid/ui/IGridMediator.java branches/engine_split/common/src/picross/common/grid/ui/PaintCommand.java branches/engine_split/common/src/picross/common/grid/ui/RepaintLeftHintsCommand.java branches/engine_split/common/src/picross/common/grid/ui/RepaintTopHintsCommand.java branches/engine_split/common/src/picross/common/ui/ branches/engine_split/common/src/picross/common/ui/GameMenuMediator.java branches/engine_split/common/src/picross/common/ui/GameMenuModel.java branches/engine_split/common/src/picross/common/ui/MainMenuMediator.java branches/engine_split/common/src/picross/common/ui/MenuCommand.java branches/engine_split/common/src/picross/common/ui/MenuMediator.java branches/engine_split/common/src/picross/common/ui/MissingImageException.java branches/engine_split/common/src/picross/common/ui/PicrossController.java branches/engine_split/common/src/picross/common/ui/PicrossUI.java branches/engine_split/common/src/picross/common/ui/PicrossView.java branches/engine_split/common/src/picross/common/ui/WaitMenuMediator.java branches/engine_split/common/src/picross/specific/ branches/engine_split/common/src/picross/specific/game/ branches/engine_split/common/src/picross/specific/game/simple/ branches/engine_split/common/src/picross/specific/game/simple/ui/ branches/engine_split/common/src/picross/specific/game/simple/ui/LevelMenuUI.java branches/engine_split/common/src/picross/specific/game/ui/ branches/engine_split/common/src/picross/specific/game/ui/GameMediator.java branches/engine_split/common/src/picross/specific/grid/ branches/engine_split/common/src/picross/specific/grid/ui/ branches/engine_split/common/src/picross/specific/grid/ui/GridController.java branches/engine_split/common/src/picross/specific/ui/ branches/engine_split/common/src/picross/specific/ui/GameMenuUI.java branches/engine_split/common/src/picross/specific/ui/MainMenuUI.java branches/engine_split/common/src/picross/specific/ui/MenuController.java branches/engine_split/common/src/picross/specific/ui/MenuUI.java branches/engine_split/common/src/picross/specific/ui/WaitMenuUI.java branches/engine_split/swing/ branches/engine_split/swing/src/ branches/engine_split/swing/src/picross/ branches/engine_split/swing/src/picross/specific/ branches/engine_split/swing/src/picross/specific/game/ branches/engine_split/swing/src/picross/specific/game/simple/ branches/engine_split/swing/src/picross/specific/game/simple/ui/ branches/engine_split/swing/src/picross/specific/game/simple/ui/LevelMenuUI.java branches/engine_split/swing/src/picross/specific/game/ui/ branches/engine_split/swing/src/picross/specific/game/ui/GameController.java branches/engine_split/swing/src/picross/specific/game/ui/GameMediator.java branches/engine_split/swing/src/picross/specific/game/ui/GameUI.java branches/engine_split/swing/src/picross/specific/game/ui/UIGameMode.java branches/engine_split/swing/src/picross/specific/grid/ branches/engine_split/swing/src/picross/specific/grid/ui/ branches/engine_split/swing/src/picross/specific/grid/ui/GridController.java branches/engine_split/swing/src/picross/specific/grid/ui/GridMediator.java branches/engine_split/swing/src/picross/specific/grid/ui/GridUI.java branches/engine_split/swing/src/picross/specific/grid/ui/HintBoxInfos.java branches/engine_split/swing/src/picross/specific/grid/ui/UIBox.java branches/engine_split/swing/src/picross/specific/ui/ branches/engine_split/swing/src/picross/specific/ui/GameMenuUI.java branches/engine_split/swing/src/picross/specific/ui/MainMenuUI.java branches/engine_split/swing/src/picross/specific/ui/MenuController.java branches/engine_split/swing/src/picross/specific/ui/MenuUI.java branches/engine_split/swing/src/picross/specific/ui/PicrossButton.java branches/engine_split/swing/src/picross/specific/ui/PicrossLog4jLogger.java branches/engine_split/swing/src/picross/specific/ui/PicrossMediator.java branches/engine_split/swing/src/picross/specific/ui/PicrossUIHelper.java branches/engine_split/swing/src/picross/specific/ui/WaitMenuUI.java Removed Paths: ------------- branches/engine_split/src/picross/Picross.java branches/engine_split/src/picross/game/simple/ui/LevelMenuController.java branches/engine_split/src/picross/game/simple/ui/LevelMenuMediator.java branches/engine_split/src/picross/game/simple/ui/LevelMenuModel.java branches/engine_split/src/picross/game/simple/ui/LevelMenuUI.java branches/engine_split/src/picross/game/simple/ui/LevelsListCommand.java branches/engine_split/src/picross/game/simple/ui/SelectSizeCommand.java branches/engine_split/src/picross/game/simple/ui/SimpleGameMediator.java branches/engine_split/src/picross/game/simple/ui/SizesListCommand.java branches/engine_split/src/picross/game/ui/GameCommand.java branches/engine_split/src/picross/game/ui/GameController.java branches/engine_split/src/picross/game/ui/GameMediator.java branches/engine_split/src/picross/game/ui/GameUI.java branches/engine_split/src/picross/game/ui/GameView.java branches/engine_split/src/picross/game/ui/UIGameMode.java branches/engine_split/src/picross/grid/ui/FillCommand.java branches/engine_split/src/picross/grid/ui/GridController.java branches/engine_split/src/picross/grid/ui/GridMediator.java branches/engine_split/src/picross/grid/ui/GridUI.java branches/engine_split/src/picross/grid/ui/GridView.java branches/engine_split/src/picross/grid/ui/HintBoxInfos.java branches/engine_split/src/picross/grid/ui/IGridMediator.java branches/engine_split/src/picross/grid/ui/PaintCommand.java branches/engine_split/src/picross/grid/ui/RepaintLeftHintsCommand.java branches/engine_split/src/picross/grid/ui/RepaintTopHintsCommand.java branches/engine_split/src/picross/grid/ui/UIBox.java branches/engine_split/src/picross/ui/GameMenuMediator.java branches/engine_split/src/picross/ui/GameMenuModel.java branches/engine_split/src/picross/ui/GameMenuUI.java branches/engine_split/src/picross/ui/MainMenuMediator.java branches/engine_split/src/picross/ui/MainMenuUI.java branches/engine_split/src/picross/ui/MenuCommand.java branches/engine_split/src/picross/ui/MenuController.java branches/engine_split/src/picross/ui/MenuMediator.java branches/engine_split/src/picross/ui/MenuUI.java branches/engine_split/src/picross/ui/MissingImageException.java branches/engine_split/src/picross/ui/PicrossButton.java branches/engine_split/src/picross/ui/PicrossController.java branches/engine_split/src/picross/ui/PicrossLog4jLogger.java branches/engine_split/src/picross/ui/PicrossMediator.java branches/engine_split/src/picross/ui/PicrossUI.java branches/engine_split/src/picross/ui/PicrossUIHelper.java branches/engine_split/src/picross/ui/PicrossView.java branches/engine_split/src/picross/ui/WaitMenuMediator.java branches/engine_split/src/picross/ui/WaitMenuUI.java Modified: branches/engine_split/build.xml =================================================================== --- branches/engine_split/build.xml 2013-01-09 13:32:12 UTC (rev 103) +++ branches/engine_split/build.xml 2013-01-10 09:09:32 UTC (rev 104) @@ -3,6 +3,10 @@ <project name="picross" default="dist"> + <property name="swing.build.dir" + value="swing/build" /> + <property name="common.build.dir" + value="common/build" /> <property name="engine.build.dir" value="engine/build" /> <property name="game.build.dir" @@ -13,6 +17,10 @@ value="doc" /> <property name="lib.dir" value="lib" /> + <property name="swing.src.dir" + value="swing/src" /> + <property name="common.src.dir" + value="common/src" /> <property name="engine.src.dir" value="engine/src" /> <property name="game.src.dir" @@ -22,6 +30,10 @@ <property name="game.test.dir" value="test" /> + <property name="swing.jar.name" + value="${dist.dir}/${ant.project.name}-swing.jar" /> + <property name="common.jar.name" + value="${dist.dir}/${ant.project.name}-common.jar" /> <property name="engine.jar.name" value="${dist.dir}/${ant.project.name}-engine.jar" /> <property name="game.jar.name" @@ -44,6 +56,8 @@ <target name="-init" depends="-setmode"> + <mkdir dir="${swing.build.dir}" /> + <mkdir dir="${common.build.dir}" /> <mkdir dir="${engine.build.dir}" /> <mkdir dir="${game.build.dir}" /> <mkdir dir="${dist.dir}" /> @@ -73,6 +87,8 @@ <path id="classpath"> <pathelement location="${game.build.dir}" /> <pathelement location="${engine.build.dir}" /> + <pathelement location="${common.build.dir}" /> + <pathelement location="${swing.build.dir}" /> <pathelement location="${bundleHelper.jar}" /> <pathelement location="${easymock.jar}" /> @@ -82,6 +98,45 @@ <pathelement location="${simpleButton.jar}" /> </path> + <path id="game-classpath"> + <pathelement location="${game.build.dir}" /> + <pathelement location="${swing.jar.name}" /> + <pathelement location="${common.jar.name}" /> + <pathelement location="${engine.jar.name}" /> + <pathelement location="${bundleHelper.jar}" /> + <pathelement location="${easymock.jar}" /> + <pathelement location="${junit.jar}" /> + <pathelement location="${log4j.jar}" /> + <pathelement location="${mmvcs.jar}" /> + <pathelement location="${simpleButton.jar}" /> + </path> + + <target name="swing-compile" + depends="-init"> + <javac srcdir="${swing.src.dir}" + destdir="${swing.build.dir}" + deprecation="on" + debug="${javac.debug}" + optimize="${javac.optimize}"> + <compilerarg value="-Xlint:all" /> + + <classpath refid="classpath" /> + </javac> + </target> + + <target name="common-compile" + depends="-init"> + <javac srcdir="${common.src.dir}" + destdir="${common.build.dir}" + deprecation="on" + debug="${javac.debug}" + optimize="${javac.optimize}"> + <compilerarg value="-Xlint:all" /> + + <classpath refid="classpath" /> + </javac> + </target> + <target name="engine-compile" depends="-init"> <javac srcdir="${engine.src.dir}" @@ -94,7 +149,7 @@ </target> <target name="game-compile" - depends="-init"> + depends="swing-dist,-init"> <javac srcdir="${game.src.dir}" destdir="${game.build.dir}" deprecation="on" @@ -102,7 +157,7 @@ optimize="${javac.optimize}"> <compilerarg value="-Xlint:all" /> - <classpath refid="classpath" /> + <classpath refid="game-classpath" /> </javac> </target> @@ -138,8 +193,21 @@ basedir="${engine.build.dir}" /> </target> + <target name="swing-dist" + depends="engine-dist,swing-compile"> + <jar destfile="${swing.jar.name}" + basedir="${swing.build.dir}" /> + </target> + + <target name="common-dist" + depends="engine-dist,common-compile"> + <jar destfile="${common.jar.name}" + basedir="${common.build.dir}" + excludes="picross/specific/**" /> + </target> + <target name="dist" - depends="engine-dist,game-compile"> + depends="engine-dist,common-dist,game-compile"> <copy todir="${game.build.dir}/picross/properties" failonerror="false"> <fileset dir="${game.src.dir}/picross/properties" /> @@ -168,6 +236,8 @@ fork="true" dir="."> <classpath> + <pathelement location="${swing.jar.name}" /> + <pathelement location="${common.jar.name}" /> <pathelement location="${engine.jar.name}" /> <pathelement location="${game.jar.name}" /> <pathelement location="${bundleHelper.jar}" /> @@ -185,6 +255,9 @@ fork="true" dir="."> <classpath> + <pathelement location="${swing.jar.name}" /> + <pathelement location="${common.jar.name}" /> + <pathelement location="${engine.jar.name}" /> <pathelement location="${game.jar.name}" /> <pathelement location="${bundleHelper.jar}" /> <pathelement location="${log4j.jar}" /> @@ -239,6 +312,8 @@ </target> <target name="clean"> + <delete dir="${swing.build.dir}" /> + <delete dir="${common.build.dir}" /> <delete dir="${engine.build.dir}" /> <delete dir="${game.build.dir}" /> <delete dir="${dist.dir}" /> Copied: branches/engine_split/common/src/picross/common/Picross.java (from rev 102, branches/engine_split/src/picross/Picross.java) =================================================================== --- branches/engine_split/common/src/picross/common/Picross.java (rev 0) +++ branches/engine_split/common/src/picross/common/Picross.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,95 @@ +/* + * $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.common; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import java.net.URL; + +/** + * Helper class. + * + * @author Y. Norsa + */ +public final class Picross { + /*** Constant ***/ + + /** Data directory. */ + private static final String DATA_DIR = "/picross/data/"; + + /*** Constructor ***/ + + /** Fake constructor. */ + private Picross() { } + + /*** Static methods ***/ + + /** + * Loads a file. + * + * @param path file path + * @return URL of the file + * @throws FileNotFoundException if the file can't be found + */ + public static URL getFile(String path) throws FileNotFoundException { + URL fileUrl = Picross.class.getResource(path); + + if (fileUrl == null) { + throw new FileNotFoundException("\"" + path + "\" can't be found"); + } + + return fileUrl; + } + + /** + * Loads a data file. + * + * @param name filename + * @return a stream containing the loaded file + * @throws IllegalArgumentException if <code>name</code> + * is <code>null</code> or empty + * @throws IOException if there is a problem while opening the file + */ + public static InputStream loadDataFile(String name) throws IOException { + + if (name == null || name.equals("")) { + throw new IllegalArgumentException("name can't be null or empty"); + } + + return Picross.getFile(Picross.DATA_DIR + name).openStream(); + } +} + Copied: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuController.java (from rev 102, branches/engine_split/src/picross/game/simple/ui/LevelMenuController.java) =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuController.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuController.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,107 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.simple.ui; + +import fr.cle.mmvcs.SimpleEvent; + +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; + +import picross.common.game.ui.GameCommand; + +import picross.common.ui.PicrossController; + +import picross.specific.game.simple.ui.LevelMenuUI; + +import picross.specific.ui.MenuController; + +/** + * Controller for the level selection menu. + * + * @author Y. Norsa + */ +public final class LevelMenuController extends MenuController { + /*** Constants ***/ + + /** Command used when selecting a grid size. */ + public static final String SIZE_CMD = "SIZE_CMD"; + + /** Command used to display a levels list. */ + public static final String LEVELS_LIST_CMD = "LEVELS_LIST_CMD"; + + /** Select level command. */ + public static final String LEVEL_CMD = "LEVEL_CMD"; + + /*** Static field ***/ + + /** The class' logger. */ + private static PicrossLogger log = PicrossLogHelper.getLogger(); + + /*** Method overloaded from the class LevelMenuController ***/ + + /** {@inheritDoc} */ + @Override + public void eventPerformed(SimpleEvent e) { + LevelMenuController.log.debug("eventPerformed(" + e + ")"); + + String cmd = e.getCommandName(); + + if (cmd.equals(GameCommand.GAME_CMD)) { + return; + } + + if (cmd.equals(PicrossController.PLAY_CMD)) { + return; + } + + if (cmd.equals(LevelMenuController.LEVELS_LIST_CMD)) { + LevelsListCommand command = (LevelsListCommand) e.getCommand(); + ((LevelMenuUI) this.getView()).displayLevels(this, + command.getList()); + + return; + } + + if (cmd.equals(SizesListCommand.SIZES_CMD)) { + SizesListCommand command = (SizesListCommand) e.getCommand(); + ((LevelMenuUI) this.getView()).displaySizes(this, + command.getSizes()); + + return; + } + + super.eventPerformed(e); + } +} + Copied: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java (from rev 102, branches/engine_split/src/picross/game/simple/ui/LevelMenuMediator.java) =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,140 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.simple.ui; + +import fr.cle.mmvcs.SimpleEvent; + +import java.util.List; + +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; +import picross.engine.PicrossException; + +import picross.common.game.ui.GameCommand; + +import picross.specific.ui.MenuController; +import picross.common.ui.MenuMediator; +import picross.common.ui.PicrossUI; + +import picross.specific.ui.MenuUI; + +import picross.specific.game.simple.ui.LevelMenuUI; + +/** + * Level selection menu. + * + * @author Y. Norsa + */ +public final class LevelMenuMediator extends MenuMediator { + /*** Static field ***/ + + /** The class' logger. */ + private static PicrossLogger log = PicrossLogHelper.getLogger(); + + /*** Field ***/ + + /** Model containing the levels list. */ + private LevelMenuModel model = null; + + /*** Methods overloaded from the class MenuMediator ***/ + + /** {@inheritDoc} */ + @Override + protected MenuController initController() { + MenuController controller = new LevelMenuController(); + this.addSimpleListener(controller); + + return controller; + } + + /** {@inheritDoc} */ + @Override + protected MenuUI initView(PicrossUI ui, MenuController controller) + throws PicrossException { + + LevelMenuMediator.log.debug("initView()"); + + this.model = new LevelMenuModel(); + + LevelMenuMediator.log.debug("this : " + this); + LevelMenuMediator.log.debug("this.model : " + this.model); + + return new LevelMenuUI(controller, this.model.getSizesList()); + } + + /** {@inheritDoc} */ + @Override + public void eventPerformed(SimpleEvent e) { + LevelMenuMediator.log.debug("eventPerformed(" + e + ")"); + LevelMenuMediator.log.debug("this : " + this); + LevelMenuMediator.log.debug("this.model : " + this.model); + + 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(LevelMenuController.LEVEL_CMD)) { + String level = e.getComment(); + this.fireEventPerformed(new + GameCommand(new + SimpleGameMediator(level))); + return; + } + + if (cmd.equals(MenuController.BACK_CMD)) { + this.fireEventPerformed(new SizesListCommand(this.model + .getSizesList())); + return; + } + + super.eventPerformed(e); + } + + /*** Method ***/ + + /** + * Sends a message asking to display the levels list. + * + * @param levels the levels list + */ + private void displayLevels(List<String> levels) { + this.fireEventPerformed(new LevelsListCommand(levels)); + } +} + Copied: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java (from rev 102, branches/engine_split/src/picross/game/simple/ui/LevelMenuModel.java) =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,154 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.simple.ui; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import picross.common.Picross; +import picross.engine.PicrossException; + +import picross.engine.game.simple.Dimensions; +import picross.engine.game.simple.FileInfos; +import picross.engine.game.simple.LevelInfos; + +/** + * Model for the level selection menu. + * + * @author Y. Norsa + */ +final class LevelMenuModel { + /*** Constant ***/ + + /** File containing the data files list. */ + private static final String DATA_LIST = "contents.txt"; + + /*** Field ***/ + + /** Levels list. */ + private Map<Dimensions, List<String>> levels; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @throws PicrossException if an error arises during the levels listing + */ + LevelMenuModel() throws PicrossException { + this.levels = new HashMap<Dimensions, List<String>>(); + + List<LevelInfos> infos = null; + + try { + infos = LevelMenuModel.listDataFiles(); + } catch (IOException ioEx) { + throw new PicrossException(ioEx); + } + + for (LevelInfos info : infos) { + Dimensions levelSize = info.getDimensions(); + List<String> levelsList = this.levels.get(levelSize); + + if (levelsList == null) { + levelsList = new ArrayList<String>(); + this.levels.put(levelSize, levelsList); + } + + levelsList.add(info.getName()); + } + } + + /*** Static method ***/ + + /** + * Reads the data files list and returns informations about the levels. + * + * @return informations about the available levels + * @throws IOException if a problem occurs during the operation + */ + private static List<LevelInfos> listDataFiles() throws IOException { + List<LevelInfos> list = new ArrayList<LevelInfos>(); + + BufferedReader in = null; + + try { + in = new + BufferedReader(new + InputStreamReader(Picross + .loadDataFile(LevelMenuModel + .DATA_LIST))); + + String line = null; + + while ((line = in.readLine()) != null) { + list.add(FileInfos.readFileInfos(line)); + } + } catch (IOException ioEx) { + throw ioEx; + } finally { + in.close(); + } + + return list; + } + + /*** Methods ***/ + + /** + * Returns the available sizes list. + * + * @return list of all the grid sizes + */ + List<Dimensions> getSizesList() { + return new ArrayList<Dimensions>(this.levels.keySet()); + } + + /** + * Returns the list of levels for this size. + * + * @param size desired grid size + * @return list of the corresponding level files + */ + List<String> getLevels(Dimensions size) { + return this.levels.get(size); + } +} + Copied: branches/engine_split/common/src/picross/common/game/simple/ui/LevelsListCommand.java (from rev 101, branches/engine_split/src/picross/game/simple/ui/LevelsListCommand.java) =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelsListCommand.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelsListCommand.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,75 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.simple.ui; + +import fr.cle.mmvcs.NamedCommand; + +import java.util.List; + +/** + * Command containing a levels list. + * + * @author Y. Norsa + */ +final class LevelsListCommand extends NamedCommand { + /*** Field ***/ + + /** List of levels' names. */ + private List<String> list; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param levels levels' names + */ + LevelsListCommand(List<String> levels) { + super(LevelMenuController.LEVELS_LIST_CMD); + + this.list = levels; + } + + /*** Accessor ***/ + + /** + * Return the levels list. + * + * @return list of the levels + */ + List<String> getList() { + return this.list; + } +} + Copied: branches/engine_split/common/src/picross/common/game/simple/ui/SelectSizeCommand.java (from rev 102, branches/engine_split/src/picross/game/simple/ui/SelectSizeCommand.java) =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/SelectSizeCommand.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/SelectSizeCommand.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,75 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.simple.ui; + +import fr.cle.mmvcs.NamedCommand; + +import picross.engine.game.simple.Dimensions; + +/** + * Command used when a grid size has been selected. + * + * @author Y. Norsa + */ +public final class SelectSizeCommand extends NamedCommand { + /*** Field ***/ + + /** The selected grid size. */ + private Dimensions size; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param dim grid size + */ + public SelectSizeCommand(Dimensions dim) { + super(LevelMenuController.SIZE_CMD); + + this.size = dim; + } + + /*** Accessor ***/ + + /** + * Returns the grid size. + * + * @return selected grid size + */ + public Dimensions getSize() { + return this.size; + } +} + Copied: branches/engine_split/common/src/picross/common/game/simple/ui/SimpleGameMediator.java (from rev 102, branches/engine_split/src/picross/game/simple/ui/SimpleGameMediator.java) =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/SimpleGameMediator.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/SimpleGameMediator.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,83 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * 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.common.game.simple.ui; + +import java.io.IOException; + +import picross.common.Picross; +import picross.engine.PicrossException; + +import picross.engine.game.simple.XBMModel; + +import picross.specific.game.ui.GameMediator; + +import picross.engine.grid.PicrossGrid; + +/** + * Mediator for a classic game. + * + * @author Y. Norsa + */ +public final class SimpleGameMediator extends GameMediator { + /*** Field ***/ + + /** Level to load. */ + private String level; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param levelName name of the level + */ + public SimpleGameMediator(String levelName) { + super(); + + this.level = levelName; + } + + /*** Method overloaded from the class GameMediator ***/ + + /** {@inheritDoc} */ + @Override + protected PicrossGrid initModel() throws PicrossException { + try { + return new XBMModel(Picross.loadDataFile(this.level)); + } catch (IOException ioEx) { + throw new PicrossException(ioEx); + } + } +} + Copied: branches/engine_split/common/src/picross/common/game/simple/ui/SizesListCommand.java (from rev 102, branches/engine_split/src/picross/game/simple/ui/SizesListCommand.java) =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/SizesListCommand.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/SizesListCommand.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,82 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.simple.ui; + +import fr.cle.mmvcs.NamedCommand; + +import java.util.List; + +import picross.engine.game.simple.Dimensions; + +/** + * Command used to display the available grid sizes. + * + * @author Y. Norsa + */ +final class SizesListCommand extends NamedCommand { + /*** Constant ***/ + + /** Command used to display the grid sizes. */ + static final String SIZES_CMD = "SIZES_CMD"; + + /*** Field ***/ + + /** The sizes list. */ + private List<Dimensions> sizes; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param sizesList the sizes list + */ + SizesListCommand(List<Dimensions> sizesList) { + super(SizesListCommand.SIZES_CMD); + + this.sizes = sizesList; + } + + /*** Accessor ***/ + + /** + * Return the sizes list. + * + * @return available grid sizes + */ + List<Dimensions> getSizes() { + return this.sizes; + } +} + Copied: branches/engine_split/common/src/picross/common/game/ui/GameCommand.java (from rev 101, branches/engine_split/src/picross/game/ui/GameCommand.java) =================================================================== --- branches/engine_split/common/src/picross/common/game/ui/GameCommand.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/ui/GameCommand.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,80 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.ui; + +import fr.cle.mmvcs.NamedCommand; + +import picross.specific.game.ui.GameMediator; + +/** + * 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; + } +} + Copied: branches/engine_split/common/src/picross/common/game/ui/GameView.java (from rev 102, branches/engine_split/src/picross/game/ui/GameView.java) =================================================================== --- branches/engine_split/common/src/picross/common/game/ui/GameView.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/ui/GameView.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,42 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * 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.common.game.ui; + +import picross.common.ui.PicrossView; + +/** + * @author Y. Norsa + */ +public interface GameView extends PicrossView { } + Copied: branches/engine_split/common/src/picross/common/grid/ui/FillCommand.java (from rev 102, branches/engine_split/src/picross/grid/ui/FillCommand.java) =================================================================== --- branches/engine_split/common/src/picross/common/grid/ui/FillCommand.java (rev 0) +++ branches/engine_split/common/src/picross/common/grid/ui/FillCommand.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,129 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * 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.common.grid.ui; + +import fr.cle.mmvcs.Command; + +import picross.engine.grid.GridAction; + +/** + * Command containing informations about the box to fill. + * + * @author Y. Norsa + */ +public final class FillCommand extends Command { + /*** Fields ***/ + + /** Row of the box to fill. */ + private int row; + + /** Column of the box to fill. */ + private int column; + + /** Type of the action. */ + //private int type; + private GridAction type; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @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) { + public 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; + } + + /*** Method overloaded from the class Command ***/ + + /** {@inheritDoc} */ + @Override + public String toString() { + return this.row + "," + this.column; + } + + /*** Accessors ***/ + + /** + * Returns the row. + * + * @return row of the box to fill + */ + public int getRow() { + return this.row; + } + + /** + * Returns the column. + * + * @return column of the box to fill + */ + public int getColumn() { + return this.column; + } + + /** + * Return the type. + * + * @return type of the action + */ + //int getType() { + public GridAction getType() { + return this.type; + } +} + Added: branches/engine_split/common/src/picross/common/grid/ui/GridCommands.java =================================================================== --- branches/engine_split/common/src/picross/common/grid/ui/GridCommands.java (rev 0) +++ branches/engine_split/common/src/picross/common/grid/ui/GridCommands.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,36 @@ +/* + * $Id$ + */ + + +package picross.common.grid.ui; + +public final class GridCommands { + /*** Constants ***/ + + /** Fill command. */ + public static final String FILL_CMD = "FILL_CMD"; + + /** Command indicating the grid is filled. */ + public static final String GRID_FILLED_CMD = "GRID_FILLED_CMD"; + + /** Command indicating the action has reached its end. */ + public static final String END_ACTION_CMD = "END_ACTION_CMD"; + + /** Command asking to repaint part of the grid. */ + public static final String PAINT_CMD = "PAINT_CMD"; + + /** Command indicating that a hint has been completed. */ + public static final String COMPLETED_CMD = "COMPLETED_CMD"; + + /** Command asking to repaint the top hints. */ + public static final String REPAINT_TOP_HINTS_CMD = "REPAINT_TOP_HINTS_CMD"; + + /** Command asking to repaint the left hints. */ + public static final String REPAINT_LEFT_HINTS_CMD = "REPAINT_LEFT_HINTS_CMD"; + + /** Command asking to enable the Erase mode. */ + public static final String ERASE_MODE_CMD = "ERASE_MODE_CMD"; + + private GridCommands() { } +} Property changes on: branches/engine_split/common/src/picross/common/grid/ui/GridCommands.java ___________________________________________________________________ Added: svn:keywords + Id Copied: branches/engine_split/common/src/picross/common/grid/ui/GridView.java (from rev 101, branches/engine_split/src/picross/grid/ui/GridView.java) =================================================================== --- branches/engine_split/common/src/picross/common/grid/ui/GridView.java (rev 0) +++ branches/engine_split/common/src/picross/common/grid/ui/GridView.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,41 @@ +/* + * $Id$ + * + * Copyright (c) 2011 + * + * 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.common.grid.ui; + +/** + * @author Y. Norsa + */ +public interface GridView { } + + Copied: branches/engine_split/common/src/picross/common/grid/ui/IGridMediator.java (from rev 101, branches/engine_split/src/picross/grid/ui/IGridMediator.java) =================================================================== --- branches/engine_split/common/src/picross/common/grid/ui/IGridMediator.java (rev 0) +++ branches/engine_split/common/src/picross/common/grid/ui/IGridMediator.java 2013-01-10 09:09:32 UTC (rev 104) @@ -0,0 +1,71 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * 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.common.grid.ui; + +import fr.cle.mmvcs.IMediateur; + +/** + * Mediator for the grid. + * + * @author Y. Norsa + */ +public interface IGridMediator extends IMediateur { + /** + * Asks to repaint a box. + * + * @param row row number of the box + * @param column column number of the box + */ + ... [truncated message content] |
From: <yva...@us...> - 2013-01-09 13:32:22
|
Revision: 103 http://picross.svn.sourceforge.net/picross/?rev=103&view=rev Author: yvan_norsa Date: 2013-01-09 13:32:12 +0000 (Wed, 09 Jan 2013) Log Message: ----------- split tests Modified Paths: -------------- branches/engine_split/build.xml branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java branches/engine_split/engine/test/picross/engine/game/random/RandomPicrossModelTest.java branches/engine_split/engine/test/picross/engine/game/simple/XBMModelTest.java branches/engine_split/test/picross/grid/ui/FillCommandTest.java branches/engine_split/test/picross/grid/ui/IGridMediatorStub.java branches/engine_split/test/picross/grid/ui/UIBoxTest.java Added Paths: ----------- branches/engine_split/engine/test/ branches/engine_split/engine/test/picross/ branches/engine_split/engine/test/picross/engine/ branches/engine_split/engine/test/picross/engine/game/ branches/engine_split/engine/test/picross/engine/grid/ branches/engine_split/engine/test/picross/engine/grid/AbstractPicrossGridTest.java branches/engine_split/engine/test/picross/engine/grid/BoxTest.java branches/engine_split/engine/test/picross/engine/grid/CompletedHintsTest.java branches/engine_split/engine/test/picross/engine/grid/GridModelIntegrationTest.java branches/engine_split/engine/test/picross/engine/grid/GridModelTest.java Removed Paths: ------------- branches/engine_split/test/picross/game/ branches/engine_split/test/picross/grid/AbstractPicrossGridTest.java branches/engine_split/test/picross/grid/BoxTest.java branches/engine_split/test/picross/grid/CompletedHintsTest.java branches/engine_split/test/picross/grid/GridModelIntegrationTest.java branches/engine_split/test/picross/grid/GridModelTest.java Modified: branches/engine_split/build.xml =================================================================== --- branches/engine_split/build.xml 2013-01-09 13:16:40 UTC (rev 102) +++ branches/engine_split/build.xml 2013-01-09 13:32:12 UTC (rev 103) @@ -17,6 +17,8 @@ value="engine/src" /> <property name="game.src.dir" value="src" /> + <property name="engine.test.dir" + value="engine/test" /> <property name="game.test.dir" value="test" /> @@ -70,8 +72,8 @@ <path id="classpath"> <pathelement location="${game.build.dir}" /> + <pathelement location="${engine.build.dir}" /> - <pathelement location="${engine.jar.name}" /> <pathelement location="${bundleHelper.jar}" /> <pathelement location="${easymock.jar}" /> <pathelement location="${junit.jar}" /> @@ -104,7 +106,20 @@ </javac> </target> - <target name="compile-test" + <target name="engine-compile-test" + depends="engine-compile"> + <javac srcdir="${engine.test.dir}" + destdir="${engine.build.dir}" + deprecation="on" + debug="on" + optimize="off"> + <compilerarg value="-Xlint:all" /> + + <classpath refid="classpath" /> + </javac> + </target> + + <target name="game-compile-test" depends="game-compile"> <javac srcdir="${game.test.dir}" destdir="${game.build.dir}" @@ -181,7 +196,10 @@ </target> <target name="test" - depends="dist,compile-test"> + depends="engine-test,game-test" /> + + <target name="engine-test" + depends="dist,engine-compile-test"> <junit filtertrace="off" showoutput="on" printsummary="withOutAndErr"> @@ -190,6 +208,26 @@ <batchtest fork="yes" filtertrace="on"> + <fileset dir="${engine.test.dir}"> + <include name="**/*Test.java" /> + <exclude name="**/Abstract*Test.java" /> + </fileset> + </batchtest> + + <classpath refid="classpath" /> + </junit> + </target> + + <target name="game-test" + depends="dist,game-compile-test"> + <junit filtertrace="off" + showoutput="on" + printsummary="withOutAndErr"> + <formatter type="plain" + usefile="false" /> + + <batchtest fork="yes" + filtertrace="on"> <fileset dir="${game.test.dir}"> <include name="**/*Test.java" /> <exclude name="**/Abstract*Test.java" /> Modified: branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java =================================================================== --- branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java 2013-01-09 13:16:40 UTC (rev 102) +++ branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java 2013-01-09 13:32:12 UTC (rev 103) @@ -34,7 +34,7 @@ package picross.engine; public final class PicrossLogHelper { - private static PicrossLogger logger; + private static PicrossLogger logger = new DefaultPicrossLogger(); public static PicrossLogger getLogger() { return PicrossLogHelper.logger; @@ -45,4 +45,21 @@ } private PicrossLogHelper() { } + + private static final class DefaultPicrossLogger implements PicrossLogger { + @Override + public void debug(String msg) { + System.out.println("DEBUG " + msg); + } + + @Override + public void info(String msg) { + System.out.println("INFO " + msg); + } + + @Override + public void error(String msg) { + System.out.println("ERROR " + msg); + } + } } Modified: branches/engine_split/engine/test/picross/engine/game/random/RandomPicrossModelTest.java =================================================================== --- branches/engine_split/test/picross/game/random/RandomPicrossModelTest.java 2013-01-09 11:54:44 UTC (rev 101) +++ branches/engine_split/engine/test/picross/engine/game/random/RandomPicrossModelTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -31,14 +31,14 @@ */ -package picross.game.random; +package picross.engine.game.random; import org.apache.log4j.PropertyConfigurator; import org.junit.Test; -import picross.grid.AbstractPicrossGridTest; -import picross.grid.PicrossGrid; +import picross.engine.grid.AbstractPicrossGridTest; +import picross.engine.grid.PicrossGrid; /** * Test class for the random model. Modified: branches/engine_split/engine/test/picross/engine/game/simple/XBMModelTest.java =================================================================== --- branches/engine_split/test/picross/game/simple/XBMModelTest.java 2013-01-09 11:54:44 UTC (rev 101) +++ branches/engine_split/engine/test/picross/engine/game/simple/XBMModelTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -31,7 +31,7 @@ */ -package picross.game.simple; +package picross.engine.game.simple; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -43,11 +43,12 @@ import org.junit.Test; import picross.Picross; -import picross.PicrossException; -import picross.grid.AbstractPicrossGridTest; -import picross.grid.PicrossGrid; +import picross.engine.PicrossException; +import picross.engine.grid.AbstractPicrossGridTest; +import picross.engine.grid.PicrossGrid; + /** * Unit tests for XBMModel. * Copied: branches/engine_split/engine/test/picross/engine/grid/AbstractPicrossGridTest.java (from rev 101, branches/engine_split/test/picross/grid/AbstractPicrossGridTest.java) =================================================================== --- branches/engine_split/engine/test/picross/engine/grid/AbstractPicrossGridTest.java (rev 0) +++ branches/engine_split/engine/test/picross/engine/grid/AbstractPicrossGridTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -0,0 +1,112 @@ +/* + * $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.engine.grid; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Abstract test class for the PicrossGrid interface. + * + * @author Y. Norsa + */ +public abstract class AbstractPicrossGridTest { + /*** Field ***/ + + /** The instance to test. */ + private PicrossGrid picrossGrid = null; + + /*** Abstract method ***/ + + /** + * Returns an instance. + * + * @return instance to test + */ + protected abstract PicrossGrid getPicrossGrid(); + + /*** Methods ***/ + + /** Performs the instance initialisation. */ + @Before + public void setUp() { + this.picrossGrid = this.getPicrossGrid(); + } + + /** Tests the method getWidth(). */ + @Test + public void testGetWidth() { + int width = this.picrossGrid.getWidth(); + Assert.assertTrue("width = " + width, (width > 0)); + } + + /** Tests the method getHeight(). */ + @Test + public void testGetHeight() { + int height = this.picrossGrid.getHeight(); + Assert.assertTrue("height = " + height, (height > 0)); + } + + /** Tests the method getData(). */ + @Test + public void testGetData() { + boolean[][] data = this.picrossGrid.getData(); + Assert.assertNotNull("data = null", data); + + int width = this.picrossGrid.getWidth(); + int height = this.picrossGrid.getHeight(); + + Assert.assertEquals("data.length = " + data.length, + width, data.length); + + for (int i = 0; i < width; i++) { + Assert.assertEquals("data[" + i + "].length = " + data[i].length, + height, data[i].length); + } + + boolean atLeastOneCheckedBox = false; + + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { + if (data[i][j]) { + atLeastOneCheckedBox = true; + break; + } + } + } + + Assert.assertTrue("Empty grid", atLeastOneCheckedBox); + } +} Copied: branches/engine_split/engine/test/picross/engine/grid/BoxTest.java (from rev 101, branches/engine_split/test/picross/grid/BoxTest.java) =================================================================== --- branches/engine_split/engine/test/picross/engine/grid/BoxTest.java (rev 0) +++ branches/engine_split/engine/test/picross/engine/grid/BoxTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -0,0 +1,106 @@ +/* + * $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.engine.grid; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class BoxTest { + private Box box = null; + + @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 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()); + } +} + Copied: branches/engine_split/engine/test/picross/engine/grid/CompletedHintsTest.java (from rev 101, branches/engine_split/test/picross/grid/CompletedHintsTest.java) =================================================================== --- branches/engine_split/engine/test/picross/engine/grid/CompletedHintsTest.java (rev 0) +++ branches/engine_split/engine/test/picross/engine/grid/CompletedHintsTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -0,0 +1,190 @@ +/* + * $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.engine.grid; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class CompletedHintsTest { + CompletedHints hints = null; + + @Before + public void setUp() { + this.hints = new CompletedHints(10, 10, 10, 10); + } + + @Test(expected = IllegalArgumentException.class) + public void negColWidth() { + new CompletedHints(-1, 1, 1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void zeroColWidth() { + new CompletedHints(0, 1, 1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void negColHeight() { + new CompletedHints(1, -1, 1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void zeroColHeight() { + new CompletedHints(1, 0, 1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void negRowWidth() { + new CompletedHints(1, 1, -1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void zeroRowWidth() { + new CompletedHints(1, 1, 0, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void negRowHeight() { + new CompletedHints(1, 1, 1, -1); + } + + @Test(expected = IllegalArgumentException.class) + public void zeroRowHeight() { + new CompletedHints(1, 1, 1, 0); + } + + @Test + public void completedHints() { + new CompletedHints(1, 1, 1, 1); + } + + @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(expected = IllegalArgumentException.class) + public void getOutsideColHint() { + this.hints.getCompleteColHints(-1); + } + + @Test(expected = IllegalArgumentException.class) + public void getTooHighColHint() { + this.hints.getCompleteColHints(42); + } + + @Test + public void testGetCompleteColHints() { + 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(expected = IllegalArgumentException.class) + public void getOutsideRowHint() { + this.hints.getCompleteRowHints(-1); + } + + @Test(expected = IllegalArgumentException.class) + public void getTooHighRowHint() { + this.hints.getCompleteRowHints(42); + } + + @Test + public void testGetCompleteRowHints() { + 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)); + } +} + Copied: branches/engine_split/engine/test/picross/engine/grid/GridModelIntegrationTest.java (from rev 101, branches/engine_split/test/picross/grid/GridModelIntegrationTest.java) =================================================================== --- branches/engine_split/engine/test/picross/engine/grid/GridModelIntegrationTest.java (rev 0) +++ branches/engine_split/engine/test/picross/engine/grid/GridModelIntegrationTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -0,0 +1,325 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * 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.engine.grid; + +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; + +import org.easymock.EasyMock; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class GridModelIntegrationTest { + private static Logger log = Logger.getLogger(GridModelIntegrationTest.class); + + /*** Static initialisation block. Loads a valid XBM file. ***/ + static { + PropertyConfigurator.configure("log4j.properties"); + } + + @Test + public void gameSession() { + GridModel gridModel = + new GridModel(new boolean[][] { +{false, false, true, false, false, false, false, true, true, false, true, true}, +{true, false, false, true, false, true, true, true, true, true, false, true}, +{false, false, false, false, false, false, true, false, true, true, false, false}, +{true, false, true, true, false, true, false, false, false, true, true, false}, +{true, true, false, true, true, false, true, false, true, false, false, true}, +{false, false, true, false, false, true, true, false, false, true, true, true}, +{true, true, true, false, true, true, true, false, true, true, false, true}, +{true, false, false, true, true, true, false, true, true, true, true, false}, +{true, false, true, true, false, true, true, false, false, false, true, false}, +{false, false, false, false, false, true, true, true, true, true, false, true}, +{false, true, true, true, false, false, true, true, false, false, false, true}, +{true, true, false, true, true, true, true, true, true, true, true, true}}); + + int[][] hints = gridModel.getRowData(); + + Assert.assertArrayEquals(new int[] {GridModel.EMPTY_HINT, 1, 1, 5, 1}, + hints[5]); + + gridModel.actOnBox(0, 0, GridAction.CROSS); + gridModel.actOnBox(0, 1, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 0, 1); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 1, 3); + gridModel.actOnBox(0, 2, GridAction.CROSS); + gridModel.actOnBox(0, 3, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 3, 3); + gridModel.actOnBox(0, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 0, 2); + gridModel.actOnBox(0, 5, GridAction.CROSS); + gridModel.actOnBox(0, 6, GridAction.CHECK); + gridModel.actOnBox(0, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 7, 2); + gridModel.actOnBox(0, 8, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 0, 3); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 8, 3); + gridModel.actOnBox(0, 9, GridAction.CROSS); + gridModel.actOnBox(0, 10, GridAction.CROSS); + gridModel.actOnBox(0, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 0, 4); + + gridModel.actOnBox(1, 0, GridAction.CROSS); + gridModel.actOnBox(1, 1, GridAction.CROSS); + gridModel.actOnBox(1, 2, GridAction.CROSS); + gridModel.actOnBox(1, 3, GridAction.CROSS); + gridModel.actOnBox(1, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 1, 2); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 4, 4); + gridModel.actOnBox(1, 5, GridAction.CROSS); + gridModel.actOnBox(1, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 1, 3); + gridModel.actOnBox(1, 7, GridAction.CROSS); + gridModel.actOnBox(1, 8, GridAction.CROSS); + gridModel.actOnBox(1, 9, GridAction.CROSS); + gridModel.actOnBox(1, 10, GridAction.CHECK); + gridModel.actOnBox(1, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 1, 4); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 11, 1); + + //gridModel.actOnBox(2, 0, GridAction.EMPTY); + //gridModel.actOnBox(2, 1, GridAction.EMPTY); + gridModel.actOnBox(2, 2, GridAction.CROSS); + gridModel.actOnBox(2, 3, GridAction.CHECK); + gridModel.actOnBox(2, 4, GridAction.CROSS); + gridModel.actOnBox(2, 5, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 5, 2); + gridModel.actOnBox(2, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 6, 3); + gridModel.actOnBox(2, 7, GridAction.CROSS); + gridModel.actOnBox(2, 8, GridAction.CHECK); + gridModel.actOnBox(2, 9, GridAction.CROSS); + gridModel.actOnBox(2, 10, GridAction.CHECK); + gridModel.actOnBox(2, 11, GridAction.CROSS); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 2, 1); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 2, 2); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 2, 3); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 2, 4); + + //gridModel.actOnBox(3, 0, GridAction.EMPTY); + //gridModel.actOnBox(3, 1, GridAction.EMPTY); + gridModel.actOnBox(3, 2, GridAction.CROSS); + gridModel.actOnBox(3, 3, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 3, 2); + gridModel.actOnBox(3, 4, GridAction.CHECK); + gridModel.actOnBox(3, 5, GridAction.CROSS); + gridModel.actOnBox(3, 6, GridAction.CROSS); + gridModel.actOnBox(3, 7, GridAction.CHECK); + gridModel.actOnBox(3, 8, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 8, 2); + gridModel.actOnBox(3, 9, GridAction.CROSS); + gridModel.actOnBox(3, 10, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 10, 2); + gridModel.actOnBox(3, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 3, 2); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 3, 3); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 3, 4); + + gridModel.actOnBox(4, 0, GridAction.CROSS); + gridModel.actOnBox(4, 1, GridAction.CROSS); + gridModel.actOnBox(4, 2, GridAction.CROSS); + gridModel.actOnBox(4, 3, GridAction.CROSS); + gridModel.actOnBox(4, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 4, 2); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 4, 3); + gridModel.actOnBox(4, 5, GridAction.CROSS); + gridModel.actOnBox(4, 6, GridAction.CHECK); + gridModel.actOnBox(4, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 4, 3); + gridModel.actOnBox(4, 8, GridAction.CROSS); + gridModel.actOnBox(4, 9, GridAction.CROSS); + gridModel.actOnBox(4, 10, GridAction.CROSS); + gridModel.actOnBox(4, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 4, 4); + + gridModel.actOnBox(5, 0, GridAction.CROSS); + gridModel.actOnBox(5, 1, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 5, 1); + gridModel.actOnBox(5, 2, GridAction.CROSS); + gridModel.actOnBox(5, 3, GridAction.CROSS); + gridModel.actOnBox(5, 4, GridAction.CROSS); + gridModel.actOnBox(5, 6, GridAction.CHECK); + gridModel.actOnBox(5, 7, GridAction.CHECK); + gridModel.actOnBox(5, 8, GridAction.CHECK); + gridModel.actOnBox(5, 9, GridAction.CHECK); + gridModel.actOnBox(5, 10, GridAction.CROSS); + gridModel.actOnBox(5, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 5, 4); + + gridModel.actOnBox(6, 0, GridAction.CROSS); + gridModel.actOnBox(6, 1, GridAction.CHECK); + gridModel.actOnBox(6, 2, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 6, 2); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 2, 1); + gridModel.actOnBox(6, 3, GridAction.CROSS); + gridModel.actOnBox(6, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 4, 2); + gridModel.actOnBox(6, 5, GridAction.CHECK); + gridModel.actOnBox(6, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 6, 3); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 7, 2); + gridModel.actOnBox(6, 7, GridAction.CROSS); + gridModel.actOnBox(6, 8, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 8, 1); + gridModel.actOnBox(6, 9, GridAction.CHECK); + gridModel.actOnBox(6, 10, GridAction.CHECK); + gridModel.actOnBox(6, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 6, 4); + + gridModel.actOnBox(7, 0, GridAction.CHECK); + gridModel.actOnBox(7, 1, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 7, 2); + gridModel.actOnBox(7, 2, GridAction.CROSS); + gridModel.actOnBox(7, 3, GridAction.CROSS); + gridModel.actOnBox(7, 4, GridAction.CROSS); + gridModel.actOnBox(7, 5, GridAction.CROSS); + gridModel.actOnBox(7, 6, GridAction.CROSS); + gridModel.actOnBox(7, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 7, 3); + gridModel.actOnBox(7, 8, GridAction.CROSS); + gridModel.actOnBox(7, 9, GridAction.CHECK); + gridModel.actOnBox(7, 10, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 10, 1); + gridModel.actOnBox(7, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 7, 4); + + gridModel.actOnBox(8, 0, GridAction.CHECK); + gridModel.actOnBox(8, 1, GridAction.CHECK); + gridModel.actOnBox(8, 2, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 0); + gridModel.actOnBox(8, 3, GridAction.CROSS); + gridModel.actOnBox(8, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 1); + gridModel.actOnBox(8, 5, GridAction.CROSS); + gridModel.actOnBox(8, 6, GridAction.CHECK); + gridModel.actOnBox(8, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 2); + gridModel.actOnBox(8, 8, GridAction.CROSS); + gridModel.actOnBox(8, 9, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 3); + gridModel.actOnBox(8, 10, GridAction.CROSS); + gridModel.actOnBox(8, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 4); + + gridModel.actOnBox(9, 0, GridAction.CROSS); + gridModel.actOnBox(9, 1, GridAction.CHECK); + gridModel.actOnBox(9, 2, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 2, 0); + gridModel.actOnBox(9, 3, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 9, 1); + gridModel.actOnBox(9, 4, GridAction.CROSS); + gridModel.actOnBox(9, 5, GridAction.CHECK); + gridModel.actOnBox(9, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 6, 1); + gridModel.actOnBox(9, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 9, 2); + gridModel.actOnBox(9, 8, GridAction.CROSS); + gridModel.actOnBox(9, 9, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 9, 3); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 9, 1); + gridModel.actOnBox(9, 10, GridAction.CROSS); + gridModel.actOnBox(9, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 9, 4); + + gridModel.actOnBox(10, 0, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 10, 0); + gridModel.actOnBox(10, 1, GridAction.CROSS); + gridModel.actOnBox(10, 2, GridAction.CROSS); + gridModel.actOnBox(10, 3, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 10, 1); +// CHECK +//GridModelIntegrationTest.ensureColHintComplete(gridModel, 3, 0); + gridModel.actOnBox(10, 4, GridAction.CROSS); + gridModel.actOnBox(10, 5, GridAction.CHECK); + gridModel.actOnBox(10, 6, GridAction.CROSS); + gridModel.actOnBox(10, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 7, 0); + gridModel.actOnBox(10, 8, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 8, 0); + gridModel.actOnBox(10, 9, GridAction.CROSS); + gridModel.actOnBox(10, 10, GridAction.CROSS); + gridModel.actOnBox(10, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 10, 3); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 10, 4); + + gridModel.actOnBox(11, 0, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 0, 0); + gridModel.actOnBox(11, 1, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 11, 2); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 1, 0); + gridModel.actOnBox(11, 2, GridAction.CROSS); + gridModel.actOnBox(11, 3, GridAction.CROSS); + gridModel.actOnBox(11, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 4, 0); + gridModel.actOnBox(11, 5, GridAction.CHECK); + gridModel.actOnBox(11, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 11, 3); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 6, 0); + gridModel.actOnBox(11, 7, GridAction.CROSS); + gridModel.actOnBox(11, 8, GridAction.CROSS); + gridModel.actOnBox(11, 9, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 9, 0); + gridModel.actOnBox(11, 10, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 10, 0); + gridModel.actOnBox(11, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 11, 4); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 11, 0); + + gridModel.actOnBox(5, 5, GridAction.CHECK); + CompletedHints completedHints = gridModel.getCompletedHints(); + Assert.assertFalse(completedHints.isRowHintComplete(5, 1)); + Assert.assertTrue(completedHints.isRowHintComplete(5, 2)); + Assert.assertTrue(completedHints.isRowHintComplete(5, 3)); + Assert.assertTrue(completedHints.isRowHintComplete(5, 4)); + } + + private static void ensureRowHintComplete(GridModel model, int row, + int hintIndex) { + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isRowHintComplete(row, hintIndex)); + } + + private static void ensureColHintComplete(GridModel model, int col, + int hintIndex) { + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isColHintComplete(col, hintIndex)); + } +} + Copied: branches/engine_split/engine/test/picross/engine/grid/GridModelTest.java (from rev 101, branches/engine_split/test/picross/grid/GridModelTest.java) =================================================================== --- branches/engine_split/engine/test/picross/engine/grid/GridModelTest.java (rev 0) +++ branches/engine_split/engine/test/picross/engine/grid/GridModelTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -0,0 +1,269 @@ +/* + * $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.engine.grid; + +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; + +import org.easymock.EasyMock; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class GridModelTest { + private static Logger log = Logger.getLogger(GridModelTest.class); + + private GridModel model = null; + + /*** Static initialisation block. Loads a valid XBM file. ***/ + static { + PropertyConfigurator.configure("log4j.properties"); + } + + @Before + public void setUp() { + this.model = new GridModel(/*new IGridMediatorStub(),*/ new boolean[3][5]); + } + /* + @Test(expected = IllegalArgumentException.class) + public void gridModelWithNullMediator() { + new GridModel(null, new boolean[1][1]); + } + */ + @Test(expected = IllegalArgumentException.class) + public void gridModelWithNullData() { + new GridModel(/*new IGridMediatorStub(),*/ null); + } + + @Test(expected = IllegalArgumentException.class) + public void gridModelWithEmptyData() { + new GridModel(/*new IGridMediatorStub(),*/ new boolean[0][0]); + } + + @Test(expected = IllegalArgumentException.class) + public void gridModelWithoutRows() { + new GridModel(/*new IGridMediatorStub(),*/ new boolean[1][0]); + } + + @Test(expected = IllegalArgumentException.class) + public void gridModelWithoutCols() { + new GridModel(/*new IGridMediatorStub(),*/ new boolean[0][1]); + } + + @Test + public void checkValidModel() { + GridModel model = new GridModel(new boolean[][] {{true, false, false}, + {false, true, false}}); + Assert.assertFalse(model.checkCompleted()); + + Box[][] boxes = model.getBoxes(); + Assert.assertEquals(2, boxes.length); + Assert.assertEquals(3, boxes[0].length); + Assert.assertEquals(3, boxes[1].length); + + for (Box[] row : boxes) { + for (Box box : row) { + Assert.assertTrue(box.isEmpty()); + } + } + + int[][] colData = model.getColData(); + Assert.assertEquals(2, colData.length); + Assert.assertEquals(1, colData[0].length); + Assert.assertEquals(1, colData[0][0]); + Assert.assertEquals(1, colData[1].length); + Assert.assertEquals(1, colData[1][0]); + + int[][] rowData = model.getRowData(); + Assert.assertEquals(3, rowData.length); + Assert.assertEquals(1, rowData[0].length); + Assert.assertEquals(1, rowData[0][0]); + Assert.assertEquals(1, rowData[1].length); + Assert.assertEquals(1, rowData[1][0]); + Assert.assertEquals(1, rowData[2].length); + Assert.assertEquals(0, rowData[2][0]); + } + + @Test + public void checkModelWithDifferentNumberOfHints() { + GridModel model = new GridModel(new boolean[][] {{false, false, false, false}, + {true, false, true, true}, + {false, true, false, false}}); + int[][] colData = model.getColData(); + Assert.assertEquals(3, colData.length); + Assert.assertEquals(2, colData[0].length); + Assert.assertEquals(0, colData[0][0]); + Assert.assertEquals(GridModel.EMPTY_HINT, colData[0][1]); + Assert.assertEquals(2, colData[1].length); + Assert.assertEquals(2, colData[1][0]); + Assert.assertEquals(1, colData[1][1]); + Assert.assertEquals(2, colData[2].length); + Assert.assertEquals(1, colData[2][0]); + Assert.assertEquals(GridModel.EMPTY_HINT, colData[2][1]); + + int[][] rowData = model.getRowData(); + Assert.assertEquals(4, rowData.length); + Assert.assertEquals(1, rowData[0].length); + Assert.assertEquals(1, rowData[0][0]); + Assert.assertEquals(1, rowData[1].length); + Assert.assertEquals(1, rowData[1][0]); + Assert.assertEquals(1, rowData[2].length); + Assert.assertEquals(1, rowData[2][0]); + Assert.assertEquals(1, rowData[3].length); + Assert.assertEquals(1, rowData[3][0]); + } + + @Test + public void checkRowHintsInCorrectOrder() { + GridModel model = new GridModel(new boolean[][]{{true},{false},{true},{true}}); + int[][] rowData = model.getRowData(); + Assert.assertEquals(1, rowData.length); + Assert.assertEquals(2, rowData[0].length); + Assert.assertEquals(1, rowData[0][0]); + Assert.assertEquals(2, rowData[0][1]); + } + + @Test + public void checkColHintsInReverseOrder() { + GridModel model = new GridModel(new boolean[][]{{true, false, true, true}}); + int[][] colData = model.getColData(); + Assert.assertEquals(1, colData.length); + Assert.assertEquals(2, colData[0].length); + Assert.assertEquals(2, colData[0][0]); + Assert.assertEquals(1, colData[0][1]); + } + + @Test + public void checkEmptyRowsAreComplete() { + GridModel model = new GridModel(new boolean[][] {{false, false}, + {true, false}}); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isRowHintComplete(1, 0)); + } + + @Test + public void checkEmptyColsAreComplete() { + GridModel model = new GridModel(new boolean[][] {{false}, + {true}}); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isColHintComplete(0, 0)); + } + + @Test + public void checkEmptyRowHintIsComplete() { + GridModel model = new GridModel(new boolean[][] {{true, false}, + {false, false}, + {true, true}}); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isRowHintComplete(1, 0)); + } + + @Test + public void checkEmptyColHintIsComplete() { + GridModel model = new GridModel(new boolean[][] {{true, false, true}, + {false, false, true}}); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isColHintComplete(1, 1)); + } + + @Test + public void checkRowHintsCorrectlyUpdate() { + GridModel model = new GridModel(new boolean[][] {{true}, {false}}); + model.actOnBox(0, 0, GridAction.CHECK); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isRowHintComplete(0, 0)); + model.actOnBox(0, 1, GridAction.CHECK); + completedHints = model.getCompletedHints(); + Assert.assertFalse(completedHints.isRowHintComplete(0, 0)); + } + + @Test + public void checkColHintsCorrectlyUpdate() { + GridModel model = new GridModel(new boolean[][] {{true, false}}); + model.actOnBox(0, 0, GridAction.CHECK); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isColHintComplete(0, 0)); + model.actOnBox(1, 0, GridAction.CHECK); + completedHints = model.getCompletedHints(); + Assert.assertFalse(completedHints.isColHintComplete(0, 0)); + } + + @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); + } + + @Test + public void allHintsAreNotOK() { + GridModel gridModel = new GridModel(new boolean[][] {{false, true}, {true, false}, {false, true}, {true, false}, {false, true}, {true, false}, {true, true}, {true, false}, {true, true}, {true, false}, {false, false}, {true, false}}); + gridModel.actOnBox(0, 0, GridAction.CROSS); + gridModel.actOnBox(0, 1, GridAction.CHECK); + gridModel.actOnBox(0, 2, GridAction.CROSS); + gridModel.actOnBox(0, 3, GridAction.CROSS); + gridModel.actOnBox(0, 4, GridAction.CROSS); + gridModel.actOnBox(0, 5, GridAction.CHECK); + gridModel.actOnBox(0, 6, GridAction.CHECK); + gridModel.actOnBox(0, 7, GridAction.CHECK); + gridModel.actOnBox(0, 8, GridAction.CHECK); + gridModel.actOnBox(0, 9, GridAction.CHECK); + gridModel.actOnBox(0, 10, GridAction.CROSS); + gridModel.actOnBox(0, 11, GridAction.CHECK); + + int[][] hints = gridModel.getRowData(); + + Assert.assertArrayEquals(new int[] {GridModel.EMPTY_HINT, 1, 1, 5, 1}, + hints[0]); + + CompletedHints completedHints = gridModel.getCompletedHints(); + Assert.assertFalse(completedHints.isRowHintComplete(0, 1)); + Assert.assertTrue(completedHints.isRowHintComplete(0, 2)); + Assert.assertTrue(completedHints.isRowHintComplete(0, 3)); + Assert.assertTrue(completedHints.isRowHintComplete(0, 4)); + } +} + Deleted: branches/engine_split/test/picross/grid/AbstractPicrossGridTest.java =================================================================== --- branches/engine_split/test/picross/grid/AbstractPicrossGridTest.java 2013-01-09 13:16:40 UTC (rev 102) +++ branches/engine_split/test/picross/grid/AbstractPicrossGridTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -1,112 +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.grid; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * Abstract test class for the PicrossGrid interface. - * - * @author Y. Norsa - */ -public abstract class AbstractPicrossGridTest { - /*** Field ***/ - - /** The instance to test. */ - private PicrossGrid picrossGrid = null; - - /*** Abstract method ***/ - - /** - * Returns an instance. - * - * @return instance to test - */ - protected abstract PicrossGrid getPicrossGrid(); - - /*** Methods ***/ - - /** Performs the instance initialisation. */ - @Before - public void setUp() { - this.picrossGrid = this.getPicrossGrid(); - } - - /** Tests the method getWidth(). */ - @Test - public void testGetWidth() { - int width = this.picrossGrid.getWidth(); - Assert.assertTrue("width = " + width, (width > 0)); - } - - /** Tests the method getHeight(). */ - @Test - public void testGetHeight() { - int height = this.picrossGrid.getHeight(); - Assert.assertTrue("height = " + height, (height > 0)); - } - - /** Tests the method getData(). */ - @Test - public void testGetData() { - boolean[][] data = this.picrossGrid.getData(); - Assert.assertNotNull("data = null", data); - - int width = this.picrossGrid.getWidth(); - int height = this.picrossGrid.getHeight(); - - Assert.assertEquals("data.length = " + data.length, - width, data.length); - - for (int i = 0; i < width; i++) { - Assert.assertEquals("data[" + i + "].length = " + data[i].length, - height, data[i].length); - } - - boolean atLeastOneCheckedBox = false; - - for (int i = 0; i < width; i++) { - for (int j = 0; j < height; j++) { - if (data[i][j]) { - atLeastOneCheckedBox = true; - break; - } - } - } - - Assert.assertTrue("Empty grid", atLeastOneCheckedBox); - } -} Deleted: branches/engine_split/test/picross/grid/BoxTest.java =================================================================== --- branches/engine_split/test/picross/grid/BoxTest.java 2013-01-09 13:16:40 UTC (rev 102) +++ branches/engine_split/test/picross/grid/BoxTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -1,123 +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.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 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()); - } -} - Deleted: branches/engine_split/test/picross/grid/CompletedHintsTest.java =================================================================== --- branches/engine_split/test/picross/grid/CompletedHintsTest.java 2013-01-09 13:16:40 UTC (rev 102) +++ branches/engine_split/test/picross/grid/CompletedHintsTest.java 2013-01-09 13:32:12 UTC (rev 103) @@ -1,207 +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.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(expected = IllegalArgumentException.class) - public void negColWidth() { - new CompletedHints(-1, 1, 1, 1); - } - - @Test(expected = IllegalArgumentException.class) - public void zeroColWidth() { - new CompletedHints(0, 1, 1, 1); - } - - @Test(expected = IllegalArgumentException.class) - public void negColHeight() { - new CompletedHints(1, -1, 1, 1); - } - - @Test(expected = IllegalArgumentException.class) - public void zeroColHeight() { - new CompletedHints(1, 0, 1, 1); - } - - @Test(expected = IllegalArgumentException.class) - public void negRowWidth() { - new CompletedHints(1, 1, -1, 1); - } - - @Test(expected = IllegalArgumentException.class) - public void zeroRowWidth() { - new CompletedHints(1, 1, 0, 1); - } - - @Test(expected = IllegalArgumentException.class) - public void negRowHeight() { - new CompletedHints(1, 1, 1, -1); - ... [truncated message content] |
From: <yva...@us...> - 2013-01-09 13:16:52
|
Revision: 102 http://picross.svn.sourceforge.net/picross/?rev=102&view=rev Author: yvan_norsa Date: 2013-01-09 13:16:40 +0000 (Wed, 09 Jan 2013) Log Message: ----------- split engine from game Modified Paths: -------------- branches/engine_split/applet/picross.jnlp branches/engine_split/build.xml branches/engine_split/src/picross/Picross.java branches/engine_split/src/picross/game/random/ui/RandomGameController.java branches/engine_split/src/picross/game/random/ui/RandomGameMediator.java branches/engine_split/src/picross/game/random/ui/RandomGameModeUI.java branches/engine_split/src/picross/game/simple/ui/LevelMenuController.java branches/engine_split/src/picross/game/simple/ui/LevelMenuMediator.java branches/engine_split/src/picross/game/simple/ui/LevelMenuModel.java branches/engine_split/src/picross/game/simple/ui/LevelMenuUI.java branches/engine_split/src/picross/game/simple/ui/SelectSizeCommand.java branches/engine_split/src/picross/game/simple/ui/SimpleGameMediator.java branches/engine_split/src/picross/game/simple/ui/SimpleGameModeUI.java branches/engine_split/src/picross/game/simple/ui/SizesListCommand.java branches/engine_split/src/picross/game/ui/GameController.java branches/engine_split/src/picross/game/ui/GameMediator.java branches/engine_split/src/picross/game/ui/GameView.java branches/engine_split/src/picross/game/ui/UIGameMode.java branches/engine_split/src/picross/grid/ui/FillCommand.java branches/engine_split/src/picross/grid/ui/GridController.java branches/engine_split/src/picross/grid/ui/GridMediator.java branches/engine_split/src/picross/grid/ui/GridUI.java branches/engine_split/src/picross/grid/ui/UIBox.java branches/engine_split/src/picross/ui/GameMenuMediator.java branches/engine_split/src/picross/ui/GameMenuModel.java branches/engine_split/src/picross/ui/GameMenuUI.java branches/engine_split/src/picross/ui/MainMenuMediator.java branches/engine_split/src/picross/ui/MenuController.java branches/engine_split/src/picross/ui/MenuMediator.java branches/engine_split/src/picross/ui/MenuUI.java branches/engine_split/src/picross/ui/PicrossController.java branches/engine_split/src/picross/ui/PicrossMediator.java branches/engine_split/src/picross/ui/PicrossUIHelper.java branches/engine_split/src/picross/ui/PicrossView.java branches/engine_split/src/picross/ui/WaitMenuMediator.java Added Paths: ----------- branches/engine_split/engine/ branches/engine_split/engine/src/ branches/engine_split/engine/src/picross/ branches/engine_split/engine/src/picross/engine/ branches/engine_split/engine/src/picross/engine/PicrossException.java branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java branches/engine_split/engine/src/picross/engine/PicrossLogger.java branches/engine_split/engine/src/picross/engine/game/ branches/engine_split/engine/src/picross/engine/game/AbstractPicrossModel.java branches/engine_split/engine/src/picross/engine/game/GameMode.java branches/engine_split/engine/src/picross/engine/game/package.html branches/engine_split/engine/src/picross/engine/game/random/ branches/engine_split/engine/src/picross/engine/game/random/RandomGameMode.java branches/engine_split/engine/src/picross/engine/game/random/RandomPicrossModel.java branches/engine_split/engine/src/picross/engine/game/random/package.html branches/engine_split/engine/src/picross/engine/game/simple/ branches/engine_split/engine/src/picross/engine/game/simple/Dimensions.java branches/engine_split/engine/src/picross/engine/game/simple/FileInfos.java branches/engine_split/engine/src/picross/engine/game/simple/LevelInfos.java branches/engine_split/engine/src/picross/engine/game/simple/SimpleGameMode.java branches/engine_split/engine/src/picross/engine/game/simple/XBMException.java branches/engine_split/engine/src/picross/engine/game/simple/XBMModel.java branches/engine_split/engine/src/picross/engine/game/simple/package.html branches/engine_split/engine/src/picross/engine/grid/ branches/engine_split/engine/src/picross/engine/grid/Box.java branches/engine_split/engine/src/picross/engine/grid/CompletedHints.java branches/engine_split/engine/src/picross/engine/grid/GridAction.java branches/engine_split/engine/src/picross/engine/grid/GridModel.java branches/engine_split/engine/src/picross/engine/grid/PicrossGrid.java branches/engine_split/engine/src/picross/engine/grid/package.html branches/engine_split/services/picross.engine.game.GameMode branches/engine_split/src/picross/ui/PicrossLog4jLogger.java Removed Paths: ------------- branches/engine_split/services/picross.game.GameMode branches/engine_split/src/picross/PicrossException.java branches/engine_split/src/picross/game/AbstractPicrossModel.java branches/engine_split/src/picross/game/GameMode.java branches/engine_split/src/picross/game/package.html branches/engine_split/src/picross/game/random/RandomGameMode.java branches/engine_split/src/picross/game/random/RandomPicrossModel.java branches/engine_split/src/picross/game/random/package.html branches/engine_split/src/picross/game/simple/FileInfos.java branches/engine_split/src/picross/game/simple/LevelInfos.java branches/engine_split/src/picross/game/simple/SimpleGameMode.java branches/engine_split/src/picross/game/simple/XBMException.java branches/engine_split/src/picross/game/simple/XBMModel.java branches/engine_split/src/picross/game/simple/package.html branches/engine_split/src/picross/grid/Box.java branches/engine_split/src/picross/grid/CompletedHints.java branches/engine_split/src/picross/grid/GridAction.java branches/engine_split/src/picross/grid/GridModel.java branches/engine_split/src/picross/grid/PicrossGrid.java branches/engine_split/src/picross/grid/package.html Modified: branches/engine_split/applet/picross.jnlp =================================================================== --- branches/engine_split/applet/picross.jnlp 2013-01-09 11:54:44 UTC (rev 101) +++ branches/engine_split/applet/picross.jnlp 2013-01-09 13:16:40 UTC (rev 102) @@ -13,6 +13,7 @@ <resources> <j2se version="1.6+" /> + <jar href="picross-engine.jar" /> <jar href="picross.jar" /> <jar href="bundleHelper.jar" /> <jar href="log4j.jar" /> @@ -24,4 +25,4 @@ name="Picross" width="900" height="900" /> -</jnlp> \ No newline at end of file +</jnlp> Modified: branches/engine_split/build.xml =================================================================== --- branches/engine_split/build.xml 2013-01-09 11:54:44 UTC (rev 101) +++ branches/engine_split/build.xml 2013-01-09 13:16:40 UTC (rev 102) @@ -3,28 +3,34 @@ <project name="picross" default="dist"> - <property name="build.dir" - value="build" /> + <property name="engine.build.dir" + value="engine/build" /> + <property name="game.build.dir" + value="build/game" /> <property name="dist.dir" value="dist" /> <property name="doc.dir" value="doc" /> <property name="lib.dir" value="lib" /> - <property name="src.dir" + <property name="engine.src.dir" + value="engine/src" /> + <property name="game.src.dir" value="src" /> - <property name="test.dir" - value="test" /> + <property name="game.test.dir" + value="test" /> - <property name="jar.name" + <property name="engine.jar.name" + value="${dist.dir}/${ant.project.name}-engine.jar" /> + <property name="game.jar.name" value="${dist.dir}/${ant.project.name}.jar" /> <property name="bundleHelper.jar" value="${lib.dir}/bundleHelper.jar" /> <property name="debug.jar" value="${lib.dir}/debug.jar" /> - <property name="easymock.jar" - value="${lib.dir}/easymock.jar" /> + <property name="easymock.jar" + value="${lib.dir}/easymock.jar" /> <property name="junit.jar" value="${lib.dir}/junit.jar" /> <property name="log4j.jar" @@ -36,7 +42,8 @@ <target name="-init" depends="-setmode"> - <mkdir dir="${build.dir}" /> + <mkdir dir="${engine.build.dir}" /> + <mkdir dir="${game.build.dir}" /> <mkdir dir="${dist.dir}" /> <mkdir dir="${doc.dir}" /> </target> @@ -62,33 +69,45 @@ </target> <path id="classpath"> - <pathelement location="${build.dir}" /> + <pathelement location="${game.build.dir}" /> + <pathelement location="${engine.jar.name}" /> <pathelement location="${bundleHelper.jar}" /> - <pathelement location="${easymock.jar}" /> + <pathelement location="${easymock.jar}" /> <pathelement location="${junit.jar}" /> <pathelement location="${log4j.jar}" /> <pathelement location="${mmvcs.jar}" /> <pathelement location="${simpleButton.jar}" /> </path> - <target name="compile" + <target name="engine-compile" depends="-init"> - <javac srcdir="${src.dir}" - destdir="${build.dir}" + <javac srcdir="${engine.src.dir}" + destdir="${engine.build.dir}" deprecation="on" debug="${javac.debug}" optimize="${javac.optimize}"> <compilerarg value="-Xlint:all" /> + </javac> + </target> + <target name="game-compile" + depends="-init"> + <javac srcdir="${game.src.dir}" + destdir="${game.build.dir}" + deprecation="on" + debug="${javac.debug}" + optimize="${javac.optimize}"> + <compilerarg value="-Xlint:all" /> + <classpath refid="classpath" /> </javac> </target> <target name="compile-test" - depends="compile"> - <javac srcdir="${test.dir}" - destdir="${build.dir}" + depends="game-compile"> + <javac srcdir="${game.test.dir}" + destdir="${game.build.dir}" deprecation="on" debug="on" optimize="off"> @@ -98,27 +117,33 @@ </javac> </target> + <target name="engine-dist" + depends="engine-compile"> + <jar destfile="${engine.jar.name}" + basedir="${engine.build.dir}" /> + </target> + <target name="dist" - depends="compile"> - <copy todir="${build.dir}/picross/properties" + depends="engine-dist,game-compile"> + <copy todir="${game.build.dir}/picross/properties" failonerror="false"> - <fileset dir="${src.dir}/picross/properties" /> + <fileset dir="${game.src.dir}/picross/properties" /> </copy> - <copy todir="${build.dir}/picross/images"> + <copy todir="${game.build.dir}/picross/images"> <fileset dir="images" /> </copy> - <copy todir="${build.dir}/picross/data"> + <copy todir="${game.build.dir}/picross/data"> <fileset dir="data" /> </copy> - <copy todir="${build.dir}/META-INF/services"> + <copy todir="${game.build.dir}/META-INF/services"> <fileset dir="services" /> </copy> - <jar destfile="${jar.name}" - basedir="${build.dir}" /> + <jar destfile="${game.jar.name}" + basedir="${game.build.dir}" /> </target> <target name="run" @@ -128,7 +153,8 @@ fork="true" dir="."> <classpath> - <pathelement location="${jar.name}" /> + <pathelement location="${engine.jar.name}" /> + <pathelement location="${game.jar.name}" /> <pathelement location="${bundleHelper.jar}" /> <pathelement location="${log4j.jar}" /> <pathelement location="${mmvcs.jar}" /> @@ -144,12 +170,12 @@ fork="true" dir="."> <classpath> - <pathelement location="${jar.name}" /> + <pathelement location="${game.jar.name}" /> <pathelement location="${bundleHelper.jar}" /> <pathelement location="${log4j.jar}" /> <pathelement location="${mmvcs.jar}" /> <pathelement location="${debug.jar}" /> - <pathelement location="${simpleButton.jar}" /> + <pathelement location="${simpleButton.jar}" /> </classpath> </java> </target> @@ -164,7 +190,7 @@ <batchtest fork="yes" filtertrace="on"> - <fileset dir="${test.dir}"> + <fileset dir="${game.test.dir}"> <include name="**/*Test.java" /> <exclude name="**/Abstract*Test.java" /> </fileset> @@ -175,7 +201,8 @@ </target> <target name="clean"> - <delete dir="${build.dir}" /> + <delete dir="${engine.build.dir}" /> + <delete dir="${game.build.dir}" /> <delete dir="${dist.dir}" /> <delete dir="${doc.dir}" /> @@ -190,10 +217,10 @@ depends="clean, dist" /> <target name="doc" - depends="compile"> + depends="game-compile"> <javadoc destdir="${doc.dir}" - link="http://download.oracle.com/javase/6/docs/api/"> - <packageset dir="${src.dir}" + link="http://download.oracle.com/javase/6/docs/api/"> + <packageset dir="${game.src.dir}" defaultexcludes="yes" /> <classpath refid="classpath" /> @@ -220,7 +247,7 @@ <formatter type="xml" tofile="checkstyle.xml" /> - <fileset dir="${src.dir}" + <fileset dir="${game.src.dir}" includes="**/*.java" /> </checkstyle> @@ -261,11 +288,11 @@ projectName="${ant.project.name}" output="html" outputFile="findbugs.html"> - <class location="${build.dir}" /> + <class location="${game.build.dir}" /> <auxclasspath refid="classpath" /> - <sourcePath path="${src.dir}" /> + <sourcePath path="${game.src.dir}" /> </findbugs> </target> -</project> \ No newline at end of file +</project> Copied: branches/engine_split/engine/src/picross/engine/PicrossException.java (from rev 101, branches/engine_split/src/picross/PicrossException.java) =================================================================== --- branches/engine_split/engine/src/picross/engine/PicrossException.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/PicrossException.java 2013-01-09 13:16:40 UTC (rev 102) @@ -0,0 +1,67 @@ +/* + * $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.engine; + +/** + * General exception. + * + * @author Y. Norsa + */ +public class PicrossException extends Exception { + /*** Constant ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = 1716838910721477345L; + + /*** Constructors ***/ + + /** + * Constructor. + * + * @param cause parent exception + */ + public PicrossException(Throwable cause) { + super(cause); + } + + /** + * Constructor. + * + * @param msg message describing the exception + */ + public PicrossException(String msg) { + super(msg); + } +} + Added: branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java =================================================================== --- branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java 2013-01-09 13:16:40 UTC (rev 102) @@ -0,0 +1,48 @@ +/* + * $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.engine; + +public final class PicrossLogHelper { + private static PicrossLogger logger; + + public static PicrossLogger getLogger() { + return PicrossLogHelper.logger; + } + + public static void setLogger(PicrossLogger picrossLogger) { + PicrossLogHelper.logger = picrossLogger; + } + + private PicrossLogHelper() { } +} Property changes on: branches/engine_split/engine/src/picross/engine/PicrossLogHelper.java ___________________________________________________________________ Added: svn:keywords + Id Added: branches/engine_split/engine/src/picross/engine/PicrossLogger.java =================================================================== --- branches/engine_split/engine/src/picross/engine/PicrossLogger.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/PicrossLogger.java 2013-01-09 13:16:40 UTC (rev 102) @@ -0,0 +1,40 @@ +/* + * $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.engine; + +public interface PicrossLogger { + void debug(String msg); + void info(String msg); + void error(String msg); +} Property changes on: branches/engine_split/engine/src/picross/engine/PicrossLogger.java ___________________________________________________________________ Added: svn:keywords + Id Copied: branches/engine_split/engine/src/picross/engine/game/AbstractPicrossModel.java (from rev 101, branches/engine_split/src/picross/game/AbstractPicrossModel.java) =================================================================== --- branches/engine_split/engine/src/picross/engine/game/AbstractPicrossModel.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/game/AbstractPicrossModel.java 2013-01-09 13:16:40 UTC (rev 102) @@ -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.engine.game; + +import picross.engine.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; + } +} + Copied: branches/engine_split/engine/src/picross/engine/game/GameMode.java (from rev 101, branches/engine_split/src/picross/game/GameMode.java) =================================================================== --- branches/engine_split/engine/src/picross/engine/game/GameMode.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/game/GameMode.java 2013-01-09 13:16:40 UTC (rev 102) @@ -0,0 +1,44 @@ +/* + * $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.engine.game; + +/** + * Service describing a game mode. + * + * @author Y. Norsa + */ +public interface GameMode { + String getModeName(); +} + Copied: branches/engine_split/engine/src/picross/engine/game/package.html (from rev 101, branches/engine_split/src/picross/game/package.html) =================================================================== --- branches/engine_split/engine/src/picross/engine/game/package.html (rev 0) +++ branches/engine_split/engine/src/picross/engine/game/package.html 2013-01-09 13:16:40 UTC (rev 102) @@ -0,0 +1,12 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <!-- + $Id$ + --> + </head> + + <body bgcolor="white"> + Classes relative to a game. + </body> +</html> Copied: branches/engine_split/engine/src/picross/engine/game/random/RandomGameMode.java (from rev 101, branches/engine_split/src/picross/game/random/RandomGameMode.java) =================================================================== --- branches/engine_split/engine/src/picross/engine/game/random/RandomGameMode.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/game/random/RandomGameMode.java 2013-01-09 13:16:40 UTC (rev 102) @@ -0,0 +1,48 @@ +/* + * $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.engine.game.random; + +import picross.engine.game.GameMode; + +/** + * Random game mode. + * + * @author Y. Norsa + */ +public class RandomGameMode implements GameMode { + public String getModeName() { + return "random"; + } +} + Copied: branches/engine_split/engine/src/picross/engine/game/random/RandomPicrossModel.java (from rev 101, branches/engine_split/src/picross/game/random/RandomPicrossModel.java) =================================================================== --- branches/engine_split/engine/src/picross/engine/game/random/RandomPicrossModel.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/game/random/RandomPicrossModel.java 2013-01-09 13:16:40 UTC (rev 102) @@ -0,0 +1,87 @@ +/* + * $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.engine.game.random; + +import java.util.Random; + +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; + +import picross.engine.game.AbstractPicrossModel; + +/** + * This class provides a random grid. + * + * @author Y. Norsa + */ +public final class RandomPicrossModel extends AbstractPicrossModel { + /*** Static field ***/ + + /** The class' logger. */ + private static PicrossLogger log = PicrossLogHelper.getLogger(); + + /*** Constructor ***/ + + /** Constructor. */ + public RandomPicrossModel() { + Random rand = new Random(); + + while (this.width == 0) { + this.width = rand.nextInt(25); + } + + while (this.height == 0) { + this.height = rand.nextInt(25); + } + + RandomPicrossModel.log.debug("this.width = " + this.width + + ", this.height = " + this.height); + + this.data = new boolean[this.width][this.height]; + + 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; + } + } + } + } + } +} Copied: branches/engine_split/engine/src/picross/engine/game/random/package.html (from rev 101, branches/engine_split/src/picross/game/random/package.html) =================================================================== --- branches/engine_split/engine/src/picross/engine/game/random/package.html (rev 0) +++ branches/engine_split/engine/src/picross/engine/game/random/package.html 2013-01-09 13:16:40 UTC (rev 102) @@ -0,0 +1,12 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <!-- + $Id$ + --> + </head> + + <body bgcolor="white"> + Random grid game. + </body> +</html> Added: branches/engine_split/engine/src/picross/engine/game/simple/Dimensions.java =================================================================== --- branches/engine_split/engine/src/picross/engine/game/simple/Dimensions.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/game/simple/Dimensions.java 2013-01-09 13:16:40 UTC (rev 102) @@ -0,0 +1,74 @@ +/* + * $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.engine.game.simple; + +public final class Dimensions { + private int width; + private int height; + + public Dimensions(int w, int h) { + this.width = w; + this.height = h; + } + + public double getWidth() { + return this.width; + } + + public double getHeight() { + return this.height; + } + + public boolean equals(Object o) { + if (o == null) { + return false; + } + + if (o == this) { + return true; + } + + if (!(o instanceof Dimensions)) { + return false; + } + + Dimensions dim = (Dimensions) o; + + return ((this.width == dim.width) && (this.height == dim.height)); + } + + public int hashCode() { + return (this.width * 17) + (this.height * 23); + } +} Property changes on: branches/engine_split/engine/src/picross/engine/game/simple/Dimensions.java ___________________________________________________________________ Added: svn:keywords + Id Copied: branches/engine_split/engine/src/picross/engine/game/simple/FileInfos.java (from rev 101, branches/engine_split/src/picross/game/simple/FileInfos.java) =================================================================== --- branches/engine_split/engine/src/picross/engine/game/simple/FileInfos.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/game/simple/FileInfos.java 2013-01-09 13:16:40 UTC (rev 102) @@ -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.engine.game.simple; + +/** + * Informations about a level file. + * + * @author Y. Norsa + */ +public final class FileInfos implements LevelInfos { + /*** Constants ***/ + + /** String separating the various fields. */ + private static final String FIELDS_SEPARATOR = ":"; + + /** String separating the width from the height. */ + private static final String SIZE_SEPARATOR = "x"; + + /*** Fields ***/ + + /** The filename. */ + private String name; + + /** Grid size. */ + private Dimensions dimensions; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param levelName the filename + * @param dim grid size + */ + public FileInfos(String levelName, Dimensions dim) { + this.name = levelName.trim(); + this.dimensions = dim; + } + + /*** Static methods ***/ + + /** + * Parses a line to extract level informations. + * + * @param line the line to parse + * @return level informations + */ + public static FileInfos readFileInfos(String line) { + String[] lineData = line.split(FileInfos.FIELDS_SEPARATOR); + + return new FileInfos(lineData[0], + FileInfos.readSize(lineData[1])); + } + + /** + * Parses a line containing the grid size. + * Example : "15x10". + * + * @param sizeString a <code>String</code> describing the grid size + * @return parsed size + */ + private static Dimensions readSize(String sizeString) { + String[] sizeData = sizeString.trim().split(FileInfos.SIZE_SEPARATOR); + + return new Dimensions(Integer.parseInt(sizeData[0]), + Integer.parseInt(sizeData[1])); + } + + /*** Methods implanted from the interface LevelInfos ***/ + + /** {@inheritDoc} */ + @Override + public String getName() { + return this.name; + } + + /** {@inheritDoc} */ + @Override + public Dimensions getDimensions() { + return this.dimensions; + } +} + Copied: branches/engine_split/engine/src/picross/engine/game/simple/LevelInfos.java (from rev 101, branches/engine_split/src/picross/game/simple/LevelInfos.java) =================================================================== --- branches/engine_split/engine/src/picross/engine/game/simple/LevelInfos.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/game/simple/LevelInfos.java 2013-01-09 13:16:40 UTC (rev 102) @@ -0,0 +1,56 @@ +/* + * $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.engine.game.simple; + +/** + * Set of informations about a level. + * + * @author Y. Norsa + */ +public interface LevelInfos { + /** + * Returns the level's name. + * + * @return name of the level + */ + String getName(); + + /** + * Returns the grid size. + * + * @return size of the grid + */ + Dimensions getDimensions(); +} + Copied: branches/engine_split/engine/src/picross/engine/game/simple/SimpleGameMode.java (from rev 101, branches/engine_split/src/picross/game/simple/SimpleGameMode.java) =================================================================== --- branches/engine_split/engine/src/picross/engine/game/simple/SimpleGameMode.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/game/simple/SimpleGameMode.java 2013-01-09 13:16:40 UTC (rev 102) @@ -0,0 +1,48 @@ +/* + * $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.engine.game.simple; + +import picross.engine.game.GameMode; + +/** + * Simple game mode. + * + * @author Y. Norsa + */ +public class SimpleGameMode implements GameMode { + public String getModeName() { + return "simple"; + } +} + Copied: branches/engine_split/engine/src/picross/engine/game/simple/XBMException.java (from rev 101, branches/engine_split/src/picross/game/simple/XBMException.java) =================================================================== --- branches/engine_split/engine/src/picross/engine/game/simple/XBMException.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/game/simple/XBMException.java 2013-01-09 13:16:40 UTC (rev 102) @@ -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.engine.game.simple; + +import picross.engine.PicrossException; + +/** + * Exception thrown when reading an invalid XBM file. + * + * @author Y. Norsa + */ +final class XBMException extends PicrossException { + /*** Constant ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = 3928727649077087059L; + + /*** Constructors ***/ + + /** + * Constructor. + * + * @param msg message describing the exception + */ + XBMException(String msg) { + super(msg); + } + + /** + * Constructor. + * + * @param cause parent exception + */ + XBMException(Throwable cause) { + super(cause); + } +} Copied: branches/engine_split/engine/src/picross/engine/game/simple/XBMModel.java (from rev 101, branches/engine_split/src/picross/game/simple/XBMModel.java) =================================================================== --- branches/engine_split/engine/src/picross/engine/game/simple/XBMModel.java (rev 0) +++ branches/engine_split/engine/src/picross/engine/game/simple/XBMModel.java 2013-01-09 13:16:40 UTC (rev 102) @@ -0,0 +1,271 @@ +/* + * $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.engine.game.simple; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +import java.util.ArrayList; +import java.util.List; + +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; + +import picross.engine.game.AbstractPicrossModel; + +/** + * Class loading a XBM file. + * + * @author Y. Norsa + */ +public final class XBMModel extends AbstractPicrossModel { + /*** Constants ***/ + + /** Indicates a constant definition. */ + private static final String DEFINE_DIRECTIVE = "#define "; + + /** The width value. */ + private static final String WIDTH_KEYWORD = "width"; + + /** The height value. */ + private static final String HEIGHT_KEYWORD = "height"; + + /** Character before the int value. */ + private static final char VALUE_MARKER = ' '; + + /** The data values. */ + private static final String BITS_KEYWORD = "bits"; + + /** Value separator. */ + private static final String VALUE_SEPARATOR = ","; + + /** String indicating a hex value. */ + private static final String HEX_LEADING = "0x"; + + /** In case of error. */ + private static final int ERROR_VALUE = -1; + + /** Beginning of the actual value. */ + private static final int VALUE_BEGINNING_POS = 2; + + /** End of the actual value. */ + private static final int VALUE_END_POS = 4; + + /** Hexadecimal number radix. */ + private static final int HEX_RADIX = 16; + + /** Length of a byte. */ + private static final int BYTE_LENGTH = 8; + + /*** Static field ***/ + + /** The class' logger. */ + private static PicrossLogger log = PicrossLogHelper.getLogger(); + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param input XBM file input stream + * @throws IllegalArgumentException if <code>input</code> + * is <code>null</code> + * @throws IOException if there is a problem while reading the file + * @throws XBMException if the file isn't a valid XBM file + */ + public XBMModel(InputStream input) throws IOException, XBMException, + IllegalArgumentException { + super(); + + if (input == null) { + throw new IllegalArgumentException("input can't be null"); + } + + List<String> byteValues = new ArrayList<String>(); + + BufferedReader in = new BufferedReader(new InputStreamReader(input)); + + String line = null; + + try { + while ((line = in.readLine()) != null) { + line = line.trim(); + + if (line.startsWith(XBMModel.DEFINE_DIRECTIVE) + && line.contains(XBMModel.WIDTH_KEYWORD)) { + + this.width = XBMModel.readLineValue(line); + + XBMModel.log.debug("width = " + this.width); + continue; + } + + if (line.startsWith(XBMModel.DEFINE_DIRECTIVE) + && line.contains(XBMModel.HEIGHT_KEYWORD)) { + + this.height = XBMModel.readLineValue(line); + + XBMModel.log.debug("height = " + this.height); + continue; + } + + if (line.contains(XBMModel.BITS_KEYWORD)) { + this.data = new boolean[this.width][this.height]; + + while ((line = in.readLine()) != null) { + String[] values = line.split(XBMModel.VALUE_SEPARATOR); + + for (int i = 0; i < values.length; i++) { + if (values[i].contains(XBMModel.HEX_LEADING)) { + values[i] = values[i].trim(); + + //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] + .substring(XBMModel.VALUE_BEGINNING_POS, + XBMModel.VALUE_END_POS); + byteValues.add(byteStr); + } + } + } + } + } + } catch (IOException ioEx) { + throw ioEx; + } finally { + try { + i... [truncated message content] |
From: <yva...@us...> - 2013-01-09 11:54:50
|
Revision: 101 http://picross.svn.sourceforge.net/picross/?rev=101&view=rev Author: yvan_norsa Date: 2013-01-09 11:54:44 +0000 (Wed, 09 Jan 2013) Log Message: ----------- new branch for engine split from UI Added Paths: ----------- branches/engine_split/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2011-07-21 11:29:17
|
Revision: 100 http://picross.svn.sourceforge.net/picross/?rev=100&view=rev Author: yvan_norsa Date: 2011-07-21 11:29:07 +0000 (Thu, 21 Jul 2011) Log Message: ----------- upgraded applet page Modified Paths: -------------- trunk/applet/index.html trunk/build.xml Added Paths: ----------- trunk/applet/picross.jnlp Modified: trunk/applet/index.html =================================================================== --- trunk/applet/index.html 2011-07-18 12:16:48 UTC (rev 99) +++ trunk/applet/index.html 2011-07-21 11:29:07 UTC (rev 100) @@ -8,56 +8,16 @@ <body> <h1>Picross</h1> -<!--"CONVERTED_APPLET"--> -<!-- HTML CONVERTER --> -<script language="JavaScript" type="text/javascript"><!-- - var _info = navigator.userAgent; - var _ns = false; - var _ns6 = false; - var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); -//--></script> - <comment> - <script language="JavaScript" type="text/javascript"><!-- - var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) || (_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0) || (_info.indexOf("IRIX") > 0))); - var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0)); -//--></script> - </comment> +<script src="http://www.java.com/js/deployJava.js"></script> +<script> + var attributes = {code: 'picross.applet.PicrossApplet.class', archive: 'picross.jar', width: '900', height: '900'}; + var parameters = {jnlp_href: 'picross.jnlp'}; + deployJava.runApplet(attributes, parameters, '1.6'); +</script> -<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.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.6" \ - CODE = "picross.applet.PicrossApplet" \ - 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,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.6"> - <param name="scriptable" value="false"> - - -</applet> -</noembed> -</embed> -</object> - -<!-- -<APPLET CODE = "picross.applet.PicrossApplet" ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar,simpleButton.jar" WIDTH = "900" HEIGHT = "900"> - - -</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> </body> -</html> \ No newline at end of file +</html> Added: trunk/applet/picross.jnlp =================================================================== --- trunk/applet/picross.jnlp (rev 0) +++ trunk/applet/picross.jnlp 2011-07-21 11:29:07 UTC (rev 100) @@ -0,0 +1,27 @@ +<?xml version="1.0" + encoding="UTF-8"?> + +<jnlp spec="1.0+" + codebase="http://picross.sourceforge.net/" + href="picross.jnlp"> + <information> + <title>Picross</title> + <vendor>Yvan Norsa</vendor> + <offline-allowed /> + </information> + + <resources> + <j2se version="1.6+" /> + + <jar href="picross.jar" /> + <jar href="bundleHelper.jar" /> + <jar href="log4j.jar" /> + <jar href="mmvcs.jar" /> + <jar href="simpleButton.jar" /> + </resources> + + <applet-desc main-class="picross.applet.PicrossApplet" + name="Picross" + width="900" + height="900" /> +</jnlp> \ No newline at end of file Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2011-07-18 12:16:48 UTC (rev 99) +++ trunk/build.xml 2011-07-21 11:29:07 UTC (rev 100) @@ -192,7 +192,7 @@ <target name="doc" depends="compile"> <javadoc destdir="${doc.dir}" - link="http://java.sun.com/j2se/1.5.0/docs/api"> + link="http://download.oracle.com/javase/6/docs/api/"> <packageset dir="${src.dir}" defaultexcludes="yes" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2011-07-18 12:16:58
|
Revision: 99 http://picross.svn.sourceforge.net/picross/?rev=99&view=rev Author: yvan_norsa Date: 2011-07-18 12:16:48 +0000 (Mon, 18 Jul 2011) Log Message: ----------- fixed falsely completed hint bug; lots of test Modified Paths: -------------- trunk/src/picross/grid/GridModel.java trunk/src/picross/grid/ui/GridUI.java trunk/test/picross/grid/GridModelTest.java Added Paths: ----------- trunk/test/picross/grid/GridModelIntegrationTest.java Modified: trunk/src/picross/grid/GridModel.java =================================================================== --- trunk/src/picross/grid/GridModel.java 2011-07-18 11:29:59 UTC (rev 98) +++ trunk/src/picross/grid/GridModel.java 2011-07-18 12:16:48 UTC (rev 99) @@ -80,6 +80,9 @@ /** List of completed hints. */ private CompletedHints completedHints; + private int[] rowHintsTotal; + private int[] colHintsTotal; + /*** Constructor ***/ /** @@ -98,10 +101,13 @@ // this.mediator = mediator; this.data = data; - this.boxes = new Box[this.data.length][this.data[0].length]; + int lineSize = this.data[0].length; + + this.boxes = new Box[this.data.length][lineSize]; + for (int i = 0; i < this.boxes.length; i++) { - for (int j = 0; j < this.boxes[i].length; j++) { + for (int j = 0; j < lineSize; j++) { this.boxes[i][j] = new Box(); } } @@ -113,19 +119,38 @@ new CompletedHints(data.length, this.colData[0].length, data[0].length, this.rowData[0].length); - // Marks the empty rows and columns as completed - + /* + * Marks the empty rows and columns as completed + * and the empty hints as completed + */ for (int i = 0; i < this.rowData.length; i++) { if (this.emptyRow(i)) { this.completedHints.setCompleteRow(i); + } else { + for (int j = 0; j < this.rowData[i].length; j++) { + if (this.rowData[i][j] == GridModel.EMPTY_HINT) { + this.completedHints.setCompleteRowHint(i, j); + } + } } } for (int i = 0; i < this.colData.length; i++) { if (this.emptyCol(i)) { this.completedHints.setCompleteCol(i); + } else { + for (int j = 0; j < this.colData[i].length; j++) { + if (this.colData[i][j] == GridModel.EMPTY_HINT) { + this.completedHints.setCompleteColHint(i, j); + } + } } } + + /**/ + + this.rowHintsTotal = GridModel.computeRowHintsTotal(data); + this.colHintsTotal = GridModel.computeColHintsTotal(data); } /*** Static methods ***/ @@ -215,12 +240,12 @@ } /* - * Final array containing the hints, in the following form : + * So for the hints : * * 1 - * 0 2 1 + * 0 2 1 * - * Which corresponds to the following grid : + * Which corresponds to the grid : * * |-----| * |_|X|_| @@ -228,6 +253,9 @@ * |_|X|_| * |_|X|_| * |-----| + * + * We build this array : + * {{0, -1}, {2, 1}, {1, -1}} */ int[][] result = new int[data.length][max]; @@ -265,7 +293,6 @@ for (int i = 0; i < data[0].length; i++) { List<Integer> current = new ArrayList<Integer>(); - int chain = 0; for (int j = 0; j < data.length; j++) { @@ -368,6 +395,42 @@ return GridModel.EMPTY_HINT; } + private static int[] computeRowHintsTotal(boolean[][] data) { + int[] result = new int[data[0].length]; + + for (int i = 0; i < data[0].length; i++) { + int total = 0; + + for (int j = 0; j < data.length; j++) { + if (data[j][i]) { + total++; + } + } + + result[i] = total; + } + + return result; + } + + private static int[] computeColHintsTotal(boolean[][] data) { + int[] result = new int[data.length]; + + for (int i = 0; i < data.length; i++) { + int total = 0; + + for (boolean cell : data[i]) { + if (cell) { + total++; + } + } + + result[i] = total; + } + + return result; + } + /*** Methods ***/ /** @@ -516,137 +579,203 @@ // Contains the completed hints List<Integer> completedRowHints = new ArrayList<Integer>(); - // Current hint we're looking to complete - int currentHintIndex = - GridModel.getFirstHintIndex(this.rowData[row]); + List<Integer> leftToRightHints = new ArrayList<Integer>(); - // First from left to right - int currentHint = 0; + // If the first box is empty, skip left-to-right check + if (!this.boxes[0][row].isEmpty()) { + leftToRightHints = this.checkLeftToRight(row); + //GridModel.log.debug("left-to-right for row #" + row + ": " + // + leftToRightHints); + completedRowHints.addAll(leftToRightHints); + } - // If the first box is empty, do nothing this time - if (!this.boxes[currentHint][row].isEmpty()) { - // Current chain of checked boxes - int currentChain = 0; + List<Integer> rightToLeftHints = new ArrayList<Integer>(); - while (currentHint < this.boxes.length) { - if (this.boxes[currentHint][row].isChecked()) { - currentChain++; - } else { - // We reach the end of a chain + // Same thing from right to left + if (!this.boxes[this.boxes.length - 1][row].isEmpty()) { + rightToLeftHints = this.checkRightToLeft(row); + //GridModel.log.debug("right-to-left hints for row #" + row + ": " + // + rightToLeftHints); + completedRowHints.addAll(rightToLeftHints); + } - // And it matches the current hint - if (this.rowData[row][currentHintIndex] - == currentChain) { + List<Integer> rowHints = this.completedHints.getCompleteRowHints(row); - completedRowHints.add(currentHintIndex); - currentChain = 0; + for (int hintIndex : rowHints) { + if (!completedRowHints.contains(hintIndex)) { + this.completedHints.clearRowHint(row, hintIndex); + } + } - currentHintIndex = - GridModel.getNextHintIndex(currentHintIndex + 1, - this.rowData[row]); + for (int index : completedRowHints) { + this.completedHints.setCompleteRowHint(row, index); + } - if (currentHintIndex == GridModel.EMPTY_HINT) { - /* - * If this is the last hint, we verify that - * there aren't any extra checked boxes - */ - for (int i = currentHint; i < this.boxes.length; - i++) { + /**/ + boolean complete = true; - if (this.boxes[i][row].isChecked()) { - /* - * If this is the case, - * we cancel everything - */ - completedRowHints.clear(); - break; - } - } + for (int i = 0; i < this.rowData[row].length; i++) { + if (this.rowData[row][i] != GridModel.EMPTY_HINT && !completedRowHints.contains(i)) { + complete = false; + } + } - break; - } - } + if (!complete) { + return; + } + /**/ - // If there is a blank after a filled hint, we stop there - if (this.boxes[currentHint][row].isEmpty()) { - break; - } - } + //GridModel.log.debug("Row #" + row + " is complete"); - currentHint++; + // Let's compare number of checked boxes and the sum of all hints + int totalChecked = 0; + + for (int i = 0; i < this.boxes.length; i++) { + if (this.boxes[i][row].isChecked()) { + totalChecked++; } + } - /* - * If we've reached the end of the row - * and there is a current chain, we mark it as completed - */ - if (currentHintIndex != -1 - && this.rowData[row][currentHintIndex] == currentChain) { + /* + * If it's the same number, then we're good to go + * Otherwise, we're gonna keep the highest number of cleared hints + */ + if (totalChecked == this.rowHintsTotal[row]) { + return; + } - completedRowHints.add(currentHintIndex); - currentChain = 0; + //GridModel.log.debug("totalChecked = " + totalChecked); + //GridModel.log.debug("rowHintsTotal[" + row + "] = " + // + this.rowHintsTotal[row]); + + int leftToRightSize = leftToRightHints.size(); + int rightToLeftSize = rightToLeftHints.size(); + + //GridModel.log.debug("left to right = " + leftToRightSize); + //GridModel.log.debug("right to left = " + rightToLeftSize); + + if (leftToRightSize > 0 || rightToLeftSize > 0) { + if (leftToRightSize >= rightToLeftSize) { + for (int hintIndex : rightToLeftHints) { + this.completedHints.clearRowHint(row, hintIndex); + } + } else { + for (int hintIndex : leftToRightHints) { + this.completedHints.clearRowHint(row, hintIndex); + } } + } else { + throw new RuntimeException("Confusion occured during " + + "completed hints look-up"); } + } - // Same thing from right to left - currentHintIndex = GridModel.getLastHintIndex(this.rowData[row]); + private List<Integer> checkLeftToRight(int row) { + List<Integer> result = new ArrayList<Integer>(); - currentHint = this.boxes.length - 1; + // Current hint we're looking to complete + int currentHintIndex = + GridModel.getFirstHintIndex(this.rowData[row]); - if (!this.boxes[currentHint][row].isEmpty()) { - int currentChain = 0; + int currentBox = 0; - while (currentHint >= 0) { - if (this.boxes[currentHint][row].isChecked()) { - currentChain++; - } else { - if (this.rowData[row][currentHintIndex] - == currentChain) { + // Current chain of checked boxes + int currentChain = 0; - completedRowHints.add(currentHintIndex); - currentChain = 0; + while (currentBox < this.boxes.length) { + if (this.boxes[currentBox][row].isChecked()) { + currentChain++; + } else { + // We reach the end of a chain + // And it matches the current hint + if (this.rowData[row][currentHintIndex] == currentChain) { + result.add(currentHintIndex); + currentChain = 0; - currentHintIndex = - GridModel.getPreviousHintIndex(currentHintIndex - - 1, - this.rowData[row]); + currentHintIndex = + GridModel.getNextHintIndex(currentHintIndex + 1, + this.rowData[row]); - if (currentHintIndex == -1) { - for (int i = currentHint; i >= 0; i--) { - if (this.boxes[i][row].isChecked()) { - completedRowHints.clear(); - } - } + if (currentHintIndex == GridModel.EMPTY_HINT) { + /* + * If this is the last hint, we verify that + * there aren't any extra checked boxes + */ + for (int i = currentBox; i < this.boxes.length; i++) { + if (this.boxes[i][row].isChecked()) { + // If this is the case, we cancel everything + result.clear(); + break; + } + } - break; - } - } + break; + } + } - if (this.boxes[currentHint][row].isEmpty()) { - break; - } - } + // If there is a blank after a filled hint, we stop there + if (this.boxes[currentBox][row].isEmpty()) { + break; + } + } + + currentBox++; + } + + /* + * If we've reached the end of the row + * and there is a current chain, we mark it as completed + */ + if (currentHintIndex != -1 + && this.rowData[row][currentHintIndex] == currentChain) { - currentHint--; - } - } + result.add(currentHintIndex); + } - List<Integer> rowHints = this.completedHints.getCompleteRowHints(row); + return result; + } - for (int hintIndex : rowHints) { - if (!completedRowHints.contains(hintIndex)) { - this.completedHints.clearRowHint(row, hintIndex); - } - } + private List<Integer> checkRightToLeft(int row) { + List<Integer> result = new ArrayList<Integer>(); - for (int index : completedRowHints) { - this.completedHints.setCompleteRowHint(row, index); - } + int currentHintIndex = GridModel.getLastHintIndex(this.rowData[row]); + int currentBox = this.boxes.length - 1; + int currentChain = 0; - // FIXME - //this.mediator.repaintRowHints(row); - } + while (currentBox >= 0) { + if (this.boxes[currentBox][row].isChecked()) { + currentChain++; + } else { + if (this.rowData[row][currentHintIndex] == currentChain) { + result.add(currentHintIndex); + currentChain = 0; + currentHintIndex = + GridModel.getPreviousHintIndex(currentHintIndex - 1, + this.rowData[row]); + + if (currentHintIndex == -1) { + for (int i = currentBox; i >= 0; i--) { + if (this.boxes[i][row].isChecked()) { + result.clear(); + } + } + + break; + } + } + + if (this.boxes[currentBox][row].isEmpty()) { + break; + } + } + + currentBox--; + } + + return result; + } + /** * Checks if a column is empty. * @@ -674,145 +803,169 @@ } List<Integer> completedColHints = new ArrayList<Integer>(); - /* - for (int i = 0; i < this.colData[column].length; i++) { - GridModel.log.debug("this.colData[" + column + "][" + i + "] = " - + this.colData[column][i]); - } - */ - //GridModel.log.debug("hint courant :" - //+ this.colData[column][currentHintIndex]); + List<Integer> topToBottomHints = new ArrayList<Integer>(); - int currentHintIndex = - GridModel.getLastHintIndex(this.colData[column]); + if (!this.boxes[column][0].isEmpty()) { + topToBottomHints = this.checkTopToBottom(column); + completedColHints.addAll(topToBottomHints); + } - int currentHint = 0; + List<Integer> bottomToTopHints = new ArrayList<Integer>(); - if (!this.boxes[column][currentHint].isEmpty()) { - int currentChain = 0; + if (!this.boxes[column][this.boxes[0].length - 1].isEmpty()) { + bottomToTopHints = this.checkBottomToTop(column); + completedColHints.addAll(bottomToTopHints); + } - while (currentHint < this.boxes[0].length) { - //GridModel.log.debug("dans la boucle, currentHint = " - //+ currentHint + ", currentChain = " + currentChain); + /**/ + List<Integer> colHints = + this.completedHints.getCompleteColHints(column); - if (this.boxes[column][currentHint].isChecked()) { - currentChain++; - } else { - if (this.colData[column][currentHintIndex] - == currentChain) { + for (int hintIndex : colHints) { + if (!completedColHints.contains(hintIndex)) { + this.completedHints.clearColHint(column, hintIndex); + } + } - //GridModel.log.debug("found " + currentChain); + for (int index : completedColHints) { + this.completedHints.setCompleteColHint(column, index); + } - completedColHints.add(currentHintIndex); - currentChain = 0; + /**/ + boolean complete = true; - //GridModel.log.debug("currentHintIndex = " - //+ currentHintIndex); + for (int i = 0; i < this.colData[column].length; i++) { + if (this.colData[column][i] != GridModel.EMPTY_HINT && !completedColHints.contains(i)) { + complete = false; + } + } - currentHintIndex = GridModel - .getPreviousHintIndex(currentHintIndex - 1, - this.colData[column]); + if (!complete) { + return; + } + /**/ - if (currentHintIndex == GridModel.EMPTY_HINT) { - for (int i = currentHint; i < this.boxes[0].length; - i++) { + int totalChecked = 0; - if (this.boxes[column][i].isChecked()) { - completedColHints.clear(); - break; - } - } + for (int i = 0; i < this.boxes[column].length; i++) { + if (this.boxes[column][i].isChecked()) { + totalChecked++; + } + } - break; - } - } + if (totalChecked == this.colHintsTotal[column]) { + return; + } - if (this.boxes[column][currentHint].isEmpty()) { - break; - } + int topToBottomSize = topToBottomHints.size(); + int bottomToTopSize = bottomToTopHints.size(); + + if (topToBottomSize > 0 || bottomToTopSize > 0) { + if (topToBottomSize >= bottomToTopSize) { + for (int hintIndex : bottomToTopHints) { + this.completedHints.clearColHint(column, hintIndex); } - - currentHint++; + } else { + for (int hintIndex : topToBottomHints) { + this.completedHints.clearColHint(column, hintIndex); + } } + } else { + throw new RuntimeException("Confusion occured during " + + "completed hints look-up"); + } + } - //GridModel.log.debug("fin de la boucle, currentHint = " - //+ currentHint); + private List<Integer> checkTopToBottom(int col) { + List<Integer> result = new ArrayList<Integer>(); - if (currentHintIndex != GridModel.EMPTY_HINT - && this.colData[column][currentHintIndex] == currentChain) { + int currentHintIndex = + GridModel.getLastHintIndex(this.colData[col]); + int currentBox = 0; + int currentChain = 0; - //GridModel.log.debug("found " + currentChain); + while (currentBox < this.boxes[0].length) { + if (this.boxes[col][currentBox].isChecked()) { + currentChain++; + } else { + if (this.colData[col][currentHintIndex] == currentChain) { + result.add(currentHintIndex); + currentChain = 0; - completedColHints.add(currentHintIndex); - currentChain = 0; + currentHintIndex = GridModel + .getPreviousHintIndex(currentHintIndex - 1, + this.colData[col]); + + if (currentHintIndex == GridModel.EMPTY_HINT) { + for (int i = currentBox; i < this.boxes[0].length; + i++) { + + if (this.boxes[col][i].isChecked()) { + result.clear(); + break; + } + } + + break; + } + } + + if (this.boxes[col][currentBox].isEmpty()) { + break; + } } + currentBox++; } - currentHintIndex = GridModel.getFirstHintIndex(this.colData[column]); + if (currentHintIndex != GridModel.EMPTY_HINT + && this.colData[col][currentHintIndex] == currentChain) { - //GridModel.log.debug("hintCourant2 : " - //+ this.colData[column][currentHintIndex]); + result.add(currentHintIndex); + } - currentHint = this.boxes[0].length - 1; + return result; + } - if (!this.boxes[column][currentHint].isEmpty()) { - int currentChain = 0; + private List<Integer> checkBottomToTop(int col) { + List<Integer> result = new ArrayList<Integer>(); - while (currentHint >= 0) { - //GridModel.log.debug("dans la boucle2, currentHint = " - //+ currentHint + ", currentChain = " + currentChain); + int currentHintIndex = GridModel.getFirstHintIndex(this.colData[col]); + int currentBox = this.boxes[0].length - 1; + int currentChain = 0; - if (this.boxes[column][currentHint].isChecked()) { - currentChain++; - } else { - if (this.colData[column][currentHintIndex] - == currentChain) { + while (currentBox >= 0) { + if (this.boxes[col][currentBox].isChecked()) { + currentChain++; + } else { + if (this.colData[col][currentHintIndex] == currentChain) { + result.add(currentHintIndex); + currentChain = 0; - //GridModel.log.debug("found2 " + currentChain); + currentHintIndex = + GridModel.getNextHintIndex(currentHintIndex + 1, + this.colData[col]); - completedColHints.add(currentHintIndex); - currentChain = 0; - - currentHintIndex = - GridModel.getNextHintIndex(currentHintIndex + 1, - this.colData[column]); - - if (currentHintIndex == GridModel.EMPTY_HINT) { - for (int i = currentHint; i >= 0; i--) { - if (this.boxes[column][i].isChecked()) { - completedColHints.clear(); - } + if (currentHintIndex == GridModel.EMPTY_HINT) { + for (int i = currentBox; i >= 0; i--) { + if (this.boxes[col][i].isChecked()) { + result.clear(); } - - break; } - } - if (this.boxes[column][currentHint].isEmpty()) { break; } } - currentHint--; + if (this.boxes[col][currentBox].isEmpty()) { + break; + } } - } - List<Integer> colHints = - this.completedHints.getCompleteColHints(column); - - for (int hintIndex : colHints) { - if (!completedColHints.contains(hintIndex)) { - this.completedHints.clearColHint(column, hintIndex); - } + currentBox--; } - for (int index : completedColHints) { - this.completedHints.setCompleteColHint(column, index); - } - - // FIXME - //this.mediator.repaintColHints(column); + return result; } /** Checks wether the grid is finished. */ Modified: trunk/src/picross/grid/ui/GridUI.java =================================================================== --- trunk/src/picross/grid/ui/GridUI.java 2011-07-18 11:29:59 UTC (rev 98) +++ trunk/src/picross/grid/ui/GridUI.java 2011-07-18 12:16:48 UTC (rev 99) @@ -481,6 +481,7 @@ int y = 0; + // Column hints are in reverse order 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); Added: trunk/test/picross/grid/GridModelIntegrationTest.java =================================================================== --- trunk/test/picross/grid/GridModelIntegrationTest.java (rev 0) +++ trunk/test/picross/grid/GridModelIntegrationTest.java 2011-07-18 12:16:48 UTC (rev 99) @@ -0,0 +1,331 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * 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.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; + +import org.easymock.EasyMock; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class GridModelIntegrationTest { + /*** Constante ***/ + + /*** Champ statique ***/ + + private static Logger log = Logger.getLogger(GridModelIntegrationTest.class); + + /*** Static initialisation block. Loads a valid XBM file. ***/ + static { + PropertyConfigurator.configure("log4j.properties"); + } + + /*** M\xE9thode ***/ + + @Test + public void gameSession() { + GridModel gridModel = + new GridModel(new boolean[][] { +{false, false, true, false, false, false, false, true, true, false, true, true}, +{true, false, false, true, false, true, true, true, true, true, false, true}, +{false, false, false, false, false, false, true, false, true, true, false, false}, +{true, false, true, true, false, true, false, false, false, true, true, false}, +{true, true, false, true, true, false, true, false, true, false, false, true}, +{false, false, true, false, false, true, true, false, false, true, true, true}, +{true, true, true, false, true, true, true, false, true, true, false, true}, +{true, false, false, true, true, true, false, true, true, true, true, false}, +{true, false, true, true, false, true, true, false, false, false, true, false}, +{false, false, false, false, false, true, true, true, true, true, false, true}, +{false, true, true, true, false, false, true, true, false, false, false, true}, +{true, true, false, true, true, true, true, true, true, true, true, true}}); + + int[][] hints = gridModel.getRowData(); + + Assert.assertArrayEquals(new int[] {GridModel.EMPTY_HINT, 1, 1, 5, 1}, + hints[5]); + + gridModel.actOnBox(0, 0, GridAction.CROSS); + gridModel.actOnBox(0, 1, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 0, 1); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 1, 3); + gridModel.actOnBox(0, 2, GridAction.CROSS); + gridModel.actOnBox(0, 3, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 3, 3); + gridModel.actOnBox(0, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 0, 2); + gridModel.actOnBox(0, 5, GridAction.CROSS); + gridModel.actOnBox(0, 6, GridAction.CHECK); + gridModel.actOnBox(0, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 7, 2); + gridModel.actOnBox(0, 8, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 0, 3); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 8, 3); + gridModel.actOnBox(0, 9, GridAction.CROSS); + gridModel.actOnBox(0, 10, GridAction.CROSS); + gridModel.actOnBox(0, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 0, 4); + + gridModel.actOnBox(1, 0, GridAction.CROSS); + gridModel.actOnBox(1, 1, GridAction.CROSS); + gridModel.actOnBox(1, 2, GridAction.CROSS); + gridModel.actOnBox(1, 3, GridAction.CROSS); + gridModel.actOnBox(1, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 1, 2); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 4, 4); + gridModel.actOnBox(1, 5, GridAction.CROSS); + gridModel.actOnBox(1, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 1, 3); + gridModel.actOnBox(1, 7, GridAction.CROSS); + gridModel.actOnBox(1, 8, GridAction.CROSS); + gridModel.actOnBox(1, 9, GridAction.CROSS); + gridModel.actOnBox(1, 10, GridAction.CHECK); + gridModel.actOnBox(1, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 1, 4); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 11, 1); + + //gridModel.actOnBox(2, 0, GridAction.EMPTY); + //gridModel.actOnBox(2, 1, GridAction.EMPTY); + gridModel.actOnBox(2, 2, GridAction.CROSS); + gridModel.actOnBox(2, 3, GridAction.CHECK); + gridModel.actOnBox(2, 4, GridAction.CROSS); + gridModel.actOnBox(2, 5, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 5, 2); + gridModel.actOnBox(2, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 6, 3); + gridModel.actOnBox(2, 7, GridAction.CROSS); + gridModel.actOnBox(2, 8, GridAction.CHECK); + gridModel.actOnBox(2, 9, GridAction.CROSS); + gridModel.actOnBox(2, 10, GridAction.CHECK); + gridModel.actOnBox(2, 11, GridAction.CROSS); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 2, 1); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 2, 2); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 2, 3); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 2, 4); + + //gridModel.actOnBox(3, 0, GridAction.EMPTY); + //gridModel.actOnBox(3, 1, GridAction.EMPTY); + gridModel.actOnBox(3, 2, GridAction.CROSS); + gridModel.actOnBox(3, 3, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 3, 2); + gridModel.actOnBox(3, 4, GridAction.CHECK); + gridModel.actOnBox(3, 5, GridAction.CROSS); + gridModel.actOnBox(3, 6, GridAction.CROSS); + gridModel.actOnBox(3, 7, GridAction.CHECK); + gridModel.actOnBox(3, 8, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 8, 2); + gridModel.actOnBox(3, 9, GridAction.CROSS); + gridModel.actOnBox(3, 10, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 10, 2); + gridModel.actOnBox(3, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 3, 2); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 3, 3); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 3, 4); + + gridModel.actOnBox(4, 0, GridAction.CROSS); + gridModel.actOnBox(4, 1, GridAction.CROSS); + gridModel.actOnBox(4, 2, GridAction.CROSS); + gridModel.actOnBox(4, 3, GridAction.CROSS); + gridModel.actOnBox(4, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 4, 2); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 4, 3); + gridModel.actOnBox(4, 5, GridAction.CROSS); + gridModel.actOnBox(4, 6, GridAction.CHECK); + gridModel.actOnBox(4, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 4, 3); + gridModel.actOnBox(4, 8, GridAction.CROSS); + gridModel.actOnBox(4, 9, GridAction.CROSS); + gridModel.actOnBox(4, 10, GridAction.CROSS); + gridModel.actOnBox(4, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 4, 4); + + gridModel.actOnBox(5, 0, GridAction.CROSS); + gridModel.actOnBox(5, 1, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 5, 1); + gridModel.actOnBox(5, 2, GridAction.CROSS); + gridModel.actOnBox(5, 3, GridAction.CROSS); + gridModel.actOnBox(5, 4, GridAction.CROSS); + gridModel.actOnBox(5, 6, GridAction.CHECK); + gridModel.actOnBox(5, 7, GridAction.CHECK); + gridModel.actOnBox(5, 8, GridAction.CHECK); + gridModel.actOnBox(5, 9, GridAction.CHECK); + gridModel.actOnBox(5, 10, GridAction.CROSS); + gridModel.actOnBox(5, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 5, 4); + + gridModel.actOnBox(6, 0, GridAction.CROSS); + gridModel.actOnBox(6, 1, GridAction.CHECK); + gridModel.actOnBox(6, 2, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 6, 2); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 2, 1); + gridModel.actOnBox(6, 3, GridAction.CROSS); + gridModel.actOnBox(6, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 4, 2); + gridModel.actOnBox(6, 5, GridAction.CHECK); + gridModel.actOnBox(6, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 6, 3); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 7, 2); + gridModel.actOnBox(6, 7, GridAction.CROSS); + gridModel.actOnBox(6, 8, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 8, 1); + gridModel.actOnBox(6, 9, GridAction.CHECK); + gridModel.actOnBox(6, 10, GridAction.CHECK); + gridModel.actOnBox(6, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 6, 4); + + gridModel.actOnBox(7, 0, GridAction.CHECK); + gridModel.actOnBox(7, 1, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 7, 2); + gridModel.actOnBox(7, 2, GridAction.CROSS); + gridModel.actOnBox(7, 3, GridAction.CROSS); + gridModel.actOnBox(7, 4, GridAction.CROSS); + gridModel.actOnBox(7, 5, GridAction.CROSS); + gridModel.actOnBox(7, 6, GridAction.CROSS); + gridModel.actOnBox(7, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 7, 3); + gridModel.actOnBox(7, 8, GridAction.CROSS); + gridModel.actOnBox(7, 9, GridAction.CHECK); + gridModel.actOnBox(7, 10, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 10, 1); + gridModel.actOnBox(7, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 7, 4); + + gridModel.actOnBox(8, 0, GridAction.CHECK); + gridModel.actOnBox(8, 1, GridAction.CHECK); + gridModel.actOnBox(8, 2, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 0); + gridModel.actOnBox(8, 3, GridAction.CROSS); + gridModel.actOnBox(8, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 1); + gridModel.actOnBox(8, 5, GridAction.CROSS); + gridModel.actOnBox(8, 6, GridAction.CHECK); + gridModel.actOnBox(8, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 2); + gridModel.actOnBox(8, 8, GridAction.CROSS); + gridModel.actOnBox(8, 9, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 3); + gridModel.actOnBox(8, 10, GridAction.CROSS); + gridModel.actOnBox(8, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 8, 4); + + gridModel.actOnBox(9, 0, GridAction.CROSS); + gridModel.actOnBox(9, 1, GridAction.CHECK); + gridModel.actOnBox(9, 2, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 2, 0); + gridModel.actOnBox(9, 3, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 9, 1); + gridModel.actOnBox(9, 4, GridAction.CROSS); + gridModel.actOnBox(9, 5, GridAction.CHECK); + gridModel.actOnBox(9, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 6, 1); + gridModel.actOnBox(9, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 9, 2); + gridModel.actOnBox(9, 8, GridAction.CROSS); + gridModel.actOnBox(9, 9, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 9, 3); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 9, 1); + gridModel.actOnBox(9, 10, GridAction.CROSS); + gridModel.actOnBox(9, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 9, 4); + + gridModel.actOnBox(10, 0, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 10, 0); + gridModel.actOnBox(10, 1, GridAction.CROSS); + gridModel.actOnBox(10, 2, GridAction.CROSS); + gridModel.actOnBox(10, 3, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 10, 1); +// CHECK +//GridModelIntegrationTest.ensureColHintComplete(gridModel, 3, 0); + gridModel.actOnBox(10, 4, GridAction.CROSS); + gridModel.actOnBox(10, 5, GridAction.CHECK); + gridModel.actOnBox(10, 6, GridAction.CROSS); + gridModel.actOnBox(10, 7, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 7, 0); + gridModel.actOnBox(10, 8, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 8, 0); + gridModel.actOnBox(10, 9, GridAction.CROSS); + gridModel.actOnBox(10, 10, GridAction.CROSS); + gridModel.actOnBox(10, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 10, 3); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 10, 4); + + gridModel.actOnBox(11, 0, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 0, 0); + gridModel.actOnBox(11, 1, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 11, 2); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 1, 0); + gridModel.actOnBox(11, 2, GridAction.CROSS); + gridModel.actOnBox(11, 3, GridAction.CROSS); + gridModel.actOnBox(11, 4, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 4, 0); + gridModel.actOnBox(11, 5, GridAction.CHECK); + gridModel.actOnBox(11, 6, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 11, 3); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 6, 0); + gridModel.actOnBox(11, 7, GridAction.CROSS); + gridModel.actOnBox(11, 8, GridAction.CROSS); + gridModel.actOnBox(11, 9, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 9, 0); + gridModel.actOnBox(11, 10, GridAction.CHECK); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 10, 0); + gridModel.actOnBox(11, 11, GridAction.CHECK); + GridModelIntegrationTest.ensureRowHintComplete(gridModel, 11, 4); + GridModelIntegrationTest.ensureColHintComplete(gridModel, 11, 0); + + gridModel.actOnBox(5, 5, GridAction.CHECK); + CompletedHints completedHints = gridModel.getCompletedHints(); + Assert.assertFalse(completedHints.isRowHintComplete(5, 1)); + Assert.assertTrue(completedHints.isRowHintComplete(5, 2)); + Assert.assertTrue(completedHints.isRowHintComplete(5, 3)); + Assert.assertTrue(completedHints.isRowHintComplete(5, 4)); + } + + private static void ensureRowHintComplete(GridModel model, int row, + int hintIndex) { + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isRowHintComplete(row, hintIndex)); + } + + private static void ensureColHintComplete(GridModel model, int col, + int hintIndex) { + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isColHintComplete(col, hintIndex)); + } +} + Property changes on: trunk/test/picross/grid/GridModelIntegrationTest.java ___________________________________________________________________ Added: svn:keywords + Id Modified: trunk/test/picross/grid/GridModelTest.java =================================================================== --- trunk/test/picross/grid/GridModelTest.java 2011-07-18 11:29:59 UTC (rev 98) +++ trunk/test/picross/grid/GridModelTest.java 2011-07-18 12:16:48 UTC (rev 99) @@ -102,239 +102,185 @@ new GridModel(/*new IGridMediatorStub(),*/ new boolean[0][1]); } + @Test + public void checkValidModel() { + GridModel model = new GridModel(new boolean[][] {{true, false, false}, + {false, true, false}}); + Assert.assertFalse(model.checkCompleted()); - @Test - public void testActOnBox() { - try { - this.model.actOnBox(-1, -1, GridAction.CHECK); - Assert.fail("row = -1"); - } catch (IllegalArgumentException argEx) { } + Box[][] boxes = model.getBoxes(); + Assert.assertEquals(2, boxes.length); + Assert.assertEquals(3, boxes[0].length); + Assert.assertEquals(3, boxes[1].length); - try { - this.model.actOnBox(0, -1, GridAction.CHECK); - Assert.fail("column = -1"); - } catch (IllegalArgumentException argEx) { } + for (Box[] row : boxes) { + for (Box box : row) { + Assert.assertTrue(box.isEmpty()); + } + } - this.model.actOnBox(0, 0, GridAction.CHECK); - } + int[][] colData = model.getColData(); + Assert.assertEquals(2, colData.length); + Assert.assertEquals(1, colData[0].length); + Assert.assertEquals(1, colData[0][0]); + Assert.assertEquals(1, colData[1].length); + Assert.assertEquals(1, colData[1][0]); + int[][] rowData = model.getRowData(); + Assert.assertEquals(3, rowData.length); + Assert.assertEquals(1, rowData[0].length); + Assert.assertEquals(1, rowData[0][0]); + Assert.assertEquals(1, rowData[1].length); + Assert.assertEquals(1, rowData[1][0]); + Assert.assertEquals(1, rowData[2].length); + Assert.assertEquals(0, rowData[2][0]); + } - /* - private static void actOnBox(Object gridModel, int row, int column, Object action) { - TestsHelper.invoke(gridModel, "actOnBox", row, colum, action); - } - */ - @Test - public void incorrectHint() { - GridModel gridModel = new GridModel(/*EasyMock.createMock(IGridMediator.class), - */new boolean[][] { -{false -, false, true, false, false, true, false, true, true, false, true, true -}, - {true, false, false, true, false, false, true, true, true, true, false, true -}, -{false, false, false, false, false, true, true, false, true, true, false, false -}, - {true, false, true, true, false, false, false, false, false, true, true, false -}, - {true, true, false, true, true, false, true, false, true, false, false, true -} -, {false, false, true, false, false, true, true, false, false, true, true, true -}, - {true, true, true, false, true, true, true, false, true, true, false, true -}, - {true, false, false, true, true, true, false, true, true, true, true, false -}, - {true, false, true, true, false, true, true, false, false, false, true, false -}, - {false, false, false, false, false, true, true, true, true, true, false, true -}, - {false, true, true, true, false, false, true, true, false, false, false, true -}, - {true, true, false, true, true, true, true, true, true, true, true, true -} - }); - int[][] hints = gridModel.getRowData(); + public void checkModelWithDifferentNumberOfHints() { + GridModel model = new GridModel(new boolean[][] {{false, false, false, false}, + {true, false, true, true}, + {false, true, false, false}}); + int[][] colData = model.getColData(); + Assert.assertEquals(3, colData.length); + Assert.assertEquals(2, colData[0].length); + Assert.assertEquals(0, colData[0][0]); + Assert.assertEquals(GridModel.EMPTY_HINT, colData[0][1]); + Assert.assertEquals(2, colData[1].length); + Assert.assertEquals(2, colData[1][0]); + Assert.assertEquals(1, colData[1][1]); + Assert.assertEquals(2, colData[2].length); + Assert.assertEquals(1, colData[2][0]); + Assert.assertEquals(GridModel.EMPTY_HINT, colData[2][1]); - GridModelTest.log.debug("row hints :"); - StringBuilder builder = new StringBuilder("["); + int[][] rowData = model.getRowData(); + Assert.assertEquals(4, rowData.length); + Assert.assertEquals(1, rowData[0].length); + Assert.assertEquals(1, rowData[0][0]); + Assert.assertEquals(1, rowData[1].length); + Assert.assertEquals(1, rowData[1][0]); + Assert.assertEquals(1, rowData[2].length); + Assert.assertEquals(1, rowData[2][0]); + Assert.assertEquals(1, rowData[3].length); + Assert.assertEquals(1, rowData[3][0]); + } - for (int[] data : hints) { - builder.append("["); + @Test + public void checkRowHintsInCorrectOrder() { + GridModel model = new GridModel(new boolean[][]{{true},{false},{true},{true}}); + int[][] rowData = model.getRowData(); + Assert.assertEquals(1, rowData.length); + Assert.assertEquals(2, rowData[0].length); + Assert.assertEquals(1, rowData[0][0]); + Assert.assertEquals(2, rowData[0][1]); + } - for (int value : data) { - builder.append(value); - builder.append(", "); - } + @Test + public void checkColHintsInReverseOrder() { + GridModel model = new GridModel(new boolean[][]{{true, false, true, true}}); + int[][] colData = model.getColData(); + Assert.assertEquals(1, colData.length); + Assert.assertEquals(2, colData[0].length); + Assert.assertEquals(2, colData[0][0]); + Assert.assertEquals(1, colData[0][1]); + } - builder.append("], "); - } + @Test + public void checkEmptyRowsAreComplete() { + GridModel model = new GridModel(new boolean[][] {{false, false}, + {true, false}}); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isRowHintComplete(1, 0)); + } - builder.append("]"); - GridModelTest.log.debug(builder.toString()); + @Test + public void checkEmptyColsAreComplete() { + GridModel model = new GridModel(new boolean[][] {{false}, + {true}}); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isColHintComplete(0, 0)); + } - //Assert.assertArrayEquals(new int[] {1, 2, 3, 1}, hints[0]); + @Test + public void checkEmptyRowHintIsComplete() { + GridModel model = new GridModel(new boolean[][] {{true, false}, + {false, false}, + {true, true}}); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isRowHintComplete(1, 0)); + } - gridModel.actOnBox(0, 0, GridAction.CROSS); - gridModel.actOnBox(0, 1, GridAction.CHECK); - gridModel.actOnBox(0, 2, GridAction.CROSS); - gridModel.actOnBox(0, 3, GridAction.CHECK); - gridModel.actOnBox(0, 4, GridAction.CHECK); - gridModel.actOnBox(0, 5, GridAction.CROSS); - gridModel.actOnBox(0, 6, GridAction.CHECK); - gridModel.actOnBox(0, 7, GridAction.CHECK); - gridModel.actOnBox(0, 8, GridAction.CHECK); - gridModel.actOnBox(0, 9, GridAction.CROSS); - gridModel.actOnBox(0, 10, GridAction.CROSS); - gridModel.actOnBox(0, 11, GridAction.CHECK); + @Test + public void checkEmptyColHintIsComplete() { + GridModel model = new GridModel(new boolean[][] {{true, false, true}, + {false, false, true}}); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isColHintComplete(1, 1)); + } - gridModel.actOnBox(1, 0, GridAction.CROSS); - gridModel.actOnBox(1, 1, GridAction.CROSS); - gridModel.actOnBox(1, 2, GridAction.CROSS); - gridModel.actOnBox(1, 3, GridAction.CROSS); - gridModel.actOnBox(1, 4, GridAction.CHECK); - gridModel.actOnBox(1, 5, GridAction.CROSS); - gridModel.actOnBox(1, 6, GridAction.CHECK); - gridModel.actOnBox(1, 7, GridAction.CROSS); - gridModel.actOnBox(1, 8, GridAction.CROSS); - gridModel.actOnBox(1, 9, GridAction.CROSS); - gridModel.actOnBox(1, 10, GridAction.CHECK); - gridModel.actOnBox(1, 11, GridAction.CHECK); + @Test + public void checkRowHintsCorrectlyUpdate() { + GridModel model = new GridModel(new boolean[][] {{true}, {false}}); + model.actOnBox(0, 0, GridAction.CHECK); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isRowHintComplete(0, 0)); + model.actOnBox(0, 1, GridAction.CHECK); + completedHints = model.getCompletedHints(); + Assert.assertFalse(completedHints.isRowHintComplete(0, 0)); + } - gridModel.actOnBox(2, 0, GridAction.EMPTY); - gridModel.actOnBox(2, 1, GridAction.EMPTY); - gridModel.actOnBox(2, 2, GridAction.CROSS); - gridModel.actOnBox(2, 3, GridAction.CHECK); - gridModel.actOnBox(2, 4, GridAction.CROSS); - gridModel.actOnBox(2, 5, GridAction.CHECK); - gridModel.actOnBox(2, 6, GridAction.CHECK); - gridModel.actOnBox(2, 7, GridAction.CROSS); - gridModel.actOnBox(2, 8, GridAction.CHECK); - gridModel.actOnBox(2, 9, GridAction.CROSS); - gridModel.actOnBox(2, 10, GridAction.CHECK); - gridModel.actOnBox(2, 11, GridAction.CROSS); + @Test + public void checkColHintsCorrectlyUpdate() { + GridModel model = new GridModel(new boolean[][] {{true, false}}); + model.actOnBox(0, 0, GridAction.CHECK); + CompletedHints completedHints = model.getCompletedHints(); + Assert.assertTrue(completedHints.isColHintComplete(0, 0)); + model.actOnBox(1, 0, GridAction.CHECK); + completedHints = model.getCompletedHints(); + Assert.assertFalse(completedHints.isColHintComplete(0, 0)); + } - gridModel.actOnBox(3, 0, GridAction.EMPTY); - gridModel.actOnBox(3, 1, GridAction.EMPTY); - gridModel.actOnBox(3, 2, GridAction.CROSS); - gridModel.actOnBox(3, 3, GridAction.CHECK); - gridModel.actOnBox(3, 4, GridAction.CHECK); - gridModel.actOnBox(3, 5, GridAction.CROSS); - gridModel.actOnBox(3, 6, GridAction.CROSS); - gridModel.actOnBox(3, 7, GridAction.CHECK); - gridModel.actOnBox(3, 8, GridAction.CHECK); - gridModel.actOnBox(3, 9, GridAction.CROSS); - gridModel.actOnBox(3, 10, GridAction.CHECK); - gridModel.actOnBox(3, 11, GridAction.CHECK); + @Test + public void testActOnBox() { + try { + this.model.actOnBox(-1, -1, GridAction.CHECK); + Assert.fail("row = -1"); + } catch (IllegalArgumentException argEx) { } - gridModel.actOnBox(4, 0, GridAction.CROSS); - gridModel.actOnBox(4, 1, GridAction.CROSS); - gridModel.actOnBox(4, 2, GridAction.CROSS); - gridModel.actOnBox(4, 3, GridAction.CROSS); - gridModel.actOnBox(4, 4, GridAction.CHECK); - gridModel.actOnBox(4, 5, GridAction.CROSS); - gridModel.actOnBox(4, 6, GridAction.CHECK); - gridModel.actOnBox(4, 7, GridAction.CHECK); - gridModel.actOnBox(4, 8, GridAction.CROSS); - gridModel.actOnBox(4, 9, GridAction.CROSS); - gridModel.actOnBox(4, 10, GridAction.CROSS); - gridModel.actOnBox(4, 11, GridAction.CHECK); + try { + this.model.actOnBox(0, -1, GridAction.CHECK); + Assert.fail("column = -1"); + } catch (IllegalArgumentException argEx) { } - gridModel.actOnBox(5, 0, GridAction.CROSS); - gridModel.actOnBox(5, 1, GridAction.CHECK); - gridModel.actOnBox(5, 2, GridAction.CROSS); - gridModel.actOnBox(5, 3, GridAction.CROSS); - gridModel.actOnBox(5, 4, GridAction.CROSS); - gridModel.actOnBox(5, 5, GridAction.CHECK); - gridModel.actOnBox(5, 6, GridAction.CHECK); - gridModel.actOnBox(5, 7, GridAction.CHECK); - gridModel.actOnBox(5, 8, GridAction.CHECK); - gridModel.actOnBox(5, 9, GridAction.CHECK); - gridModel.actOnBox(5, 10, GridAction.CROSS); - gridModel.actOnBox(5, 11, GridAction.CHECK); + this.model.actOnBox(0, 0, GridAction.CHECK); + } - gridModel.actOnBox(6, 0, GridAction.CROSS); - gridModel.actOnBox(6, 1, GridAction.CHECK); - gridModel.actOnBox(6, 2, GridAction.CHECK); - gridModel.actOnBox(6, 3, GridAction.CROSS); - gridModel.actOnBox(6, 4, GridAction.CHECK); - gridModel.actOnBox(6, 5, GridAction.CHECK); - gridModel.actOnBox(6, 6, GridAction.CHECK); - gridModel.actOnBox(6, 7, GridAction.CROSS); - gridModel.actOnBox(6, 8, GridAction.CHECK); - gridModel.actOnBox(6, 9, GridAction.CHECK); - gridModel.actOnBox(6, 10, GridAction.CHECK); - gridModel.actOnBox(6, 11, GridAction.CHECK); + @Test + public void allHintsAreNotOK() { + GridModel gridModel = new GridModel(new boolean[][] {{false, true}, {true, false}, {false, true}, {true, false}, {false, true}, {true, false}, {true, true}, {true, false}, {true, true}, {true, false}, {false, false}, {true, false}}); + gridModel.actOnBox(0, 0, GridAction.CROSS); + gridModel.actOnBox(0, 1, GridAction.CHECK); + gridModel.actOnBox(0, 2, GridAction.CROSS); + gridModel.actOnBox(0, 3, GridAction.CROSS); + gridModel.actOnBox(0, 4, GridAction.CROSS); + gridModel.actOnBox(0, 5, GridAction.CHECK); + gridModel.actOnBox(0, 6, GridAction.CHECK); + gridModel.actOnBox(0, 7, GridAction.CHECK); + gridModel.actOnBox(0, 8, GridAction.CHECK); + gridModel.actOnBox(0, 9, GridAction.CHECK); + gridModel.actOnBox(0, 10, GridAction.CROSS); + gridModel.actOnBox(0, 11, GridAction.CHECK); - gridModel.actOnBox(7, 0, GridAction.CHECK); - gridModel.actOnBox(7, 1, GridAction.CHECK); - gridModel.actOnBox(7, 2, GridAction.CROSS); - gridModel.actOnBox(7, 3, GridAction.CROSS); - gridModel.actOnBox(7, 4, GridAction.CROSS); - gridModel.actOnBox(7, 5, GridAction.CROSS); - gridModel.actOnBox(7, 6, GridAction.CROSS); - gridModel.actOnBox(7, 7, GridAction.CHECK); - gridModel.actOnBox(7, 8, GridAction.CROSS); - gridModel.actOnBox(7, 9, GridAction.CHECK); - gridModel.actOnBox(7, 10, GridAction.CHECK); - gridModel.actOnBox(7, 11, GridAction.CHECK); + int[][] hints = gridModel.getRowData(); - gridModel.actOnBox(8, 0, GridAction.CHECK); - gridModel.actOnBox(8, 1, GridAction.CHECK); - gridModel.actOnBox(8, 2, GridAction.CHECK); - gridModel.actOnBox(8, 3, GridAction.CROSS); - gridModel.actOnBox(8, 4, GridAction.CHECK); - gridModel.actOnBox(8, 5, GridAction.CROSS); - gridModel.actOnBox(8, 6, GridAction.CHECK); - gridModel.actOnBox(8, 7, GridAction.CHECK); - gridModel.actOnBox(8, 8, GridAction.CROSS); - gridModel.actOnBox(8, 9, GridAction.CHECK); - gridModel.actOnBox(8, 10, GridAction.CROSS); - gridModel.actOnBox(8, 11, GridAction.CHECK); + Assert.assertArrayEquals(new int[] {GridModel.EMPTY_HINT, 1, 1, 5, 1}, + hints[0]); - gridModel.actOnBox(9, 0, GridAction.CROSS); - gridModel.actOnBox(9, 1, GridAction.CHECK); - gridModel.actOnBox(9, 2, GridAction.CHECK); - gridModel.actOnBox(9, 3, GridAction.CHECK); - gridModel.actOnBox(9, 4, GridAction.CROSS); - gridModel.actOnBox(9, 5, GridAction.CHECK); - gridModel.actOnBox(9, 6, GridAction.CHECK); - gridModel.actOnBox(9, 7, GridAction.CHECK); - gridModel.actOnBox(9, 8, GridAction.CROSS); - gridModel.actOnBox(9, 9, GridAction.CHECK); - gridModel.actOnBox(9, 10, GridAction.CROSS); - gridModel.actOnBox(9, 11, GridAction.CHECK); - - gridModel.actOnBox(10, 0, GridAction.CHECK); - gridModel.actOnBox(10, 1, GridAction.CROSS); - gridModel.actOnBox(10, 2, GridAction.CROSS); - gridModel.actOnBox(10, 3, GridAction.CHECK); - gridModel.actOnBox(10, 4, GridAction.CROSS); - gridModel.actOnBox(10, 5, GridAction.CHECK); - gridModel.actOnBox(10, 6, GridAction.CROSS); - gridModel.actOnBox(10, 7, GridAction.CHECK); - gridModel.actOnBox(10, 8, GridAction.CHECK); - gridModel.actOnBox(10, 9, GridAction.CROSS); - gridModel.actOnBox(10, 10, GridAction.CROSS); - gridModel.actOnBox(10, 11, GridAction.CHECK); - - gridModel.actOnBox(11, 0, GridAction.CHECK); - gridModel.actOnBox(11, 1, GridAction.CHECK); - gridModel.actOnBox(11, 2, GridAction.CROSS); - gridModel.actOnBox(11, 3, GridAction.CROSS); - gridModel.actOnBox(11, 4, GridAction.CHECK); - gridModel.actOnBox(11, 5, GridAction.CHECK); - gridModel.actOnBox(11, 6, GridAction.CHECK); - gridModel.actOnBox(11, 7, GridAction.CROSS); - gridModel.actOnBox(11, 8, GridAction.CROSS); - gridModel.actOnBox(11, 9, GridAction.CHECK); - gridModel.actOnBox(11, 10, GridAction.CHECK); - gridModel.actOnBox(11, 11, GridAction.CHECK); - - //CompletedHints completedHints = gridModel.getCompletedHints(); - int rowData = gridModel.getRowData(); - Assert.assertFalse(completedHints.isRowHintComplete(5, 2)); - } + CompletedHints completedHints = gridModel.getCompletedHints(); + Asse... [truncated message content] |
From: <yva...@us...> - 2011-07-18 11:30:05
|
Revision: 98 http://picross.svn.sourceforge.net/picross/?rev=98&view=rev Author: yvan_norsa Date: 2011-07-18 11:29:59 +0000 (Mon, 18 Jul 2011) Log Message: ----------- do not stop tests on first failure Modified Paths: -------------- trunk/build.xml Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2011-06-29 15:09:14 UTC (rev 97) +++ trunk/build.xml 2011-07-18 11:29:59 UTC (rev 98) @@ -156,16 +156,14 @@ <target name="test" depends="dist,compile-test"> - <junit haltonfailure="yes" - filtertrace="off" + <junit filtertrace="off" showoutput="on" printsummary="withOutAndErr"> <formatter type="plain" usefile="false" /> <batchtest fork="yes" - filtertrace="on" - haltonfailure="yes"> + filtertrace="on"> <fileset dir="${test.dir}"> <include name="**/*Test.java" /> <exclude name="**/Abstract*Test.java" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2011-06-29 15:09:24
|
Revision: 97 http://picross.svn.sourceforge.net/picross/?rev=97&view=rev Author: yvan_norsa Date: 2011-06-29 15:09:14 +0000 (Wed, 29 Jun 2011) Log Message: ----------- removed logs Modified Paths: -------------- trunk/src/picross/game/ui/GameMediator.java trunk/src/picross/grid/ui/GridMediator.java Modified: trunk/src/picross/game/ui/GameMediator.java =================================================================== --- trunk/src/picross/game/ui/GameMediator.java 2011-06-29 13:57:17 UTC (rev 96) +++ trunk/src/picross/game/ui/GameMediator.java 2011-06-29 15:09:14 UTC (rev 97) @@ -84,7 +84,7 @@ /** {@inheritDoc} */ @Override public void eventPerformed(SimpleEvent e) { - GameMediator.log.debug("eventPerformed(" + e + ")"); + //GameMediator.log.debug("eventPerformed(" + e + ")"); this.fireEventPerformed(e); } Modified: trunk/src/picross/grid/ui/GridMediator.java =================================================================== --- trunk/src/picross/grid/ui/GridMediator.java 2011-06-29 13:57:17 UTC (rev 96) +++ trunk/src/picross/grid/ui/GridMediator.java 2011-06-29 15:09:14 UTC (rev 97) @@ -135,7 +135,7 @@ /** {@inheritDoc} */ @Override public void eventPerformed(SimpleEvent e) { - GridMediator.log.debug("eventPerformed(" + e + ")"); + //GridMediator.log.debug("eventPerformed(" + e + ")"); String cmd = e.getCommandName(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2011-06-29 13:57:23
|
Revision: 96 http://picross.svn.sourceforge.net/picross/?rev=96&view=rev Author: yvan_norsa Date: 2011-06-29 13:57:17 +0000 (Wed, 29 Jun 2011) Log Message: ----------- fixed bugs due to reorg Modified Paths: -------------- trunk/src/picross/grid/GridModel.java trunk/src/picross/grid/ui/GridMediator.java trunk/test/picross/grid/GridModelTest.java Modified: trunk/src/picross/grid/GridModel.java =================================================================== --- trunk/src/picross/grid/GridModel.java 2011-06-29 13:07:46 UTC (rev 95) +++ trunk/src/picross/grid/GridModel.java 2011-06-29 13:57:17 UTC (rev 96) @@ -394,9 +394,9 @@ return; } - GridModel.log.debug("checkBox(" + row + ", " + column + ")"); - GridModel.log.debug("lastModified == null : " - + (lastModified == null)); + //GridModel.log.debug("checkBox(" + row + ", " + column + ")"); + //GridModel.log.debug("lastModified == null : " + // + (lastModified == null)); /* * If we are trying to check the last box we just checked @@ -471,15 +471,24 @@ this.lastModified = this.boxes[column][row]; this.checkColumn(column); this.checkRow(row); - this.checkCompleted(); + //this.checkCompleted(); } + private boolean erase; + /** Enables the erase mode. */ private void setEraseMode() { // FIXME //this.mediator.setEraseMode(); + this.erase = true; } + public boolean getEraseMode() { + boolean result = this.erase; + this.erase = false; + return result; + } + /** * Checks if a row is empty. * @@ -657,7 +666,7 @@ * @param column column number to check */ private void checkColumn(int column) { - GridModel.log.debug("checkColumn(" + column + ")"); + //GridModel.log.debug("checkColumn(" + column + ")"); if (this.emptyCol(column)) { this.completedHints.setCompleteCol(column); @@ -807,7 +816,7 @@ } /** Checks wether the grid is finished. */ - private void checkCompleted() { + public boolean checkCompleted() { boolean completed = true; for (int i = 0; i < this.data.length; i++) { @@ -823,10 +832,11 @@ } } - if (completed) { + //if (completed) { // FIXME //this.mediator.congratulations(); - } + //} + return completed; } /** Indicates the current action has come to an end. */ Modified: trunk/src/picross/grid/ui/GridMediator.java =================================================================== --- trunk/src/picross/grid/ui/GridMediator.java 2011-06-29 13:07:46 UTC (rev 95) +++ trunk/src/picross/grid/ui/GridMediator.java 2011-06-29 13:57:17 UTC (rev 96) @@ -150,7 +150,17 @@ // TODO what now ? check the model'state this.view.updateBox(col, row, this.model.getBoxes()[col][row]); this.repaint(row, col); + this.repaintRowHints(row); + this.repaintColHints(col); + if (this.model.checkCompleted()) { + this.congratulations(); + } else { + if (this.model.getEraseMode()) { + this.setEraseMode(); + } + } + return; } Modified: trunk/test/picross/grid/GridModelTest.java =================================================================== --- trunk/test/picross/grid/GridModelTest.java 2011-06-29 13:07:46 UTC (rev 95) +++ trunk/test/picross/grid/GridModelTest.java 2011-06-29 13:57:17 UTC (rev 96) @@ -332,8 +332,9 @@ gridModel.actOnBox(11, 10, GridAction.CHECK); gridModel.actOnBox(11, 11, GridAction.CHECK); -//CompletedHints completedHints = gridModel.getCompletedHints(); -//Assert.assertFalse(completedHints.isRowHintComplete(5, 2)); + //CompletedHints completedHints = gridModel.getCompletedHints(); + int rowData = gridModel.getRowData(); + Assert.assertFalse(completedHints.isRowHintComplete(5, 2)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2011-06-29 13:07:52
|
Revision: 95 http://picross.svn.sourceforge.net/picross/?rev=95&view=rev Author: yvan_norsa Date: 2011-06-29 13:07:46 +0000 (Wed, 29 Jun 2011) Log Message: ----------- big reorganisation Added Paths: ----------- trunk/src/picross/grid/Box.java trunk/test/picross/grid/AbstractPicrossGridTest.java Removed Paths: ------------- trunk/test/picross/AbstractPicrossGridTest.java Added: trunk/src/picross/grid/Box.java =================================================================== --- trunk/src/picross/grid/Box.java (rev 0) +++ trunk/src/picross/grid/Box.java 2011-06-29 13:07:46 UTC (rev 95) @@ -0,0 +1,161 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * 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.HashMap; +import java.util.Map; +import java.util.Random; + +import picross.Picross; + +//import org.apache.log4j.Logger; + +/** + * Representation of a box in the grid. + * + * @author Y. Norsa + */ +public class Box { + /*** Enum ***/ + + /** Possibles states of a box. */ + public enum BoxState { + /** An empty box. */ + EMPTY, + + /** A checked box. */ + CHECKED, + + /** A crossed box. */ + CROSSED + } + + /*** Constants ***/ + + /** The class's logger. */ + //private static Logger log = Logger.getLogger(Box.class); + + /** Random number generator. */ + private static Random rand; + + /*** Fields ***/ + + /** State of the box. */ + protected Box.BoxState state; + + /** Pseudo random hash-code. */ + protected int hash; + + /*** Static block ***/ + static { + Box.rand = new Random(); + } + + /*** Constructor ***/ + + /** Constructor. */ + public Box() { + this.empty(); + this.hash = Box.rand.nextInt(); + } + + /*** Methods overloaded from the class Object ***/ + + /** {@inheritDoc} */ + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + if (obj == this) { + return true; + } + + if (!(obj instanceof Box)) { + return false; + } + + return (this.state == ((Box) obj).state); + } + + /** {@inheritDoc} */ + public int hashCode() { + return this.hash; + } + + /*** Methods ***/ + + /** + * Permits to know if the box is checked. + * + * @return boolean telling if the box is checked + */ + public boolean isChecked() { + return this.state == Box.BoxState.CHECKED; + } + + /** + * Permits to know if the box is crossed. + * + * @return boolean telling if the box is crossed + */ + public boolean isCrossed() { + return this.state == Box.BoxState.CROSSED; + } + + /** + * Permits to know if the box is empty. + * + * @return boolean telling if the box is empty + */ + public boolean isEmpty() { + return this.state == Box.BoxState.EMPTY; + } + + /** Empties the box. */ + public void empty() { + this.state = Box.BoxState.EMPTY; + } + + /** Checks the box. */ + public void check() { + this.state = Box.BoxState.CHECKED; + } + + /** Crosses the box. */ + public void cross() { + this.state = Box.BoxState.CROSSED; + } +} + Property changes on: trunk/src/picross/grid/Box.java ___________________________________________________________________ Added: svn:keywords + Id Deleted: trunk/test/picross/AbstractPicrossGridTest.java =================================================================== --- trunk/test/picross/AbstractPicrossGridTest.java 2011-06-29 13:02:58 UTC (rev 94) +++ trunk/test/picross/AbstractPicrossGridTest.java 2011-06-29 13:07:46 UTC (rev 95) @@ -1,112 +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 org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * Abstract test class for the PicrossGrid interface. - * - * @author Y. Norsa - */ -public abstract class AbstractPicrossGridTest { - /*** Field ***/ - - /** The instance to test. */ - private PicrossGrid picrossGrid = null; - - /*** Abstract method ***/ - - /** - * Returns an instance. - * - * @return instance to test - */ - protected abstract PicrossGrid getPicrossGrid(); - - /*** Methods ***/ - - /** Performs the instance initialisation. */ - @Before - public void setUp() { - this.picrossGrid = this.getPicrossGrid(); - } - - /** Tests the method getWidth(). */ - @Test - public void testGetWidth() { - int width = this.picrossGrid.getWidth(); - Assert.assertTrue("width = " + width, (width > 0)); - } - - /** Tests the method getHeight(). */ - @Test - public void testGetHeight() { - int height = this.picrossGrid.getHeight(); - Assert.assertTrue("height = " + height, (height > 0)); - } - - /** Tests the method getData(). */ - @Test - public void testGetData() { - boolean[][] data = this.picrossGrid.getData(); - Assert.assertNotNull("data = null", data); - - int width = this.picrossGrid.getWidth(); - int height = this.picrossGrid.getHeight(); - - Assert.assertEquals("data.length = " + data.length, - width, data.length); - - for (int i = 0; i < width; i++) { - Assert.assertEquals("data[" + i + "].length = " + data[i].length, - height, data[i].length); - } - - boolean atLeastOneCheckedBox = false; - - for (int i = 0; i < width; i++) { - for (int j = 0; j < height; j++) { - if (data[i][j]) { - atLeastOneCheckedBox = true; - break; - } - } - } - - Assert.assertTrue("Empty grid", atLeastOneCheckedBox); - } -} Added: trunk/test/picross/grid/AbstractPicrossGridTest.java =================================================================== --- trunk/test/picross/grid/AbstractPicrossGridTest.java (rev 0) +++ trunk/test/picross/grid/AbstractPicrossGridTest.java 2011-06-29 13:07:46 UTC (rev 95) @@ -0,0 +1,112 @@ +/* + * $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.grid; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Abstract test class for the PicrossGrid interface. + * + * @author Y. Norsa + */ +public abstract class AbstractPicrossGridTest { + /*** Field ***/ + + /** The instance to test. */ + private PicrossGrid picrossGrid = null; + + /*** Abstract method ***/ + + /** + * Returns an instance. + * + * @return instance to test + */ + protected abstract PicrossGrid getPicrossGrid(); + + /*** Methods ***/ + + /** Performs the instance initialisation. */ + @Before + public void setUp() { + this.picrossGrid = this.getPicrossGrid(); + } + + /** Tests the method getWidth(). */ + @Test + public void testGetWidth() { + int width = this.picrossGrid.getWidth(); + Assert.assertTrue("width = " + width, (width > 0)); + } + + /** Tests the method getHeight(). */ + @Test + public void testGetHeight() { + int height = this.picrossGrid.getHeight(); + Assert.assertTrue("height = " + height, (height > 0)); + } + + /** Tests the method getData(). */ + @Test + public void testGetData() { + boolean[][] data = this.picrossGrid.getData(); + Assert.assertNotNull("data = null", data); + + int width = this.picrossGrid.getWidth(); + int height = this.picrossGrid.getHeight(); + + Assert.assertEquals("data.length = " + data.length, + width, data.length); + + for (int i = 0; i < width; i++) { + Assert.assertEquals("data[" + i + "].length = " + data[i].length, + height, data[i].length); + } + + boolean atLeastOneCheckedBox = false; + + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { + if (data[i][j]) { + atLeastOneCheckedBox = true; + break; + } + } + } + + Assert.assertTrue("Empty grid", atLeastOneCheckedBox); + } +} Property changes on: trunk/test/picross/grid/AbstractPicrossGridTest.java ___________________________________________________________________ Added: svn:keywords + Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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] |
From: <yva...@us...> - 2011-06-28 12:29:07
|
Revision: 93 http://picross.svn.sourceforge.net/picross/?rev=93&view=rev Author: yvan_norsa Date: 2011-06-28 12:29:00 +0000 (Tue, 28 Jun 2011) Log Message: ----------- public only javadoc Modified Paths: -------------- trunk/build.xml Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2011-06-16 15:03:44 UTC (rev 92) +++ trunk/build.xml 2011-06-28 12:29:00 UTC (rev 93) @@ -193,7 +193,7 @@ <target name="doc" depends="compile"> - <javadoc destdir="${doc.dir}" access="private" + <javadoc destdir="${doc.dir}" link="http://java.sun.com/j2se/1.5.0/docs/api"> <packageset dir="${src.dir}" defaultexcludes="yes" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2011-06-16 15:03:56
|
Revision: 92 http://picross.svn.sourceforge.net/picross/?rev=92&view=rev Author: yvan_norsa Date: 2011-06-16 15:03:44 +0000 (Thu, 16 Jun 2011) Log Message: ----------- better tests Modified Paths: -------------- trunk/test/picross/AbstractPicrossGridTest.java trunk/test/picross/PicrossTest.java trunk/test/picross/game/random/RandomPicrossModelTest.java trunk/test/picross/grid/BoxTest.java trunk/test/picross/grid/CompletedHintsTest.java trunk/test/picross/grid/GridModelTest.java trunk/test/picross/grid/PaintCommandTest.java Modified: trunk/test/picross/AbstractPicrossGridTest.java =================================================================== --- trunk/test/picross/AbstractPicrossGridTest.java 2011-06-16 12:11:02 UTC (rev 91) +++ trunk/test/picross/AbstractPicrossGridTest.java 2011-06-16 15:03:44 UTC (rev 92) @@ -55,13 +55,13 @@ * * @return instance to test */ - protected abstract PicrossGrid getPicrossGrid() throws Throwable; + protected abstract PicrossGrid getPicrossGrid(); /*** Methods ***/ /** Performs the instance initialisation. */ @Before - public void setUp() throws Throwable { + public void setUp() { this.picrossGrid = this.getPicrossGrid(); } Modified: trunk/test/picross/PicrossTest.java =================================================================== --- trunk/test/picross/PicrossTest.java 2011-06-16 12:11:02 UTC (rev 91) +++ trunk/test/picross/PicrossTest.java 2011-06-16 15:03:44 UTC (rev 92) @@ -69,80 +69,65 @@ /*** Methods ***/ - /** - * Tests the method getImage(). - * - * @throws MissingImageException if a file loading fails. - */ - @Test - public void testGetImage() { - try { - Picross.getImage(null); - Assert.fail("name = null"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void getNullImage() { + Picross.getImage(null); + } - try { - Picross.getImage(""); - Assert.fail("name is empty"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void getImageWithEmptyPath() { + Picross.getImage(""); + } - try { - Picross.getImage("fakeFile"); - Assert.fail("Fake file"); - } catch (MissingImageException imageEx) { } + @Test(expected = MissingImageException.class) + public void getMissingImage() { + Picross.getImage("fakeFile"); + } + @Test + public void getImage() { ImageIcon icon = Picross.getImage("empty.png"); PicrossTest.testIcon(icon, 25, 25); } - /** - * Tests the method getLocalizedImage(). - * - * @throws MissingImageException if a file loading fails. - */ - @Test - public void getLocalizedImage() { - try { - Picross.getLocalizedImage(null); - Assert.fail("name = null"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void getNullLocalizedImage() { + Picross.getLocalizedImage(null); + } - try { - Picross.getLocalizedImage(""); - Assert.fail("name is empty"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void getLocalizedImageWithEmptyPath() { + Picross.getLocalizedImage(""); + } - try { - Picross.getImage("fakeFile"); - Assert.fail("Fake file"); - } catch (MissingImageException imageEx) { } + @Test(expected = MissingImageException.class) + public void getMissingLocalizedImage() { + Picross.getImage("fakeFile"); + } + @Test + public void getLocalizedImage() { ImageIcon icon = Picross.getLocalizedImage("button-play.png"); PicrossTest.testIcon(icon, 150, 50); } - /** - * Tests the method loadDataFile(). - * - * @throws IOException if there is a problem loading the file - */ - @Test - public void testLoadDataFile() throws IOException { - try { - Picross.loadDataFile(null); - Assert.fail("name = null"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void loadNullFile() throws IOException { + Picross.loadDataFile(null); + } - try { - Picross.loadDataFile(""); - Assert.fail("name is empty"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void loadEmptyNamedFile() throws IOException { + Picross.loadDataFile(""); + } - try { - Picross.loadDataFile("fakeFile"); - Assert.fail("Fake file"); - } catch (FileNotFoundException fileEx) { } + @Test(expected = FileNotFoundException.class) + public void loadMissingFile() throws IOException { + Picross.loadDataFile("fakeFile"); + } + @Test + public void loadDataFile() throws IOException { InputStream in = Picross.loadDataFile("asterix.xbm"); Assert.assertNotNull("in = null", in); in.close(); Modified: trunk/test/picross/game/random/RandomPicrossModelTest.java =================================================================== --- trunk/test/picross/game/random/RandomPicrossModelTest.java 2011-06-16 12:11:02 UTC (rev 91) +++ trunk/test/picross/game/random/RandomPicrossModelTest.java 2011-06-16 15:03:44 UTC (rev 92) @@ -55,7 +55,7 @@ /** {@inheritDoc} */ @Override - protected PicrossGrid getPicrossGrid() throws Throwable { + protected PicrossGrid getPicrossGrid() { return new RandomPicrossModel(); } } Modified: trunk/test/picross/grid/BoxTest.java =================================================================== --- trunk/test/picross/grid/BoxTest.java 2011-06-16 12:11:02 UTC (rev 91) +++ trunk/test/picross/grid/BoxTest.java 2011-06-16 15:03:44 UTC (rev 92) @@ -63,121 +63,93 @@ /*** M\xE9thode ***/ @Before - public void setUp() throws Throwable { + public void setUp() { this.box = new Box(); } @Test - public void testCheck() throws Throwable { - BoxTest.checkBox(this.box); - Assert.assertTrue("box unchecked", BoxTest.isBoxChecked(this.box)); + public void testCheck() { + this.box.check(); + Assert.assertTrue("box unchecked", this.box.isChecked()); } @Test - public void testCross() throws Throwable { - BoxTest.crossBox(this.box); - Assert.assertTrue("box not crossed", BoxTest.isBoxCrossed(this.box)); + public void testCross() { + this.box.cross(); + Assert.assertTrue("box not crossed", this.box.isCrossed()); } @Test - public void testEmpty() throws Throwable { + public void testEmpty() { this.box.empty(); - Assert.assertTrue("box not empty", BoxTest.isBoxEmpty(this.box)); + Assert.assertTrue("box not empty", this.box.isEmpty()); } @Test - public void testEquals() throws Throwable { + public void testEquals() { Assert.assertFalse("this.box = null", this.box.equals(null)); Assert.assertTrue("box != box", this.box.equals(this.box)); - BoxTest.checkBox(this.box); + this.box.check(); Box box2 = new Box(); Assert.assertFalse("box = box2", this.box.equals(box2)); - BoxTest.checkBox(box2); + box2.check(); Assert.assertTrue("box != box2", this.box.equals(box2)); } @Test - public void testgetIcon() throws Throwable { - Assert.assertNotNull("empty icon = null", BoxTest.getBoxIcon(this.box)); + public void testgetIcon() { + Assert.assertNotNull("empty icon = null", this.box.getIcon()); - BoxTest.checkBox(this.box); - Assert.assertNotNull("checked icon = null", BoxTest.getBoxIcon(this.box)); + this.box.check(); + Assert.assertNotNull("checked icon = null", this.box.getIcon()); - BoxTest.crossBox(this.box); - Assert.assertNotNull("crossed icon = null", BoxTest.getBoxIcon(this.box)); + this.box.cross(); + Assert.assertNotNull("crossed icon = null", this.box.getIcon()); } @Test - public void testGetRolloverIcon() throws Throwable { + public void testGetRolloverIcon() { Assert.assertNotNull("rollover empty icon = null", - BoxTest.getBoxRolloverIcon(this.box)); + this.box.getRolloverIcon()); - BoxTest.checkBox(this.box); + this.box.check(); Assert.assertNotNull("rollover checked icon = null", - BoxTest.getBoxRolloverIcon(this.box)); + this.box.getRolloverIcon()); - BoxTest.crossBox(this.box); + this.box.cross(); Assert.assertNotNull("rollover crossed icon = null", - BoxTest.getBoxRolloverIcon(this.box)); + this.box.getRolloverIcon()); } @Test - public void testIsChecked() throws Throwable { - BoxTest.checkBox(this.box); + public void testIsChecked() { + this.box.check(); - Assert.assertFalse("box crossed AND checked", BoxTest.isBoxCrossed(this.box)); - Assert.assertFalse("box empty AND checked", BoxTest.isBoxEmpty(this.box)); + Assert.assertFalse("box crossed AND checked", this.box.isCrossed()); + Assert.assertFalse("box empty AND checked", this.box.isEmpty()); } @Test - public void testIsCrossed() throws Throwable { - BoxTest.crossBox(this.box); + public void testIsCrossed() { + this.box.cross(); - Assert.assertFalse("box checked AND crossed", BoxTest.isBoxChecked(this.box)); - Assert.assertFalse("box empty AND crossed", BoxTest.isBoxEmpty(this.box)); + Assert.assertFalse("box checked AND crossed", this.box.isChecked()); + Assert.assertFalse("box empty AND crossed", this.box.isEmpty()); } @Test - public void testIsEmpty() throws Throwable { - Assert.assertFalse("box checked AND empty", BoxTest.isBoxChecked(this.box)); - Assert.assertFalse("box crossed AND empty", BoxTest.isBoxCrossed(this.box)); + public void testIsEmpty() { + Assert.assertFalse("box checked AND empty", this.box.isChecked()); + Assert.assertFalse("box crossed AND empty", this.box.isCrossed()); } @Test(expected = IllegalArgumentException.class) - public void testSetRect() throws Throwable { + public void testSetRect() { this.box.setRect(null); } - - private static void checkBox(Box box) throws Throwable { - box.check(); - } - - private static void crossBox(Box box) throws Throwable { - box.cross(); - } - - private static ImageIcon getBoxIcon(Box box) throws Throwable { - return (ImageIcon) box.getIcon(); - } - - private static ImageIcon getBoxRolloverIcon(Box box) throws Throwable { - return (ImageIcon) box.getRolloverIcon(); - } - - private static boolean isBoxCrossed(Box box) throws Throwable { - return ((Boolean) box.isCrossed()).booleanValue(); - } - - private static boolean isBoxEmpty(Box box) throws Throwable { - return ((Boolean) box.isEmpty()).booleanValue(); - } - - private static boolean isBoxChecked(Box box) throws Throwable { - return ((Boolean) box.isChecked()).booleanValue(); - } } Modified: trunk/test/picross/grid/CompletedHintsTest.java =================================================================== --- trunk/test/picross/grid/CompletedHintsTest.java 2011-06-16 12:11:02 UTC (rev 91) +++ trunk/test/picross/grid/CompletedHintsTest.java 2011-06-16 15:03:44 UTC (rev 92) @@ -63,88 +63,90 @@ /*** M\xE9thode ***/ @Before - public void setUp() throws Throwable { - this.hints = CompletedHintsTest.getCompletedHints(10, 10, 10, 10); + public void setUp() { + this.hints = new CompletedHints(10, 10, 10, 10); } - @Test - public void testCompletedHints() throws Throwable { - try { - CompletedHintsTest.getCompletedHints(-1, -1, -1, -1); - Assert.fail("colsHintsWidth = -1"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void negColWidth() { + new CompletedHints(-1, 1, 1, 1); + } - try { - CompletedHintsTest.getCompletedHints(0, -1, -1, -1); - Assert.fail("colsHintsWidth = 0"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void zeroColWidth() { + new CompletedHints(0, 1, 1, 1); + } + + @Test(expected = IllegalArgumentException.class) + public void negColHeight() { + new CompletedHints(1, -1, 1, 1); + } - try { - CompletedHintsTest.getCompletedHints(1, -1, -1, -1); - Assert.fail("colsHintsHeight = -1"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void zeroColHeight() { + new CompletedHints(1, 0, 1, 1); + } - try { - CompletedHintsTest.getCompletedHints(1, 0, -1, -1); - Assert.fail("colsHintsHeight = 0"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void negRowWidth() { + new CompletedHints(1, 1, -1, 1); + } - try { - CompletedHintsTest.getCompletedHints(1, 1, -1, -1); - Assert.fail("rowsHintsWidth = -1"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void zeroRowWidth() { + new CompletedHints(1, 1, 0, 1); + } - try { - CompletedHintsTest.getCompletedHints(1, 1, 0, -1); - Assert.fail("rowsHintsWidth = 0"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void negRowHeight() { + new CompletedHints(1, 1, 1, -1); + } - try { - CompletedHintsTest.getCompletedHints(1, 1, 1, -1); - Assert.fail("rowsHintsHeight = -1"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void zeroRowHeight() { + new CompletedHints(1, 1, 1, 0); + } - try { - CompletedHintsTest.getCompletedHints(1, 1, 1, 0); - Assert.fail("rowsHintsHeight = 0"); - } catch (IllegalArgumentException argEx) { } + @Test + public void completedHints() { + new CompletedHints(1, 1, 1, 1); } @Test - public void testClearColHint() throws Throwable { - CompletedHintsTest.setCompleteColHint(this.hints, 3, 4); + public void testClearColHint() { + this.hints.setCompleteColHint(3, 4); this.hints.clearColHint(3, 4); - Assert.assertFalse(CompletedHintsTest.isColHintComplete(this.hints, 3, 4)); + Assert.assertFalse(this.hints.isColHintComplete(3, 4)); } @Test - public void testClearRowHint() throws Throwable { - CompletedHintsTest.setCompleteRowHint(this.hints, 8, 2); + public void testClearRowHint() { + this.hints.setCompleteRowHint(8, 2); this.hints.clearRowHint(8, 2); - Assert.assertFalse(CompletedHintsTest.isRowHintComplete(this.hints, 8, 2)); + Assert.assertFalse(this.hints.isRowHintComplete(8, 2)); } - @Test - public void testGetCompleteColHints() throws Throwable { - try { - CompletedHintsTest.getCompleteColHints(this.hints, -1); - Assert.fail("column = -1"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void getOutsideColHint() { + this.hints.getCompleteColHints(-1); + } - try { - CompletedHintsTest.getCompleteColHints(this.hints, 42); - Assert.fail("column = 42"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void getTooHighColHint() { + this.hints.getCompleteColHints(42); + } - List<Integer> complete = CompletedHintsTest.getCompleteColHints(this.hints, 4); + @Test + public void testGetCompleteColHints() { + List<Integer> complete = this.hints.getCompleteColHints(4); Assert.assertNotNull("complete = null", complete); int size = complete.size(); Assert.assertTrue("size = " + size, (size == 0)); - CompletedHintsTest.setCompleteColHint(this.hints, 4, 0); - CompletedHintsTest.setCompleteColHint(this.hints, 4, 9); + this.hints.setCompleteColHint(4, 0); + this.hints.setCompleteColHint(4, 9); - complete = CompletedHintsTest.getCompleteColHints(this.hints, 4); + complete = this.hints.getCompleteColHints(4); Assert.assertNotNull("complete = null", complete); size = complete.size(); Assert.assertTrue("size = " + size, (size == 2)); @@ -156,27 +158,27 @@ Assert.assertTrue("nb2 = " + nb2, (nb2 == 9)); } - @Test - public void testGetCompleteRowHints() throws Throwable { - try { - CompletedHintsTest.getCompleteRowHints(this.hints, -1); - Assert.fail("row = -1"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void getOutsideRowHint() { + this.hints.getCompleteRowHints(-1); + } - try { - CompletedHintsTest.getCompleteRowHints(this.hints, 42); - Assert.fail("row = 42"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void getTooHighRowHint() { + this.hints.getCompleteRowHints(42); + } - List<Integer> complete = CompletedHintsTest.getCompleteRowHints(this.hints, 9); + @Test + public void testGetCompleteRowHints() { + List<Integer> complete = this.hints.getCompleteRowHints(9); Assert.assertNotNull("complete = null", complete); int size = complete.size(); Assert.assertTrue("size = " + size, (size == 0)); - CompletedHintsTest.setCompleteRowHint(this.hints, 9, 3); - CompletedHintsTest.setCompleteRowHint(this.hints, 9, 6); + this.hints.setCompleteRowHint(9, 3); + this.hints.setCompleteRowHint(9, 6); - complete = CompletedHintsTest.getCompleteRowHints(this.hints, 9); + complete = this.hints.getCompleteRowHints(9); Assert.assertNotNull("complete = null", complete); size = complete.size(); Assert.assertTrue("size = " + size, (size == 2)); @@ -189,45 +191,17 @@ } @Test - public void testIsColHintCompleteAndSetCompleteColHint() throws Throwable { - Assert.assertFalse(CompletedHintsTest.isColHintComplete(this.hints, 0, 0)); - CompletedHintsTest.setCompleteColHint(this.hints, 0, 0); - Assert.assertTrue(CompletedHintsTest.isColHintComplete(this.hints, 0, 0)); + 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() throws Throwable { - Assert.assertFalse(CompletedHintsTest.isRowHintComplete(this.hints, 5, 5)); - CompletedHintsTest.setCompleteRowHint(this.hints, 5, 5); - Assert.assertTrue(CompletedHintsTest.isRowHintComplete(this.hints, 5, 5)); + public void testIsRowHintCompleteAndSetCompleteRowHint() { + Assert.assertFalse(this.hints.isRowHintComplete(5, 5)); + this.hints.setCompleteRowHint(5, 5); + Assert.assertTrue(this.hints.isRowHintComplete(5, 5)); } - - private static CompletedHints getCompletedHints(int colHintsWidth, int colHintsHeight, int rowHintsWidth, int rowHintsHeight) throws Throwable { - return new CompletedHints(colHintsWidth, colHintsHeight, rowHintsWidth, rowHintsHeight); - } - - private static void setCompleteColHint(CompletedHints hints, int col, int index) throws Throwable { - hints.setCompleteColHint(col, index); - } - - private static boolean isColHintComplete(CompletedHints hints, int x, int y) throws Throwable { - return ((Boolean) hints.isColHintComplete(x, y)).booleanValue(); - } - - private static void setCompleteRowHint(CompletedHints hints, int row, int index) throws Throwable { - hints.setCompleteRowHint(row, index); - } - - private static boolean isRowHintComplete(CompletedHints hints, int x, int y) throws Throwable { - return ((Boolean) hints.isRowHintComplete(x, y)).booleanValue(); - } - - private static List<Integer> getCompleteColHints(CompletedHints hints, int column) throws Throwable { - return (List<Integer>) hints.getCompleteColHints(column); - } - - private static List<Integer> getCompleteRowHints(CompletedHints hints, int row) throws Throwable { - return (List<Integer>) hints.getCompleteRowHints(row); - } } Modified: trunk/test/picross/grid/GridModelTest.java =================================================================== --- trunk/test/picross/grid/GridModelTest.java 2011-06-16 12:11:02 UTC (rev 91) +++ trunk/test/picross/grid/GridModelTest.java 2011-06-16 15:03:44 UTC (rev 92) @@ -63,33 +63,33 @@ /*** M\xE9thode ***/ @Before - public void setUp() throws Throwable { - this.model = GridModelTest.getGridModel(new IGridMediatorStub(), new boolean[3][5]); + public void setUp() { + this.model = new GridModel(new IGridMediatorStub(), new boolean[3][5]); } - @Test - public void testGridModel() throws Throwable { - try { - GridModelTest.getGridModel(null, null); - Assert.fail("mediator = null"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void gridModelWithNullMediator() { + new GridModel(null, new boolean[1][1]); + } - IGridMediator stub = new IGridMediatorStub(); + @Test(expected = IllegalArgumentException.class) + public void gridModelWithNullData() { + new GridModel(new IGridMediatorStub(), null); + } - try { - GridModelTest.getGridModel(stub, null); - Assert.fail("data = null"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void gridModelWithEmptyData() { + new GridModel(new IGridMediatorStub(), new boolean[0][0]); + } - try { - GridModelTest.getGridModel(stub, new boolean[0][0]); - Assert.fail("empty data"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void gridModelWithoutRows() { + new GridModel(new IGridMediatorStub(), new boolean[1][0]); + } - try { - GridModelTest.getGridModel(stub, new boolean[1][0]); - Assert.fail("empty data"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void gridModelWithoutCols() { + new GridModel(new IGridMediatorStub(), new boolean[0][1]); } /* @@ -108,9 +108,7 @@ GridModelTest.actOnBox(this.model, 0, 0, GridAction.CHECK); } */ - private static GridModel getGridModel(IGridMediator mediator, boolean[][] data) throws Throwable { - return new GridModel(mediator, data); - } + /* private static void actOnBox(Object gridModel, int row, int column, Object action) { TestsHelper.invoke(gridModel, "actOnBox", row, colum, action); Modified: trunk/test/picross/grid/PaintCommandTest.java =================================================================== --- trunk/test/picross/grid/PaintCommandTest.java 2011-06-16 12:11:02 UTC (rev 91) +++ trunk/test/picross/grid/PaintCommandTest.java 2011-06-16 15:03:44 UTC (rev 92) @@ -40,23 +40,19 @@ * @author Y. Norsa */ public class PaintCommandTest { - @Test - public void testPaintCommand() throws Throwable { - try { - PaintCommandTest.getPaintCommand(-1, -1); - Assert.fail("row = -1"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void paintCommandWithInvalidRow() { + new PaintCommand(-1, 0); + } - try { - PaintCommandTest.getPaintCommand(0, -1); - Assert.fail("column = -1"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void paintCommandWithInvalidCol() { + new PaintCommand(0, -1); + } - PaintCommandTest.getPaintCommand(0, 0); + @Test + public void testPaintCommand() { + new PaintCommand(0, 0); } - - private static Object getPaintCommand(int row, int column) throws Throwable { - return new picross.grid.PaintCommand(row, column); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |