Thread: [Picross-commit] SF.net SVN: picross:[90] trunk
Status: Pre-Alpha
Brought to you by:
yvan_norsa
From: <yva...@us...> - 2011-06-16 11:11:19
|
Revision: 90 http://picross.svn.sourceforge.net/picross/?rev=90&view=rev Author: yvan_norsa Date: 2011-06-16 11:11:11 +0000 (Thu, 16 Jun 2011) Log Message: ----------- reorganisation Modified Paths: -------------- trunk/bugsFilter.xml trunk/build.xml Added Paths: ----------- trunk/lib/easymock.jar trunk/test/ trunk/test/picross/ trunk/test/picross/AbstractPicrossGridTest.java trunk/test/picross/PicrossTest.java trunk/test/picross/game/ trunk/test/picross/game/random/ trunk/test/picross/game/random/RandomPicrossModelTest.java trunk/test/picross/game/simple/ trunk/test/picross/game/simple/XBMModelTest.java trunk/test/picross/grid/ trunk/test/picross/grid/BoxTest.java trunk/test/picross/grid/CompletedHintsTest.java trunk/test/picross/grid/FillCommandTest.java trunk/test/picross/grid/GridModelTest.java trunk/test/picross/grid/IGridMediatorStub.java trunk/test/picross/grid/PaintCommandTest.java trunk/test/picross/package.html Removed Paths: ------------- trunk/src/picross/game/random/tests/ trunk/src/picross/game/simple/tests/ trunk/src/picross/grid/tests/ trunk/src/picross/tests/ Modified: trunk/bugsFilter.xml =================================================================== --- trunk/bugsFilter.xml 2011-06-07 12:58:50 UTC (rev 89) +++ trunk/bugsFilter.xml 2011-06-16 11:11:11 UTC (rev 90) @@ -1,8 +1,4 @@ <FindBugsFilter> - <Match> - <Package name="~.*\.tests" /> - </Match> - <Match classregex=".*"> <Bug pattern="DM_CONVERT_CASE,LSC_LITERAL_STRING_COMPARISON,CLI_CONSTANT_LIST_INDEX,S508C_SET_COMP_COLOR,S508C_NO_SETLABELFOR,DRE_DECLARED_RUNTIME_EXCEPTION" /> </Match> Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2011-06-07 12:58:50 UTC (rev 89) +++ trunk/build.xml 2011-06-16 11:11:11 UTC (rev 90) @@ -13,6 +13,8 @@ value="lib" /> <property name="src.dir" value="src" /> + <property name="test.dir" + value="test" /> <property name="jar.name" value="${dist.dir}/${ant.project.name}.jar" /> @@ -21,6 +23,8 @@ 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="junit.jar" value="${lib.dir}/junit.jar" /> <property name="log4j.jar" @@ -63,6 +67,7 @@ <pathelement location="${build.dir}" /> <pathelement location="${bundleHelper.jar}" /> + <pathelement location="${easymock.jar}" /> <pathelement location="${junit.jar}" /> <pathelement location="${log4j.jar}" /> <pathelement location="${mmvcs.jar}" /> @@ -83,6 +88,19 @@ </javac> </target> + <target name="compile-test" + depends="compile"> + <javac srcdir="${test.dir}" + destdir="${build.dir}" + deprecation="on" + debug="on" + optimize="off"> + <compilerarg value="-Xlint:all" /> + + <classpath refid="classpath" /> + </javac> + </target> + <target name="dist" depends="compile"> <copy todir="${build.dir}/picross/properties" @@ -140,7 +158,7 @@ </target> <target name="test" - depends="dist"> + depends="dist,compile-test"> <junit haltonfailure="yes" filtertrace="off" showoutput="on" @@ -151,7 +169,7 @@ <batchtest fork="yes" filtertrace="on" haltonfailure="yes"> - <fileset dir="${src.dir}"> + <fileset dir="${test.dir}"> <include name="**/*Test.java" /> <exclude name="**/Abstract*Test.java" /> </fileset> @@ -178,14 +196,10 @@ <target name="doc" depends="compile"> - <!-- FIXME test classes which are not in a "tests" subpackage - shouldn't be included in the generated Javadoc --> <javadoc destdir="${doc.dir}" access="private" link="http://java.sun.com/j2se/1.5.0/docs/api"> <packageset dir="${src.dir}" - defaultexcludes="yes"> - <exclude name="**/tests/**" /> - </packageset> + defaultexcludes="yes" /> <classpath refid="classpath" /> </javadoc> @@ -212,8 +226,7 @@ tofile="checkstyle.xml" /> <fileset dir="${src.dir}" - includes="**/*.java" - excludes="**/tests/" /> + includes="**/*.java" /> </checkstyle> <xslt in="checkstyle.xml" Added: trunk/lib/easymock.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/easymock.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Copied: trunk/test/picross/AbstractPicrossGridTest.java (from rev 88, trunk/src/picross/tests/AbstractPicrossGridTest.java) =================================================================== --- trunk/test/picross/AbstractPicrossGridTest.java (rev 0) +++ trunk/test/picross/AbstractPicrossGridTest.java 2011-06-16 11:11:11 UTC (rev 90) @@ -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; + +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() throws Throwable; + + /*** Methods ***/ + + /** Performs the instance initialisation. */ + @Before + public void setUp() throws Throwable { + 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: trunk/test/picross/PicrossTest.java (from rev 88, trunk/src/picross/tests/PicrossTest.java) =================================================================== --- trunk/test/picross/PicrossTest.java (rev 0) +++ trunk/test/picross/PicrossTest.java 2011-06-16 11:11:11 UTC (rev 90) @@ -0,0 +1,150 @@ +/* + * $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 javax.swing.ImageIcon; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Tests for the static methods of the Picross class. + * + * @author Y. Norsa + */ +public class PicrossTest { + /*** Static method ***/ + + /** + * Helper method to test a loaded icon. + * + * @param icon the icon to test + * @param width the expected icon width + * @param height the expected icon height + */ + private static void testIcon(ImageIcon icon, int width, int height) { + Assert.assertNotNull("icon = null", icon); + + int iconWidth = icon.getIconWidth(); + Assert.assertEquals("width = " + iconWidth, width, iconWidth); + + int iconHeight = icon.getIconHeight(); + Assert.assertEquals("height = " + iconHeight, height, iconHeight); + } + + /*** 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) { } + + try { + Picross.getImage(""); + Assert.fail("name is empty"); + } catch (IllegalArgumentException argEx) { } + + try { + Picross.getImage("fakeFile"); + Assert.fail("Fake file"); + } catch (MissingImageException imageEx) { } + + 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) { } + + try { + Picross.getLocalizedImage(""); + Assert.fail("name is empty"); + } catch (IllegalArgumentException argEx) { } + + try { + Picross.getImage("fakeFile"); + Assert.fail("Fake file"); + } catch (MissingImageException imageEx) { } + + 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) { } + + try { + Picross.loadDataFile(""); + Assert.fail("name is empty"); + } catch (IllegalArgumentException argEx) { } + + try { + Picross.loadDataFile("fakeFile"); + Assert.fail("Fake file"); + } catch (FileNotFoundException fileEx) { } + + InputStream in = Picross.loadDataFile("asterix.xbm"); + Assert.assertNotNull("in = null", in); + in.close(); + } +} Copied: trunk/test/picross/game/random/RandomPicrossModelTest.java (from rev 88, trunk/src/picross/game/random/tests/RandomPicrossModelTest.java) =================================================================== --- trunk/test/picross/game/random/RandomPicrossModelTest.java (rev 0) +++ trunk/test/picross/game/random/RandomPicrossModelTest.java 2011-06-16 11:11:11 UTC (rev 90) @@ -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.game.random; + +import fr.cle.tests.TestsHelper; + +import org.apache.log4j.PropertyConfigurator; + +import org.junit.Test; + +import picross.AbstractPicrossGridTest; +import picross.PicrossGrid; + +/** + * Test class for the random model. + * + * @author Y. Norsa + */ +public class RandomPicrossModelTest extends AbstractPicrossGridTest { + /** Static block. */ + static { + PropertyConfigurator.configure("log4j.properties"); + } + + /*** Overloaded method from the class AbstractPicrossGridTest ***/ + + /** {@inheritDoc} */ + @Override + protected PicrossGrid getPicrossGrid() throws Throwable { + //return new RandomPicrossModel(); + + return (PicrossGrid) TestsHelper.getInstance("picross.game.random.RandomPicrossModel"); + } +} Copied: trunk/test/picross/game/simple/XBMModelTest.java (from rev 88, trunk/src/picross/game/simple/tests/XBMModelTest.java) =================================================================== --- trunk/test/picross/game/simple/XBMModelTest.java (rev 0) +++ trunk/test/picross/game/simple/XBMModelTest.java 2011-06-16 11:11:11 UTC (rev 90) @@ -0,0 +1,123 @@ +/* + * $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.simple; + +import fr.cle.tests.TestsHelper; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.log4j.PropertyConfigurator; + +import org.junit.Assert; +import org.junit.Test; + +import picross.AbstractPicrossGridTest; +import picross.Picross; +import picross.PicrossException; +import picross.PicrossGrid; + +/** + * Unit tests for XBMModel. + * + * @author Y. Norsa + */ +public final class XBMModelTest extends AbstractPicrossGridTest { + /*** Static field ***/ + + /** Valid XBM model. */ + private static PicrossGrid realModel; + + /*** Static initialisation block. Loads a valid XBM file. ***/ + static { + PropertyConfigurator.configure("log4j.properties"); + + try { + XBMModelTest.realModel = + //new XBMModel(Picross.loadDataFile("asterix.xbm")); + XBMModelTest.newXBMModel(Picross.loadDataFile("asterix.xbm")); + } catch (IOException ioEx) { + throw new ExceptionInInitializerError(ioEx); + } catch (PicrossException xbmEx) { + throw new ExceptionInInitializerError(xbmEx); + } + } + + /*** Method overloaded from the class AbstractPicrossGridTest ***/ + + /** {@inheritDoc} */ + protected PicrossGrid getPicrossGrid() { + return XBMModelTest.realModel; + } + + /** + * Tests the XBMModel constructor. + * + * @throws IOException if there is a problem with a stream loading + * @throws XBMException if a file isn't valid + */ + @Test + public void testXBMModel() throws IOException, PicrossException { + try { + //new XBMModel(null); + XBMModelTest.newXBMModel(null); + Assert.fail("Tried to load a null model"); + } catch (IllegalArgumentException argEx) { } + + try { + //new XBMModel(new ByteArrayInputStream("".getBytes())); + XBMModelTest.newXBMModel(new ByteArrayInputStream("".getBytes())); + Assert.fail("Empty file"); + } catch (PicrossException xbmEx) { } + } + + private static PicrossGrid newXBMModel(InputStream in) throws IOException, PicrossException { + try { + return (PicrossGrid) TestsHelper.getInstance("picross.game.simple.XBMModel", in); + } catch (Throwable throwable) { + if (throwable instanceof IOException) { + throw (IOException) throwable; + } + + if (throwable instanceof PicrossException) { + throw (PicrossException) throwable; + } + + //if (throwable instanceof RuntimeException) { + throw (RuntimeException) throwable; + //} + } + } +} Copied: trunk/test/picross/grid/BoxTest.java (from rev 88, trunk/src/picross/grid/tests/BoxTest.java) =================================================================== --- trunk/test/picross/grid/BoxTest.java (rev 0) +++ trunk/test/picross/grid/BoxTest.java 2011-06-16 11:11:11 UTC (rev 90) @@ -0,0 +1,192 @@ +/* + * $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 fr.cle.tests.TestsHelper; + +import javax.swing.ImageIcon; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class BoxTest { + /*** Constante ***/ + + /*** Champ statique ***/ + + /*** Champ ***/ + + private Object box = null; + + /*** Constructeur ***/ + + /** + * Constructeur. + */ + /* + BoxTest() { + } + */ + /*** M\xE9thode ***/ + + @Before + public void setUp() throws Throwable { + this.box = BoxTest.getBox(); + } + + @Test + public void testCheck() throws Throwable { + BoxTest.checkBox(this.box); + Assert.assertTrue("box unchecked", BoxTest.isBoxChecked(this.box)); + } + + @Test + public void testCross() throws Throwable { + BoxTest.crossBox(this.box); + Assert.assertTrue("box not crossed", BoxTest.isBoxCrossed(this.box)); + } + + @Test + public void testEmpty() throws Throwable { + TestsHelper.invoke(this.box, "empty"); + Assert.assertTrue("box not empty", BoxTest.isBoxEmpty(this.box)); + } + + @Test + public void testEquals() throws Throwable { + Assert.assertFalse("this.box = null", this.box.equals(null)); + Assert.assertTrue("box != box", this.box.equals(this.box)); + + BoxTest.checkBox(this.box); + + Object box2 = BoxTest.getBox(); + Assert.assertFalse("box = box2", this.box.equals(box2)); + + BoxTest.checkBox(box2); + + Assert.assertTrue("box != box2", this.box.equals(box2)); + } + + @Test + public void testgetIcon() throws Throwable { + Assert.assertNotNull("empty icon = null", BoxTest.getBoxIcon(this.box)); + + BoxTest.checkBox(this.box); + Assert.assertNotNull("checked icon = null", BoxTest.getBoxIcon(this.box)); + + BoxTest.crossBox(this.box); + Assert.assertNotNull("crossed icon = null", BoxTest.getBoxIcon(this.box)); + } + + @Test + public void testGetRolloverIcon() throws Throwable { + Assert.assertNotNull("rollover empty icon = null", + BoxTest.getBoxRolloverIcon(this.box)); + + BoxTest.checkBox(this.box); + Assert.assertNotNull("rollover checked icon = null", + BoxTest.getBoxRolloverIcon(this.box)); + + BoxTest.crossBox(this.box); + Assert.assertNotNull("rollover crossed icon = null", + BoxTest.getBoxRolloverIcon(this.box)); + } + + @Test + public void testIsChecked() throws Throwable { + BoxTest.checkBox(this.box); + + Assert.assertFalse("box crossed AND checked", BoxTest.isBoxCrossed(this.box)); + Assert.assertFalse("box empty AND checked", BoxTest.isBoxEmpty(this.box)); + } + + @Test + public void testIsCrossed() throws Throwable { + BoxTest.crossBox(this.box); + + Assert.assertFalse("box checked AND crossed", BoxTest.isBoxChecked(this.box)); + Assert.assertFalse("box empty AND crossed", BoxTest.isBoxEmpty(this.box)); + } + + @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)); + } + + @Test + public void testSetRect() throws Throwable { + try { + TestsHelper.invoke(this.box, "setRect", null); + Assert.fail("box.setRect(null)"); + } catch (IllegalArgumentException argEx) { } + } + + private static Object getBox() throws Throwable { + return TestsHelper.getInstance("picross.grid.Box"); + } + + private static void checkBox(Object box) throws Throwable { + TestsHelper.invoke(box, "check"); + } + + private static void crossBox(Object box) throws Throwable { + TestsHelper.invoke(box, "cross"); + } + + private static ImageIcon getBoxIcon(Object box) throws Throwable { + return (ImageIcon) TestsHelper.invoke(box, "getIcon"); + } + + private static ImageIcon getBoxRolloverIcon(Object box) throws Throwable { + return (ImageIcon) TestsHelper.invoke(box, "getRolloverIcon"); + } + + private static boolean isBoxCrossed(Object box) throws Throwable { + return ((Boolean) TestsHelper.invoke(box, "isCrossed")).booleanValue(); + } + + private static boolean isBoxEmpty(Object box) throws Throwable { + return ((Boolean) TestsHelper.invoke(box, "isEmpty")).booleanValue(); + } + + private static boolean isBoxChecked(Object box) throws Throwable { + return ((Boolean) TestsHelper.invoke(box, "isChecked")).booleanValue(); + } +} + Copied: trunk/test/picross/grid/CompletedHintsTest.java (from rev 88, trunk/src/picross/grid/tests/CompletedHintsTest.java) =================================================================== --- trunk/test/picross/grid/CompletedHintsTest.java (rev 0) +++ trunk/test/picross/grid/CompletedHintsTest.java 2011-06-16 11:11:11 UTC (rev 90) @@ -0,0 +1,235 @@ +/* + * $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 fr.cle.tests.TestsHelper; + +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 ***/ + + Object hints = null; + + /*** Constructeur ***/ + + /** + * Constructeur. + */ + /* + CompletedHintsTest() { + } + */ + /*** M\xE9thode ***/ + + @Before + public void setUp() throws Throwable { + this.hints = CompletedHintsTest.getCompletedHints(10, 10, 10, 10); + } + + @Test + public void testCompletedHints() throws Throwable { + try { + CompletedHintsTest.getCompletedHints(-1, -1, -1, -1); + Assert.fail("colsHintsWidth = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(0, -1, -1, -1); + Assert.fail("colsHintsWidth = 0"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(1, -1, -1, -1); + Assert.fail("colsHintsHeight = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(1, 0, -1, -1); + Assert.fail("colsHintsHeight = 0"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(1, 1, -1, -1); + Assert.fail("rowsHintsWidth = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(1, 1, 0, -1); + Assert.fail("rowsHintsWidth = 0"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(1, 1, 1, -1); + Assert.fail("rowsHintsHeight = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(1, 1, 1, 0); + Assert.fail("rowsHintsHeight = 0"); + } catch (IllegalArgumentException argEx) { } + } + + @Test + public void testClearColHint() throws Throwable { + CompletedHintsTest.setCompleteColHint(this.hints, 3, 4); + TestsHelper.invoke(this.hints, "clearColHint", 3, 4); + Assert.assertFalse(CompletedHintsTest.isColHintComplete(this.hints, 3, 4)); + } + + @Test + public void testClearRowHint() throws Throwable { + CompletedHintsTest.setCompleteRowHint(this.hints, 8, 2); + TestsHelper.invoke(this.hints, "clearRowHint", 8, 2); + Assert.assertFalse(CompletedHintsTest.isRowHintComplete(this.hints, 8, 2)); + } + + @Test + public void testGetCompleteColHints() throws Throwable { + try { + CompletedHintsTest.getCompleteColHints(this.hints, -1); + Assert.fail("column = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompleteColHints(this.hints, 42); + Assert.fail("column = 42"); + } catch (IllegalArgumentException argEx) { } + + List<Integer> complete = CompletedHintsTest.getCompleteColHints(this.hints, 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); + + complete = CompletedHintsTest.getCompleteColHints(this.hints, 4); + Assert.assertNotNull("complete = null", complete); + size = complete.size(); + Assert.assertTrue("size = " + size, (size == 2)); + + int nb1 = complete.get(0); + Assert.assertTrue("nb1 = " + nb1, (nb1 == 0)); + + int nb2 = complete.get(1); + Assert.assertTrue("nb2 = " + nb2, (nb2 == 9)); + } + + @Test + public void testGetCompleteRowHints() throws Throwable { + try { + CompletedHintsTest.getCompleteRowHints(this.hints, -1); + Assert.fail("row = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompleteRowHints(this.hints, 42); + Assert.fail("row = 42"); + } catch (IllegalArgumentException argEx) { } + + List<Integer> complete = CompletedHintsTest.getCompleteRowHints(this.hints, 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); + + complete = CompletedHintsTest.getCompleteRowHints(this.hints, 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() throws Throwable { + Assert.assertFalse(CompletedHintsTest.isColHintComplete(this.hints, 0, 0)); + CompletedHintsTest.setCompleteColHint(this.hints, 0, 0); + Assert.assertTrue(CompletedHintsTest.isColHintComplete(this.hints, 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)); + } + + private static Object getCompletedHints(int colHintsWidth, int colHintsHeight, int rowHintsWidth, int rowHintsHeight) throws Throwable { + return TestsHelper.getInstance("picross.grid.CompletedHints", colHintsWidth, colHintsHeight, rowHintsWidth, rowHintsHeight); + } + + private static void setCompleteColHint(Object hints, int col, int index) throws Throwable { + TestsHelper.invoke(hints, "setCompleteColHint", col, index); + } + + private static boolean isColHintComplete(Object hints, int x, int y) throws Throwable { + return ((Boolean) TestsHelper.invoke(hints, "isColHintComplete", x, y)).booleanValue(); + } + + private static void setCompleteRowHint(Object hints, int row, int index) throws Throwable { + TestsHelper.invoke(hints, "setCompleteRowHint", row, index); + } + + private static boolean isRowHintComplete(Object hints, int x, int y) throws Throwable { + return ((Boolean) TestsHelper.invoke(hints, "isRowHintComplete", x, y)).booleanValue(); + } + + private static List<Integer> getCompleteColHints(Object hints, int column) throws Throwable { + return (List<Integer>) TestsHelper.invoke(hints, "getCompleteColHints", column); + } + + private static List<Integer> getCompleteRowHints(Object hints, int row) throws Throwable { + return (List<Integer>) TestsHelper.invoke(hints, "getCompleteRowHints", row); + } +} + Copied: trunk/test/picross/grid/FillCommandTest.java (from rev 88, trunk/src/picross/grid/tests/FillCommandTest.java) =================================================================== --- trunk/test/picross/grid/FillCommandTest.java (rev 0) +++ trunk/test/picross/grid/FillCommandTest.java 2011-06-16 11:11:11 UTC (rev 90) @@ -0,0 +1,82 @@ +/* + * $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.Test; + +/** + * @author Y. Norsa + */ +public class FillCommandTest { + /*** Constante ***/ + + /*** Champ statique ***/ + + /*** Champ ***/ + + /*** Constructeur ***/ + + /** + * Constructeur. + */ + /* + FillCommandTest() { + } + */ + /*** M\xE9thode ***/ + + @Test + public void testFillCommand() { + /* try { + new FillCommand(-1, -1, GridAction.UNKNOWN); + Assert.fail("row = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + new FillCommand(0, -1, GridAction.UNKNOWN); + Assert.fail("column = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + new FillCommand(0, 0, GridAction.UNKNOWN); + Assert.fail("UNKNOWN type"); + } catch (IllegalArgumentException argEx) { } + + new FillCommand(0, 0, GridAction.CHECK); + */ + } + +} + Copied: trunk/test/picross/grid/GridModelTest.java (from rev 88, trunk/src/picross/grid/tests/GridModelTest.java) =================================================================== --- trunk/test/picross/grid/GridModelTest.java (rev 0) +++ trunk/test/picross/grid/GridModelTest.java 2011-06-16 11:11:11 UTC (rev 90) @@ -0,0 +1,122 @@ +/* + * $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 fr.cle.tests.TestsHelper; + +import org.easymock.EasyMock; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class GridModelTest { + /*** Constante ***/ + + /*** Champ statique ***/ + + /*** Champ ***/ + + private Object model = null; + + /*** Constructeur ***/ + + /** + * Constructeur. + */ + /* + GridModelTest() { + }*/ + + /*** M\xE9thode ***/ + + @Before + public void setUp() throws Throwable { + this.model = GridModelTest.getGridModel(new IGridMediatorStub(), new boolean[3][5]); + } + + @Test + public void testGridModel() throws Throwable { + try { + GridModelTest.getGridModel(null, null); + Assert.fail("mediator = null"); + } catch (IllegalArgumentException argEx) { } + + IGridMediator stub = new IGridMediatorStub(); + + try { + GridModelTest.getGridModel(stub, null); + Assert.fail("data = null"); + } catch (IllegalArgumentException argEx) { } + + try { + GridModelTest.getGridModel(stub, new boolean[0][0]); + Assert.fail("empty data"); + } catch (IllegalArgumentException argEx) { } + + try { + GridModelTest.getGridModel(stub, new boolean[1][0]); + Assert.fail("empty data"); + } catch (IllegalArgumentException argEx) { } + } + + /* + @Test + public void testActOnBox() { + try { + GridModelTest.actOnBox(this.model, -1, -1, GridAction.CHECK); + Assert.fail("row = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + GridModelTest.actOnBox(this.model, 0, -1, GridAction.CHECK); + Assert.fail("column = -1"); + } catch (IllegalArgumentException argEx) { } + + GridModelTest.actOnBox(this.model, 0, 0, GridAction.CHECK); + } + */ + private static Object getGridModel(IGridMediator mediator, boolean[][] data) throws Throwable { + return TestsHelper.getInstance("picross.grid.GridModel", mediator, data); + } + /* + private static void actOnBox(Object gridModel, int row, int column, Object action) { + TestsHelper.invoke(gridModel, "actOnBox", row, colum, action); + } + */ +} + Copied: trunk/test/picross/grid/IGridMediatorStub.java (from rev 88, trunk/src/picross/grid/tests/IGridMediatorStub.java) =================================================================== --- trunk/test/picross/grid/IGridMediatorStub.java (rev 0) +++ trunk/test/picross/grid/IGridMediatorStub.java 2011-06-16 11:11:11 UTC (rev 90) @@ -0,0 +1,82 @@ +/* + * $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 fr.cle.mmvcs.SimpleEvent; +import fr.cle.mmvcs.SimpleListener; + +/** + * @author Y. Norsa + */ +public class IGridMediatorStub implements IGridMediator { + /*** Constante ***/ + + /*** Champ statique ***/ + + /*** Champ ***/ + + /*** Constructeur ***/ + + /** + * Constructeur. + */ + /* + IGridMediatorStub() { + } + */ + + /*** M\xE9thode ***/ + + public void repaint(int row, int column) { } + + public void repaintColHints(int col) { } + + public void repaintRowHints(int row) { } + + public void congratulations() { } + + public void setEraseMode() { } + + public GridView getView() { + return null; + } + + public void eventPerformed(SimpleEvent e) { + } + + public void addSimpleListener(SimpleListener listener) { } + + public void removeSimpleListener(SimpleListener listener) { } +} + Copied: trunk/test/picross/grid/PaintCommandTest.java (from rev 88, trunk/src/picross/grid/tests/PaintCommandTest.java) =================================================================== --- trunk/test/picross/grid/PaintCommandTest.java (rev 0) +++ trunk/test/picross/grid/PaintCommandTest.java 2011-06-16 11:11:11 UTC (rev 90) @@ -0,0 +1,64 @@ +/* + * $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 fr.cle.tests.TestsHelper; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class PaintCommandTest { + @Test + public void testPaintCommand() throws Throwable { + try { + PaintCommandTest.getPaintCommand(-1, -1); + Assert.fail("row = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + PaintCommandTest.getPaintCommand(0, -1); + Assert.fail("column = -1"); + } catch (IllegalArgumentException argEx) { } + + PaintCommandTest.getPaintCommand(0, 0); + } + + private static Object getPaintCommand(int row, int column) throws Throwable { + return TestsHelper.getInstance("picross.grid.PaintCommand", row, column); + } +} + Copied: trunk/test/picross/package.html (from rev 88, trunk/src/picross/tests/package.html) =================================================================== --- trunk/test/picross/package.html (rev 0) +++ trunk/test/picross/package.html 2011-06-16 11:11:11 UTC (rev 90) @@ -0,0 +1,12 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <!-- + $Id$ + --> + </head> + + <body bgcolor="white"> + Unit tests for package picross. + </body> +</html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2011-06-16 12:11:10
|
Revision: 91 http://picross.svn.sourceforge.net/picross/?rev=91&view=rev Author: yvan_norsa Date: 2011-06-16 12:11:02 +0000 (Thu, 16 Jun 2011) Log Message: ----------- better test code Modified Paths: -------------- trunk/build.xml trunk/test/picross/game/random/RandomPicrossModelTest.java trunk/test/picross/game/simple/XBMModelTest.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 Removed Paths: ------------- trunk/lib/testsHelper.jar Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2011-06-16 11:11:11 UTC (rev 90) +++ trunk/build.xml 2011-06-16 12:11:02 UTC (rev 91) @@ -33,8 +33,6 @@ value="${lib.dir}/mmvcs.jar" /> <property name="simpleButton.jar" value="${lib.dir}/simpleButton.jar" /> - <property name="testsHelper.jar" - value="${lib.dir}/testsHelper.jar" /> <target name="-init" depends="-setmode"> @@ -72,7 +70,6 @@ <pathelement location="${log4j.jar}" /> <pathelement location="${mmvcs.jar}" /> <pathelement location="${simpleButton.jar}" /> - <pathelement location="${testsHelper.jar}" /> </path> <target name="compile" Deleted: trunk/lib/testsHelper.jar =================================================================== (Binary files differ) Modified: trunk/test/picross/game/random/RandomPicrossModelTest.java =================================================================== --- trunk/test/picross/game/random/RandomPicrossModelTest.java 2011-06-16 11:11:11 UTC (rev 90) +++ trunk/test/picross/game/random/RandomPicrossModelTest.java 2011-06-16 12:11:02 UTC (rev 91) @@ -33,8 +33,6 @@ package picross.game.random; -import fr.cle.tests.TestsHelper; - import org.apache.log4j.PropertyConfigurator; import org.junit.Test; @@ -58,8 +56,6 @@ /** {@inheritDoc} */ @Override protected PicrossGrid getPicrossGrid() throws Throwable { - //return new RandomPicrossModel(); - - return (PicrossGrid) TestsHelper.getInstance("picross.game.random.RandomPicrossModel"); + return new RandomPicrossModel(); } } Modified: trunk/test/picross/game/simple/XBMModelTest.java =================================================================== --- trunk/test/picross/game/simple/XBMModelTest.java 2011-06-16 11:11:11 UTC (rev 90) +++ trunk/test/picross/game/simple/XBMModelTest.java 2011-06-16 12:11:02 UTC (rev 91) @@ -33,8 +33,6 @@ package picross.game.simple; -import fr.cle.tests.TestsHelper; - import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -66,8 +64,7 @@ try { XBMModelTest.realModel = - //new XBMModel(Picross.loadDataFile("asterix.xbm")); - XBMModelTest.newXBMModel(Picross.loadDataFile("asterix.xbm")); + new XBMModel(Picross.loadDataFile("asterix.xbm")); } catch (IOException ioEx) { throw new ExceptionInInitializerError(ioEx); } catch (PicrossException xbmEx) { @@ -82,42 +79,12 @@ return XBMModelTest.realModel; } - /** - * Tests the XBMModel constructor. - * - * @throws IOException if there is a problem with a stream loading - * @throws XBMException if a file isn't valid - */ - @Test - public void testXBMModel() throws IOException, PicrossException { - try { - //new XBMModel(null); - XBMModelTest.newXBMModel(null); - Assert.fail("Tried to load a null model"); - } catch (IllegalArgumentException argEx) { } + @Test(expected = IllegalArgumentException.class) + public void loadNullModel() throws IOException, PicrossException { + new XBMModel(null); + } - try { - //new XBMModel(new ByteArrayInputStream("".getBytes())); - XBMModelTest.newXBMModel(new ByteArrayInputStream("".getBytes())); - Assert.fail("Empty file"); - } catch (PicrossException xbmEx) { } + public void loadEmptyModel() throws IOException, PicrossException { + new XBMModel(new ByteArrayInputStream("".getBytes())); } - - private static PicrossGrid newXBMModel(InputStream in) throws IOException, PicrossException { - try { - return (PicrossGrid) TestsHelper.getInstance("picross.game.simple.XBMModel", in); - } catch (Throwable throwable) { - if (throwable instanceof IOException) { - throw (IOException) throwable; - } - - if (throwable instanceof PicrossException) { - throw (PicrossException) throwable; - } - - //if (throwable instanceof RuntimeException) { - throw (RuntimeException) throwable; - //} - } - } } Modified: trunk/test/picross/grid/BoxTest.java =================================================================== --- trunk/test/picross/grid/BoxTest.java 2011-06-16 11:11:11 UTC (rev 90) +++ trunk/test/picross/grid/BoxTest.java 2011-06-16 12:11:02 UTC (rev 91) @@ -33,8 +33,6 @@ package picross.grid; -import fr.cle.tests.TestsHelper; - import javax.swing.ImageIcon; import org.junit.Assert; @@ -51,7 +49,7 @@ /*** Champ ***/ - private Object box = null; + private Box box = null; /*** Constructeur ***/ @@ -66,7 +64,7 @@ @Before public void setUp() throws Throwable { - this.box = BoxTest.getBox(); + this.box = new Box(); } @Test @@ -83,7 +81,7 @@ @Test public void testEmpty() throws Throwable { - TestsHelper.invoke(this.box, "empty"); + this.box.empty(); Assert.assertTrue("box not empty", BoxTest.isBoxEmpty(this.box)); } @@ -94,7 +92,7 @@ BoxTest.checkBox(this.box); - Object box2 = BoxTest.getBox(); + Box box2 = new Box(); Assert.assertFalse("box = box2", this.box.equals(box2)); BoxTest.checkBox(box2); @@ -149,44 +147,37 @@ Assert.assertFalse("box crossed AND empty", BoxTest.isBoxCrossed(this.box)); } - @Test + @Test(expected = IllegalArgumentException.class) public void testSetRect() throws Throwable { - try { - TestsHelper.invoke(this.box, "setRect", null); - Assert.fail("box.setRect(null)"); - } catch (IllegalArgumentException argEx) { } + this.box.setRect(null); } - private static Object getBox() throws Throwable { - return TestsHelper.getInstance("picross.grid.Box"); + private static void checkBox(Box box) throws Throwable { + box.check(); } - private static void checkBox(Object box) throws Throwable { - TestsHelper.invoke(box, "check"); + private static void crossBox(Box box) throws Throwable { + box.cross(); } - private static void crossBox(Object box) throws Throwable { - TestsHelper.invoke(box, "cross"); + private static ImageIcon getBoxIcon(Box box) throws Throwable { + return (ImageIcon) box.getIcon(); } - private static ImageIcon getBoxIcon(Object box) throws Throwable { - return (ImageIcon) TestsHelper.invoke(box, "getIcon"); + private static ImageIcon getBoxRolloverIcon(Box box) throws Throwable { + return (ImageIcon) box.getRolloverIcon(); } - private static ImageIcon getBoxRolloverIcon(Object box) throws Throwable { - return (ImageIcon) TestsHelper.invoke(box, "getRolloverIcon"); + private static boolean isBoxCrossed(Box box) throws Throwable { + return ((Boolean) box.isCrossed()).booleanValue(); } - private static boolean isBoxCrossed(Object box) throws Throwable { - return ((Boolean) TestsHelper.invoke(box, "isCrossed")).booleanValue(); + private static boolean isBoxEmpty(Box box) throws Throwable { + return ((Boolean) box.isEmpty()).booleanValue(); } - private static boolean isBoxEmpty(Object box) throws Throwable { - return ((Boolean) TestsHelper.invoke(box, "isEmpty")).booleanValue(); + private static boolean isBoxChecked(Box box) throws Throwable { + return ((Boolean) box.isChecked()).booleanValue(); } - - private static boolean isBoxChecked(Object box) throws Throwable { - return ((Boolean) TestsHelper.invoke(box, "isChecked")).booleanValue(); - } } Modified: trunk/test/picross/grid/CompletedHintsTest.java =================================================================== --- trunk/test/picross/grid/CompletedHintsTest.java 2011-06-16 11:11:11 UTC (rev 90) +++ trunk/test/picross/grid/CompletedHintsTest.java 2011-06-16 12:11:02 UTC (rev 91) @@ -33,8 +33,6 @@ package picross.grid; -import fr.cle.tests.TestsHelper; - import java.util.List; import org.junit.Assert; @@ -51,7 +49,7 @@ /*** Champ ***/ - Object hints = null; + CompletedHints hints = null; /*** Constructeur ***/ @@ -115,14 +113,14 @@ @Test public void testClearColHint() throws Throwable { CompletedHintsTest.setCompleteColHint(this.hints, 3, 4); - TestsHelper.invoke(this.hints, "clearColHint", 3, 4); + this.hints.clearColHint(3, 4); Assert.assertFalse(CompletedHintsTest.isColHintComplete(this.hints, 3, 4)); } @Test public void testClearRowHint() throws Throwable { CompletedHintsTest.setCompleteRowHint(this.hints, 8, 2); - TestsHelper.invoke(this.hints, "clearRowHint", 8, 2); + this.hints.clearRowHint(8, 2); Assert.assertFalse(CompletedHintsTest.isRowHintComplete(this.hints, 8, 2)); } @@ -204,32 +202,32 @@ Assert.assertTrue(CompletedHintsTest.isRowHintComplete(this.hints, 5, 5)); } - private static Object getCompletedHints(int colHintsWidth, int colHintsHeight, int rowHintsWidth, int rowHintsHeight) throws Throwable { - return TestsHelper.getInstance("picross.grid.CompletedHints", colHintsWidth, colHintsHeight, rowHintsWidth, rowHintsHeight); + 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(Object hints, int col, int index) throws Throwable { - TestsHelper.invoke(hints, "setCompleteColHint", col, index); + private static void setCompleteColHint(CompletedHints hints, int col, int index) throws Throwable { + hints.setCompleteColHint(col, index); } - private static boolean isColHintComplete(Object hints, int x, int y) throws Throwable { - return ((Boolean) TestsHelper.invoke(hints, "isColHintComplete", x, y)).booleanValue(); + private static boolean isColHintComplete(CompletedHints hints, int x, int y) throws Throwable { + return ((Boolean) hints.isColHintComplete(x, y)).booleanValue(); } - private static void setCompleteRowHint(Object hints, int row, int index) throws Throwable { - TestsHelper.invoke(hints, "setCompleteRowHint", row, index); + private static void setCompleteRowHint(CompletedHints hints, int row, int index) throws Throwable { + hints.setCompleteRowHint(row, index); } - private static boolean isRowHintComplete(Object hints, int x, int y) throws Throwable { - return ((Boolean) TestsHelper.invoke(hints, "isRowHintComplete", x, y)).booleanValue(); + private static boolean isRowHintComplete(CompletedHints hints, int x, int y) throws Throwable { + return ((Boolean) hints.isRowHintComplete(x, y)).booleanValue(); } - private static List<Integer> getCompleteColHints(Object hints, int column) throws Throwable { - return (List<Integer>) TestsHelper.invoke(hints, "getCompleteColHints", column); + private static List<Integer> getCompleteColHints(CompletedHints hints, int column) throws Throwable { + return (List<Integer>) hints.getCompleteColHints(column); } - private static List<Integer> getCompleteRowHints(Object hints, int row) throws Throwable { - return (List<Integer>) TestsHelper.invoke(hints, "getCompleteRowHints", row); + 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 11:11:11 UTC (rev 90) +++ trunk/test/picross/grid/GridModelTest.java 2011-06-16 12:11:02 UTC (rev 91) @@ -33,8 +33,6 @@ package picross.grid; -import fr.cle.tests.TestsHelper; - import org.easymock.EasyMock; import org.junit.Assert; @@ -51,7 +49,7 @@ /*** Champ ***/ - private Object model = null; + private GridModel model = null; /*** Constructeur ***/ @@ -110,13 +108,22 @@ GridModelTest.actOnBox(this.model, 0, 0, GridAction.CHECK); } */ - private static Object getGridModel(IGridMediator mediator, boolean[][] data) throws Throwable { - return TestsHelper.getInstance("picross.grid.GridModel", mediator, data); + 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); } */ + + @Test + public void incorrectHint() { + GridModel gridModel = new GridModel(EasyMock.createMock(IGridMediator.class), + new boolean[][] { + {false, true, false, true, true, false, true, true, true, false, false, true} + }); + + } } Modified: trunk/test/picross/grid/PaintCommandTest.java =================================================================== --- trunk/test/picross/grid/PaintCommandTest.java 2011-06-16 11:11:11 UTC (rev 90) +++ trunk/test/picross/grid/PaintCommandTest.java 2011-06-16 12:11:02 UTC (rev 91) @@ -33,8 +33,6 @@ package picross.grid; -import fr.cle.tests.TestsHelper; - import org.junit.Assert; import org.junit.Test; @@ -58,7 +56,7 @@ } private static Object getPaintCommand(int row, int column) throws Throwable { - return TestsHelper.getInstance("picross.grid.PaintCommand", row, column); + 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. |
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...> - 2013-01-23 08:35:53
|
Revision: 134 http://sourceforge.net/p/picross/code/134 Author: yvan_norsa Date: 2013-01-23 08:35:48 +0000 (Wed, 23 Jan 2013) Log Message: ----------- updated copyright Modified Paths: -------------- trunk/android/src/picross/specific/activities/MainMenuActivityUI.java trunk/android/src/picross/specific/activities/PicrossActivityUI.java trunk/android/src/picross/specific/activities/PicrossMainActivity.java trunk/android/src/picross/specific/game/random/ui/RandomGameController.java trunk/android/src/picross/specific/game/random/ui/RandomGameMediator.java trunk/android/src/picross/specific/game/random/ui/RandomGameModeUI.java trunk/android/src/picross/specific/game/random/ui/RandomGameUI.java trunk/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java trunk/android/src/picross/specific/game/simple/ui/AndroidSimpleGameMediator.java trunk/android/src/picross/specific/game/simple/ui/LevelMenuUI.java trunk/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java trunk/android/src/picross/specific/game/ui/GameController.java trunk/android/src/picross/specific/game/ui/GameMediator.java trunk/android/src/picross/specific/game/ui/GameUI.java trunk/android/src/picross/specific/game/ui/UIGameMode.java trunk/android/src/picross/specific/grid/ui/GridController.java trunk/android/src/picross/specific/grid/ui/GridMediator.java trunk/android/src/picross/specific/grid/ui/GridUI.java trunk/android/src/picross/specific/grid/ui/HintBoxInfos.java trunk/android/src/picross/specific/grid/ui/Point.java trunk/android/src/picross/specific/grid/ui/UIBox.java trunk/android/src/picross/specific/ui/AbstractAndroidView.java trunk/android/src/picross/specific/ui/GameMenuMediator.java trunk/android/src/picross/specific/ui/GameMenuUI.java trunk/android/src/picross/specific/ui/MainMenuMediator.java trunk/android/src/picross/specific/ui/MainMenuUI.java trunk/android/src/picross/specific/ui/MenuController.java trunk/android/src/picross/specific/ui/MenuUI.java trunk/android/src/picross/specific/ui/PicrossAndroidLogger.java trunk/android/src/picross/specific/ui/PicrossButton.java trunk/android/src/picross/specific/ui/PicrossEvent.java trunk/android/src/picross/specific/ui/PicrossLabel.java trunk/android/src/picross/specific/ui/PicrossMediator.java trunk/android/src/picross/specific/ui/PicrossUIHelper.java trunk/android/src/picross/specific/ui/WaitMenuMediator.java trunk/android/src/picross/specific/ui/WaitMenuUI.java trunk/common/src/picross/common/game/simple/ui/LevelMenuController.java trunk/common/src/picross/common/game/simple/ui/LevelMenuMediator.java trunk/common/src/picross/common/game/simple/ui/LevelMenuModel.java trunk/common/src/picross/common/game/simple/ui/LevelsListCommand.java trunk/common/src/picross/common/game/simple/ui/SelectSizeCommand.java trunk/common/src/picross/common/game/simple/ui/SimpleGameMediator.java trunk/common/src/picross/common/game/simple/ui/SizesListCommand.java trunk/common/src/picross/common/game/ui/GameCommand.java trunk/common/src/picross/common/game/ui/GameMediator.java trunk/common/src/picross/common/game/ui/GameView.java trunk/common/src/picross/common/grid/ui/AbstractGridMediator.java trunk/common/src/picross/common/grid/ui/FillCommand.java trunk/common/src/picross/common/grid/ui/GridCommands.java trunk/common/src/picross/common/grid/ui/GridView.java trunk/common/src/picross/common/grid/ui/IGridMediator.java trunk/common/src/picross/common/grid/ui/PaintCommand.java trunk/common/src/picross/common/grid/ui/RepaintLeftHintsCommand.java trunk/common/src/picross/common/grid/ui/RepaintTopHintsCommand.java trunk/common/src/picross/common/ui/AbstractMenuController.java trunk/common/src/picross/common/ui/AbstractPicrossMediator.java trunk/common/src/picross/common/ui/AbstractWaitMenuMediator.java trunk/common/src/picross/common/ui/GameMenuModel.java trunk/common/src/picross/common/ui/MainMenuUI.java trunk/common/src/picross/common/ui/MenuCommand.java trunk/common/src/picross/common/ui/MenuMediator.java trunk/common/src/picross/common/ui/MissingImageException.java trunk/common/src/picross/common/ui/PicrossController.java trunk/common/src/picross/common/ui/PicrossUI.java trunk/common/src/picross/common/ui/PicrossView.java trunk/engine/src/picross/engine/AbstractPicrossLogger.java trunk/engine/src/picross/engine/Picross.java trunk/engine/src/picross/engine/PicrossException.java trunk/engine/src/picross/engine/PicrossLogHelper.java trunk/engine/src/picross/engine/PicrossLogger.java trunk/engine/src/picross/engine/game/AbstractPicrossModel.java trunk/engine/src/picross/engine/game/GameMode.java trunk/engine/src/picross/engine/game/random/RandomGameMode.java trunk/engine/src/picross/engine/game/random/RandomPicrossModel.java trunk/engine/src/picross/engine/game/simple/Dimensions.java trunk/engine/src/picross/engine/game/simple/FileInfos.java trunk/engine/src/picross/engine/game/simple/LevelInfos.java trunk/engine/src/picross/engine/game/simple/SimpleGameMode.java trunk/engine/src/picross/engine/game/simple/XBMException.java trunk/engine/src/picross/engine/game/simple/XBMModel.java trunk/engine/src/picross/engine/grid/Box.java trunk/engine/src/picross/engine/grid/CompletedHints.java trunk/engine/src/picross/engine/grid/GridAction.java trunk/engine/src/picross/engine/grid/GridModel.java trunk/engine/src/picross/engine/grid/PicrossGrid.java trunk/swing/src/picross/specific/game/random/ui/RandomGameController.java trunk/swing/src/picross/specific/game/random/ui/RandomGameMediator.java trunk/swing/src/picross/specific/game/random/ui/RandomGameModeUI.java trunk/swing/src/picross/specific/game/random/ui/RandomGameUI.java trunk/swing/src/picross/specific/game/simple/ui/LevelMenuUI.java trunk/swing/src/picross/specific/game/simple/ui/SimpleGameModeUI.java trunk/swing/src/picross/specific/game/ui/GameController.java trunk/swing/src/picross/specific/game/ui/GameMediator.java trunk/swing/src/picross/specific/game/ui/GameUI.java trunk/swing/src/picross/specific/game/ui/UIGameMode.java trunk/swing/src/picross/specific/grid/ui/GridController.java trunk/swing/src/picross/specific/grid/ui/GridMediator.java trunk/swing/src/picross/specific/grid/ui/GridUI.java trunk/swing/src/picross/specific/grid/ui/HintBoxInfos.java trunk/swing/src/picross/specific/grid/ui/UIBox.java trunk/swing/src/picross/specific/ui/GameMenuMediator.java trunk/swing/src/picross/specific/ui/GameMenuUI.java trunk/swing/src/picross/specific/ui/MainMenuMediator.java trunk/swing/src/picross/specific/ui/MenuController.java trunk/swing/src/picross/specific/ui/MenuUI.java trunk/swing/src/picross/specific/ui/PicrossButton.java trunk/swing/src/picross/specific/ui/PicrossLog4jLogger.java trunk/swing/src/picross/specific/ui/PicrossMediator.java trunk/swing/src/picross/specific/ui/PicrossUIHelper.java trunk/swing/src/picross/specific/ui/WaitMenuMediator.java trunk/swing/src/picross/specific/ui/WaitMenuUI.java Property Changed: ---------------- trunk/common/src/picross/common/game/simple/ui/LevelMenuMediator.java Modified: trunk/android/src/picross/specific/activities/MainMenuActivityUI.java =================================================================== --- trunk/android/src/picross/specific/activities/MainMenuActivityUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/activities/MainMenuActivityUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/activities/PicrossActivityUI.java =================================================================== --- trunk/android/src/picross/specific/activities/PicrossActivityUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/activities/PicrossActivityUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/activities/PicrossMainActivity.java =================================================================== --- trunk/android/src/picross/specific/activities/PicrossMainActivity.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/activities/PicrossMainActivity.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/game/random/ui/RandomGameController.java =================================================================== --- trunk/android/src/picross/specific/game/random/ui/RandomGameController.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/game/random/ui/RandomGameController.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/game/random/ui/RandomGameMediator.java =================================================================== --- trunk/android/src/picross/specific/game/random/ui/RandomGameMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/game/random/ui/RandomGameMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/game/random/ui/RandomGameModeUI.java =================================================================== --- trunk/android/src/picross/specific/game/random/ui/RandomGameModeUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/game/random/ui/RandomGameModeUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/game/random/ui/RandomGameUI.java =================================================================== --- trunk/android/src/picross/specific/game/random/ui/RandomGameUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/game/random/ui/RandomGameUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java =================================================================== --- trunk/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/game/simple/ui/AndroidSimpleGameMediator.java =================================================================== --- trunk/android/src/picross/specific/game/simple/ui/AndroidSimpleGameMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/game/simple/ui/AndroidSimpleGameMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/game/simple/ui/LevelMenuUI.java =================================================================== --- trunk/android/src/picross/specific/game/simple/ui/LevelMenuUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/game/simple/ui/LevelMenuUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java =================================================================== --- trunk/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/game/ui/GameController.java =================================================================== --- trunk/android/src/picross/specific/game/ui/GameController.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/game/ui/GameController.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/game/ui/GameMediator.java =================================================================== --- trunk/android/src/picross/specific/game/ui/GameMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/game/ui/GameMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/game/ui/GameUI.java =================================================================== --- trunk/android/src/picross/specific/game/ui/GameUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/game/ui/GameUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/game/ui/UIGameMode.java =================================================================== --- trunk/android/src/picross/specific/game/ui/UIGameMode.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/game/ui/UIGameMode.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/grid/ui/GridController.java =================================================================== --- trunk/android/src/picross/specific/grid/ui/GridController.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/grid/ui/GridController.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/grid/ui/GridMediator.java =================================================================== --- trunk/android/src/picross/specific/grid/ui/GridMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/grid/ui/GridMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/grid/ui/GridUI.java =================================================================== --- trunk/android/src/picross/specific/grid/ui/GridUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/grid/ui/GridUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/grid/ui/HintBoxInfos.java =================================================================== --- trunk/android/src/picross/specific/grid/ui/HintBoxInfos.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/grid/ui/HintBoxInfos.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/grid/ui/Point.java =================================================================== --- trunk/android/src/picross/specific/grid/ui/Point.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/grid/ui/Point.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/grid/ui/UIBox.java =================================================================== --- trunk/android/src/picross/specific/grid/ui/UIBox.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/grid/ui/UIBox.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/AbstractAndroidView.java =================================================================== --- trunk/android/src/picross/specific/ui/AbstractAndroidView.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/AbstractAndroidView.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,5 +1,33 @@ /* * $Id$ + * + * Copyright (c) 2008-2013 + * + * 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. */ Modified: trunk/android/src/picross/specific/ui/GameMenuMediator.java =================================================================== --- trunk/android/src/picross/specific/ui/GameMenuMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/GameMenuMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/GameMenuUI.java =================================================================== --- trunk/android/src/picross/specific/ui/GameMenuUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/GameMenuUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/MainMenuMediator.java =================================================================== --- trunk/android/src/picross/specific/ui/MainMenuMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/MainMenuMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/MainMenuUI.java =================================================================== --- trunk/android/src/picross/specific/ui/MainMenuUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/MainMenuUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/MenuController.java =================================================================== --- trunk/android/src/picross/specific/ui/MenuController.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/MenuController.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/MenuUI.java =================================================================== --- trunk/android/src/picross/specific/ui/MenuUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/MenuUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/PicrossAndroidLogger.java =================================================================== --- trunk/android/src/picross/specific/ui/PicrossAndroidLogger.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/PicrossAndroidLogger.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/PicrossButton.java =================================================================== --- trunk/android/src/picross/specific/ui/PicrossButton.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/PicrossButton.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/PicrossEvent.java =================================================================== --- trunk/android/src/picross/specific/ui/PicrossEvent.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/PicrossEvent.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/PicrossLabel.java =================================================================== --- trunk/android/src/picross/specific/ui/PicrossLabel.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/PicrossLabel.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/PicrossMediator.java =================================================================== --- trunk/android/src/picross/specific/ui/PicrossMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/PicrossMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/PicrossUIHelper.java =================================================================== --- trunk/android/src/picross/specific/ui/PicrossUIHelper.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/PicrossUIHelper.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2001 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/WaitMenuMediator.java =================================================================== --- trunk/android/src/picross/specific/ui/WaitMenuMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/WaitMenuMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/android/src/picross/specific/ui/WaitMenuUI.java =================================================================== --- trunk/android/src/picross/specific/ui/WaitMenuUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/android/src/picross/specific/ui/WaitMenuUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/game/simple/ui/LevelMenuController.java =================================================================== --- trunk/common/src/picross/common/game/simple/ui/LevelMenuController.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/game/simple/ui/LevelMenuController.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/game/simple/ui/LevelMenuMediator.java =================================================================== --- trunk/common/src/picross/common/game/simple/ui/LevelMenuMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/game/simple/ui/LevelMenuMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Property changes on: trunk/common/src/picross/common/game/simple/ui/LevelMenuMediator.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Modified: trunk/common/src/picross/common/game/simple/ui/LevelMenuModel.java =================================================================== --- trunk/common/src/picross/common/game/simple/ui/LevelMenuModel.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/game/simple/ui/LevelMenuModel.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/game/simple/ui/LevelsListCommand.java =================================================================== --- trunk/common/src/picross/common/game/simple/ui/LevelsListCommand.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/game/simple/ui/LevelsListCommand.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/game/simple/ui/SelectSizeCommand.java =================================================================== --- trunk/common/src/picross/common/game/simple/ui/SelectSizeCommand.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/game/simple/ui/SelectSizeCommand.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/game/simple/ui/SimpleGameMediator.java =================================================================== --- trunk/common/src/picross/common/game/simple/ui/SimpleGameMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/game/simple/ui/SimpleGameMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/game/simple/ui/SizesListCommand.java =================================================================== --- trunk/common/src/picross/common/game/simple/ui/SizesListCommand.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/game/simple/ui/SizesListCommand.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/game/ui/GameCommand.java =================================================================== --- trunk/common/src/picross/common/game/ui/GameCommand.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/game/ui/GameCommand.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/game/ui/GameMediator.java =================================================================== --- trunk/common/src/picross/common/game/ui/GameMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/game/ui/GameMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/game/ui/GameView.java =================================================================== --- trunk/common/src/picross/common/game/ui/GameView.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/game/ui/GameView.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/grid/ui/AbstractGridMediator.java =================================================================== --- trunk/common/src/picross/common/grid/ui/AbstractGridMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/grid/ui/AbstractGridMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/grid/ui/FillCommand.java =================================================================== --- trunk/common/src/picross/common/grid/ui/FillCommand.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/grid/ui/FillCommand.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/grid/ui/GridCommands.java =================================================================== --- trunk/common/src/picross/common/grid/ui/GridCommands.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/grid/ui/GridCommands.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,5 +1,33 @@ /* * $Id$ + + * Copyright (c) 2011-2013 + * + * 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. */ Modified: trunk/common/src/picross/common/grid/ui/GridView.java =================================================================== --- trunk/common/src/picross/common/grid/ui/GridView.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/grid/ui/GridView.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2011 + * Copyright (c) 2011-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/grid/ui/IGridMediator.java =================================================================== --- trunk/common/src/picross/common/grid/ui/IGridMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/grid/ui/IGridMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/grid/ui/PaintCommand.java =================================================================== --- trunk/common/src/picross/common/grid/ui/PaintCommand.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/grid/ui/PaintCommand.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/grid/ui/RepaintLeftHintsCommand.java =================================================================== --- trunk/common/src/picross/common/grid/ui/RepaintLeftHintsCommand.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/grid/ui/RepaintLeftHintsCommand.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/grid/ui/RepaintTopHintsCommand.java =================================================================== --- trunk/common/src/picross/common/grid/ui/RepaintTopHintsCommand.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/grid/ui/RepaintTopHintsCommand.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/ui/AbstractMenuController.java =================================================================== --- trunk/common/src/picross/common/ui/AbstractMenuController.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/ui/AbstractMenuController.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/ui/AbstractPicrossMediator.java =================================================================== --- trunk/common/src/picross/common/ui/AbstractPicrossMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/ui/AbstractPicrossMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/ui/AbstractWaitMenuMediator.java =================================================================== --- trunk/common/src/picross/common/ui/AbstractWaitMenuMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/ui/AbstractWaitMenuMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/ui/GameMenuModel.java =================================================================== --- trunk/common/src/picross/common/ui/GameMenuModel.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/ui/GameMenuModel.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/ui/MainMenuUI.java =================================================================== --- trunk/common/src/picross/common/ui/MainMenuUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/ui/MainMenuUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/ui/MenuCommand.java =================================================================== --- trunk/common/src/picross/common/ui/MenuCommand.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/ui/MenuCommand.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/ui/MenuMediator.java =================================================================== --- trunk/common/src/picross/common/ui/MenuMediator.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/ui/MenuMediator.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/ui/MissingImageException.java =================================================================== --- trunk/common/src/picross/common/ui/MissingImageException.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/ui/MissingImageException.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2001 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/ui/PicrossController.java =================================================================== --- trunk/common/src/picross/common/ui/PicrossController.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/ui/PicrossController.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/ui/PicrossUI.java =================================================================== --- trunk/common/src/picross/common/ui/PicrossUI.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/ui/PicrossUI.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/common/src/picross/common/ui/PicrossView.java =================================================================== --- trunk/common/src/picross/common/ui/PicrossView.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/common/src/picross/common/ui/PicrossView.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008-2011 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/AbstractPicrossLogger.java =================================================================== --- trunk/engine/src/picross/engine/AbstractPicrossLogger.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/AbstractPicrossLogger.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,5 +1,33 @@ /* * $Id$ + * + * Copyright (c) 2007-2013 + * + * 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. */ Modified: trunk/engine/src/picross/engine/Picross.java =================================================================== --- trunk/engine/src/picross/engine/Picross.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/Picross.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/PicrossException.java =================================================================== --- trunk/engine/src/picross/engine/PicrossException.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/PicrossException.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/PicrossLogHelper.java =================================================================== --- trunk/engine/src/picross/engine/PicrossLogHelper.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/PicrossLogHelper.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/PicrossLogger.java =================================================================== --- trunk/engine/src/picross/engine/PicrossLogger.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/PicrossLogger.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/game/AbstractPicrossModel.java =================================================================== --- trunk/engine/src/picross/engine/game/AbstractPicrossModel.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/game/AbstractPicrossModel.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/game/GameMode.java =================================================================== --- trunk/engine/src/picross/engine/game/GameMode.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/game/GameMode.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/game/random/RandomGameMode.java =================================================================== --- trunk/engine/src/picross/engine/game/random/RandomGameMode.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/game/random/RandomGameMode.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/game/random/RandomPicrossModel.java =================================================================== --- trunk/engine/src/picross/engine/game/random/RandomPicrossModel.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/game/random/RandomPicrossModel.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/game/simple/Dimensions.java =================================================================== --- trunk/engine/src/picross/engine/game/simple/Dimensions.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/game/simple/Dimensions.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/game/simple/FileInfos.java =================================================================== --- trunk/engine/src/picross/engine/game/simple/FileInfos.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/game/simple/FileInfos.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/game/simple/LevelInfos.java =================================================================== --- trunk/engine/src/picross/engine/game/simple/LevelInfos.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/game/simple/LevelInfos.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/game/simple/SimpleGameMode.java =================================================================== --- trunk/engine/src/picross/engine/game/simple/SimpleGameMode.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/game/simple/SimpleGameMode.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2008 + * Copyright (c) 2008-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/game/simple/XBMException.java =================================================================== --- trunk/engine/src/picross/engine/game/simple/XBMException.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/game/simple/XBMException.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/game/simple/XBMModel.java =================================================================== --- trunk/engine/src/picross/engine/game/simple/XBMModel.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/game/simple/XBMModel.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/grid/Box.java =================================================================== --- trunk/engine/src/picross/engine/grid/Box.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/grid/Box.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2011 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/grid/CompletedHints.java =================================================================== --- trunk/engine/src/picross/engine/grid/CompletedHints.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/grid/CompletedHints.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/grid/GridAction.java =================================================================== --- trunk/engine/src/picross/engine/grid/GridAction.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/grid/GridAction.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/grid/GridModel.java =================================================================== --- trunk/engine/src/picross/engine/grid/GridModel.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/grid/GridModel.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007-2008 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/engine/src/picross/engine/grid/PicrossGrid.java =================================================================== --- trunk/engine/src/picross/engine/grid/PicrossGrid.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/engine/src/picross/engine/grid/PicrossGrid.java 2013-01-23 08:35:48 UTC (rev 134) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2013 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, Modified: trunk/swing/src/picross/specific/game/random/ui/RandomGameController.java =================================================================== --- trunk/swing/src/picross/specific/game/random/ui/RandomGameController.java 2013-01-23 08:22:42 UTC (rev 133) +++ trunk/swing/src/picross/specific/game/random/ui/RandomGameController.java 2013-01-2... [truncated message content] |
From: <yva...@us...> - 2013-01-28 08:42:44
|
Revision: 136 http://sourceforge.net/p/picross/code/136 Author: yvan_norsa Date: 2013-01-28 08:42:39 +0000 (Mon, 28 Jan 2013) Log Message: ----------- add 'reset' button Modified Paths: -------------- trunk/android/src/picross/specific/game/ui/GameController.java trunk/android/src/picross/specific/game/ui/GameMediator.java trunk/android/src/picross/specific/game/ui/GameUI.java trunk/android/src/picross/specific/grid/ui/GridUI.java trunk/common/src/picross/common/grid/ui/AbstractGridMediator.java trunk/common/src/picross/common/grid/ui/GridCommands.java trunk/common/src/picross/common/grid/ui/IGridMediator.java trunk/common/src/picross/common/ui/PicrossController.java trunk/common/src/picross/specific/grid/ui/GridUI.java trunk/engine/src/picross/engine/grid/GridModel.java trunk/properties/messages_picross.properties trunk/properties/messages_picross_fr.properties trunk/swing/src/picross/specific/game/ui/GameController.java trunk/swing/src/picross/specific/game/ui/GameMediator.java trunk/swing/src/picross/specific/game/ui/GameUI.java trunk/swing/src/picross/specific/grid/ui/GridController.java trunk/swing/src/picross/specific/grid/ui/GridUI.java Added Paths: ----------- trunk/common/src/picross/common/game/ui/AbstractGameMediator.java trunk/common/src/picross/specific/game/ui/GameController.java trunk/common/src/picross/specific/game/ui/GameUI.java Removed Paths: ------------- trunk/common/src/picross/common/game/ui/GameMediator.java Modified: trunk/android/src/picross/specific/game/ui/GameController.java =================================================================== --- trunk/android/src/picross/specific/game/ui/GameController.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/android/src/picross/specific/game/ui/GameController.java 2013-01-28 08:42:39 UTC (rev 136) @@ -57,6 +57,8 @@ public static final int QUIT_CMD_ID = PicrossController.QUIT_CMD.hashCode(); + public static final int RESET_CMD_ID = PicrossController.RESET_CMD.hashCode(); + /*** Method overloaded from the class Controller ***/ /** {@inheritDoc} */ @@ -92,6 +94,11 @@ return; } + if (itemId == GameController.RESET_CMD_ID) { + this.fireEventPerformed(PicrossController.RESET_CMD); + return; + } + super.onPicrossEvent(e); } } Modified: trunk/android/src/picross/specific/game/ui/GameMediator.java =================================================================== --- trunk/android/src/picross/specific/game/ui/GameMediator.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/android/src/picross/specific/game/ui/GameMediator.java 2013-01-28 08:42:39 UTC (rev 136) @@ -33,7 +33,6 @@ package picross.specific.game.ui; -import fr.cle.mmvcs.Mediateur; import fr.cle.mmvcs.SimpleEvent; import picross.engine.PicrossLogger; @@ -46,52 +45,21 @@ import picross.common.grid.ui.GridView; import picross.common.grid.ui.IGridMediator; +import picross.common.game.ui.AbstractGameMediator; + import picross.common.game.ui.GameView; import android.content.Context; import picross.specific.ui.MenuController; -public abstract class GameMediator extends Mediateur { - /*** Static field ***/ - - /** The class' logger. */ - private static PicrossLogger log = PicrossLogHelper.getLogger(GameMediator.class); - - /*** Fields ***/ - - /** The game view. */ - private GameUI view; - - /** The game grid. */ - private IGridMediator grid; - +public abstract class GameMediator extends AbstractGameMediator { protected Context context; public GameMediator(Context androidContext) { this.context = androidContext; } - /*** Abstract 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 ***/ /** @@ -135,22 +103,19 @@ return new GameUI(this.context, width, height, gridView, controller); } - /** - * Initialises the controller. - * - * @return the created controller - */ + @Override + public void eventPerformed(SimpleEvent e) { + //GameMediator.log.debug("eventPerformed(" + e + ")"); - protected GameController initController() { - return new GameController(); - } + String cmd = e.getCommandName(); - /** - * Returns the game view. - * - * @return the view - */ - public final GameView getView() { - return this.view; + if (cmd.equals(picross.common.ui.PicrossController.RESET_CMD)) { + this.grid.clear(); + this.view.repaint(); + + return; + } + + this.fireEventPerformed(e); } } Modified: trunk/android/src/picross/specific/game/ui/GameUI.java =================================================================== --- trunk/android/src/picross/specific/game/ui/GameUI.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/android/src/picross/specific/game/ui/GameUI.java 2013-01-28 08:42:39 UTC (rev 136) @@ -180,6 +180,7 @@ public void populateOptionsMenu(Menu menu) { menu.clear(); + menu.add(Menu.NONE, GameController.RESET_CMD_ID, Menu.NONE, BundleHelper.getString(this, "resetButton")); menu.add(Menu.NONE, GameController.QUIT_CMD_ID, Menu.NONE, BundleHelper.getString(this, "menuButton")); } @@ -193,4 +194,8 @@ protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec) { this.setMeasuredDimension(this.grid.getWidth(), this.grid.getHeight()); } + + public void repaint() { + this.invalidate(); + } } Modified: trunk/android/src/picross/specific/grid/ui/GridUI.java =================================================================== --- trunk/android/src/picross/specific/grid/ui/GridUI.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/android/src/picross/specific/grid/ui/GridUI.java 2013-01-28 08:42:39 UTC (rev 136) @@ -711,6 +711,20 @@ this.boxes[row][col].updateState(box); } + public void clearAll() { + for (UIBox[] boxRow : this.boxes) { + for (UIBox box : boxRow) { + box.updateState(GridUI.EMPTY_BOX); + } + } + } + + private static final Box EMPTY_BOX = new Box(); + + public void doRepaint() { + //this.repaint(); + } + @Override public boolean onTouch(View view, MotionEvent event) { this.controller.onTouch(null, event); Copied: trunk/common/src/picross/common/game/ui/AbstractGameMediator.java (from rev 134, trunk/common/src/picross/common/game/ui/GameMediator.java) =================================================================== --- trunk/common/src/picross/common/game/ui/AbstractGameMediator.java (rev 0) +++ trunk/common/src/picross/common/game/ui/AbstractGameMediator.java 2013-01-28 08:42:39 UTC (rev 136) @@ -0,0 +1,124 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2013 + * + * 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.Mediateur; + +import picross.engine.PicrossException; +import picross.engine.grid.PicrossGrid; + +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; + +import picross.specific.game.ui.GameUI; +import picross.specific.game.ui.GameController; + +import picross.common.grid.ui.IGridMediator; +import picross.common.grid.ui.GridView; + +import picross.common.ui.PicrossController; + +import fr.cle.mmvcs.SimpleEvent; + +public abstract class AbstractGameMediator extends Mediateur { + /*** Static field ***/ + + /** The class' logger. */ + private static PicrossLogger log = PicrossLogHelper.getLogger(AbstractGameMediator.class); + + /*** Fields ***/ + + /** The game view. */ + protected GameUI view; + + /** The game grid. */ + protected 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 + ")"); + + String cmd = e.getCommandName(); + + if (cmd.equals(PicrossController.RESET_CMD)) { + this.grid.clear(); + return; + } + + this.fireEventPerformed(e); + } + + /*** Methods ***/ + + /** + * Inits the game. + * + * @throws PicrossException if there is a problem loading the grid model + * or building the view + */ + public abstract void init() throws PicrossException; + + /** + * 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; + } + +} + Deleted: trunk/common/src/picross/common/game/ui/GameMediator.java =================================================================== --- trunk/common/src/picross/common/game/ui/GameMediator.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/common/src/picross/common/game/ui/GameMediator.java 2013-01-28 08:42:39 UTC (rev 136) @@ -1,45 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007-2013 - * - * 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.IMediateur; - -import picross.engine.PicrossException; -import picross.engine.grid.PicrossGrid; - -public interface GameMediator extends IMediateur { - PicrossGrid initModel() throws PicrossException; - void init() throws PicrossException; -} - Modified: trunk/common/src/picross/common/grid/ui/AbstractGridMediator.java =================================================================== --- trunk/common/src/picross/common/grid/ui/AbstractGridMediator.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/common/src/picross/common/grid/ui/AbstractGridMediator.java 2013-01-28 08:42:39 UTC (rev 136) @@ -217,6 +217,12 @@ this.fireEventPerformed(GridCommands.ERASE_MODE_CMD); } + public void clear() { + this.model.clearAll(); + this.view.clearAll(); + this.fireEventPerformed(GridCommands.REPAINT_EVERYTHING_CMD); + } + /*** Accessor ***/ /** Modified: trunk/common/src/picross/common/grid/ui/GridCommands.java =================================================================== --- trunk/common/src/picross/common/grid/ui/GridCommands.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/common/src/picross/common/grid/ui/GridCommands.java 2013-01-28 08:42:39 UTC (rev 136) @@ -60,5 +60,7 @@ /** Command asking to enable the Erase mode. */ public static final String ERASE_MODE_CMD = "ERASE_MODE_CMD"; + public static final String REPAINT_EVERYTHING_CMD = "REPAINT_EVERYTHING_CMD"; + private GridCommands() { } } Modified: trunk/common/src/picross/common/grid/ui/IGridMediator.java =================================================================== --- trunk/common/src/picross/common/grid/ui/IGridMediator.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/common/src/picross/common/grid/ui/IGridMediator.java 2013-01-28 08:42:39 UTC (rev 136) @@ -61,6 +61,8 @@ /** Enables the erase mode. */ void setEraseMode(); + void clear(); + /** * Returns the grid view. * Modified: trunk/common/src/picross/common/ui/PicrossController.java =================================================================== --- trunk/common/src/picross/common/ui/PicrossController.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/common/src/picross/common/ui/PicrossController.java 2013-01-28 08:42:39 UTC (rev 136) @@ -56,6 +56,8 @@ /** Command used to quit a game. */ public static final String QUIT_CMD = "QUIT_CMD"; + public static final String RESET_CMD = "RESET_CMD"; + /*** Field ***/ /** The view to which this controller is attached. */ Added: trunk/common/src/picross/specific/game/ui/GameController.java =================================================================== --- trunk/common/src/picross/specific/game/ui/GameController.java (rev 0) +++ trunk/common/src/picross/specific/game/ui/GameController.java 2013-01-28 08:42:39 UTC (rev 136) @@ -0,0 +1,43 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2013 + * + * 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.Controller; +import fr.cle.mmvcs.SimpleEvent; + +public class GameController extends Controller { + public void eventPerformed(SimpleEvent event) { } +} + + Property changes on: trunk/common/src/picross/specific/game/ui/GameController.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: trunk/common/src/picross/specific/game/ui/GameUI.java =================================================================== --- trunk/common/src/picross/specific/game/ui/GameUI.java (rev 0) +++ trunk/common/src/picross/specific/game/ui/GameUI.java 2013-01-28 08:42:39 UTC (rev 136) @@ -0,0 +1,39 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2013 + * + * 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 picross.common.game.ui.GameView; + +public class GameUI implements GameView { } + Property changes on: trunk/common/src/picross/specific/game/ui/GameUI.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Modified: trunk/common/src/picross/specific/grid/ui/GridUI.java =================================================================== --- trunk/common/src/picross/specific/grid/ui/GridUI.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/common/src/picross/specific/grid/ui/GridUI.java 2013-01-28 08:42:39 UTC (rev 136) @@ -50,4 +50,5 @@ public void init() throws FileNotFoundException { } public void updateBox(int row, int col, Box box) { } + public void clearAll() { } } Modified: trunk/engine/src/picross/engine/grid/GridModel.java =================================================================== --- trunk/engine/src/picross/engine/grid/GridModel.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/engine/src/picross/engine/grid/GridModel.java 2013-01-28 08:42:39 UTC (rev 136) @@ -117,8 +117,8 @@ this.rowData = GridModel.getRowHints(this.data); this.completedHints = - new CompletedHints(data.length, this.colData[0].length, - data[0].length, this.rowData[0].length); + new CompletedHints(this.data.length, this.colData[0].length, + this.data[0].length, this.rowData[0].length); /* * Marks the empty rows and columns as completed @@ -1036,5 +1036,15 @@ public CompletedHints getCompletedHints() { return this.completedHints; } + + public void clearAll() { + //for (Box[] boxRow : this.boxes) { + // for (Box box : boxRow) { + for (int i = 0; i < this.boxes.length; i++) { + for (int j = 0; j < this.boxes[i].length; j++) { + this.actOnBox(j, i, GridAction.EMPTY); + } + } + } } Modified: trunk/properties/messages_picross.properties =================================================================== --- trunk/properties/messages_picross.properties 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/properties/messages_picross.properties 2013-01-28 08:42:39 UTC (rev 136) @@ -4,6 +4,7 @@ # picross.game.GameUI gridSize = Size menuButton = Back to menu +resetButton = Reset # picross.game.random.RandomGameUI anotherGrid = Another grid Modified: trunk/properties/messages_picross_fr.properties =================================================================== --- trunk/properties/messages_picross_fr.properties 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/properties/messages_picross_fr.properties 2013-01-28 08:42:39 UTC (rev 136) @@ -4,6 +4,7 @@ # picross.game.GameUI gridSize = Taille menuButton = Retour au menu +resetButton = Recommencer # picross.game.random.RandomGameUI anotherGrid = Une autre grille Modified: trunk/swing/src/picross/specific/game/ui/GameController.java =================================================================== --- trunk/swing/src/picross/specific/game/ui/GameController.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/swing/src/picross/specific/game/ui/GameController.java 2013-01-28 08:42:39 UTC (rev 136) @@ -74,6 +74,11 @@ this.fireEventPerformed(cmd); return; } + + if (cmd.equals(PicrossController.RESET_CMD)) { + this.fireEventPerformed(cmd); + return; + } } } Modified: trunk/swing/src/picross/specific/game/ui/GameMediator.java =================================================================== --- trunk/swing/src/picross/specific/game/ui/GameMediator.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/swing/src/picross/specific/game/ui/GameMediator.java 2013-01-28 08:42:39 UTC (rev 136) @@ -33,7 +33,6 @@ package picross.specific.game.ui; -import fr.cle.mmvcs.Mediateur; import fr.cle.mmvcs.SimpleEvent; import java.awt.event.ActionListener; @@ -50,6 +49,7 @@ import picross.common.grid.ui.GridView; import picross.common.grid.ui.IGridMediator; +import picross.common.game.ui.AbstractGameMediator; import picross.common.game.ui.GameView; /** @@ -57,40 +57,7 @@ * * @author Y. Norsa */ -public abstract class GameMediator extends Mediateur { - /*** Static field ***/ - - /** The class' logger. */ - private static PicrossLogger log = PicrossLogHelper.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); - } - +public abstract class GameMediator extends AbstractGameMediator { /*** Methods ***/ /** @@ -137,22 +104,4 @@ 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/swing/src/picross/specific/game/ui/GameUI.java =================================================================== --- trunk/swing/src/picross/specific/game/ui/GameUI.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/swing/src/picross/specific/game/ui/GameUI.java 2013-01-28 08:42:39 UTC (rev 136) @@ -109,6 +109,11 @@ this.buttonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); this.buttonsPanel.setBackground(Color.WHITE); + JButton resetButton = new JButton(BundleHelper.getString(this, "resetButton")); + resetButton.addActionListener(listener); + resetButton.setActionCommand(PicrossController.RESET_CMD); + this.buttonsPanel.add(resetButton); + JButton menuButton = new JButton(BundleHelper.getString(this, "menuButton")); menuButton.addActionListener(listener); Modified: trunk/swing/src/picross/specific/grid/ui/GridController.java =================================================================== --- trunk/swing/src/picross/specific/grid/ui/GridController.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/swing/src/picross/specific/grid/ui/GridController.java 2013-01-28 08:42:39 UTC (rev 136) @@ -106,6 +106,11 @@ this.eraseMode = true; return; } + + if (cmd.equals(GridCommands.REPAINT_EVERYTHING_CMD)) { + this.view.doRepaint(); + return; + } } /*** Methods implanted from the interface MouseListener ***/ Modified: trunk/swing/src/picross/specific/grid/ui/GridUI.java =================================================================== --- trunk/swing/src/picross/specific/grid/ui/GridUI.java 2013-01-23 11:32:35 UTC (rev 135) +++ trunk/swing/src/picross/specific/grid/ui/GridUI.java 2013-01-28 08:42:39 UTC (rev 136) @@ -732,4 +732,18 @@ public void updateBox(int row, int col, Box box) { this.boxes[row][col].updateState(box); } + + public void clearAll() { + for (UIBox[] boxRow : this.boxes) { + for (UIBox box : boxRow) { + box.updateState(GridUI.EMPTY_BOX); + } + } + } + + private static final Box EMPTY_BOX = new Box(); + + public void doRepaint() { + this.repaint(); + } } 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: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-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-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...> - 2013-01-23 08:21:31
|
Revision: 131 http://sourceforge.net/p/picross/code/131 Author: yvan_norsa Date: 2013-01-23 08:21:27 +0000 (Wed, 23 Jan 2013) Log Message: ----------- reintegration branche separation moteur/etc Modified Paths: -------------- trunk/applet/picross.jnlp trunk/build.xml trunk/log4j.properties trunk/src/picross/app/PicrossApp.java trunk/src/picross/app/PicrossAppUI.java trunk/src/picross/applet/MainMenuAppletUI.java trunk/src/picross/applet/PicrossApplet.java Added Paths: ----------- trunk/android/ trunk/common/ trunk/engine/ trunk/images/empty_button.png trunk/images/en/button_back.png trunk/images/en/button_exit.png trunk/images/en/button_play.png trunk/images/en/button_random.png trunk/images/en/button_select.png trunk/images/en/label_wait.png trunk/images/fr/button_back.png trunk/images/fr/button_exit.png trunk/images/fr/button_play.png trunk/images/fr/button_random.png trunk/images/fr/button_select.png trunk/images/fr/label_wait.png trunk/properties/ trunk/services/picross.engine.game.GameMode trunk/src/picross/app/MainMenuAppUI.java trunk/swing/ Removed Paths: ------------- trunk/images/empty-button.png trunk/images/en/button-back.png trunk/images/en/button-exit.png trunk/images/en/button-play.png trunk/images/en/button-random.png trunk/images/en/button-select.png trunk/images/en/label-wait.png trunk/images/fr/button-back.png trunk/images/fr/button-exit.png trunk/images/fr/button-play.png trunk/images/fr/button-random.png trunk/images/fr/button-select.png trunk/images/fr/label-wait.png trunk/services/picross.game.GameMode trunk/src/picross/Picross.java trunk/src/picross/PicrossException.java trunk/src/picross/app/MainMenuAppUI.java trunk/src/picross/game/ trunk/src/picross/grid/ trunk/src/picross/properties/ trunk/src/picross/ui/ trunk/test/ Property Changed: ---------------- trunk/ Index: trunk =================================================================== --- trunk 2013-01-18 07:47:31 UTC (rev 130) +++ trunk 2013-01-23 08:21:27 UTC (rev 131) Property changes on: trunk ___________________________________________________________________ Added: svn:mergeinfo ## -0,0 +1 ## +/branches/engine_split:101-130 \ No newline at end of property Modified: trunk/applet/picross.jnlp =================================================================== --- trunk/applet/picross.jnlp 2013-01-18 07:47:31 UTC (rev 130) +++ trunk/applet/picross.jnlp 2013-01-23 08:21:27 UTC (rev 131) @@ -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: trunk/build.xml =================================================================== --- trunk/build.xml 2013-01-18 07:47:31 UTC (rev 130) +++ trunk/build.xml 2013-01-23 08:21:27 UTC (rev 131) @@ -3,28 +3,50 @@ <project name="picross" default="dist"> - <property name="build.dir" - value="build" /> + <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" + 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="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" value="src" /> - <property name="test.dir" - value="test" /> + <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="jar.name" + <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" 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 +58,10 @@ <target name="-init" depends="-setmode"> - <mkdir dir="${build.dir}" /> + <mkdir dir="${swing.build.dir}" /> + <mkdir dir="${common.build.dir}" /> + <mkdir dir="${engine.build.dir}" /> + <mkdir dir="${game.build.dir}" /> <mkdir dir="${dist.dir}" /> <mkdir dir="${doc.dir}" /> </target> @@ -62,20 +87,36 @@ </target> <path id="classpath"> - <pathelement location="${build.dir}" /> + <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}" /> + <pathelement location="${easymock.jar}" /> <pathelement location="${junit.jar}" /> <pathelement location="${log4j.jar}" /> <pathelement location="${mmvcs.jar}" /> <pathelement location="${simpleButton.jar}" /> </path> - <target name="compile" + <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="${src.dir}" - destdir="${build.dir}" + <javac srcdir="${swing.src.dir}" + destdir="${swing.build.dir}" deprecation="on" debug="${javac.debug}" optimize="${javac.optimize}"> @@ -85,11 +126,48 @@ </javac> </target> - <target name="compile-test" - depends="compile"> - <javac srcdir="${test.dir}" - destdir="${build.dir}" + <target name="common-compile" + depends="-init,engine-dist"> + <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}" + destdir="${engine.build.dir}" + deprecation="on" + debug="${javac.debug}" + optimize="${javac.optimize}"> + <compilerarg value="-Xlint:all" /> + </javac> + </target> + + <target name="game-compile" + depends="swing-dist,-init"> + <javac srcdir="${game.src.dir}" + destdir="${game.build.dir}" + deprecation="on" + debug="${javac.debug}" + optimize="${javac.optimize}"> + <compilerarg value="-Xlint:all" /> + + <classpath refid="game-classpath" /> + </javac> + </target> + + <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" /> @@ -98,27 +176,76 @@ </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="engine-dist" + depends="engine-compile"> + <jar destfile="${engine.jar.name}" + basedir="${engine.build.dir}" /> + </target> + + <target name="swing-dist" + depends="engine-dist,common-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="compile"> - <copy todir="${build.dir}/picross/properties" + depends="engine-dist,common-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}/picross/properties"> + <fileset dir="properties" /> + </copy> + + <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 +255,10 @@ fork="true" dir="."> <classpath> - <pathelement location="${jar.name}" /> + <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}" /> <pathelement location="${mmvcs.jar}" /> @@ -144,18 +274,24 @@ fork="true" dir="."> <classpath> - <pathelement location="${jar.name}" /> + <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}" /> <pathelement location="${mmvcs.jar}" /> <pathelement location="${debug.jar}" /> - <pathelement location="${simpleButton.jar}" /> + <pathelement location="${simpleButton.jar}" /> </classpath> </java> </target> <target name="test" - depends="dist,compile-test"> + depends="engine-test,common-test,swing-test" /> + + <target name="engine-test" + depends="dist,engine-compile-test"> <junit filtertrace="off" showoutput="on" printsummary="withOutAndErr"> @@ -164,7 +300,7 @@ <batchtest fork="yes" filtertrace="on"> - <fileset dir="${test.dir}"> + <fileset dir="${engine.test.dir}"> <include name="**/*Test.java" /> <exclude name="**/Abstract*Test.java" /> </fileset> @@ -174,26 +310,93 @@ </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="clean"> - <delete dir="${build.dir}" /> + <delete dir="${swing.build.dir}" /> + <delete dir="${common.build.dir}" /> + <delete dir="${engine.build.dir}" /> + <delete dir="${game.build.dir}" /> <delete dir="${dist.dir}" /> <delete dir="${doc.dir}" /> + <delete dir="${android.dir}/src/picross/data" /> + <delete dir="${android.dir}/src/picross/properties" /> <delete> + <fileset dir="${android.dir}/res/drawable/" + defaultexcludes="no" + includes="*.png" /> + </delete> + + <delete> + <fileset dir="${android.dir}/libs/" + defaultexcludes="no" + includes="*.png" /> + </delete> + + <delete> + <fileset dir="${android.dir}/extraData/gameModes/" + defaultexcludes="no" + includes="*" /> + </delete> + + <delete> <fileset dir="." defaultexcludes="no" includes="**/*~" /> </delete> + + <ant antfile="build.xml" + dir="${android.dir}" + target="clean" /> </target> <target name="rebuild" 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 +423,7 @@ <formatter type="xml" tofile="checkstyle.xml" /> - <fileset dir="${src.dir}" + <fileset dir="${game.src.dir}" includes="**/*.java" /> </checkstyle> @@ -261,11 +464,52 @@ 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 + + <!-- Android stuff --> + + <property name="android.dir" + value="android" /> + + <target name="android-dist" + depends="common-dist"> + <copy todir="${android.dir}/extraData/gameModes/META-INF/services"> + <fileset dir="services" /> + </copy> + + <copy todir="${android.dir}/src/picross/properties"> + <fileset dir="properties" /> + </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}/res/drawable"> + <fileset dir="images" + includes="*.png" + excludes="*rollover*.png" /> + <fileset dir="images/en/" + includes="*.png" /> + </copy> + + <copy todir="${android.dir}/src/picross/data"> + <fileset dir="data" /> + </copy> + + <ant antfile="build.xml" + dir="${android.dir}" + target="debug" /> + </target> +</project> Deleted: trunk/images/empty-button.png =================================================================== (Binary files differ) Copied: trunk/images/empty_button.png (from rev 130, branches/engine_split/images/empty_button.png) =================================================================== (Binary files differ) Deleted: trunk/images/en/button-back.png =================================================================== (Binary files differ) Deleted: trunk/images/en/button-exit.png =================================================================== (Binary files differ) Deleted: trunk/images/en/button-play.png =================================================================== (Binary files differ) Deleted: trunk/images/en/button-random.png =================================================================== (Binary files differ) Deleted: trunk/images/en/button-select.png =================================================================== (Binary files differ) Copied: trunk/images/en/button_back.png (from rev 130, branches/engine_split/images/en/button_back.png) =================================================================== (Binary files differ) Copied: trunk/images/en/button_exit.png (from rev 130, branches/engine_split/images/en/button_exit.png) =================================================================== (Binary files differ) Copied: trunk/images/en/button_play.png (from rev 130, branches/engine_split/images/en/button_play.png) =================================================================== (Binary files differ) Copied: trunk/images/en/button_random.png (from rev 130, branches/engine_split/images/en/button_random.png) =================================================================== (Binary files differ) Copied: trunk/images/en/button_select.png (from rev 130, branches/engine_split/images/en/button_select.png) =================================================================== (Binary files differ) Deleted: trunk/images/en/label-wait.png =================================================================== (Binary files differ) Copied: trunk/images/en/label_wait.png (from rev 130, branches/engine_split/images/en/label_wait.png) =================================================================== (Binary files differ) Deleted: trunk/images/fr/button-back.png =================================================================== (Binary files differ) Deleted: trunk/images/fr/button-exit.png =================================================================== (Binary files differ) Deleted: trunk/images/fr/button-play.png =================================================================== (Binary files differ) Deleted: trunk/images/fr/button-random.png =================================================================== (Binary files differ) Deleted: trunk/images/fr/button-select.png =================================================================== (Binary files differ) Copied: trunk/images/fr/button_back.png (from rev 130, branches/engine_split/images/fr/button_back.png) =================================================================== (Binary files differ) Copied: trunk/images/fr/button_exit.png (from rev 130, branches/engine_split/images/fr/button_exit.png) =================================================================== (Binary files differ) Copied: trunk/images/fr/button_play.png (from rev 130, branches/engine_split/images/fr/button_play.png) =================================================================== (Binary files differ) Copied: trunk/images/fr/button_random.png (from rev 130, branches/engine_split/images/fr/button_random.png) =================================================================== (Binary files differ) Copied: trunk/images/fr/button_select.png (from rev 130, branches/engine_split/images/fr/button_select.png) =================================================================== (Binary files differ) Deleted: trunk/images/fr/label-wait.png =================================================================== (Binary files differ) Copied: trunk/images/fr/label_wait.png (from rev 130, branches/engine_split/images/fr/label_wait.png) =================================================================== (Binary files differ) Modified: trunk/log4j.properties =================================================================== --- trunk/log4j.properties 2013-01-18 07:47:31 UTC (rev 130) +++ trunk/log4j.properties 2013-01-23 08:21:27 UTC (rev 131) @@ -1,4 +1,4 @@ log4j.rootCategory=debug, stdout, log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%5p (%F:%L) - %m%n +log4j.appender.stdout.layout.ConversionPattern=%5p - %m%n Copied: trunk/services/picross.engine.game.GameMode (from rev 130, branches/engine_split/services/picross.engine.game.GameMode) =================================================================== --- trunk/services/picross.engine.game.GameMode (rev 0) +++ trunk/services/picross.engine.game.GameMode 2013-01-23 08:21:27 UTC (rev 131) @@ -0,0 +1,2 @@ +picross.specific.game.random.ui.RandomGameModeUI +picross.specific.game.simple.ui.SimpleGameModeUI Deleted: trunk/services/picross.game.GameMode =================================================================== --- trunk/services/picross.game.GameMode 2013-01-18 07:47:31 UTC (rev 130) +++ trunk/services/picross.game.GameMode 2013-01-23 08:21:27 UTC (rev 131) @@ -1,2 +0,0 @@ -picross.game.random.ui.RandomGameModeUI -picross.game.simple.ui.SimpleGameModeUI Deleted: trunk/src/picross/Picross.java =================================================================== --- trunk/src/picross/Picross.java 2013-01-18 07:47:31 UTC (rev 130) +++ trunk/src/picross/Picross.java 2013-01-23 08:21:27 UTC (rev 131) @@ -1,104 +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 java.net.URL; - -import java.util.Locale; - -//import org.apache.log4j.Logger; - -/** - * Helper class. - * - * @author Y. Norsa - */ -public final class Picross { - /*** Constant ***/ - - /** Data directory. */ - private static final String DATA_DIR = "/picross/data/"; - - /*** Static field ***/ - - /** The class' logger. */ - //private static Logger log = Logger.getLogger(Picross.class); - - /*** 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(); - } -} - Deleted: trunk/src/picross/PicrossException.java =================================================================== --- trunk/src/picross/PicrossException.java 2013-01-18 07:47:31 UTC (rev 130) +++ trunk/src/picross/PicrossException.java 2013-01-23 08:21:27 UTC (rev 131) @@ -1,67 +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; - -/** - * 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); - } -} - Deleted: trunk/src/picross/app/MainMenuAppUI.java =================================================================== --- trunk/src/picross/app/MainMenuAppUI.java 2013-01-18 07:47:31 UTC (rev 130) +++ trunk/src/picross/app/MainMenuAppUI.java 2013-01-23 08:21:27 UTC (rev 131) @@ -1,94 +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.app; - -import java.awt.event.ActionListener; - -import picross.ui.MainMenuUI; -import picross.ui.PicrossController; - -/** - * Main menu for the application version. - * - * @author Y. Norsa - */ -public final class MainMenuAppUI extends MainMenuUI { - /*** Constants ***/ - - /** Serialisation ID. */ - private static final long serialVersionUID = 8153436550520127667L; - - /** "Play" button X coordinate. */ - private static final int PLAY_BUTTON_X = 50; - - /** "Play" button Y coordinate. */ - private static final int PLAY_BUTTON_Y = 225; - - /** Image for the "exit" button. */ - private static final String EXIT_BUTTON_IMAGE = "button-exit.png"; - - /** "Exit" button X coordinate. */ - private static final int EXIT_BUTTON_X = 250; - - /** "Exit" button Y coordinate. */ - private static final int EXIT_BUTTON_Y = 225; - - /*** Methods overloaded from the class MainMenuUI ***/ - - /** {@inheritDoc} */ - @Override - protected void init(ActionListener controller) { - super.init(controller); - - this.addButton(MainMenuAppUI.EXIT_BUTTON_IMAGE, - PicrossController.EXIT_CMD, - controller, - MainMenuAppUI.EXIT_BUTTON_X, - MainMenuAppUI.EXIT_BUTTON_Y); - } - - /** {@inheritDoc} */ - @Override - protected int getPlayButtonX() { - return MainMenuAppUI.PLAY_BUTTON_X; - } - - /** {@inheritDoc} */ - @Override - protected int getPlayButtonY() { - return MainMenuAppUI.PLAY_BUTTON_Y; - } -} - - Copied: trunk/src/picross/app/MainMenuAppUI.java (from rev 130, branches/engine_split/src/picross/app/MainMenuAppUI.java) =================================================================== --- trunk/src/picross/app/MainMenuAppUI.java (rev 0) +++ trunk/src/picross/app/MainMenuAppUI.java 2013-01-23 08:21:27 UTC (rev 131) @@ -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.app; + +import java.awt.event.ActionListener; + +import picross.common.ui.MainMenuUI; +import picross.common.ui.PicrossController; + +import picross.specific.ui.MenuController; + +/** + * Main menu for the application version. + * + * @author Y. Norsa + */ +public final class MainMenuAppUI extends MainMenuUI { + /*** Constants ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = 8153436550520127667L; + + /** "Play" button X coordinate. */ + private static final int PLAY_BUTTON_X = 50; + + /** "Play" button Y coordinate. */ + private static final int PLAY_BUTTON_Y = 225; + + /** Image for the "exit" button. */ + private static final String EXIT_BUTTON_IMAGE = "button_exit.png"; + + /** "Exit" button X coordinate. */ + private static final int EXIT_BUTTON_X = 250; + + /** "Exit" button Y coordinate. */ + private static final int EXIT_BUTTON_Y = 225; + + /*** Methods overloaded from the class MainMenuUI ***/ + + /** {@inheritDoc} */ + @Override + public void init(/*ActionListener*/MenuController controller) { + super.init(controller); + + this.addButton(MainMenuAppUI.EXIT_BUTTON_IMAGE, + PicrossController.EXIT_CMD, + controller, + MainMenuAppUI.EXIT_BUTTON_X, + MainMenuAppUI.EXIT_BUTTON_Y); + } + + /** {@inheritDoc} */ + @Override + protected int getPlayButtonX() { + return MainMenuAppUI.PLAY_BUTTON_X; + } + + /** {@inheritDoc} */ + @Override + protected int getPlayButtonY() { + return MainMenuAppUI.PLAY_BUTTON_Y; + } +} + + Modified: trunk/src/picross/app/PicrossApp.java =================================================================== --- trunk/src/picross/app/PicrossApp.java 2013-01-18 07:47:31 UTC (rev 130) +++ trunk/src/picross/app/PicrossApp.java 2013-01-23 08:21:27 UTC (rev 131) @@ -37,7 +37,7 @@ import org.apache.log4j.PropertyConfigurator; -import picross.ui.PicrossMediator; +import picross.specific.ui.PicrossMediator; /** * Main class of the application version. Modified: trunk/src/picross/app/PicrossAppUI.java =================================================================== --- trunk/src/picross/app/PicrossAppUI.java 2013-01-18 07:47:31 UTC (rev 130) +++ trunk/src/picross/app/PicrossAppUI.java 2013-01-23 08:21:27 UTC (rev 131) @@ -38,8 +38,8 @@ import javax.swing.JFrame; import javax.swing.JOptionPane; -import picross.ui.PicrossUI; -import picross.ui.PicrossView; +import picross.common.ui.PicrossUI; +import picross.common.ui.PicrossView; /** * Main window of the application version. Modified: trunk/src/picross/applet/MainMenuAppletUI.java =================================================================== --- trunk/src/picross/applet/MainMenuAppletUI.java 2013-01-18 07:47:31 UTC (rev 130) +++ trunk/src/picross/applet/MainMenuAppletUI.java 2013-01-23 08:21:27 UTC (rev 131) @@ -37,8 +37,10 @@ import java.awt.event.ActionListener; -import picross.ui.MainMenuUI; +import picross.common.ui.MainMenuUI; +import picross.specific.ui.MenuController; + /** * Main menu for the applet version. * @@ -60,7 +62,7 @@ /** {@inheritDoc} */ @Override - protected void init(ActionListener controller) { + public void init(/*ActionListener*/MenuController controller) { super.init(controller); this.setBackground(Color.WHITE); Modified: trunk/src/picross/applet/PicrossApplet.java =================================================================== --- trunk/src/picross/applet/PicrossApplet.java 2013-01-18 07:47:31 UTC (rev 130) +++ trunk/src/picross/applet/PicrossApplet.java 2013-01-23 08:21:27 UTC (rev 131) @@ -39,9 +39,9 @@ import javax.swing.JOptionPane; import javax.swing.SwingUtilities; -import picross.ui.PicrossMediator; -import picross.ui.PicrossUI; -import picross.ui.PicrossView; +import picross.specific.ui.PicrossMediator; +import picross.common.ui.PicrossUI; +import picross.common.ui.PicrossView; /** * Main class of the applet version. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2020-03-14 09:39:38
|
Revision: 137 http://sourceforge.net/p/picross/code/137 Author: yvan_norsa Date: 2020-03-14 09:39:37 +0000 (Sat, 14 Mar 2020) Log Message: ----------- added JS phaser implementation Added Paths: ----------- trunk/phaser/ trunk/phaser/Box.js trunk/phaser/CompletedHints.js trunk/phaser/GameScene.js trunk/phaser/GridAction.js trunk/phaser/GridController.js trunk/phaser/GridMediator.js trunk/phaser/GridModel.js trunk/phaser/GridUI.js trunk/phaser/HintBox.js trunk/phaser/MainMenu.js trunk/phaser/RandomPicrossModel.js trunk/phaser/SimpleButton.js trunk/phaser/UIBox.js trunk/phaser/index.html trunk/phaser/picross.js Added: trunk/phaser/Box.js =================================================================== --- trunk/phaser/Box.js (rev 0) +++ trunk/phaser/Box.js 2020-03-14 09:39:37 UTC (rev 137) @@ -0,0 +1,110 @@ +/* Copyright Yvan Norsa (2007-2020) + * + * yva...@gm... + * + * This software is a computer program whose purpose is to [describe + * functionalities and technical features of your software]. + * + * 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. + */ + + /** Possibles states of a box. */ + class BoxState { }; + /** An empty box. */ + BoxState.EMPTY = 0; + + /** A checked box. */ + BoxState.CHECKED = 1; + + /** A crossed box. */ + BoxState.CROSSED = 2; + +/** + * Representation of a box in the grid. + * + * @author Y. Norsa + */ + class Box { + + /*** Constructor ***/ + + /** Constructor. */ + constructor() { + this.empty(); + this.hash = Math.random(); + } + + + hashCode() { + return this.hash; + } + + /*** Methods ***/ + + /** + * Permits to know if the box is checked. + * + * @return boolean telling if the box is checked + */ + isChecked() { + return this.state == BoxState.CHECKED; + } + + /** + * Permits to know if the box is crossed. + * + * @return boolean telling if the box is crossed + */ + isCrossed() { + return this.state == BoxState.CROSSED; + } + + /** + * Permits to know if the box is empty. + * + * @return boolean telling if the box is empty + */ + isEmpty() { + return this.state == BoxState.EMPTY; + } + + /** Empties the box. */ + empty() { + this.state = BoxState.EMPTY; + } + + /** Checks the box. */ + check() { + this.state = BoxState.CHECKED; + } + + /** Crosses the box. */ + cross() { + this.state = BoxState.CROSSED; + } +} + Added: trunk/phaser/CompletedHints.js =================================================================== --- trunk/phaser/CompletedHints.js (rev 0) +++ trunk/phaser/CompletedHints.js 2020-03-14 09:39:37 UTC (rev 137) @@ -0,0 +1,193 @@ +/* Copyright Yvan Norsa (2007-2020) + * + * yva...@gm... + * + * This software is a computer program whose purpose is to [describe + * functionalities and technical features of your software]. + * + * 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. + */ + +/** + * This class contains the list of hints, marking those which are completed. + * + * @author Y. Norsa + */ +class CompletedHints { + /*** Constructor ***/ + + /** + * Constructor. + * + * @param colsHintsWidth width of the column hints list + * @param colsHintsHeight height of the column hints list + * @param rowsHintsWidth width of the row hints list + * @param rowsHintsHeight height of the row hints list + * @throws IllegalArgumentException if one of the parameters is <= 0 + */ + constructor( colsHintsWidth, colsHintsHeight, + rowsHintsWidth, rowsHintsHeight) + { + + /** List of completed column hints. */ + this.completedCols = Array(colsHintsWidth).fill().map(() => Array(colsHintsHeight).fill(false)); + /** List of completed row hints. */ + this.completedRows = Array(rowsHintsWidth).fill().map(() => Array(rowsHintsHeight).fill(false)); + + } + + /*** Methods ***/ + + /** + * Tells wether a specific column hint is complete. + * + * @param x column number + * @param y hint position + * @return boolean telling wether the hint is completed + */ + isColHintComplete( x, y) { + return this.completedCols[x][y]; + } + + /** + * Returns the list of the completed column hints. + * + * @param column column number + * @return list of completed hints in the column + * @throws IllegalArgumentException if <code>column</code> is lesser + * than 0 or greater than the number of hints columns + */ + getCompleteColHints( column) { + + + var res = []; + + for (var i = 0; i < this.completedCols[column].length; i++) { + if (this.completedCols[column][i]) { + res.push(i); + } + } + + return res; + } + + /** + * Resets the state of a hint. + * + * @param col column number + * @param hintIndex hint position + */ + clearColHint( col, hintIndex) { + this.completedCols[col][hintIndex] = false; + } + + /** + * Marks a hint as complete. + * + * @param col column number + * @param index hint position + */ + setCompleteColHint( col, index) { + this.completedCols[col][index] = true; + } + + /** + * Marks a whole column as complete. + * + * @param col column number + */ + setCompleteCol( col) { + for (var i = 0; i < this.completedCols[col].length; i++) { + this.setCompleteColHint(col, i); + } + } + + /** + * Tells wether a specific row hint is complete. + * + * @param x row number + * @param y hint position + * @return boolean telling wether the hint is completed + */ + isRowHintComplete( x, y) { + return this.completedRows[x][y]; + } + + /** + * Returns the list of the completed row hints. + * + * @param row row number + * @return list of completed hints in the row + * @throws IllegalArgumentException if <code>row</code> is lesser + * than 0 or greater than the number of hints row + */ + getCompleteRowHints( row) { + + + var res = []; + + for (var i = 0; i < this.completedRows[row].length; i++) { + if (this.completedRows[row][i]) { + res.push(i); + } + } + + return res; + } + + /** + * Resets the state of a hint. + * + * @param row row number + * @param hintIndex hint position + */ + clearRowHint( row, hintIndex) { + this.completedRows[row][hintIndex] = false; + } + + /** + * Marks a hint as complete. + * + * @param row row number + * @param index hint position + */ + setCompleteRowHint( row, index) { + this.completedRows[row][index] = true; + } + + /** + * Marks a whole row as complete. + * + * @param row row number + */ + setCompleteRow( row) { + for (var i = 0; i < this.completedRows[row].length; i++) { + this.setCompleteRowHint(row, i); + } + } +} + Added: trunk/phaser/GameScene.js =================================================================== --- trunk/phaser/GameScene.js (rev 0) +++ trunk/phaser/GameScene.js 2020-03-14 09:39:37 UTC (rev 137) @@ -0,0 +1,119 @@ +/* Copyright Yvan Norsa (2007-2020) + * + * yva...@gm... + * + * This software is a computer program whose purpose is to [describe + * functionalities and technical features of your software]. + * + * 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. + */ + +class GameScene extends Phaser.Scene { + constructor () { + super({ key: 'game' }); + } + + preload () { + this.load.setBaseURL('http://picross.sourceforge.net/phaser/images/'); + this.load.image('checked-rollover', 'checked-rollover.png'); + this.load.image('checked', 'checked.png'); + this.load.image('crossed', 'crossed.png'); + this.load.image('crossed-rollover', 'crossed-rollover.png'); + this.load.image('empty-rollover', 'empty-rollover.png'); + this.load.image('empty', 'empty.png'); + this.load.image('hint', 'hint.png'); + } + + + create () { + //this.stage.backgroundColor = "#FFFFFF"; + +/* + + if (this.view.isInGrid(point)) { + int row = this.view.getRow(point); + int column = this.view.getColumn(point); + + this.view.setRollover(row, column); + } else { + this.view.rolloverEnded(); + } + */ + +/* + // Paints the boxes + for (var i = 0; i < 200; i=i+25) { + for (var j = 0; j < 300; j=j+25) { + this.add.image(i, j, "empty").setOrigin(0, 0); + } + } + */ + + var gridModel = new RandomPicrossModel(); + + var width = gridModel.width; + var height = gridModel.height; + + this.model = new GridMediator(width, height, gridModel.data, this); + + + //this.input.on('pointermove', function (pointer) {this.model.controller.mouseMoved(pointer)}, this); + this.input.on('pointermove', this.model.controller.mouseMoved, this.model.controller); + this.input.on('pointerdown', this.model.controller.mousePressed, this.model.controller); + this.input.on('pointerup', this.model.controller.mouseReleased, this.model.controller); + + this.model.view.paintComponent(this); + +/* +this.add.line(0, 0, 200, 200, 300, 200, 0xffaabb); + + var rect = new Phaser.GameObjects.Rectangle(this, 0,15 + + (2 * GridUI.BOX_HEIGHT), + 15, + GridUI.BOX_HEIGHT,).setOrigin(0); + rect.setFillStyle(0xff0000); + this.children.add(rect); +*/ + + + + } + + update() { + /* + for (var i = 0; i < 200; i=i+25) { + for (var j = 0; j < 300; j=j+25) { + if ((this.rolloverRow * 25) == j && (this.rolloverColumn * 25) == i) { + this.add.image(i, j, "empty-rollover").setOrigin(0, 0); + } + } + } + */ + + this.model.view.repaint(this); + } +}; \ No newline at end of file Added: trunk/phaser/GridAction.js =================================================================== --- trunk/phaser/GridAction.js (rev 0) +++ trunk/phaser/GridAction.js 2020-03-14 09:39:37 UTC (rev 137) @@ -0,0 +1,48 @@ +/* Copyright Yvan Norsa (2007-2020) + * + * yva...@gm... + * + * This software is a computer program whose purpose is to [describe + * functionalities and technical features of your software]. + * + * 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. + */ + + class GridAction { } + /** Unrecognized action. */ + GridAction.UNKNOWN = 0; + + /** Checking a box. */ + GridAction.CHECK = 1; + + /** Crossing a box. */ + GridAction.CROSS = 2; + + /** Erasing a box. */ + GridAction.EMPTY = 3; + + Added: trunk/phaser/GridController.js =================================================================== --- trunk/phaser/GridController.js (rev 0) +++ trunk/phaser/GridController.js 2020-03-14 09:39:37 UTC (rev 137) @@ -0,0 +1,254 @@ +/* Copyright Yvan Norsa (2007-2020) + * + * yva...@gm... + * + * This software is a computer program whose purpose is to [describe + * functionalities and technical features of your software]. + * + * 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. + */ + + class GridController { + + /** The view to which the controller is attached. */ + //private GridUI view = null; + + /** Indicates wether the erase mode is "on" or not. */ + //private boolean eraseMode; + + /*** Method overloaded from the class Controller ***/ + + constructor(mediator) { + this.mediator = mediator; + } + + doPaintCommand(row, col) { + + this.view.repaint(row, col); + + } + + + doRepaintTopHintsCommand(col) { + this.view.repaintColHints(col); + } + + doRepaintLeftHintsCommand(row) { + this.view.repaintRowHints(row); + } + + doEraseModeCommand() { + this.eraseMode = true; + } + + doGridFilledCommand() { + this.view.rolloverEnded(); + this.view.disableGrid(); + + } + + eventPerformed( e) { + /* + String cmd = e.getCommandName(); + + if (cmd.equals(GridCommands.GRID_FILLED_CMD)) { + this.view.rolloverEnded(); + this.view.disableGrid(); + + return; + } + + if (cmd.equals(GridCommands.PAINT_CMD)) { + PaintCommand command = (PaintCommand) e.getCommand(); + this.view.repaint(command.getRow(), command.getColumn()); + + return; + } + + if (cmd.equals(GridCommands.REPAINT_TOP_HINTS_CMD)) { + int col = ((RepaintTopHintsCommand) e.getCommand()).getColumn(); + this.view.repaintColHints(col); + + return; + } + + if (cmd.equals(GridCommands.REPAINT_LEFT_HINTS_CMD)) { + int row = ((RepaintLeftHintsCommand) e.getCommand()).getRow(); + this.view.repaintRowHints(row); + + return; + } + + if (cmd.equals(GridCommands.ERASE_MODE_CMD)) { + this.eraseMode = true; + return; + } + + if (cmd.equals(GridCommands.REPAINT_EVERYTHING_CMD)) { + this.view.doRepaint(); + return; + } + */ + } + + /*** Methods implanted from the interface MouseListener ***/ + mouseClicked( e) { } + +mouseEntered( e) { } + + +mouseExited( e) { + this.view.rolloverEnded(); + this.view.highlightEnded(); + } + + + mousePressed (e) { + //this.view.rolloverEnded(); + } + +mouseReleased( e) { + this.checkAndFill(e); + this.eraseMode = false; + this.mediator.doEndActionCommand(); + } + + /*** Methods implanted from the interface MouseMotionListener ***/ + /* + mouseDragged (e) { + this.checkAndFill(e); + } +*/ + + mouseMoved( e) { + // dragging + + /* + if (e.leftButtonDown() || e.rightButtonDown()) { + + this.checkAndFill(e); + + + + } else { +*/ + var point = e.position; + + if (this.view.isInGrid(point)) { + var row = this.view.getRow(point); + var column = this.view.getColumn(point); + + this.view.setRollover(row, column); + +/**/ + if (e.leftButtonDown() || e.rightButtonDown()) { + + this.checkAndFill(e); + } +/**/ + + + } else { + this.view.rolloverEnded(); + } + // } + } + + /*** Methods ***/ + + /** + * Checks if the mouse current click's location is inside the grid + * and eventually fills the corresponding box. + * + * @param e mouse event to handle + */ + checkAndFill( e) { +/* var modifiers = e.getModifiers(); + + if (modifiers != MouseEvent.BUTTON1_MASK + && modifiers != MouseEvent.BUTTON3_MASK) { +*/ +if (!e.leftButtonDown() && !e.leftButtonReleased() + && !e.rightButtonDown() && !e.rightButtonReleased()) { + return; + } + + var point = e.position; + + if (this.view.isInGrid(point)) { + var row = this.view.getRow(point); + var column = this.view.getColumn(point); + + var type; + + if (this.eraseMode) { + type = GridAction.EMPTY; + } else { + type = GridController.modifiersToType(e.event); + } + + this.view.rolloverHighlight(row, column); + + //this.fireEventPerformed(GridCommands.FILL_CMD, + this.mediator.doFillCommand(row, column, type); + } else { + this.view.highlightEnded(); + } + } + + /** + * Converts a mouse click to an action. + * + * @param modifiers mouse event modifiers + * @return corresponding action, or -1 + */ + static modifiersToType( e) { + // Chrome fix + if (e.button === 2 || e.buttons === 2) { + return GridAction.CROSS; + } + + if (e.button === 0) { + return GridAction.CHECK; + } + + return GridAction.UNKNOWN; + + } + + /*** Accessor ***/ + + /** + * Allows to set the view. + * + * @param view view to which this controller is attached + */ + setView( view) { + this.view = view; + } +} + Added: trunk/phaser/GridMediator.js =================================================================== --- trunk/phaser/GridMediator.js (rev 0) +++ trunk/phaser/GridMediator.js 2020-03-14 09:39:37 UTC (rev 137) @@ -0,0 +1,114 @@ +/* Copyright Yvan Norsa (2007-2020) + * + * yva...@gm... + * + * This software is a computer program whose purpose is to [describe + * functionalities and technical features of your software]. + * + * 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. + */ + +class GridMediator { + constructor(width, height, data, scene) { + this.model = new GridModel(data); + + this.controller = this.initController(); + //controller.addSimpleListener(this); + //this.addSimpleListener(controller); + + var tmpBoxes = this.model.boxes; + var boxes = []; + + for (var i = 0; i < tmpBoxes.length; i++) { + boxes[i] = []; + + for (var j = 0; j < tmpBoxes[i].length; j++) { + boxes[i][j] = UIBox.fromBox(tmpBoxes[i][j]); + } + } + + var hints = this.model.getCompletedHints(); + + var colData = this.model.colData; + var rowData = this.model.rowData; + + //this.initGrid(width, height, boxes, colData, rowData, hints, controller); + this.view = new GridUI(width, height, + boxes, + colData, + rowData, + hints, + null); + + this.controller.setView(this.view); + + this.view.init(scene); + + } + + + initController() { + return new GridController(this); + } + + + + doFillCommand(row, col, type) { + + this.model.actOnBox(row, col, type); + + // TODO what now ? check the model'state + this.view.updateBox(col, row, this.model.getBoxes()[col][row]); + + this.controller.doPaintCommand(row, col); + + this.controller.doRepaintLeftHintsCommand(row); + this.controller.doRepaintTopHintsCommand(col); + + if (this.model.checkCompleted()) { + this.congratulations(); + } else { + if (this.model.getEraseMode()) { + this.controller.doEraseModeCommand(); + } + } + + return; + } + + doEndActionCommand() { + this.model.endAction(); + } + + congratulations() { + //this.fireEventPerformed(PicrossController.MESSAGE_CMD, + // BundleHelper.getString(this, "victory")); + alert("Congratulations"); + + this.controller.doGridFilledCommand(); + } +} \ No newline at end of file Added: trunk/phaser/GridModel.js =================================================================== --- trunk/phaser/GridModel.js (rev 0) +++ trunk/phaser/GridModel.js 2020-03-14 09:39:37 UTC (rev 137) @@ -0,0 +1,1017 @@ +/* Copyright Yvan Norsa (2007-2020) + * + * yva...@gm... + * + * This software is a computer program whose purpose is to [describe + * functionalities and technical features of your software]. + * + * 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. + */ + +class GridModel { + constructor(cData) { + this.data = cData; + + var lineSize = this.data[0].length; + + this.boxes = []; + + for (var i = 0; i < this.data.length; i++) { + this.boxes[i] = []; + for (var j = 0; j < lineSize; j++) { + this.boxes[i][j] = new Box(); + } + } + + this.colData = GridModel.getColHints(this.data); + this.rowData = GridModel.getRowHints(this.data); + + this.completedHints = + new CompletedHints(this.data.length, this.colData[0].length, + this.data[0].length, this.rowData[0].length); + + for (var i = 0; i < this.rowData.length; i++) { + if (this.emptyRow(i)) { + this.completedHints.setCompleteRow(i); + } else { + for (var j = 0; j < this.rowData[i].length; j++) { + if (this.rowData[i][j] == GridModel.EMPTY_HINT) { + this.completedHints.setCompleteRowHint(i, j); + } + } + } + } + + for (var i = 0; i < this.colData.length; i++) { + if (this.emptyCol(i)) { + this.completedHints.setCompleteCol(i); + } else { + for (var 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(cData); + this.colHintsTotal = GridModel.computeColHintsTotal(cData); + + } + + + /** + * Extracts the column hints from the grid data. + * + * @param data the grid data + * @return column hints + */ + + static getColHints(data) { + // Grid of columns hints + var colHints = []; + + // Largest number of hints for a column + var max = 0; + + for (var i = 0; i < data.length; i++) { + var col = data[i]; + var current = []; + + // Current hint + var chain = 0; + + for (var j = 0; j < col.length; j++) { + var cell = col[j]; + + if (cell) { + chain++; + } else if (chain > 0) { + // We've reached the end of a series of checked boxes + current.push(chain); + chain = 0; + } + } + + if (chain > 0) { + current.push(chain); + } else if (current.length == 0) { + // If this column is empty, we add a "0" hint + current.push(0); + } + + var currentSize = current.length; + + if (currentSize > max) { + max = currentSize; + } + + colHints.push(current); + } + + /* + * So for the hints : + * + * 1 + * 0 2 1 + * + * Which corresponds to the grid : + * + * |-----| + * |_|X|_| + * |_|_|X| + * |_|X|_| + * |_|X|_| + * |-----| + * + * We build this array : + * {{0, -1}, {2, 1}, {1, -1}} + */ + + //int[][] result = new int[data.length][max]; + //var result = new Array(data.length).fill(new Array(max).fill(0)); + var result = []; + + for (var i = 0; i < data.length; i++) { + result[i] = []; + } + + for (var i = 0; i < max; i++) { + // Minimal number of hints for the current column to be considered + var ref = max - i; + + // Current hint row + var currentRow = ref - 1; + + for (var j = 0; j < colHints.length; j++) { + var currentCol = colHints[j]; + var size = currentCol.length; + + if (size >= ref) { + result[j][currentRow] = currentCol[size - ref]; + } else { + result[j][currentRow] = GridModel.EMPTY_HINT; + } + } + } + + return result; + } + + /** + * Extracts the row hints from the grid data. + * + * @param data the grid data + * @return row hints + */ + + static getRowHints( data) { + var rowHints = []; + var max = 0; + + for (var i = 0; i < data[0].length; i++) { + var current = []; + var chain = 0; + + for (var j = 0; j < data.length; j++) { + if (data[j][i]) { + chain++; + } else if (chain > 0) { + current.push(chain); + chain = 0; + } + } + + if (chain > 0) { + current.push(chain); + } else if (current.length == 0) { + current.push(0); + } + + var currentSize = current.length; + + if (currentSize > max) { + max = currentSize; + } + + rowHints.push(current); + } + + //int[][] result = new int[data[0].length][max]; + //var result = new Array(data[0].length).fill(new Array(max).fill(0)); + var result = []; + + for (var i = 0; i < data[0].length; i++) { + result[i] = []; + } + + var nbRows = rowHints.length; + + for (var i = 0; i < max; i++) { + var ref = max - i; + + for (var j = 0; j < nbRows; j++) { + var currentRow = rowHints[j]; + var size = currentRow.length; + + if (size >= ref) { + result[j][i] = currentRow[i - Math.abs(size - max)]; + } else { + result[j][i] = GridModel.EMPTY_HINT; + } + } + } + + return result; + } + + /** + * Returns the index of the first non-empty hint. + * + * @param hints hints array + * @return index of the first non-empty hint + */ + static getFirstHintIndex( hints) { + return GridModel.getNextHintIndex(0, hints); + } + + /** + * Returns the index of the next non-empty hint. + * + * @param currentIndex start index + * @param hints hints array + * @return index of the next non-empty hint + */ + static getNextHintIndex( currentIndex, hints) { + for (var i = currentIndex; i < hints.length; i++) { + if (hints[i] != GridModel.EMPTY_HINT) { + return i; + } + } + + return GridModel.EMPTY_HINT; + } + + /** + * Returns the index of the last non-empty hint. + * + * @param hints hints array + * @return index of the last non-empty hint + */ + static getLastHintIndex( hints) { + return GridModel.getPreviousHintIndex(hints.length - 1, hints); + } + + /** + * Returns the index of the previous non-empty hint. + * + * @param currentIndex start index + * @param hints hints array + * @return index of the previous non-empty hint + */ + static getPreviousHintIndex( currentIndex, hints) { + for (var i = currentIndex; i >= 0; i--) { + if (hints[i] != GridModel.EMPTY_HINT) { + return i; + } + } + + return GridModel.EMPTY_HINT; + } + + static computeRowHintsTotal( data) { + //int[] result = new int[data[0].length]; + var result = new Array(data[0].length); + + for (var i = 0; i < data[0].length; i++) { + var total = 0; + + for (var j = 0; j < data.length; j++) { + if (data[j][i]) { + total++; + } + } + + result[i] = total; + } + + return result; + } + + static computeColHintsTotal( data) { + //int[] result = new int[data.length]; + var result = new Array(data.length); + + for (var i = 0; i < data.length; i++) { + var total = 0; + + //for (boolean cell : data[i]) { + for (var j = 0; j < data[i].length; j++) { + var cell = data[i][j]; + + if (cell) { + total++; + } + } + + result[i] = total; + } + + return result; + } + + /*** Methods ***/ + + /** + * Method called during an action. Does the action on the specified box, + * then checks for completed hints. + * + * @param row row of the box + * @param column column of the box + * @throws IllegalArgumentException if <code>row</code> or + * <code>column</code> is less than 0 + */ + actOnBox( row, column, type) { + + if (type == GridAction.UNKNOWN) { + return; + } + +/* + + console.log("actOnBox(" + row + ", " + column + ")"); + console.log("lastModified == null : " + + (this.lastModified == null)); +*/ +/* + +if (column >= this.boxes.length || row >= this.boxes[0].length) { + console.log("#############"); + debugger; +} +*/ + + //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 + * (while dragging), do nothing + */ + if (this.lastModified != null + && this.lastModified == this.boxes[column][row]) { + + return; + } + + if (this.lastModified != null) { + /* + * If we are in a box which is in the same state as our aim + * (if we are in a checks serie and we are on a box which + * is already checked), do nothing + */ + + if (this.boxes[column][row] === this.lastModified) { + return; + } + } + + if (!this.boxes[column][row].isEmpty() && type == GridAction.EMPTY) { + this.boxes[column][row].empty(); + + // FIXME + //this.mediator.repaint(row, column); + } else { + + if (this.boxes[column][row].isEmpty() + && (this.lastModified == null || !this.lastModified.isEmpty())) { + + if (type == GridAction.CHECK) { + console.log("checked 1"); + this.boxes[column][row].check(); + } else { //if (type == GridAction.CROSS) { + console.log("crossed 1"); + this.boxes[column][row].cross(); + } + + // FIXME + //this.mediator.repaint(row, column); + } else if (!this.boxes[column][row].isEmpty() + && (this.lastModified == null + || this.lastModified.isEmpty())) { + + if (this.boxes[column][row].isChecked()) { + console.log("checked 2"); + + if (type == GridAction.CHECK) { + this.boxes[column][row].empty(); + this.setEraseMode(); + } else { //if (type == GridAction.CROSS) { + console.log("crossed 2"); + this.boxes[column][row].cross(); + } + } else { //if (this.boxes[column][row].isCrossed()) { + console.log("crossed 3"); + + if (type == GridAction.CROSS) { + this.boxes[column][row].empty(); + this.setEraseMode(); + } else { //if (type == GridAction.CHECK) { + console.log("checked 3"); + + this.boxes[column][row].check(); + } + } + + // FIXME + //this.mediator.repaint(row, column); + } + } + + this.lastModified = this.boxes[column][row]; + this.checkColumn(column); + this.checkRow(row); + //this.checkCompleted(); + } + + //private boolean erase; + + /** Enables the erase mode. */ + setEraseMode() { + // FIXME + //this.mediator.setEraseMode(); + this.erase = true; + } + + getEraseMode() { + var result = this.erase; + this.erase = false; + return result; + } + + /** + * Checks if a row is empty. + * + * @param row row number + * @return boolean stating wether the row is empty or not + */ + emptyRow( row) { + var index = GridModel.getFirstHintIndex(this.rowData[row]); + + return (index == GridModel.getLastHintIndex(this.rowData[row])) + && (this.rowData[row][index] == 0); + } + + /** + * Checks if a hint has been completed in a row. + * + * @param row row number to check + */ + checkRow( row) { + if (this.emptyRow(row)) { + this.completedHints.setCompleteRow(row); + return; + } + + // Contains the completed hints + var completedRowHints = []; + + var leftToRightHints = []; + + // If the first box is empty, skip left-to-right check + if (!this.boxes[0][row].isEmpty()) { + leftToRightHints = this.checkLeftToRight(row); + console.log("left-to-right for row #" + row + ": " + + leftToRightHints); + completedRowHints.push.apply(completedRowHints, leftToRightHints); + } + + var rightToLeftHints = []; + + // 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.push.apply(completedRowHints, rightToLeftHints); + } + + var rowHints = this.completedHints.getCompleteRowHints(row); + + //for (int hintIndex : rowHints) { + for (var i = 0; i < rowHints.length; i++) { + var hintIndex = rowHints[i]; + + if (!this.arrayContains(completedRowHints, hintIndex)) { + this.completedHints.clearRowHint(row, hintIndex); + } + } + + //for (int index : completedRowHints) { + for (var i = 0; i < completedRowHints.length; i++) { + var index = completedRowHints[i]; + this.completedHints.setCompleteRowHint(row, index); + } + + /**/ + var complete = true; + + for (var i = 0; i < this.rowData[row].length; i++) { + if (this.rowData[row][i] != GridModel.EMPTY_HINT && !this.arrayContains(completedRowHints, i)) { + complete = false; + } + } + + if (!complete) { + return; + } + /**/ + + //GridModel.log.debug("Row #" + row + " is complete"); + + // Let's compare number of checked boxes and the sum of all hints + var totalChecked = 0; + + for (var i = 0; i < this.boxes.length; i++) { + if (this.boxes[i][row].isChecked()) { + totalChecked++; + } + } + + /* + * 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; + } + + //GridModel.log.debug("totalChecked = " + totalChecked); + //GridModel.log.debug("rowHintsTotal[" + row + "] = " + // + this.rowHintsTotal[row]); + + var leftToRightSize = leftToRightHints.size(); + var 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) { + for (var i = 0; i < rightToLeftHints.length; i++) { + var hintIndex = rightToLeftHints[i]; + this.completedHints.clearRowHint(row, hintIndex); + } + } else { + //for (int hintIndex : leftToRightHints) { + for (var i = 0; i < leftToRightHints.length; i++) { + var hintIndex = leftToRightHints[i]; + this.completedHints.clearRowHint(row, hintIndex); + } + } + } //else { + //throw new RuntimeException("Confusion occured during " + // + "completed hints look-up"); + //} + } + + checkLeftToRight( row) { + var result = []; + + // Current hint we're looking to complete + var currentHintIndex = + GridModel.getFirstHintIndex(this.rowData[row]); + + var currentBox = 0; + + // Current chain of checked boxes + var 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.push(currentHintIndex); + currentChain = 0; + + currentHintIndex = + GridModel.getNextHintIndex(currentHintIndex + 1, + this.rowData[row]); + + if (currentHintIndex == GridModel.EMPTY_HINT) { + /* + * If this is the last hint, we verify that + * there aren't any extra checked boxes + */ + for (var 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; + } + } + + // 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) { + + result.push(currentHintIndex); + } + + return result; + } + + checkRightToLeft( row) { + var result = []; + + var currentHintIndex = GridModel.getLastHintIndex(this.rowData[row]); + var currentBox = this.boxes.length - 1; + var currentChain = 0; + + while (currentBox >= 0) { + if (this.boxes[currentBox][row].isChecked()) { + currentChain++; + } else { + if (this.rowData[row][currentHintIndex] == currentChain) { + result.push(currentHintIndex); + currentChain = 0; + + currentHintIndex = + GridModel.getPreviousHintIndex(currentHintIndex - 1, + this.rowData[row]); + + if (currentHintIndex == -1) { + for (var i = currentBox; i >= 0; i--) { + if (this.boxes[i][row].isChecked()) { + //result.clear(); + result = []; + } + } + + break; + } + } + + if (this.boxes[currentBox][row].isEmpty()) { + break; + } + } + + currentBox--; + } + + return result; + } + + /** + * Checks if a column is empty. + * + * @param col column number + * @return boolean stating wether the column is empty or not + */ + emptyCol( col) { + var index = GridModel.getFirstHintIndex(this.colData[col]); + + return (index == GridModel.getLastHintIndex(this.colData[col])) + && (this.colData[col][index] == 0); + } + + /** + * Checks if a hint has been completed in a column. + * + * @param column column number to check + */ + checkColumn( column) { + //GridModel.log.debug("checkColumn(" + column + ")"); + + if (this.emptyCol(column)) { + this.completedHints.setCompleteCol(column); + return; + } + + var completedColHints = [] + var topToBottomHints = []; + + if (!this.boxes[column][0].isEmpty()) { + topToBottomHints = this.checkTopToBottom(column); + + //completedColHints.addAll(topToBottomHints); + //for (var i = 0; i < topToBottomHints.length; i++) { + completedColHints.push.apply(completedColHints, topToBottomHints); + //} + } + + var bottomToTopHints = []; + + if (!this.boxes[column][this.boxes[0].length - 1].isEmpty()) { + bottomToTopHints = this.checkBottomToTop(column); + + //completedColHints.addAll(bottomToTopHints); + //for (var i = 0; i < bottomToTopHints.length; i++) { + completedColHints.push.apply(completedColHints, bottomToTopHints); + //} + } + + /**/ + var colHints = + this.completedHints.getCompleteColHints(column); + + //for (int hintIndex : colHints) { + for (var i = 0; i < colHints.length; i++) { + var hintIndex = colHints[i]; + + //if (!completedColHints.contains(hintIndex)) { + if (!this.arrayContains(completedColHints, hintIndex)) { + this.completedHints.clearColHint(column, hintIndex); + } + } + + //for (int index : completedColHints) { + for (var i = 0; i < completedColHints.length; i++) { + var index = completedColHints[i]; + this.completedHints.setCompleteColHint(column, index); + } + + /**/ + var complete = true; + + for (var i = 0; i < this.colData[column].length; i++) { + if (this.colData[column][i] != GridModel.EMPTY_HINT && !this.arrayContains(completedColHints, i)) { + complete = false; + } + } + + if (!complete) { + return; + } + /**/ + + var totalChecked = 0; + + for (var i = 0; i < this.boxes[column].length; i++) { + if (this.boxes[column][i].isChecked()) { + totalChecked++; + } + } + + if (totalChecked == this.colHintsTotal[column]) { + return; + } + + var topToBottomSize = topToBottomHints.size(); + var bottomToTopSize = bottomToTopHints.size(); + + if (topToBottomSize > 0 || bottomToTopSize > 0) { + if (topToBottomSize >= bottomToTopSize) { + //for (int hintIndex : bottomToTopHints) { + for (var i = 0; i < bottomToTopHints.length; i++) { + var hintIndex = bottomToTopHints[i]; + this.completedHints.clearColHint(column, hintIndex); + } + } else { + //for (int hintIndex : topToBottomHints) { + for (var i = 0; i < topToBottomHints.length; i++) { + var hintIndex = topToBottomHints[i]; + this.completedHints.clearColHint(column, hintIndex); + } + } + } /*else { + throw new RuntimeException("Confusion occured during " + + "completed hints look-up"); + }*/ + } + + + arrayContains(array, target) { + for (var j = 0; j < array.length; j++) { + if (array[j] == target) { + return true; + } + } + + return false; + } + + + checkTopToBottom( col) { + var result = []; + + var currentHintIndex = + GridModel.getLastHintIndex(this.colData[col]); + var currentBox = 0; + var currentChain = 0; + + while (currentBox < this.boxes[0].length) { + if (this.boxes[col][currentBox].isChecked()) { + currentChain++; + } else { + if (this.colData[col][currentHintIndex] == currentChain) { + result.push(currentHintIndex); + currentChain = 0; + + currentHintIndex = GridModel + .getPreviousHintIndex(currentHintIndex - 1, + this.colData[col]); + + if (currentHintIndex == GridModel.EMPTY_HINT) { + for (var i = currentBox; i < this.boxes[0].length; + i++) { + + if (this.boxes[col][i].isChecked()) { + //result.clear(); + result = []; + break; + } + } + + break; + } + } + + if (this.boxes[col][currentBox].isEmpty()) { + break; + } + } + + currentBox++; + } + + if (currentHintIndex != GridModel.EMPTY_HINT + && this.colData[col][currentHintIndex] == currentChain) { + + result.push(currentHintIndex); + } + + return result; + } + + checkBottomToTop( col) { + var result = []; + + var currentHintIndex = GridModel.getFirstHintIndex(this.colData[col]); + var currentBox = this.boxes[0].length - 1; + var currentChain = 0; + + while (currentBox >= 0) { + if (this.boxes[col][currentBox].isChecked()) { + currentChain++; + } else { + if (this.colData[col][currentHintIndex] == currentChain) { + result.push(currentHintIndex); + currentChain = 0; + + currentHintIndex = + GridModel.getNextHintIndex(currentHintIndex + 1, + this.colData[col]); + + if (currentHintIndex == GridModel.EMPTY_HINT) { + for (var i = currentBox; i >= 0; i--) { + if (this.boxes[col][i].isChecked()) { + //result.clear(); + result = []; + } + } + + break; + } + } + + if (this.boxes[col][currentBox].isEmpty()) { + break; + } + } + + currentBox--; + } + + return result; + } + + /** Checks wether the grid is finished. */ + checkCompleted() { + var completed = true; + + for (var i = 0; i < this.data.length; i++) { + for (var j = 0; j < this.data[i].length; j++) { + var isCurrentBoxChecked = this.boxes[i][j].isChecked(); + + if ((this.data[i][j] && !isCurrentBoxChecked) + || (!this.data[i][j] && isCurrentBoxChecked)) { + + completed = false; + break; + } + } + } + + //if (completed) { + // FIXME + //this.mediator.congratulations(); + //} + return completed; + } + + /** Indicates the current action has come to an end. */ + endAction() { + //this.lastChecked = null; + this.lastModified = null; + } + + /*** Accessors ***/ + + /** + * Returns the boxes. + * + * @return grid boxes + */ + getBoxes() { + return this.boxes; + } + + /** + * Returns the vertical hints. + * + * @return columns hints + */ + getColData() { + return this.colData; + } + + /** + * Returns the horizontal hints. + * + * @return rows hints + */ + getRowData() { + return this.rowData; + } + + /** + * Returns the completed hints. + * + * @return list of completed hints + */ + getCompletedHints() { + return this.completedHints; + } + + clearAll() { + //for (Box[] boxRow : this.boxes) { + // for (Box box : boxRow) { + for (var i = 0; i < this.boxes.length; i++) { + for (var j = 0; j < this.boxes[i].length; j++) { + this.actOnBox(j, i, GridAction.EMPTY); + } + } + } +}; + +GridModel.EMPTY_HINT = -1; Added: trunk/phaser/GridUI.js =================================================================== --- trunk/phaser/GridUI.js (rev 0) +++ trunk/phaser/GridUI.js 2020-03-14 09:39:37 UTC (rev 137) @@ -0,0 +1,708 @@ +/* Copyright Yvan Norsa (2007-2020) + * + * yva...@gm... + * + * This software is a computer program whose purpose is to [describe + * functionalities and technical features of your software]. + * + * 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 redist... [truncated message content] |