picross-commit Mailing List for picross (Page 3)
Status: Pre-Alpha
Brought to you by:
yvan_norsa
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(40) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
|
Feb
|
Mar
|
Apr
(30) |
May
(15) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(10) |
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(38) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
(1) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <yva...@us...> - 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-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-07 12:58:59
|
Revision: 89 http://picross.svn.sourceforge.net/picross/?rev=89&view=rev Author: yvan_norsa Date: 2011-06-07 12:58:50 +0000 (Tue, 07 Jun 2011) Log Message: ----------- wrong directory name Added Paths: ----------- branches/picross-web/ Removed Paths: ------------- branches/picross-trunk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2011-06-07 12:56:07
|
Revision: 88 http://picross.svn.sourceforge.net/picross/?rev=88&view=rev Author: yvan_norsa Date: 2011-06-07 12:55:58 +0000 (Tue, 07 Jun 2011) Log Message: ----------- creating a branch for web version Added Paths: ----------- branches/picross-trunk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-16 07:28:03
|
Revision: 87 http://picross.svn.sourceforge.net/picross/?rev=87&view=rev Author: yvan_norsa Date: 2008-05-16 00:28:03 -0700 (Fri, 16 May 2008) Log Message: ----------- clean-up, refactorisation Modified Paths: -------------- trunk/lib/mmvcs.jar trunk/src/picross/PicrossUI.java trunk/src/picross/app/PicrossAppUI.java trunk/src/picross/applet/PicrossApplet.java trunk/src/picross/game/GameController.java trunk/src/picross/game/GameMediator.java trunk/src/picross/game/GameUI.java trunk/src/picross/game/random/RandomGameMediator.java trunk/src/picross/game/random/RandomGameUI.java trunk/src/picross/grid/GridController.java trunk/src/picross/grid/GridMediator.java trunk/src/picross/grid/GridUI.java trunk/src/picross/grid/IGridMediator.java trunk/src/picross/grid/tests/IGridMediatorStub.java trunk/src/picross/menus/MenuUI.java Added Paths: ----------- trunk/src/picross/PicrossView.java trunk/src/picross/game/GameView.java trunk/src/picross/grid/GridView.java Modified: trunk/lib/mmvcs.jar =================================================================== (Binary files differ) Modified: trunk/src/picross/PicrossUI.java =================================================================== --- trunk/src/picross/PicrossUI.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/PicrossUI.java 2008-05-16 07:28:03 UTC (rev 87) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2008 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -33,8 +33,6 @@ package picross; -import javax.swing.JPanel; - /** * Main window. * @@ -46,7 +44,7 @@ * * @param content new content panel */ - void setContent(JPanel content); + void setContent(PicrossView content); /** * Displays a message box. Added: trunk/src/picross/PicrossView.java =================================================================== --- trunk/src/picross/PicrossView.java (rev 0) +++ trunk/src/picross/PicrossView.java 2008-05-16 07:28:03 UTC (rev 87) @@ -0,0 +1,58 @@ +/* + * $Id$ + * + * Copyright (c) 2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross; + +/** + * @author Y. Norsa + */ +public interface PicrossView { + /*** Constante ***/ + + /*** Champ statique ***/ + + /*** Champ ***/ + + /*** Constructeur ***/ + + /** + * Constructeur. + */ + /* + PicrossView() { + } + */ + + /*** M\xE9thode ***/ +} + Property changes on: trunk/src/picross/PicrossView.java ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/src/picross/app/PicrossAppUI.java =================================================================== --- trunk/src/picross/app/PicrossAppUI.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/app/PicrossAppUI.java 2008-05-16 07:28:03 UTC (rev 87) @@ -33,11 +33,13 @@ package picross.app; +import java.awt.Container; + import javax.swing.JFrame; import javax.swing.JOptionPane; -import javax.swing.JPanel; import picross.PicrossUI; +import picross.PicrossView; /** * Main window of the application version. @@ -67,8 +69,8 @@ /** {@inheritDoc} */ @Override - public void setContent(JPanel content) { - this.setContentPane(content); + public void setContent(PicrossView content) { + this.setContentPane((Container) content); this.pack(); } Modified: trunk/src/picross/applet/PicrossApplet.java =================================================================== --- trunk/src/picross/applet/PicrossApplet.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/applet/PicrossApplet.java 2008-05-16 07:28:03 UTC (rev 87) @@ -33,13 +33,15 @@ package picross.applet; +import java.awt.Container; + import javax.swing.JApplet; import javax.swing.JOptionPane; -import javax.swing.JPanel; import javax.swing.SwingUtilities; import picross.PicrossMediator; import picross.PicrossUI; +import picross.PicrossView; /** * Main class of the applet version. @@ -91,8 +93,8 @@ /** {@inheritDoc} */ @Override - public void setContent(JPanel content) { - this.setContentPane(content); + public void setContent(PicrossView content) { + this.setContentPane((Container) content); this.validate(); } Modified: trunk/src/picross/game/GameController.java =================================================================== --- trunk/src/picross/game/GameController.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/game/GameController.java 2008-05-16 07:28:03 UTC (rev 87) @@ -71,7 +71,6 @@ if (cmd.equals(PicrossController.QUIT_CMD)) { this.fireEventPerformed(cmd); - return; } } Modified: trunk/src/picross/game/GameMediator.java =================================================================== --- trunk/src/picross/game/GameMediator.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/game/GameMediator.java 2008-05-16 07:28:03 UTC (rev 87) @@ -38,7 +38,6 @@ import java.awt.event.ActionListener; -import javax.swing.JPanel; import javax.swing.SwingUtilities; //import org.apache.log4j.Logger; @@ -47,6 +46,8 @@ import picross.PicrossGrid; import picross.grid.GridMediator; +import picross.grid.GridView; +import picross.grid.IGridMediator; /** * Handles a game. @@ -59,11 +60,14 @@ /** The class' logger. */ //private static Logger log = Logger.getLogger(GameMediator.class); - /*** Field ***/ + /*** Fields ***/ /** The game view. */ private GameUI view; + /** The game grid. */ + private IGridMediator grid; + /*** Abstrac method ***/ /** @@ -98,9 +102,9 @@ final int width = model.getWidth(); final int height = model.getHeight(); - final GridMediator grid = new GridMediator(width, height, + this.grid = new GridMediator(width, height, model.getData()); - grid.addSimpleListener(this); + this.grid.addSimpleListener(this); final GameController controller = this.initController(); controller.addSimpleListener(this); @@ -109,9 +113,10 @@ SwingUtilities.invokeLater(new Runnable() { public void run() { GameMediator.this.view = - GameMediator.this.initView(width, height, - grid.getView(), - controller); + GameMediator.this + .initView(width, height, + GameMediator.this.grid.getView(), + controller); } }); } @@ -125,7 +130,7 @@ * @param controller controller for the grid buttons * @return view containing the grid */ - protected GameUI initView(int width, int height, JPanel gridView, + protected GameUI initView(int width, int height, GridView gridView, ActionListener controller) { return new GameUI(width, height, gridView, controller); } @@ -144,7 +149,7 @@ * * @return the view */ - public final JPanel getView() { + public final GameView getView() { return this.view; } } Modified: trunk/src/picross/game/GameUI.java =================================================================== --- trunk/src/picross/game/GameUI.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/game/GameUI.java 2008-05-16 07:28:03 UTC (rev 87) @@ -37,6 +37,7 @@ import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Component; import java.awt.FlowLayout; import java.awt.event.ActionListener; @@ -49,12 +50,14 @@ import picross.PicrossController; +import picross.grid.GridView; + /** * The game UI. * * @author Y. Norsa */ -public class GameUI extends JPanel { +public class GameUI extends JPanel implements GameView { /*** Constant ***/ /** Serialisation ID. */ @@ -75,7 +78,8 @@ * @param grid the grid * @param listener listener for the buttons */ - public GameUI(int width, int height, JPanel grid, + //public GameUI(int width, int height, JPanel grid, + public GameUI(int width, int height, GridView grid, ActionListener listener) { super(); @@ -115,7 +119,7 @@ topPanel.add(contentPanel, BorderLayout.LINE_START); this.add(topPanel, BorderLayout.PAGE_START); - this.add(grid, BorderLayout.CENTER); + this.add((Component) grid, BorderLayout.CENTER); } /*** Method ***/ Added: trunk/src/picross/game/GameView.java =================================================================== --- trunk/src/picross/game/GameView.java (rev 0) +++ trunk/src/picross/game/GameView.java 2008-05-16 07:28:03 UTC (rev 87) @@ -0,0 +1,60 @@ +/* + * $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 picross.PicrossView; + +/** + * @author Y. Norsa + */ +public interface GameView extends PicrossView { + /*** Constante ***/ + + /*** Champ statique ***/ + + /*** Champ ***/ + + /*** Constructeur ***/ + + /** + * Constructeur. + */ + /* + GameView() { + } + */ + + /*** M\xE9thode ***/ +} + Property changes on: trunk/src/picross/game/GameView.java ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/src/picross/game/random/RandomGameMediator.java =================================================================== --- trunk/src/picross/game/random/RandomGameMediator.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/game/random/RandomGameMediator.java 2008-05-16 07:28:03 UTC (rev 87) @@ -37,8 +37,6 @@ import java.awt.event.ActionListener; -import javax.swing.JPanel; - //import org.apache.log4j.Logger; import picross.PicrossGrid; @@ -47,6 +45,8 @@ import picross.game.GameMediator; import picross.game.GameUI; +import picross.grid.GridView; + /** * This object handles a random grid game. * @@ -62,7 +62,7 @@ /** {@inheritDoc} */ @Override - protected GameUI initView(int width, int height, JPanel gridView, + protected GameUI initView(int width, int height, GridView gridView, ActionListener controller) { return new RandomGameUI(width, height, gridView, controller); @@ -71,10 +71,7 @@ /** {@inheritDoc} */ @Override protected GameController initController() { - RandomGameController controller = new RandomGameController(); - controller.addSimpleListener(this); - - return controller; + return new RandomGameController(); } /** {@inheritDoc} */ Modified: trunk/src/picross/game/random/RandomGameUI.java =================================================================== --- trunk/src/picross/game/random/RandomGameUI.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/game/random/RandomGameUI.java 2008-05-16 07:28:03 UTC (rev 87) @@ -38,10 +38,11 @@ import java.awt.event.ActionListener; import javax.swing.JButton; -import javax.swing.JPanel; import picross.game.GameUI; +import picross.grid.GridView; + /** * Custom UI for a random game. * @@ -63,7 +64,7 @@ * @param grid the grid * @param controller the UI controller */ - RandomGameUI(int width, int height, JPanel grid, + RandomGameUI(int width, int height, GridView grid, ActionListener controller) { super(width, height, grid, controller); Modified: trunk/src/picross/grid/GridController.java =================================================================== --- trunk/src/picross/grid/GridController.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/grid/GridController.java 2008-05-16 07:28:03 UTC (rev 87) @@ -117,12 +117,14 @@ if (cmd.equals(GridController.REPAINT_TOP_HINTS_CMD)) { int col = ((RepaintTopHintsCommand) e.getCommand()).getColumn(); this.view.repaintColHints(col); + return; } if (cmd.equals(GridController.REPAINT_LEFT_HINTS_CMD)) { int row = ((RepaintLeftHintsCommand) e.getCommand()).getRow(); this.view.repaintRowHints(row); + return; } Modified: trunk/src/picross/grid/GridMediator.java =================================================================== --- trunk/src/picross/grid/GridMediator.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/grid/GridMediator.java 2008-05-16 07:28:03 UTC (rev 87) @@ -40,7 +40,6 @@ import java.lang.reflect.InvocationTargetException; -import javax.swing.JPanel; import javax.swing.SwingUtilities; //import org.apache.log4j.Logger; @@ -157,15 +156,13 @@ /** {@inheritDoc} */ @Override public void repaintColHints(int column) { - this.fireEventPerformed(//GridController.REPAINT_TOP_HINTS_CMD); - new RepaintTopHintsCommand(column)); + this.fireEventPerformed(new RepaintTopHintsCommand(column)); } /** {@inheritDoc} */ @Override public void repaintRowHints(int row) { - this.fireEventPerformed(//GridController.REPAINT_LEFT_HINTS_CMD); - new RepaintLeftHintsCommand(row)); + this.fireEventPerformed(new RepaintLeftHintsCommand(row)); } /** {@inheritDoc} */ @@ -181,7 +178,7 @@ * * @return the grid view */ - public JPanel getView() { + public GridView getView() { return this.view; } } Modified: trunk/src/picross/grid/GridUI.java =================================================================== --- trunk/src/picross/grid/GridUI.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/grid/GridUI.java 2008-05-16 07:28:03 UTC (rev 87) @@ -65,7 +65,7 @@ * * @author Y. Norsa */ -final class GridUI extends JPanel { +final class GridUI extends JPanel implements GridView { /*** Constants ***/ /** Serialisation ID. */ Added: trunk/src/picross/grid/GridView.java =================================================================== --- trunk/src/picross/grid/GridView.java (rev 0) +++ trunk/src/picross/grid/GridView.java 2008-05-16 07:28:03 UTC (rev 87) @@ -0,0 +1,41 @@ +/* + * $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.grid; + +/** + * @author Y. Norsa + */ +public interface GridView { } + + Property changes on: trunk/src/picross/grid/GridView.java ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/src/picross/grid/IGridMediator.java =================================================================== --- trunk/src/picross/grid/IGridMediator.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/grid/IGridMediator.java 2008-05-16 07:28:03 UTC (rev 87) @@ -33,10 +33,14 @@ package picross.grid; +import fr.cle.mmvcs.IMediateur; + /** + * Mediator for the grid. + * * @author Y. Norsa */ -public interface IGridMediator { +public interface IGridMediator extends IMediateur { /** * Asks to repaint a box. * @@ -56,5 +60,12 @@ /** Enables the erase mode. */ void setEraseMode(); + + /** + * Returns the grid view. + * + * @return view of the grid + */ + GridView getView(); } Modified: trunk/src/picross/grid/tests/IGridMediatorStub.java =================================================================== --- trunk/src/picross/grid/tests/IGridMediatorStub.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/grid/tests/IGridMediatorStub.java 2008-05-16 07:28:03 UTC (rev 87) @@ -33,6 +33,10 @@ package picross.grid.tests; +import fr.cle.mmvcs.SimpleEvent; +import fr.cle.mmvcs.SimpleListener; + +import picross.grid.GridView; import picross.grid.IGridMediator; /** @@ -66,5 +70,16 @@ 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) { } } Modified: trunk/src/picross/menus/MenuUI.java =================================================================== --- trunk/src/picross/menus/MenuUI.java 2008-05-14 12:50:47 UTC (rev 86) +++ trunk/src/picross/menus/MenuUI.java 2008-05-16 07:28:03 UTC (rev 87) @@ -54,13 +54,14 @@ import picross.MissingImageException; import picross.Picross; +import picross.PicrossView; /** * Base class for menus. * * @author Y. Norsa */ -public abstract class MenuUI extends JPanel { +public abstract class MenuUI extends JPanel implements PicrossView { /*** Constants ***/ /** Background image. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-14 12:50:40
|
Revision: 86 http://picross.svn.sourceforge.net/picross/?rev=86&view=rev Author: yvan_norsa Date: 2008-05-14 05:50:47 -0700 (Wed, 14 May 2008) Log Message: ----------- support for more XBM files Modified Paths: -------------- trunk/data/contents.txt trunk/src/picross/game/simple/XBMModel.java Added Paths: ----------- trunk/data/bitrabbit.xbm Added: trunk/data/bitrabbit.xbm =================================================================== --- trunk/data/bitrabbit.xbm (rev 0) +++ trunk/data/bitrabbit.xbm 2008-05-14 12:50:47 UTC (rev 86) @@ -0,0 +1,7 @@ +#define bitrabbit_width 19 +#define bitrabbit_height 14 +static unsigned char bitrabbit_bits[] = { + 0x60, 0x00, 0x00, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, + 0xe0, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xfe, 0x78, 0x00, 0xf7, 0xfe, 0x00, + 0xff, 0xff, 0x02, 0xfe, 0xff, 0x07, 0xf8, 0xff, 0x07, 0xf8, 0xff, 0x07, + 0xfe, 0xff, 0x07, 0xff, 0xff, 0x03 }; Modified: trunk/data/contents.txt =================================================================== --- trunk/data/contents.txt 2008-05-14 08:55:22 UTC (rev 85) +++ trunk/data/contents.txt 2008-05-14 12:50:47 UTC (rev 86) @@ -2,6 +2,7 @@ asterix.xbm : 16x16 audio.xbm : 32x32 batman2.xbm : 32x32 +bitrabbit.xbm : 19x14 bunny.xbm : 16x16 halloween.xbm : 16x16 squares.xbm : 16x16 Modified: trunk/src/picross/game/simple/XBMModel.java =================================================================== --- trunk/src/picross/game/simple/XBMModel.java 2008-05-14 08:55:22 UTC (rev 85) +++ trunk/src/picross/game/simple/XBMModel.java 2008-05-14 12:50:47 UTC (rev 86) @@ -199,9 +199,8 @@ for (String byteStr : byteValues) { String binaryStr = XBMModel.toBits(byteStr); + //XBMModel.log.debug("binaryStr : " + binaryStr); - //XBMModel.log.debug(binaryStr); - for (int j = XBMModel.BYTE_LENGTH - 1; j >= 0; j--) { //XBMModel.log.debug("this.data[" + yIndex //+ "][" + xIndex + "] = " @@ -214,11 +213,16 @@ if (yIndex == this.width) { xIndex++; yIndex = 0; + + break; } + // Useless ? + /* if (xIndex == this.height) { xIndex = 0; } + */ } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-14 08:55:21
|
Revision: 85 http://picross.svn.sourceforge.net/picross/?rev=85&view=rev Author: yvan_norsa Date: 2008-05-14 01:55:22 -0700 (Wed, 14 May 2008) Log Message: ----------- minor clean-up Modified Paths: -------------- trunk/src/picross/game/random/RandomGameController.java Modified: trunk/src/picross/game/random/RandomGameController.java =================================================================== --- trunk/src/picross/game/random/RandomGameController.java 2008-05-14 08:55:01 UTC (rev 84) +++ trunk/src/picross/game/random/RandomGameController.java 2008-05-14 08:55:22 UTC (rev 85) @@ -51,10 +51,8 @@ static final String NEXT_CMD = "NEXT_CMD"; /** Random game command. */ - /*public */static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD"; + static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD"; - //public static final String NEXT_RANDOM_GAME_CMD = "NEXT_RANDOM_GAME_CMD"; - /*** Static field ***/ /** The class' logger. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-14 08:54:56
|
Revision: 84 http://picross.svn.sourceforge.net/picross/?rev=84&view=rev Author: yvan_norsa Date: 2008-05-14 01:55:01 -0700 (Wed, 14 May 2008) Log Message: ----------- added an in-game 'back to menu' button Modified Paths: -------------- trunk/src/picross/PicrossController.java trunk/src/picross/PicrossMediator.java trunk/src/picross/game/GameMediator.java trunk/src/picross/game/GameUI.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/properties/messages_picross.properties trunk/src/picross/properties/messages_picross_fr.properties Added Paths: ----------- trunk/src/picross/game/GameController.java Modified: trunk/src/picross/PicrossController.java =================================================================== --- trunk/src/picross/PicrossController.java 2008-05-14 07:32:12 UTC (rev 83) +++ trunk/src/picross/PicrossController.java 2008-05-14 08:55:01 UTC (rev 84) @@ -36,7 +36,7 @@ import fr.cle.mmvcs.Controller; import fr.cle.mmvcs.SimpleEvent; -import org.apache.log4j.Logger; +//import org.apache.log4j.Logger; /** * Application controller. @@ -55,10 +55,13 @@ /** 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); + //private static Logger log = Logger.getLogger(PicrossController.class); /*** Field ***/ @@ -70,7 +73,7 @@ /** {@inheritDoc} */ @Override public void eventPerformed(SimpleEvent e) { - PicrossController.log.debug("eventPerformed(" + e + ")"); + //PicrossController.log.debug("eventPerformed(" + e + ")"); String cmd = e.getCommandName(); Modified: trunk/src/picross/PicrossMediator.java =================================================================== --- trunk/src/picross/PicrossMediator.java 2008-05-14 07:32:12 UTC (rev 83) +++ trunk/src/picross/PicrossMediator.java 2008-05-14 08:55:01 UTC (rev 84) @@ -137,6 +137,11 @@ BundleHelper.getString(this, "victory")); return; } + + if (cmd.equals(PicrossController.QUIT_CMD)) { + this.displayGameMenu(); + return; + } } /*** Methods ***/ Added: trunk/src/picross/game/GameController.java =================================================================== --- trunk/src/picross/game/GameController.java (rev 0) +++ trunk/src/picross/game/GameController.java 2008-05-14 08:55:01 UTC (rev 84) @@ -0,0 +1,79 @@ +/* + * $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; + } + } +} + Property changes on: trunk/src/picross/game/GameController.java ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/src/picross/game/GameMediator.java =================================================================== --- trunk/src/picross/game/GameMediator.java 2008-05-14 07:32:12 UTC (rev 83) +++ trunk/src/picross/game/GameMediator.java 2008-05-14 08:55:01 UTC (rev 84) @@ -36,6 +36,8 @@ import fr.cle.mmvcs.Mediateur; import fr.cle.mmvcs.SimpleEvent; +import java.awt.event.ActionListener; + import javax.swing.JPanel; import javax.swing.SwingUtilities; @@ -62,21 +64,9 @@ /** The game view. */ private GameUI view; - /*** Abstract methods ***/ + /*** Abstrac method ***/ /** - * Creates the view. - * - * @param width the grid width - * @param height the grid height - * @param gridView the grid itself - * @return view containing the grid - */ - protected GameUI initView(int width, int height, JPanel gridView) { - return new GameUI(width, height, gridView); - } - - /** * Creates the model. * * @return grid model @@ -112,17 +102,44 @@ model.getData()); 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, - grid.getView()); + 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, JPanel 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 Modified: trunk/src/picross/game/GameUI.java =================================================================== --- trunk/src/picross/game/GameUI.java 2008-05-14 07:32:12 UTC (rev 83) +++ trunk/src/picross/game/GameUI.java 2008-05-14 08:55:01 UTC (rev 84) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2008 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -37,11 +37,18 @@ import java.awt.BorderLayout; import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.event.ActionListener; + import javax.swing.BoxLayout; +import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JSeparator; +import picross.PicrossController; + /** * The game UI. * @@ -55,8 +62,8 @@ /*** Field ***/ - /** Displays informations about the current game. */ - protected JPanel infosPanel; + /** Panel holding the buttons. */ + private JPanel buttonsPanel; /*** Constructor ***/ @@ -66,23 +73,59 @@ * @param width the grid width * @param height the grid height * @param grid the grid + * @param listener listener for the buttons */ - public GameUI(int width, int height, JPanel grid) { + public GameUI(int width, int height, JPanel grid, + ActionListener listener) { super(); this.setLayout(new BorderLayout()); - this.infosPanel = new JPanel(); - this.infosPanel.setBackground(Color.WHITE); - this.infosPanel.setLayout(new BoxLayout(this.infosPanel, - BoxLayout.Y_AXIS)); + JPanel topPanel = new JPanel(new BorderLayout()); + topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS)); + JPanel contentPanel = new JPanel(); + contentPanel.setLayout(new BoxLayout(contentPanel, + BoxLayout.Y_AXIS)); + + JPanel infosPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + infosPanel.setBackground(Color.WHITE); + JLabel infos = new JLabel(BundleHelper.getString(this, "gridSize") + " : " + width + "*" + height); - this.infosPanel.add(infos); - this.add(this.infosPanel, BorderLayout.NORTH); + infosPanel.add(infos); + + topPanel.add(infosPanel); + topPanel.add(new JSeparator()); + + this.buttonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + this.buttonsPanel.setBackground(Color.WHITE); + + JButton menuButton = new JButton(BundleHelper.getString(this, + "menuButton")); + menuButton.addActionListener(listener); + menuButton.setActionCommand(PicrossController.QUIT_CMD); + this.buttonsPanel.add(menuButton); + + topPanel.add(this.buttonsPanel); + topPanel.add(new JSeparator()); + + topPanel.add(contentPanel, BorderLayout.LINE_START); + + this.add(topPanel, BorderLayout.PAGE_START); this.add(grid, BorderLayout.CENTER); } + + /*** Method ***/ + + /** + * Helper method to add a button. + * + * @param button the button to add + */ + protected void addButton(JButton button) { + this.buttonsPanel.add(button); + } } Modified: trunk/src/picross/game/random/RandomGameController.java =================================================================== --- trunk/src/picross/game/random/RandomGameController.java 2008-05-14 07:32:12 UTC (rev 83) +++ trunk/src/picross/game/random/RandomGameController.java 2008-05-14 08:55:01 UTC (rev 84) @@ -33,20 +33,18 @@ package picross.game.random; -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 org.apache.log4j.Logger; +import picross.game.GameController; + /** * Controller for the random game UI. * * @author Y. Norsa */ -final class RandomGameController extends Controller implements ActionListener { +final class RandomGameController extends GameController { /*** Constant ***/ /** Command asking to create another grid. */ @@ -60,20 +58,12 @@ /*** Static field ***/ /** The class' logger. */ - private static Logger log = Logger.getLogger(RandomGameController.class); + //private static Logger log = Logger.getLogger(RandomGameController.class); /*** Method overloaded from the class Controller ***/ /** {@inheritDoc} */ @Override - public void eventPerformed(SimpleEvent e) { - RandomGameController.log.debug("eventPerformed(" + e + ")"); - } - - /*** Method implanted from the interface ActionListener ***/ - - /** {@inheritDoc} */ - @Override public void actionPerformed(ActionEvent e) { //RandomGameController.log.debug("actionPerformed(" + e + ")"); @@ -81,6 +71,10 @@ if (cmd.equals(RandomGameController.NEXT_CMD)) { this.fireEventPerformed(cmd); + + return; } + + super.actionPerformed(e); } } Modified: trunk/src/picross/game/random/RandomGameMediator.java =================================================================== --- trunk/src/picross/game/random/RandomGameMediator.java 2008-05-14 07:32:12 UTC (rev 83) +++ trunk/src/picross/game/random/RandomGameMediator.java 2008-05-14 08:55:01 UTC (rev 84) @@ -35,12 +35,15 @@ import fr.cle.mmvcs.SimpleEvent; +import java.awt.event.ActionListener; + import javax.swing.JPanel; //import org.apache.log4j.Logger; import picross.PicrossGrid; +import picross.game.GameController; import picross.game.GameMediator; import picross.game.GameUI; @@ -59,12 +62,19 @@ /** {@inheritDoc} */ @Override - protected GameUI initView(int width, int height, JPanel gridView) { + protected GameUI initView(int width, int height, JPanel gridView, + ActionListener controller) { + return new RandomGameUI(width, height, gridView, + controller); + } + + /** {@inheritDoc} */ + @Override + protected GameController initController() { RandomGameController controller = new RandomGameController(); controller.addSimpleListener(this); - return new RandomGameUI(width, height, gridView, - controller); + return controller; } /** {@inheritDoc} */ Modified: trunk/src/picross/game/random/RandomGameUI.java =================================================================== --- trunk/src/picross/game/random/RandomGameUI.java 2008-05-14 07:32:12 UTC (rev 83) +++ trunk/src/picross/game/random/RandomGameUI.java 2008-05-14 08:55:01 UTC (rev 84) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2008 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -43,7 +43,7 @@ import picross.game.GameUI; /** - * UI modifications for a random game. + * Custom UI for a random game. * * @author Y. Norsa */ @@ -65,16 +65,13 @@ */ RandomGameUI(int width, int height, JPanel grid, ActionListener controller) { - super(width, height, grid); + super(width, height, grid, controller); JButton nextButton = new JButton(BundleHelper.getString(this, "anotherGrid")); nextButton.addActionListener(controller); nextButton.setActionCommand(RandomGameController.NEXT_CMD); - this.infosPanel.add(nextButton); - - // FIXME this should not be here - this.infosPanel.add(new javax.swing.JSeparator()); + this.addButton(nextButton); } } Modified: trunk/src/picross/properties/messages_picross.properties =================================================================== --- trunk/src/picross/properties/messages_picross.properties 2008-05-14 07:32:12 UTC (rev 83) +++ trunk/src/picross/properties/messages_picross.properties 2008-05-14 08:55:01 UTC (rev 84) @@ -3,6 +3,7 @@ # picross.game.GameUI gridSize = Size +menuButton = Back to menu # picross.game.random.RandomGameUI anotherGrid = Another grid Modified: trunk/src/picross/properties/messages_picross_fr.properties =================================================================== --- trunk/src/picross/properties/messages_picross_fr.properties 2008-05-14 07:32:12 UTC (rev 83) +++ trunk/src/picross/properties/messages_picross_fr.properties 2008-05-14 08:55:01 UTC (rev 84) @@ -3,6 +3,7 @@ # picross.game.GameUI gridSize = Taille +menuButton = Retour au menu # picross.game.random.RandomGameUI anotherGrid = Une autre grille This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-14 07:32:05
|
Revision: 83 http://picross.svn.sourceforge.net/picross/?rev=83&view=rev Author: yvan_norsa Date: 2008-05-14 00:32:12 -0700 (Wed, 14 May 2008) Log Message: ----------- trying to fix crossed-rollover.png image Added Paths: ----------- trunk/images/crossed-rollover.png Added: trunk/images/crossed-rollover.png =================================================================== (Binary files differ) Property changes on: trunk/images/crossed-rollover.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-14 07:31:52
|
Revision: 82 http://picross.svn.sourceforge.net/picross/?rev=82&view=rev Author: yvan_norsa Date: 2008-05-14 00:31:58 -0700 (Wed, 14 May 2008) Log Message: ----------- trying to fix crossed-rollover.png image Removed Paths: ------------- trunk/images/crossed-rollover.png Deleted: trunk/images/crossed-rollover.png =================================================================== --- trunk/images/crossed-rollover.png 2008-05-09 13:49:56 UTC (rev 81) +++ trunk/images/crossed-rollover.png 2008-05-14 07:31:58 UTC (rev 82) @@ -1,11 +0,0 @@ -\x89PNG - - |
From: <yva...@us...> - 2008-05-09 13:49:57
|
Revision: 81 http://picross.svn.sourceforge.net/picross/?rev=81&view=rev Author: yvan_norsa Date: 2008-05-09 06:49:56 -0700 (Fri, 09 May 2008) Log Message: ----------- fixed crossed-rollover.png file for platforms without symbolic links support Modified Paths: -------------- trunk/images/crossed-rollover.png Modified: trunk/images/crossed-rollover.png =================================================================== --- trunk/images/crossed-rollover.png 2008-05-07 13:37:14 UTC (rev 80) +++ trunk/images/crossed-rollover.png 2008-05-09 13:49:56 UTC (rev 81) @@ -1 +1,11 @@ -link crossed.png \ No newline at end of file +\x89PNG + + |
From: <yva...@us...> - 2008-05-07 13:37:14
|
Revision: 80 http://picross.svn.sourceforge.net/picross/?rev=80&view=rev Author: yvan_norsa Date: 2008-05-07 06:37:14 -0700 (Wed, 07 May 2008) Log Message: ----------- disable highlights on success Modified Paths: -------------- trunk/src/picross/grid/GridController.java trunk/src/picross/grid/GridUI.java Modified: trunk/src/picross/grid/GridController.java =================================================================== --- trunk/src/picross/grid/GridController.java 2008-05-07 09:47:16 UTC (rev 79) +++ trunk/src/picross/grid/GridController.java 2008-05-07 13:37:14 UTC (rev 80) @@ -101,7 +101,9 @@ String cmd = e.getCommandName(); if (cmd.equals(GridController.GRID_FILLED_CMD)) { + this.view.rolloverEnded(); this.view.disableGrid(); + return; } @@ -223,10 +225,10 @@ //GridController.log.debug("type : " + type); + this.view.rolloverHighlight(row, column); + this.fireEventPerformed(GridController.FILL_CMD, new FillCommand(row, column, type)); - - this.view.rolloverHighlight(row, column); } else { this.view.highlightEnded(); } Modified: trunk/src/picross/grid/GridUI.java =================================================================== --- trunk/src/picross/grid/GridUI.java 2008-05-07 09:47:16 UTC (rev 79) +++ trunk/src/picross/grid/GridUI.java 2008-05-07 13:37:14 UTC (rev 80) @@ -523,6 +523,7 @@ */ private void drawTopHints(Graphics g, int col) { //GridUI.log.debug("drawTopHints(g, " + col + ")"); + //GridUI.log.debug("this.rolloverColumn = " + this.rolloverColumn); g.drawImage(this.topHints[col].getBox(), this.topHints[col].getX(), this.topHints[col].getY(), @@ -550,6 +551,9 @@ * @param g the graphics context */ private void drawLeftHints(Graphics g, int row) { + //GridUI.log.debug("drawLeftHints(g, " + row + ")"); + //GridUI.log.debug("this.rolloverRow = " + this.rolloverRow); + g.drawImage(this.leftHints[row].getBox(), this.leftHints[row].getX(), this.leftHints[row].getY(), null); @@ -685,6 +689,8 @@ * @param column column's index to highlight */ void rolloverHighlight(int row, int column) { + //GridUI.log.debug("rolloverHighlight(" + row + ", " + column + ")"); + if ((this.rolloverColumn != column) || (this.rolloverRow != row)) { this.repaintColHints(this.rolloverColumn); this.repaintRowHints(this.rolloverRow); @@ -715,6 +721,8 @@ /** Ends the highlight. */ void highlightEnded() { + //GridUI.log.debug("highlightEnded"); + this.repaintColHints(this.rolloverColumn); this.repaintRowHints(this.rolloverRow); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-07 09:47:13
|
Revision: 79 http://picross.svn.sourceforge.net/picross/?rev=79&view=rev Author: yvan_norsa Date: 2008-05-07 02:47:16 -0700 (Wed, 07 May 2008) Log Message: ----------- buttons alignment Modified Paths: -------------- trunk/src/picross/menus/GameMenuUI.java Modified: trunk/src/picross/menus/GameMenuUI.java =================================================================== --- trunk/src/picross/menus/GameMenuUI.java 2008-05-07 09:34:52 UTC (rev 78) +++ trunk/src/picross/menus/GameMenuUI.java 2008-05-07 09:47:16 UTC (rev 79) @@ -67,7 +67,7 @@ super(); int x = 150; - int y = 175; + int y = 150; GameMenuUI.log.debug("listing des modes..."); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-07 09:34:48
|
Revision: 78 http://picross.svn.sourceforge.net/picross/?rev=78&view=rev Author: yvan_norsa Date: 2008-05-07 02:34:52 -0700 (Wed, 07 May 2008) Log Message: ----------- 'back button'; scroll for level selection Modified Paths: -------------- trunk/src/picross/game/simple/LevelMenuController.java trunk/src/picross/game/simple/LevelMenuMediator.java trunk/src/picross/game/simple/LevelMenuUI.java trunk/src/picross/menus/MenuController.java trunk/src/picross/menus/MenuUI.java Added Paths: ----------- trunk/images/en/button-back.png trunk/images/fr/button-back.png trunk/src/picross/game/simple/SizesListCommand.java Added: trunk/images/en/button-back.png =================================================================== (Binary files differ) Property changes on: trunk/images/en/button-back.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/images/fr/button-back.png =================================================================== (Binary files differ) Property changes on: trunk/images/fr/button-back.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/src/picross/game/simple/LevelMenuController.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuController.java 2008-05-05 09:34:00 UTC (rev 77) +++ trunk/src/picross/game/simple/LevelMenuController.java 2008-05-07 09:34:52 UTC (rev 78) @@ -37,6 +37,10 @@ import org.apache.log4j.Logger; +import picross.PicrossController; + +import picross.game.GameCommand; + import picross.menus.MenuController; /** @@ -70,10 +74,14 @@ String cmd = e.getCommandName(); - if (cmd.equals(picross.game.GameCommand.GAME_CMD)) { + if (cmd.equals(GameCommand.GAME_CMD)) { return; } + if (cmd.equals(PicrossController.PLAY_CMD)) { + return; + } + if (cmd.equals(LevelMenuController.LEVELS_LIST_CMD)) { LevelsListCommand command = (LevelsListCommand) e.getCommand(); ((LevelMenuUI) this.getView()).displayLevels(this, @@ -82,6 +90,14 @@ return; } + if (cmd.equals(SizesListCommand.SIZES_CMD)) { + SizesListCommand command = (SizesListCommand) e.getCommand(); + ((LevelMenuUI) this.getView()).displaySizes(this, + command.getSizes()); + + return; + } + super.eventPerformed(e); } } Modified: trunk/src/picross/game/simple/LevelMenuMediator.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuMediator.java 2008-05-05 09:34:00 UTC (rev 77) +++ trunk/src/picross/game/simple/LevelMenuMediator.java 2008-05-07 09:34:52 UTC (rev 78) @@ -114,6 +114,12 @@ return; } + if (cmd.equals(MenuController.BACK_CMD)) { + this.fireEventPerformed(new SizesListCommand(this.model + .getSizesList())); + return; + } + super.eventPerformed(e); } Modified: trunk/src/picross/game/simple/LevelMenuUI.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuUI.java 2008-05-05 09:34:00 UTC (rev 77) +++ trunk/src/picross/game/simple/LevelMenuUI.java 2008-05-07 09:34:52 UTC (rev 78) @@ -34,12 +34,25 @@ package picross.game.simple; import fr.cle.mmvcs.SimpleEvent; -import fr.cle.mmvcs.SimpleListener; import java.awt.Dimension; +import java.awt.event.ActionListener; + import java.util.List; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JScrollPane; + +import picross.Picross; + +import picross.PicrossController; + +import picross.menus.MenuController; import picross.menus.MenuUI; /** @@ -61,9 +74,23 @@ * @param listener listener for the buttons * @param sizes available grid sizes */ - LevelMenuUI(SimpleListener listener, List<Dimension> sizes) { + LevelMenuUI(MenuController listener, List<Dimension> sizes) { super(); + this.displaySizes(listener, sizes); + } + + /*** Method ***/ + + /** + * Displays the available level sizes. + * + * @param listener listener for the buttons + * @param sizes grid sizes + */ + void displaySizes(MenuController listener, List<Dimension> sizes) { + this.removeAll(); + int x = 150; int y = 150; @@ -82,36 +109,76 @@ y = 150; } } + + this.addBackButton(listener, PicrossController.PLAY_CMD); + + this.repaint(); } - /*** Method ***/ - /** * Displays the levels list. * * @param listener listener for the buttons * @param levels levels to display */ - void displayLevels(SimpleListener listener, List<String> levels) { + void displayLevels(MenuController listener, List<String> levels) { this.removeAll(); - int x = 50; - int y = 150; - for (String level : levels) { + JPanel panel = new JPanel(); + panel.setOpaque(false); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + + int nbLevels = levels.size(); + + for (int i = 0; i < nbLevels; i++) { + String level = levels.get(i); + SimpleEvent event = new SimpleEvent(LevelMenuController.LEVEL_CMD, level); - this.addSimpleButton(level, event, listener, x, y); - y += 75; + panel.add(this.createSimpleButton(level, event, listener) + .getButton()); - if (y == 375) { - x = 250; - y = 150; + if (i != (nbLevels - 1)) { + panel.add(Box.createRigidArea(new Dimension(0, 20))); } } + JScrollPane scrollPane = new JScrollPane(panel); + scrollPane.setOpaque(false); + scrollPane.setBorder(null); + scrollPane.setBounds(150, 120, 294, 200); + + scrollPane.getViewport().setOpaque(false); + + this.add(scrollPane); + + this.addBackButton(listener, MenuController.BACK_CMD); + + this.revalidate(); this.repaint(); } + + /** + * Adds a "back" button. + * + * @param listener listener for the button + * @param command command associated to the button + */ + private void addBackButton(ActionListener listener, String command) { + ImageIcon backIcon = Picross.getLocalizedImage("button-back.png"); + + JButton backButton = new JButton(backIcon); + backButton.setActionCommand(command); + backButton.addActionListener(listener); + + backButton.setBorder(null); + backButton.setBounds(7, 318, + backIcon.getIconWidth(), + backIcon.getIconHeight()); + + this.add(backButton); + } } Added: trunk/src/picross/game/simple/SizesListCommand.java =================================================================== --- trunk/src/picross/game/simple/SizesListCommand.java (rev 0) +++ trunk/src/picross/game/simple/SizesListCommand.java 2008-05-07 09:34:52 UTC (rev 78) @@ -0,0 +1,82 @@ +/* + * $Id$ + * + * Copyright (c) 2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.game.simple; + +import fr.cle.mmvcs.NamedCommand; + +import java.awt.Dimension; + +import java.util.List; + +/** + * Command used to display the available grid sizes. + * + * @author Y. Norsa + */ +final class SizesListCommand extends NamedCommand { + /*** Constant ***/ + + /** Command used to display the grid sizes. */ + static final String SIZES_CMD = "SIZES_CMD"; + + /*** Field ***/ + + /** The sizes list. */ + private List<Dimension> sizes; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param sizesList the sizes list + */ + SizesListCommand(List<Dimension> sizesList) { + super(SizesListCommand.SIZES_CMD); + + this.sizes = sizesList; + } + + /*** Accessor ***/ + + /** + * Return the sizes list. + * + * @return available grid sizes + */ + List<Dimension> getSizes() { + return this.sizes; + } +} + Property changes on: trunk/src/picross/game/simple/SizesListCommand.java ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/src/picross/menus/MenuController.java =================================================================== --- trunk/src/picross/menus/MenuController.java 2008-05-05 09:34:00 UTC (rev 77) +++ trunk/src/picross/menus/MenuController.java 2008-05-07 09:34:52 UTC (rev 78) @@ -47,6 +47,11 @@ * @author Y. Norsa */ public class MenuController extends Controller implements ActionListener { + /*** Constant ***/ + + /** Command used to redisplay the previous menu. */ + public static final String BACK_CMD = "BACK_CMD"; + /*** Static field ***/ /** The class' logger. */ Modified: trunk/src/picross/menus/MenuUI.java =================================================================== --- trunk/src/picross/menus/MenuUI.java 2008-05-05 09:34:00 UTC (rev 77) +++ trunk/src/picross/menus/MenuUI.java 2008-05-07 09:34:52 UTC (rev 78) @@ -149,19 +149,41 @@ SimpleListener listener, int x, int y) { PicrossButton button = + this.createSimpleButton(label, event, listener); + this.putButton(button.getButton(), x, y, 150, 50); + } + + /** + * Helper method to create a button. + * + * @param label the button's label + * @param event the event linked to the button + * @param listener listener for the button + * @return the created button + */ + protected final PicrossButton createSimpleButton(String label, + SimpleEvent event, + SimpleListener listener) { + PicrossButton button = new PicrossButton(label, Picross.getImage("empty-button.png"), event); button.addSimpleListener(listener); JButton realButton = button.getButton(); + realButton.setHorizontalTextPosition(JButton.CENTER); realButton.setVerticalTextPosition(JButton.CENTER); - + realButton.setFont(realButton.getFont() .deriveFont(MenuUI.BUTTON_TEXT_SIZE)); realButton.setForeground(Color.WHITE); - this.putButton(realButton, x, y, 150, 50); + Dimension dim = new Dimension(150, 50); + realButton.setMinimumSize(dim); + realButton.setMaximumSize(dim); + realButton.setPreferredSize(dim); + + return button; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-05 09:33:54
|
Revision: 77 http://picross.svn.sourceforge.net/picross/?rev=77&view=rev Author: yvan_norsa Date: 2008-05-05 02:34:00 -0700 (Mon, 05 May 2008) Log Message: ----------- nicer buttons Modified Paths: -------------- trunk/src/picross/menus/MenuUI.java Modified: trunk/src/picross/menus/MenuUI.java =================================================================== --- trunk/src/picross/menus/MenuUI.java 2008-05-05 08:59:21 UTC (rev 76) +++ trunk/src/picross/menus/MenuUI.java 2008-05-05 09:34:00 UTC (rev 77) @@ -38,6 +38,7 @@ import fr.cle.mmvcs.SimpleEvent; import fr.cle.mmvcs.SimpleListener; +import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Image; @@ -71,6 +72,9 @@ /** Default height to be used if the background file can't be found. */ private static final int DEFAULT_HEIGHT = 375; + /** Size for buttons' text. */ + private static final float BUTTON_TEXT_SIZE = 16; + /*** Static field ***/ /** This class' logger. */ @@ -152,6 +156,10 @@ JButton realButton = button.getButton(); realButton.setHorizontalTextPosition(JButton.CENTER); realButton.setVerticalTextPosition(JButton.CENTER); + + realButton.setFont(realButton.getFont() + .deriveFont(MenuUI.BUTTON_TEXT_SIZE)); + realButton.setForeground(Color.WHITE); this.putButton(realButton, x, y, 150, 50); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-05 09:01:50
|
Revision: 76 http://picross.svn.sourceforge.net/picross/?rev=76&view=rev Author: yvan_norsa Date: 2008-05-05 01:59:21 -0700 (Mon, 05 May 2008) Log Message: ----------- findbugs Modified Paths: -------------- trunk/src/picross/grid/GridController.java Modified: trunk/src/picross/grid/GridController.java =================================================================== --- trunk/src/picross/grid/GridController.java 2008-05-05 08:56:57 UTC (rev 75) +++ trunk/src/picross/grid/GridController.java 2008-05-05 08:59:21 UTC (rev 76) @@ -213,7 +213,7 @@ int row = this.view.getRow(point); int column = this.view.getColumn(point); - GridAction type = GridAction.UNKNOWN; + GridAction type; if (this.eraseMode) { type = GridAction.EMPTY; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-05 08:57:49
|
Revision: 75 http://picross.svn.sourceforge.net/picross/?rev=75&view=rev Author: yvan_norsa Date: 2008-05-05 01:56:57 -0700 (Mon, 05 May 2008) Log Message: ----------- ignore tests while running Findbugs Modified Paths: -------------- trunk/bugsFilter.xml Modified: trunk/bugsFilter.xml =================================================================== --- trunk/bugsFilter.xml 2008-05-05 08:54:15 UTC (rev 74) +++ trunk/bugsFilter.xml 2008-05-05 08:56:57 UTC (rev 75) @@ -1,4 +1,8 @@ <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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-05 08:54:17
|
Revision: 74 http://picross.svn.sourceforge.net/picross/?rev=74&view=rev Author: yvan_norsa Date: 2008-05-05 01:54:15 -0700 (Mon, 05 May 2008) Log Message: ----------- code clean-up Modified Paths: -------------- trunk/src/picross/grid/GridController.java trunk/src/picross/grid/GridMediator.java Modified: trunk/src/picross/grid/GridController.java =================================================================== --- trunk/src/picross/grid/GridController.java 2008-05-05 08:53:08 UTC (rev 73) +++ trunk/src/picross/grid/GridController.java 2008-05-05 08:54:15 UTC (rev 74) @@ -78,12 +78,6 @@ /** Command asking to enable the Erase mode. */ static final String ERASE_MODE_CMD = "ERASE_MODE_CMD"; - /** Checking a box. */ - //static final int CHECK_ACTION = 0; - - /** Crossing a box. */ - //static final int CROSS_ACTION = 1; - /*** Static field ***/ /** The class' logger. */ @@ -224,7 +218,6 @@ if (this.eraseMode) { type = GridAction.EMPTY; } else { - //int type = GridController.modifiersToType(modifiers); type = GridController.modifiersToType(modifiers); } @@ -245,19 +238,15 @@ * @param modifiers mouse event modifiers * @return corresponding action, or -1 */ - //private static int modifiersToType(int modifiers) { private static GridAction modifiersToType(int modifiers) { switch (modifiers) { case MouseEvent.BUTTON1_MASK: - //return GridController.CHECK_ACTION; return GridAction.CHECK; case MouseEvent.BUTTON3_MASK: - //return GridController.CROSS_ACTION; return GridAction.CROSS; default: - //return -1; return GridAction.UNKNOWN; } } Modified: trunk/src/picross/grid/GridMediator.java =================================================================== --- trunk/src/picross/grid/GridMediator.java 2008-05-05 08:53:08 UTC (rev 73) +++ trunk/src/picross/grid/GridMediator.java 2008-05-05 08:54:15 UTC (rev 74) @@ -141,29 +141,28 @@ /*** Methods implanted from the interface IGridMediator ***/ - /** Tells the application mediator the grid has been filled. */ + /** {@inheritDoc} */ + @Override public void congratulations() { this.fireEventPerformed(GridController.GRID_FILLED_CMD); } - /** - * Asks to repaint a box. - * - * @param row row number of the box - * @param column column number of the box - */ + /** {@inheritDoc} */ + @Override public void repaint(int row, int column) { this.fireEventPerformed(GridController.PAINT_CMD, new PaintCommand(row, column)); } - /** Asks to repaint the column hints. */ + /** {@inheritDoc} */ + @Override public void repaintColHints(int column) { this.fireEventPerformed(//GridController.REPAINT_TOP_HINTS_CMD); new RepaintTopHintsCommand(column)); } - /** Asks to repaint the row hints. */ + /** {@inheritDoc} */ + @Override public void repaintRowHints(int row) { this.fireEventPerformed(//GridController.REPAINT_LEFT_HINTS_CMD); new RepaintLeftHintsCommand(row)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-05 08:53:37
|
Revision: 73 http://picross.svn.sourceforge.net/picross/?rev=73&view=rev Author: yvan_norsa Date: 2008-05-05 01:53:08 -0700 (Mon, 05 May 2008) Log Message: ----------- added erase mode Modified Paths: -------------- trunk/src/picross/grid/GridAction.java trunk/src/picross/grid/GridController.java trunk/src/picross/grid/GridMediator.java trunk/src/picross/grid/GridModel.java trunk/src/picross/grid/IGridMediator.java trunk/src/picross/grid/tests/IGridMediatorStub.java Modified: trunk/src/picross/grid/GridAction.java =================================================================== --- trunk/src/picross/grid/GridAction.java 2008-04-30 13:47:52 UTC (rev 72) +++ trunk/src/picross/grid/GridAction.java 2008-05-05 08:53:08 UTC (rev 73) @@ -46,6 +46,9 @@ CHECK, /** Crossing a box. */ - CROSS + CROSS, + + /** Erasing a box. */ + EMPTY } Modified: trunk/src/picross/grid/GridController.java =================================================================== --- trunk/src/picross/grid/GridController.java 2008-04-30 13:47:52 UTC (rev 72) +++ trunk/src/picross/grid/GridController.java 2008-05-05 08:53:08 UTC (rev 73) @@ -75,6 +75,9 @@ /** Command asking to repaint the left hints. */ static final String REPAINT_LEFT_HINTS_CMD = "REPAINT_LEFT_HINTS_CMD"; + /** Command asking to enable the Erase mode. */ + static final String ERASE_MODE_CMD = "ERASE_MODE_CMD"; + /** Checking a box. */ //static final int CHECK_ACTION = 0; @@ -86,11 +89,14 @@ /** The class' logger. */ //private static Logger log = Logger.getLogger(GridController.class); - /*** Field ***/ + /*** Fields ***/ /** 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 ***/ /** {@inheritDoc} */ @@ -123,6 +129,11 @@ this.view.repaintRowHints(row); return; } + + if (cmd.equals(GridController.ERASE_MODE_CMD)) { + this.eraseMode = true; + return; + } } /*** Methods implanted from the interface MouseListener ***/ @@ -154,6 +165,7 @@ public void mouseReleased(MouseEvent e) { //GridController.log.debug("mouseReleased()"); this.checkAndFill(e); + this.eraseMode = false; this.fireEventPerformed(GridController.END_ACTION_CMD); } @@ -206,9 +218,16 @@ if (this.view.isInGrid(point)) { int row = this.view.getRow(point); int column = this.view.getColumn(point); - //int type = GridController.modifiersToType(modifiers); - GridAction type = GridController.modifiersToType(modifiers); + GridAction type = GridAction.UNKNOWN; + + if (this.eraseMode) { + type = GridAction.EMPTY; + } else { + //int type = GridController.modifiersToType(modifiers); + type = GridController.modifiersToType(modifiers); + } + //GridController.log.debug("type : " + type); this.fireEventPerformed(GridController.FILL_CMD, Modified: trunk/src/picross/grid/GridMediator.java =================================================================== --- trunk/src/picross/grid/GridMediator.java 2008-04-30 13:47:52 UTC (rev 72) +++ trunk/src/picross/grid/GridMediator.java 2008-05-05 08:53:08 UTC (rev 73) @@ -169,6 +169,12 @@ new RepaintLeftHintsCommand(row)); } + /** {@inheritDoc} */ + @Override + public void setEraseMode() { + this.fireEventPerformed(GridController.ERASE_MODE_CMD); + } + /*** Accessor ***/ /** Modified: trunk/src/picross/grid/GridModel.java =================================================================== --- trunk/src/picross/grid/GridModel.java 2008-04-30 13:47:52 UTC (rev 72) +++ trunk/src/picross/grid/GridModel.java 2008-05-05 08:53:08 UTC (rev 73) @@ -418,6 +418,11 @@ } } + if (!this.boxes[column][row].isEmpty() && type == GridAction.EMPTY) { + this.boxes[column][row].empty(); + this.mediator.repaint(row, column); + } else { + if (this.boxes[column][row].isEmpty() && (this.lastModified == null || !this.lastModified.isEmpty())) { @@ -437,6 +442,7 @@ if (type == GridAction.CHECK) { this.boxes[column][row].empty(); + this.setEraseMode(); } else { //if (type == GridAction.CROSS) { this.boxes[column][row].cross(); } @@ -445,6 +451,7 @@ if (type == GridAction.CROSS) { this.boxes[column][row].empty(); + this.setEraseMode(); } else { //if (type == GridAction.CHECK) { //GridModel.log.debug("check()"); @@ -454,6 +461,7 @@ this.mediator.repaint(row, column); } + } this.lastModified = this.boxes[column][row]; this.checkColumn(column); @@ -461,6 +469,11 @@ this.checkCompleted(); } + /** Enables the erase mode. */ + private void setEraseMode() { + this.mediator.setEraseMode(); + } + /** * Checks if a row is empty. * Modified: trunk/src/picross/grid/IGridMediator.java =================================================================== --- trunk/src/picross/grid/IGridMediator.java 2008-04-30 13:47:52 UTC (rev 72) +++ trunk/src/picross/grid/IGridMediator.java 2008-05-05 08:53:08 UTC (rev 73) @@ -53,5 +53,8 @@ /** Tells the application mediator the grid has been filled. */ void congratulations(); + + /** Enables the erase mode. */ + void setEraseMode(); } Modified: trunk/src/picross/grid/tests/IGridMediatorStub.java =================================================================== --- trunk/src/picross/grid/tests/IGridMediatorStub.java 2008-04-30 13:47:52 UTC (rev 72) +++ trunk/src/picross/grid/tests/IGridMediatorStub.java 2008-05-05 08:53:08 UTC (rev 73) @@ -64,5 +64,7 @@ public void repaintRowHints(int row) { } public void congratulations() { } + + public void setEraseMode() { } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-04-30 13:47:45
|
Revision: 72 http://picross.svn.sourceforge.net/picross/?rev=72&view=rev Author: yvan_norsa Date: 2008-04-30 06:47:52 -0700 (Wed, 30 Apr 2008) Log Message: ----------- unit tests Modified Paths: -------------- trunk/build.xml trunk/src/picross/tests/AbstractPicrossGridTest.java Added Paths: ----------- trunk/lib/testsHelper.jar trunk/src/picross/game/random/tests/ trunk/src/picross/game/random/tests/RandomPicrossModelTest.java trunk/src/picross/game/simple/tests/ trunk/src/picross/game/simple/tests/XBMModelTest.java trunk/src/picross/grid/tests/BoxTest.java trunk/src/picross/grid/tests/CompletedHintsTest.java trunk/src/picross/grid/tests/FillCommandTest.java trunk/src/picross/grid/tests/GridModelTest.java trunk/src/picross/grid/tests/PaintCommandTest.java Removed Paths: ------------- trunk/src/picross/game/random/RandomPicrossModelTest.java trunk/src/picross/game/simple/XBMModelTest.java trunk/src/picross/grid/BoxTest.java trunk/src/picross/grid/CompletedHintsTest.java trunk/src/picross/grid/FillCommandTest.java trunk/src/picross/grid/GridModelTest.java trunk/src/picross/grid/PaintCommandTest.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/build.xml 2008-04-30 13:47:52 UTC (rev 72) @@ -29,6 +29,8 @@ 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"> @@ -65,6 +67,7 @@ <pathelement location="${log4j.jar}" /> <pathelement location="${mmvcs.jar}" /> <pathelement location="${simpleButton.jar}" /> + <pathelement location="${testsHelper.jar}" /> </path> <target name="compile" Added: trunk/lib/testsHelper.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/testsHelper.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Deleted: trunk/src/picross/game/random/RandomPicrossModelTest.java =================================================================== --- trunk/src/picross/game/random/RandomPicrossModelTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/game/random/RandomPicrossModelTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,59 +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.game.random; - -import org.apache.log4j.PropertyConfigurator; - -import picross.PicrossGrid; - -import picross.tests.AbstractPicrossGridTest; - -/** - * 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} */ - protected PicrossGrid getPicrossGrid() { - return new RandomPicrossModel(); - } -} Copied: trunk/src/picross/game/random/tests/RandomPicrossModelTest.java (from rev 63, trunk/src/picross/game/random/RandomPicrossModelTest.java) =================================================================== --- trunk/src/picross/game/random/tests/RandomPicrossModelTest.java (rev 0) +++ trunk/src/picross/game/random/tests/RandomPicrossModelTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -0,0 +1,66 @@ +/* + * $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.tests; + +import fr.cle.tests.TestsHelper; + +import org.apache.log4j.PropertyConfigurator; + +import org.junit.Test; + +import picross.PicrossGrid; + +import picross.tests.AbstractPicrossGridTest; + +/** + * 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"); + } +} Deleted: trunk/src/picross/game/simple/XBMModelTest.java =================================================================== --- trunk/src/picross/game/simple/XBMModelTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/game/simple/XBMModelTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,99 +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.simple; - -import java.io.ByteArrayInputStream; -import java.io.IOException; - -import org.apache.log4j.PropertyConfigurator; - -import org.junit.Assert; -import org.junit.Test; - -import picross.Picross; -import picross.PicrossGrid; - -import picross.tests.AbstractPicrossGridTest; - -/** - * 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")); - } catch (IOException ioEx) { - throw new ExceptionInInitializerError(ioEx); - } catch (XBMException 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, XBMException { - try { - new XBMModel(null); - Assert.fail("Tried to load a null model"); - } catch (IllegalArgumentException argEx) { } - - try { - new XBMModel(new ByteArrayInputStream("".getBytes())); - Assert.fail("Empty file"); - } catch (XBMException xbmEx) { } - } -} Copied: trunk/src/picross/game/simple/tests/XBMModelTest.java (from rev 67, trunk/src/picross/game/simple/XBMModelTest.java) =================================================================== --- trunk/src/picross/game/simple/tests/XBMModelTest.java (rev 0) +++ trunk/src/picross/game/simple/tests/XBMModelTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -0,0 +1,124 @@ +/* + * $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.tests; + +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.Picross; +import picross.PicrossException; +import picross.PicrossGrid; + +import picross.tests.AbstractPicrossGridTest; + +/** + * 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; + //} + } + } +} Deleted: trunk/src/picross/grid/BoxTest.java =================================================================== --- trunk/src/picross/grid/BoxTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/grid/BoxTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,156 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Y. Norsa - */ -public class BoxTest { - /*** Constante ***/ - - /*** Champ statique ***/ - - /*** Champ ***/ - - private Box box = null; - - /*** Constructeur ***/ - - /** - * Constructeur. - */ - /* - BoxTest() { - } - */ - /*** M\xE9thode ***/ - - @Before - public void setUp() { - this.box = new Box(); - } - - @Test - public void testCheck() { - this.box.check(); - Assert.assertTrue("box unchecked", this.box.isChecked()); - } - - @Test - public void testCross() { - this.box.cross(); - Assert.assertTrue("box not crossed", this.box.isCrossed()); - } - - @Test - public void testEmpty() { - this.box.empty(); - Assert.assertTrue("box not empty", this.box.isEmpty()); - } - - @Test - public void testEquals() { - Assert.assertFalse("this.box = null", this.box.equals(null)); - Assert.assertTrue("box != box", this.box.equals(this.box)); - - this.box.check(); - - Box box2 = new Box(); - Assert.assertFalse("box = box2", this.box.equals(box2)); - - box2.check(); - - Assert.assertTrue("box != box2", this.box.equals(box2)); - } - - @Test - public void testgetIcon() { - Assert.assertNotNull("empty icon = null", this.box.getIcon()); - - this.box.check(); - Assert.assertNotNull("checked icon = null", this.box.getIcon()); - - this.box.cross(); - Assert.assertNotNull("crossed icon = null", this.box.getIcon()); - } - - @Test - public void testGetRolloverIcon() { - Assert.assertNotNull("rollover empty icon = null", - this.box.getRolloverIcon()); - - this.box.check(); - Assert.assertNotNull("rollover checked icon = null", - this.box.getRolloverIcon()); - - this.box.cross(); - Assert.assertNotNull("rollover crossed icon = null", - this.box.getRolloverIcon()); - } - - @Test - public void testIsChecked() { - this.box.check(); - - Assert.assertFalse("box crossed AND checked", this.box.isCrossed()); - Assert.assertFalse("box empty AND checked", this.box.isEmpty()); - } - - @Test - public void testIsCrossed() { - this.box.cross(); - - Assert.assertFalse("box checked AND crossed", this.box.isChecked()); - Assert.assertFalse("box empty AND crossed", this.box.isEmpty()); - } - - @Test - public void testIsEmpty() { - Assert.assertFalse("box checked AND empty", this.box.isChecked()); - Assert.assertFalse("box crossed AND empty", this.box.isCrossed()); - } - - @Test - public void testSetRect() { - try { - this.box.setRect(null); - Assert.fail("box.setRect(null)"); - } catch (IllegalArgumentException argEx) { } - } -} - Deleted: trunk/src/picross/grid/CompletedHintsTest.java =================================================================== --- trunk/src/picross/grid/CompletedHintsTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/grid/CompletedHintsTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,205 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Y. Norsa - */ -public class CompletedHintsTest { - /*** Constante ***/ - - /*** Champ statique ***/ - - /*** Champ ***/ - - CompletedHints hints = null; - - /*** Constructeur ***/ - - /** - * Constructeur. - */ - /* - CompletedHintsTest() { - } - */ - /*** M\xE9thode ***/ - - @Before - public void setUp() { - this.hints = new CompletedHints(10, 10, 10, 10); - } - - @Test - public void testCompletedHints() { - try { - new CompletedHints(-1, -1, -1, -1); - Assert.fail("colsHintsWidth = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(0, -1, -1, -1); - Assert.fail("colsHintsWidth = 0"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(1, -1, -1, -1); - Assert.fail("colsHintsHeight = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(1, 0, -1, -1); - Assert.fail("colsHintsHeight = 0"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(1, 1, -1, -1); - Assert.fail("rowsHintsWidth = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(1, 1, 0, -1); - Assert.fail("rowsHintsWidth = 0"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(1, 1, 1, -1); - Assert.fail("rowsHintsHeight = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(1, 1, 1, 0); - Assert.fail("rowsHintsHeight = 0"); - } catch (IllegalArgumentException argEx) { } - } - - @Test - public void testClearColHint() { - this.hints.setCompleteColHint(3, 4); - this.hints.clearColHint(3, 4); - Assert.assertFalse(this.hints.isColHintComplete(3, 4)); - } - - @Test - public void testClearRowHint() { - this.hints.setCompleteRowHint(8, 2); - this.hints.clearRowHint(8, 2); - Assert.assertFalse(this.hints.isRowHintComplete(8, 2)); - } - - @Test - public void testGetCompleteColHints() { - try { - this.hints.getCompleteColHints(-1); - Assert.fail("column = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - this.hints.getCompleteColHints(42); - Assert.fail("column = 42"); - } catch (IllegalArgumentException argEx) { } - - List<Integer> complete = this.hints.getCompleteColHints(4); - Assert.assertNotNull("complete = null", complete); - int size = complete.size(); - Assert.assertTrue("size = " + size, (size == 0)); - - this.hints.setCompleteColHint(4, 0); - this.hints.setCompleteColHint(4, 9); - - complete = this.hints.getCompleteColHints(4); - Assert.assertNotNull("complete = null", complete); - size = complete.size(); - Assert.assertTrue("size = " + size, (size == 2)); - - int nb1 = complete.get(0); - Assert.assertTrue("nb1 = " + nb1, (nb1 == 0)); - - int nb2 = complete.get(1); - Assert.assertTrue("nb2 = " + nb2, (nb2 == 9)); - } - - @Test - public void testGetCompleteRowHints() { - try { - this.hints.getCompleteRowHints(-1); - Assert.fail("row = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - this.hints.getCompleteRowHints(42); - Assert.fail("row = 42"); - } catch (IllegalArgumentException argEx) { } - - List<Integer> complete = this.hints.getCompleteRowHints(9); - Assert.assertNotNull("complete = null", complete); - int size = complete.size(); - Assert.assertTrue("size = " + size, (size == 0)); - - this.hints.setCompleteRowHint(9, 3); - this.hints.setCompleteRowHint(9, 6); - - complete = this.hints.getCompleteRowHints(9); - Assert.assertNotNull("complete = null", complete); - size = complete.size(); - Assert.assertTrue("size = " + size, (size == 2)); - - int nb1 = complete.get(0); - Assert.assertTrue("nb1 = " + nb1, (nb1 == 3)); - - int nb2 = complete.get(1); - Assert.assertTrue("nb2 = " + nb2, (nb2 == 6)); - } - - @Test - public void testIsColHintCompleteAndSetCompleteColHint() { - Assert.assertFalse(this.hints.isColHintComplete(0, 0)); - this.hints.setCompleteColHint(0, 0); - Assert.assertTrue(this.hints.isColHintComplete(0, 0)); - } - - @Test - public void testIsRowHintCompleteAndSetCompleteRowHint() { - Assert.assertFalse(this.hints.isRowHintComplete(5, 5)); - this.hints.setCompleteRowHint(5, 5); - Assert.assertTrue(this.hints.isRowHintComplete(5, 5)); - } -} - Deleted: trunk/src/picross/grid/FillCommandTest.java =================================================================== --- trunk/src/picross/grid/FillCommandTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/grid/FillCommandTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,80 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import 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); - } -} - Deleted: trunk/src/picross/grid/GridModelTest.java =================================================================== --- trunk/src/picross/grid/GridModelTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/grid/GridModelTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,110 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import picross.grid.tests.IGridMediatorStub; - -/** - * @author Y. Norsa - */ -public class GridModelTest { - /*** Constante ***/ - - /*** Champ statique ***/ - - /*** Champ ***/ - - private GridModel model = null; - - /*** Constructeur ***/ - - /** - * Constructeur. - */ - /* - GridModelTest() { - }*/ - - /*** M\xE9thode ***/ - - @Before - public void setUp() { - this.model = new GridModel(new IGridMediatorStub(), new boolean[3][5]); - } - - @Test - public void testGridModel() { - try { - new GridModel(null, null); - Assert.fail("mediator = null"); - } catch (IllegalArgumentException argEx) { } - - IGridMediator stub = new IGridMediatorStub(); - - try { - new GridModel(stub, null); - Assert.fail("data = null"); - } catch (IllegalArgumentException argEx) { } - - try { - new GridModel(stub, new boolean[0][0]); - Assert.fail("empty data"); - } catch (IllegalArgumentException argEx) { } - - try { - new GridModel(stub, new boolean[1][0]); - Assert.fail("empty data"); - } catch (IllegalArgumentException argEx) { } - } - - @Test - public void testActOnBox() { - try { - this.model.actOnBox(-1, -1, GridAction.CHECK); - Assert.fail("row = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - this.model.actOnBox(0, -1, GridAction.CHECK); - Assert.fail("column = -1"); - } catch (IllegalArgumentException argEx) { } - - this.model.actOnBox(0, 0, GridAction.CHECK); - } -} - Deleted: trunk/src/picross/grid/PaintCommandTest.java =================================================================== --- trunk/src/picross/grid/PaintCommandTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/grid/PaintCommandTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,58 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Y. Norsa - */ -public class PaintCommandTest { - @Test - public void testPaintCommand() { - try { - new PaintCommand(-1, -1); - Assert.fail("row = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - new PaintCommand(0, -1); - Assert.fail("column = -1"); - } catch (IllegalArgumentException argEx) { } - - new PaintCommand(0, 0); - } -} - Copied: trunk/src/picross/grid/tests/BoxTest.java (from rev 63, trunk/src/picross/grid/BoxTest.java) =================================================================== --- trunk/src/picross/grid/tests/BoxTest.java (rev 0) +++ trunk/src/picross/grid/tests/BoxTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -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.tests; + +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/src/picross/grid/tests/CompletedHintsTest.java (from rev 63, trunk/src/picross/grid/CompletedHintsTest.java) =================================================================== --- trunk/src/picross/grid/tests/CompletedHintsTest.java (rev 0) +++ trunk/src/picross/grid/tests/CompletedHintsTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -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.tests; + +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/src/picross/grid/tests/FillCommandTest.java (from rev 63, trunk/src/picross/grid/FillCommandTest.java) =================================================================== --- trunk/src/picross/grid/tests/FillCommandTest.java (rev 0) +++ trunk/src/picross/grid/tests/FillCommandTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -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.tests; + +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/src/picross/grid/tests/GridModelTest.java (from rev 63, trunk/src/picross/grid/GridModelTest.java) =================================================================== --- trunk/src/picross/grid/tests/GridModelTest.java (rev 0) +++ trunk/src/picross/grid/tests/GridModelTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -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.tests; + +import fr.cle.tests.TestsHelper; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import picross.grid.IGridMediator; + +/** + * @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/src/picross/grid/tests/PaintCommandTest.java (from rev 63, trunk/src/picross/grid/PaintCommandTest.java) =================================================================== --- trunk/src/picross/grid/tests/PaintCommandTest.java (rev 0) +++ trunk/src/picross/grid/tests/PaintCommandTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -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 l... [truncated message content] |
From: <yva...@us...> - 2008-04-29 09:32:50
|
Revision: 71 http://picross.svn.sourceforge.net/picross/?rev=71&view=rev Author: yvan_norsa Date: 2008-04-29 02:32:57 -0700 (Tue, 29 Apr 2008) Log Message: ----------- checkstyle Modified Paths: -------------- trunk/src/picross/MissingImageException.java trunk/src/picross/Picross.java trunk/src/picross/PicrossController.java trunk/src/picross/PicrossMediator.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/GameCommand.java trunk/src/picross/game/GameMediator.java trunk/src/picross/game/GameMode.java trunk/src/picross/game/random/RandomGameController.java trunk/src/picross/game/random/RandomGameMediator.java trunk/src/picross/game/random/RandomGameMode.java trunk/src/picross/game/simple/FileInfos.java trunk/src/picross/game/simple/LevelInfos.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/SimpleGameMode.java trunk/src/picross/grid/CompletedHints.java trunk/src/picross/grid/FillCommand.java trunk/src/picross/grid/GridAction.java trunk/src/picross/grid/GridController.java trunk/src/picross/grid/GridMediator.java trunk/src/picross/grid/GridModel.java trunk/src/picross/grid/GridUI.java trunk/src/picross/grid/HintBoxInfos.java trunk/src/picross/grid/RepaintLeftHintsCommand.java trunk/src/picross/grid/RepaintTopHintsCommand.java trunk/src/picross/menus/GameMenuMediator.java trunk/src/picross/menus/GameMenuModel.java trunk/src/picross/menus/GameMenuUI.java trunk/src/picross/menus/MainMenuMediator.java trunk/src/picross/menus/MainMenuUI.java trunk/src/picross/menus/MenuCommand.java trunk/src/picross/menus/MenuController.java trunk/src/picross/menus/MenuMediator.java trunk/src/picross/menus/MenuUI.java trunk/src/picross/menus/PicrossButton.java trunk/src/picross/menus/WaitMenuMediator.java trunk/src/picross/menus/WaitMenuUI.java trunk/src/picross/properties/messages_picross.properties trunk/src/picross/properties/messages_picross_fr.properties Modified: trunk/src/picross/MissingImageException.java =================================================================== --- trunk/src/picross/MissingImageException.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/MissingImageException.java 2008-04-29 09:32:57 UTC (rev 71) @@ -38,7 +38,7 @@ * * @author Y. Norsa */ -public class MissingImageException extends RuntimeException { +public final class MissingImageException extends RuntimeException { /*** Constant ***/ /** Serialisation ID. */ Modified: trunk/src/picross/Picross.java =================================================================== --- trunk/src/picross/Picross.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/Picross.java 2008-04-29 09:32:57 UTC (rev 71) @@ -39,17 +39,12 @@ import java.net.URL; -import java.util.ArrayList; -import java.util.List; import java.util.Locale; import javax.swing.ImageIcon; //import org.apache.log4j.Logger; -//import picross.game.simple.FileInfos; -//import picross.game.simple.LevelInfos; - /** * Helper class. * Modified: trunk/src/picross/PicrossController.java =================================================================== --- trunk/src/picross/PicrossController.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/PicrossController.java 2008-04-29 09:32:57 UTC (rev 71) @@ -49,16 +49,9 @@ /** Play command. */ public static final String PLAY_CMD = "PLAY_CMD"; - /** Random game command. */ - //public static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD"; + /** Command used to display a menu. */ + public static final String MENU_CMD = "MENU_CMD"; - //public static final String NEXT_RANDOM_GAME_CMD = "NEXT_RANDOM_GAME_CMD"; - - /** Select level command. */ - //public static final String SELECT_LEVEL_CMD = "SELECT_LEVEL_CMD"; - - //public static final String LEVEL_CMD = "LEVEL_CMD"; - /** Exit command. */ public static final String EXIT_CMD = "EXIT_CMD"; @@ -75,6 +68,7 @@ /*** Method overloaded from the class Controller ***/ /** {@inheritDoc} */ + @Override public void eventPerformed(SimpleEvent e) { PicrossController.log.debug("eventPerformed(" + e + ")"); Modified: trunk/src/picross/PicrossMediator.java =================================================================== --- trunk/src/picross/PicrossMediator.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/PicrossMediator.java 2008-04-29 09:32:57 UTC (rev 71) @@ -47,14 +47,9 @@ import picross.game.GameCommand; import picross.game.GameMediator; -//import picross.game.random.RandomGameMediator; - -//import picross.game.simple.SimpleGameMediator; - import picross.grid.GridController; import picross.menus.GameMenuMediator; -//import picross.menus.LevelMenuMediator; import picross.menus.MainMenuMediator; import picross.menus.MenuCommand; import picross.menus.MenuMediator; @@ -71,23 +66,30 @@ /** Class' logger. */ //private static Logger log = Logger.getLogger(PicrossMediator.class); - /*** Field ***/ + /*** 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. */ + /** + * 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(view); + controller.setView(this.view); this.addSimpleListener(controller); this.displayMenu(MainMenuMediator.class); @@ -98,49 +100,18 @@ /*** 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.startGame(); this.displayGameMenu(); - return; } - /* - if (cmd.equals(PicrossController.RANDOM_GAME_CMD)) { - this.displayWaitScreen(); - this.startRandomGame(); - return; - } - */ - - /* - if (cmd.equals(PicrossController.NEXT_RANDOM_GAME_CMD)) { - this.startRandomGame(); - return; - } - */ - - /* - if (cmd.equals(PicrossController.SELECT_LEVEL_CMD)) { - this.displaySelectLevelMenu(); - return; - } - */ - - /* - if (cmd.equals(PicrossController.LEVEL_CMD)) { - this.displayWaitScreen(); - this.startGame(e.getComment()); - return; - } - */ - - if (cmd.equals("MENU_CMD")) { + if (cmd.equals(PicrossController.MENU_CMD)) { MenuCommand command = (MenuCommand) e.getCommand(); this.displayMenu(command.getMenuClass()); @@ -148,10 +119,7 @@ } if (cmd.equals(GameCommand.GAME_CMD)) { - if (this.firstTime) { - this.displayWaitScreen(); - this.firstTime = false; - } + this.displayWaitScreen(); GameCommand command = (GameCommand) e.getCommand(); this.startGame(command.getGame()); @@ -166,8 +134,7 @@ if (cmd.equals(GridController.GRID_FILLED_CMD)) { this.fireEventPerformed(PicrossController.MESSAGE_CMD, - BundleHelper.getString(this, "victory") - + " !"); + BundleHelper.getString(this, "victory")); return; } } @@ -184,15 +151,12 @@ this.displayMenu(GameMenuMediator.class); } - /** Displays the level selection menu. */ - /* - private void displaySelectLevelMenu() { - this.displayMenu(LevelMenuMediator.class); - } - */ - + /** Displays the loading screen only the first time. */ private void displayWaitScreen() { - this.displayMenu(WaitMenuMediator.class); + if (this.firstTime) { + this.displayMenu(WaitMenuMediator.class); + this.firstTime = false; + } } /** @@ -205,8 +169,7 @@ try { try { - menu = menuClass.getConstructor()//PicrossUI.class) - .newInstance(/*this.view*/); + menu = menuClass.getConstructor().newInstance(); } catch (NoSuchMethodException methodEx) { throw new PicrossException(methodEx); } catch (InstantiationException instantiationEx) { @@ -214,8 +177,6 @@ } catch (IllegalAccessException accessEx) { throw new PicrossException(accessEx); } catch (InvocationTargetException targetEx) { - //targetEx.printStackTrace(); - //throw (PicrossException) targetEx.getCause(); throw new PicrossException(targetEx); } @@ -232,74 +193,28 @@ 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 = new RandomGameMediator(); - game.start(); + game.init(); PicrossMediator.this.gameLoaded(game); } catch (PicrossException picrossEx) { PicrossMediator.this.view .displayError(picrossEx.getMessage()); return; - } + } } }; worker.start(); } - /** Starts a random game. * - /* - private void startRandomGame() { - Thread worker = new Thread() { - public void run() { - GameMediator game = null; - - try { - game = new RandomGameMediator(); - game.start(); - PicrossMediator.this.gameLoaded(game); - } catch (PicrossException picrossEx) { - PicrossMediator.this.view - .displayError(picrossEx.getMessage()); - return; - } - } - }; - - worker.start(); - } - */ - /** Starts a new game. */ - /* - private void startGame(final String level) { - PicrossMediator.log.debug("startGame(" + level + ")"); - - Thread worker = new Thread() { - public void run() { - GameMediator game = null; - - try { - game = new SimpleGameMediator(level); - PicrossMediator.this.gameLoaded(game); - } catch (final PicrossException picrossEx) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - PicrossMediator.this.view - .displayError(picrossEx.getMessage()); - return; - } - }); - } - } - }; - - worker.start(); - } - */ - /** * Callback used to display the game view. * Modified: trunk/src/picross/app/MainMenuAppUI.java =================================================================== --- trunk/src/picross/app/MainMenuAppUI.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/app/MainMenuAppUI.java 2008-04-29 09:32:57 UTC (rev 71) @@ -35,12 +35,6 @@ import java.awt.event.ActionListener; -import java.io.FileNotFoundException; - -import javax.swing.ImageIcon; -import javax.swing.JButton; - -import picross.Picross; import picross.PicrossController; import picross.menus.MainMenuUI; @@ -51,7 +45,7 @@ * @author Y. Norsa */ public final class MainMenuAppUI extends MainMenuUI { - /*** Constans ***/ + /*** Constants ***/ /** Serialisation ID. */ private static final long serialVersionUID = 8153436550520127667L; @@ -71,15 +65,10 @@ /** "Exit" button Y coordinate. */ private static final int EXIT_BUTTON_Y = 225; - /*** Constructor ***/ + /*** Methods overloaded from the class MainMenuUI ***/ - /** - * Constructor. - * - * @param controller controller for the buttons - * @throws MissingImageException if a button image can't be found - */ - + /** {@inheritDoc} */ + @Override protected void init(ActionListener controller) { super.init(controller); @@ -90,14 +79,14 @@ MainMenuAppUI.EXIT_BUTTON_Y); } - /*** Methods overloaded from MainMenuUI ***/ - /** {@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 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/app/PicrossApp.java 2008-04-29 09:32:57 UTC (rev 71) @@ -90,6 +90,7 @@ .newInstance((Object[]) null); javax.swing.RepaintManager.setCurrentManager(manag); } catch (ClassNotFoundException classEx) { + // The debug jar isn't here } catch (NoSuchMethodException methodEx) { methodEx.printStackTrace(); } catch (InstantiationException instantiationEx) { @@ -107,6 +108,7 @@ monitorClass.getMethod("initMonitoring"); method.invoke(null); } catch (ClassNotFoundException classEx) { + // The debug jar isn't here } catch (NoSuchMethodException methodEx) { methodEx.printStackTrace(); } catch (IllegalAccessException accessEx) { Modified: trunk/src/picross/app/PicrossAppUI.java =================================================================== --- trunk/src/picross/app/PicrossAppUI.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/app/PicrossAppUI.java 2008-04-29 09:32:57 UTC (rev 71) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2008 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -66,33 +66,39 @@ /*** Methods implanted from the interface PicrossUI ***/ /** {@inheritDoc} */ + @Override public void setContent(JPanel content) { this.setContentPane(content); this.pack(); } /** {@inheritDoc} */ + @Override public void displayMessage(String msg) { JOptionPane.showMessageDialog(this, msg); } /** {@inheritDoc} */ + @Override public void displayError(String msg) { JOptionPane.showMessageDialog(this, msg, "Picross", JOptionPane.ERROR_MESSAGE); } /** {@inheritDoc} */ + @Override public void showUI() { this.setVisible(true); } /** {@inheritDoc} */ + @Override public void exit() { this.dispose(); } /** {@inheritDoc} */ + @Override public String getMainMenuClass() { return PicrossAppUI.MAIN_MENU_CLASS; } Modified: trunk/src/picross/applet/MainMenuAppletUI.java =================================================================== --- trunk/src/picross/applet/MainMenuAppletUI.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/applet/MainMenuAppletUI.java 2008-04-29 09:32:57 UTC (rev 71) @@ -37,8 +37,6 @@ import java.awt.event.ActionListener; -import java.io.FileNotFoundException; - import picross.menus.MainMenuUI; /** @@ -58,29 +56,24 @@ /** "Play" button Y coordinate. */ private static final int PLAY_BUTTON_Y = 225; - /*** Constructor ***/ + /*** Methods inherited from the class MainMenuUI ***/ - /** - * Constructor. - * - * @param controller controller for the buttons - * @throws MissingImageException if a button image can't be found - */ - + /** {@inheritDoc} */ + @Override protected void init(ActionListener controller) { super.init(controller); this.setBackground(Color.WHITE); } - /*** Methods inherited from the class MainMenuUI ***/ - /** {@inheritDoc} */ + @Override protected int getPlayButtonX() { return MainMenuAppletUI.PLAY_BUTTON_X; } /** {@inheritDoc} */ + @Override protected int getPlayButtonY() { return MainMenuAppletUI.PLAY_BUTTON_Y; } Modified: trunk/src/picross/applet/PicrossApplet.java =================================================================== --- trunk/src/picross/applet/PicrossApplet.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/applet/PicrossApplet.java 2008-04-29 09:32:57 UTC (rev 71) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2008 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -59,6 +59,7 @@ /*** Methods overloaded from the class JApplet ***/ /** {@inheritDoc} */ + @Override public void init() { SwingUtilities.invokeLater(new Runnable() { public void run() { @@ -70,31 +71,37 @@ /*** Methods implanted from the interface PicrossUI ***/ /** {@inheritDoc} */ + @Override public String getMainMenuClass() { return PicrossApplet.MAIN_MENU_CLASS; } /** {@inheritDoc} */ + @Override public void displayMessage(String msg) { JOptionPane.showMessageDialog(this, msg); } /** {@inheritDoc} */ + @Override public void displayError(String msg) { JOptionPane.showMessageDialog(this, msg, "Picross", JOptionPane.ERROR_MESSAGE); } /** {@inheritDoc} */ + @Override public void setContent(JPanel content) { this.setContentPane(content); this.validate(); } /** {@inheritDoc} */ + @Override public void showUI() { } /** {@inheritDoc} */ + @Override public void exit() { } } Modified: trunk/src/picross/game/GameCommand.java =================================================================== --- trunk/src/picross/game/GameCommand.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/GameCommand.java 2008-04-29 09:32:57 UTC (rev 71) @@ -36,23 +36,27 @@ import fr.cle.mmvcs.NamedCommand; /** + * Command used to launch a game. + * * @author Y. Norsa */ -public class GameCommand extends NamedCommand { - /*** Constante ***/ +public final class GameCommand extends NamedCommand { + /*** Constant ***/ + /** Command requiring the game launch. */ public static final String GAME_CMD = "GAME_CMD"; - /*** Champ statique ***/ + /*** Field ***/ - /*** Champ ***/ - + /** The game to launch. */ private GameMediator game; - /*** Constructeur ***/ + /*** Constructor ***/ /** - * Constructeur. + * Constructor. + * + * @param gameMediator the game to launch */ public GameCommand(GameMediator gameMediator) { super(GameCommand.GAME_CMD); @@ -60,8 +64,13 @@ this.game = gameMediator; } - /*** M\xE9thode ***/ + /*** Accessor ***/ + /** + * Returns the game. + * + * @return the game to launch + */ public GameMediator getGame() { return this.game; } Modified: trunk/src/picross/game/GameMediator.java =================================================================== --- trunk/src/picross/game/GameMediator.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/GameMediator.java 2008-04-29 09:32:57 UTC (rev 71) @@ -62,35 +62,6 @@ /** The game view. */ private GameUI view; - /*** Constructor ***/ - - /** - * Constructor. - * - * @throws PicrossException if there is a problem loading the grid model - * or building the view - */ - //public GameMediator() throws PicrossException { - protected void init() throws PicrossException { - PicrossGrid model = this.initModel(); - - final int width = model.getWidth(); - final int height = model.getHeight(); - - final GridMediator grid = new GridMediator(width, height, - model.getData()); - grid.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, - grid.getView()); - } - }); - } - /*** Abstract methods ***/ /** @@ -113,27 +84,50 @@ */ protected abstract PicrossGrid initModel() throws PicrossException; - public void start() throws PicrossException { - this.init(); - } - /*** Method overloaded from the class Mediator ***/ /** {@inheritDoc} */ + @Override public void eventPerformed(SimpleEvent e) { //GameMediator.log.debug("eventPerformed(" + e + ")"); this.fireEventPerformed(e); } - /*** Method ***/ + /*** 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(); + + final GridMediator grid = new GridMediator(width, height, + model.getData()); + grid.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, + grid.getView()); + } + }); + } + + /** * Returns the game view. * * @return the view */ - public JPanel getView() { + public final JPanel getView() { return this.view; } } Modified: trunk/src/picross/game/GameMode.java =================================================================== --- trunk/src/picross/game/GameMode.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/GameMode.java 2008-04-29 09:32:57 UTC (rev 71) @@ -38,9 +38,16 @@ 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(); } Modified: trunk/src/picross/game/random/RandomGameController.java =================================================================== --- trunk/src/picross/game/random/RandomGameController.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/random/RandomGameController.java 2008-04-29 09:32:57 UTC (rev 71) @@ -65,6 +65,7 @@ /*** Method overloaded from the class Controller ***/ /** {@inheritDoc} */ + @Override public void eventPerformed(SimpleEvent e) { RandomGameController.log.debug("eventPerformed(" + e + ")"); } @@ -72,6 +73,7 @@ /*** Method implanted from the interface ActionListener ***/ /** {@inheritDoc} */ + @Override public void actionPerformed(ActionEvent e) { //RandomGameController.log.debug("actionPerformed(" + e + ")"); Modified: trunk/src/picross/game/random/RandomGameMediator.java =================================================================== --- trunk/src/picross/game/random/RandomGameMediator.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/random/RandomGameMediator.java 2008-04-29 09:32:57 UTC (rev 71) @@ -39,8 +39,6 @@ //import org.apache.log4j.Logger; -import picross.PicrossController; -import picross.PicrossException; import picross.PicrossGrid; import picross.game.GameMediator; @@ -57,23 +55,10 @@ /** The class' logger. */ //private static Logger log = Logger.getLogger(RandomGameMediator.class); - /*** Constructor ***/ - - /** - * Constructor. - * - * @throws PicrossException if there is a problem loading the grid model - * or building the view - */ - /* - public RandomGameMediator() {//throws PicrossException { - //super(); - //this.init(); - } - */ /*** Methods overloaded from the class GameMediator ***/ /** {@inheritDoc} */ + @Override protected GameUI initView(int width, int height, JPanel gridView) { RandomGameController controller = new RandomGameController(); controller.addSimpleListener(this); @@ -83,18 +68,19 @@ } /** {@inheritDoc} */ + @Override protected PicrossGrid initModel() { return new RandomPicrossModel(); } /** {@inheritDoc} */ + @Override public void eventPerformed(SimpleEvent e) { //RandomGameMediator.log.debug("eventPerformed(" + e + ")"); String cmd = e.getCommandName(); if (cmd.equals(RandomGameController.NEXT_CMD)) { - //this.fireEventPerformed(RandomGameController.NEXT_RANDOM_GAME_CMD); this.fireEventPerformed(RandomGameMode.getRandomGameCommand()); return; Modified: trunk/src/picross/game/random/RandomGameMode.java =================================================================== --- trunk/src/picross/game/random/RandomGameMode.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/random/RandomGameMode.java 2008-04-29 09:32:57 UTC (rev 71) @@ -48,10 +48,12 @@ import picross.menus.PicrossButton; /** + * Random game mode. + * * @author Y. Norsa */ -public class RandomGameMode implements GameMode { - /*** Constante ***/ +public final class RandomGameMode implements GameMode { + /*** Constants ***/ /** Image for the "random" button. */ private static final String RANDOM_BUTTON_IMAGE = "button-random.png"; @@ -62,32 +64,28 @@ /** "Random" button Y coordinate. */ private static final int RANDOM_BUTTON_Y = 175; - /*** Champ statique ***/ + /*** Static method ***/ - /*** Champ ***/ - - /*** Constructeur ***/ - /** - * Constructeur. + * Returns the command corresponding to a new random grid. + * + * @return a game command for a new random grid */ - /* - RandomGameMode() { - } - */ - /*** M\xE9thode ***/ - public static GameCommand getRandomGameCommand() { return new GameCommand(new RandomGameMediator()); } + /*** Method implanted from the interface GameMode ***/ + + /** {@inheritDoc} */ + @Override public SimpleButton<JButton> getButton() { - ImageIcon icon = Picross.getLocalizedImage(RandomGameMode.RANDOM_BUTTON_IMAGE); - SimpleEvent event = new SimpleEvent(RandomGameMode.getRandomGameCommand()); - /*PicrossButton button = */return new PicrossButton(icon, event); - //button.getButton().setIcon(icon); + ImageIcon icon = + Picross.getLocalizedImage(RandomGameMode.RANDOM_BUTTON_IMAGE); + SimpleEvent event = + new SimpleEvent(RandomGameMode.getRandomGameCommand()); - //return button; + return new PicrossButton(icon, event); } } Modified: trunk/src/picross/game/simple/FileInfos.java =================================================================== --- trunk/src/picross/game/simple/FileInfos.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/simple/FileInfos.java 2008-04-29 09:32:57 UTC (rev 71) @@ -40,7 +40,7 @@ * * @author Y. Norsa */ -public class FileInfos implements LevelInfos { +public final class FileInfos implements LevelInfos { /*** Constants ***/ /** String separating the various fields. */ Modified: trunk/src/picross/game/simple/LevelInfos.java =================================================================== --- trunk/src/picross/game/simple/LevelInfos.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/simple/LevelInfos.java 2008-04-29 09:32:57 UTC (rev 71) @@ -36,10 +36,23 @@ import java.awt.Dimension; /** + * Set of informations about a level. + * * @author Y. Norsa */ public interface LevelInfos { + /** + * Returns the level's name. + * + * @return name of the level + */ String getName(); + + /** + * Returns the grid size. + * + * @return size of the grid + */ Dimension getDimension(); } Modified: trunk/src/picross/game/simple/LevelMenuController.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuController.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/simple/LevelMenuController.java 2008-04-29 09:32:57 UTC (rev 71) @@ -35,43 +35,36 @@ import fr.cle.mmvcs.SimpleEvent; -import picross.menus.MenuController; - import org.apache.log4j.Logger; +import picross.menus.MenuController; + /** + * Controller for the level selection menu. + * * @author Y. Norsa */ -class LevelMenuController extends MenuController { - /*** Constante ***/ +final class LevelMenuController extends MenuController { + /*** Constants ***/ + /** Command used when selecting a grid size. */ static final String SIZE_CMD = "SIZE_CMD"; + /** Command used to display a levels list. */ static final String LEVELS_LIST_CMD = "LEVELS_LIST_CMD"; /** Select level command. */ - //static final String SELECT_LEVEL_CMD = "SELECT_LEVEL_CMD"; - static final String LEVEL_CMD = "LEVEL_CMD"; - /*** Champ statique ***/ + /*** Static field ***/ + /** The class' logger. */ private static Logger log = Logger.getLogger(LevelMenuController.class); - /*** Champ ***/ + /*** Method overloaded from the class LevelMenuController ***/ - /*** Constructeur ***/ - - /** - * Constructeur. - */ - /* - LevelMenuController() { - } - */ - - /*** M\xE9thode ***/ - + /** {@inheritDoc} */ + @Override public void eventPerformed(SimpleEvent e) { LevelMenuController.log.debug("eventPerformed(" + e + ")"); @@ -83,7 +76,8 @@ if (cmd.equals(LevelMenuController.LEVELS_LIST_CMD)) { LevelsListCommand command = (LevelsListCommand) e.getCommand(); - ((LevelMenuUI) this.getView()).displayLevels(this, command.getList()); + ((LevelMenuUI) this.getView()).displayLevels(this, + command.getList()); return; } Modified: trunk/src/picross/game/simple/LevelMenuMediator.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuMediator.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/simple/LevelMenuMediator.java 2008-04-29 09:32:57 UTC (rev 71) @@ -42,6 +42,8 @@ import picross.PicrossException; import picross.PicrossUI; +import picross.game.GameCommand; + import picross.menus.MenuController; import picross.menus.MenuMediator; import picross.menus.MenuUI; @@ -51,27 +53,21 @@ * * @author Y. Norsa */ -public class LevelMenuMediator extends MenuMediator { +public final class LevelMenuMediator extends MenuMediator { + /*** Static field ***/ + + /** The class' logger. */ private static Logger log = Logger.getLogger(LevelMenuMediator.class); + /*** Field ***/ + + /** Model containing the levels list. */ private LevelMenuModel model = null; - /*** Constructor ***/ + /*** Methods overloaded from the class MenuMediator ***/ - /** - * Constructor. - * - * @param ui reference to the main UI - * @throws PicrossException if the instantiation of the view fails - */ - /* - public LevelMenuMediator(PicrossUI ui) throws PicrossException { - super(ui); - } - */ - - /*** Method overloaded from the class MenuMediator ***/ - + /** {@inheritDoc} */ + @Override protected MenuController initController() { MenuController controller = new LevelMenuController(); this.addSimpleListener(controller); @@ -91,10 +87,11 @@ LevelMenuMediator.log.debug("this : " + this); LevelMenuMediator.log.debug("this.model : " + this.model); - //return new LevelMenuUI(controller, model.getLevelsList()); return new LevelMenuUI(controller, this.model.getSizesList()); } + /** {@inheritDoc} */ + @Override public void eventPerformed(SimpleEvent e) { LevelMenuMediator.log.debug("eventPerformed(" + e + ")"); LevelMenuMediator.log.debug("this : " + this); @@ -110,13 +107,23 @@ } if (cmd.equals(LevelMenuController.LEVEL_CMD)) { - this.fireEventPerformed(new picross.game.GameCommand(new picross.game.simple.SimpleGameMediator(e.getComment()))); + String level = e.getComment(); + this.fireEventPerformed(new + GameCommand(new + SimpleGameMediator(level))); return; } super.eventPerformed(e); } + /*** Method ***/ + + /** + * Sends a message asking to display the levels list. + * + * @param levels the levels list + */ private void displayLevels(List<String> levels) { this.fireEventPerformed(new LevelsListCommand(levels)); } Modified: trunk/src/picross/game/simple/LevelMenuModel.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuModel.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/simple/LevelMenuModel.java 2008-04-29 09:32:57 UTC (rev 71) @@ -47,14 +47,12 @@ import picross.Picross; import picross.PicrossException; -import picross.game.simple.LevelInfos; - /** * Model for the level selection menu. * * @author Y. Norsa */ -class LevelMenuModel { +final class LevelMenuModel { /*** Constant ***/ /** File containing the data files list. */ @@ -62,9 +60,7 @@ /*** Field ***/ - /** Level list. */ - //private List<String> levels; - + /** Levels list. */ private Map<Dimension, List<String>> levels; /*** Constructor ***/ @@ -80,8 +76,6 @@ List<LevelInfos> infos = null; try { - //this.levels = Picross.listDataFiles(); - //infos = Picross.listDataFiles(); infos = LevelMenuModel.listDataFiles(); } catch (IOException ioEx) { throw new PicrossException(ioEx); @@ -108,7 +102,7 @@ * @return informations about the available levels * @throws IOException if a problem occurs during the operation */ - public static List<LevelInfos> listDataFiles() throws IOException { + private static List<LevelInfos> listDataFiles() throws IOException { List<LevelInfos> list = new ArrayList<LevelInfos>(); BufferedReader in = null; @@ -134,19 +128,25 @@ return list; } - /*** Method ***/ + /*** Methods ***/ /** - * Returns the levels list. + * Returns the available sizes list. * - * @return list of the level files + * @return list of all the grid sizes */ + List<Dimension> getSizesList() { + return new ArrayList<Dimension>(this.levels.keySet()); + } + + /** + * Returns the list of levels for this size. + * + * @param size desired grid size + * @return list of the corresponding level files + */ List<String> getLevels(Dimension size) { return this.levels.get(size); } - - List<Dimension> getSizesList() { - return new ArrayList<Dimension>(this.levels.keySet()); - } } Modified: trunk/src/picross/game/simple/LevelMenuUI.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuUI.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/simple/LevelMenuUI.java 2008-04-29 09:32:57 UTC (rev 71) @@ -40,8 +40,6 @@ import java.util.List; -import picross.PicrossController; - import picross.menus.MenuUI; /** @@ -49,7 +47,7 @@ * * @author Y. Norsa */ -class LevelMenuUI extends MenuUI { +final class LevelMenuUI extends MenuUI { /*** Constant ***/ /** Serialisation ID. */ @@ -63,22 +61,18 @@ * @param listener listener for the buttons * @param sizes available grid sizes */ - //LevelMenuUI(SimpleListener listener, List<String> levels) { LevelMenuUI(SimpleListener listener, List<Dimension> sizes) { super(); int x = 150; int y = 150; - //int nbSizes = sizes.size(); - - //for (int i = 0; i < nbSizes; i++) { - //Dimension currentDim = sizes.get(i); for (Dimension currentDim : sizes) { String size = (int) currentDim.getWidth() + "x" + (int) currentDim.getHeight(); - SimpleEvent event = new SimpleEvent(new SelectSizeCommand(currentDim)); + SimpleEvent event = + new SimpleEvent(new SelectSizeCommand(currentDim)); this.addSimpleButton(size, event, listener, x, y); y += 75; @@ -90,6 +84,14 @@ } } + /*** Method ***/ + + /** + * Displays the levels list. + * + * @param listener listener for the buttons + * @param levels levels to display + */ void displayLevels(SimpleListener listener, List<String> levels) { this.removeAll(); @@ -97,7 +99,8 @@ int y = 150; for (String level : levels) { - SimpleEvent event = new SimpleEvent(LevelMenuController.LEVEL_CMD, level); + SimpleEvent event = + new SimpleEvent(LevelMenuController.LEVEL_CMD, level); this.addSimpleButton(level, event, listener, x, y); y += 75; Modified: trunk/src/picross/game/simple/LevelsListCommand.java =================================================================== --- trunk/src/picross/game/simple/LevelsListCommand.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/simple/LevelsListCommand.java 2008-04-29 09:32:57 UTC (rev 71) @@ -38,21 +38,22 @@ import java.util.List; /** + * Command containing a levels list. + * * @author Y. Norsa */ -class LevelsListCommand extends NamedCommand { - /*** Constante ***/ +final class LevelsListCommand extends NamedCommand { + /*** Field ***/ - /*** Champ statique ***/ - - /*** Champ ***/ - + /** List of levels' names. */ private List<String> list; - /*** Constructeur ***/ + /*** Constructor ***/ /** - * Constructeur. + * Constructor. + * + * @param levels levels' names */ LevelsListCommand(List<String> levels) { super(LevelMenuController.LEVELS_LIST_CMD); @@ -60,8 +61,13 @@ this.list = levels; } - /*** M\xE9thode ***/ + /*** Accessor ***/ + /** + * Return the levels list. + * + * @return list of the levels + */ List<String> getList() { return this.list; } Modified: trunk/src/picross/game/simple/SelectSizeCommand.java =================================================================== --- trunk/src/picross/game/simple/SelectSizeCommand.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/simple/SelectSizeCommand.java 2008-04-29 09:32:57 UTC (rev 71) @@ -38,21 +38,22 @@ import java.awt.Dimension; /** + * Command used when a grid size has been selected. + * * @author Y. Norsa */ -class SelectSizeCommand extends NamedCommand { - /*** Constante ***/ +final class SelectSizeCommand extends NamedCommand { + /*** Field ***/ - /*** Champ statique ***/ - - /*** Champ ***/ - + /** The selected grid size. */ private Dimension size; - /*** Constructeur ***/ + /*** Constructor ***/ /** - * Constructeur. + * Constructor. + * + * @param dim grid size */ SelectSizeCommand(Dimension dim) { super(LevelMenuController.SIZE_CMD); @@ -60,8 +61,13 @@ this.size = dim; } - /*** M\xE9thode ***/ + /*** Accessor ***/ + /** + * Returns the grid size. + * + * @return selected grid size + */ Dimension getSize() { return this.size; } Modified: trunk/src/picross/game/simple/SimpleGameMediator.java =================================================================== --- trunk/src/picross/game/simple/SimpleGameMediator.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/simple/SimpleGameMediator.java 2008-04-29 09:32:57 UTC (rev 71) @@ -47,6 +47,9 @@ * @author Y. Norsa */ public final class SimpleGameMediator extends GameMediator { + /*** Field ***/ + + /** Level to load. */ private String level; /*** Constructor ***/ @@ -54,19 +57,18 @@ /** * Constructor. * - * @throws PicrossException if there is a problem loading the grid model - * or building the view + * @param levelName name of the level */ - public SimpleGameMediator(String levelName) {//throws PicrossException { - //super(); + public SimpleGameMediator(String levelName) { + super(); this.level = levelName; - //this.init(); } /*** Method overloaded from the class GameMediator ***/ /** {@inheritDoc} */ + @Override protected PicrossGrid initModel() throws PicrossException { try { return new XBMModel(Picross.loadDataFile(this.level)); Modified: trunk/src/picross/game/simple/SimpleGameMode.java =================================================================== --- trunk/src/picross/game/simple/SimpleGameMode.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/game/simple/SimpleGameMode.java 2008-04-29 09:32:57 UTC (rev 71) @@ -37,20 +37,23 @@ import fr.cle.mmvcs.SimpleEvent; +import javax.swing.ImageIcon; +import javax.swing.JButton; + import picross.Picross; import picross.game.GameMode; +import picross.menus.MenuCommand; import picross.menus.PicrossButton; -import javax.swing.ImageIcon; -import javax.swing.JButton; - /** + * Simple game mode. + * * @author Y. Norsa */ -public class SimpleGameMode implements GameMode { - /*** Constante ***/ +public final class SimpleGameMode implements GameMode { + /*** Constant ***/ /** Image for the "select" button. */ private static final String SELECT_BUTTON_IMAGE = "button-select.png"; @@ -61,30 +64,17 @@ /** "Select" button Y coordinate. */ private static final int SELECT_BUTTON_Y = 250; - /*** Champ statique ***/ + /*** Method implanted from the interface GameMode ***/ - /*** Champ ***/ - - /*** Constructeur ***/ - - /** - * Constructeur. - */ - /* - SimpleGameMode() { - } - */ - - /*** M\xE9thode ***/ - + /** {@inheritDoc} */ + @Override public SimpleButton<JButton> getButton() { ImageIcon icon = Picross.getLocalizedImage(SimpleGameMode.SELECT_BUTTON_IMAGE); - SimpleEvent event = new SimpleEvent(new picross.menus.MenuCommand(LevelMenuMediator.class)); - /*PicrossButton button = */return new PicrossButton(icon, event); - //button.getButton().setIcon(icon); + SimpleEvent event = + new SimpleEvent(new MenuCommand(LevelMenuMediator.class)); - //return button; + return new PicrossButton(icon, event); } } Modified: trunk/src/picross/grid/CompletedHints.java =================================================================== --- trunk/src/picross/grid/CompletedHints.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/grid/CompletedHints.java 2008-04-29 09:32:57 UTC (rev 71) @@ -41,7 +41,7 @@ * * @author Y. Norsa */ -class CompletedHints { +final class CompletedHints { /*** Fields ***/ /** List of completed column hints. */ Modified: trunk/src/picross/grid/FillCommand.java =================================================================== --- trunk/src/picross/grid/FillCommand.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/grid/FillCommand.java 2008-04-29 09:32:57 UTC (rev 71) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2008 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -89,6 +89,7 @@ /*** Method overloaded from the class Command ***/ /** {@inheritDoc} */ + @Override public String toString() { return this.row + "," + this.column; } Modified: trunk/src/picross/grid/GridAction.java =================================================================== --- trunk/src/picross/grid/GridAction.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/grid/GridAction.java 2008-04-29 09:32:57 UTC (rev 71) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2008 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -34,26 +34,18 @@ package picross.grid; /** + * Enumerates the possible actions on the grid. + * * @author Y. Norsa */ enum GridAction { - /*** Constante ***/ - - /*** Champ statique ***/ - - /*** Champ ***/ - - /*** Constructeur ***/ - - /** - * Constructeur. - */ - /* - */ - - /*** M\xE9thode ***/ + /** Unrecognized action. */ UNKNOWN, + + /** Checking a box. */ CHECK, + + /** Crossing a box. */ CROSS } Modified: trunk/src/picross/grid/GridController.java =================================================================== --- trunk/src/picross/grid/GridController.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/grid/GridController.java 2008-04-29 09:32:57 UTC (rev 71) @@ -94,6 +94,7 @@ /*** Method overloaded from the class Controller ***/ /** {@inheritDoc} */ + @Override public void eventPerformed(SimpleEvent e) { //GridController.log.debug("eventPerformed(" + e + ")"); @@ -127,12 +128,15 @@ /*** Methods implanted from the interface MouseListener ***/ /** {@inheritDoc} */ + @Override public void mouseClicked(MouseEvent e) { } /** {@inheritDoc} */ + @Override public void mouseEntered(MouseEvent e) { } /** {@inheritDoc} */ + @Override public void mouseExited(MouseEvent e) { //GridController.log.debug("mouseExited()"); this.view.rolloverEnded(); @@ -140,11 +144,13 @@ } /** {@inheritDoc} */ + @Override public void mousePressed(MouseEvent e) { this.view.rolloverEnded(); } /** {@inheritDoc} */ + @Override public void mouseReleased(MouseEvent e) { //GridController.log.debug("mouseReleased()"); this.checkAndFill(e); @@ -154,11 +160,13 @@ /*** Methods implanted from the interface MouseMotionListener ***/ /** {@inheritDoc} */ + @Override public void mouseDragged(MouseEvent e) { this.checkAndFill(e); } /** {@inheritDoc} */ + @Override public void mouseMoved(MouseEvent e) { //GridController.log.debug(e.getPoint()); Modified: trunk/src/picross/grid/GridMediator.java =================================================================== --- trunk/src/picross/grid/GridMediator.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/grid/GridMediator.java 2008-04-29 09:32:57 UTC (rev 71) @@ -87,7 +87,7 @@ final Box[][] boxes = this.model.getBoxes(); final int[][] colData = this.model.getColData(); - final int[][] rowData = this.model.getRowData(); + final int[][] rowData = this.model.getRowData(); final CompletedHints hints = this.model.getCompletedHints(); try { @@ -119,6 +119,7 @@ /*** Method overloaded from the class Mediateur ***/ /** {@inheritDoc} */ + @Override public void eventPerformed(SimpleEvent e) { //GridMediator.log.debug("eventPerformed(" + e + ")"); Modified: trunk/src/picross/grid/GridModel.java =================================================================== --- trunk/src/picross/grid/GridModel.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/grid/GridModel.java 2008-04-29 09:32:57 UTC (rev 71) @@ -94,33 +94,7 @@ throws IllegalArgumentException { GridModel.checkModelParams(mediator, data); - /* - if (mediator == null) { - throw new IllegalArgumentException("mediator cannot be null"); - } - if (data == null) { - throw new IllegalArgumentException("data cannot be null"); - } - - if (data.length == 0) { - throw new IllegalArgumentException("data cannot be empty"); - } - - int expectedSize = data[0].length; - - if (expectedSize == 0) { - throw new IllegalArgumentException("data cannot be empty"); - } - - for (int i = 0; i < data.length; i++) { - if (data[i].length == 0 || data[i].length != expectedSize) { - throw new IllegalArgumentException("data[i].length " - + "is supposed to be " - + expectedSize); - } - } - */ this.mediator = mediator; this.data = data; @@ -133,139 +107,8 @@ } this.colData = GridModel.getColHints(this.data); - /* - // Grid of columns hints - List<List<Integer>> colHints = new ArrayList<List<Integer>>(); + this.rowData = GridModel.getRowHints(this.data); - // Largest number of hints for a column - int max = 0; - - for (boolean[] col : data) { - List<Integer> current = new ArrayList<Integer>(); - - // Current hint - int chain = 0; - - for (boolean cell : col) { - if (cell) { - chain++; - } else if (chain > 0) { - // We've reached the end of a series of checked boxes - current.add(chain); - chain = 0; - } - } - - if (chain > 0) { - current.add(chain); - } else if (current.size() == 0) { - // If this column is empty, we add a "0" hint - current.add(0); - } - - int currentSize = current.size(); - - if (currentSize > max) { - max = currentSize; - } - - colHints.add(current); - } -*/ - /* - * Final array containing the hints, in the following form : - * - * 1 - * 0 2 1 - * - * Which corresponds to the following grid : - * - * |-----| - * |_|X|_| - * |_|_|X| - * |_|X|_| - * |_|X|_| - * |-----| - */ - /* - this.colData = new int[data.length][max]; - - for (int i = 0; i < max; i++) { - // Minimal number of hints for the current column to be considered - int ref = max - i; - - // Current hint row - int currentRow = ref - 1; - - for (int j = 0; j < colHints.size(); j++) { - List<Integer> currentCol = colHints.get(j); - int size = currentCol.size(); - - if (size >= ref) { - this.colData[j][currentRow] = currentCol.get(size - ref); - } else { - this.colData[j][currentRow] = GridModel.EMPTY_HINT; - } - } - } -*/ - - this.rowData = GridModel.getRowHints(data); - /* - // Same operations as for the columns, basically - - List<List<Integer>> rowHints = new ArrayList<List<Integer>>(); - int max = 0; - - 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++) { - if (data[j][i]) { - chain++; - } else if (chain > 0) { - current.add(chain); - chain = 0; - } - } - - if (chain > 0) { - current.add(chain); - } else if (current.size() == 0) { - current.add(0); - } - - int currentSize = current.size(); - - if (currentSize > max) { - max = currentSize; - } - - rowHints.add(current); - } - - this.rowData = new int[data[0].length][max]; - int nbRows = rowHints.size(); - - for (int i = 0; i < max; i++) { - int ref = max - i; - - for (int j = 0; j < nbRows; j++) { - List<Integer> currentRow = rowHints.get(j); - int size = currentRow.size(); - - if (size >= ref) { - this.rowData[j][i] = - currentRow.get(i - Math.abs(size - max)); - } else { - this.rowData[j][i] = GridModel.EMPTY_HINT; - } - } - } - */ - this.completedHints = new CompletedHints(data.length, this.colData[0].length, data[0].length, this.rowData[0].length); @@ -287,7 +130,17 @@ /*** Static methods ***/ - private static void checkModelParams(IGridMediator mediator, boolean[][] data) { + /** + * Checks the model parameters. + * + * @param mediator the grid mediator + * @param data the grid data + * @throws IllegalArgumentException if <code>mediator</code> + * or <code>data</code> is <code>null</code>, or if <code>data</code> + * is empty, or if the content of <code>data</code> hasn't a constant size + */ + private static void checkModelParams(IGridMediator mediator, + boolean[][] data) { if (mediator == null) { throw new IllegalArgumentException("mediator cannot be null"); } @@ -315,6 +168,12 @@ } } + /** + * Extracts the column hints from the grid data. + * + * @param data the grid data + * @return column hints + */ private static int[][] getColHints(boolean[][] data) { // Grid of columns hints List<List<Integer>> colHints = new ArrayList<List<Integer>>(); @@ -393,6 +252,12 @@ return result; } + /** + * Extracts the row hints from the grid data. + * + * @param data the grid data + * @return row hints + */ private static int[][] getRowHints(boolean[][] data) { List<List<Integer>> rowHints = new ArrayList<List<Integer>>(); int max = 0; @@ -513,7 +378,6 @@ * @throws IllegalArgumentException if <code>row</code> or * <code>column</code> is less than 0 */ - //void checkBox(int row, int column, int type) { void actOnBox(int row, int column, GridAction type) throws IllegalArgumentException { Modified: trunk/src/picross/grid/GridUI.java =================================================================== --- trunk/src/picross/grid/GridUI.java 2008-04-28 13:30:53 UTC (rev 70) +++ trunk/src/picross/grid/GridUI.java 2008-04-29 09:32:57 UTC (rev 71) @@ -151,20 +151,10 @@ /** Position of the bottom end of the grid. */ private int bottomBoundary; - /** Rectangles occupied by the top hints. */ - //private Rectangle[] topHintsRects; - - /** Precomputed images containing the top hints boxes. */ - //private transient BufferedImage[] topHintsBoxes; - + /** Top hints boxes. */ private transient HintBoxInfos[] topHints; - /** Rectangles occupied by the left hints. */ - //private Rectangle[] leftHintsRects; - - /** Precomputed images containing the left hints boxes. */ - //private transient BufferedImage[] leftHintsBoxes; - + /** Left hints boxes. */ private transient HintBoxInfos[] leftHints; /** Current state of the grid. */ @@ -206,6 +196,12 @@ /** List of completed hints. */ private transient CompletedHints completedHints; + /** Index of the currently highlighted row. */ + private int rolloverRow = -1; + + /** Index of the currently highlighted column. */ + private int rolloverColumn = -1; + /*** Constructor ***/ /** @@ -250,6 +246,7 @@ /*** Method overloaded from JPanel ***/ /** {@inheritDoc} */ + @Override protected void paintComponent(Graphics g) { super.paintComponent(g); @@ -257,17 +254,13 @@ Rectangle clipRect = newG.getClipBounds(); - //for (int i = 0; i < this.topHintsRects.length; i++) { for (int i = 0; i < this.topHints.length; i++) { - //if (this.topHintsRects[i].intersects(clipRect)) { if (this.topHints[i].intersects(clipRect)) { this.drawTopHints(newG, i); } } - //for (int i = 0; i < this.leftHintsRects.length; i++) { for (int i = 0; i < this.leftHints.length; i++) { - //if (this.leftHintsRects[i].intersects(clipRect)) { if (this.leftHints[i].intersects(clipRect)) { this.drawLeftHints(newG, i); } @@ -349,34 +342,26 @@ + (this.height * GridUI.BOX_HEIGHT); // Space occupied by the hints - //this.topHintsRects = new Rectangle[this.width]; this.topHints = new HintBoxInfos[this.width]; - //for (int i = 0; i < this.topHintsRects.length; i++) { for (int i = 0; i < this.topHints.length; i++) { this.topHints[i] = new HintBoxInfos(); - //this.topHintsRects[i] = - this.topHints[i].setRect( - new Rectangle(this.leftBoundary + (i * GridUI.BOX_WIDTH), 0, - GridUI.BOX_WIDTH, this.topBoundary) - ) - ; + this.topHints[i].setRect(new Rectangle(this.leftBoundary + + (i * GridUI.BOX_WIDTH), 0, + GridUI.BOX_WIDTH, + this.topBoundary)); } - //this.leftHintsRects = new Rectangle[this.height]... [truncated message content] |
From: <yva...@us...> - 2008-04-28 13:33:02
|
Revision: 70 http://picross.svn.sourceforge.net/picross/?rev=70&view=rev Author: yvan_norsa Date: 2008-04-28 06:30:53 -0700 (Mon, 28 Apr 2008) Log Message: ----------- game modes separation Modified Paths: -------------- trunk/src/picross/Picross.java trunk/src/picross/PicrossController.java trunk/src/picross/PicrossMediator.java trunk/src/picross/game/random/RandomGameController.java trunk/src/picross/game/random/RandomGameMediator.java trunk/src/picross/game/random/RandomGameMode.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 Modified: trunk/src/picross/Picross.java =================================================================== --- trunk/src/picross/Picross.java 2008-04-28 13:12:16 UTC (rev 69) +++ trunk/src/picross/Picross.java 2008-04-28 13:30:53 UTC (rev 70) @@ -33,11 +33,9 @@ package picross; -import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.net.URL; @@ -49,8 +47,8 @@ //import org.apache.log4j.Logger; -import picross.game.simple.FileInfos; -import picross.game.simple.LevelInfos; +//import picross.game.simple.FileInfos; +//import picross.game.simple.LevelInfos; /** * Helper class. @@ -66,9 +64,6 @@ /** Data directory. */ private static final String DATA_DIR = "/picross/data/"; - /** File containing the data files list. */ - private static final String DATA_LIST = "contents.txt"; - /** Images directory corresponding to the default locale. */ private static final String LOCAL_IMAGES_PATH = Picross.IMAGES_DIR + Locale.getDefault().getLanguage() + "/"; @@ -168,37 +163,5 @@ return Picross.getFile(Picross.DATA_DIR + name).openStream(); } - - /** - * Reads the data files list and returns informations about the levels. - * - * @return informations about the available levels - * @throws IOException if a problem occurs during the operation - */ - public static List<LevelInfos> listDataFiles() throws IOException { - List<LevelInfos> list = new ArrayList<LevelInfos>(); - - BufferedReader in = null; - - try { - in = new - BufferedReader(new - InputStreamReader(Picross - .loadDataFile(Picross - .DATA_LIST))); - - String line = null; - - while ((line = in.readLine()) != null) { - list.add(FileInfos.readFileInfos(line)); - } - } catch (IOException ioEx) { - throw ioEx; - } finally { - in.close(); - } - - return list; - } } Modified: trunk/src/picross/PicrossController.java =================================================================== --- trunk/src/picross/PicrossController.java 2008-04-28 13:12:16 UTC (rev 69) +++ trunk/src/picross/PicrossController.java 2008-04-28 13:30:53 UTC (rev 70) @@ -50,14 +50,14 @@ public static final String PLAY_CMD = "PLAY_CMD"; /** Random game command. */ - public static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD"; + //public static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD"; - public static final String NEXT_RANDOM_GAME_CMD = "NEXT_RANDOM_GAME_CMD"; + //public static final String NEXT_RANDOM_GAME_CMD = "NEXT_RANDOM_GAME_CMD"; /** Select level command. */ - public static final String SELECT_LEVEL_CMD = "SELECT_LEVEL_CMD"; + //public static final String SELECT_LEVEL_CMD = "SELECT_LEVEL_CMD"; - public static final String LEVEL_CMD = "LEVEL_CMD"; + //public static final String LEVEL_CMD = "LEVEL_CMD"; /** Exit command. */ public static final String EXIT_CMD = "EXIT_CMD"; Modified: trunk/src/picross/PicrossMediator.java =================================================================== --- trunk/src/picross/PicrossMediator.java 2008-04-28 13:12:16 UTC (rev 69) +++ trunk/src/picross/PicrossMediator.java 2008-04-28 13:30:53 UTC (rev 70) @@ -47,7 +47,7 @@ import picross.game.GameCommand; import picross.game.GameMediator; -import picross.game.random.RandomGameMediator; +//import picross.game.random.RandomGameMediator; //import picross.game.simple.SimpleGameMediator; @@ -76,6 +76,8 @@ /** Main view. */ private PicrossUI view; + private boolean firstTime = true; + /*** Constructor ***/ /** Constructor. */ @@ -116,11 +118,12 @@ } */ - // FIXME doesn't belong here + /* if (cmd.equals(PicrossController.NEXT_RANDOM_GAME_CMD)) { this.startRandomGame(); return; } + */ /* if (cmd.equals(PicrossController.SELECT_LEVEL_CMD)) { @@ -145,7 +148,10 @@ } if (cmd.equals(GameCommand.GAME_CMD)) { - this.displayWaitScreen(); + if (this.firstTime) { + this.displayWaitScreen(); + this.firstTime = false; + } GameCommand command = (GameCommand) e.getCommand(); this.startGame(command.getGame()); @@ -244,7 +250,8 @@ worker.start(); } - /** Starts a random game. */ + /** Starts a random game. * + /* private void startRandomGame() { Thread worker = new Thread() { public void run() { @@ -264,7 +271,7 @@ worker.start(); } - + */ /** Starts a new game. */ /* private void startGame(final String level) { Modified: trunk/src/picross/game/random/RandomGameController.java =================================================================== --- trunk/src/picross/game/random/RandomGameController.java 2008-04-28 13:12:16 UTC (rev 69) +++ trunk/src/picross/game/random/RandomGameController.java 2008-04-28 13:30:53 UTC (rev 70) @@ -52,6 +52,11 @@ /** Command asking to create another grid. */ static final String NEXT_CMD = "NEXT_CMD"; + /** Random game command. */ + /*public */static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD"; + + //public static final String NEXT_RANDOM_GAME_CMD = "NEXT_RANDOM_GAME_CMD"; + /*** Static field ***/ /** The class' logger. */ Modified: trunk/src/picross/game/random/RandomGameMediator.java =================================================================== --- trunk/src/picross/game/random/RandomGameMediator.java 2008-04-28 13:12:16 UTC (rev 69) +++ trunk/src/picross/game/random/RandomGameMediator.java 2008-04-28 13:30:53 UTC (rev 70) @@ -65,11 +65,12 @@ * @throws PicrossException if there is a problem loading the grid model * or building the view */ + /* public RandomGameMediator() {//throws PicrossException { //super(); //this.init(); } - + */ /*** Methods overloaded from the class GameMediator ***/ /** {@inheritDoc} */ @@ -93,7 +94,9 @@ String cmd = e.getCommandName(); if (cmd.equals(RandomGameController.NEXT_CMD)) { - this.fireEventPerformed(PicrossController.NEXT_RANDOM_GAME_CMD); + //this.fireEventPerformed(RandomGameController.NEXT_RANDOM_GAME_CMD); + this.fireEventPerformed(RandomGameMode.getRandomGameCommand()); + return; } Modified: trunk/src/picross/game/random/RandomGameMode.java =================================================================== --- trunk/src/picross/game/random/RandomGameMode.java 2008-04-28 13:12:16 UTC (rev 69) +++ trunk/src/picross/game/random/RandomGameMode.java 2008-04-28 13:30:53 UTC (rev 70) @@ -42,6 +42,7 @@ import picross.Picross; +import picross.game.GameCommand; import picross.game.GameMode; import picross.menus.PicrossButton; @@ -76,9 +77,13 @@ */ /*** M\xE9thode ***/ + public static GameCommand getRandomGameCommand() { + return new GameCommand(new RandomGameMediator()); + } + public SimpleButton<JButton> getButton() { ImageIcon icon = Picross.getLocalizedImage(RandomGameMode.RANDOM_BUTTON_IMAGE); - SimpleEvent event = new SimpleEvent(new picross.game.GameCommand(new RandomGameMediator())); + SimpleEvent event = new SimpleEvent(RandomGameMode.getRandomGameCommand()); /*PicrossButton button = */return new PicrossButton(icon, event); //button.getButton().setIcon(icon); Modified: trunk/src/picross/game/simple/LevelMenuController.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuController.java 2008-04-28 13:12:16 UTC (rev 69) +++ trunk/src/picross/game/simple/LevelMenuController.java 2008-04-28 13:30:53 UTC (rev 70) @@ -49,6 +49,11 @@ static final String LEVELS_LIST_CMD = "LEVELS_LIST_CMD"; + /** Select level command. */ + //static final String SELECT_LEVEL_CMD = "SELECT_LEVEL_CMD"; + + static final String LEVEL_CMD = "LEVEL_CMD"; + /*** Champ statique ***/ private static Logger log = Logger.getLogger(LevelMenuController.class); Modified: trunk/src/picross/game/simple/LevelMenuMediator.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuMediator.java 2008-04-28 13:12:16 UTC (rev 69) +++ trunk/src/picross/game/simple/LevelMenuMediator.java 2008-04-28 13:30:53 UTC (rev 70) @@ -109,7 +109,7 @@ return; } - if (cmd.equals(picross.PicrossController.LEVEL_CMD)) { + if (cmd.equals(LevelMenuController.LEVEL_CMD)) { this.fireEventPerformed(new picross.game.GameCommand(new picross.game.simple.SimpleGameMediator(e.getComment()))); return; } Modified: trunk/src/picross/game/simple/LevelMenuModel.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuModel.java 2008-04-28 13:12:16 UTC (rev 69) +++ trunk/src/picross/game/simple/LevelMenuModel.java 2008-04-28 13:30:53 UTC (rev 70) @@ -35,7 +35,9 @@ import java.awt.Dimension; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; @@ -53,6 +55,11 @@ * @author Y. Norsa */ class LevelMenuModel { + /*** Constant ***/ + + /** File containing the data files list. */ + private static final String DATA_LIST = "contents.txt"; + /*** Field ***/ /** Level list. */ @@ -74,7 +81,8 @@ try { //this.levels = Picross.listDataFiles(); - infos = Picross.listDataFiles(); + //infos = Picross.listDataFiles(); + infos = LevelMenuModel.listDataFiles(); } catch (IOException ioEx) { throw new PicrossException(ioEx); } @@ -92,6 +100,40 @@ } } + /*** Static method ***/ + + /** + * Reads the data files list and returns informations about the levels. + * + * @return informations about the available levels + * @throws IOException if a problem occurs during the operation + */ + public static List<LevelInfos> listDataFiles() throws IOException { + List<LevelInfos> list = new ArrayList<LevelInfos>(); + + BufferedReader in = null; + + try { + in = new + BufferedReader(new + InputStreamReader(Picross + .loadDataFile(LevelMenuModel + .DATA_LIST))); + + String line = null; + + while ((line = in.readLine()) != null) { + list.add(FileInfos.readFileInfos(line)); + } + } catch (IOException ioEx) { + throw ioEx; + } finally { + in.close(); + } + + return list; + } + /*** Method ***/ /** Modified: trunk/src/picross/game/simple/LevelMenuUI.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuUI.java 2008-04-28 13:12:16 UTC (rev 69) +++ trunk/src/picross/game/simple/LevelMenuUI.java 2008-04-28 13:30:53 UTC (rev 70) @@ -97,7 +97,7 @@ int y = 150; for (String level : levels) { - SimpleEvent event = new SimpleEvent(PicrossController.LEVEL_CMD, level); + SimpleEvent event = new SimpleEvent(LevelMenuController.LEVEL_CMD, level); this.addSimpleButton(level, event, listener, x, y); y += 75; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-04-28 13:12:16
|
Revision: 69 http://picross.svn.sourceforge.net/picross/?rev=69&view=rev Author: yvan_norsa Date: 2008-04-28 06:12:16 -0700 (Mon, 28 Apr 2008) Log Message: ----------- code clean-up Modified Paths: -------------- trunk/src/picross/Picross.java trunk/src/picross/game/simple/LevelMenuModel.java Added Paths: ----------- trunk/src/picross/game/simple/FileInfos.java trunk/src/picross/game/simple/LevelInfos.java Removed Paths: ------------- trunk/src/picross/game/simple/FileInfo.java trunk/src/picross/game/simple/LevelInfo.java Modified: trunk/src/picross/Picross.java =================================================================== --- trunk/src/picross/Picross.java 2008-04-28 12:47:06 UTC (rev 68) +++ trunk/src/picross/Picross.java 2008-04-28 13:12:16 UTC (rev 69) @@ -49,8 +49,8 @@ //import org.apache.log4j.Logger; -import picross.game.simple.FileInfo; -import picross.game.simple.LevelInfo; +import picross.game.simple.FileInfos; +import picross.game.simple.LevelInfos; /** * Helper class. @@ -66,6 +66,9 @@ /** Data directory. */ private static final String DATA_DIR = "/picross/data/"; + /** File containing the data files list. */ + private static final String DATA_LIST = "contents.txt"; + /** Images directory corresponding to the default locale. */ private static final String LOCAL_IMAGES_PATH = Picross.IMAGES_DIR + Locale.getDefault().getLanguage() + "/"; @@ -123,9 +126,7 @@ * is <code>null</code> or empty * @throws MissingImageException if the image file can't be found */ - public static ImageIcon getImage(String name) - throws IllegalArgumentException { - + public static ImageIcon getImage(String name) { if (name == null || name.equals("")) { throw new IllegalArgumentException("name can't be null or empty"); } @@ -142,9 +143,7 @@ * is <code>null</code> or empty * @throws MissingImageException if the image file can't be found */ - public static ImageIcon getLocalizedImage(String name) - throws IllegalArgumentException { - + public static ImageIcon getLocalizedImage(String name) { if (name == null || name.equals("")) { throw new IllegalArgumentException("name can't be null or empty"); } @@ -161,8 +160,7 @@ * is <code>null</code> or empty * @throws IOException if there is a problem while opening the file */ - public static InputStream loadDataFile(String name) - throws IllegalArgumentException, IOException { + public static InputStream loadDataFile(String name) throws IOException { if (name == null || name.equals("")) { throw new IllegalArgumentException("name can't be null or empty"); @@ -171,25 +169,29 @@ return Picross.getFile(Picross.DATA_DIR + name).openStream(); } - //public static List<String> listDataFiles() throws IOException { - public static List<LevelInfo> listDataFiles() throws IOException { - //List<String> list = new ArrayList<String>(); - List<LevelInfo> list = new ArrayList<LevelInfo>(); + /** + * Reads the data files list and returns informations about the levels. + * + * @return informations about the available levels + * @throws IOException if a problem occurs during the operation + */ + public static List<LevelInfos> listDataFiles() throws IOException { + List<LevelInfos> list = new ArrayList<LevelInfos>(); BufferedReader in = null; try { - in = new BufferedReader(new InputStreamReader(Picross.loadDataFile("contents.txt"))); + in = new + BufferedReader(new + InputStreamReader(Picross + .loadDataFile(Picross + .DATA_LIST))); - String line = null; + String line = null; - while ((line = in.readLine()) != null) { - //list.add(line); - String[] lineData = line.split(":"); - String[] sizeData = lineData[1].trim().split("x"); - - list.add(new FileInfo(lineData[0].trim(), Integer.parseInt(sizeData[0]), Integer.parseInt(sizeData[1]))); - } + while ((line = in.readLine()) != null) { + list.add(FileInfos.readFileInfos(line)); + } } catch (IOException ioEx) { throw ioEx; } finally { Deleted: trunk/src/picross/game/simple/FileInfo.java =================================================================== --- trunk/src/picross/game/simple/FileInfo.java 2008-04-28 12:47:06 UTC (rev 68) +++ trunk/src/picross/game/simple/FileInfo.java 2008-04-28 13:12:16 UTC (rev 69) @@ -1,71 +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.simple; - -import java.awt.Dimension; - -/** - * @author Y. Norsa - */ -public class FileInfo implements LevelInfo { - /*** Constante ***/ - - /*** Champ statique ***/ - - /*** Champ ***/ - - private String name; - private Dimension dimension; - - /*** Constructeur ***/ - - /** - * Constructeur. - */ - public FileInfo(String levelName, int width, int height) { - this.name = levelName; - this.dimension = new Dimension(width, height); - } - - /*** M\xE9thode ***/ - - public String getName() { - return this.name; - } - - public Dimension getDimension() { - return this.dimension; - } -} - Copied: trunk/src/picross/game/simple/FileInfos.java (from rev 63, trunk/src/picross/game/simple/FileInfo.java) =================================================================== --- trunk/src/picross/game/simple/FileInfos.java (rev 0) +++ trunk/src/picross/game/simple/FileInfos.java 2008-04-28 13:12:16 UTC (rev 69) @@ -0,0 +1,116 @@ +/* + * $Id$ + * + * Copyright (c) 2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.game.simple; + +import java.awt.Dimension; + +/** + * Informations about a level file. + * + * @author Y. Norsa + */ +public class FileInfos implements LevelInfos { + /*** Constants ***/ + + /** String separating the various fields. */ + private static final String FIELDS_SEPARATOR = ":"; + + /** String separating the width from the height. */ + private static final String SIZE_SEPARATOR = "x"; + + /*** Fields ***/ + + /** The filename. */ + private String name; + + /** Grid size. */ + private Dimension dimension; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param levelName the filename + * @param dim grid size + */ + public FileInfos(String levelName, Dimension dim) { + this.name = levelName.trim(); + this.dimension = dim; + } + + /*** Static methods ***/ + + /** + * Parses a line to extract level informations. + * + * @param line the line to parse + * @return level informations + */ + public static FileInfos readFileInfos(String line) { + String[] lineData = line.split(FileInfos.FIELDS_SEPARATOR); + + return new FileInfos(lineData[0], + FileInfos.readSize(lineData[1])); + } + + /** + * Parses a line containing the grid size. + * Example : "15x10". + * + * @param sizeString a <code>String</code> describing the grid size + * @return parsed size + */ + private static Dimension readSize(String sizeString) { + String[] sizeData = sizeString.trim().split(FileInfos.SIZE_SEPARATOR); + + return new Dimension(Integer.parseInt(sizeData[0]), + Integer.parseInt(sizeData[1])); + } + + /*** Methods implanted from the interface LevelInfos ***/ + + /** {@inheritDoc} */ + @Override + public String getName() { + return this.name; + } + + /** {@inheritDoc} */ + @Override + public Dimension getDimension() { + return this.dimension; + } +} + Deleted: trunk/src/picross/game/simple/LevelInfo.java =================================================================== --- trunk/src/picross/game/simple/LevelInfo.java 2008-04-28 12:47:06 UTC (rev 68) +++ trunk/src/picross/game/simple/LevelInfo.java 2008-04-28 13:12:16 UTC (rev 69) @@ -1,45 +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.simple; - -import java.awt.Dimension; - -/** - * @author Y. Norsa - */ -public interface LevelInfo { - String getName(); - Dimension getDimension(); -} - Copied: trunk/src/picross/game/simple/LevelInfos.java (from rev 63, trunk/src/picross/game/simple/LevelInfo.java) =================================================================== --- trunk/src/picross/game/simple/LevelInfos.java (rev 0) +++ trunk/src/picross/game/simple/LevelInfos.java 2008-04-28 13:12:16 UTC (rev 69) @@ -0,0 +1,45 @@ +/* + * $Id$ + * + * Copyright (c) 2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.game.simple; + +import java.awt.Dimension; + +/** + * @author Y. Norsa + */ +public interface LevelInfos { + String getName(); + Dimension getDimension(); +} + Modified: trunk/src/picross/game/simple/LevelMenuModel.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuModel.java 2008-04-28 12:47:06 UTC (rev 68) +++ trunk/src/picross/game/simple/LevelMenuModel.java 2008-04-28 13:12:16 UTC (rev 69) @@ -45,7 +45,7 @@ import picross.Picross; import picross.PicrossException; -import picross.game.simple.LevelInfo; +import picross.game.simple.LevelInfos; /** * Model for the level selection menu. @@ -70,7 +70,7 @@ LevelMenuModel() throws PicrossException { this.levels = new HashMap<Dimension, List<String>>(); - List<LevelInfo> infos = null; + List<LevelInfos> infos = null; try { //this.levels = Picross.listDataFiles(); @@ -79,7 +79,7 @@ throw new PicrossException(ioEx); } - for (LevelInfo info : infos) { + for (LevelInfos info : infos) { Dimension levelSize = info.getDimension(); List<String> levelsList = this.levels.get(levelSize); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-04-28 12:47:11
|
Revision: 68 http://picross.svn.sourceforge.net/picross/?rev=68&view=rev Author: yvan_norsa Date: 2008-04-28 05:47:06 -0700 (Mon, 28 Apr 2008) Log Message: ----------- findbugs Modified Paths: -------------- trunk/src/picross/Picross.java trunk/src/picross/PicrossMediator.java trunk/src/picross/app/MainMenuAppUI.java trunk/src/picross/app/PicrossApp.java trunk/src/picross/applet/MainMenuAppletUI.java trunk/src/picross/game/random/RandomGameMode.java trunk/src/picross/game/simple/LevelMenuMediator.java trunk/src/picross/game/simple/LevelMenuUI.java trunk/src/picross/game/simple/SimpleGameMode.java trunk/src/picross/grid/GridController.java trunk/src/picross/grid/GridModel.java trunk/src/picross/grid/GridUI.java trunk/src/picross/menus/GameMenuMediator.java trunk/src/picross/menus/MainMenuMediator.java trunk/src/picross/menus/MainMenuUI.java trunk/src/picross/menus/MenuMediator.java trunk/src/picross/menus/MenuUI.java trunk/src/picross/menus/WaitMenuMediator.java Added Paths: ----------- trunk/src/picross/grid/HintBoxInfos.java trunk/src/picross/menus/PicrossButton.java Modified: trunk/src/picross/Picross.java =================================================================== --- trunk/src/picross/Picross.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/Picross.java 2008-04-28 12:47:06 UTC (rev 68) @@ -47,7 +47,7 @@ import javax.swing.ImageIcon; -import org.apache.log4j.Logger; +//import org.apache.log4j.Logger; import picross.game.simple.FileInfo; import picross.game.simple.LevelInfo; @@ -73,7 +73,7 @@ /*** Static field ***/ /** The class' logger. */ - private static Logger log = Logger.getLogger(Picross.class); + //private static Logger log = Logger.getLogger(Picross.class); /*** Constructor ***/ Modified: trunk/src/picross/PicrossMediator.java =================================================================== --- trunk/src/picross/PicrossMediator.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/PicrossMediator.java 2008-04-28 12:47:06 UTC (rev 68) @@ -42,14 +42,14 @@ import javax.swing.SwingUtilities; -import org.apache.log4j.Logger; +//import org.apache.log4j.Logger; import picross.game.GameCommand; import picross.game.GameMediator; import picross.game.random.RandomGameMediator; -import picross.game.simple.SimpleGameMediator; +//import picross.game.simple.SimpleGameMediator; import picross.grid.GridController; @@ -69,7 +69,7 @@ /*** Static field ***/ /** Class' logger. */ - private static Logger log = Logger.getLogger(PicrossMediator.class); + //private static Logger log = Logger.getLogger(PicrossMediator.class); /*** Field ***/ @@ -116,6 +116,7 @@ } */ + // FIXME doesn't belong here if (cmd.equals(PicrossController.NEXT_RANDOM_GAME_CMD)) { this.startRandomGame(); return; @@ -198,8 +199,8 @@ try { try { - menu = menuClass.getConstructor(PicrossUI.class) - .newInstance(this.view); + menu = menuClass.getConstructor()//PicrossUI.class) + .newInstance(/*this.view*/); } catch (NoSuchMethodException methodEx) { throw new PicrossException(methodEx); } catch (InstantiationException instantiationEx) { @@ -207,9 +208,12 @@ } catch (IllegalAccessException accessEx) { throw new PicrossException(accessEx); } catch (InvocationTargetException targetEx) { - targetEx.printStackTrace(); - throw (PicrossException) targetEx.getCause(); + //targetEx.printStackTrace(); + //throw (PicrossException) targetEx.getCause(); + throw new PicrossException(targetEx); } + + menu.init(this.view); } catch (PicrossException picrossEx) { this.fireEventPerformed(PicrossController.ERROR_CMD, picrossEx.getMessage()); Modified: trunk/src/picross/app/MainMenuAppUI.java =================================================================== --- trunk/src/picross/app/MainMenuAppUI.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/app/MainMenuAppUI.java 2008-04-28 12:47:06 UTC (rev 68) @@ -79,9 +79,10 @@ * @param controller controller for the buttons * @throws MissingImageException if a button image can't be found */ - public MainMenuAppUI(ActionListener controller) { - super(controller); + protected void init(ActionListener controller) { + super.init(controller); + this.addButton(MainMenuAppUI.EXIT_BUTTON_IMAGE, PicrossController.EXIT_CMD, controller, Modified: trunk/src/picross/app/PicrossApp.java =================================================================== --- trunk/src/picross/app/PicrossApp.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/app/PicrossApp.java 2008-04-28 12:47:06 UTC (rev 68) @@ -78,6 +78,7 @@ /*** Static method ***/ /** Tries to load the debugging tools from debug.jar. */ + @SuppressWarnings("unchecked") private static void setupDebugging() { try { Class managerClass = Class.forName( Modified: trunk/src/picross/applet/MainMenuAppletUI.java =================================================================== --- trunk/src/picross/applet/MainMenuAppletUI.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/applet/MainMenuAppletUI.java 2008-04-28 12:47:06 UTC (rev 68) @@ -66,9 +66,10 @@ * @param controller controller for the buttons * @throws MissingImageException if a button image can't be found */ - public MainMenuAppletUI(ActionListener controller) { - super(controller); + protected void init(ActionListener controller) { + super.init(controller); + this.setBackground(Color.WHITE); } Modified: trunk/src/picross/game/random/RandomGameMode.java =================================================================== --- trunk/src/picross/game/random/RandomGameMode.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/game/random/RandomGameMode.java 2008-04-28 12:47:06 UTC (rev 68) @@ -44,6 +44,8 @@ import picross.game.GameMode; +import picross.menus.PicrossButton; + /** * @author Y. Norsa */ @@ -77,10 +79,10 @@ public SimpleButton<JButton> getButton() { ImageIcon icon = Picross.getLocalizedImage(RandomGameMode.RANDOM_BUTTON_IMAGE); SimpleEvent event = new SimpleEvent(new picross.game.GameCommand(new RandomGameMediator())); - SimpleButton<JButton> button = new SimpleButton<JButton>(null, event) { }; - button.getButton().setIcon(icon); + /*PicrossButton button = */return new PicrossButton(icon, event); + //button.getButton().setIcon(icon); - return button; + //return button; } } Modified: trunk/src/picross/game/simple/LevelMenuMediator.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuMediator.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/game/simple/LevelMenuMediator.java 2008-04-28 12:47:06 UTC (rev 68) @@ -54,7 +54,7 @@ public class LevelMenuMediator extends MenuMediator { private static Logger log = Logger.getLogger(LevelMenuMediator.class); - private LevelMenuModel model; + private LevelMenuModel model = null; /*** Constructor ***/ @@ -64,9 +64,11 @@ * @param ui reference to the main UI * @throws PicrossException if the instantiation of the view fails */ + /* public LevelMenuMediator(PicrossUI ui) throws PicrossException { super(ui); } + */ /*** Method overloaded from the class MenuMediator ***/ @@ -82,13 +84,21 @@ protected MenuUI initView(PicrossUI ui, MenuController controller) throws PicrossException { + LevelMenuMediator.log.debug("initView()"); + this.model = new LevelMenuModel(); + + LevelMenuMediator.log.debug("this : " + this); + LevelMenuMediator.log.debug("this.model : " + this.model); + //return new LevelMenuUI(controller, model.getLevelsList()); return new LevelMenuUI(controller, this.model.getSizesList()); } public void eventPerformed(SimpleEvent e) { LevelMenuMediator.log.debug("eventPerformed(" + e + ")"); + LevelMenuMediator.log.debug("this : " + this); + LevelMenuMediator.log.debug("this.model : " + this.model); String cmd = e.getCommandName(); Modified: trunk/src/picross/game/simple/LevelMenuUI.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuUI.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/game/simple/LevelMenuUI.java 2008-04-28 12:47:06 UTC (rev 68) @@ -61,7 +61,7 @@ * Constructor. * * @param listener listener for the buttons - * @param levels levels list + * @param sizes available grid sizes */ //LevelMenuUI(SimpleListener listener, List<String> levels) { LevelMenuUI(SimpleListener listener, List<Dimension> sizes) { @@ -70,10 +70,11 @@ int x = 150; int y = 150; - int nbSizes = sizes.size(); + //int nbSizes = sizes.size(); - for (int i = 0; i < nbSizes; i++) { - Dimension currentDim = sizes.get(i); + //for (int i = 0; i < nbSizes; i++) { + //Dimension currentDim = sizes.get(i); + for (Dimension currentDim : sizes) { String size = (int) currentDim.getWidth() + "x" + (int) currentDim.getHeight(); Modified: trunk/src/picross/game/simple/SimpleGameMode.java =================================================================== --- trunk/src/picross/game/simple/SimpleGameMode.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/game/simple/SimpleGameMode.java 2008-04-28 12:47:06 UTC (rev 68) @@ -41,6 +41,8 @@ import picross.game.GameMode; +import picross.menus.PicrossButton; + import javax.swing.ImageIcon; import javax.swing.JButton; @@ -79,10 +81,10 @@ ImageIcon icon = Picross.getLocalizedImage(SimpleGameMode.SELECT_BUTTON_IMAGE); SimpleEvent event = new SimpleEvent(new picross.menus.MenuCommand(LevelMenuMediator.class)); - SimpleButton<JButton> button = new SimpleButton<JButton>("", event) { }; - button.getButton().setIcon(icon); + /*PicrossButton button = */return new PicrossButton(icon, event); + //button.getButton().setIcon(icon); - return button; + //return button; } } Modified: trunk/src/picross/grid/GridController.java =================================================================== --- trunk/src/picross/grid/GridController.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/grid/GridController.java 2008-04-28 12:47:06 UTC (rev 68) @@ -42,7 +42,7 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; -import org.apache.log4j.Logger; +//import org.apache.log4j.Logger; /** * Grid controller. @@ -84,7 +84,7 @@ /*** Static field ***/ /** The class' logger. */ - private static Logger log = Logger.getLogger(GridController.class); + //private static Logger log = Logger.getLogger(GridController.class); /*** Field ***/ Modified: trunk/src/picross/grid/GridModel.java =================================================================== --- trunk/src/picross/grid/GridModel.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/grid/GridModel.java 2008-04-28 12:47:06 UTC (rev 68) @@ -36,7 +36,7 @@ import java.util.ArrayList; import java.util.List; -import org.apache.log4j.Logger; +//import org.apache.log4j.Logger; /** * The grid model. @@ -52,7 +52,7 @@ /*** Static field ***/ /** The class' logger. */ - private static Logger log = Logger.getLogger(GridModel.class); + //private static Logger log = Logger.getLogger(GridModel.class); /*** Fields ***/ @@ -93,6 +93,8 @@ GridModel(IGridMediator mediator, boolean[][] data) throws IllegalArgumentException { + GridModel.checkModelParams(mediator, data); + /* if (mediator == null) { throw new IllegalArgumentException("mediator cannot be null"); } @@ -118,7 +120,7 @@ + expectedSize); } } - + */ this.mediator = mediator; this.data = data; @@ -130,6 +132,8 @@ } } + this.colData = GridModel.getColHints(this.data); + /* // Grid of columns hints List<List<Integer>> colHints = new ArrayList<List<Integer>>(); @@ -167,7 +171,7 @@ colHints.add(current); } - +*/ /* * Final array containing the hints, in the following form : * @@ -183,6 +187,7 @@ * |_|X|_| * |-----| */ + /* this.colData = new int[data.length][max]; for (int i = 0; i < max; i++) { @@ -203,11 +208,14 @@ } } } +*/ + this.rowData = GridModel.getRowHints(data); + /* // Same operations as for the columns, basically List<List<Integer>> rowHints = new ArrayList<List<Integer>>(); - max = 0; + int max = 0; for (int i = 0; i < data[0].length; i++) { List<Integer> current = new ArrayList<Integer>(); @@ -256,6 +264,7 @@ } } } + */ this.completedHints = new CompletedHints(data.length, this.colData[0].length, @@ -278,6 +287,167 @@ /*** Static methods ***/ + private static void checkModelParams(IGridMediator mediator, boolean[][] data) { + if (mediator == null) { + throw new IllegalArgumentException("mediator cannot be null"); + } + + if (data == null) { + throw new IllegalArgumentException("data cannot be null"); + } + + if (data.length == 0) { + throw new IllegalArgumentException("data cannot be empty"); + } + + int expectedSize = data[0].length; + + if (expectedSize == 0) { + throw new IllegalArgumentException("data cannot be empty"); + } + + for (int i = 0; i < data.length; i++) { + if (data[i].length == 0 || data[i].length != expectedSize) { + throw new IllegalArgumentException("data[i].length " + + "is supposed to be " + + expectedSize); + } + } + } + + private static int[][] getColHints(boolean[][] data) { + // Grid of columns hints + List<List<Integer>> colHints = new ArrayList<List<Integer>>(); + + // Largest number of hints for a column + int max = 0; + + for (boolean[] col : data) { + List<Integer> current = new ArrayList<Integer>(); + + // Current hint + int chain = 0; + + for (boolean cell : col) { + if (cell) { + chain++; + } else if (chain > 0) { + // We've reached the end of a series of checked boxes + current.add(chain); + chain = 0; + } + } + + if (chain > 0) { + current.add(chain); + } else if (current.size() == 0) { + // If this column is empty, we add a "0" hint + current.add(0); + } + + int currentSize = current.size(); + + if (currentSize > max) { + max = currentSize; + } + + colHints.add(current); + } + + /* + * Final array containing the hints, in the following form : + * + * 1 + * 0 2 1 + * + * Which corresponds to the following grid : + * + * |-----| + * |_|X|_| + * |_|_|X| + * |_|X|_| + * |_|X|_| + * |-----| + */ + int[][] result = new int[data.length][max]; + + for (int i = 0; i < max; i++) { + // Minimal number of hints for the current column to be considered + int ref = max - i; + + // Current hint row + int currentRow = ref - 1; + + for (int j = 0; j < colHints.size(); j++) { + List<Integer> currentCol = colHints.get(j); + int size = currentCol.size(); + + if (size >= ref) { + result[j][currentRow] = currentCol.get(size - ref); + } else { + result[j][currentRow] = GridModel.EMPTY_HINT; + } + } + } + + return result; + } + + private static int[][] getRowHints(boolean[][] data) { + List<List<Integer>> rowHints = new ArrayList<List<Integer>>(); + int max = 0; + + 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++) { + if (data[j][i]) { + chain++; + } else if (chain > 0) { + current.add(chain); + chain = 0; + } + } + + if (chain > 0) { + current.add(chain); + } else if (current.size() == 0) { + current.add(0); + } + + int currentSize = current.size(); + + if (currentSize > max) { + max = currentSize; + } + + rowHints.add(current); + } + + int[][] result = new int[data[0].length][max]; + int nbRows = rowHints.size(); + + for (int i = 0; i < max; i++) { + int ref = max - i; + + for (int j = 0; j < nbRows; j++) { + List<Integer> currentRow = rowHints.get(j); + int size = currentRow.size(); + + if (size >= ref) { + result[j][i] = + currentRow.get(i - Math.abs(size - max)); + } else { + result[j][i] = GridModel.EMPTY_HINT; + } + } + } + + return result; + } + /** * Returns the index of the first non-empty hint. * @@ -434,9 +604,9 @@ * @return boolean stating wether the row is empty or not */ private boolean emptyRow(int row) { - int index = this.getFirstHintIndex(this.rowData[row]); + int index = GridModel.getFirstHintIndex(this.rowData[row]); - return (index == this.getLastHintIndex(this.rowData[row])) + return (index == GridModel.getLastHintIndex(this.rowData[row])) && (this.rowData[row][index] == 0); } @@ -591,9 +761,9 @@ * @return boolean stating wether the column is empty or not */ private boolean emptyCol(int col) { - int index = this.getFirstHintIndex(this.colData[col]); + int index = GridModel.getFirstHintIndex(this.colData[col]); - return (index == this.getLastHintIndex(this.colData[col])) + return (index == GridModel.getLastHintIndex(this.colData[col])) && (this.colData[col][index] == 0); } Modified: trunk/src/picross/grid/GridUI.java =================================================================== --- trunk/src/picross/grid/GridUI.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/grid/GridUI.java 2008-04-28 12:47:06 UTC (rev 68) @@ -152,17 +152,21 @@ private int bottomBoundary; /** Rectangles occupied by the top hints. */ - private Rectangle[] topHintsRects; + //private Rectangle[] topHintsRects; /** Precomputed images containing the top hints boxes. */ - private transient BufferedImage[] topHintsBoxes; + //private transient BufferedImage[] topHintsBoxes; + private transient HintBoxInfos[] topHints; + /** Rectangles occupied by the left hints. */ - private Rectangle[] leftHintsRects; + //private Rectangle[] leftHintsRects; /** Precomputed images containing the left hints boxes. */ - private transient BufferedImage[] leftHintsBoxes; + //private transient BufferedImage[] leftHintsBoxes; + private transient HintBoxInfos[] leftHints; + /** Current state of the grid. */ private transient Box[][] boxes; @@ -253,14 +257,18 @@ Rectangle clipRect = newG.getClipBounds(); - for (int i = 0; i < this.topHintsRects.length; i++) { - if (this.topHintsRects[i].intersects(clipRect)) { + //for (int i = 0; i < this.topHintsRects.length; i++) { + for (int i = 0; i < this.topHints.length; i++) { + //if (this.topHintsRects[i].intersects(clipRect)) { + if (this.topHints[i].intersects(clipRect)) { this.drawTopHints(newG, i); } } - for (int i = 0; i < this.leftHintsRects.length; i++) { - if (this.leftHintsRects[i].intersects(clipRect)) { + //for (int i = 0; i < this.leftHintsRects.length; i++) { + for (int i = 0; i < this.leftHints.length; i++) { + //if (this.leftHintsRects[i].intersects(clipRect)) { + if (this.leftHints[i].intersects(clipRect)) { this.drawLeftHints(newG, i); } } @@ -341,20 +349,34 @@ + (this.height * GridUI.BOX_HEIGHT); // Space occupied by the hints - this.topHintsRects = new Rectangle[this.width]; + //this.topHintsRects = new Rectangle[this.width]; + this.topHints = new HintBoxInfos[this.width]; - for (int i = 0; i < this.topHintsRects.length; i++) { - this.topHintsRects[i] = + //for (int i = 0; i < this.topHintsRects.length; i++) { + for (int i = 0; i < this.topHints.length; i++) { + this.topHints[i] = new HintBoxInfos(); + + //this.topHintsRects[i] = + this.topHints[i].setRect( new Rectangle(this.leftBoundary + (i * GridUI.BOX_WIDTH), 0, - GridUI.BOX_WIDTH, this.topBoundary); + GridUI.BOX_WIDTH, this.topBoundary) + ) + ; } - this.leftHintsRects = new Rectangle[this.height]; + //this.leftHintsRects = new Rectangle[this.height]; + this.leftHints = new HintBoxInfos[this.height]; - for (int i = 0; i < this.leftHintsRects.length; i++) { - this.leftHintsRects[i] = + //for (int i = 0; i < this.leftHintsRects.length; i++) { + for (int i = 0; i < this.leftHints.length; i++) { + this.leftHints[i] = new HintBoxInfos(); + + //this.leftHintsRects[i] = + this.leftHints[i].setRect( new Rectangle(0, this.topBoundary + (i * GridUI.BOX_HEIGHT), - this.leftBoundary, GridUI.BOX_HEIGHT); + this.leftBoundary, GridUI.BOX_HEIGHT) + ) + ; } this.topHintsX = this.leftBoundary @@ -457,18 +479,25 @@ * @param topHintsStart coordinate where the boxes begin */ private void initTopHints(int topHintsStart) { - this.topHintsBoxes = new BufferedImage[this.width]; + //this.topHintsBoxes = new BufferedImage[this.width]; - for (int k = 0; k < this.topHintsBoxes.length; k++) { - this.topHintsBoxes[k] = + //for (int k = 0; k < this.topHintsBoxes.length; k++) { + for (int k = 0; k < this.topHints.length; k++) { + //this.topHintsBoxes[k] = + this.topHints[k].setBox( new BufferedImage(GridUI.BOX_WIDTH, this.topBoundary, - BufferedImage.TYPE_INT_RGB); + BufferedImage.TYPE_INT_RGB) + ) + ; - Graphics2D g2d = this.topHintsBoxes[k].createGraphics(); + //Graphics2D g2d = this.topHintsBoxes[k].createGraphics(); + Graphics2D g2d = this.topHints[k].createBoxGraphics(); g2d.setColor(Color.WHITE); g2d.fillRect(0, 0, - this.topHintsRects[k].width, - this.topHintsRects[k].height); + //this.topHintsRects[k].width, + this.topHints[k].getWidth(), + //this.topHintsRects[k].height); + this.topHints[k].getHeight()); int y = 0; @@ -488,18 +517,25 @@ * @param leftHintsStart coordinate where the boxes begin */ private void initLeftHints(int leftHintsStart) { - this.leftHintsBoxes = new BufferedImage[this.height]; + //this.leftHintsBoxes = new BufferedImage[this.height]; - for (int k = 0; k < this.leftHintsBoxes.length; k++) { - this.leftHintsBoxes[k] = + //for (int k = 0; k < this.leftHintsBoxes.length; k++) { + for (int k = 0; k < this.leftHints.length; k++) { + //this.leftHintsBoxes[k] = + this.leftHints[k].setBox( new BufferedImage(this.leftBoundary, GridUI.BOX_HEIGHT, - BufferedImage.TYPE_INT_RGB); + BufferedImage.TYPE_INT_RGB) + ) + ; - Graphics2D g2d = this.leftHintsBoxes[k].createGraphics(); + //Graphics2D g2d = this.leftHintsBoxes[k].createGraphics(); + Graphics2D g2d = this.leftHints[k].createBoxGraphics(); g2d.setColor(Color.WHITE); g2d.fillRect(0, 0, - this.leftHintsRects[k].width, - this.leftHintsRects[k].height); + //this.leftHintsRects[k].width, + this.leftHints[k].getWidth(), + //this.leftHintsRects[k].height); + this.leftHints[k].getHeight()); int x = 0; @@ -521,8 +557,10 @@ private void drawTopHints(Graphics g, int col) { //GridUI.log.debug("drawTopHints(g, " + col + ")"); - g.drawImage(this.topHintsBoxes[col], - this.topHintsRects[col].x, this.topHintsRects[col].y, + g.drawImage(//this.topHintsBoxes[col], + this.topHints[col].getBox(), + //this.topHintsRects[col].x, this.topHintsRects[col].y, + this.topHints[col].getX(), this.topHints[col].getY(), null); g.setFont(GridUI.HINT_FONT); @@ -547,8 +585,10 @@ * @param g the graphics context */ private void drawLeftHints(Graphics g, int row) { - g.drawImage(this.leftHintsBoxes[row], - this.leftHintsRects[row].x, this.leftHintsRects[row].y, + g.drawImage(//this.leftHintsBoxes[row], + this.leftHints[row].getBox(), + //this.leftHintsRects[row].x, this.leftHintsRects[row].y, + this.leftHints[row].getX(), this.leftHints[row].getY(), null); g.setFont(GridUI.HINT_FONT); @@ -721,7 +761,8 @@ return; } - this.repaint(this.topHintsRects[col]); + //this.repaint(this.topHintsRects[col]); + this.repaint(this.topHints[col].getRect()); } /** Repaints left hints. */ @@ -730,6 +771,7 @@ return; } - this.repaint(this.leftHintsRects[row]); + //this.repaint(this.leftHintsRects[row]); + this.repaint(this.leftHints[row].getRect()); } } Added: trunk/src/picross/grid/HintBoxInfos.java =================================================================== --- trunk/src/picross/grid/HintBoxInfos.java (rev 0) +++ trunk/src/picross/grid/HintBoxInfos.java 2008-04-28 12:47:06 UTC (rev 68) @@ -0,0 +1,106 @@ +/* + * $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.grid; + +import java.awt.Graphics2D; +import java.awt.Rectangle; + +import java.awt.image.BufferedImage; + +/** + * @author Y. Norsa + */ +class HintBoxInfos { + /*** Constante ***/ + + /*** Champ statique ***/ + + /*** Champ ***/ + + private Rectangle rect = null; + private BufferedImage box = null; + + /*** Constructeur ***/ + + /** + * Constructeur. + */ + /* + HintsInfos() { + } + */ + + /*** M\xE9thode ***/ + + void setRect(Rectangle newRect) { + this.rect = newRect; + } + + void setBox(BufferedImage newBox) { + this.box = newBox; + } + + boolean intersects(Rectangle rectangle) { + return this.rect.intersects(rectangle); + } + + Graphics2D createBoxGraphics() { + return this.box.createGraphics(); + } + + int getWidth() { + return this.rect.width; + } + + int getHeight() { + return this.rect.height; + } + + BufferedImage getBox() { + return this.box; + } + + int getX() { + return this.rect.x; + } + + int getY() { + return this.rect.y; + } + + Rectangle getRect() { + return this.rect; + } +} + Property changes on: trunk/src/picross/grid/HintBoxInfos.java ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/src/picross/menus/GameMenuMediator.java =================================================================== --- trunk/src/picross/menus/GameMenuMediator.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/menus/GameMenuMediator.java 2008-04-28 12:47:06 UTC (rev 68) @@ -55,10 +55,11 @@ * @param ui reference to the main UI * @throws PicrossException if the instantiation of the view fails */ + /* public GameMenuMediator(PicrossUI ui) throws PicrossException { super(ui); } - + */ /*** Method overloaded from the class MenuMediator ***/ /** {@inheritDoc}\xA0*/ Modified: trunk/src/picross/menus/MainMenuMediator.java =================================================================== --- trunk/src/picross/menus/MainMenuMediator.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/menus/MainMenuMediator.java 2008-04-28 12:47:06 UTC (rev 68) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2008 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -59,10 +59,11 @@ * @param ui reference to the main UI * @throws PicrossException if the instantiation of the main menu UI fails */ + /* public MainMenuMediator(PicrossUI ui) throws PicrossException { super(ui); } - + */ /*** Method overloaded from the class MenuMediator ***/ /** {@inheritDoc} */ @@ -70,9 +71,11 @@ protected MenuUI initView(PicrossUI ui, MenuController controller) throws PicrossException { + MainMenuUI view = null; + try { - return (MainMenuUI) Class.forName(ui.getMainMenuClass()) - .getConstructor(ActionListener.class).newInstance(controller); + view = (MainMenuUI) Class.forName(ui.getMainMenuClass()) + .getConstructor().newInstance(); } catch (ClassNotFoundException classEx) { throw new PicrossException(classEx); } catch (NoSuchMethodException methodEx) { @@ -84,6 +87,10 @@ } catch (InvocationTargetException targetEx) { throw new PicrossException(targetEx.getCause()); } + + view.init(controller); + + return view; } } Modified: trunk/src/picross/menus/MainMenuUI.java =================================================================== --- trunk/src/picross/menus/MainMenuUI.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/menus/MainMenuUI.java 2008-04-28 12:47:06 UTC (rev 68) @@ -70,9 +70,11 @@ * @param controller controller for the buttons * @throws MissingImageException if a button image can't be found */ - public MainMenuUI(ActionListener controller) { + public MainMenuUI() { super(); + } + protected void init(ActionListener controller) { this.addButton(MainMenuUI.PLAY_BUTTON_IMAGE, PicrossController.PLAY_CMD, controller, this.getPlayButtonX(), this.getPlayButtonY()); Modified: trunk/src/picross/menus/MenuMediator.java =================================================================== --- trunk/src/picross/menus/MenuMediator.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/menus/MenuMediator.java 2008-04-28 12:47:06 UTC (rev 68) @@ -65,8 +65,10 @@ * @param ui reference to the main UI * @throws PicrossException if the instantiation of the view fails */ - public MenuMediator(PicrossUI ui) throws PicrossException { + /* + public MenuMediator() {//PicrossUI ui) throws PicrossException { //MenuController controller = new MenuController(); + MenuController controller = this.initController(); controller.addSimpleListener(this); @@ -75,7 +77,18 @@ MenuMediator.log.debug("controller.setView()"); controller.setView(this.view); } + */ + public final void init(PicrossUI ui) throws PicrossException { + MenuController controller = this.initController(); + controller.addSimpleListener(this); + + this.view = this.initView(ui, controller); + + MenuMediator.log.debug("controller.setView()"); + controller.setView(this.view); + } + protected MenuController initController() { return new MenuController(); } Modified: trunk/src/picross/menus/MenuUI.java =================================================================== --- trunk/src/picross/menus/MenuUI.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/menus/MenuUI.java 2008-04-28 12:47:06 UTC (rev 68) @@ -46,6 +46,7 @@ import java.io.FileNotFoundException; +import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JPanel; @@ -140,22 +141,33 @@ protected void addSimpleButton(String label, SimpleEvent event, SimpleListener listener, int x, int y) { + /* SimpleButton<JButton> button = new SimpleButton<JButton>(label, event) { }; + */ + + PicrossButton button = new PicrossButton(label, Picross.getImage("empty-button.png"), event); + button.addSimpleListener(listener); - button.getButton().setIcon(Picross.getImage("empty-button.png")); - button.getButton().setHorizontalTextPosition(JButton.CENTER); - button.getButton().setVerticalTextPosition(JButton.CENTER); + JButton realButton = button.getButton(); - this.putButton(button.getButton(), x, y, 150, 50); + //realButton.setIcon(Picross.getImage("empty-button.png")); + realButton.setHorizontalTextPosition(JButton.CENTER); + realButton.setVerticalTextPosition(JButton.CENTER); + + this.putButton(realButton, x, y, 150, 50); } protected void addButton(SimpleButton<JButton> button, SimpleListener listener, int x, int y) { button.addSimpleListener(listener); - button.getButton().setBorder(null); - this.putButton(button.getButton(), x, y, button.getButton().getIcon().getIconWidth(), button.getButton().getIcon().getIconHeight()); + + JButton realButton = button.getButton(); + Icon icon = realButton.getIcon(); + + realButton.setBorder(null); + this.putButton(realButton, x, y, icon.getIconWidth(), icon.getIconHeight()); } private void putButton(JButton button, int x, int y, int width, int height) { Added: trunk/src/picross/menus/PicrossButton.java =================================================================== --- trunk/src/picross/menus/PicrossButton.java (rev 0) +++ trunk/src/picross/menus/PicrossButton.java 2008-04-28 12:47:06 UTC (rev 68) @@ -0,0 +1,68 @@ +/* + * $Id$ + * + * Copyright (c) 2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.menus; + +import fr.cle.core.gui.SimpleButton; + +import fr.cle.mmvcs.SimpleEvent; + +import javax.swing.Icon; +import javax.swing.JButton; + +/** + * @author Y. Norsa + */ +public class PicrossButton extends SimpleButton<JButton> { + /*** Constante ***/ + + /*** Champ statique ***/ + + /*** Champ ***/ + + /*** Constructeur ***/ + + /** + * Constructeur. + */ + public PicrossButton(String label, Icon icon, SimpleEvent event) { + super(label, event); + + this.getButton().setIcon(icon); + } + + public PicrossButton(Icon icon, SimpleEvent event) { + this("", icon, event); + } +} + Property changes on: trunk/src/picross/menus/PicrossButton.java ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/src/picross/menus/WaitMenuMediator.java =================================================================== --- trunk/src/picross/menus/WaitMenuMediator.java 2008-04-28 12:33:55 UTC (rev 67) +++ trunk/src/picross/menus/WaitMenuMediator.java 2008-04-28 12:47:06 UTC (rev 68) @@ -51,10 +51,11 @@ /** * Constructeur. */ + /* public WaitMenuMediator(PicrossUI ui) throws PicrossException { super(ui); } - + */ /*** M\xE9thode ***/ protected MenuUI initView(PicrossUI ui, MenuController controller) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-04-28 12:33:49
|
Revision: 67 http://picross.svn.sourceforge.net/picross/?rev=67&view=rev Author: yvan_norsa Date: 2008-04-28 05:33:55 -0700 (Mon, 28 Apr 2008) Log Message: ----------- fixed tests Modified Paths: -------------- trunk/src/picross/game/simple/XBMModelTest.java trunk/src/picross/tests/PicrossTest.java Modified: trunk/src/picross/game/simple/XBMModelTest.java =================================================================== --- trunk/src/picross/game/simple/XBMModelTest.java 2008-04-28 09:07:21 UTC (rev 66) +++ trunk/src/picross/game/simple/XBMModelTest.java 2008-04-28 12:33:55 UTC (rev 67) @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (c) 2007 + * Copyright (c) 2007-2008 * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -63,7 +63,7 @@ try { XBMModelTest.realModel = - new XBMModel(Picross.loadDataFile("blarg.xbm")); + new XBMModel(Picross.loadDataFile("asterix.xbm")); } catch (IOException ioEx) { throw new ExceptionInInitializerError(ioEx); } catch (XBMException xbmEx) { Modified: trunk/src/picross/tests/PicrossTest.java =================================================================== --- trunk/src/picross/tests/PicrossTest.java 2008-04-28 09:07:21 UTC (rev 66) +++ trunk/src/picross/tests/PicrossTest.java 2008-04-28 12:33:55 UTC (rev 67) @@ -146,7 +146,7 @@ Assert.fail("Fake file"); } catch (FileNotFoundException fileEx) { } - InputStream in = Picross.loadDataFile("blarg.xbm"); + InputStream in = Picross.loadDataFile("asterix.xbm"); Assert.assertNotNull("in = null", in); in.close(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |