Thread: [Picross-commit] SF.net SVN: picross: [5] trunk
Status: Pre-Alpha
Brought to you by:
yvan_norsa
|
From: <yva...@us...> - 2007-06-05 07:37:02
|
Revision: 5
http://picross.svn.sourceforge.net/picross/?rev=5&view=rev
Author: yvan_norsa
Date: 2007-06-05 00:37:02 -0700 (Tue, 05 Jun 2007)
Log Message:
-----------
added support for checkstyle and findbugs
Modified Paths:
--------------
trunk/build.xml
Added Paths:
-----------
trunk/bugsFilter.xml
trunk/checkstyle.sample.properties
Added: trunk/bugsFilter.xml
===================================================================
--- trunk/bugsFilter.xml (rev 0)
+++ trunk/bugsFilter.xml 2007-06-05 07:37:02 UTC (rev 5)
@@ -0,0 +1,5 @@
+<FindBugsFilter>
+ <Match classregex=".*">
+ <Bug pattern="CLI_CONSTANT_LIST_INDEX,S508C_SET_COMP_COLOR" />
+ </Match>
+</FindBugsFilter>
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2007-06-05 06:53:14 UTC (rev 4)
+++ trunk/build.xml 2007-06-05 07:37:02 UTC (rev 5)
@@ -82,4 +82,73 @@
<target name="rebuild"
depends="clean, compile" />
+
+ <property file="checkstyle.properties" />
+
+ <target name="-check-checkstyle">
+ <fail unless="checkstyle.jar"
+ message="You need checkstyle.properties to call this target" />
+ </target>
+
+ <target name="checkstyle"
+ depends="-check-checkstyle,rebuild">
+ <taskdef resource="checkstyletask.properties"
+ classpath="${checkstyle.jar}" />
+
+ <checkstyle configURL="${checkstyle.url}"
+ failOnViolation="false"
+ failureProperty="checkstyle-failed">
+ <classpath refid="classpath" />
+
+ <formatter type="xml"
+ tofile="checkstyle.xml" />
+
+ <!-- Pour tous les fichiers source sauf les tests -->
+ <fileset dir="${src.dir}"
+ includes="**/*.java" />
+ </checkstyle>
+
+ <xslt in="checkstyle.xml"
+ out="checkstyle.html">
+ <style>
+ <url url="${checkstyle.xsl}" />
+ </style>
+ </xslt>
+
+ <fail message="Checkstyle failed">
+ <condition>
+ <isset property="checkstyle-failed" />
+ </condition>
+ </fail>
+ </target>
+
+ <property environment="env" />
+
+ <target name="-check-findbugs">
+ <available property="has-findbugs"
+ file="${env.FINDBUGS_HOME}/lib/findbugs.jar" />
+
+ <fail unless="has-findbugs"
+ message="You need to set the FINDBUGS_HOME variable to call this target" />
+ </target>
+
+ <target name="findbugs"
+ depends="-check-findbugs,rebuild">
+ <taskdef name="findbugs"
+ classname="edu.umd.cs.findbugs.anttask.FindBugsTask" />
+
+ <findbugs home="${env.FINDBUGS_HOME}"
+ reportLevel="low"
+ effort="max"
+ excludeFilter="bugsFilter.xml"
+ projectName="${ant.project.name}"
+ output="html"
+ outputFile="findbugs.html">
+ <class location="${build.dir}" />
+
+ <auxclasspath refid="classpath" />
+
+ <sourcePath path="${src.dir}" />
+ </findbugs>
+ </target>
</project>
\ No newline at end of file
Added: trunk/checkstyle.sample.properties
===================================================================
--- trunk/checkstyle.sample.properties (rev 0)
+++ trunk/checkstyle.sample.properties 2007-06-05 07:37:02 UTC (rev 5)
@@ -0,0 +1,3 @@
+checkstyle.jar=/path/checkstyle.jar
+checkstyle.url=http://picross.sourceforge.net/style.xml
+checkstyle.xsl=http://picross.sourceforge.net/checkstyle.xsl
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2007-06-05 11:32:57
|
Revision: 8
http://picross.svn.sourceforge.net/picross/?rev=8&view=rev
Author: yvan_norsa
Date: 2007-06-05 04:32:56 -0700 (Tue, 05 Jun 2007)
Log Message:
-----------
displays a message when the grid is complete
Modified Paths:
--------------
trunk/bugsFilter.xml
trunk/src/picross/PicrossMediator.java
trunk/src/picross/PicrossUI.java
trunk/src/picross/grid/FillCommand.java
trunk/src/picross/grid/PicrossGridController.java
trunk/src/picross/grid/PicrossGridMediator.java
trunk/src/picross/grid/PicrossGridModel.java
Added Paths:
-----------
trunk/src/picross/PicrossController.java
Modified: trunk/bugsFilter.xml
===================================================================
--- trunk/bugsFilter.xml 2007-06-05 08:52:12 UTC (rev 7)
+++ trunk/bugsFilter.xml 2007-06-05 11:32:56 UTC (rev 8)
@@ -1,5 +1,5 @@
<FindBugsFilter>
<Match classregex=".*">
- <Bug pattern="CLI_CONSTANT_LIST_INDEX,S508C_SET_COMP_COLOR" />
+ <Bug pattern="LSC_LITERAL_STRING_COMPARISON,CLI_CONSTANT_LIST_INDEX,S508C_SET_COMP_COLOR" />
</Match>
</FindBugsFilter>
Added: trunk/src/picross/PicrossController.java
===================================================================
--- trunk/src/picross/PicrossController.java (rev 0)
+++ trunk/src/picross/PicrossController.java 2007-06-05 11:32:56 UTC (rev 8)
@@ -0,0 +1,81 @@
+/*
+ * $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;
+
+import fr.cle.mmvcs.Controller;
+import fr.cle.mmvcs.SimpleEvent;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Application controller.
+ *
+ * @author Y. Norsa
+ */
+class PicrossController extends Controller {
+ /*** Static field ***/
+
+ /** The class's logger. */
+ private static Logger log = Logger.getLogger(PicrossController.class);
+
+ /*** Field ***/
+
+ /** The view to which this controller is attached. */
+ private PicrossUI view = null;
+
+ /*** Method overloaded from the class Controller ***/
+
+ /** {@inheritDoc} */
+ public void eventPerformed(SimpleEvent e) {
+ PicrossController.log.debug("eventPerformed(" + e + ")");
+
+ String cmd = e.getCommandName();
+
+ if (cmd.equals(PicrossController.MESSAGE_CMD)) {
+ this.view.displayMessage(e.getComment());
+ }
+ }
+
+ /*** Accessor ***/
+
+ /**
+ * Allows to define the view.
+ *
+ * @param view the view to which this controller is to be attached
+ */
+ void setView(PicrossUI view) {
+ this.view = view;
+ }
+}
+
Property changes on: trunk/src/picross/PicrossController.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2007-06-05 08:52:12 UTC (rev 7)
+++ trunk/src/picross/PicrossMediator.java 2007-06-05 11:32:56 UTC (rev 8)
@@ -38,6 +38,7 @@
import org.apache.log4j.Logger;
+import picross.grid.PicrossGridController;
import picross.grid.PicrossGridMediator;
/**
@@ -57,11 +58,17 @@
PicrossMediator() {
PicrossModel model = new PicrossModel();
+ PicrossController controller = new PicrossController();
+ this.addSimpleListener(controller);
+
PicrossGridMediator grid =
new PicrossGridMediator(model.getWidth(), model.getHeight(),
model.getData());
+ grid.addSimpleListener(this);
- new PicrossUI(grid.getView());
+ PicrossUI view = new PicrossUI(grid.getView());
+
+ controller.setView(view);
}
/*** Method overloaded from the Mediateur class ***/
@@ -69,6 +76,13 @@
/** {@inheritDoc} */
public void eventPerformed(SimpleEvent e) {
PicrossMediator.log.debug("eventPerformed(" + e + ")");
+
+ String cmd = e.getCommandName();
+
+ if (cmd.equals(PicrossGridController.GRID_FILLED_CMD)) {
+ this.fireEventPerformed(PicrossController.MESSAGE_CMD,
+ "Congratulations");
+ }
}
}
Modified: trunk/src/picross/PicrossUI.java
===================================================================
--- trunk/src/picross/PicrossUI.java 2007-06-05 08:52:12 UTC (rev 7)
+++ trunk/src/picross/PicrossUI.java 2007-06-05 11:32:56 UTC (rev 8)
@@ -34,7 +34,9 @@
package picross;
import javax.swing.JFrame;
+import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
/**
* Main window.
@@ -60,5 +62,51 @@
this.pack();
this.setVisible(true);
}
+
+ /*** Method ***/
+
+ /**
+ * Displays a message box.
+ *
+ * @param msg message to be displayed
+ */
+ void displayMessage(String msg) {
+ SwingUtilities.invokeLater(new RunnableDialog(this, msg));
+ }
+
+ /**
+ * Inner class displaying a message asynchronously.
+ *
+ * @author Y. Norsa
+ */
+ private static final class RunnableDialog implements Runnable {
+ /*** Fields ***/
+
+ /** Parent frame. */
+ private JFrame parent;
+
+ /** Message to be displayed. */
+ private String msg;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @param parent parent frame
+ * @param msg message to be displayed
+ */
+ private RunnableDialog(JFrame parent, String msg) {
+ this.parent = parent;
+ this.msg = msg;
+ }
+
+ /*** Method implanted from the interface Runnable ***/
+
+ /** {@inheritDoc} */
+ public void run() {
+ JOptionPane.showMessageDialog(this.parent, this.msg);
+ }
+ }
}
Modified: trunk/src/picross/grid/FillCommand.java
===================================================================
--- trunk/src/picross/grid/FillCommand.java 2007-06-05 08:52:12 UTC (rev 7)
+++ trunk/src/picross/grid/FillCommand.java 2007-06-05 11:32:56 UTC (rev 8)
@@ -66,7 +66,7 @@
/** {@inheritDoc} */
public String toString() {
- return this.row + ", " + this.column;
+ return this.row + "," + this.column;
}
/*** Accessors ***/
Modified: trunk/src/picross/grid/PicrossGridController.java
===================================================================
--- trunk/src/picross/grid/PicrossGridController.java 2007-06-05 08:52:12 UTC (rev 7)
+++ trunk/src/picross/grid/PicrossGridController.java 2007-06-05 11:32:56 UTC (rev 8)
@@ -49,13 +49,17 @@
*
* @author Y. Norsa
*/
-class PicrossGridController extends Controller implements MouseListener,
- MouseMotionListener {
- /*** Constant ***/
+public class PicrossGridController extends Controller
+ implements MouseListener, MouseMotionListener {
+ /*** Constants ***/
+
/** Fill command. */
static final String FILL_CMD = "FILL_CMD";
+ /** Command indicating the grid is filled. */
+ public static final String GRID_FILLED_CMD = "GRID_FILLED_CMD";
+
/*** Static field ***/
/** The class' logger. */
Modified: trunk/src/picross/grid/PicrossGridMediator.java
===================================================================
--- trunk/src/picross/grid/PicrossGridMediator.java 2007-06-05 08:52:12 UTC (rev 7)
+++ trunk/src/picross/grid/PicrossGridMediator.java 2007-06-05 11:32:56 UTC (rev 8)
@@ -51,8 +51,11 @@
/** Class' logger. */
private static Logger log = Logger.getLogger(PicrossGridMediator.class);
- /*** Field ***/
+ /*** Fields ***/
+ /** The grid model. */
+ private PicrossGridModel model;
+
/** The grid view. */
private PicrossGridUI view;
@@ -66,15 +69,14 @@
* @param data grid content
*/
public PicrossGridMediator(int width, int height, boolean[][] data) {
- PicrossGridModel model = new PicrossGridModel(data);
+ this.model = new PicrossGridModel(this, data);
PicrossGridController controller = new PicrossGridController();
controller.addSimpleListener(this);
- this.addSimpleListener(controller);
this.view = new PicrossGridUI(width, height,
- model.getColData(),
- model.getRowData(),
+ this.model.getColData(),
+ this.model.getRowData(),
controller);
controller.setView(this.view);
@@ -85,8 +87,23 @@
/** {@inheritDoc} */
public void eventPerformed(SimpleEvent e) {
PicrossGridMediator.log.debug("eventPerformed(" + e + ")");
+
+ String cmd = e.getCommandName();
+
+ if (cmd.equals(PicrossGridController.FILL_CMD)) {
+ FillCommand command = (FillCommand) e.getCommand();
+
+ this.model.checkBox(command.getRow(), command.getColumn());
+ }
}
+ /*** Method ***/
+
+ /** Tells the application mediator the grid has been filled. */
+ void congratulations() {
+ this.fireEventPerformed(PicrossGridController.GRID_FILLED_CMD);
+ }
+
/*** Accessor ***/
/**
Modified: trunk/src/picross/grid/PicrossGridModel.java
===================================================================
--- trunk/src/picross/grid/PicrossGridModel.java 2007-06-05 08:52:12 UTC (rev 7)
+++ trunk/src/picross/grid/PicrossGridModel.java 2007-06-05 11:32:56 UTC (rev 8)
@@ -51,6 +51,15 @@
/*** Fields ***/
+ /** This model's mediator. */
+ private PicrossGridMediator mediator;
+
+ /** The original grid. */
+ private boolean[][] data;
+
+ /** The grid as filled by the user. */
+ private boolean[][] checked;
+
/** Columns hints. */
private int[][] colData;
@@ -62,9 +71,15 @@
/**
* Constructor.
*
+ * @param mediator this model's mediator
* @param data grid content
*/
- PicrossGridModel(boolean[][] data) {
+ PicrossGridModel(PicrossGridMediator mediator, boolean[][] data) {
+ this.mediator = mediator;
+
+ this.data = data;
+ this.checked = new boolean[this.data.length][this.data[0].length];
+
List<List<Integer>> colRawData = new ArrayList<List<Integer>>();
int max = 0;
@@ -231,6 +246,33 @@
*/
}
+ /*** Method ***/
+
+ /**
+ * Indicates a box has been checked.
+ *
+ * @param row row of the box
+ * @param column column of the box
+ */
+ void checkBox(int row, int column) {
+ this.checked[row][column] = true;
+
+ boolean completed = true;
+
+ for (int i = 0; i < this.data.length; i++) {
+ for (int j = 0; j < this.data[i].length; j++) {
+ if (this.data[i][j] != this.checked[i][j]) {
+ completed = false;
+ break;
+ }
+ }
+ }
+
+ if (completed) {
+ this.mediator.congratulations();
+ }
+ }
+
/*** Accessors ***/
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2007-06-06 11:42:56
|
Revision: 11
http://picross.svn.sourceforge.net/picross/?rev=11&view=rev
Author: yvan_norsa
Date: 2007-06-06 04:42:57 -0700 (Wed, 06 Jun 2007)
Log Message:
-----------
added images and crosses
Modified Paths:
--------------
trunk/bugsFilter.xml
trunk/src/picross/grid/FillCommand.java
trunk/src/picross/grid/PicrossGridController.java
trunk/src/picross/grid/PicrossGridMediator.java
trunk/src/picross/grid/PicrossGridModel.java
trunk/src/picross/grid/PicrossGridUI.java
Added Paths:
-----------
trunk/images/
trunk/images/checked.png
trunk/images/crossed.png
trunk/images/empty.png
trunk/src/picross/grid/Box.java
Modified: trunk/bugsFilter.xml
===================================================================
--- trunk/bugsFilter.xml 2007-06-06 08:27:54 UTC (rev 10)
+++ trunk/bugsFilter.xml 2007-06-06 11:42:57 UTC (rev 11)
@@ -1,5 +1,5 @@
<FindBugsFilter>
<Match classregex=".*">
- <Bug pattern="LSC_LITERAL_STRING_COMPARISON,CLI_CONSTANT_LIST_INDEX,S508C_SET_COMP_COLOR" />
+ <Bug pattern="DM_CONVERT_CASE,LSC_LITERAL_STRING_COMPARISON,CLI_CONSTANT_LIST_INDEX,S508C_SET_COMP_COLOR" />
</Match>
</FindBugsFilter>
Added: trunk/images/checked.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/checked.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/images/crossed.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/crossed.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/images/empty.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/empty.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/picross/grid/Box.java
===================================================================
--- trunk/src/picross/grid/Box.java (rev 0)
+++ trunk/src/picross/grid/Box.java 2007-06-06 11:42:57 UTC (rev 11)
@@ -0,0 +1,211 @@
+/*
+ * $Id$
+ * \xC9crit le 06/06/2007 par Y. Norsa
+ *
+ * Copyright (c) 2007
+ * Projet Carte Lorraine de l'Etudiant (CLE)
+ *
+ * Universit\xE9 Henri Poincar\xE9, Nancy
+ * Universit\xE9 Nancy2
+ * Institut National Polytechnique de Lorraine
+ * Universit\xE9 Paul Verlaine, Metz
+ *
+ * Ce projet regroupe les d\xE9veloppements concernant la production
+ * et l'exploitation de la Carte Lorraine de l'Etudiant
+ * (carte \xE0 puce sans contact Mifare).
+ *
+ * Ce logiciel est r\xE9gi par la licence CeCILL soumise au droit fran\xE7ais et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffus\xE9e par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilit\xE9 au code source et des droits de copie,
+ * de modification et de redistribution accord\xE9s par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limit\xE9e. Pour les m\xEAmes raisons,
+ * seule une responsabilit\xE9 restreinte p\xE8se sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les conc\xE9dants successifs.
+ *
+ * A cet \xE9gard l'attention de l'utilisateur est attir\xE9e sur les risques
+ * associ\xE9s au chargement, \xE0 l'utilisation, \xE0 la modification et/ou au
+ * d\xE9veloppement et \xE0 la reproduction du logiciel par l'utilisateur \xE9tant
+ * donn\xE9 sa sp\xE9cificit\xE9 de logiciel libre, qui peut le rendre complexe \xE0
+ * manipuler et qui le r\xE9serve donc \xE0 des d\xE9veloppeurs et des professionnels
+ * avertis poss\xE9dant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invit\xE9s \xE0 charger et tester l'ad\xE9quation du
+ * logiciel \xE0 leurs besoins dans des conditions permettant d'assurer la
+ * s\xE9curit\xE9 de leurs syst\xE8mes et ou de leurs donn\xE9es et, plus g\xE9n\xE9ralement,
+ * \xE0 l'utiliser et l'exploiter dans les m\xEAmes conditions de s\xE9curit\xE9.
+ *
+ * Le fait que vous puissiez acc\xE9der \xE0 cet en-t\xEAte signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accept\xE9 les
+ * termes.
+ */
+
+
+package picross.grid;
+
+import java.awt.Image;
+
+import java.io.File;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+import javax.swing.ImageIcon;
+
+//import org.apache.log4j.Logger;
+
+/**
+ * Representation of a box in the grid.
+ *
+ * @author Y. Norsa
+ */
+final class Box {
+ /*** Enum ***/
+
+ /** Possibles states of a box. */
+ private enum BoxState {
+ /** An empty box. */
+ EMPTY,
+
+ /** A checked box. */
+ CHECKED,
+
+ /** A crossed box. */
+ CROSSED
+ }
+
+ /*** Constants ***/
+
+ /** Directory containing the images. */
+ private static final String IMAGES_DIR = "images";
+
+ /** Images files extension. */
+ private static final String IMAGES_EXT = ".png";
+
+ /*** Statics fields ***/
+
+ /** The class's logger. */
+ //private static Logger log = Logger.getLogger(Box.class);
+
+ /** Random number generator. */
+ private static Random rand;
+
+ /** Map containing the images corresponding to the different states. */
+ private static Map<Box.BoxState, Image> images;
+
+ /*** Fields ***/
+
+ /** State of the box. */
+ private Box.BoxState state;
+
+ /** Pseudo random hash-code. */
+ private int hash;
+
+ /*** Static block ***/
+
+ // Fills in the images map
+ static {
+ Box.rand = new Random();
+
+ Box.images = new HashMap<Box.BoxState, Image>();
+
+ String path = Box.IMAGES_DIR + File.separator;
+
+ for (Box.BoxState state : Box.BoxState.values()) {
+ Box.images.put(state, new ImageIcon(path
+ + state.toString()
+ .toLowerCase()
+ + Box.IMAGES_EXT).getImage());
+ }
+ }
+
+ /*** Constructor ***/
+
+ /** Constructor. */
+ Box() {
+ this.state = Box.BoxState.EMPTY;
+ this.hash = Box.rand.nextInt();
+ }
+
+ /*** Methods overloaded from the class Object ***/
+
+ /** {@inheritDoc} */
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+
+ if (obj == this) {
+ return true;
+ }
+
+ if (!(obj instanceof Box)) {
+ return false;
+ }
+
+ return (this.state == ((Box) obj).state);
+ }
+
+ /** {@inheritDoc} */
+ public int hashCode() {
+ return this.hash;
+ }
+
+ /*** Methods ***/
+
+ /**
+ * Permits to know if the box is checked.
+ *
+ * @return boolean telling if the box is checked
+ */
+ boolean isChecked() {
+ return this.state == Box.BoxState.CHECKED;
+ }
+
+ /**
+ * Permits to know if the box is crossed.
+ *
+ * @return boolean telling if the box is crossed
+ */
+ boolean isCrossed() {
+ return this.state == Box.BoxState.CROSSED;
+ }
+
+ /**
+ * Permits to know if the box is empty.
+ *
+ * @return boolean telling if the box is empty
+ */
+ boolean isEmpty() {
+ return this.state == Box.BoxState.EMPTY;
+ }
+
+ /** Empties the box. */
+ void empty() {
+ this.state = Box.BoxState.EMPTY;
+ }
+
+ /** Checks the box. */
+ void check() {
+ this.state = Box.BoxState.CHECKED;
+ }
+
+ /** Crosses the box. */
+ void cross() {
+ this.state = Box.BoxState.CROSSED;
+ }
+
+ /**
+ * Returns the image associated with the box's state.
+ *
+ * @return the image corresponding to the box's state
+ */
+ Image getImage() {
+ //Box.log.debug("return " + Box.images.get(this.state));
+ return Box.images.get(this.state);
+ }
+}
+
Property changes on: trunk/src/picross/grid/Box.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/grid/FillCommand.java
===================================================================
--- trunk/src/picross/grid/FillCommand.java 2007-06-06 08:27:54 UTC (rev 10)
+++ trunk/src/picross/grid/FillCommand.java 2007-06-06 11:42:57 UTC (rev 11)
@@ -49,6 +49,9 @@
/** Column of the box to fill. */
private int column;
+ /** Type of the action. */
+ private int type;
+
/*** Constructor ***/
/**
@@ -56,10 +59,12 @@
*
* @param row row of the box to fill
* @param column column of the box to fill
+ * @param type type of the action
*/
- FillCommand(int row, int column) {
+ FillCommand(int row, int column, int type) {
this.row = row;
this.column = column;
+ this.type = type;
}
/*** Method overloaded from the class Command ***/
@@ -88,5 +93,14 @@
int getColumn() {
return this.column;
}
+
+ /**
+ * Return the type.
+ *
+ * @return type of the action
+ */
+ int getType() {
+ return this.type;
+ }
}
Modified: trunk/src/picross/grid/PicrossGridController.java
===================================================================
--- trunk/src/picross/grid/PicrossGridController.java 2007-06-06 08:27:54 UTC (rev 10)
+++ trunk/src/picross/grid/PicrossGridController.java 2007-06-06 11:42:57 UTC (rev 11)
@@ -69,6 +69,12 @@
/** Command to uncheck a box. */
static final String UNCHECK_CMD = "UNCHECK_CMD";
+ /** Checking a box. */
+ static final int CHECK_ACTION = 0;
+
+ /** Crossing a box. */
+ static final int CROSS_ACTION = 1;
+
/*** Static field ***/
/** The class' logger. */
@@ -94,14 +100,16 @@
if (cmd.equals(PicrossGridController.CHECK_CMD)) {
FillCommand command = (FillCommand) e.getCommand();
- this.view.check(command.getRow(), command.getColumn());
+ this.view.check(command.getRow(), command.getColumn(),
+ command.getType());
return;
}
if (cmd.equals(PicrossGridController.UNCHECK_CMD)) {
FillCommand command = (FillCommand) e.getCommand();
- this.view.uncheck(command.getRow(), command.getColumn());
+ this.view.uncheck(command.getRow(), command.getColumn(),
+ command.getType());
return;
}
@@ -138,7 +146,7 @@
/** {@inheritDoc} */
public void mouseMoved(MouseEvent e) { }
- /*** Method ***/
+ /*** Methods ***/
/**
* Checks if the mouse current click's location is inside the grid
@@ -149,7 +157,11 @@
private void checkAndFill(MouseEvent e) {
//PicrossGridController.log.debug(e);
- if (e.getModifiers() != MouseEvent.BUTTON1_MASK) {
+ int modifiers = e.getModifiers();
+
+ if (modifiers != MouseEvent.BUTTON1_MASK
+ && modifiers != MouseEvent.BUTTON3_MASK) {
+
return;
}
@@ -158,12 +170,33 @@
if (this.view.isInGrid(point)) {
int row = this.view.getRow(point);
int column = this.view.getColumn(point);
+ int type = PicrossGridController.modifiersToType(modifiers);
this.fireEventPerformed(PicrossGridController.FILL_CMD,
- new FillCommand(row, column));
+ new FillCommand(row, column, type));
+
}
}
+ /**
+ * Converts a mouse click to an action.
+ *
+ * @param modifiers mouse event modifiers
+ * @return corresponding action, or -1
+ */
+ private static int modifiersToType(int modifiers) {
+ switch (modifiers) {
+ case MouseEvent.BUTTON1_MASK:
+ return PicrossGridController.CHECK_ACTION;
+
+ case MouseEvent.BUTTON2_MASK:
+ return PicrossGridController.CROSS_ACTION;
+
+ default:
+ return -1;
+ }
+ }
+
/*** Accessor ***/
/**
Modified: trunk/src/picross/grid/PicrossGridMediator.java
===================================================================
--- trunk/src/picross/grid/PicrossGridMediator.java 2007-06-06 08:27:54 UTC (rev 10)
+++ trunk/src/picross/grid/PicrossGridMediator.java 2007-06-06 11:42:57 UTC (rev 11)
@@ -93,7 +93,8 @@
if (cmd.equals(PicrossGridController.FILL_CMD)) {
FillCommand command = (FillCommand) e.getCommand();
- this.model.checkBox(command.getRow(), command.getColumn());
+ this.model.checkBox(command.getRow(), command.getColumn(),
+ command.getType());
return;
}
@@ -117,9 +118,9 @@
* @param row row of the box
* @param column column of the box
*/
- void check(int row, int column) {
+ void check(int row, int column, int type) {
this.fireEventPerformed(PicrossGridController.CHECK_CMD,
- new FillCommand(row, column));
+ new FillCommand(row, column, type));
}
/**
@@ -128,9 +129,9 @@
* @param row row of the box
* @param column column of the box
*/
- void uncheck(int row, int column) {
+ void uncheck(int row, int column, int type) {
this.fireEventPerformed(PicrossGridController.UNCHECK_CMD,
- new FillCommand(row, column));
+ new FillCommand(row, column, type));
}
/*** Accessor ***/
Modified: trunk/src/picross/grid/PicrossGridModel.java
===================================================================
--- trunk/src/picross/grid/PicrossGridModel.java 2007-06-06 08:27:54 UTC (rev 10)
+++ trunk/src/picross/grid/PicrossGridModel.java 2007-06-06 11:42:57 UTC (rev 11)
@@ -63,13 +63,13 @@
private boolean[][] data;
/** The grid as filled by the user. */
- private DummyBoolean[][] checked;
+ private Box[][] boxes;
/**
* The last modified box. Permis to know if we are in a serie or
* a single action.
*/
- private DummyBoolean lastChecked = null;
+ private Box lastModified = null;
/** Columns hints. */
private int[][] colData;
@@ -89,11 +89,11 @@
this.mediator = mediator;
this.data = data;
- this.checked = new DummyBoolean[this.data.length][this.data[0].length];
+ this.boxes = new Box[this.data.length][this.data[0].length];
- for (int i = 0; i < this.checked.length; i++) {
- for (int j = 0; j < this.checked[i].length; j++) {
- this.checked[i][j] = new DummyBoolean(false);
+ for (int i = 0; i < this.boxes.length; i++) {
+ for (int j = 0; j < this.boxes[i].length; j++) {
+ this.boxes[i][j] = new Box();
}
}
@@ -233,7 +233,7 @@
* @param row row of the box
* @param column column of the box
*/
- void checkBox(int row, int column) {
+ void checkBox(int row, int column, int type) {
//PicrossGridModel.log.debug("checkBox(" + row + ", " + column + ")");
//PicrossGridModel.log.debug("lastChecked == null : "
// + (lastChecked == null));
@@ -242,42 +242,42 @@
* If we are trying to check the last box we just checked
* (while dragging), do nothing
*/
- if (this.lastChecked != null
- && this.lastChecked == this.checked[row][column]) {
+ if (this.lastModified != null
+ && this.lastModified == this.boxes[row][column]) {
return;
}
- boolean currentValue = this.checked[row][column].getValue();
-
- /*
- * The value of the last checked box tells us if we are in
- * a checks serie or a uncheck serie
- */
- boolean lastValue = false;
-
- if (this.lastChecked != null) {
- lastValue = this.lastChecked.getValue();
-
+ if (this.lastModified != null) {
/*
* If we are in a box which is in the same state as our aim
* (if we are in a checks serie and we are on a box which
* is already checked), do nothing
*/
- if (currentValue == lastValue) {
+ if (this.boxes[row][column].equals(this.lastModified)) {
return;
}
}
- if (!currentValue && (this.lastChecked == null || lastValue)) {
- this.checked[row][column].setValue(true);
- this.mediator.check(row, column);
- } else if (currentValue && (this.lastChecked == null || !lastValue)) {
- this.checked[row][column].setValue(false);
- this.mediator.uncheck(row, column);
+ if (this.boxes[row][column].isEmpty()
+ && (this.lastModified == null || !this.lastModified.isEmpty())) {
+
+ if (type == PicrossGridController.CHECK_ACTION) {
+ this.boxes[row][column].check();
+ } else { //if (type == PicrossGridController.CROSS_ACTION) {
+ this.boxes[row][column].cross();
+ }
+
+ this.mediator.check(row, column, type);
+ } else if (!this.boxes[row][column].isEmpty()
+ && (this.lastModified == null
+ || this.lastModified.isEmpty())) {
+ this.boxes[row][column].empty();
+
+ this.mediator.uncheck(row, column, type);
}
- this.lastChecked = this.checked[row][column];
+ this.lastModified = this.boxes[row][column];
this.checkCompleted();
}
@@ -287,7 +287,7 @@
for (int i = 0; i < this.data.length; i++) {
for (int j = 0; j < this.data[i].length; j++) {
- if (this.data[i][j] != this.checked[i][j].getValue()) {
+ if (this.data[i][j] && !this.boxes[i][j].isChecked()) {
completed = false;
break;
}
@@ -301,7 +301,8 @@
/** Indicates the current action has come to an end. */
void endAction() {
- this.lastChecked = null;
+ //this.lastChecked = null;
+ this.lastModified = null;
}
/*** Accessors ***/
@@ -323,49 +324,5 @@
int[][] getRowData() {
return this.rowData;
}
-
- /**
- * This class is a wrapper for boolean, allowing us to do reference
- * comparisons.
- *
- * @author Y. Norsa
- */
- private static final class DummyBoolean {
- /*** Field ***/
-
- /** The value being held. */
- private boolean value;
-
- /*** Constructor ***/
-
- /**
- * Constructor.
- *
- * @param value the value to hold
- */
- private DummyBoolean(boolean value) {
- this.value = value;
- }
-
- /*** Accessors ***/
-
- /**
- * Returns the value.
- *
- * @return held value
- */
- private boolean getValue() {
- return this.value;
- }
-
- /**
- * Allows to set the value.
- *
- * @param value new value to hold
- */
- private void setValue(boolean value) {
- this.value = value;
- }
- }
}
Modified: trunk/src/picross/grid/PicrossGridUI.java
===================================================================
--- trunk/src/picross/grid/PicrossGridUI.java 2007-06-06 08:27:54 UTC (rev 10)
+++ trunk/src/picross/grid/PicrossGridUI.java 2007-06-06 11:42:57 UTC (rev 11)
@@ -111,8 +111,8 @@
/** Position of the bottom end of the grid. */
private int bottomBoundary;
- /** Filled boxes. */
- private boolean[][] filled;
+ /** Current state of the grid. */
+ private Box[][] boxes;
/** Controller attached to this view. */
private transient PicrossGridController controller;
@@ -148,8 +148,14 @@
this.colData = colData;
this.rowData = rowData;
- this.filled = new boolean[this.width][this.height];
+ this.boxes = new Box[this.width][this.height];
+ for (int i = 0; i < this.boxes.length; i++) {
+ for (int j = 0; j < this.boxes[i].length; j++) {
+ this.boxes[i][j] = new Box();
+ }
+ }
+
this.leftBoundary =
this.rowData[0].length * PicrossGridUI.ROW_HINT_WIDTH;
@@ -218,23 +224,7 @@
x = this.leftBoundary;
for (int j = 0; j < this.width; j++) {
- if (this.filled[i][j]) {
- g.setColor(Color.BLACK);
- g.fillRect(x, y,
- PicrossGridUI.BOX_WIDTH,
- PicrossGridUI.BOX_HEIGHT);
- } else {
- g.setColor(Color.BLACK);
- g.drawRect(x, y,
- PicrossGridUI.BOX_WIDTH,
- PicrossGridUI.BOX_HEIGHT);
-
- g.setColor(Color.WHITE);
- g.fillRect(x + 1, y + 1,
- PicrossGridUI.BOX_WIDTH - 1,
- PicrossGridUI.BOX_HEIGHT - 1);
- }
-
+ g.drawImage(this.boxes[i][j].getImage(), x, y, null);
x += PicrossGridUI.BOX_WIDTH;
}
@@ -297,8 +287,8 @@
* @param row row of the box
* @param column column of the box
*/
- void check(int row, int column) {
- this.setBoxState(row, column, true);
+ void check(int row, int column, int type) {
+ this.setBoxState(row, column, true, type);
}
/**
@@ -307,8 +297,8 @@
* @param row row of the box
* @param column column of the box
*/
- void uncheck(int row, int column) {
- this.setBoxState(row, column, false);
+ void uncheck(int row, int column, int type) {
+ this.setBoxState(row, column, false, type);
}
/**
@@ -318,8 +308,17 @@
* @param column column of the box
* @param state new state of the box
*/
- private void setBoxState(int row, int column, boolean state) {
- this.filled[row][column] = state;
+ private void setBoxState(int row, int column, boolean state, int type) {
+ if (!state) {
+ this.boxes[row][column].empty();
+ } else {
+ if (type == PicrossGridController.CHECK_ACTION) {
+ this.boxes[row][column].check();
+ } else { //if (type == PicrossGridController.CROSS_ACTION) {
+ this.boxes[row][column].cross();
+ }
+ }
+
this.repaint();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2007-06-07 14:57:22
|
Revision: 22
http://picross.svn.sourceforge.net/picross/?rev=22&view=rev
Author: yvan_norsa
Date: 2007-06-07 07:57:23 -0700 (Thu, 07 Jun 2007)
Log Message:
-----------
pretty graphics
Modified Paths:
--------------
trunk/applet/index.html
trunk/src/picross/PicrossModel.java
trunk/src/picross/grid/GridModel.java
trunk/src/picross/grid/GridUI.java
Modified: trunk/applet/index.html
===================================================================
--- trunk/applet/index.html 2007-06-07 11:29:21 UTC (rev 21)
+++ trunk/applet/index.html 2007-06-07 14:57:23 UTC (rev 22)
@@ -10,7 +10,8 @@
<applet code="picross.applet.PicrossApplet"
archive="picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar"
- width="450"
- height="375" />
+ width="550"
+ height="400"
+ cache_option="no" />
</body>
</html>
Modified: trunk/src/picross/PicrossModel.java
===================================================================
--- trunk/src/picross/PicrossModel.java 2007-06-07 11:29:21 UTC (rev 21)
+++ trunk/src/picross/PicrossModel.java 2007-06-07 14:57:23 UTC (rev 22)
@@ -54,27 +54,182 @@
/** Constructor. */
PicrossModel() {
- this.width = 5;
- this.height = 5;
+ this.width = 19;
+ this.height = 14;
this.data = new boolean[this.width][this.height];
+ /*
+ for (int i = 0; i < this.width; i++) {
+ for (int j = 0; j < this.height; j++) {
+ this.data[i][j] = true;
+ }
+ }
+ */
+ this.data[0][7] = true;
+ this.data[0][8] = true;
+ this.data[0][13] = true;
- this.data[0][1] = true;
- this.data[0][3] = true;
- this.data[1][0] = true;
- this.data[1][1] = true;
- this.data[1][2] = true;
- this.data[1][3] = true;
- this.data[1][4] = true;
- this.data[2][1] = true;
- this.data[2][3] = true;
- this.data[3][0] = true;
- this.data[3][1] = true;
- this.data[3][2] = true;
- this.data[3][3] = true;
- this.data[3][4] = true;
- this.data[4][1] = true;
- this.data[4][3] = true;
+ this.data[1][6] = true;
+ this.data[1][7] = true;
+ this.data[1][8] = true;
+ this.data[1][9] = true;
+ this.data[1][12] = true;
+ this.data[1][13] = true;
+
+ this.data[2][6] = true;
+ this.data[2][7] = true;
+ this.data[2][8] = true;
+ this.data[2][9] = true;
+ this.data[2][12] = true;
+ this.data[2][13] = true;
+
+ this.data[3][5] = true;
+ this.data[3][6] = true;
+ this.data[3][8] = true;
+ this.data[3][9] = true;
+ this.data[3][10] = true;
+ this.data[3][11] = true;
+ this.data[3][12] = true;
+ this.data[3][13] = true;
+
+ this.data[4][5] = true;
+ this.data[4][6] = true;
+ this.data[4][7] = true;
+ this.data[4][8] = true;
+ this.data[4][9] = true;
+ this.data[4][10] = true;
+ this.data[4][11] = true;
+ this.data[4][12] = true;
+ this.data[4][13] = true;
+
+ this.data[5][0] = true;
+ this.data[5][1] = true;
+ this.data[5][2] = true;
+ this.data[5][3] = true;
+ this.data[5][4] = true;
+ this.data[5][5] = true;
+ this.data[5][6] = true;
+ this.data[5][7] = true;
+ this.data[5][8] = true;
+ this.data[5][9] = true;
+ this.data[5][10] = true;
+ this.data[5][11] = true;
+ this.data[5][12] = true;
+ this.data[5][13] = true;
+
+ this.data[6][0] = true;
+ this.data[6][1] = true;
+ this.data[6][2] = true;
+ this.data[6][3] = true;
+ this.data[6][4] = true;
+ this.data[6][5] = true;
+ this.data[6][6] = true;
+ this.data[6][7] = true;
+ this.data[6][8] = true;
+ this.data[6][9] = true;
+ this.data[6][10] = true;
+ this.data[6][11] = true;
+ this.data[6][12] = true;
+ this.data[6][13] = true;
+
+ this.data[7][1] = true;
+ this.data[7][2] = true;
+ this.data[7][3] = true;
+ this.data[7][4] = true;
+ this.data[7][5] = true;
+ this.data[7][6] = true;
+ this.data[7][7] = true;
+ this.data[7][8] = true;
+ this.data[7][9] = true;
+ this.data[7][10] = true;
+ this.data[7][11] = true;
+ this.data[7][12] = true;
+ this.data[7][13] = true;
+
+ this.data[8][8] = true;
+ this.data[8][9] = true;
+ this.data[8][10] = true;
+ this.data[8][11] = true;
+ this.data[8][12] = true;
+ this.data[8][13] = true;
+
+ this.data[9][7] = true;
+ this.data[9][8] = true;
+ this.data[9][9] = true;
+ this.data[9][10] = true;
+ this.data[9][11] = true;
+ this.data[9][12] = true;
+ this.data[9][13] = true;
+
+ this.data[10][7] = true;
+ this.data[10][8] = true;
+ this.data[10][9] = true;
+ this.data[10][10] = true;
+ this.data[10][11] = true;
+ this.data[10][12] = true;
+ this.data[10][13] = true;
+
+ this.data[11][6] = true;
+ this.data[11][7] = true;
+ this.data[11][8] = true;
+ this.data[11][9] = true;
+ this.data[11][10] = true;
+ this.data[11][11] = true;
+ this.data[11][12] = true;
+ this.data[11][13] = true;
+
+ this.data[12][6] = true;
+ this.data[12][7] = true;
+ this.data[12][8] = true;
+ this.data[12][9] = true;
+ this.data[12][10] = true;
+ this.data[12][11] = true;
+ this.data[12][12] = true;
+ this.data[12][13] = true;
+
+ this.data[13][6] = true;
+ this.data[13][7] = true;
+ this.data[13][8] = true;
+ this.data[13][9] = true;
+ this.data[13][10] = true;
+ this.data[13][11] = true;
+ this.data[13][12] = true;
+ this.data[13][13] = true;
+
+ this.data[14][6] = true;
+ this.data[14][7] = true;
+ this.data[14][8] = true;
+ this.data[14][9] = true;
+ this.data[14][10] = true;
+ this.data[14][11] = true;
+ this.data[14][12] = true;
+ this.data[14][13] = true;
+
+ this.data[15][7] = true;
+ this.data[15][8] = true;
+ this.data[15][9] = true;
+ this.data[15][10] = true;
+ this.data[15][11] = true;
+ this.data[15][12] = true;
+ this.data[15][13] = true;
+
+ this.data[16][9] = true;
+ this.data[16][10] = true;
+ this.data[16][11] = true;
+ this.data[16][12] = true;
+ this.data[16][13] = true;
+
+ this.data[17][8] = true;
+ this.data[17][9] = true;
+ this.data[17][10] = true;
+ this.data[17][11] = true;
+ this.data[17][12] = true;
+ this.data[17][13] = true;
+
+ this.data[18][9] = true;
+ this.data[18][10] = true;
+ this.data[18][11] = true;
+ this.data[18][12] = true;
}
/*** Accessors ***/
Modified: trunk/src/picross/grid/GridModel.java
===================================================================
--- trunk/src/picross/grid/GridModel.java 2007-06-07 11:29:21 UTC (rev 21)
+++ trunk/src/picross/grid/GridModel.java 2007-06-07 14:57:23 UTC (rev 22)
@@ -243,7 +243,7 @@
* (while dragging), do nothing
*/
if (this.lastModified != null
- && this.lastModified == this.boxes[row][column]) {
+ && this.lastModified == this.boxes[column][row]) {
return;
}
@@ -254,53 +254,53 @@
* (if we are in a checks serie and we are on a box which
* is already checked), do nothing
*/
- if (this.boxes[row][column].equals(this.lastModified)) {
+ if (this.boxes[column][row].equals(this.lastModified)) {
return;
}
}
- if (this.boxes[row][column].isEmpty()
+ if (this.boxes[column][row].isEmpty()
&& (this.lastModified == null || !this.lastModified.isEmpty())) {
if (type == GridController.CHECK_ACTION) {
- this.boxes[row][column].check();
+ this.boxes[column][row].check();
} else { //if (type == GridController.CROSS_ACTION) {
- this.boxes[row][column].cross();
+ this.boxes[column][row].cross();
}
this.mediator.check(row, column, type);
- } else if (!this.boxes[row][column].isEmpty()
+ } else if (!this.boxes[column][row].isEmpty()
&& (this.lastModified == null
|| this.lastModified.isEmpty())) {
- if (this.boxes[row][column].isChecked()) {
+ if (this.boxes[column][row].isChecked()) {
//GridModel.log.debug("checked");
if (type == GridController.CHECK_ACTION) {
- this.boxes[row][column].empty();
+ this.boxes[column][row].empty();
this.mediator.uncheck(row, column, type);
} else { //if (type == GridController.CROSS_ACTION) {
- this.boxes[row][column].cross();
+ this.boxes[column][row].cross();
this.mediator.check(row, column,
GridController.CROSS_ACTION);
}
- } else { //if (this.boxes[row][column].isCrossed()) {
+ } else { //if (this.boxes[column][row].isCrossed()) {
//GridModel.log.debug("crossed");
if (type == GridController.CROSS_ACTION) {
- this.boxes[row][column].empty();
+ this.boxes[column][row].empty();
this.mediator.uncheck(row, column, type);
} else {
//GridModel.log.debug("check()");
- this.boxes[row][column].check();
+ this.boxes[column][row].check();
this.mediator.check(row, column,
GridController.CHECK_ACTION);
}
}
}
- this.lastModified = this.boxes[row][column];
+ this.lastModified = this.boxes[column][row];
this.checkCompleted();
}
Modified: trunk/src/picross/grid/GridUI.java
===================================================================
--- trunk/src/picross/grid/GridUI.java 2007-06-07 11:29:21 UTC (rev 21)
+++ trunk/src/picross/grid/GridUI.java 2007-06-07 14:57:23 UTC (rev 22)
@@ -35,10 +35,17 @@
import java.awt.Color;
import java.awt.Dimension;
+import java.awt.Font;
import java.awt.Graphics;
+import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.font.FontRenderContext;
+
+import java.awt.geom.Rectangle2D;
+
import javax.swing.JPanel;
import org.apache.log4j.Logger;
@@ -55,7 +62,7 @@
private static final long serialVersionUID = 2050855523399115878L;
/** Space left before the top hints. */
- private static final int TOP_HINTS = 10;
+ private static final int TOP_HINTS = 10 + 3;
/** Width occupied by a row hint. */
private static final int ROW_HINT_WIDTH = 10;
@@ -69,6 +76,12 @@
/** Height occupied by a column hint. */
private static final int COL_HINT_HEIGHT = 12;
+ private static final Color HINT_FORE_COLOR = new Color(188, 211, 227);
+ private static final Color HINT_FILL_COLOR = new Color(131, 155, 200);
+ private static final Color HINT_TEXT_COLOR = new Color(233, 246, 255);
+
+ private static final Font HINT_FONT = new Font("Sans Serif", Font.BOLD, 10);
+
/** A box width. */
private static final int BOX_WIDTH = 25;
@@ -127,6 +140,8 @@
/** Controller attached to this view. */
private transient GridController controller;
+ int hintBoxSize;
+
/*** Constructor ***/
/**
@@ -158,15 +173,51 @@
this.colData = colData;
this.rowData = rowData;
- this.leftBoundary =
- this.rowData[0].length * GridUI.ROW_HINT_WIDTH;
+ /**/
+ //FontRenderContext frc = g2d.getFontRenderContext();
+ FontRenderContext frc = new FontRenderContext(null, true,
+ true);
+ Rectangle2D textBounds =
+ GridUI.HINT_FONT
+ .getStringBounds("42", frc);
+
+ double textWidth = textBounds.getWidth();
+ double textHeight = textBounds.getHeight();
+
+ this.hintBoxSize = (int) (textWidth > textHeight
+ ? textWidth : textHeight);
+ //this.bigHintBoxSize = this.hintBoxSize + 3;
+ this.hintBoxSize += 2;
+
+ /**/
+
+
+
+ /*
+ this.leftBoundary =
+ this.rowData[0].length * GridUI.ROW_HINT_WIDTH;
+ */
+
+ for (int i = 0; i < this.rowData[0].length; i++) {
+ int size = (this.rowData[0][i] / 10) + 1;
+ //this.leftBoundary += size * GridUI.ROW_HINT_WIDTH;
+ this.leftBoundary += size * this.hintBoxSize;
+ }
+
+ //this.leftBoundary = 70;
+
+ this.leftBoundary += 10;
+
this.rightBoundary = this.leftBoundary
+ (this.width * GridUI.BOX_WIDTH);
this.topBoundary = GridUI.TOP_HINTS
- + (this.colData[0].length * GridUI.COL_HINT_HEIGHT);
+ //+ (this.colData[0].length * GridUI.COL_HINT_HEIGHT);
+ + (this.colData[0].length * this.hintBoxSize);
+ //this.topBoundary = 70;
+
this.bottomBoundary = this.topBoundary
+ (this.height * GridUI.BOX_HEIGHT);
@@ -180,8 +231,8 @@
this.boxes = new GridBox[this.width][this.height];
- for (int i = 0; i < this.boxes.length; i++) {
- for (int j = 0; j < this.boxes[i].length; j++) {
+ for (int i = 0; i < this.width; i++) {
+ for (int j = 0; j < this.height; j++) {
/*
* We compute here the rectangle corresponding to each box
* so we'll be able
@@ -189,9 +240,9 @@
*/
this.boxes[i][j] =
new GridBox(new Rectangle(this.leftBoundary
+ + (i * GridUI.BOX_WIDTH),
+ this.topBoundary
+ (j * GridUI.BOX_WIDTH),
- this.topBoundary
- + (i * GridUI.BOX_WIDTH),
GridUI.BOX_WIDTH,
GridUI.BOX_HEIGHT));
}
@@ -215,8 +266,12 @@
Rectangle clipRect = g.getClipBounds();
if (this.topHintsRect.intersects(clipRect)) {
- GridUI.log.debug("top hints");
+ Graphics2D g2d = (Graphics2D) g.create();
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ //GridUI.log.debug("top hints");
+
int x = 0;
int y = GridUI.TOP_HINTS;
@@ -225,40 +280,51 @@
for (int j = 0; j < this.colData.length; j++) {
if (this.colData[j][i] != GridModel.EMPTY_HINT) {
- g.drawString(String.valueOf(this.colData[j][i]),
- x, y);
+ int hintX = x + (((x + GridUI.COL_HINT_WIDTH) - x) / 2);
+ this.drawColHint(g2d, this.colData[j][i], hintX, y);
}
x += GridUI.BOX_WIDTH;
}
- y += GridUI.COL_HINT_HEIGHT;
+ y += this.hintBoxSize + 2;
}
+
+ g2d.dispose();
}
if (this.leftHintsRect.intersects(clipRect)) {
- GridUI.log.debug("left hints");
+ //GridUI.log.debug("left hints");
+ Graphics2D g2d = (Graphics2D) g.create();
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+
int y = this.topBoundary;
for (int i = 0; i < this.rowData.length; i++) {
int x = 0;
+ int hintY = y + GridUI.ROW_HINT_HEIGHT;
+
for (int j = 0; j < this.rowData[i].length; j++) {
if (this.rowData[i][j] != GridModel.EMPTY_HINT) {
- g.drawString(String.valueOf(this.rowData[i][j]),
- x, y + GridUI.ROW_HINT_HEIGHT);
+ this.drawRowHint(g2d, this.rowData[i][j], x, hintY);
}
- x += GridUI.ROW_HINT_WIDTH;
+ x += this.hintBoxSize + 2;
}
y += GridUI.BOX_HEIGHT;
}
+
+ g2d.dispose();
}
- for (int i = 0; i < this.height; i++) {
- for (int j = 0; j < this.width; j++) {
+ for (int i = 0; i < this.width; i++) {
+ for (int j = 0; j < this.height; j++) {
+ //GridUI.log.debug("currentRect : " + i + "," + j);
+
Rectangle currentRect = this.boxes[i][j].getRect();
if (currentRect.intersects(clipRect)) {
@@ -277,6 +343,68 @@
/*** Methods ***/
+ private void drawColHint(Graphics2D g2d, int value, int hintX, int y) {
+ g2d.setColor(GridUI.HINT_FILL_COLOR);
+
+ g2d.fillRoundRect(hintX,
+ y - GridUI.COL_HINT_HEIGHT,
+ this.hintBoxSize,
+ this.hintBoxSize,
+ 8, 8);
+
+ g2d.setColor(GridUI.HINT_FORE_COLOR);
+
+ g2d.drawRoundRect(hintX,
+ y - GridUI.COL_HINT_HEIGHT,
+ this.hintBoxSize,
+ this.hintBoxSize,
+ 8, 8);
+
+ g2d.setColor(GridUI.HINT_TEXT_COLOR);
+ g2d.setFont(GridUI.HINT_FONT);
+
+ if (value < 10) {
+ g2d.drawString(String.valueOf(value),
+ hintX + (this.hintBoxSize / 3),
+ y);
+ } else {
+ g2d.drawString(String.valueOf(value),
+ hintX,
+ y);
+ }
+ }
+
+ private void drawRowHint(Graphics2D g2d, int value, int hintX, int y) {
+ g2d.setColor(GridUI.HINT_FILL_COLOR);
+
+ g2d.fillRoundRect(hintX,
+ y - GridUI.ROW_HINT_HEIGHT,
+ this.hintBoxSize,
+ this.hintBoxSize,
+ 8, 8);
+
+ g2d.setColor(GridUI.HINT_FORE_COLOR);
+
+ g2d.drawRoundRect(hintX,
+ y - GridUI.ROW_HINT_HEIGHT,
+ this.hintBoxSize,
+ this.hintBoxSize,
+ 8, 8);
+
+ g2d.setColor(GridUI.HINT_TEXT_COLOR);
+ g2d.setFont(GridUI.HINT_FONT);
+
+ if (value < 10) {
+ g2d.drawString(String.valueOf(value),
+ hintX + (this.hintBoxSize / 3) - 1,
+ y - 3);
+ } else {
+ g2d.drawString(String.valueOf(value),
+ hintX + 1,
+ y - 3);
+ }
+ }
+
/**
* This methods tells wether a point is inside the grid or not.
*
@@ -353,16 +481,16 @@
*/
private void setBoxState(int row, int column, boolean state, int type) {
if (!state) {
- this.boxes[row][column].empty();
+ this.boxes[column][row].empty();
} else {
if (type == GridController.CHECK_ACTION) {
- this.boxes[row][column].check();
+ this.boxes[column][row].check();
} else { //if (type == GridController.CROSS_ACTION) {
- this.boxes[row][column].cross();
+ this.boxes[column][row].cross();
}
}
- this.repaint(this.boxes[row][column].getRect());
+ this.repaint(this.boxes[column][row].getRect());
}
/**
@@ -375,7 +503,7 @@
//GridUI.log.debug("setRollover(" + row + ", " + column + ")");
this.rolloverEnded();
- this.rollover = this.boxes[row][column];
+ this.rollover = this.boxes[column][row];
this.repaint(this.rollover.getRect());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2007-06-07 11:18:40
|
Revision: 20
http://picross.svn.sourceforge.net/picross/?rev=20&view=rev
Author: yvan_norsa
Date: 2007-06-07 04:18:40 -0700 (Thu, 07 Jun 2007)
Log Message:
-----------
applet version
Modified Paths:
--------------
trunk/build.xml
trunk/src/picross/Picross.java
trunk/src/picross/PicrossController.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/PicrossUI.java
trunk/src/picross/grid/GridBox.java
trunk/src/picross/menus/MainMenuController.java
trunk/src/picross/menus/MainMenuMediator.java
trunk/src/picross/menus/MainMenuUI.java
Added Paths:
-----------
trunk/applet/
trunk/applet/index.html
trunk/images/crossed-rollover.png
trunk/src/picross/PicrossException.java
trunk/src/picross/app/
trunk/src/picross/app/MainMenuAppUI.java
trunk/src/picross/app/PicrossApp.java
trunk/src/picross/app/PicrossFrame.java
trunk/src/picross/app/package.html
trunk/src/picross/applet/
trunk/src/picross/applet/MainMenuAppletUI.java
trunk/src/picross/applet/PicrossApplet.java
trunk/src/picross/applet/package.html
Added: trunk/applet/index.html
===================================================================
--- trunk/applet/index.html (rev 0)
+++ trunk/applet/index.html 2007-06-07 11:18:40 UTC (rev 20)
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+ <title>Picross</title>
+ <meta name="author" content="Yvan Norsa">
+ </head>
+
+ <body>
+ <h1>Picross</h1>
+
+ <applet code="picross.applet.PicrossApplet"
+ archive="picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar"
+ width="450"
+ height="375" />
+ </body>
+</html>
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2007-06-07 04:22:39 UTC (rev 19)
+++ trunk/build.xml 2007-06-07 11:18:40 UTC (rev 20)
@@ -2,14 +2,19 @@
encoding="ISO-8859-1"?>
<project name="picross"
- default="run">
+ default="dist">
<property name="build.dir"
value="build" />
+ <property name="dist.dir"
+ value="dist" />
<property name="lib.dir"
value="lib" />
<property name="src.dir"
value="src" />
+ <property name="jar.name"
+ value="${dist.dir}/${ant.project.name}.jar" />
+
<property name="bundleHelper.jar"
value="${lib.dir}/bundleHelper.jar" />
<property name="mmvcs.jar"
@@ -20,6 +25,7 @@
<target name="-init"
depends="-setmode">
<mkdir dir="${build.dir}" />
+ <mkdir dir="${dist.dir}" />
</target>
<target name="release">
@@ -61,26 +67,41 @@
<classpath refid="classpath" />
</javac>
+ </target>
+ <target name="dist"
+ depends="compile">
<copy todir="${build.dir}/picross/properties"
failonerror="false">
<fileset dir="${src.dir}/picross/properties" />
</copy>
+ <copy todir="${build.dir}/picross/images">
+ <fileset dir="images" />
+ </copy>
+
+ <jar destfile="${jar.name}"
+ basedir="${build.dir}" />
</target>
<target name="run"
- depends="compile">
- <java classname="picross.Picross"
+ depends="dist">
+ <java classname="picross.app.PicrossApp"
failonerror="true"
fork="true"
dir=".">
- <classpath refid="classpath" />
+ <classpath>
+ <pathelement location="${jar.name}" />
+ <pathelement location="${bundleHelper.jar}" />
+ <pathelement location="${log4j.jar}" />
+ <pathelement location="${mmvcs.jar}" />
+ </classpath>
</java>
</target>
<target name="clean">
<delete dir="${build.dir}" />
+ <delete dir="${dist.dir}" />
<delete>
<fileset dir="."
@@ -90,7 +111,7 @@
</target>
<target name="rebuild"
- depends="clean, compile" />
+ depends="clean, dist" />
<property file="checkstyle.properties" />
Added: trunk/images/crossed-rollover.png
===================================================================
--- trunk/images/crossed-rollover.png (rev 0)
+++ trunk/images/crossed-rollover.png 2007-06-07 11:18:40 UTC (rev 20)
@@ -0,0 +1 @@
+link crossed.png
\ No newline at end of file
Property changes on: trunk/images/crossed-rollover.png
___________________________________________________________________
Name: svn:special
+ *
Modified: trunk/src/picross/Picross.java
===================================================================
--- trunk/src/picross/Picross.java 2007-06-07 04:22:39 UTC (rev 19)
+++ trunk/src/picross/Picross.java 2007-06-07 11:18:40 UTC (rev 20)
@@ -33,59 +33,49 @@
package picross;
-import java.io.File;
-
import java.util.Locale;
import javax.swing.ImageIcon;
-import javax.swing.SwingUtilities;
-import org.apache.log4j.PropertyConfigurator;
+//import org.apache.log4j.Logger;
/**
- * Application main class.
+ * Helper class.
*
* @author Y. Norsa
*/
public final class Picross {
/*** Constants ***/
- /** Log4j config file. */
- private static final String LOG4J_CONFIG = "log4j.properties";
-
/** Images directory. */
- private static final String IMAGES_DIR = "images" + File.separator;
+ private static final String IMAGES_DIR = "/picross/images/";
/** Images directory corresponding to the default locale. */
private static final String LOCAL_IMAGES_PATH = Picross.IMAGES_DIR
- + Locale.getDefault().getLanguage() + File.separator;
+ + Locale.getDefault().getLanguage() + "/";
- /*** Constructor ***/
+ /*** Static field ***/
- /** Constructor. */
- private Picross() {
- PropertyConfigurator.configure(Picross.LOG4J_CONFIG);
+ /** The class' logger. */
+ //private static Logger log = Logger.getLogger(Picross.class);
- new PicrossMediator();
- }
+ /*** Constructor ***/
- /*** Main method ***/
+ /** Fake constructor. */
+ private Picross() { }
+ /*** Static methods ***/
+
/**
- * Application main method.
+ * Loads an image.
*
- * @param args command line parameters
+ * @param path path of the image
+ * @return the image
*/
- public static void main(String[] args) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- new Picross();
- }
- });
+ private static ImageIcon loadImage(String path) {
+ return new ImageIcon(Picross.class.getResource(path));
}
- /*** Static methods ***/
-
/**
* Returns an image.
*
@@ -93,7 +83,7 @@
* @return the image
*/
public static ImageIcon getImage(String name) {
- return new ImageIcon(Picross.IMAGES_DIR + name);
+ return Picross.loadImage(Picross.IMAGES_DIR + name);
}
/**
@@ -103,7 +93,7 @@
* @return the image
*/
public static ImageIcon getLocalizedImage(String name) {
- return new ImageIcon(Picross.LOCAL_IMAGES_PATH + name);
+ return Picross.loadImage(Picross.LOCAL_IMAGES_PATH + name);
}
}
Modified: trunk/src/picross/PicrossController.java
===================================================================
--- trunk/src/picross/PicrossController.java 2007-06-07 04:22:39 UTC (rev 19)
+++ trunk/src/picross/PicrossController.java 2007-06-07 11:18:40 UTC (rev 20)
@@ -64,7 +64,18 @@
if (cmd.equals(PicrossController.MESSAGE_CMD)) {
this.view.displayMessage(e.getComment());
+ return;
}
+
+ if (cmd.equals(PicrossController.ERROR_CMD)) {
+ this.view.displayError(e.getComment());
+ return;
+ }
+
+ if (cmd.equals(PicrossController.DISPOSE_CMD)) {
+ this.view.exit();
+ return;
+ }
}
/*** Accessor ***/
Added: trunk/src/picross/PicrossException.java
===================================================================
--- trunk/src/picross/PicrossException.java (rev 0)
+++ trunk/src/picross/PicrossException.java 2007-06-07 11:18:40 UTC (rev 20)
@@ -0,0 +1,58 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross;
+
+/**
+ * General exception.
+ *
+ * @author Y. Norsa
+ */
+public final class PicrossException extends Exception {
+ /*** Constant ***/
+
+ /** Serialisation ID. */
+ private static final long serialVersionUID = 1716838910721477345L;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @param cause parent exception
+ */
+ public PicrossException(Throwable cause) {
+ super(cause);
+ }
+}
+
Property changes on: trunk/src/picross/PicrossException.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2007-06-07 04:22:39 UTC (rev 19)
+++ trunk/src/picross/PicrossMediator.java 2007-06-07 11:18:40 UTC (rev 20)
@@ -51,33 +51,46 @@
*
* @author Y. Norsa
*/
-final class PicrossMediator extends Mediateur {
+public final class PicrossMediator extends Mediateur {
/*** Static field ***/
/** Class' logger. */
//private static Logger log = Logger.getLogger(PicrossMediator.class);
- /*** Fields ***/
+ /*** Field ***/
- /** The view's controller. */
- private PicrossController controller;
-
/** Main view. */
private PicrossUI view;
/*** Constructor ***/
/** Constructor. */
- PicrossMediator() {
+ public PicrossMediator(PicrossUI view) {
BundleHelper.loadBundle("picross.properties.messages_picross");
- this.controller = new PicrossController();
- this.addSimpleListener(this.controller);
+ this.view = view;
- MainMenuMediator mediator = new MainMenuMediator();
+ PicrossController controller = new PicrossController();
+ controller.setView(view);
+
+ this.addSimpleListener(controller);
+
+ MainMenuMediator mediator = null;
+
+ try {
+ mediator = new MainMenuMediator(view);
+ } catch (PicrossException picrossEx) {
+ this.fireEventPerformed(PicrossController.ERROR_CMD,
+ picrossEx.getMessage());
+
+ this.exit();
+ return;
+ }
+
mediator.addSimpleListener(this);
- this.view = new PicrossUI(mediator.getView());
+ //this.view = new PicrossUI(mediator.getView());
+ this.view.setContent(mediator.getView());
}
/*** Method overloaded from the Mediateur class ***/
@@ -97,13 +110,12 @@
grid.addSimpleListener(this);
this.view.setContent(grid.getView());
- this.controller.setView(this.view);
return;
}
if (cmd.equals(MainMenuController.EXIT_CMD)) {
- this.view.dispose();
+ this.exit();
return;
}
@@ -113,5 +125,12 @@
return;
}
}
+
+ /*** Method ***/
+
+ /** Exits the application. */
+ private void exit() {
+ this.fireEventPerformed(PicrossController.DISPOSE_CMD);
+ }
}
Modified: trunk/src/picross/PicrossUI.java
===================================================================
--- trunk/src/picross/PicrossUI.java 2007-06-07 04:22:39 UTC (rev 19)
+++ trunk/src/picross/PicrossUI.java 2007-06-07 11:18:40 UTC (rev 20)
@@ -33,87 +33,43 @@
package picross;
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
-import javax.swing.SwingUtilities;
/**
* Main window.
*
* @author Y. Norsa
*/
-final class PicrossUI extends JFrame {
- /*** Constant ***/
-
- /** Serialisation ID. */
- private static final long serialVersionUID = -6091243469021691734L;
-
- /*** Constructor ***/
-
- /** Constructor. */
- PicrossUI(JPanel content) {
- super("Picross");
-
- this.setContent(content);
- this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- this.setVisible(true);
- }
-
- /*** Method ***/
-
+public interface PicrossUI {
/**
- * Sets the frame panel and resizes the window.
+ * Sets the content panel.
*
* @param content new content panel
*/
- void setContent(JPanel content) {
- this.setContentPane(content);
- this.pack();
- }
+ void setContent(JPanel content);
/**
* Displays a message box.
*
* @param msg message to be displayed
*/
- void displayMessage(String msg) {
- SwingUtilities.invokeLater(new RunnableDialog(this, msg));
- }
+ void displayMessage(String msg);
/**
- * Inner class displaying a message asynchronously.
+ * Displays an error message.
*
- * @author Y. Norsa
+ * @param msg error message
*/
- private static final class RunnableDialog implements Runnable {
- /*** Fields ***/
+ void displayError(String msg);
- /** Parent frame. */
- private JFrame parent;
+ /**
+ * Returns the name of the main menu class.
+ *
+ * @return name of the main menu class
+ */
+ String getMainMenuClass();
- /** Message to be displayed. */
- private String msg;
-
- /*** Constructor ***/
-
- /**
- * Constructor.
- *
- * @param parent parent frame
- * @param msg message to be displayed
- */
- private RunnableDialog(JFrame parent, String msg) {
- this.parent = parent;
- this.msg = msg;
- }
-
- /*** Method implanted from the interface Runnable ***/
-
- /** {@inheritDoc} */
- public void run() {
- JOptionPane.showMessageDialog(this.parent, this.msg);
- }
- }
+ /** Method called when the application exits. */
+ void exit();
}
Added: trunk/src/picross/app/MainMenuAppUI.java
===================================================================
--- trunk/src/picross/app/MainMenuAppUI.java (rev 0)
+++ trunk/src/picross/app/MainMenuAppUI.java 2007-06-07 11:18:40 UTC (rev 20)
@@ -0,0 +1,108 @@
+/*
+ * $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.app;
+
+import java.awt.event.ActionListener;
+
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+
+import picross.Picross;
+
+import picross.menus.MainMenuController;
+import picross.menus.MainMenuUI;
+
+/**
+ * Main menu for the application version.
+ *
+ * @author Y. Norsa
+ */
+public final class MainMenuAppUI extends MainMenuUI {
+ /*** Constans ***/
+
+ /** Serialisation ID. */
+ private static final long serialVersionUID = 8153436550520127667L;
+
+ /** "Play" button X coordinate. */
+ private static final int PLAY_BUTTON_X = 50;
+
+ /** "Play" button Y coordinate. */
+ private static final int PLAY_BUTTON_Y = 225;
+
+ /** Image for the "exit" button. */
+ private static final String EXIT_BUTTON_IMAGE = "button-exit.png";
+
+ /** "Exit" button X coordinate. */
+ private static final int EXIT_BUTTON_X = 250;
+
+ /** "Exit" button Y coordinate. */
+ private static final int EXIT_BUTTON_Y = 225;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @param controller controller for the buttons
+ */
+ public MainMenuAppUI(ActionListener controller) {
+ super(controller);
+
+ ImageIcon exitIcon =
+ Picross.getLocalizedImage(MainMenuAppUI.EXIT_BUTTON_IMAGE);
+ JButton exitButton = new JButton(exitIcon);
+ exitButton.setActionCommand(MainMenuController.EXIT_CMD);
+ exitButton.addActionListener(controller);
+ exitButton.setBorder(null);
+ exitButton.setBounds(MainMenuAppUI.EXIT_BUTTON_X,
+ MainMenuAppUI.EXIT_BUTTON_Y,
+ exitIcon.getIconWidth(),
+ exitIcon.getIconHeight());
+ this.add(exitButton);
+ }
+
+ /*** Methods overloaded from MainMenuUI ***/
+
+ /** {@inheritDoc} */
+ protected int getPlayButtonX() {
+ return MainMenuAppUI.PLAY_BUTTON_X;
+ }
+
+ /** {@inheritDoc} */
+ protected int getPlayButtonY() {
+ return MainMenuAppUI.PLAY_BUTTON_Y;
+ }
+}
+
+
Property changes on: trunk/src/picross/app/MainMenuAppUI.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/app/PicrossApp.java
===================================================================
--- trunk/src/picross/app/PicrossApp.java (rev 0)
+++ trunk/src/picross/app/PicrossApp.java 2007-06-07 11:18:40 UTC (rev 20)
@@ -0,0 +1,76 @@
+/*
+ * $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.app;
+
+import javax.swing.SwingUtilities;
+
+import org.apache.log4j.PropertyConfigurator;
+
+import picross.PicrossMediator;
+
+/**
+ * Main class of the application version.
+ *
+ * @author Y. Norsa
+ */
+public final class PicrossApp {
+ /*** Constant ***/
+
+ /** Log4j config file. */
+ private static final String LOG4J_CONFIG = "log4j.properties";
+
+ /** Constructor. */
+
+ /** Constructor. */
+ private PicrossApp() {
+ PropertyConfigurator.configure(PicrossApp.LOG4J_CONFIG);
+ new PicrossMediator(new PicrossFrame());
+ }
+
+ /*** Main method ***/
+
+ /**
+ * Application main method.
+ *
+ * @param args command line parameters
+ */
+ public static void main(String[] args) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ new PicrossApp();
+ }
+ });
+ }
+}
+
Property changes on: trunk/src/picross/app/PicrossApp.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/app/PicrossFrame.java
===================================================================
--- trunk/src/picross/app/PicrossFrame.java (rev 0)
+++ trunk/src/picross/app/PicrossFrame.java 2007-06-07 11:18:40 UTC (rev 20)
@@ -0,0 +1,95 @@
+/*
+ * $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.app;
+
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+
+import picross.PicrossUI;
+
+/**
+ * Main window of the application version.
+ *
+ * @author Y. Norsa
+ */
+public final class PicrossFrame extends JFrame implements PicrossUI {
+ /*** Constants ***/
+
+ /** Serialisation ID. */
+ private static final long serialVersionUID = -6091243469021691734L;
+
+ /** Main menu class. */
+ private static final String MAIN_MENU_CLASS = "picross.app.MainMenuAppUI";
+
+ /*** Constructor ***/
+
+ /** Constructor. */
+ public PicrossFrame() {
+ super("Picross");
+
+ this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ this.setVisible(true);
+ }
+
+ /*** Methods implanted from the interface PicrossUI ***/
+
+ /** {@inheritDoc} */
+ public void setContent(JPanel content) {
+ this.setContentPane(content);
+ this.pack();
+ }
+
+ /** {@inheritDoc} */
+ public void displayMessage(String msg) {
+ JOptionPane.showMessageDialog(this, msg);
+ }
+
+ /** {@inheritDoc} */
+ public void displayError(String msg) {
+ JOptionPane.showMessageDialog(this, msg,
+ "Picross", JOptionPane.ERROR_MESSAGE);
+ }
+
+ /** {@inheritDoc} */
+ public void exit() {
+ this.dispose();
+ }
+
+ /** {@inheritDoc} */
+ public String getMainMenuClass() {
+ return PicrossFrame.MAIN_MENU_CLASS;
+ }
+}
+
Property changes on: trunk/src/picross/app/PicrossFrame.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/app/package.html
===================================================================
--- trunk/src/picross/app/package.html (rev 0)
+++ trunk/src/picross/app/package.html 2007-06-07 11:18:40 UTC (rev 20)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <!--
+ $Id$
+ -->
+ </head>
+
+ <body bgcolor="white">
+ Classes for the application version.
+ </body>
+</html>
Property changes on: trunk/src/picross/app/package.html
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/applet/MainMenuAppletUI.java
===================================================================
--- trunk/src/picross/applet/MainMenuAppletUI.java (rev 0)
+++ trunk/src/picross/applet/MainMenuAppletUI.java 2007-06-07 11:18:40 UTC (rev 20)
@@ -0,0 +1,92 @@
+/*
+ * $Id$
+ * \xC9crit le 07/06/2007 par Y. Norsa
+ *
+ * Copyright (c) 2007
+ * Projet Carte Lorraine de l'Etudiant (CLE)
+ *
+ * Universit\xE9 Henri Poincar\xE9, Nancy
+ * Universit\xE9 Nancy2
+ * Institut National Polytechnique de Lorraine
+ * Universit\xE9 Paul Verlaine, Metz
+ *
+ * Ce projet regroupe les d\xE9veloppements concernant la production
+ * et l'exploitation de la Carte Lorraine de l'Etudiant
+ * (carte \xE0 puce sans contact Mifare).
+ *
+ * Ce logiciel est r\xE9gi par la licence CeCILL soumise au droit fran\xE7ais et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffus\xE9e par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilit\xE9 au code source et des droits de copie,
+ * de modification et de redistribution accord\xE9s par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limit\xE9e. Pour les m\xEAmes raisons,
+ * seule une responsabilit\xE9 restreinte p\xE8se sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les conc\xE9dants successifs.
+ *
+ * A cet \xE9gard l'attention de l'utilisateur est attir\xE9e sur les risques
+ * associ\xE9s au chargement, \xE0 l'utilisation, \xE0 la modification et/ou au
+ * d\xE9veloppement et \xE0 la reproduction du logiciel par l'utilisateur \xE9tant
+ * donn\xE9 sa sp\xE9cificit\xE9 de logiciel libre, qui peut le rendre complexe \xE0
+ * manipuler et qui le r\xE9serve donc \xE0 des d\xE9veloppeurs et des professionnels
+ * avertis poss\xE9dant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invit\xE9s \xE0 charger et tester l'ad\xE9quation du
+ * logiciel \xE0 leurs besoins dans des conditions permettant d'assurer la
+ * s\xE9curit\xE9 de leurs syst\xE8mes et ou de leurs donn\xE9es et, plus g\xE9n\xE9ralement,
+ * \xE0 l'utiliser et l'exploiter dans les m\xEAmes conditions de s\xE9curit\xE9.
+ *
+ * Le fait que vous puissiez acc\xE9der \xE0 cet en-t\xEAte signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accept\xE9 les
+ * termes.
+ */
+
+
+package picross.applet;
+
+import java.awt.event.ActionListener;
+
+import picross.menus.MainMenuUI;
+
+/**
+ * Main menu for the applet version.
+ *
+ * @author Y. Norsa
+ */
+public final class MainMenuAppletUI extends MainMenuUI {
+ /*** Constants ***/
+
+ /** Serialisation ID. */
+ private static final long serialVersionUID = 5820728724819549202L;
+
+ /** "Play" button X coordinate. */
+ private static final int PLAY_BUTTON_X = 149;
+
+ /** "Play" button Y coordinate. */
+ private static final int PLAY_BUTTON_Y = 225;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @param controller controller for the buttons
+ */
+ public MainMenuAppletUI(ActionListener controller) {
+ super(controller);
+ }
+
+ /*** Methods inherited from the class MainMenuUI ***/
+
+ /** {@inheritDoc} */
+ protected int getPlayButtonX() {
+ return MainMenuAppletUI.PLAY_BUTTON_X;
+ }
+
+ /** {@inheritDoc} */
+ protected int getPlayButtonY() {
+ return MainMenuAppletUI.PLAY_BUTTON_Y;
+ }
+}
+
Property chang...
[truncated message content] |
|
From: <yva...@us...> - 2007-06-17 18:55:45
|
Revision: 41
http://picross.svn.sourceforge.net/picross/?rev=41&view=rev
Author: yvan_norsa
Date: 2007-06-17 11:55:46 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
more tests
Modified Paths:
--------------
trunk/build.xml
trunk/src/picross/PicrossException.java
trunk/src/picross/game/simple/XBMModel.java
trunk/src/picross/tests/AbstractPicrossGridTest.java
Added Paths:
-----------
trunk/src/picross/game/simple/XBMException.java
trunk/src/picross/game/simple/XBMModelTest.java
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2007-06-15 19:57:57 UTC (rev 40)
+++ trunk/build.xml 2007-06-17 18:55:46 UTC (rev 41)
@@ -148,8 +148,8 @@
<target name="doc"
depends="compile">
- <!-- FIXME test classes which are *not* in a "tests" subpackage
- are included in the Javadoc -->
+ <!-- FIXME test classes which are not in a "tests" subpackage
+ shouldn't be included in the generated Javadoc -->
<javadoc destdir="${doc.dir}"
link="http://java.sun.com/j2se/1.5.0/docs/api">
<packageset dir="${src.dir}"
Modified: trunk/src/picross/PicrossException.java
===================================================================
--- trunk/src/picross/PicrossException.java 2007-06-15 19:57:57 UTC (rev 40)
+++ trunk/src/picross/PicrossException.java 2007-06-17 18:55:46 UTC (rev 41)
@@ -38,13 +38,13 @@
*
* @author Y. Norsa
*/
-public final class PicrossException extends Exception {
+public class PicrossException extends Exception {
/*** Constant ***/
/** Serialisation ID. */
private static final long serialVersionUID = 1716838910721477345L;
- /*** Constructor ***/
+ /*** Constructors ***/
/**
* Constructor.
@@ -54,5 +54,14 @@
public PicrossException(Throwable cause) {
super(cause);
}
+
+ /**
+ * Constructor.
+ *
+ * @param msg message describing the exception
+ */
+ public PicrossException(String msg) {
+ super(msg);
+ }
}
Added: trunk/src/picross/game/simple/XBMException.java
===================================================================
--- trunk/src/picross/game/simple/XBMException.java (rev 0)
+++ trunk/src/picross/game/simple/XBMException.java 2007-06-17 18:55:46 UTC (rev 41)
@@ -0,0 +1,68 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.simple;
+
+import picross.PicrossException;
+
+/**
+ * Exception thrown when reading an invalid XBM file.
+ *
+ * @author Y. Norsa
+ */
+final class XBMException extends PicrossException {
+ /*** Constant ***/
+
+ /** Serialisation ID. */
+ private static final long serialVersionUID = 3928727649077087059L;
+
+ /*** Constructors ***/
+
+ /**
+ * Constructor.
+ *
+ * @param msg message describing the exception
+ */
+ XBMException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param cause parent exception
+ */
+ XBMException(Throwable cause) {
+ super(cause);
+ }
+}
Property changes on: trunk/src/picross/game/simple/XBMException.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/game/simple/XBMModel.java
===================================================================
--- trunk/src/picross/game/simple/XBMModel.java 2007-06-15 19:57:57 UTC (rev 40)
+++ trunk/src/picross/game/simple/XBMModel.java 2007-06-17 18:55:46 UTC (rev 41)
@@ -51,6 +51,44 @@
* @author Y. Norsa
*/
final class XBMModel extends AbstractPicrossModel {
+ /*** Constants ***/
+
+ /** Indicates a constant definition. */
+ private static final String DEFINE_DIRECTIVE = "#define ";
+
+ /** The width value. */
+ private static final String WIDTH_KEYWORD = "width";
+
+ /** The height value. */
+ private static final String HEIGHT_KEYWORD = "height";
+
+ /** Character before the int value. */
+ private static final char VALUE_MARKER = ' ';
+
+ /** The data values. */
+ private static final String BITS_KEYWORD = "bits";
+
+ /** Value separator. */
+ private static final String VALUE_SEPARATOR = ",";
+
+ /** String indicating a hex value. */
+ private static final String HEX_LEADING = "0x";
+
+ /** In case of error. */
+ private static final int ERROR_VALUE = -1;
+
+ /** Beginning of the actual value. */
+ private static final int VALUE_BEGINNING_POS = 2;
+
+ /** End of the actual value. */
+ private static final int VALUE_END_POS = 4;
+
+ /** Hexadecimal number radix. */
+ private static final int HEX_RADIX = 16;
+
+ /** Length of a byte. */
+ private static final int BYTE_LENGTH = 8;
+
/*** Static field ***/
/** The class' logger. */
@@ -62,11 +100,19 @@
* Constructor.
*
* @param input XBM file input stream
+ * @throws IllegalArgumentException if <code>input</code>
+ * is <code>null</code>
* @throws IOException if there is a problem while reading the file
+ * @throws XBMException if the file isn't a valid XBM file
*/
- XBMModel(InputStream input) throws IOException {
+ XBMModel(InputStream input) throws IOException, XBMException,
+ IllegalArgumentException {
super();
+ if (input == null) {
+ throw new IllegalArgumentException("input can't be null");
+ }
+
List<String> byteValues = new ArrayList<String>();
BufferedReader in = new BufferedReader(new InputStreamReader(input));
@@ -75,37 +121,39 @@
try {
while ((line = in.readLine()) != null) {
- if (line.contains("width")) {
- this.width =
- Integer.parseInt(line.substring(line
- .lastIndexOf(' '))
- .trim());
+ if (line.startsWith(XBMModel.DEFINE_DIRECTIVE)
+ && line.contains(XBMModel.WIDTH_KEYWORD)) {
+
+ this.width = XBMModel.readLineValue(line);
+
XBMModel.log.debug("width = " + this.width);
continue;
}
- if (line.contains("height")) {
- this.height =
- Integer.parseInt(line.substring(line
- .lastIndexOf(' '))
- .trim());
+ if (line.startsWith(XBMModel.DEFINE_DIRECTIVE)
+ && line.contains(XBMModel.HEIGHT_KEYWORD)) {
+
+ this.height = XBMModel.readLineValue(line);
+
XBMModel.log.debug("height = " + this.height);
continue;
}
- if (line.contains("bits")) {
+ if (line.contains(XBMModel.BITS_KEYWORD)) {
this.data = new boolean[this.width][this.height];
while ((line = in.readLine()) != null) {
- String[] values = line.split(",");
+ String[] values = line.split(XBMModel.VALUE_SEPARATOR);
for (int i = 0; i < values.length; i++) {
//XBMModel.log.debug("values[" + i + "] = "
//+ values[i]);
- if (values[i].contains("0x")) {
+ if (values[i].contains(XBMModel.HEX_LEADING)) {
String byteStr =
- values[i].trim().substring(2, 4);
+ values[i].trim()
+ .substring(XBMModel.VALUE_BEGINNING_POS,
+ XBMModel.VALUE_END_POS);
byteValues.add(byteStr);
}
}
@@ -122,20 +170,19 @@
}
}
+ if (width <= 0 || height <= 0 || this.data == null) {
+ throw new XBMException("Invalid XBM file");
+ }
+
int xIndex = 0;
int yIndex = 0;
for (String byteStr : byteValues) {
- int byteVal = Integer.parseInt(byteStr, 16);
- String binaryStr = Integer.toBinaryString(byteVal);
+ String binaryStr = XBMModel.toBits(byteStr);
- while (binaryStr.length() < 8) {
- binaryStr = "0" + binaryStr;
- }
-
//XBMModel.log.debug(binaryStr);
- for (int j = 8 - 1; j >= 0; j--) {
+ for (int j = XBMModel.BYTE_LENGTH - 1; j >= 0; j--) {
//XBMModel.log.debug("this.data[" + yIndex
//+ "][" + xIndex + "] = "
//+ (binaryStr.charAt(j) == '1' ? true
@@ -155,5 +202,45 @@
}
}
}
+
+ /*** Static methods ***/
+
+ /**
+ * Reads a constant value (C-style) in a line.
+ *
+ * @param line the line to read
+ * @return defined value or -1
+ * @throws XBMException if the line format is incorrect
+ */
+ private static int readLineValue(String line) throws XBMException {
+ int spaceIndex = line.lastIndexOf(XBMModel.VALUE_MARKER);
+
+ if (spaceIndex == -1) {
+ return XBMModel.ERROR_VALUE;
+ }
+
+ try {
+ return Integer.parseInt(line.substring(spaceIndex).trim());
+ } catch (NumberFormatException numberEx) {
+ throw new XBMException(numberEx);
+ }
+ }
+
+ /**
+ * Converts a hex value to its binary representation.
+ *
+ * @param byteStr the original String
+ * @return binary representation
+ */
+ private static String toBits(String byteStr) {
+ int byteVal = Integer.parseInt(byteStr, XBMModel.HEX_RADIX);
+ String binaryStr = Integer.toBinaryString(byteVal);
+
+ while (binaryStr.length() < XBMModel.BYTE_LENGTH) {
+ binaryStr = '0' + binaryStr;
+ }
+
+ return binaryStr;
+ }
}
Added: trunk/src/picross/game/simple/XBMModelTest.java
===================================================================
--- trunk/src/picross/game/simple/XBMModelTest.java (rev 0)
+++ trunk/src/picross/game/simple/XBMModelTest.java 2007-06-17 18:55:46 UTC (rev 41)
@@ -0,0 +1,99 @@
+/*
+ * $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.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("blarg.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) { }
+ }
+}
Property changes on: trunk/src/picross/game/simple/XBMModelTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/tests/AbstractPicrossGridTest.java
===================================================================
--- trunk/src/picross/tests/AbstractPicrossGridTest.java 2007-06-15 19:57:57 UTC (rev 40)
+++ trunk/src/picross/tests/AbstractPicrossGridTest.java 2007-06-17 18:55:46 UTC (rev 41)
@@ -97,5 +97,18 @@
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);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-16 09:31:03
|
Revision: 44
http://picross.svn.sourceforge.net/picross/?rev=44&view=rev
Author: yvan_norsa
Date: 2008-04-16 02:31:04 -0700 (Wed, 16 Apr 2008)
Log Message:
-----------
added debug target
Modified Paths:
--------------
trunk/build.xml
trunk/src/picross/app/PicrossApp.java
Added Paths:
-----------
trunk/lib/debug.jar
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-04-16 09:24:40 UTC (rev 43)
+++ trunk/build.xml 2008-04-16 09:31:04 UTC (rev 44)
@@ -19,6 +19,8 @@
<property name="bundleHelper.jar"
value="${lib.dir}/bundleHelper.jar" />
+ <property name="debug.jar"
+ value="${lib.dir}/debug.jar" />
<property name="junit.jar"
value="${lib.dir}/junit.jar" />
<property name="log4j.jar"
@@ -109,6 +111,22 @@
</java>
</target>
+ <target name="run-debug"
+ depends="dist">
+ <java classname="picross.app.PicrossApp"
+ failonerror="true"
+ fork="true"
+ dir=".">
+ <classpath>
+ <pathelement location="${jar.name}" />
+ <pathelement location="${bundleHelper.jar}" />
+ <pathelement location="${log4j.jar}" />
+ <pathelement location="${mmvcs.jar}" />
+ <pathelement location="${debug.jar}" />
+ </classpath>
+ </java>
+ </target>
+
<target name="test"
depends="dist">
<junit haltonfailure="yes"
Added: trunk/lib/debug.jar
===================================================================
(Binary files differ)
Property changes on: trunk/lib/debug.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/picross/app/PicrossApp.java
===================================================================
--- trunk/src/picross/app/PicrossApp.java 2008-04-16 09:24:40 UTC (rev 43)
+++ trunk/src/picross/app/PicrossApp.java 2008-04-16 09:31:04 UTC (rev 44)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -68,9 +68,50 @@
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
+ PicrossApp.setupDebugging();
new PicrossApp();
}
});
}
+
+ /*** Static method ***/
+
+ /** Tries to load the debugging tools from debug.jar. */
+ private static void setupDebugging() {
+ try {
+ Class managerClass = Class.forName(
+ "org.jdesktop.swinghelper.debug.CheckThreadViolationRepaintManager");
+ java.lang.reflect.Constructor construct =
+ managerClass.getConstructor((Class) null);
+ javax.swing.RepaintManager manag =
+ (javax.swing.RepaintManager) construct
+ .newInstance((Class) null);
+ javax.swing.RepaintManager.setCurrentManager(manag);
+ } catch (ClassNotFoundException classEx) {
+ } catch (NoSuchMethodException methodEx) {
+ methodEx.printStackTrace();
+ } catch (InstantiationException instantiationEx) {
+ instantiationEx.printStackTrace();
+ } catch (IllegalAccessException accessEx) {
+ accessEx.printStackTrace();
+ } catch (java.lang.reflect.InvocationTargetException targetEx) {
+ targetEx.printStackTrace();
+ }
+
+ try {
+ Class monitorClass = Class.forName(
+ "org.jdesktop.swinghelper.debug.EventDispatchThreadHangMonitor");
+ java.lang.reflect.Method method =
+ monitorClass.getMethod("initMonitoring");
+ method.invoke(null);
+ } catch (ClassNotFoundException classEx) {
+ } catch (NoSuchMethodException methodEx) {
+ methodEx.printStackTrace();
+ } catch (IllegalAccessException accessEx) {
+ accessEx.printStackTrace();
+ } catch (java.lang.reflect.InvocationTargetException targetEx) {
+ targetEx.printStackTrace();
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-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...> - 2007-06-06 13:23:00
|
Revision: 13
http://picross.svn.sourceforge.net/picross/?rev=13&view=rev
Author: yvan_norsa
Date: 2007-06-06 06:22:59 -0700 (Wed, 06 Jun 2007)
Log Message:
-----------
added menu
Modified Paths:
--------------
trunk/src/picross/PicrossMediator.java
trunk/src/picross/PicrossUI.java
Added Paths:
-----------
trunk/images/button-exit.png
trunk/images/button-play.png
trunk/images/mainMenu.png
trunk/src/picross/menus/
trunk/src/picross/menus/MainMenuController.java
trunk/src/picross/menus/MainMenuMediator.java
trunk/src/picross/menus/MainMenuUI.java
Added: trunk/images/button-exit.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/button-exit.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/images/button-play.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/button-play.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/images/mainMenu.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/mainMenu.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2007-06-06 12:07:47 UTC (rev 12)
+++ trunk/src/picross/PicrossMediator.java 2007-06-06 13:22:59 UTC (rev 13)
@@ -36,11 +36,14 @@
import fr.cle.mmvcs.Mediateur;
import fr.cle.mmvcs.SimpleEvent;
-//import org.apache.log4j.Logger;
+import org.apache.log4j.Logger;
import picross.grid.PicrossGridController;
import picross.grid.PicrossGridMediator;
+import picross.menus.MainMenuController;
+import picross.menus.MainMenuMediator;
+
/**
* Application mediator.
*
@@ -50,38 +53,56 @@
/*** Static field ***/
/** Class' logger. */
- //private static Logger log = Logger.getLogger(PicrossMediator.class);
+ private static Logger log = Logger.getLogger(PicrossMediator.class);
+ private PicrossController controller;
+ private PicrossUI view;
+
/*** Constructor ***/
/** Constructor. */
PicrossMediator() {
- PicrossModel model = new PicrossModel();
+ this.controller = new PicrossController();
+ this.addSimpleListener(this.controller);
- PicrossController controller = new PicrossController();
- this.addSimpleListener(controller);
+ MainMenuMediator mediator = new MainMenuMediator();
+ mediator.addSimpleListener(this);
- PicrossGridMediator grid =
- new PicrossGridMediator(model.getWidth(), model.getHeight(),
- model.getData());
- grid.addSimpleListener(this);
-
- PicrossUI view = new PicrossUI(grid.getView());
-
- controller.setView(view);
+ this.view = new PicrossUI(mediator.getView());
}
/*** Method overloaded from the Mediateur class ***/
/** {@inheritDoc} */
public void eventPerformed(SimpleEvent e) {
- //PicrossMediator.log.debug("eventPerformed(" + e + ")");
+ PicrossMediator.log.debug("eventPerformed(" + e + ")");
String cmd = e.getCommandName();
+ if (cmd.equals(MainMenuController.PLAY_CMD)) {
+ PicrossModel model = new PicrossModel();
+
+ PicrossGridMediator grid =
+ new PicrossGridMediator(model.getWidth(), model.getHeight(),
+ model.getData());
+ grid.addSimpleListener(this);
+
+ //PicrossUI view = new PicrossUI(grid.getView());
+ this.view.setContent(grid.getView());
+ this.controller.setView(this.view);
+
+ return;
+ }
+
+ if (cmd.equals(MainMenuController.EXIT_CMD)) {
+ this.view.dispose();
+ return;
+ }
+
if (cmd.equals(PicrossGridController.GRID_FILLED_CMD)) {
this.fireEventPerformed(PicrossController.MESSAGE_CMD,
"Congratulations");
+ return;
}
}
}
Modified: trunk/src/picross/PicrossUI.java
===================================================================
--- trunk/src/picross/PicrossUI.java 2007-06-06 12:07:47 UTC (rev 12)
+++ trunk/src/picross/PicrossUI.java 2007-06-06 13:22:59 UTC (rev 13)
@@ -55,16 +55,18 @@
PicrossUI(JPanel content) {
super("Picross");
- this.setContentPane(content);
-
+ this.setContent(content);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
-
- this.pack();
this.setVisible(true);
}
/*** Method ***/
+ void setContent(JPanel content) {
+ this.setContentPane(content);
+ this.pack();
+ }
+
/**
* Displays a message box.
*
Added: trunk/src/picross/menus/MainMenuController.java
===================================================================
--- trunk/src/picross/menus/MainMenuController.java (rev 0)
+++ trunk/src/picross/menus/MainMenuController.java 2007-06-06 13:22:59 UTC (rev 13)
@@ -0,0 +1,81 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import fr.cle.mmvcs.Controller;
+import fr.cle.mmvcs.SimpleEvent;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author Y. Norsa
+ */
+public class MainMenuController extends Controller implements ActionListener {
+ /*** Constante ***/
+
+ public static final String PLAY_CMD = "PLAY_CMD";
+ public static final String EXIT_CMD = "EXIT_CMD";
+
+ /*** Champ statique ***/
+
+ private static Logger log = Logger.getLogger(MainMenuController.class);
+
+ /*** Champ ***/
+
+ /*** M\xE9thode ***/
+
+ public void eventPerformed(SimpleEvent e) {
+ MainMenuController.log.debug("eventPerformed(" + e + ")");
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ //MainMenuController.log.debug("actionPerformed(" + e + ")");
+
+ String cmd = e.getActionCommand();
+
+ if (cmd.equals(MainMenuController.PLAY_CMD)) {
+ this.fireEventPerformed(cmd);
+ return;
+ }
+
+ if (cmd.equals(MainMenuController.EXIT_CMD)) {
+ this.fireEventPerformed(cmd);
+ return;
+ }
+ }
+}
+
Property changes on: trunk/src/picross/menus/MainMenuController.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/MainMenuMediator.java
===================================================================
--- trunk/src/picross/menus/MainMenuMediator.java (rev 0)
+++ trunk/src/picross/menus/MainMenuMediator.java 2007-06-06 13:22:59 UTC (rev 13)
@@ -0,0 +1,78 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import fr.cle.mmvcs.Mediateur;
+import fr.cle.mmvcs.SimpleEvent;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author Y. Norsa
+ */
+public class MainMenuMediator extends Mediateur {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ private static Logger log = Logger.getLogger(MainMenuMediator.class);
+
+ /*** Champ ***/
+
+ private MainMenuUI view;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ public MainMenuMediator() {
+ MainMenuController controller = new MainMenuController();
+ controller.addSimpleListener(this);
+
+ this.view = new MainMenuUI(controller);
+ }
+
+ /*** M\xE9thode ***/
+
+ public void eventPerformed(SimpleEvent e) {
+ MainMenuMediator.log.debug("eventPerformed(" + e + ")");
+ this.fireEventPerformed(e);
+ }
+
+ public MainMenuUI getView() {
+ return this.view;
+ }
+}
+
Property changes on: trunk/src/picross/menus/MainMenuMediator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/MainMenuUI.java
===================================================================
--- trunk/src/picross/menus/MainMenuUI.java (rev 0)
+++ trunk/src/picross/menus/MainMenuUI.java 2007-06-06 13:22:59 UTC (rev 13)
@@ -0,0 +1,97 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Image;
+
+import java.awt.event.ActionListener;
+
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+
+/**
+ * @author Y. Norsa
+ */
+class MainMenuUI extends JPanel {
+ /*** Constante ***/
+ private static final long serialVersionUID = -505088917693050187L;
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private Image image;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ MainMenuUI(ActionListener controller) {
+ ImageIcon icon = new ImageIcon("images/mainMenu.png");
+ this.setPreferredSize(new Dimension(icon.getIconWidth(),
+ icon.getIconHeight()));
+ this.image = icon.getImage();
+
+ this.setLayout(null);
+
+ ImageIcon playIcon = new ImageIcon("images/button-play.png");
+ JButton playButton = new JButton(playIcon);
+ playButton.setActionCommand(MainMenuController.PLAY_CMD);
+ playButton.addActionListener(controller);
+ playButton.setBounds(50, 225,
+ playIcon.getIconWidth(), playIcon.getIconHeight());
+ this.add(playButton);
+
+ ImageIcon exitIcon = new ImageIcon("images/button-exit.png");
+ JButton exitButton = new JButton(exitIcon);
+ exitButton.setActionCommand(MainMenuController.EXIT_CMD);
+ exitButton.addActionListener(controller);
+ exitButton.setBounds(250, 225,
+ exitIcon.getIconWidth(), exitIcon.getIconHeight());
+ this.add(exitButton);
+ }
+
+ /*** M\xE9thode ***/
+
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+
+ g.drawImage(this.image, 0, 0, null);
+ }
+}
+
Property changes on: trunk/src/picross/menus/MainMenuUI.java
___________________________________________________________________
Name: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2007-06-06 13:47:38
|
Revision: 14
http://picross.svn.sourceforge.net/picross/?rev=14&view=rev
Author: yvan_norsa
Date: 2007-06-06 06:47:38 -0700 (Wed, 06 Jun 2007)
Log Message:
-----------
cleanup
Modified Paths:
--------------
trunk/src/picross/PicrossMediator.java
trunk/src/picross/PicrossUI.java
trunk/src/picross/menus/MainMenuController.java
trunk/src/picross/menus/MainMenuMediator.java
trunk/src/picross/menus/MainMenuUI.java
Added Paths:
-----------
trunk/images/background.png
trunk/src/picross/menus/package.html
Removed Paths:
-------------
trunk/images/mainMenu.png
Copied: trunk/images/background.png (from rev 13, trunk/images/mainMenu.png)
===================================================================
(Binary files differ)
Deleted: trunk/images/mainMenu.png
===================================================================
(Binary files differ)
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2007-06-06 13:22:59 UTC (rev 13)
+++ trunk/src/picross/PicrossMediator.java 2007-06-06 13:47:38 UTC (rev 14)
@@ -55,7 +55,12 @@
/** Class' logger. */
private static Logger log = Logger.getLogger(PicrossMediator.class);
+ /*** Fields ***/
+
+ /** The view's controller. */
private PicrossController controller;
+
+ /** Main view. */
private PicrossUI view;
/*** Constructor ***/
@@ -87,7 +92,6 @@
model.getData());
grid.addSimpleListener(this);
- //PicrossUI view = new PicrossUI(grid.getView());
this.view.setContent(grid.getView());
this.controller.setView(this.view);
Modified: trunk/src/picross/PicrossUI.java
===================================================================
--- trunk/src/picross/PicrossUI.java 2007-06-06 13:22:59 UTC (rev 13)
+++ trunk/src/picross/PicrossUI.java 2007-06-06 13:47:38 UTC (rev 14)
@@ -62,6 +62,11 @@
/*** Method ***/
+ /**
+ * Sets the frame panel and resizes the window.
+ *
+ * @param content new content panel
+ */
void setContent(JPanel content) {
this.setContentPane(content);
this.pack();
Modified: trunk/src/picross/menus/MainMenuController.java
===================================================================
--- trunk/src/picross/menus/MainMenuController.java 2007-06-06 13:22:59 UTC (rev 13)
+++ trunk/src/picross/menus/MainMenuController.java 2007-06-06 13:47:38 UTC (rev 14)
@@ -33,46 +33,51 @@
package picross.menus;
+import fr.cle.mmvcs.Controller;
+import fr.cle.mmvcs.SimpleEvent;
+
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import fr.cle.mmvcs.Controller;
-import fr.cle.mmvcs.SimpleEvent;
-
import org.apache.log4j.Logger;
/**
+ * Controller for the main menu.
+ *
* @author Y. Norsa
*/
public class MainMenuController extends Controller implements ActionListener {
- /*** Constante ***/
+ /*** Constants ***/
+ /** Play command. */
public static final String PLAY_CMD = "PLAY_CMD";
+
+ /** Exit command. */
public static final String EXIT_CMD = "EXIT_CMD";
- /*** Champ statique ***/
+ /*** Static field ***/
+ /** The class' logger. */
private static Logger log = Logger.getLogger(MainMenuController.class);
- /*** Champ ***/
+ /*** Method overloaded from the class Controller ***/
- /*** M\xE9thode ***/
-
+ /** {@inheritDoc} */
public void eventPerformed(SimpleEvent e) {
MainMenuController.log.debug("eventPerformed(" + e + ")");
}
+ /*** Method implanted from the interface ActionListener ***/
+
+ /** {@inheritDoc} */
public void actionPerformed(ActionEvent e) {
//MainMenuController.log.debug("actionPerformed(" + e + ")");
String cmd = e.getActionCommand();
- if (cmd.equals(MainMenuController.PLAY_CMD)) {
- this.fireEventPerformed(cmd);
- return;
- }
+ if (cmd.equals(MainMenuController.PLAY_CMD)
+ || cmd.equals(MainMenuController.EXIT_CMD)) {
- if (cmd.equals(MainMenuController.EXIT_CMD)) {
this.fireEventPerformed(cmd);
return;
}
Modified: trunk/src/picross/menus/MainMenuMediator.java
===================================================================
--- trunk/src/picross/menus/MainMenuMediator.java 2007-06-06 13:22:59 UTC (rev 13)
+++ trunk/src/picross/menus/MainMenuMediator.java 2007-06-06 13:47:38 UTC (rev 14)
@@ -39,24 +39,24 @@
import org.apache.log4j.Logger;
/**
+ * Mediator for the main menu.
+ *
* @author Y. Norsa
*/
public class MainMenuMediator extends Mediateur {
- /*** Constante ***/
+ /*** Static field ***/
- /*** Champ statique ***/
-
+ /** The class' logger. */
private static Logger log = Logger.getLogger(MainMenuMediator.class);
- /*** Champ ***/
+ /*** Field ***/
+ /** The menu view. */
private MainMenuUI view;
- /*** Constructeur ***/
+ /*** Constructor ***/
- /**
- * Constructeur.
- */
+ /** Constructor. */
public MainMenuMediator() {
MainMenuController controller = new MainMenuController();
controller.addSimpleListener(this);
@@ -64,13 +64,21 @@
this.view = new MainMenuUI(controller);
}
- /*** M\xE9thode ***/
+ /*** Method overloaded from the class Mediateur ***/
+ /** {@inheritDoc} */
public void eventPerformed(SimpleEvent e) {
MainMenuMediator.log.debug("eventPerformed(" + e + ")");
this.fireEventPerformed(e);
}
+ /*** Accessor ***/
+
+ /**
+ * Returns the view.
+ *
+ * @return the view
+ */
public MainMenuUI getView() {
return this.view;
}
Modified: trunk/src/picross/menus/MainMenuUI.java
===================================================================
--- trunk/src/picross/menus/MainMenuUI.java 2007-06-06 13:22:59 UTC (rev 13)
+++ trunk/src/picross/menus/MainMenuUI.java 2007-06-06 13:47:38 UTC (rev 14)
@@ -39,55 +39,92 @@
import java.awt.event.ActionListener;
+import java.io.File;
+
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
/**
+ * UI for the main menu.
+ *
* @author Y. Norsa
*/
class MainMenuUI extends JPanel {
- /*** Constante ***/
+ /*** Constants ***/
+
+ /** Serialisation ID. */
private static final long serialVersionUID = -505088917693050187L;
- /*** Champ statique ***/
+ /** Images directory. */
+ private static final String IMAGES_DIR = "images";
- /*** Champ ***/
+ /** Background image. */
+ private static final String BACKGROUND_IMAGE = "background.png";
+ /** Image for the "play" button. */
+ private static final String PLAY_BUTTON_IMAGE = "button-play.png";
+
+ /** "Play" button X coordinate. */
+ private static final int PLAY_BUTTON_X = 50;
+
+ /** "Play" button Y coordinate. */
+ private static final int PLAY_BUTTON_Y = 225;
+
+ /** Image for the "exit" button. */
+ private static final String EXIT_BUTTON_IMAGE = "button-exit.png";
+
+ /** "Exit" button X coordinate. */
+ private static final int EXIT_BUTTON_X = 250;
+
+ /** "Exit" button Y coordinate. */
+ private static final int EXIT_BUTTON_Y = 225;
+
+ /*** Field ***/
+
+ /** Background image. */
private Image image;
- /*** Constructeur ***/
+ /*** Constructor ***/
/**
- * Constructeur.
+ * Constructor.
+ *
+ * @param controller controller for the buttons
*/
MainMenuUI(ActionListener controller) {
- ImageIcon icon = new ImageIcon("images/mainMenu.png");
+ ImageIcon icon = new ImageIcon(MainMenuUI.IMAGES_DIR + File.separator
+ + MainMenuUI.BACKGROUND_IMAGE);
this.setPreferredSize(new Dimension(icon.getIconWidth(),
icon.getIconHeight()));
this.image = icon.getImage();
this.setLayout(null);
- ImageIcon playIcon = new ImageIcon("images/button-play.png");
+ ImageIcon playIcon = new ImageIcon(MainMenuUI.IMAGES_DIR
+ + File.separator
+ + MainMenuUI.PLAY_BUTTON_IMAGE);
JButton playButton = new JButton(playIcon);
playButton.setActionCommand(MainMenuController.PLAY_CMD);
playButton.addActionListener(controller);
- playButton.setBounds(50, 225,
+ playButton.setBounds(MainMenuUI.PLAY_BUTTON_X, MainMenuUI.PLAY_BUTTON_Y,
playIcon.getIconWidth(), playIcon.getIconHeight());
this.add(playButton);
- ImageIcon exitIcon = new ImageIcon("images/button-exit.png");
+ ImageIcon exitIcon = new ImageIcon(MainMenuUI.IMAGES_DIR
+ + File.separator
+ + MainMenuUI.EXIT_BUTTON_IMAGE);
JButton exitButton = new JButton(exitIcon);
exitButton.setActionCommand(MainMenuController.EXIT_CMD);
exitButton.addActionListener(controller);
- exitButton.setBounds(250, 225,
+ exitButton.setBounds(MainMenuUI.EXIT_BUTTON_X, MainMenuUI.EXIT_BUTTON_Y,
exitIcon.getIconWidth(), exitIcon.getIconHeight());
this.add(exitButton);
}
- /*** M\xE9thode ***/
+ /*** Method overloaded from the class JPanel ***/
+ /** {@inheritDoc} */
public void paintComponent(Graphics g) {
super.paintComponent(g);
Added: trunk/src/picross/menus/package.html
===================================================================
--- trunk/src/picross/menus/package.html (rev 0)
+++ trunk/src/picross/menus/package.html 2007-06-06 13:47:38 UTC (rev 14)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <!--
+ $Id$
+ -->
+ </head>
+
+ <body bgcolor="white">
+ Classes for the menus.
+ </body>
+</html>
Property changes on: trunk/src/picross/menus/package.html
___________________________________________________________________
Name: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2007-06-06 14:26:28
|
Revision: 15
http://picross.svn.sourceforge.net/picross/?rev=15&view=rev
Author: yvan_norsa
Date: 2007-06-06 07:26:30 -0700 (Wed, 06 Jun 2007)
Log Message:
-----------
bundle added
Modified Paths:
--------------
trunk/build.xml
trunk/src/picross/Picross.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/grid/Box.java
trunk/src/picross/grid/PicrossGridModel.java
trunk/src/picross/menus/MainMenuUI.java
Added Paths:
-----------
trunk/images/en/
trunk/images/en/button-exit.png
trunk/images/en/button-play.png
trunk/images/fr/
trunk/images/fr/button-exit.png
trunk/images/fr/button-play.png
trunk/lib/bundleHelper.jar
trunk/src/picross/properties/
trunk/src/picross/properties/messages_picross.properties
trunk/src/picross/properties/messages_picross_en.properties
trunk/src/picross/properties/messages_picross_fr.properties
Removed Paths:
-------------
trunk/images/button-exit.png
trunk/images/button-play.png
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2007-06-06 13:47:38 UTC (rev 14)
+++ trunk/build.xml 2007-06-06 14:26:30 UTC (rev 15)
@@ -10,6 +10,8 @@
<property name="src.dir"
value="src" />
+ <property name="bundleHelper.jar"
+ value="${lib.dir}/bundleHelper.jar" />
<property name="mmvcs.jar"
value="${lib.dir}/mmvcs.jar" />
<property name="log4j.jar"
@@ -43,6 +45,7 @@
<path id="classpath">
<pathelement location="${build.dir}" />
+ <pathelement location="${bundleHelper.jar}" />
<pathelement location="${log4j.jar}" />
<pathelement location="${mmvcs.jar}" />
</path>
@@ -58,6 +61,12 @@
<classpath refid="classpath" />
</javac>
+
+ <copy todir="${build.dir}/picross/properties"
+ failonerror="false">
+ <fileset dir="${src.dir}/picross/properties" />
+ </copy>
+
</target>
<target name="run"
Deleted: trunk/images/button-exit.png
===================================================================
(Binary files differ)
Deleted: trunk/images/button-play.png
===================================================================
(Binary files differ)
Added: trunk/images/en/button-exit.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/en/button-exit.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/images/en/button-play.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/en/button-play.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Copied: trunk/images/fr/button-exit.png (from rev 13, trunk/images/button-exit.png)
===================================================================
(Binary files differ)
Copied: trunk/images/fr/button-play.png (from rev 13, trunk/images/button-play.png)
===================================================================
(Binary files differ)
Added: trunk/lib/bundleHelper.jar
===================================================================
(Binary files differ)
Property changes on: trunk/lib/bundleHelper.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/picross/Picross.java
===================================================================
--- trunk/src/picross/Picross.java 2007-06-06 13:47:38 UTC (rev 14)
+++ trunk/src/picross/Picross.java 2007-06-06 14:26:30 UTC (rev 15)
@@ -33,6 +33,11 @@
package picross;
+import java.io.File;
+
+import java.util.Locale;
+
+import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;
import org.apache.log4j.PropertyConfigurator;
@@ -42,12 +47,19 @@
*
* @author Y. Norsa
*/
-final class Picross {
- /*** Constant ***/
+public final class Picross {
+ /*** Constants ***/
/** Log4j config file. */
private static final String LOG4J_CONFIG = "log4j.properties";
+ /** Images directory. */
+ private static final String IMAGES_DIR = "images" + File.separator;
+
+ /** Images directory corresponding to the default locale. */
+ private static final String LOCAL_IMAGES_PATH = Picross.IMAGES_DIR
+ + Locale.getDefault().getLanguage() + File.separator;
+
/*** Constructor ***/
/** Constructor. */
@@ -71,5 +83,27 @@
}
});
}
+
+ /*** Static methods ***/
+
+ /**
+ * Returns an image.
+ *
+ * @param name image filename
+ * @return the image
+ */
+ public static ImageIcon getImage(String name) {
+ return new ImageIcon(Picross.IMAGES_DIR + name);
+ }
+
+ /**
+ * Returns the localized version of an image.
+ *
+ * @param name image filename
+ * @return the image
+ */
+ public static ImageIcon getLocalizedImage(String name) {
+ return new ImageIcon(Picross.LOCAL_IMAGES_PATH + name);
+ }
}
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2007-06-06 13:47:38 UTC (rev 14)
+++ trunk/src/picross/PicrossMediator.java 2007-06-06 14:26:30 UTC (rev 15)
@@ -33,6 +33,8 @@
package picross;
+import bundleHelper.BundleHelper;
+
import fr.cle.mmvcs.Mediateur;
import fr.cle.mmvcs.SimpleEvent;
@@ -67,6 +69,8 @@
/** Constructor. */
PicrossMediator() {
+ BundleHelper.loadBundle("picross.properties.messages_picross");
+
this.controller = new PicrossController();
this.addSimpleListener(this.controller);
@@ -105,7 +109,7 @@
if (cmd.equals(PicrossGridController.GRID_FILLED_CMD)) {
this.fireEventPerformed(PicrossController.MESSAGE_CMD,
- "Congratulations");
+ BundleHelper.getString(this, "victory"));
return;
}
}
Modified: trunk/src/picross/grid/Box.java
===================================================================
--- trunk/src/picross/grid/Box.java 2007-06-06 13:47:38 UTC (rev 14)
+++ trunk/src/picross/grid/Box.java 2007-06-06 14:26:30 UTC (rev 15)
@@ -47,16 +47,14 @@
import java.awt.Image;
-import java.io.File;
-
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
-import javax.swing.ImageIcon;
-
//import org.apache.log4j.Logger;
+import picross.Picross;
+
/**
* Representation of a box in the grid.
*
@@ -77,11 +75,8 @@
CROSSED
}
- /*** Constants ***/
+ /*** Constant ***/
- /** Directory containing the images. */
- private static final String IMAGES_DIR = "images";
-
/** Images files extension. */
private static final String IMAGES_EXT = ".png";
@@ -112,13 +107,10 @@
Box.images = new HashMap<Box.BoxState, Image>();
- String path = Box.IMAGES_DIR + File.separator;
-
for (Box.BoxState state : Box.BoxState.values()) {
- Box.images.put(state, new ImageIcon(path
- + state.toString()
- .toLowerCase()
- + Box.IMAGES_EXT).getImage());
+ Box.images.put(state, Picross
+ .getImage(state.toString().toLowerCase()
+ + Box.IMAGES_EXT).getImage());
}
}
Modified: trunk/src/picross/grid/PicrossGridModel.java
===================================================================
--- trunk/src/picross/grid/PicrossGridModel.java 2007-06-06 13:47:38 UTC (rev 14)
+++ trunk/src/picross/grid/PicrossGridModel.java 2007-06-06 14:26:30 UTC (rev 15)
@@ -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(PicrossGridModel.class);
+ //private static Logger log = Logger.getLogger(PicrossGridModel.class);
/*** Fields ***/
@@ -234,7 +234,7 @@
* @param column column of the box
*/
void checkBox(int row, int column, int type) {
- PicrossGridModel.log.debug("checkBox(" + row + ", " + column + ")");
+ //PicrossGridModel.log.debug("checkBox(" + row + ", " + column + ")");
//PicrossGridModel.log.debug("lastModified == null : "
// + (lastModified == null));
Modified: trunk/src/picross/menus/MainMenuUI.java
===================================================================
--- trunk/src/picross/menus/MainMenuUI.java 2007-06-06 13:47:38 UTC (rev 14)
+++ trunk/src/picross/menus/MainMenuUI.java 2007-06-06 14:26:30 UTC (rev 15)
@@ -39,12 +39,12 @@
import java.awt.event.ActionListener;
-import java.io.File;
-
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
+import picross.Picross;
+
/**
* UI for the main menu.
*
@@ -56,9 +56,6 @@
/** Serialisation ID. */
private static final long serialVersionUID = -505088917693050187L;
- /** Images directory. */
- private static final String IMAGES_DIR = "images";
-
/** Background image. */
private static final String BACKGROUND_IMAGE = "background.png";
@@ -93,30 +90,29 @@
* @param controller controller for the buttons
*/
MainMenuUI(ActionListener controller) {
- ImageIcon icon = new ImageIcon(MainMenuUI.IMAGES_DIR + File.separator
- + MainMenuUI.BACKGROUND_IMAGE);
+ ImageIcon icon = Picross.getImage(MainMenuUI.BACKGROUND_IMAGE);
this.setPreferredSize(new Dimension(icon.getIconWidth(),
icon.getIconHeight()));
this.image = icon.getImage();
this.setLayout(null);
- ImageIcon playIcon = new ImageIcon(MainMenuUI.IMAGES_DIR
- + File.separator
- + MainMenuUI.PLAY_BUTTON_IMAGE);
+ ImageIcon playIcon =
+ Picross.getLocalizedImage(MainMenuUI.PLAY_BUTTON_IMAGE);
JButton playButton = new JButton(playIcon);
playButton.setActionCommand(MainMenuController.PLAY_CMD);
playButton.addActionListener(controller);
+ playButton.setBorder(null);
playButton.setBounds(MainMenuUI.PLAY_BUTTON_X, MainMenuUI.PLAY_BUTTON_Y,
playIcon.getIconWidth(), playIcon.getIconHeight());
this.add(playButton);
- ImageIcon exitIcon = new ImageIcon(MainMenuUI.IMAGES_DIR
- + File.separator
- + MainMenuUI.EXIT_BUTTON_IMAGE);
+ ImageIcon exitIcon =
+ Picross.getLocalizedImage(MainMenuUI.EXIT_BUTTON_IMAGE);
JButton exitButton = new JButton(exitIcon);
exitButton.setActionCommand(MainMenuController.EXIT_CMD);
exitButton.addActionListener(controller);
+ exitButton.setBorder(null);
exitButton.setBounds(MainMenuUI.EXIT_BUTTON_X, MainMenuUI.EXIT_BUTTON_Y,
exitIcon.getIconWidth(), exitIcon.getIconHeight());
this.add(exitButton);
Added: trunk/src/picross/properties/messages_picross.properties
===================================================================
--- trunk/src/picross/properties/messages_picross.properties (rev 0)
+++ trunk/src/picross/properties/messages_picross.properties 2007-06-06 14:26:30 UTC (rev 15)
@@ -0,0 +1 @@
+victory = Congratulations !
Added: trunk/src/picross/properties/messages_picross_en.properties
===================================================================
--- trunk/src/picross/properties/messages_picross_en.properties (rev 0)
+++ trunk/src/picross/properties/messages_picross_en.properties 2007-06-06 14:26:30 UTC (rev 15)
@@ -0,0 +1 @@
+link messages_picross.properties
\ No newline at end of file
Property changes on: trunk/src/picross/properties/messages_picross_en.properties
___________________________________________________________________
Name: svn:special
+ *
Added: trunk/src/picross/properties/messages_picross_fr.properties
===================================================================
--- trunk/src/picross/properties/messages_picross_fr.properties (rev 0)
+++ trunk/src/picross/properties/messages_picross_fr.properties 2007-06-06 14:26:30 UTC (rev 15)
@@ -0,0 +1,2 @@
+# picross.PicrossMediator
+victory = F\xE9licitations !
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2007-06-06 19:14:24
|
Revision: 18
http://picross.svn.sourceforge.net/picross/?rev=18&view=rev
Author: yvan_norsa
Date: 2007-06-06 12:14:19 -0700 (Wed, 06 Jun 2007)
Log Message:
-----------
added rollover icons
Modified Paths:
--------------
trunk/src/picross/PicrossMediator.java
trunk/src/picross/grid/Box.java
trunk/src/picross/grid/PicrossGridController.java
trunk/src/picross/grid/PicrossGridModel.java
trunk/src/picross/grid/PicrossGridUI.java
trunk/src/picross/menus/MainMenuUI.java
Added Paths:
-----------
trunk/images/checked-rollover.png
trunk/images/empty-rollover.png
trunk/src/picross/grid/GridBox.java
Added: trunk/images/checked-rollover.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/checked-rollover.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/images/empty-rollover.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/empty-rollover.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2007-06-06 15:08:52 UTC (rev 17)
+++ trunk/src/picross/PicrossMediator.java 2007-06-06 19:14:19 UTC (rev 18)
@@ -38,7 +38,7 @@
import fr.cle.mmvcs.Mediateur;
import fr.cle.mmvcs.SimpleEvent;
-import org.apache.log4j.Logger;
+//import org.apache.log4j.Logger;
import picross.grid.PicrossGridController;
import picross.grid.PicrossGridMediator;
@@ -55,7 +55,7 @@
/*** Static field ***/
/** Class' logger. */
- private static Logger log = Logger.getLogger(PicrossMediator.class);
+ //private static Logger log = Logger.getLogger(PicrossMediator.class);
/*** Fields ***/
@@ -84,7 +84,7 @@
/** {@inheritDoc} */
public void eventPerformed(SimpleEvent e) {
- PicrossMediator.log.debug("eventPerformed(" + e + ")");
+ //PicrossMediator.log.debug("eventPerformed(" + e + ")");
String cmd = e.getCommandName();
Modified: trunk/src/picross/grid/Box.java
===================================================================
--- trunk/src/picross/grid/Box.java 2007-06-06 15:08:52 UTC (rev 17)
+++ trunk/src/picross/grid/Box.java 2007-06-06 19:14:19 UTC (rev 18)
@@ -45,26 +45,20 @@
package picross.grid;
-import java.awt.Image;
-
-import java.util.HashMap;
-import java.util.Map;
import java.util.Random;
//import org.apache.log4j.Logger;
-import picross.Picross;
-
/**
* Representation of a box in the grid.
*
* @author Y. Norsa
*/
-final class Box {
+class Box {
/*** Enum ***/
/** Possibles states of a box. */
- private enum BoxState {
+ enum BoxState {
/** An empty box. */
EMPTY,
@@ -75,11 +69,6 @@
CROSSED
}
- /*** Constant ***/
-
- /** Images files extension. */
- private static final String IMAGES_EXT = ".png";
-
/*** Statics fields ***/
/** The class's logger. */
@@ -88,37 +77,25 @@
/** Random number generator. */
private static Random rand;
- /** Map containing the images corresponding to the different states. */
- private static Map<Box.BoxState, Image> images;
-
/*** Fields ***/
/** State of the box. */
- private Box.BoxState state;
+ protected Box.BoxState state;
/** Pseudo random hash-code. */
- private int hash;
+ private final int hash;
/*** Static block ***/
- // Fills in the images map
static {
Box.rand = new Random();
-
- Box.images = new HashMap<Box.BoxState, Image>();
-
- for (Box.BoxState state : Box.BoxState.values()) {
- Box.images.put(state, Picross
- .getImage(state.toString().toLowerCase()
- + Box.IMAGES_EXT).getImage());
- }
}
/*** Constructor ***/
/** Constructor. */
Box() {
- this.state = Box.BoxState.EMPTY;
+ this.empty();
this.hash = Box.rand.nextInt();
}
@@ -153,7 +130,7 @@
*
* @return boolean telling if the box is checked
*/
- boolean isChecked() {
+ final boolean isChecked() {
return this.state == Box.BoxState.CHECKED;
}
@@ -162,7 +139,7 @@
*
* @return boolean telling if the box is crossed
*/
- boolean isCrossed() {
+ final boolean isCrossed() {
return this.state == Box.BoxState.CROSSED;
}
@@ -171,33 +148,23 @@
*
* @return boolean telling if the box is empty
*/
- boolean isEmpty() {
+ final boolean isEmpty() {
return this.state == Box.BoxState.EMPTY;
}
/** Empties the box. */
- void empty() {
+ final void empty() {
this.state = Box.BoxState.EMPTY;
}
/** Checks the box. */
- void check() {
+ final void check() {
this.state = Box.BoxState.CHECKED;
}
/** Crosses the box. */
- void cross() {
+ final void cross() {
this.state = Box.BoxState.CROSSED;
}
-
- /**
- * Returns the image associated with the box's state.
- *
- * @return the image corresponding to the box's state
- */
- Image getImage() {
- //Box.log.debug("return " + Box.images.get(this.state));
- return Box.images.get(this.state);
- }
}
Added: trunk/src/picross/grid/GridBox.java
===================================================================
--- trunk/src/picross/grid/GridBox.java (rev 0)
+++ trunk/src/picross/grid/GridBox.java 2007-06-06 19:14:19 UTC (rev 18)
@@ -0,0 +1,111 @@
+package picross.grid;
+
+import java.awt.Rectangle;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.ImageIcon;
+
+import picross.Picross;
+
+/**
+ * Graphical representation of a box in the grid.
+ *
+ * @author Y. Norsa
+ */
+final class GridBox extends Box {
+ /*** Constants ***/
+
+ /** Index of the normal icon. */
+ private static final int ICON_INDEX = 0;
+
+ /** Index of the rollover icon. */
+ private static final int ROLLOVER_ICON_INDEX = 1;
+
+ /** Suffix for rollover icons. */
+ private static final String ROLLOVER_NAME = "-rollover";
+
+ /** Images files extension. */
+ private static final String IMAGES_EXT = ".png";
+
+ /*** Static field ***/
+
+ /** Map containing the images corresponding to the different states. */
+ private static Map<Box.BoxState, ImageIcon[]> images;
+
+ /*** Field ***/
+
+ /** Rectangle occupied by the box. */
+ private Rectangle rect;
+
+ // Fills in the images map
+ static {
+ /*
+ * We create a too large HashMap so it doesn't grow
+ * during its initialisation
+ */
+ GridBox.images = new HashMap<Box.BoxState, ImageIcon[]>(7);
+
+ for (Box.BoxState state : Box.BoxState.values()) {
+ ImageIcon[] img = new ImageIcon[2];
+
+ String stateImageName = state.toString().toLowerCase();
+ img[GridBox.ICON_INDEX] = Picross.getImage(stateImageName
+ + GridBox.IMAGES_EXT);
+ img[GridBox.ROLLOVER_ICON_INDEX] =
+ Picross.getImage(stateImageName + GridBox.ROLLOVER_NAME
+ + GridBox.IMAGES_EXT);
+
+ GridBox.images.put(state, img);
+ }
+
+ // We don't have a rollover icon for crossed boxes
+ GridBox.images.get(Box.BoxState.CROSSED)[GridBox.ROLLOVER_ICON_INDEX] =
+ GridBox.images.get(Box.BoxState.CROSSED)[GridBox.ICON_INDEX];
+ }
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @param rect rectangle occupied by this box
+ */
+ GridBox(Rectangle rect) {
+ super();
+
+ this.rect = rect;
+ }
+
+ /*** Methods ***/
+
+ /**
+ * Returns the icon representing the current state of the box.
+ *
+ * @return icon of the state of the box
+ */
+ ImageIcon getIcon() {
+ return GridBox.images.get(this.state)[GridBox.ICON_INDEX];
+ }
+
+ /**
+ * Returns the rollover icon representing the current state of the box.
+ *
+ * @return rollover icon of the state of the box
+ */
+ ImageIcon getRolloverIcon() {
+ return GridBox.images.get(this.state)[GridBox.ROLLOVER_ICON_INDEX];
+ }
+
+ /*** Accessor ***/
+
+ /**
+ * Returns this box' rectangle.
+ *
+ * @return rectangle occupied by this box
+ */
+ Rectangle getRect() {
+ return this.rect;
+ }
+}
Property changes on: trunk/src/picross/grid/GridBox.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/grid/PicrossGridController.java
===================================================================
--- trunk/src/picross/grid/PicrossGridController.java 2007-06-06 15:08:52 UTC (rev 17)
+++ trunk/src/picross/grid/PicrossGridController.java 2007-06-06 19:14:19 UTC (rev 18)
@@ -127,7 +127,9 @@
public void mouseExited(MouseEvent e) { }
/** {@inheritDoc} */
- public void mousePressed(MouseEvent e) { }
+ public void mousePressed(MouseEvent e) {
+ this.view.rolloverEnded();
+ }
/** {@inheritDoc} */
public void mouseReleased(MouseEvent e) {
@@ -144,8 +146,22 @@
}
/** {@inheritDoc} */
- public void mouseMoved(MouseEvent e) { }
+ public void mouseMoved(MouseEvent e) {
+ //PicrossGridController.log.debug(e.getPoint());
+ Point point = e.getPoint();
+
+ if (this.view.isInGrid(point)) {
+ int row = this.view.getRow(point);
+ int column = this.view.getColumn(point);
+
+ this.view.setRollover(row, column);
+ } else {
+ this.view.rolloverEnded();
+ }
+
+ }
+
/*** Methods ***/
/**
Modified: trunk/src/picross/grid/PicrossGridModel.java
===================================================================
--- trunk/src/picross/grid/PicrossGridModel.java 2007-06-06 15:08:52 UTC (rev 17)
+++ trunk/src/picross/grid/PicrossGridModel.java 2007-06-06 19:14:19 UTC (rev 18)
@@ -284,7 +284,7 @@
this.mediator.check(row, column,
PicrossGridController.CROSS_ACTION);
}
- } else { //if (this.boxes[row][column].isCrossed())\xA0{
+ } else { //if (this.boxes[row][column].isCrossed()) {
//PicrossGridModel.log.debug("crossed");
if (type == PicrossGridController.CROSS_ACTION) {
Modified: trunk/src/picross/grid/PicrossGridUI.java
===================================================================
--- trunk/src/picross/grid/PicrossGridUI.java 2007-06-06 15:08:52 UTC (rev 17)
+++ trunk/src/picross/grid/PicrossGridUI.java 2007-06-06 19:14:19 UTC (rev 18)
@@ -37,10 +37,11 @@
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
+import java.awt.Rectangle;
import javax.swing.JPanel;
-//import org.apache.log4j.Logger;
+import org.apache.log4j.Logger;
/**
* Grid UI.
@@ -83,7 +84,7 @@
/*** Static field ***/
/** Class' logger. */
- //private static Logger log = Logger.getLogger(PicrossGridUI.class);
+ private static Logger log = Logger.getLogger(PicrossGridUI.class);
/*** Fields ***/
@@ -111,9 +112,18 @@
/** Position of the bottom end of the grid. */
private int bottomBoundary;
+ /** Rectangle occupied by the top hints. */
+ private Rectangle topHintsRect;
+
+ /** Rectangle occupied by the left hints. */
+ private Rectangle leftHintsRect;
+
/** Current state of the grid. */
- private Box[][] boxes;
+ private GridBox[][] boxes;
+ /** Current rolled-over box. */
+ private transient GridBox rollover;
+
/** Controller attached to this view. */
private transient PicrossGridController controller;
@@ -132,7 +142,7 @@
int[][] colData,
int[][] rowData,
PicrossGridController controller) {
- super();
+ super(true);
this.controller = controller;
@@ -148,14 +158,6 @@
this.colData = colData;
this.rowData = rowData;
- this.boxes = new Box[this.width][this.height];
-
- for (int i = 0; i < this.boxes.length; i++) {
- for (int j = 0; j < this.boxes[i].length; j++) {
- this.boxes[i][j] = new Box();
- }
- }
-
this.leftBoundary =
this.rowData[0].length * PicrossGridUI.ROW_HINT_WIDTH;
@@ -168,6 +170,33 @@
this.bottomBoundary = this.topBoundary
+ (this.height * PicrossGridUI.BOX_HEIGHT);
+ this.topHintsRect = new Rectangle(this.leftBoundary, 0,
+ this.width * PicrossGridUI.BOX_WIDTH,
+ this.topBoundary);
+ this.leftHintsRect = new Rectangle(0, this.topBoundary,
+ this.leftBoundary,
+ this.height
+ * PicrossGridUI.BOX_HEIGHT);
+
+ this.boxes = new GridBox[this.width][this.height];
+
+ for (int i = 0; i < this.boxes.length; i++) {
+ for (int j = 0; j < this.boxes[i].length; j++) {
+ /*
+ * We compute here the rectangle corresponding to each box
+ * so we'll be able
+ * to redraw only what is needed
+ */
+ this.boxes[i][j] =
+ new GridBox(new Rectangle(this.leftBoundary
+ + (j * PicrossGridUI.BOX_WIDTH),
+ this.topBoundary
+ + (i * PicrossGridUI.BOX_WIDTH),
+ PicrossGridUI.BOX_WIDTH,
+ PicrossGridUI.BOX_HEIGHT));
+ }
+ }
+
//PicrossGridUI.log.debug("rightBoundary : " + this.rightBoundary);
//PicrossGridUI.log.debug("bottomBoundary : " + this.bottomBoundary);
@@ -180,55 +209,69 @@
/*** Method overloaded from JPanel ***/
/** {@inheritDoc} */
- public void paintComponent(Graphics g) {
+ protected void paintComponent(Graphics g) {
super.paintComponent(g);
- int x = 0;
- int y = PicrossGridUI.TOP_HINTS;
+ Rectangle clipRect = g.getClipBounds();
- for (int i = this.colData[0].length - 1; i >= 0; i--) {
- x = this.leftBoundary + PicrossGridUI.COL_HINT_WIDTH;
+ if (this.topHintsRect.intersects(clipRect)) {
+ PicrossGridUI.log.debug("top hints");
- for (int j = 0; j < this.colData.length; j++) {
- if (this.colData[j][i] != PicrossGridModel.EMPTY_HINT) {
- g.drawString(String.valueOf(this.colData[j][i]),
- x, y);
+ int x = 0;
+ int y = PicrossGridUI.TOP_HINTS;
+
+ for (int i = this.colData[0].length - 1; i >= 0; i--) {
+ x = this.leftBoundary + PicrossGridUI.COL_HINT_WIDTH;
+
+ for (int j = 0; j < this.colData.length; j++) {
+ if (this.colData[j][i] != PicrossGridModel.EMPTY_HINT) {
+ g.drawString(String.valueOf(this.colData[j][i]),
+ x, y);
+ }
+
+ x += PicrossGridUI.BOX_WIDTH;
}
- x += PicrossGridUI.BOX_WIDTH;
+ y += PicrossGridUI.COL_HINT_HEIGHT;
}
-
- y += PicrossGridUI.COL_HINT_HEIGHT;
}
- int gridY = y;
+ if (this.leftHintsRect.intersects(clipRect)) {
+ PicrossGridUI.log.debug("left hints");
- for (int i = 0; i < this.rowData.length; i++) {
- x = 0;
+ int y = this.topBoundary;
- for (int j = 0; j < this.rowData[i].length; j++) {
- if (this.rowData[i][j] != PicrossGridModel.EMPTY_HINT) {
- g.drawString(String.valueOf(this.rowData[i][j]),
- x, y + PicrossGridUI.ROW_HINT_HEIGHT);
+ for (int i = 0; i < this.rowData.length; i++) {
+ int x = 0;
+
+ for (int j = 0; j < this.rowData[i].length; j++) {
+ if (this.rowData[i][j] != PicrossGridModel.EMPTY_HINT) {
+ g.drawString(String.valueOf(this.rowData[i][j]),
+ x, y + PicrossGridUI.ROW_HINT_HEIGHT);
+ }
+
+ x += PicrossGridUI.ROW_HINT_WIDTH;
}
- x += PicrossGridUI.ROW_HINT_WIDTH;
+ y += PicrossGridUI.BOX_HEIGHT;
}
-
- y += PicrossGridUI.BOX_HEIGHT;
}
- y = gridY;
-
for (int i = 0; i < this.height; i++) {
- x = this.leftBoundary;
+ for (int j = 0; j < this.width; j++) {
+ Rectangle currentRect = this.boxes[i][j].getRect();
- for (int j = 0; j < this.width; j++) {
- g.drawImage(this.boxes[i][j].getImage(), x, y, null);
- x += PicrossGridUI.BOX_WIDTH;
+ if (currentRect.intersects(clipRect)) {
+ if (this.boxes[i][j] == this.rollover) {
+ this.boxes[i][j].getRolloverIcon()
+ .paintIcon(this, g, currentRect.x, currentRect.y);
+ } else {
+ this.boxes[i][j].getIcon().paintIcon(this, g,
+ currentRect.x,
+ currentRect.y);
+ }
+ }
}
-
- y += PicrossGridUI.BOX_HEIGHT;
}
}
@@ -319,7 +362,35 @@
}
}
- this.repaint();
+ this.repaint(this.boxes[row][column].getRect());
}
+
+ /**
+ * Allows to set the current rolled-over box.
+ *
+ * @param row row of the box
+ * @param column column of the box
+ */
+ void setRollover(int row, int column) {
+ //PicrossGridUI.log.debug("setRollover(" + row + ", " + column + ")");
+
+ this.rolloverEnded();
+ this.rollover = this.boxes[row][column];
+ this.repaint(this.rollover.getRect());
+ }
+
+ /** Indicates that no box is currently rolled over. */
+ void rolloverEnded() {
+ if (this.rollover != null) {
+ /*
+ * Save the old rolled-over box so we can draw it
+ * in its initial state
+ */
+ Rectangle rect = this.rollover.getRect();
+
+ this.rollover = null;
+ this.repaint(rect);
+ }
+ }
}
Modified: trunk/src/picross/menus/MainMenuUI.java
===================================================================
--- trunk/src/picross/menus/MainMenuUI.java 2007-06-06 15:08:52 UTC (rev 17)
+++ trunk/src/picross/menus/MainMenuUI.java 2007-06-06 19:14:19 UTC (rev 18)
@@ -121,7 +121,7 @@
/*** Method overloaded from the class JPanel ***/
/** {@inheritDoc} */
- public void paintComponent(Graphics g) {
+ protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(this.image, 0, 0, null);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2007-06-08 12:07:03
|
Revision: 26
http://picross.svn.sourceforge.net/picross/?rev=26&view=rev
Author: yvan_norsa
Date: 2007-06-08 05:07:03 -0700 (Fri, 08 Jun 2007)
Log Message:
-----------
hint boxes image, blocks color
Modified Paths:
--------------
trunk/src/picross/grid/GridUI.java
Added Paths:
-----------
trunk/images/hint.png
Added: trunk/images/hint.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/hint.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/picross/grid/GridUI.java
===================================================================
--- trunk/src/picross/grid/GridUI.java 2007-06-08 07:41:19 UTC (rev 25)
+++ trunk/src/picross/grid/GridUI.java 2007-06-08 12:07:03 UTC (rev 26)
@@ -37,19 +37,20 @@
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
-import java.awt.RenderingHints;
import java.awt.font.FontRenderContext;
import java.awt.geom.Rectangle2D;
+import javax.swing.ImageIcon;
import javax.swing.JPanel;
import org.apache.log4j.Logger;
+import picross.Picross;
+
/**
* Grid UI.
*
@@ -62,29 +63,11 @@
private static final long serialVersionUID = 2050855523399115878L;
/** Space left before the top hints. */
- private static final int TOP_HINTS = 13;
+ private static final int TOP_HINTS = 10;
/** Space left after the left hints. */
private static final int LEFT_HINTS = 10;
- /** Width occupied by a row hint. */
- private static final int ROW_HINT_WIDTH = 10;
-
- /** Height occupied by a row hint. */
- private static final int ROW_HINT_HEIGHT = 15;
-
- /** Width occupied by a column hint. */
- private static final int COL_HINT_WIDTH = 5;
-
- /** Height occupied by a column hint. */
- private static final int COL_HINT_HEIGHT = 12;
-
- /** Outline color for the hints boxes. */
- private static final Color HINT_OUTLINE_COLOR = new Color(188, 211, 227);
-
- /** Background color for the hints boxes. */
- private static final Color HINT_FILL_COLOR = new Color(131, 155, 200);
-
/** Color of the hints text. */
private static final Color HINT_TEXT_COLOR = new Color(233, 246, 255);
@@ -104,12 +87,27 @@
/** Extra space at the bottom of the grid. */
private static final int BOTTOM_SPACE = 5;
- /** Text used to compute the hints boxes size. */
- private static final String SAMPLE_HINT = "42";
+ /** Text used to compute the high hints boxes size. */
+ private static final String HIGH_SAMPLE_HINT = "88";
- /** Diameter of the arc for hint boxes. */
- private static final int ROUND_DIAMETER = 8;
+ /** Text used to compute the low hints boxes size. */
+ private static final String LOW_SAMPLE_HINT = "8";
+ /** Hint box icon. */
+ private static final String HINT_BOX_ICON = "hint.png";
+
+ /** Space between hint boxes. */
+ private static final int HINTS_SPACE = 2;
+
+ /** Boxes blocks color. */
+ private static final Color BLOCKS_COLOR = new Color(131, 155, 200);
+
+ /** A block width. */
+ private static final int BLOCK_WIDTH = 5;
+
+ /** A block height. */
+ private static final int BLOCK_HEIGHT = 5;
+
/*** Static field ***/
/** Class' logger. */
@@ -156,9 +154,30 @@
/** Controller attached to this view. */
private transient GridController controller;
- /** Size of the hints boxes. */
- private int hintBoxSize;
+ /** Hint box icon. */
+ private ImageIcon hintBoxIcon;
+ /** X coordinate of the beginning of a top hints row. */
+ private int topHintsX;
+
+ /** Space left between two top hints. */
+ private int topHintsDecal;
+
+ /** Y coordinate of the beginning of a left hints column. */
+ private int leftHintsY;
+
+ /** Space left between two left hints. */
+ private int leftHintsDecal;
+
+ /** Used to center a hint vertically. */
+ private int centerHintHeight;
+
+ /** Used to center a low hint horizontally. */
+ private int centerLowHintWidth;
+
+ /** Used to center a high hint horizontally. */
+ private int centerHighHintWidth;
+
/*** Constructor ***/
/**
@@ -190,27 +209,35 @@
this.colData = colData;
this.rowData = rowData;
- // Computes the size of a hint box
+ // Computes the size of a hint
FontRenderContext frc = new FontRenderContext(null, true, true);
+
+ // High hint (> 10)
Rectangle2D textBounds =
- GridUI.HINT_FONT.getStringBounds(GridUI.SAMPLE_HINT, frc);
+ GridUI.HINT_FONT.getStringBounds(GridUI.HIGH_SAMPLE_HINT, frc);
+ int hintHeight = (int) textBounds.getHeight();
+ int highHintWidth = (int) textBounds.getWidth();
- double textWidth = textBounds.getWidth();
- double textHeight = textBounds.getHeight();
+ // Low hint
+ textBounds = GridUI.HINT_FONT.getStringBounds(GridUI.LOW_SAMPLE_HINT,
+ frc);
+ int lowHintWidth = (int) textBounds.getWidth();
- this.hintBoxSize = ((int) (textWidth > textHeight
- ? textWidth : textHeight)) + 2;
+ this.hintBoxIcon = Picross.getImage(GridUI.HINT_BOX_ICON);
+ int hintBoxWidth = this.hintBoxIcon.getIconWidth();
+ int hintBoxHeight = this.hintBoxIcon.getIconHeight();
+
// Now computes the grid boundaries
this.leftBoundary = GridUI.LEFT_HINTS
- + (this.rowData[0].length * this.hintBoxSize);
+ + (this.rowData[0].length * hintBoxWidth);
this.rightBoundary = this.leftBoundary
+ (this.width * GridUI.BOX_WIDTH);
this.topBoundary = GridUI.TOP_HINTS
- + (this.colData[0].length * this.hintBoxSize);
+ + (this.colData[0].length * hintBoxHeight);
this.bottomBoundary = this.topBoundary
+ (this.height * GridUI.BOX_HEIGHT);
@@ -225,6 +252,24 @@
this.height
* GridUI.BOX_HEIGHT);
+ this.topHintsX = this.leftBoundary
+ + (GridUI.BOX_WIDTH / 2) - (hintBoxWidth / 2);
+ this.topHintsDecal = hintBoxHeight + GridUI.HINTS_SPACE;
+
+ this.leftHintsY = this.topBoundary
+ + (GridUI.BOX_HEIGHT / 2) - (hintBoxHeight / 2);
+
+ this.leftHintsDecal = hintBoxWidth + GridUI.HINTS_SPACE;
+
+ this.centerHintHeight =
+ (hintBoxHeight / 2) + (hintHeight / 2);
+ this.centerLowHintWidth =
+ (hintBoxWidth / 2) - (lowHintWidth / 2);
+ this.centerHighHintWidth =
+ (hintBoxWidth / 2) - (highHintWidth / 2);
+
+ // Contain the state of the grid
+
this.boxes = new GridBox[this.width][this.height];
for (int i = 0; i < this.width; i++) {
@@ -259,67 +304,20 @@
protected void paintComponent(Graphics g) {
super.paintComponent(g);
- Rectangle clipRect = g.getClipBounds();
+ Graphics newG = g.create();
- if (this.topHintsRect.intersects(clipRect)) {
- Graphics2D g2d = (Graphics2D) g.create();
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
+ Rectangle clipRect = newG.getClipBounds();
- //GridUI.log.debug("top hints");
-
- int x = 0;
- int y = GridUI.TOP_HINTS;
-
- for (int i = this.colData[0].length - 1; i >= 0; i--) {
- x = this.leftBoundary + GridUI.COL_HINT_WIDTH;
-
- for (int j = 0; j < this.colData.length; j++) {
- if (this.colData[j][i] != GridModel.EMPTY_HINT) {
- // Center the hint
- int hintX = x
- + (((x + GridUI.COL_HINT_WIDTH) - x) / 2);
-
- this.drawColHint(g2d, this.colData[j][i], hintX, y);
- }
-
- x += GridUI.BOX_WIDTH;
- }
-
- y += this.hintBoxSize + 2;
- }
-
- g2d.dispose();
+ if (this.topHintsRect.intersects(clipRect)) {
+ this.drawTopHints(newG);
}
if (this.leftHintsRect.intersects(clipRect)) {
- //GridUI.log.debug("left hints");
-
- Graphics2D g2d = (Graphics2D) g.create();
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
-
- int y = this.topBoundary;
-
- for (int i = 0; i < this.rowData.length; i++) {
- int x = 0;
-
- int hintY = y + GridUI.ROW_HINT_HEIGHT;
-
- for (int j = 0; j < this.rowData[i].length; j++) {
- if (this.rowData[i][j] != GridModel.EMPTY_HINT) {
- this.drawRowHint(g2d, this.rowData[i][j], x, hintY);
- }
-
- x += this.hintBoxSize + 2;
- }
-
- y += GridUI.BOX_HEIGHT;
- }
-
- g2d.dispose();
+ this.drawLeftHints(newG);
}
+ // Paints the boxes
+
for (int i = 0; i < this.width; i++) {
for (int j = 0; j < this.height; j++) {
//GridUI.log.debug("currentRect : " + i + "," + j);
@@ -329,9 +327,10 @@
if (currentRect.intersects(clipRect)) {
if (this.boxes[i][j] == this.rollover) {
this.boxes[i][j].getRolloverIcon()
- .paintIcon(this, g, currentRect.x, currentRect.y);
+ .paintIcon(this, newG,
+ currentRect.x, currentRect.y);
} else {
- this.boxes[i][j].getIcon().paintIcon(this, g,
+ this.boxes[i][j].getIcon().paintIcon(this, newG,
currentRect.x,
currentRect.y);
}
@@ -339,130 +338,123 @@
}
}
- g.setColor(Color.RED);
+ // Draws the blocks
+ newG.setColor(GridUI.BLOCKS_COLOR);
- int currentY = this.topBoundary;
- int boxWidth = 5 * GridUI.BOX_WIDTH;
- int boxHeight = 5 * GridUI.BOX_HEIGHT;
+ int boxWidth = GridUI.BLOCK_WIDTH * GridUI.BOX_WIDTH;
+ int boxHeight = GridUI.BLOCK_HEIGHT * GridUI.BOX_HEIGHT;
int i = 0;
+ int currentY = this.topBoundary;
while (i < this.height) {
- int currentX = this.leftBoundary;
int j = 0;
+ int currentX = this.leftBoundary;
while (j < this.width) {
- if ((i + 5) <= this.height) {
- if ((j + 5 <= this.width)) {
- g.drawRect(currentX, currentY,
+ if ((i + GridUI.BLOCK_HEIGHT) <= this.height) {
+ if ((j + GridUI.BLOCK_WIDTH <= this.width)) {
+ newG.drawRect(currentX, currentY,
boxWidth, boxHeight);
} else {
- g.drawRect(currentX, currentY,
+ newG.drawRect(currentX, currentY,
(this.width - j) * GridUI.BOX_WIDTH,
boxHeight);
}
} else {
- if ((j + 5 <= this.width)) {
- g.drawRect(currentX, currentY,
+ if ((j + GridUI.BLOCK_WIDTH <= this.width)) {
+ newG.drawRect(currentX, currentY,
boxWidth,
(this.height - i) * GridUI.BOX_HEIGHT);
} else {
- g.drawRect(currentX, currentY,
+ newG.drawRect(currentX, currentY,
(this.width - j) * GridUI.BOX_WIDTH,
(this.height - i) * GridUI.BOX_HEIGHT);
}
}
currentX += boxWidth;
- j += 5;
+ j += GridUI.BLOCK_WIDTH;
}
currentY += boxHeight;
- i += 5;
+ i += GridUI.BLOCK_HEIGHT;
}
+
+ newG.dispose();
}
/*** Methods ***/
/**
- * Draws a column hint.
+ * Draws the top hints.
*
- * @param g2d the graphic context
- * @param value hint value
- * @param x X coordinate
- * @param y Y coordinate
+ * @param g the graphics context
*/
- private void drawColHint(Graphics2D g2d, int value, int x, int y) {
- this.drawHintBox(g2d, x, y, GridUI.COL_HINT_HEIGHT);
- this.setHintPen(g2d);
+ private void drawTopHints(Graphics g) {
+ int y = 0;
- if (value < 10) {
- // Tries to center the hint text
- g2d.drawString(String.valueOf(value),
- x + (this.hintBoxSize / 3),
- y);
- } else {
- g2d.drawString(String.valueOf(value),
- x,
- y);
+ for (int i = this.colData[0].length - 1; i >= 0; i--) {
+ int x = this.topHintsX;
+
+ for (int j = 0; j < this.colData.length; j++) {
+ if (this.colData[j][i] != GridModel.EMPTY_HINT) {
+ this.drawHint(g, this.colData[j][i], x, y);
+ }
+
+ x += GridUI.BOX_WIDTH;
+ }
+
+ y += this.topHintsDecal;
}
}
/**
- * Draws a row hint.
+ * Draws the left hints.
*
- * @param g2d the graphic context
- * @param value hint value
- * @param x X coordinate
- * @param y Y coordinate
+ * @param g the graphics context
*/
- private void drawRowHint(Graphics2D g2d, int value, int x, int y) {
- this.drawHintBox(g2d, x, y, GridUI.ROW_HINT_HEIGHT);
- this.setHintPen(g2d);
+ private void drawLeftHints(Graphics g) {
+ int y = this.leftHintsY;
- if (value < 10) {
- g2d.drawString(String.valueOf(value),
- x + (this.hintBoxSize / 3) - 1,
- y - 3);
- } else {
- g2d.drawString(String.valueOf(value),
- x + 1,
- y - 3);
+ for (int i = 0; i < this.rowData.length; i++) {
+ int x = 0;
+
+ for (int j = 0; j < this.rowData[i].length; j++) {
+ if (this.rowData[i][j] != GridModel.EMPTY_HINT) {
+ this.drawHint(g, this.rowData[i][j], x, y);
+ }
+
+ x += this.leftHintsDecal;
+ }
+
+ y += GridUI.BOX_HEIGHT;
}
}
/**
- * Draws a hint box.
+ * Draws a hint.
*
- * @param g2d the graphic context
+ * @param g the graphics context
+ * @param value hint value
* @param x X coordinate
* @param y Y coordinate
- * @param hintHeight the hint height
*/
- private void drawHintBox(Graphics2D g2d, int x, int y, int hintHeight) {
- g2d.setColor(GridUI.HINT_FILL_COLOR);
- g2d.fillRoundRect(x,
- y - hintHeight,
- this.hintBoxSize,
- this.hintBoxSize,
- GridUI.ROUND_DIAMETER, GridUI.ROUND_DIAMETER);
+ private void drawHint(Graphics g, int value, int x, int y) {
+ this.hintBoxIcon.paintIcon(this, g, x, y);
- g2d.setColor(GridUI.HINT_OUTLINE_COLOR);
- g2d.drawRoundRect(x,
- y - hintHeight,
- this.hintBoxSize,
- this.hintBoxSize,
- GridUI.ROUND_DIAMETER, GridUI.ROUND_DIAMETER);
- }
+ g.setColor(GridUI.HINT_TEXT_COLOR);
+ g.setFont(GridUI.HINT_FONT);
- /**
- * Sets the hint color and font.
- *
- * @param g2d the graphic context
- */
- private void setHintPen(Graphics2D g2d) {
- g2d.setColor(GridUI.HINT_TEXT_COLOR);
- g2d.setFont(GridUI.HINT_FONT);
+ y += this.centerHintHeight;
+
+ if (value < 10) {
+ x += this.centerLowHintWidth;
+ g.drawString(String.valueOf(value), x, y);
+ } else {
+ x += this.centerHighHintWidth;
+ g.drawString(String.valueOf(value), x, y);
+ }
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2007-06-13 18:20:42
|
Revision: 36
http://picross.svn.sourceforge.net/picross/?rev=36&view=rev
Author: yvan_norsa
Date: 2007-06-13 11:20:44 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
random game, bigger applet
Modified Paths:
--------------
trunk/applet/index.html
trunk/bugsFilter.xml
trunk/src/picross/PicrossController.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/applet/MainMenuAppletUI.java
trunk/src/picross/applet/PicrossApplet.java
trunk/src/picross/grid/GridUI.java
trunk/src/picross/menus/MainMenuController.java
trunk/src/picross/menus/MainMenuUI.java
trunk/src/picross/properties/messages_picross.properties
trunk/src/picross/properties/messages_picross_fr.properties
Added Paths:
-----------
trunk/applet/log4j.properties
trunk/src/picross/AbstractPicrossModel.java
trunk/src/picross/PicrossGrid.java
trunk/src/picross/game/
trunk/src/picross/game/GameMediator.java
trunk/src/picross/game/GameUI.java
trunk/src/picross/game/package.html
trunk/src/picross/game/random/
trunk/src/picross/game/random/RandomGameController.java
trunk/src/picross/game/random/RandomGameMediator.java
trunk/src/picross/game/random/RandomGameUI.java
trunk/src/picross/game/random/RandomPicrossModel.java
trunk/src/picross/game/random/package.html
Removed Paths:
-------------
trunk/src/picross/PicrossModel.java
Modified: trunk/applet/index.html
===================================================================
--- trunk/applet/index.html 2007-06-13 18:01:08 UTC (rev 35)
+++ trunk/applet/index.html 2007-06-13 18:20:44 UTC (rev 36)
@@ -24,17 +24,17 @@
</comment>
<script language="JavaScript" type="text/javascript"><!--
- if (_ie == true) document.writeln('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "550" HEIGHT = "400" codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,3"><noembed><xmp>');
+ if (_ie == true) document.writeln('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "900" HEIGHT = "900" codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,3"><noembed><xmp>');
else if (_ns == true && _ns6 == false) document.writeln('<embed ' +
'type="application/x-java-applet;version=1.5" \
CODE = "picross.applet.PicrossApplet" \
ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar" \
- WIDTH = "550" \
- HEIGHT = "400" ' +
+ WIDTH = "900" \
+ HEIGHT = "900" ' +
'scriptable=false ' +
'pluginspage="http://java.sun.com/products/plugin/index.html#download"><noembed><xmp>');
//--></script>
-<applet CODE = "picross.applet.PicrossApplet" ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar" WIDTH = "550" HEIGHT = "400"></xmp>
+<applet CODE = "picross.applet.PicrossApplet" ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar" WIDTH = "900" HEIGHT = "900"></xmp>
<PARAM NAME = CODE VALUE = "picross.applet.PicrossApplet" >
<PARAM NAME = ARCHIVE VALUE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar" >
<param name="type" value="application/x-java-applet;version=1.5">
@@ -46,7 +46,7 @@
</embed>
</object>
<!--
-<APPLET CODE = "picross.applet.PicrossApplet" ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar" WIDTH = "550" HEIGHT = "400">
+<APPLET CODE = "picross.applet.PicrossApplet" ARCHIVE = "picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar" WIDTH = "900" HEIGHT = "900">
</APPLET>
Added: trunk/applet/log4j.properties
===================================================================
--- trunk/applet/log4j.properties (rev 0)
+++ trunk/applet/log4j.properties 2007-06-13 18:20:44 UTC (rev 36)
@@ -0,0 +1,3 @@
+log4j.rootCategory=off
+
+
Property changes on: trunk/applet/log4j.properties
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/bugsFilter.xml
===================================================================
--- trunk/bugsFilter.xml 2007-06-13 18:01:08 UTC (rev 35)
+++ trunk/bugsFilter.xml 2007-06-13 18:20:44 UTC (rev 36)
@@ -1,5 +1,5 @@
<FindBugsFilter>
<Match classregex=".*">
- <Bug pattern="DM_CONVERT_CASE,LSC_LITERAL_STRING_COMPARISON,CLI_CONSTANT_LIST_INDEX,S508C_SET_COMP_COLOR" />
+ <Bug pattern="DM_CONVERT_CASE,LSC_LITERAL_STRING_COMPARISON,CLI_CONSTANT_LIST_INDEX,S508C_SET_COMP_COLOR,S508C_NO_SETLABELFOR" />
</Match>
</FindBugsFilter>
Copied: trunk/src/picross/AbstractPicrossModel.java (from rev 32, trunk/src/picross/PicrossModel.java)
===================================================================
--- trunk/src/picross/AbstractPicrossModel.java (rev 0)
+++ trunk/src/picross/AbstractPicrossModel.java 2007-06-13 18:20:44 UTC (rev 36)
@@ -0,0 +1,268 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross;
+
+/**
+ * Model handling the puzzle data.
+ *
+ * @author Y. Norsa
+ */
+public class AbstractPicrossModel implements PicrossGrid {
+ /*** Fields ***/
+
+ /** Grid width. */
+ protected int width;
+
+ /** Grid height. */
+ protected int height;
+
+ /** Grid content. */
+ protected boolean[][] data;
+
+ /*** Constructor ***/
+
+ /** Constructor. */
+ /*
+ PicrossModel() {
+ this.width = 19;
+ this.height = 14;
+
+ this.data = new boolean[this.width][this.height];
+
+ this.data[0][7] = true;
+ this.data[0][8] = true;
+ this.data[0][13] = true;
+
+ this.data[1][6] = true;
+ this.data[1][7] = true;
+ this.data[1][8] = true;
+ this.data[1][9] = true;
+ this.data[1][12] = true;
+ this.data[1][13] = true;
+
+ this.data[2][6] = true;
+ this.data[2][7] = true;
+ this.data[2][8] = true;
+ this.data[2][9] = true;
+ this.data[2][12] = true;
+ this.data[2][13] = true;
+
+ this.data[3][5] = true;
+ this.data[3][6] = true;
+ this.data[3][8] = true;
+ this.data[3][9] = true;
+ this.data[3][10] = true;
+ this.data[3][11] = true;
+ this.data[3][12] = true;
+ this.data[3][13] = true;
+
+ this.data[4][5] = true;
+ this.data[4][6] = true;
+ this.data[4][7] = true;
+ this.data[4][8] = true;
+ this.data[4][9] = true;
+ this.data[4][10] = true;
+ this.data[4][11] = true;
+ this.data[4][12] = true;
+ this.data[4][13] = true;
+
+ this.data[5][0] = true;
+ this.data[5][1] = true;
+ this.data[5][2] = true;
+ this.data[5][3] = true;
+ this.data[5][4] = true;
+ this.data[5][5] = true;
+ this.data[5][6] = true;
+ this.data[5][7] = true;
+ this.data[5][8] = true;
+ this.data[5][9] = true;
+ this.data[5][10] = true;
+ this.data[5][11] = true;
+ this.data[5][12] = true;
+ this.data[5][13] = true;
+
+ this.data[6][0] = true;
+ this.data[6][1] = true;
+ this.data[6][2] = true;
+ this.data[6][3] = true;
+ this.data[6][4] = true;
+ this.data[6][5] = true;
+ this.data[6][6] = true;
+ this.data[6][7] = true;
+ this.data[6][8] = true;
+ this.data[6][9] = true;
+ this.data[6][10] = true;
+ this.data[6][11] = true;
+ this.data[6][12] = true;
+ this.data[6][13] = true;
+
+ this.data[7][1] = true;
+ this.data[7][2] = true;
+ this.data[7][3] = true;
+ this.data[7][4] = true;
+ this.data[7][5] = true;
+ this.data[7][6] = true;
+ this.data[7][7] = true;
+ this.data[7][8] = true;
+ this.data[7][9] = true;
+ this.data[7][10] = true;
+ this.data[7][11] = true;
+ this.data[7][12] = true;
+ this.data[7][13] = true;
+
+ this.data[8][8] = true;
+ this.data[8][9] = true;
+ this.data[8][10] = true;
+ this.data[8][11] = true;
+ this.data[8][12] = true;
+ this.data[8][13] = true;
+
+ this.data[9][7] = true;
+ this.data[9][8] = true;
+ this.data[9][9] = true;
+ this.data[9][10] = true;
+ this.data[9][11] = true;
+ this.data[9][12] = true;
+ this.data[9][13] = true;
+
+ this.data[10][7] = true;
+ this.data[10][8] = true;
+ this.data[10][9] = true;
+ this.data[10][10] = true;
+ this.data[10][11] = true;
+ this.data[10][12] = true;
+ this.data[10][13] = true;
+
+ this.data[11][6] = true;
+ this.data[11][7] = true;
+ this.data[11][8] = true;
+ this.data[11][9] = true;
+ this.data[11][10] = true;
+ this.data[11][11] = true;
+ this.data[11][12] = true;
+ this.data[11][13] = true;
+
+ this.data[12][6] = true;
+ this.data[12][7] = true;
+ this.data[12][8] = true;
+ this.data[12][9] = true;
+ this.data[12][10] = true;
+ this.data[12][11] = true;
+ this.data[12][12] = true;
+ this.data[12][13] = true;
+
+ this.data[13][6] = true;
+ this.data[13][7] = true;
+ this.data[13][8] = true;
+ this.data[13][9] = true;
+ this.data[13][10] = true;
+ this.data[13][11] = true;
+ this.data[13][12] = true;
+ this.data[13][13] = true;
+
+ this.data[14][6] = true;
+ this.data[14][7] = true;
+ this.data[14][8] = true;
+ this.data[14][9] = true;
+ this.data[14][10] = true;
+ this.data[14][11] = true;
+ this.data[14][12] = true;
+ this.data[14][13] = true;
+
+ this.data[15][7] = true;
+ this.data[15][8] = true;
+ this.data[15][9] = true;
+ this.data[15][10] = true;
+ this.data[15][11] = true;
+ this.data[15][12] = true;
+ this.data[15][13] = true;
+
+ this.data[16][9] = true;
+ this.data[16][10] = true;
+ this.data[16][11] = true;
+ this.data[16][12] = true;
+ this.data[16][13] = true;
+
+ this.data[17][8] = true;
+ this.data[17][9] = true;
+ this.data[17][10] = true;
+ this.data[17][11] = true;
+ this.data[17][12] = true;
+ this.data[17][13] = true;
+
+ this.data[18][9] = true;
+ this.data[18][10] = true;
+ this.data[18][11] = true;
+ this.data[18][12] = true;
+ }
+ */
+ /*** Accessors ***/
+
+ /**
+ * Returns the width.
+ *
+ * @return grid width
+ */
+ public final int getWidth() {
+ return this.width;
+ }
+
+ /**
+ * Returns the height.
+ *
+ * @return grid height
+ */
+ public final int getHeight() {
+ return this.height;
+ }
+
+ /**
+ * Returns the content.
+ *
+ * @return grid content
+ */
+ public final boolean[][] getData() {
+ boolean[][] dataCopy = new boolean[this.data.length][];
+
+ for (int i = 0; i < this.data.length; i++) {
+ dataCopy[i] = new boolean[this.data[i].length];
+ System.arraycopy(this.data[i], 0,
+ dataCopy[i], 0,
+ this.data[i].length);
+ }
+
+ return dataCopy;
+ }
+}
+
Modified: trunk/src/picross/PicrossController.java
===================================================================
--- trunk/src/picross/PicrossController.java 2007-06-13 18:01:08 UTC (rev 35)
+++ trunk/src/picross/PicrossController.java 2007-06-13 18:20:44 UTC (rev 36)
@@ -43,7 +43,12 @@
*
* @author Y. Norsa
*/
-final class PicrossController extends Controller {
+public final class PicrossController extends Controller {
+ /*** Constant ***/
+
+ /** Play command. */
+ public static final String PLAY_CMD = "PLAY_CMD";
+
/*** Static field ***/
/** The class's logger. */
Added: trunk/src/picross/PicrossGrid.java
===================================================================
--- trunk/src/picross/PicrossGrid.java (rev 0)
+++ trunk/src/picross/PicrossGrid.java 2007-06-13 18:20:44 UTC (rev 36)
@@ -0,0 +1,62 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross;
+
+/**
+ * Interface for classes able to provide a grid.
+ *
+ * @author Y. Norsa
+ */
+public interface PicrossGrid {
+ /**
+ * Returns the width.
+ *
+ * @return grid width
+ */
+ int getWidth();
+
+ /**
+ * Returns the height.
+ *
+ * @return grid height
+ */
+ int getHeight();
+
+ /**
+ * Returns the content.
+ *
+ * @return grid content
+ */
+ boolean[][] getData();
+}
Property changes on: trunk/src/picross/PicrossGrid.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2007-06-13 18:01:08 UTC (rev 35)
+++ trunk/src/picross/PicrossMediator.java 2007-06-13 18:20:44 UTC (rev 36)
@@ -40,8 +40,9 @@
//import org.apache.log4j.Logger;
+import picross.game.GameMediator;
+
import picross.grid.GridController;
-import picross.grid.GridMediator;
import picross.menus.MainMenuController;
import picross.menus.MainMenuMediator;
@@ -101,16 +102,13 @@
String cmd = e.getCommandName();
- if (cmd.equals(MainMenuController.PLAY_CMD)) {
- PicrossModel model = new PicrossModel();
+ if (cmd.equals(PicrossController.PLAY_CMD)) {
+ //this.view.setContent(grid.getView());
- GridMediator grid = new GridMediator(model.getWidth(),
- model.getHeight(),
- model.getData());
- grid.addSimpleListener(this);
+ GameMediator game = new picross.game.random.RandomGameMediator();
+ game.addSimpleListener(this);
+ this.view.setContent(game.getView());
- this.view.setContent(grid.getView());
-
return;
}
@@ -121,7 +119,8 @@
if (cmd.equals(GridController.GRID_FILLED_CMD)) {
this.fireEventPerformed(PicrossController.MESSAGE_CMD,
- BundleHelper.getString(this, "victory"));
+ BundleHelper.getString(this, "victory")
+ + " !");
return;
}
}
Deleted: trunk/src/picross/PicrossModel.java
===================================================================
--- trunk/src/picross/PicrossModel.java 2007-06-13 18:01:08 UTC (rev 35)
+++ trunk/src/picross/PicrossModel.java 2007-06-13 18:20:44 UTC (rev 36)
@@ -1,258 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (c) 2007
- *
- * This software is governed by the CeCILL license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL license and that you accept its terms.
- */
-
-
-package picross;
-
-/**
- * Model handling the puzzle data.
- *
- * @author Y. Norsa
- */
-final class PicrossModel {
- /*** Fields ***/
-
- /** Grid width. */
- private int width;
-
- /** Grid height. */
- private int height;
-
- /** Grid content. */
- private boolean[][] data;
-
- /*** Constructor ***/
-
- /** Constructor. */
- PicrossModel() {
- this.width = 19;
- this.height = 14;
-
- this.data = new boolean[this.width][this.height];
-
- this.data[0][7] = true;
- this.data[0][8] = true;
- this.data[0][13] = true;
-
- this.data[1][6] = true;
- this.data[1][7] = true;
- this.data[1][8] = true;
- this.data[1][9] = true;
- this.data[1][12] = true;
- this.data[1][13] = true;
-
- this.data[2][6] = true;
- this.data[2][7] = true;
- this.data[2][8] = true;
- this.data[2][9] = true;
- this.data[2][12] = true;
- this.data[2][13] = true;
-
- this.data[3][5] = true;
- this.data[3][6] = true;
- this.data[3][8] = true;
- this.data[3][9] = true;
- this.data[3][10] = true;
- this.data[3][11] = true;
- this.data[3][12] = true;
- this.data[3][13] = true;
-
- this.data[4][5] = true;
- this.data[4][6] = true;
- this.data[4][7] = true;
- this.data[4][8] = true;
- this.data[4][9] = true;
- this.data[4][10] = true;
- this.data[4][11] = true;
- this.data[4][12] = true;
- this.data[4][13] = true;
-
- this.data[5][0] = true;
- this.data[5][1] = true;
- this.data[5][2] = true;
- this.data[5][3] = true;
- this.data[5][4] = true;
- this.data[5][5] = true;
- this.data[5][6] = true;
- this.data[5][7] = true;
- this.data[5][8] = true;
- this.data[5][9] = true;
- this.data[5][10] = true;
- this.data[5][11] = true;
- this.data[5][12] = true;
- this.data[5][13] = true;
-
- this.data[6][0] = true;
- this.data[6][1] = true;
- this.data[6][2] = true;
- this.data[6][3] = true;
- this.data[6][4] = true;
- this.data[6][5] = true;
- this.data[6][6] = true;
- this.data[6][7] = true;
- this.data[6][8] = true;
- this.data[6][9] = true;
- this.data[6][10] = true;
- this.data[6][11] = true;
- this.data[6][12] = true;
- this.data[6][13] = true;
-
- this.data[7][1] = true;
- this.data[7][2] = true;
- this.data[7][3] = true;
- this.data[7][4] = true;
- this.data[7][5] = true;
- this.data[7][6] = true;
- this.data[7][7] = true;
- this.data[7][8] = true;
- this.data[7][9] = true;
- this.data[7][10] = true;
- this.data[7][11] = true;
- this.data[7][12] = true;
- this.data[7][13] = true;
-
- this.data[8][8] = true;
- this.data[8][9] = true;
- this.data[8][10] = true;
- this.data[8][11] = true;
- this.data[8][12] = true;
- this.data[8][13] = true;
-
- this.data[9][7] = true;
- this.data[9][8] = true;
- this.data[9][9] = true;
- this.data[9][10] = true;
- this.data[9][11] = true;
- this.data[9][12] = true;
- this.data[9][13] = true;
-
- this.data[10][7] = true;
- this.data[10][8] = true;
- this.data[10][9] = true;
- this.data[10][10] = true;
- this.data[10][11] = true;
- this.data[10][12] = true;
- this.data[10][13] = true;
-
- this.data[11][6] = true;
- this.data[11][7] = true;
- this.data[11][8] = true;
- this.data[11][9] = true;
- this.data[11][10] = true;
- this.data[11][11] = true;
- this.data[11][12] = true;
- this.data[11][13] = true;
-
- this.data[12][6] = true;
- this.data[12][7] = true;
- this.data[12][8] = true;
- this.data[12][9] = true;
- this.data[12][10] = true;
- this.data[12][11] = true;
- this.data[12][12] = true;
- this.data[12][13] = true;
-
- this.data[13][6] = true;
- this.data[13][7] = true;
- this.data[13][8] = true;
- this.data[13][9] = true;
- this.data[13][10] = true;
- this.data[13][11] = true;
- this.data[13][12] = true;
- this.data[13][13] = true;
-
- this.data[14][6] = true;
- this.data[14][7] = true;
- this.data[14][8] = true;
- this.data[14][9] = true;
- this.data[14][10] = true;
- this.data[14][11] = true;
- this.data[14][12] = true;
- this.data[14][13] = true;
-
- this.data[15][7] = true;
- this.data[15][8] = true;
- this.data[15][9] = true;
- this.data[15][10] = true;
- this.data[15][11] = true;
- this.data[15][12] = true;
- this.data[15][13] = true;
-
- this.data[16][9] = true;
- this.data[16][10] = true;
- this.data[16][11] = true;
- this.data[16][12] = true;
- this.data[16][13] = true;
-
- this.data[17][8] = true;
- this.data[17][9] = true;
- this.data[17][10] = true;
- this.data[17][11] = true;
- this.data[17][12] = true;
- this.data[17][13] = true;
-
- this.data[18][9] = true;
- this.data[18][10] = true;
- this.data[18][11] = true;
- this.data[18][12] = true;
- }
-
- /*** Accessors ***/
-
- /**
- * Returns the width.
- *
- * @return grid width
- */
- int getWidth() {
- return this.width;
- }
-
- /**
- * Returns the height.
- *
- * @return grid height
- */
- int getHeight() {
- return this.height;
- }
-
- /**
- * Returns the content.
- *
- * @return grid content
- */
- boolean[][] getData() {
- return this.data;
- }
-}
-
Modified: trunk/src/picross/applet/MainMenuAppletUI.java
===================================================================
--- trunk/src/picross/applet/MainMenuAppletUI.java 2007-06-13 18:01:08 UTC (rev 35)
+++ trunk/src/picross/applet/MainMenuAppletUI.java 2007-06-13 18:20:44 UTC (rev 36)
@@ -1,50 +1,40 @@
/*
* $Id$
- * \xC9crit le 07/06/2007 par Y. Norsa
*
* Copyright (c) 2007
- * Projet Carte Lorraine de l'Etudiant (CLE)
*
- * Universit\xE9 Henri Poincar\xE9, Nancy
- * Universit\xE9 Nancy2
- * Institut National Polytechnique de Lorraine
- * Universit\xE9 Paul Verlaine, Metz
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
*
- * Ce projet regroupe les d\xE9veloppements concernant la production
- * et l'exploitation de la Carte Lorraine de l'Etudiant
- * (carte \xE0 puce sans contact Mifare).
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
*
- * Ce logiciel est r\xE9gi par la licence CeCILL soumise au droit fran\xE7ais et
- * respectant les principes de diffusion des logiciels libres. Vous pouvez
- * utiliser, modifier et/ou redistribuer ce programme sous les conditions
- * de la licence CeCILL telle que diffus\xE9e par le CEA, le CNRS et l'INRIA
- * sur le site "http://www.cecill.info".
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
*
- * En contrepartie de l'accessibilit\xE9 au code source et des droits de copie,
- * de modification et de redistribution accord\xE9s par cette licence, il n'est
- * offert aux utilisateurs qu'une garantie limit\xE9e. Pour les m\xEAmes raisons,
- * seule une responsabilit\xE9 restreinte p\xE8se sur l'auteur du programme, le
- * titulaire des droits patrimoniaux et les conc\xE9dants successifs.
- *
- * A cet \xE9gard l'attention de l'utilisateur est attir\xE9e sur les risques
- * associ\xE9s au chargement, \xE0 l'utilisation, \xE0 la modification et/ou au
- * d\xE9veloppement et \xE0 la reproduction du logiciel par l'utilisateur \xE9tant
- * donn\xE9 sa sp\xE9cificit\xE9 de logiciel libre, qui peut le rendre complexe \xE0
- * manipuler et qui le r\xE9serve donc \xE0 des d\xE9veloppeurs et des professionnels
- * avertis poss\xE9dant des connaissances informatiques approfondies. Les
- * utilisateurs sont donc invit\xE9s \xE0 charger et tester l'ad\xE9quation du
- * logiciel \xE0 leurs besoins dans des conditions permettant d'assurer la
- * s\xE9curit\xE9 de leurs syst\xE8mes et ou de leurs donn\xE9es et, plus g\xE9n\xE9ralement,
- * \xE0 l'utiliser et l'exploiter dans les m\xEAmes conditions de s\xE9curit\xE9.
- *
- * Le fait que vous puissiez acc\xE9der \xE0 cet en-t\xEAte signifie que vous avez
- * pris connaissance de la licence CeCILL, et que vous en avez accept\xE9 les
- * termes.
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
*/
package picross.applet;
+import java.awt.Color;
+
import java.awt.event.ActionListener;
import picross.menus.MainMenuUI;
@@ -75,6 +65,8 @@
*/
public MainMenuAppletUI(ActionListener controller) {
super(controller);
+
+ this.setBackground(Color.WHITE);
}
/*** Methods inherited from the class MainMenuUI ***/
Modified: trunk/src/picross/applet/PicrossApplet.java
===================================================================
--- trunk/src/picross/applet/PicrossApplet.java 2007-06-13 18:01:08 UTC (rev 35)
+++ trunk/src/picross/applet/PicrossApplet.java 2007-06-13 18:20:44 UTC (rev 36)
@@ -33,8 +33,6 @@
package picross.applet;
-import java.awt.Color;
-
import javax.swing.JApplet;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
Added: trunk/src/picross/game/GameMediator.java
===================================================================
--- trunk/src/picross/...
[truncated message content] |
|
From: <yva...@us...> - 2007-06-14 05:59:00
|
Revision: 37
http://picross.svn.sourceforge.net/picross/?rev=37&view=rev
Author: yvan_norsa
Date: 2007-06-13 22:59:01 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
fixed bundleHelper
Modified Paths:
--------------
trunk/lib/bundleHelper.jar
trunk/src/picross/game/GameUI.java
trunk/src/picross/game/random/RandomGameUI.java
Modified: trunk/lib/bundleHelper.jar
===================================================================
(Binary files differ)
Modified: trunk/src/picross/game/GameUI.java
===================================================================
--- trunk/src/picross/game/GameUI.java 2007-06-13 18:20:44 UTC (rev 36)
+++ trunk/src/picross/game/GameUI.java 2007-06-14 05:59:01 UTC (rev 37)
@@ -79,8 +79,7 @@
this.infosPanel.setLayout(new BoxLayout(this.infosPanel,
BoxLayout.Y_AXIS));
- // FIXME "this" should be usable instead of "Picross.class"
- JLabel infos = new JLabel(BundleHelper.getString(Picross.class,
+ JLabel infos = new JLabel(BundleHelper.getString(this,
"gridSize")
+ " : " + width + "*" + height);
this.infosPanel.add(infos);
Modified: trunk/src/picross/game/random/RandomGameUI.java
===================================================================
--- trunk/src/picross/game/random/RandomGameUI.java 2007-06-13 18:20:44 UTC (rev 36)
+++ trunk/src/picross/game/random/RandomGameUI.java 2007-06-14 05:59:01 UTC (rev 37)
@@ -70,7 +70,7 @@
super(width, height, grid);
JButton nextButton =
- new JButton(BundleHelper.getString(Picross.class, "anotherGrid"));
+ new JButton(BundleHelper.getString(this, "anotherGrid"));
nextButton.addActionListener(controller);
nextButton.setActionCommand(RandomGameController.NEXT_CMD);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2007-06-14 13:51:02
|
Revision: 39
http://picross.svn.sourceforge.net/picross/?rev=39&view=rev
Author: yvan_norsa
Date: 2007-06-14 06:51:01 -0700 (Thu, 14 Jun 2007)
Log Message:
-----------
XBM support
Modified Paths:
--------------
trunk/build.xml
trunk/src/picross/Picross.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/game/GameMediator.java
trunk/src/picross/game/random/RandomGameMediator.java
Added Paths:
-----------
trunk/data/
trunk/data/anchor.xbm
trunk/data/bart.xbm
trunk/data/blarg.xbm
trunk/data/bunny.xbm
trunk/data/candle.xbm
trunk/data/crab.xbm
trunk/data/ghost_left.xbm
trunk/data/halloween.xbm
trunk/data/squares.xbm
trunk/src/picross/game/simple/
trunk/src/picross/game/simple/SimpleGameMediator.java
trunk/src/picross/game/simple/XBMModel.java
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2007-06-14 09:33:57 UTC (rev 38)
+++ trunk/build.xml 2007-06-14 13:51:01 UTC (rev 39)
@@ -80,6 +80,10 @@
<fileset dir="images" />
</copy>
+ <copy todir="${build.dir}/picross/data">
+ <fileset dir="data" />
+ </copy>
+
<jar destfile="${jar.name}"
basedir="${build.dir}" />
</target>
Added: trunk/data/anchor.xbm
===================================================================
--- trunk/data/anchor.xbm (rev 0)
+++ trunk/data/anchor.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,6 @@
+#define anchor.xbm_width 16
+#define anchor.xbm_height 16
+static char anchor.xbm_bits[] = {
+ 0x00, 0x00, 0xe0, 0x07, 0xe0, 0x07, 0x80, 0x05, 0x80, 0x05, 0x80, 0x05,
+ 0x80, 0x03, 0x80, 0x01, 0x9e, 0x79, 0x8e, 0x71, 0x8e, 0x71, 0x8a, 0x51,
+ 0x90, 0x09, 0xe0, 0x07, 0x80, 0x01, 0x00, 0x00};
Added: trunk/data/bart.xbm
===================================================================
--- trunk/data/bart.xbm (rev 0)
+++ trunk/data/bart.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,27 @@
+#define noname_width 43
+#define noname_height 58
+static char noname_bits[] = {
+ 0x00,0x00,0x00,0xc4,0x00,0x00,0x00,0x00,0xc0,0xca,0x00,0x00,0x00,0x00,0xc0,
+ 0xb2,0x00,0x00,0x00,0x00,0x4c,0xb3,0x00,0x00,0x00,0xc0,0x34,0x82,0x00,0x00,
+ 0x00,0x4c,0x35,0x80,0x00,0x00,0x80,0x54,0x26,0x80,0x00,0x00,0x80,0x67,0x04,
+ 0x80,0x00,0x00,0xb0,0x4c,0x00,0x80,0x00,0x00,0xd0,0x08,0x00,0x00,0x01,0x00,
+ 0x90,0x01,0x00,0x00,0x01,0x00,0x17,0x00,0x00,0x00,0x01,0x00,0x39,0x00,0x00,
+ 0x00,0x01,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00,0x02,0x00,
+ 0x04,0x00,0x00,0x00,0x02,0x00,0x08,0x00,0x00,0x00,0x02,0x00,0x08,0x00,0x00,
+ 0x00,0x0c,0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x1f,0x00,
+ 0x20,0x00,0x00,0x80,0x20,0x00,0x20,0x00,0x80,0x43,0x40,0x00,0x40,0x00,0x60,
+ 0x2c,0x80,0x00,0x40,0x00,0x18,0x10,0x80,0x00,0x40,0x00,0x04,0x20,0x8c,0x00,
+ 0x80,0x00,0x04,0x40,0x8c,0x00,0x80,0x00,0x02,0x40,0x40,0x00,0x00,0x01,0x01,
+ 0x40,0x70,0x00,0x00,0x01,0xc1,0xc0,0x8f,0x00,0x00,0x02,0xc1,0x40,0x00,0x01,
+ 0x00,0x02,0x02,0x20,0x00,0x01,0x00,0x02,0x02,0x10,0x00,0x01,0x00,0x04,0x04,
+ 0x10,0x00,0x01,0x00,0x04,0x08,0x0c,0x80,0x00,0x00,0x04,0xf0,0x03,0x40,0x00,
+ 0x00,0x08,0x00,0x00,0xbe,0x00,0x00,0x08,0x00,0x00,0x80,0x00,0x00,0x30,0x00,
+ 0x00,0x80,0x00,0x00,0x48,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00,0x01,
+ 0x00,0x74,0x00,0x00,0x00,0x02,0x00,0x2a,0x00,0x00,0x00,0x04,0x00,0x6a,0x40,
+ 0x00,0x00,0x03,0x00,0x04,0x20,0x00,0xc0,0x00,0x00,0x88,0x70,0x00,0x3e,0x00,
+ 0x00,0x70,0x90,0xff,0x01,0x00,0x00,0x20,0x10,0x80,0x00,0x00,0x00,0x20,0x00,
+ 0x80,0x00,0x00,0x00,0x20,0x00,0x60,0x00,0x00,0x00,0x20,0x00,0x10,0x00,0x00,
+ 0x00,0x20,0x00,0x08,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x10,0x00,
+ 0x08,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x60,0x00,0x08,0x00,0x00,
+ 0x00,0x80,0x01,0x08,0x00,0x00,0x00,0x00,0x06,0x04,0x00,0x00,0x00,0x00,0xf8,
+ 0x03,0x00,0x00};
Added: trunk/data/blarg.xbm
===================================================================
--- trunk/data/blarg.xbm (rev 0)
+++ trunk/data/blarg.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,5 @@
+#define test_width 16
+#define test_height 7
+static char test_bits[] = {
+0x13, 0x00, 0x15, 0x00, 0x93, 0xcd, 0x55, 0xa5, 0x93, 0xc5, 0x00, 0x80,
+0x00, 0x60, };
Added: trunk/data/bunny.xbm
===================================================================
--- trunk/data/bunny.xbm (rev 0)
+++ trunk/data/bunny.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,6 @@
+#define bunny_width 16
+#define bunny_height 16
+static char bunny_bits[] = {
+ 0x00,0x00,0x00,0x44,0x00,0xee,0x00,0xee,0x00,0xee,0x00,0xee,0x00,0x6c,0x00,
+ 0x38,0xe0,0x7c,0xf0,0xbd,0xf8,0xff,0xfa,0xff,0xff,0x7f,0xff,0x3f,0xff,0xff,
+ 0xfa,0xff};
Added: trunk/data/candle.xbm
===================================================================
--- trunk/data/candle.xbm (rev 0)
+++ trunk/data/candle.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,8 @@
+#define noname_width 16
+#define noname_height 33
+static char noname_bits[] = {
+ 0x00,0x01,0x00,0x03,0x00,0x03,0x00,0x03,0x80,0x06,0x40,0x06,0x40,0x06,0x40,
+ 0x06,0x40,0x03,0x80,0x01,0xf0,0x0f,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,
+ 0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,
+ 0x0c,0x10,0x0c,0xfe,0x7f,0x01,0xc0,0x02,0x60,0x0c,0x38,0x10,0x0c,0x10,0x0c,
+ 0x20,0x06,0x20,0x06,0x10,0x0c};
Added: trunk/data/crab.xbm
===================================================================
--- trunk/data/crab.xbm (rev 0)
+++ trunk/data/crab.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,7 @@
+#define crab_width 16
+#define crab_height 16
+
+static char crab_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x70, 0x0e, 0x78, 0x1e, 0x18, 0x18, 0x44, 0x22,
+ 0xc4, 0x23, 0xf8, 0x1f, 0xe0, 0x07, 0xf8, 0x1f, 0xe4, 0x27, 0xd0, 0x0b,
+ 0x08, 0x10, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 };
Added: trunk/data/ghost_left.xbm
===================================================================
--- trunk/data/ghost_left.xbm (rev 0)
+++ trunk/data/ghost_left.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,6 @@
+#define pacman_left_width 16
+#define pacman_left_height 16
+static char pacman_left_bits[] = {
+ 0xf0,0x07,0x0c,0x18,0x02,0x20,0x3a,0x2e,0x45,0x51,0x5d,0x57,0x5d,0x57,0x5d,
+ 0x57,0x45,0x51,0x39,0x4e,0x01,0x40,0x01,0x40,0x11,0x44,0x29,0x4a,0x45,0x51,
+ 0x82,0x20};
Added: trunk/data/halloween.xbm
===================================================================
--- trunk/data/halloween.xbm (rev 0)
+++ trunk/data/halloween.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,6 @@
+#define noname_width 16
+#define noname_height 16
+static char noname_bits[] = {
+ 0x00,0x03,0x80,0x01,0x80,0x01,0xb8,0x0d,0xf8,0x3f,0xfe,0x7f,0xce,0xf3,0xdf,
+ 0xf7,0x7f,0xfe,0xff,0xfe,0xff,0xff,0xce,0x67,0x1e,0x70,0x7c,0x3d,0xf0,0x0f,
+ 0x00,0x00};
Added: trunk/data/squares.xbm
===================================================================
--- trunk/data/squares.xbm (rev 0)
+++ trunk/data/squares.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,6 @@
+ #define test_width 16
+ #define test_height 16
+ static unsigned char test_bits[] = {
+ 0xff, 0xff, 0x01, 0x80, 0xfd, 0xbf, 0x05, 0xa0, 0xf5, 0xaf, 0x15, 0xa8,
+ 0xd5, 0xab, 0x55, 0xaa, 0x55, 0xaa, 0xd5, 0xab, 0x15, 0xa8, 0xf5, 0xaf,
+ 0x05, 0xa0, 0xfd, 0xbf, 0x01, 0x80, 0xff, 0xff};
Modified: trunk/src/picross/Picross.java
===================================================================
--- trunk/src/picross/Picross.java 2007-06-14 09:33:57 UTC (rev 38)
+++ trunk/src/picross/Picross.java 2007-06-14 13:51:01 UTC (rev 39)
@@ -33,6 +33,9 @@
package picross;
+import java.io.IOException;
+import java.io.InputStream;
+
import java.util.Locale;
import javax.swing.ImageIcon;
@@ -50,6 +53,8 @@
/** Images directory. */
private static final String IMAGES_DIR = "/picross/images/";
+ private static final String DATA_DIR = "/picross/data/";
+
/** Images directory corresponding to the default locale. */
private static final String LOCAL_IMAGES_PATH = Picross.IMAGES_DIR
+ Locale.getDefault().getLanguage() + "/";
@@ -95,5 +100,11 @@
public static ImageIcon getLocalizedImage(String name) {
return Picross.loadImage(Picross.LOCAL_IMAGES_PATH + name);
}
+
+ public static InputStream loadDataFile(String name)
+ throws IOException {
+
+ return Picross.class.getResource(Picross.DATA_DIR + name).openStream();
+ }
}
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2007-06-14 09:33:57 UTC (rev 38)
+++ trunk/src/picross/PicrossMediator.java 2007-06-14 13:51:01 UTC (rev 39)
@@ -105,7 +105,16 @@
if (cmd.equals(PicrossController.PLAY_CMD)) {
//this.view.setContent(grid.getView());
- GameMediator game = new picross.game.random.RandomGameMediator();
+ //GameMediator game = new picross.game.random.RandomGameMediator();
+ GameMediator game = null;
+
+ try {
+ game = new picross.game.simple.SimpleGameMediator();
+ } catch (PicrossException picrossEx) {
+ this.view.displayError(picrossEx.getMessage());
+ return;
+ }
+
game.addSimpleListener(this);
this.view.setContent(game.getView());
Modified: trunk/src/picross/game/GameMediator.java
===================================================================
--- trunk/src/picross/game/GameMediator.java 2007-06-14 09:33:57 UTC (rev 38)
+++ trunk/src/picross/game/GameMediator.java 2007-06-14 13:51:01 UTC (rev 39)
@@ -40,6 +40,7 @@
//import org.apache.log4j.Logger;
+import picross.PicrossException;
import picross.PicrossGrid;
import picross.grid.GridMediator;
@@ -63,7 +64,7 @@
/*** Constructor ***/
/** Constructor. */
- public GameMediator() {
+ public GameMediator() throws PicrossException {
PicrossGrid model = this.initModel();
int width = model.getWidth();
@@ -86,14 +87,16 @@
* @param gridView the grid itself
* @return view containing the grid
*/
- protected abstract GameUI initView(int width, int height, JPanel gridView);
+ protected GameUI initView(int width, int height, JPanel gridView) {
+ return new GameUI(width, height, gridView);
+ }
/**
* Creates the model.
*
* @return grid model
*/
- protected abstract PicrossGrid initModel();
+ protected abstract PicrossGrid initModel() throws PicrossException;
/*** Method overloaded from the class Mediator ***/
Modified: trunk/src/picross/game/random/RandomGameMediator.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMediator.java 2007-06-14 09:33:57 UTC (rev 38)
+++ trunk/src/picross/game/random/RandomGameMediator.java 2007-06-14 13:51:01 UTC (rev 39)
@@ -40,6 +40,7 @@
//import org.apache.log4j.Logger;
import picross.PicrossController;
+import picross.PicrossException;
import picross.PicrossGrid;
import picross.game.GameMediator;
@@ -56,6 +57,10 @@
/** The class' logger. */
//private static Logger log = Logger.getLogger(RandomGameMediator.class);
+ RandomGameMediator() throws PicrossException {
+ super();
+ }
+
/*** Methods overloaded from the class GameMediator ***/
/** {@inheritDoc} */
Added: trunk/src/picross/game/simple/SimpleGameMediator.java
===================================================================
--- trunk/src/picross/game/simple/SimpleGameMediator.java (rev 0)
+++ trunk/src/picross/game/simple/SimpleGameMediator.java 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,75 @@
+/*
+ * $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.simple;
+
+import java.io.IOException;
+
+import javax.swing.JPanel;
+
+import picross.Picross;
+import picross.PicrossException;
+import picross.PicrossGrid;
+
+import picross.game.GameMediator;
+
+/**
+ * @author Y. Norsa
+ */
+public final class SimpleGameMediator extends GameMediator {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ public SimpleGameMediator() throws PicrossException {
+ super();
+ }
+
+ /*** M\xE9thode ***/
+
+ protected PicrossGrid initModel() throws PicrossException {
+ try {
+ return new XBMModel(Picross.loadDataFile("halloween.xbm"));
+ } catch (IOException ioEx) {
+ throw new PicrossException(ioEx);
+ }
+ }
+}
+
Property changes on: trunk/src/picross/game/simple/SimpleGameMediator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/game/simple/XBMModel.java
===================================================================
--- trunk/src/picross/game/simple/XBMModel.java (rev 0)
+++ trunk/src/picross/game/simple/XBMModel.java 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,157 @@
+/*
+ * $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.simple;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import picross.AbstractPicrossModel;
+
+/**
+ * @author Y. Norsa
+ */
+final class XBMModel extends AbstractPicrossModel {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ private static Logger log = Logger.getLogger(XBMModel.class);
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ XBMModel(InputStream input) throws IOException {
+ super();
+
+ List<String> byteValues = new ArrayList<String>();
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(input));
+
+ String line = null;
+
+ try {
+ while ((line = in.readLine()) != null) {
+ if (line.contains("width")) {
+ this.width =
+ Integer.parseInt(line.substring(line
+ .lastIndexOf(' '))
+ .trim());
+ XBMModel.log.debug("width = " + this.width);
+ continue;
+ }
+
+ if (line.contains("height")) {
+ this.height =
+ Integer.parseInt(line.substring(line
+ .lastIndexOf(' '))
+ .trim());
+ XBMModel.log.debug("height = " + this.height);
+ continue;
+ }
+
+ if (line.contains("bits")) {
+ this.data = new boolean[this.width][this.height];
+
+ while ((line = in.readLine()) != null) {
+ String[] values = line.split(",");
+
+ for (int i = 0; i < values.length; i++) {
+ //XBMModel.log.debug("values[" + i + "] = "
+ //+ values[i]);
+
+ if (values[i].contains("0x")) {
+ String byteStr =
+ values[i].trim().substring(2, 4);
+ byteValues.add(byteStr);
+ }
+ }
+ }
+ }
+ }
+ } catch (IOException ioEx) {
+ throw ioEx;
+ } finally {
+ try {
+ in.close();
+ } catch (IOException ioEx) {
+ XBMModel.log.error(ioEx.getMessage());
+ }
+ }
+
+ int xIndex = 0;
+ int yIndex = 0;
+
+ for (String byteStr : byteValues) {
+ int byteVal = Integer.parseInt(byteStr, 16);
+ String binaryStr = Integer.toBinaryString(byteVal);
+
+ while (binaryStr.length() < 8) {
+ binaryStr = "0" + binaryStr;
+ }
+
+ //XBMModel.log.debug(binaryStr);
+
+ for (int j = 8 - 1; j >= 0; j--) {
+ //XBMModel.log.debug("this.data[" + yIndex
+ //+ "][" + xIndex + "] = "
+ //+ (binaryStr.charAt(j) == '1' ? true
+ //: false));
+
+ this.data[yIndex++][xIndex] =
+ (binaryStr.charAt(j) == '1' ? true : false);
+
+ if (yIndex == this.width) {
+ xIndex++;
+ yIndex = 0;
+ }
+
+ if (xIndex == this.height) {
+ xIndex = 0;
+ }
+ }
+ }
+ }
+}
+
Property changes on: trunk/src/picross/game/simple/XBMModel.java
___________________________________________________________________
Name: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2007-06-15 19:57:57
|
Revision: 40
http://picross.svn.sourceforge.net/picross/?rev=40&view=rev
Author: yvan_norsa
Date: 2007-06-15 12:57:57 -0700 (Fri, 15 Jun 2007)
Log Message:
-----------
javadoc generation, unit tests
Modified Paths:
--------------
trunk/bugsFilter.xml
trunk/build.xml
trunk/src/picross/Picross.java
trunk/src/picross/PicrossGrid.java
trunk/src/picross/app/MainMenuAppUI.java
trunk/src/picross/applet/MainMenuAppletUI.java
trunk/src/picross/game/GameMediator.java
trunk/src/picross/game/random/RandomGameMediator.java
trunk/src/picross/game/simple/SimpleGameMediator.java
trunk/src/picross/game/simple/XBMModel.java
trunk/src/picross/grid/Box.java
trunk/src/picross/grid/GridMediator.java
trunk/src/picross/grid/GridUI.java
trunk/src/picross/menus/MainMenuUI.java
Added Paths:
-----------
trunk/lib/junit.jar
trunk/src/picross/game/random/RandomPicrossModelTest.java
trunk/src/picross/game/simple/package.html
trunk/src/picross/tests/
trunk/src/picross/tests/AbstractPicrossGridTest.java
trunk/src/picross/tests/PicrossTest.java
trunk/src/picross/tests/package.html
Modified: trunk/bugsFilter.xml
===================================================================
--- trunk/bugsFilter.xml 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/bugsFilter.xml 2007-06-15 19:57:57 UTC (rev 40)
@@ -1,5 +1,5 @@
<FindBugsFilter>
<Match classregex=".*">
- <Bug pattern="DM_CONVERT_CASE,LSC_LITERAL_STRING_COMPARISON,CLI_CONSTANT_LIST_INDEX,S508C_SET_COMP_COLOR,S508C_NO_SETLABELFOR" />
+ <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>
</FindBugsFilter>
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/build.xml 2007-06-15 19:57:57 UTC (rev 40)
@@ -7,6 +7,8 @@
value="build" />
<property name="dist.dir"
value="dist" />
+ <property name="doc.dir"
+ value="doc" />
<property name="lib.dir"
value="lib" />
<property name="src.dir"
@@ -17,15 +19,18 @@
<property name="bundleHelper.jar"
value="${lib.dir}/bundleHelper.jar" />
+ <property name="junit.jar"
+ value="${lib.dir}/junit.jar" />
+ <property name="log4j.jar"
+ value="${lib.dir}/log4j.jar" />
<property name="mmvcs.jar"
value="${lib.dir}/mmvcs.jar" />
- <property name="log4j.jar"
- value="${lib.dir}/log4j.jar" />
<target name="-init"
depends="-setmode">
<mkdir dir="${build.dir}" />
<mkdir dir="${dist.dir}" />
+ <mkdir dir="${doc.dir}" />
</target>
<target name="release">
@@ -52,6 +57,7 @@
<pathelement location="${build.dir}" />
<pathelement location="${bundleHelper.jar}" />
+ <pathelement location="${junit.jar}" />
<pathelement location="${log4j.jar}" />
<pathelement location="${mmvcs.jar}" />
</path>
@@ -103,9 +109,32 @@
</java>
</target>
+ <target name="test"
+ depends="dist">
+ <junit haltonfailure="yes"
+ filtertrace="off"
+ showoutput="on"
+ printsummary="withOutAndErr">
+ <formatter type="plain"
+ usefile="false" />
+
+ <batchtest fork="yes"
+ filtertrace="on"
+ haltonfailure="yes">
+ <fileset dir="${src.dir}">
+ <include name="**/*Test.java" />
+ <exclude name="**/Abstract*Test.java" />
+ </fileset>
+ </batchtest>
+
+ <classpath refid="classpath" />
+ </junit>
+ </target>
+
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
+ <delete dir="${doc.dir}" />
<delete>
<fileset dir="."
@@ -117,6 +146,21 @@
<target name="rebuild"
depends="clean, dist" />
+ <target name="doc"
+ depends="compile">
+ <!-- FIXME test classes which are *not* in a "tests" subpackage
+ are included in the Javadoc -->
+ <javadoc destdir="${doc.dir}"
+ link="http://java.sun.com/j2se/1.5.0/docs/api">
+ <packageset dir="${src.dir}"
+ defaultexcludes="yes">
+ <exclude name="**/tests/**" />
+ </packageset>
+
+ <classpath refid="classpath" />
+ </javadoc>
+ </target>
+
<property file="checkstyle.properties" />
<target name="-check-checkstyle">
@@ -137,9 +181,9 @@
<formatter type="xml"
tofile="checkstyle.xml" />
- <!-- Pour tous les fichiers source sauf les tests -->
<fileset dir="${src.dir}"
- includes="**/*.java" />
+ includes="**/*.java"
+ excludes="**/tests/" />
</checkstyle>
<xslt in="checkstyle.xml"
Added: trunk/lib/junit.jar
===================================================================
(Binary files differ)
Property changes on: trunk/lib/junit.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:keywords
+ Id
Modified: trunk/src/picross/Picross.java
===================================================================
--- trunk/src/picross/Picross.java 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/src/picross/Picross.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -33,9 +33,12 @@
package picross;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
+
import java.util.Locale;
import javax.swing.ImageIcon;
@@ -53,6 +56,7 @@
/** Images directory. */
private static final String IMAGES_DIR = "/picross/images/";
+ /** Data directory. */
private static final String DATA_DIR = "/picross/data/";
/** Images directory corresponding to the default locale. */
@@ -72,13 +76,33 @@
/*** Static methods ***/
/**
+ * Loads a file.
+ *
+ * @param path file path
+ * @return URL of the file
+ * @throws FileNotFoundException if the file can't be found
+ */
+ private static URL getFile(String path) throws FileNotFoundException {
+ URL fileUrl = Picross.class.getResource(path);
+
+ if (fileUrl == null) {
+ throw new FileNotFoundException("\"" + path + "\" can't be found");
+ }
+
+ return fileUrl;
+ }
+
+ /**
* Loads an image.
*
* @param path path of the image
* @return the image
+ * @throws FileNotFoundException if the file can't be found
*/
- private static ImageIcon loadImage(String path) {
- return new ImageIcon(Picross.class.getResource(path));
+ private static ImageIcon loadImage(String path)
+ throws FileNotFoundException {
+
+ return new ImageIcon(Picross.getFile(path));
}
/**
@@ -86,8 +110,17 @@
*
* @param name image filename
* @return the image
+ * @throws IllegalArgumentException if <code>name</code>
+ * is <code>null</code> or empty
+ * @throws FileNotFoundException if the file can't be found
*/
- public static ImageIcon getImage(String name) {
+ public static ImageIcon getImage(String name)
+ throws IllegalArgumentException, FileNotFoundException {
+
+ if (name == null || name.equals("")) {
+ throw new IllegalArgumentException("name can't be null or empty");
+ }
+
return Picross.loadImage(Picross.IMAGES_DIR + name);
}
@@ -96,15 +129,37 @@
*
* @param name image filename
* @return the image
+ * @throws IllegalArgumentException if <code>name</code>
+ * is <code>null</code> or empty
+ * @throws FileNotFoundException if the file can't be found
*/
- public static ImageIcon getLocalizedImage(String name) {
+ public static ImageIcon getLocalizedImage(String name)
+ throws IllegalArgumentException, FileNotFoundException {
+
+ if (name == null || name.equals("")) {
+ throw new IllegalArgumentException("name can't be null or empty");
+ }
+
return Picross.loadImage(Picross.LOCAL_IMAGES_PATH + name);
}
+ /**
+ * Loads a data file.
+ *
+ * @param name filename
+ * @return a stream containing the loaded file
+ * @throws IllegalArgumentException if <code>name</code>
+ * is <code>null</code> or empty
+ * @throws IOException if there is a problem while opening the file
+ */
public static InputStream loadDataFile(String name)
- throws IOException {
+ throws IllegalArgumentException, IOException {
- return Picross.class.getResource(Picross.DATA_DIR + name).openStream();
+ if (name == null || name.equals("")) {
+ throw new IllegalArgumentException("name can't be null or empty");
+ }
+
+ return Picross.getFile(Picross.DATA_DIR + name).openStream();
}
}
Modified: trunk/src/picross/PicrossGrid.java
===================================================================
--- trunk/src/picross/PicrossGrid.java 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/src/picross/PicrossGrid.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -42,21 +42,21 @@
/**
* Returns the width.
*
- * @return grid width
+ * @return grid width (always > 0)
*/
int getWidth();
/**
* Returns the height.
*
- * @return grid height
+ * @return grid height (always > 0)
*/
int getHeight();
/**
* Returns the content.
*
- * @return grid content
+ * @return grid content (of size width * height)
*/
boolean[][] getData();
}
Modified: trunk/src/picross/app/MainMenuAppUI.java
===================================================================
--- trunk/src/picross/app/MainMenuAppUI.java 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/src/picross/app/MainMenuAppUI.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -35,6 +35,8 @@
import java.awt.event.ActionListener;
+import java.io.FileNotFoundException;
+
import javax.swing.ImageIcon;
import javax.swing.JButton;
@@ -75,8 +77,11 @@
* Constructor.
*
* @param controller controller for the buttons
+ * @throws FileNotFoundException if a button image can't be found
*/
- public MainMenuAppUI(ActionListener controller) {
+ public MainMenuAppUI(ActionListener controller)
+ throws FileNotFoundException {
+
super(controller);
ImageIcon exitIcon =
Modified: trunk/src/picross/applet/MainMenuAppletUI.java
===================================================================
--- trunk/src/picross/applet/MainMenuAppletUI.java 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/src/picross/applet/MainMenuAppletUI.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -37,6 +37,8 @@
import java.awt.event.ActionListener;
+import java.io.FileNotFoundException;
+
import picross.menus.MainMenuUI;
/**
@@ -62,8 +64,11 @@
* Constructor.
*
* @param controller controller for the buttons
+ * @throws FileNotFoundException if a button image can't be found
*/
- public MainMenuAppletUI(ActionListener controller) {
+ public MainMenuAppletUI(ActionListener controller)
+ throws FileNotFoundException {
+
super(controller);
this.setBackground(Color.WHITE);
Modified: trunk/src/picross/game/GameMediator.java
===================================================================
--- trunk/src/picross/game/GameMediator.java 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/src/picross/game/GameMediator.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -63,7 +63,12 @@
/*** Constructor ***/
- /** Constructor. */
+ /**
+ * Constructor.
+ *
+ * @throws PicrossException if there is a problem loading the grid model
+ * or building the view
+ */
public GameMediator() throws PicrossException {
PicrossGrid model = this.initModel();
@@ -95,6 +100,7 @@
* Creates the model.
*
* @return grid model
+ * @throws PicrossException if there is a problem
*/
protected abstract PicrossGrid initModel() throws PicrossException;
Modified: trunk/src/picross/game/random/RandomGameMediator.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMediator.java 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/src/picross/game/random/RandomGameMediator.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -57,6 +57,14 @@
/** 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
+ */
RandomGameMediator() throws PicrossException {
super();
}
Added: trunk/src/picross/game/random/RandomPicrossModelTest.java
===================================================================
--- trunk/src/picross/game/random/RandomPicrossModelTest.java (rev 0)
+++ trunk/src/picross/game/random/RandomPicrossModelTest.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -0,0 +1,59 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.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();
+ }
+}
Property changes on: trunk/src/picross/game/random/RandomPicrossModelTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/game/simple/SimpleGameMediator.java
===================================================================
--- trunk/src/picross/game/simple/SimpleGameMediator.java 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/src/picross/game/simple/SimpleGameMediator.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -35,8 +35,6 @@
import java.io.IOException;
-import javax.swing.JPanel;
-
import picross.Picross;
import picross.PicrossException;
import picross.PicrossGrid;
@@ -44,26 +42,26 @@
import picross.game.GameMediator;
/**
+ * Mediator for a classic game.
+ *
* @author Y. Norsa
*/
public final class SimpleGameMediator extends GameMediator {
- /*** Constante ***/
+ /*** Constructor ***/
- /*** Champ statique ***/
-
- /*** Champ ***/
-
- /*** Constructeur ***/
-
/**
- * Constructeur.
+ * Constructor.
+ *
+ * @throws PicrossException if there is a problem loading the grid model
+ * or building the view
*/
public SimpleGameMediator() throws PicrossException {
super();
}
- /*** M\xE9thode ***/
+ /*** Method overloaded from the class GameMediator ***/
+ /** {@inheritDoc} */
protected PicrossGrid initModel() throws PicrossException {
try {
return new XBMModel(Picross.loadDataFile("halloween.xbm"));
Modified: trunk/src/picross/game/simple/XBMModel.java
===================================================================
--- trunk/src/picross/game/simple/XBMModel.java 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/src/picross/game/simple/XBMModel.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -34,9 +34,9 @@
package picross.game.simple;
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -46,21 +46,23 @@
import picross.AbstractPicrossModel;
/**
+ * Class loading a XBM file.
+ *
* @author Y. Norsa
*/
final class XBMModel extends AbstractPicrossModel {
- /*** Constante ***/
+ /*** Static field ***/
- /*** Champ statique ***/
-
+ /** The class' logger. */
private static Logger log = Logger.getLogger(XBMModel.class);
- /*** Champ ***/
+ /*** Constructor ***/
- /*** Constructeur ***/
-
/**
- * Constructeur.
+ * Constructor.
+ *
+ * @param input XBM file input stream
+ * @throws IOException if there is a problem while reading the file
*/
XBMModel(InputStream input) throws IOException {
super();
@@ -130,7 +132,7 @@
while (binaryStr.length() < 8) {
binaryStr = "0" + binaryStr;
}
-
+
//XBMModel.log.debug(binaryStr);
for (int j = 8 - 1; j >= 0; j--) {
Added: trunk/src/picross/game/simple/package.html
===================================================================
--- trunk/src/picross/game/simple/package.html (rev 0)
+++ trunk/src/picross/game/simple/package.html 2007-06-15 19:57:57 UTC (rev 40)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <!--
+ $Id$
+ -->
+ </head>
+
+ <body bgcolor="white">
+ Simple game mode.
+ </body>
+</html>
Property changes on: trunk/src/picross/game/simple/package.html
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/grid/Box.java
===================================================================
--- trunk/src/picross/grid/Box.java 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/src/picross/grid/Box.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -35,6 +35,8 @@
import java.awt.Rectangle;
+import java.io.FileNotFoundException;
+
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
@@ -113,17 +115,21 @@
*/
Box.images = new HashMap<Box.BoxState, ImageIcon[]>(7);
- for (Box.BoxState state : Box.BoxState.values()) {
- ImageIcon[] img = new ImageIcon[2];
+ try {
+ for (Box.BoxState state : Box.BoxState.values()) {
+ ImageIcon[] img = new ImageIcon[2];
- String stateImageName = state.toString().toLowerCase();
- img[Box.ICON_INDEX] = Picross.getImage(stateImageName
+ String stateImageName = state.toString().toLowerCase();
+ img[Box.ICON_INDEX] = Picross.getImage(stateImageName
+ Box.IMAGES_EXT);
- img[Box.ROLLOVER_ICON_INDEX] =
- Picross.getImage(stateImageName + Box.ROLLOVER_NAME
- + Box.IMAGES_EXT);
+ img[Box.ROLLOVER_ICON_INDEX] =
+ Picross.getImage(stateImageName + Box.ROLLOVER_NAME
+ + Box.IMAGES_EXT);
- Box.images.put(state, img);
+ Box.images.put(state, img);
+ }
+ } catch (FileNotFoundException fileEx) {
+ throw new ExceptionInInitializerError(fileEx);
}
}
Modified: trunk/src/picross/grid/GridMediator.java
===================================================================
--- trunk/src/picross/grid/GridMediator.java 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/src/picross/grid/GridMediator.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -36,10 +36,14 @@
import fr.cle.mmvcs.Mediateur;
import fr.cle.mmvcs.SimpleEvent;
+import java.io.FileNotFoundException;
+
import javax.swing.JPanel;
//import org.apache.log4j.Logger;
+import picross.PicrossException;
+
/**
* Picross grid mediator.
*
@@ -67,20 +71,27 @@
* @param width grid width
* @param height grid height
* @param data grid content
+ * @throws PicrossException if there is a probleme while building the view
*/
- public GridMediator(int width, int height, boolean[][] data) {
+ public GridMediator(int width, int height, boolean[][] data)
+ throws PicrossException {
+
this.model = new GridModel(this, data);
GridController controller = new GridController();
controller.addSimpleListener(this);
this.addSimpleListener(controller);
- this.view = new GridUI(width, height,
- this.model.getBoxes(),
- this.model.getColData(),
- this.model.getRowData(),
- this.model.getCompletedHints(),
- controller);
+ try {
+ this.view = new GridUI(width, height,
+ this.model.getBoxes(),
+ this.model.getColData(),
+ this.model.getRowData(),
+ this.model.getCompletedHints(),
+ controller);
+ } catch (FileNotFoundException fileEx) {
+ throw new PicrossException(fileEx);
+ }
controller.setView(this.view);
}
Modified: trunk/src/picross/grid/GridUI.java
===================================================================
--- trunk/src/picross/grid/GridUI.java 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/src/picross/grid/GridUI.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -48,6 +48,8 @@
import java.awt.image.BufferedImage;
+import java.io.FileNotFoundException;
+
import java.util.ArrayList;
import java.util.List;
@@ -212,13 +214,14 @@
* @param rowData rows hints
* @param completedHints list of completed hints
* @param controller controller for the grid
+ * @throws FileNotFoundException if an image is missing
*/
GridUI(int width, int height,
Box[][] boxes,
int[][] colData,
int[][] rowData,
CompletedHints completedHints,
- GridController controller) {
+ GridController controller) throws FileNotFoundException {
super(true);
this.controller = controller;
Modified: trunk/src/picross/menus/MainMenuUI.java
===================================================================
--- trunk/src/picross/menus/MainMenuUI.java 2007-06-14 13:51:01 UTC (rev 39)
+++ trunk/src/picross/menus/MainMenuUI.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -39,6 +39,8 @@
import java.awt.event.ActionListener;
+import java.io.FileNotFoundException;
+
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
@@ -74,8 +76,9 @@
* Constructor.
*
* @param controller controller for the buttons
+ * @throws FileNotFoundException if a button image can't be found
*/
- public MainMenuUI(ActionListener controller) {
+ public MainMenuUI(ActionListener controller) throws FileNotFoundException {
ImageIcon icon = Picross.getImage(MainMenuUI.BACKGROUND_IMAGE);
this.setPreferredSize(new Dimension(icon.getIconWidth(),
icon.getIconHeight()));
@@ -90,7 +93,8 @@
playButton.addActionListener(controller);
playButton.setBorder(null);
playButton.setBounds(this.getPlayButtonX(), this.getPlayButtonY(),
- playIcon.getIconWidth(), playIcon.getIconHeight());
+ playIcon.getIconWidth(),
+ playIcon.getIconHeight());
this.add(playButton);
}
Added: trunk/src/picross/tests/AbstractPicrossGridTest.java
===================================================================
--- trunk/src/picross/tests/AbstractPicrossGridTest.java (rev 0)
+++ trunk/src/picross/tests/AbstractPicrossGridTest.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -0,0 +1,101 @@
+/*
+ * $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.tests;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import picross.PicrossGrid;
+
+/**
+ * Abstract test class for the PicrossGrid interface.
+ *
+ * @author Y. Norsa
+ */
+public abstract class AbstractPicrossGridTest {
+ /*** Field ***/
+
+ /** The instance to test. */
+ private PicrossGrid picrossGrid = null;
+
+ /*** Abstract method ***/
+
+ /**
+ * Returns an instance.
+ *
+ * @return instance to test
+ */
+ protected abstract PicrossGrid getPicrossGrid();
+
+ /*** Methods ***/
+
+ /** Performs the instance initialisation. */
+ @Before
+ public void setUp() {
+ this.picrossGrid = this.getPicrossGrid();
+ }
+
+ /** Tests the method getWidth(). */
+ @Test
+ public void testGetWidth() {
+ int width = this.picrossGrid.getWidth();
+ Assert.assertTrue("width = " + width, (width > 0));
+ }
+
+ /** Tests the method getHeight(). */
+ @Test
+ public void testGetHeight() {
+ int height = this.picrossGrid.getHeight();
+ Assert.assertTrue("height = " + height, (height > 0));
+ }
+
+ /** Tests the method getData(). */
+ @Test
+ public void testGetData() {
+ boolean[][] data = this.picrossGrid.getData();
+ Assert.assertNotNull("data = null", data);
+
+ int width = this.picrossGrid.getWidth();
+ int height = this.picrossGrid.getHeight();
+
+ Assert.assertEquals("data.length = " + data.length,
+ width, data.length);
+
+ for (int i = 0; i < width; i++) {
+ Assert.assertEquals("data[" + i + "].length = " + data[i].length,
+ height, data[i].length);
+ }
+ }
+}
Property changes on: trunk/src/picross/tests/AbstractPicrossGridTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/tests/PicrossTest.java
===================================================================
--- trunk/src/picross/tests/PicrossTest.java (rev 0)
+++ trunk/src/picross/tests/PicrossTest.java 2007-06-15 19:57:57 UTC (rev 40)
@@ -0,0 +1,152 @@
+/*
+ * $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...
[truncated message content] |
|
From: <yva...@us...> - 2007-06-29 07:02:43
|
Revision: 42
http://picross.svn.sourceforge.net/picross/?rev=42&view=rev
Author: yvan_norsa
Date: 2007-06-29 00:02:39 -0700 (Fri, 29 Jun 2007)
Log Message:
-----------
unit tests
Modified Paths:
--------------
trunk/build.xml
trunk/src/picross/game/random/RandomPicrossModel.java
trunk/src/picross/grid/Box.java
trunk/src/picross/grid/CompletedHints.java
trunk/src/picross/grid/FillCommand.java
trunk/src/picross/grid/GridController.java
trunk/src/picross/grid/GridMediator.java
trunk/src/picross/grid/GridModel.java
trunk/src/picross/grid/PaintCommand.java
Added Paths:
-----------
trunk/src/picross/grid/BoxTest.java
trunk/src/picross/grid/CompletedHintsTest.java
trunk/src/picross/grid/FillCommandTest.java
trunk/src/picross/grid/GridAction.java
trunk/src/picross/grid/GridModelTest.java
trunk/src/picross/grid/IGridMediator.java
trunk/src/picross/grid/PaintCommandTest.java
trunk/src/picross/grid/tests/
trunk/src/picross/grid/tests/IGridMediatorStub.java
Removed Paths:
-------------
trunk/src/picross/grid/CompletedCommand.java
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/build.xml 2007-06-29 07:02:39 UTC (rev 42)
@@ -149,10 +149,10 @@
<target name="doc"
depends="compile">
<!-- FIXME test classes which are not in a "tests" subpackage
- shouldn't be included in the generated Javadoc -->
- <javadoc destdir="${doc.dir}"
- link="http://java.sun.com/j2se/1.5.0/docs/api">
- <packageset dir="${src.dir}"
+ shouldn't be included in the generated Javadoc -->
+ <javadoc destdir="${doc.dir}" access="private"
+ link="http://java.sun.com/j2se/1.5.0/docs/api">
+ <packageset dir="${src.dir}"
defaultexcludes="yes">
<exclude name="**/tests/**" />
</packageset>
Modified: trunk/src/picross/game/random/RandomPicrossModel.java
===================================================================
--- trunk/src/picross/game/random/RandomPicrossModel.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/game/random/RandomPicrossModel.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -69,9 +69,17 @@
this.data = new boolean[this.width][this.height];
- for (int i = 0; i < this.width; i++) {
- for (int j = 0; j < this.height; j++) {
- this.data[i][j] = rand.nextBoolean();
+ boolean gridOK = false;
+
+ while (!gridOK) {
+ for (int i = 0; i < this.width; i++) {
+ for (int j = 0; j < this.height; j++) {
+ this.data[i][j] = rand.nextBoolean();
+
+ if (this.data[i][j]) {
+ gridOK = true;
+ }
+ }
}
}
}
Modified: trunk/src/picross/grid/Box.java
===================================================================
--- trunk/src/picross/grid/Box.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/grid/Box.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -233,8 +233,14 @@
* Permits to define the rectangle occupied by the box.
*
* @param rect rectangle of the box
+ * @throws IllegalArgumentException if <code>rect</code>
+ * is <code>null</code>
*/
- void setRect(Rectangle rect) {
+ void setRect(Rectangle rect) throws IllegalArgumentException {
+ if (rect == null) {
+ throw new IllegalArgumentException("rect cannot be null");
+ }
+
this.rect = rect;
}
Added: trunk/src/picross/grid/BoxTest.java
===================================================================
--- trunk/src/picross/grid/BoxTest.java (rev 0)
+++ trunk/src/picross/grid/BoxTest.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -0,0 +1,156 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.grid;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Y. Norsa
+ */
+public class BoxTest {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private Box box = null;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ BoxTest() {
+ }
+ */
+ /*** M\xE9thode ***/
+
+ @Before
+ public void setUp() {
+ this.box = new Box();
+ }
+
+ @Test
+ public void testCheck() {
+ this.box.check();
+ Assert.assertTrue("box unchecked", this.box.isChecked());
+ }
+
+ @Test
+ public void testCross() {
+ this.box.cross();
+ Assert.assertTrue("box not crossed", this.box.isCrossed());
+ }
+
+ @Test
+ public void testEmpty() {
+ this.box.empty();
+ Assert.assertTrue("box not empty", this.box.isEmpty());
+ }
+
+ @Test
+ public void testEquals() {
+ Assert.assertFalse("this.box = null", this.box.equals(null));
+ Assert.assertTrue("box != box", this.box.equals(this.box));
+
+ this.box.check();
+
+ Box box2 = new Box();
+ Assert.assertFalse("box = box2", this.box.equals(box2));
+
+ box2.check();
+
+ Assert.assertTrue("box != box2", this.box.equals(box2));
+ }
+
+ @Test
+ public void testgetIcon() {
+ Assert.assertNotNull("empty icon = null", this.box.getIcon());
+
+ this.box.check();
+ Assert.assertNotNull("checked icon = null", this.box.getIcon());
+
+ this.box.cross();
+ Assert.assertNotNull("crossed icon = null", this.box.getIcon());
+ }
+
+ @Test
+ public void testGetRolloverIcon() {
+ Assert.assertNotNull("rollover empty icon = null",
+ this.box.getRolloverIcon());
+
+ this.box.check();
+ Assert.assertNotNull("rollover checked icon = null",
+ this.box.getRolloverIcon());
+
+ this.box.cross();
+ Assert.assertNotNull("rollover crossed icon = null",
+ this.box.getRolloverIcon());
+ }
+
+ @Test
+ public void testIsChecked() {
+ this.box.check();
+
+ Assert.assertFalse("box crossed AND checked", this.box.isCrossed());
+ Assert.assertFalse("box empty AND checked", this.box.isEmpty());
+ }
+
+ @Test
+ public void testIsCrossed() {
+ this.box.cross();
+
+ Assert.assertFalse("box checked AND crossed", this.box.isChecked());
+ Assert.assertFalse("box empty AND crossed", this.box.isEmpty());
+ }
+
+ @Test
+ public void testIsEmpty() {
+ Assert.assertFalse("box checked AND empty", this.box.isChecked());
+ Assert.assertFalse("box crossed AND empty", this.box.isCrossed());
+ }
+
+ @Test
+ public void testSetRect() {
+ try {
+ this.box.setRect(null);
+ Assert.fail("box.setRect(null)");
+ } catch (IllegalArgumentException argEx) { }
+ }
+}
+
Property changes on: trunk/src/picross/grid/BoxTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted: trunk/src/picross/grid/CompletedCommand.java
===================================================================
--- trunk/src/picross/grid/CompletedCommand.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/grid/CompletedCommand.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -1,107 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (c) 2007
- *
- * This software is governed by the CeCILL license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * As a counterpart to the access to the source code and rights to copy,
- * modify and redistribute granted by the license, users are provided only
- * with a limited warranty and the software's author, the holder of the
- * economic rights, and the successive licensors have only limited
- * liability.
- *
- * In this respect, the user's attention is drawn to the risks associated
- * with loading, using, modifying and/or developing or reproducing the
- * software by the user in light of its specific status of free software,
- * that may mean that it is complicated to manipulate, and that also
- * therefore means that it is reserved for developers and experienced
- * professionals having in-depth computer knowledge. Users are therefore
- * encouraged to load and test the software's suitability as regards their
- * requirements in conditions enabling the security of their systems and/or
- * data to be ensured and, more generally, to use and operate it in the
- * same conditions as regards security.
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL license and that you accept its terms.
- */
-
-
-package picross.grid;
-
-import fr.cle.mmvcs.Command;
-
-/**
- * Command indicating that a hint has been completed.
- *
- * @author Y. Norsa
- */
-final class CompletedCommand extends Command {
- /*** Constants ***/
-
- /** A column hint has been completed. */
- static final int COLUMN = 0;
-
- /** A row hint has been completed. */
- static final int ROW = 1;
-
- /*** Fields ***/
-
- /** Type of hint that has been completed. */
- private int type;
-
- /** Number of the column or row. */
- private int position;
-
- /** Position of the hint in the column or row. */
- private int hintPos;
-
- /*** Constructor ***/
-
- /**
- * Constructor.
- *
- * @param type type of hint that has been completed
- * @param position number of the column or row
- * @param hintPos position of the hint in the column or row
- */
- CompletedCommand(int type, int position, int hintPos) {
- this.type = type;
- this.position = position;
- this.hintPos = hintPos;
- }
-
- /*** Accessors ***/
-
- /**
- * Returns the type of hint that has been completed.
- *
- * @return type of hint that has been completed
- */
- int getType() {
- return this.type;
- }
-
- /**
- * Returns the number of the column or row.
- *
- * @return number of the column or row
- */
- int getPosition() {
- return this.position;
- }
-
- /**
- * Returns the position of the hint in the column or row.
- *
- * @return position of the hint in the column or row
- */
- int getHintPos() {
- return this.hintPos;
- }
-}
-
Modified: trunk/src/picross/grid/CompletedHints.java
===================================================================
--- trunk/src/picross/grid/CompletedHints.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/grid/CompletedHints.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -59,9 +59,32 @@
* @param colsHintsHeight height of the column hints list
* @param rowsHintsWidth width of the row hints list
* @param rowsHintsHeight height of the row hints list
+ * @throws IllegalArgumentException if one of the parameters is <= 0
*/
CompletedHints(int colsHintsWidth, int colsHintsHeight,
- int rowsHintsWidth, int rowsHintsHeight) {
+ int rowsHintsWidth, int rowsHintsHeight)
+ throws IllegalArgumentException {
+
+ if (colsHintsWidth <= 0) {
+ throw new IllegalArgumentException("colsHintsWidth must be "
+ + "greater than 0");
+ }
+
+ if (colsHintsHeight <= 0) {
+ throw new IllegalArgumentException("colsHintsHeight must be "
+ + "greater than 0");
+ }
+
+ if (rowsHintsWidth <= 0) {
+ throw new IllegalArgumentException("rowsHintsWidth must be "
+ + "greater than 0");
+ }
+
+ if (rowsHintsHeight <= 0) {
+ throw new IllegalArgumentException("rowsHintsHeight must be "
+ + "greater than 0");
+ }
+
this.completedCols = new boolean[colsHintsWidth][colsHintsHeight];
this.completedRows = new boolean[rowsHintsWidth][rowsHintsHeight];
}
@@ -84,8 +107,19 @@
*
* @param column column number
* @return list of completed hints in the column
+ * @throws IllegalArgumentException if <code>column</code> is lesser
+ * than 0 or greater than the number of hints columns
*/
- List<Integer> getCompleteColHints(int column) {
+ List<Integer> getCompleteColHints(int column)
+ throws IllegalArgumentException {
+
+ if (column < 0 || column >= this.completedCols.length) {
+ throw new IllegalArgumentException("column must be between 0 "
+ + "and "
+ + (this.completedCols.length
+ - 1));
+ }
+
List<Integer> res = new ArrayList<Integer>();
for (int i = 0; i < this.completedCols[column].length; i++) {
@@ -133,8 +167,18 @@
*
* @param row row number
* @return list of completed hints in the row
+ * @throws IllegalArgumentException if <code>row</code> is lesser
+ * than 0 or greater than the number of hints row
*/
- List<Integer> getCompleteRowHints(int row) {
+ List<Integer> getCompleteRowHints(int row)
+ throws IllegalArgumentException {
+
+ if (row < 0 || row >= this.completedRows.length) {
+ throw new IllegalArgumentException("row must be between 0 and "
+ + (this.completedRows.length
+ - 1));
+ }
+
List<Integer> res = new ArrayList<Integer>();
for (int i = 0; i < this.completedRows[row].length; i++) {
Added: trunk/src/picross/grid/CompletedHintsTest.java
===================================================================
--- trunk/src/picross/grid/CompletedHintsTest.java (rev 0)
+++ trunk/src/picross/grid/CompletedHintsTest.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -0,0 +1,205 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.grid;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Y. Norsa
+ */
+public class CompletedHintsTest {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ CompletedHints hints = null;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ CompletedHintsTest() {
+ }
+ */
+ /*** M\xE9thode ***/
+
+ @Before
+ public void setUp() {
+ this.hints = new CompletedHints(10, 10, 10, 10);
+ }
+
+ @Test
+ public void testCompletedHints() {
+ try {
+ new CompletedHints(-1, -1, -1, -1);
+ Assert.fail("colsHintsWidth = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(0, -1, -1, -1);
+ Assert.fail("colsHintsWidth = 0");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(1, -1, -1, -1);
+ Assert.fail("colsHintsHeight = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(1, 0, -1, -1);
+ Assert.fail("colsHintsHeight = 0");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(1, 1, -1, -1);
+ Assert.fail("rowsHintsWidth = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(1, 1, 0, -1);
+ Assert.fail("rowsHintsWidth = 0");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(1, 1, 1, -1);
+ Assert.fail("rowsHintsHeight = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new CompletedHints(1, 1, 1, 0);
+ Assert.fail("rowsHintsHeight = 0");
+ } catch (IllegalArgumentException argEx) { }
+ }
+
+ @Test
+ public void testClearColHint() {
+ this.hints.setCompleteColHint(3, 4);
+ this.hints.clearColHint(3, 4);
+ Assert.assertFalse(this.hints.isColHintComplete(3, 4));
+ }
+
+ @Test
+ public void testClearRowHint() {
+ this.hints.setCompleteRowHint(8, 2);
+ this.hints.clearRowHint(8, 2);
+ Assert.assertFalse(this.hints.isRowHintComplete(8, 2));
+ }
+
+ @Test
+ public void testGetCompleteColHints() {
+ try {
+ this.hints.getCompleteColHints(-1);
+ Assert.fail("column = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ this.hints.getCompleteColHints(42);
+ Assert.fail("column = 42");
+ } catch (IllegalArgumentException argEx) { }
+
+ List<Integer> complete = this.hints.getCompleteColHints(4);
+ Assert.assertNotNull("complete = null", complete);
+ int size = complete.size();
+ Assert.assertTrue("size = " + size, (size == 0));
+
+ this.hints.setCompleteColHint(4, 0);
+ this.hints.setCompleteColHint(4, 9);
+
+ complete = this.hints.getCompleteColHints(4);
+ Assert.assertNotNull("complete = null", complete);
+ size = complete.size();
+ Assert.assertTrue("size = " + size, (size == 2));
+
+ int nb1 = complete.get(0);
+ Assert.assertTrue("nb1 = " + nb1, (nb1 == 0));
+
+ int nb2 = complete.get(1);
+ Assert.assertTrue("nb2 = " + nb2, (nb2 == 9));
+ }
+
+ @Test
+ public void testGetCompleteRowHints() {
+ try {
+ this.hints.getCompleteRowHints(-1);
+ Assert.fail("row = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ this.hints.getCompleteRowHints(42);
+ Assert.fail("row = 42");
+ } catch (IllegalArgumentException argEx) { }
+
+ List<Integer> complete = this.hints.getCompleteRowHints(9);
+ Assert.assertNotNull("complete = null", complete);
+ int size = complete.size();
+ Assert.assertTrue("size = " + size, (size == 0));
+
+ this.hints.setCompleteRowHint(9, 3);
+ this.hints.setCompleteRowHint(9, 6);
+
+ complete = this.hints.getCompleteRowHints(9);
+ Assert.assertNotNull("complete = null", complete);
+ size = complete.size();
+ Assert.assertTrue("size = " + size, (size == 2));
+
+ int nb1 = complete.get(0);
+ Assert.assertTrue("nb1 = " + nb1, (nb1 == 3));
+
+ int nb2 = complete.get(1);
+ Assert.assertTrue("nb2 = " + nb2, (nb2 == 6));
+ }
+
+ @Test
+ public void testIsColHintCompleteAndSetCompleteColHint() {
+ Assert.assertFalse(this.hints.isColHintComplete(0, 0));
+ this.hints.setCompleteColHint(0, 0);
+ Assert.assertTrue(this.hints.isColHintComplete(0, 0));
+ }
+
+ @Test
+ public void testIsRowHintCompleteAndSetCompleteRowHint() {
+ Assert.assertFalse(this.hints.isRowHintComplete(5, 5));
+ this.hints.setCompleteRowHint(5, 5);
+ Assert.assertTrue(this.hints.isRowHintComplete(5, 5));
+ }
+}
+
Property changes on: trunk/src/picross/grid/CompletedHintsTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/grid/FillCommand.java
===================================================================
--- trunk/src/picross/grid/FillCommand.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/grid/FillCommand.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -50,7 +50,8 @@
private int column;
/** Type of the action. */
- private int type;
+ //private int type;
+ private GridAction type;
/*** Constructor ***/
@@ -60,8 +61,26 @@
* @param row row of the box to fill
* @param column column of the box to fill
* @param type type of the action
+ * @throws IllegalArgumentException if <code>row</code>
+ * or <code>column</code> is less than 0, or <code>type</code>
+ * is <code>GridAction.UNKNOWN</code>
*/
- FillCommand(int row, int column, int type) {
+ //FillCommand(int row, int column, int type) {
+ FillCommand(int row, int column, GridAction type)
+ throws IllegalArgumentException {
+
+ if (row < 0) {
+ throw new IllegalArgumentException("row can't be less than 0");
+ }
+
+ if (column < 0) {
+ throw new IllegalArgumentException("column can't be less than 0");
+ }
+
+ if (type == GridAction.UNKNOWN) {
+ throw new IllegalArgumentException("type can't be UNKNOWN");
+ }
+
this.row = row;
this.column = column;
this.type = type;
@@ -99,7 +118,8 @@
*
* @return type of the action
*/
- int getType() {
+ //int getType() {
+ GridAction getType() {
return this.type;
}
}
Added: trunk/src/picross/grid/FillCommandTest.java
===================================================================
--- trunk/src/picross/grid/FillCommandTest.java (rev 0)
+++ trunk/src/picross/grid/FillCommandTest.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -0,0 +1,80 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.grid;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author Y. Norsa
+ */
+public class FillCommandTest {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ FillCommandTest() {
+ }
+ */
+ /*** M\xE9thode ***/
+
+ @Test
+ public void testFillCommand() {
+ try {
+ new FillCommand(-1, -1, GridAction.UNKNOWN);
+ Assert.fail("row = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new FillCommand(0, -1, GridAction.UNKNOWN);
+ Assert.fail("column = -1");
+ } catch (IllegalArgumentException argEx) { }
+
+ try {
+ new FillCommand(0, 0, GridAction.UNKNOWN);
+ Assert.fail("UNKNOWN type");
+ } catch (IllegalArgumentException argEx) { }
+
+ new FillCommand(0, 0, GridAction.CHECK);
+ }
+}
+
Property changes on: trunk/src/picross/grid/FillCommandTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/grid/GridAction.java
===================================================================
--- trunk/src/picross/grid/GridAction.java (rev 0)
+++ trunk/src/picross/grid/GridAction.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -0,0 +1,59 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.grid;
+
+/**
+ * @author Y. Norsa
+ */
+enum GridAction {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ */
+
+ /*** M\xE9thode ***/
+ UNKNOWN,
+ CHECK,
+ CROSS
+}
+
Property changes on: trunk/src/picross/grid/GridAction.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/grid/GridController.java
===================================================================
--- trunk/src/picross/grid/GridController.java 2007-06-17 18:55:46 UTC (rev 41)
+++ trunk/src/picross/grid/GridController.java 2007-06-29 07:02:39 UTC (rev 42)
@@ -76,10 +76,10 @@
static final String REPAINT_LEFT_HINTS_CMD = "REPAINT_LEFT_HINTS_CMD";
/** Checking a box. */
- static final int CHECK_ACTION = 0;
+ //static final int CHECK_ACTION = 0;
/** Crossing a box. */
- static final int CROSS_ACTION = 1;
+ //static final int CROSS_ACTION = 1;
/*** Static field ***/
@@ -193,7 +193,8 @@
if (this.view.isInGrid(point)) {
int row = this.view.getRow(point);
int column = this.view.getColumn(point);
- ...
[truncated message content] |
|
From: <yva...@us...> - 2008-04-17 09:11:23
|
Revision: 48
http://picross.svn.sourceforge.net/picross/?rev=48&view=rev
Author: yvan_norsa
Date: 2008-04-17 02:11:28 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
game menu
Modified Paths:
--------------
trunk/src/picross/PicrossController.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/app/MainMenuAppUI.java
trunk/src/picross/game/random/RandomGameMediator.java
trunk/src/picross/menus/MainMenuUI.java
Added Paths:
-----------
trunk/images/en/button-random.png
trunk/images/fr/button-random.png
trunk/src/picross/menus/GameMenuController.java
trunk/src/picross/menus/GameMenuMediator.java
trunk/src/picross/menus/GameMenuUI.java
trunk/src/picross/menus/MenuUI.java
Added: trunk/images/en/button-random.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/en/button-random.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/images/fr/button-random.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/fr/button-random.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/picross/PicrossController.java
===================================================================
--- trunk/src/picross/PicrossController.java 2008-04-17 08:50:24 UTC (rev 47)
+++ trunk/src/picross/PicrossController.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -44,11 +44,14 @@
* @author Y. Norsa
*/
public final class PicrossController extends Controller {
- /*** Constant ***/
+ /*** Constants ***/
/** Play command. */
public static final String PLAY_CMD = "PLAY_CMD";
+ /** Random game command. */
+ public static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD";
+
/*** Static field ***/
/** The class's logger. */
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2008-04-17 08:50:24 UTC (rev 47)
+++ trunk/src/picross/PicrossMediator.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -46,6 +46,8 @@
import picross.grid.GridController;
+import picross.menus.GameMenuMediator;
+
import picross.menus.MainMenuController;
import picross.menus.MainMenuMediator;
@@ -105,32 +107,14 @@
String cmd = e.getCommandName();
if (cmd.equals(PicrossController.PLAY_CMD)) {
- //this.view.setContent(grid.getView());
+ //this.startGame();
+ this.displayGameMenu();
- //GameMediator game = new picross.game.random.RandomGameMediator();
- //GameMediator game = null;
+ return;
+ }
- Thread worker = new Thread() {
- public void run() {
- GameMediator game = null;
-
- try {
- game =
- new picross.game.simple.SimpleGameMediator();
- } catch (PicrossException picrossEx) {
- PicrossMediator.this.view
- .displayError(picrossEx.getMessage());
- return;
- }
-
- //game.addSimpleListener(this);
- //this.view.setContent(game.getView());
- PicrossMediator.this.gameLoaded(game);
- }
- };
-
- worker.start();
-
+ if (cmd.equals(PicrossController.RANDOM_GAME_CMD)) {
+ this.startRandomGame();
return;
}
@@ -154,6 +138,68 @@
this.fireEventPerformed(PicrossController.DISPOSE_CMD);
}
+ /** Displays the game menu. */
+ private void displayGameMenu() {
+ GameMenuMediator menu = null;
+
+ try {
+ menu = new GameMenuMediator();
+ } catch (PicrossException picrossEx) {
+ this.fireEventPerformed(PicrossController.ERROR_CMD,
+ picrossEx.getMessage());
+
+ this.exit();
+ return;
+ }
+
+ menu.addSimpleListener(this);
+ this.view.setContent(menu.getView());
+ }
+
+ /** Starts a random game. */
+ private void startRandomGame() {
+ Thread worker = new Thread() {
+ public void run() {
+ GameMediator game = null;
+
+ try {
+ game =
+ new picross.game.random.RandomGameMediator();
+ } catch (PicrossException picrossEx) {
+ PicrossMediator.this.view
+ .displayError(picrossEx.getMessage());
+ return;
+ }
+
+ PicrossMediator.this.gameLoaded(game);
+ }
+ };
+
+ worker.start();
+ }
+
+ /** Starts a new game. */
+ private void startGame() {
+ Thread worker = new Thread() {
+ public void run() {
+ GameMediator game = null;
+
+ try {
+ game =
+ new picross.game.simple.SimpleGameMediator();
+ } catch (PicrossException picrossEx) {
+ PicrossMediator.this.view
+ .displayError(picrossEx.getMessage());
+ return;
+ }
+
+ PicrossMediator.this.gameLoaded(game);
+ }
+ };
+
+ worker.start();
+ }
+
/**
* Callback used to display the game view.
*
Modified: trunk/src/picross/app/MainMenuAppUI.java
===================================================================
--- trunk/src/picross/app/MainMenuAppUI.java 2008-04-17 08:50:24 UTC (rev 47)
+++ trunk/src/picross/app/MainMenuAppUI.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -84,17 +84,11 @@
super(controller);
- ImageIcon exitIcon =
- Picross.getLocalizedImage(MainMenuAppUI.EXIT_BUTTON_IMAGE);
- JButton exitButton = new JButton(exitIcon);
- exitButton.setActionCommand(MainMenuController.EXIT_CMD);
- exitButton.addActionListener(controller);
- exitButton.setBorder(null);
- exitButton.setBounds(MainMenuAppUI.EXIT_BUTTON_X,
- MainMenuAppUI.EXIT_BUTTON_Y,
- exitIcon.getIconWidth(),
- exitIcon.getIconHeight());
- this.add(exitButton);
+ this.addButton(MainMenuAppUI.EXIT_BUTTON_IMAGE,
+ MainMenuController.EXIT_CMD,
+ controller,
+ MainMenuAppUI.EXIT_BUTTON_X,
+ MainMenuAppUI.EXIT_BUTTON_Y);
}
/*** Methods overloaded from MainMenuUI ***/
Modified: trunk/src/picross/game/random/RandomGameMediator.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMediator.java 2008-04-17 08:50:24 UTC (rev 47)
+++ trunk/src/picross/game/random/RandomGameMediator.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -65,7 +65,7 @@
* @throws PicrossException if there is a problem loading the grid model
* or building the view
*/
- RandomGameMediator() throws PicrossException {
+ public RandomGameMediator() throws PicrossException {
super();
}
@@ -92,7 +92,7 @@
String cmd = e.getCommandName();
if (cmd.equals(RandomGameController.NEXT_CMD)) {
- this.fireEventPerformed(PicrossController.PLAY_CMD);
+ this.fireEventPerformed(PicrossController.RANDOM_GAME_CMD);
return;
}
Added: trunk/src/picross/menus/GameMenuController.java
===================================================================
--- trunk/src/picross/menus/GameMenuController.java (rev 0)
+++ trunk/src/picross/menus/GameMenuController.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -0,0 +1,68 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import fr.cle.mmvcs.Controller;
+import fr.cle.mmvcs.SimpleEvent;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import picross.PicrossController;
+
+/**
+ * Controller for the game menu.
+ *
+ * @author Y. Norsa
+ */
+class GameMenuController extends Controller implements ActionListener {
+ /*** Method overloaded from the class Controller ***/
+
+ /** {@inheritDoc} */
+ @Override
+ public void eventPerformed(SimpleEvent e) { }
+
+ /*** Method implanted from the interface ActionListener ***/
+
+ /** {@inheritDoc} */
+ public void actionPerformed(ActionEvent e) {
+ String cmd = e.getActionCommand();
+
+ if (cmd.equals(PicrossController.RANDOM_GAME_CMD)) {
+ this.fireEventPerformed(cmd);
+ return;
+ }
+ }
+}
+
Property changes on: trunk/src/picross/menus/GameMenuController.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/GameMenuMediator.java
===================================================================
--- trunk/src/picross/menus/GameMenuMediator.java (rev 0)
+++ trunk/src/picross/menus/GameMenuMediator.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -0,0 +1,88 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import fr.cle.mmvcs.Mediateur;
+import fr.cle.mmvcs.SimpleEvent;
+
+import java.io.FileNotFoundException;
+
+import picross.PicrossException;
+
+/**
+ * Mediator for the game menu.
+ *
+ * @author Y. Norsa
+ */
+public class GameMenuMediator extends Mediateur {
+ /*** Field ***/
+
+ private GameMenuUI view;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ */
+ public GameMenuMediator() throws PicrossException {
+ GameMenuController controller = new GameMenuController();
+ controller.addSimpleListener(this);
+
+ try {
+ this.view = new GameMenuUI(controller);
+ } catch (FileNotFoundException fileEx) {
+ throw new PicrossException(fileEx);
+ }
+ }
+
+ /*** Method overloaded from the Mediateur class ***/
+
+ /** {@inheritDoc} */
+ @Override
+ public void eventPerformed(SimpleEvent e) {
+ this.fireEventPerformed(e);
+ }
+
+ /*** Accessor ***/
+
+ /**
+ * Returns the view.
+ *
+ * @return the view
+ */
+ public GameMenuUI getView() {
+ return this.view;
+ }
+}
+
Property changes on: trunk/src/picross/menus/GameMenuMediator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/GameMenuUI.java
===================================================================
--- trunk/src/picross/menus/GameMenuUI.java (rev 0)
+++ trunk/src/picross/menus/GameMenuUI.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -0,0 +1,63 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import java.awt.event.ActionListener;
+
+import java.io.FileNotFoundException;
+
+import picross.PicrossController;
+
+/**
+ * UI for the game menu.
+ *
+ * @author Y. Norsa
+ */
+class GameMenuUI extends MenuUI {
+ /*** Constant ***/
+
+ /** Serialisation ID. */
+ private static final long serialVersionUID = 4472277675596865332L;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ */
+ GameMenuUI(ActionListener listener) throws FileNotFoundException {
+ this.addButton("button-random.png", PicrossController.RANDOM_GAME_CMD,
+ listener, 150, 225);
+ }
+}
+
Property changes on: trunk/src/picross/menus/GameMenuUI.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/menus/MainMenuUI.java
===================================================================
--- trunk/src/picross/menus/MainMenuUI.java 2008-04-17 08:50:24 UTC (rev 47)
+++ trunk/src/picross/menus/MainMenuUI.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -53,23 +53,15 @@
*
* @author Y. Norsa
*/
-public abstract class MainMenuUI extends JPanel {
+public abstract class MainMenuUI extends MenuUI {
/*** Constants ***/
/** Serialisation ID. */
private static final long serialVersionUID = -505088917693050187L;
- /** Background image. */
- private static final String BACKGROUND_IMAGE = "background.png";
-
/** Image for the "play" button. */
private static final String PLAY_BUTTON_IMAGE = "button-play.png";
- /*** Field ***/
-
- /** Background image. */
- private Image image;
-
/*** Constructor ***/
/**
@@ -79,23 +71,11 @@
* @throws FileNotFoundException if a button image can't be found
*/
public MainMenuUI(ActionListener controller) throws FileNotFoundException {
- ImageIcon icon = Picross.getImage(MainMenuUI.BACKGROUND_IMAGE);
- this.setPreferredSize(new Dimension(icon.getIconWidth(),
- icon.getIconHeight()));
- this.image = icon.getImage();
+ super();
- this.setLayout(null);
-
- ImageIcon playIcon =
- Picross.getLocalizedImage(MainMenuUI.PLAY_BUTTON_IMAGE);
- JButton playButton = new JButton(playIcon);
- playButton.setActionCommand(PicrossController.PLAY_CMD);
- playButton.addActionListener(controller);
- playButton.setBorder(null);
- playButton.setBounds(this.getPlayButtonX(), this.getPlayButtonY(),
- playIcon.getIconWidth(),
- playIcon.getIconHeight());
- this.add(playButton);
+ this.addButton(MainMenuUI.PLAY_BUTTON_IMAGE,
+ PicrossController.PLAY_CMD, controller,
+ this.getPlayButtonX(), this.getPlayButtonY());
}
/*** Abstract methods ***/
@@ -113,14 +93,5 @@
* @return Y position of the "play" button
*/
protected abstract int getPlayButtonY();
-
- /*** Method overloaded from the class JPanel ***/
-
- /** {@inheritDoc} */
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
-
- g.drawImage(this.image, 0, 0, null);
- }
}
Added: trunk/src/picross/menus/MenuUI.java
===================================================================
--- trunk/src/picross/menus/MenuUI.java (rev 0)
+++ trunk/src/picross/menus/MenuUI.java 2008-04-17 09:11:28 UTC (rev 48)
@@ -0,0 +1,117 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Image;
+
+import java.awt.event.ActionListener;
+
+import java.io.FileNotFoundException;
+
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+
+import picross.Picross;
+
+/**
+ * Base class for menus.
+ *
+ * @author Y. Norsa
+ */
+abstract class MenuUI extends JPanel {
+ /*** Constant ***/
+
+ /** Background image. */
+ private static final String BACKGROUND_IMAGE = "background.png";
+
+ /*** Field ***/
+
+ /** Background image. */
+ private Image image;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @throws FileNotFoundException if the background image can't be found
+ */
+ MenuUI() throws FileNotFoundException {
+ ImageIcon icon = Picross.getImage(MenuUI.BACKGROUND_IMAGE);
+ this.setPreferredSize(new Dimension(icon.getIconWidth(),
+ icon.getIconHeight()));
+ this.image = icon.getImage();
+
+ this.setLayout(null);
+ }
+
+ /*** Method overloaded from the class JPanel ***/
+
+ /** {@inheritDoc} */
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
+
+ g.drawImage(this.image, 0, 0, null);
+ }
+
+ /*** M\xE9thod ***/
+
+ /**
+ * Helper method to add a button to the menu.
+ *
+ * @param image the image name
+ * @param command the command linked to the button
+ * @param controller listener for the button
+ * @param x x position for the button
+ * @param y y position for the button
+ * @throws FileNotFoundException if a button image can't be found
+ */
+ protected void addButton(String image, String command,
+ ActionListener controller, int x, int y)
+ throws FileNotFoundException {
+
+ ImageIcon buttonIcon = Picross.getLocalizedImage(image);
+ JButton button = new JButton(buttonIcon);
+ button.setActionCommand(command);
+ button.addActionListener(controller);
+ button.setBorder(null);
+ button.setBounds(x, y,
+ buttonIcon.getIconWidth(),
+ buttonIcon.getIconHeight());
+ this.add(button);
+ }
+}
Property changes on: trunk/src/picross/menus/MenuUI.java
___________________________________________________________________
Name: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-18 07:42:14
|
Revision: 52
http://picross.svn.sourceforge.net/picross/?rev=52&view=rev
Author: yvan_norsa
Date: 2008-04-18 00:42:20 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
level selection menu
Modified Paths:
--------------
trunk/build.xml
trunk/lib/mmvcs.jar
trunk/src/picross/Picross.java
trunk/src/picross/PicrossController.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/game/GameMediator.java
trunk/src/picross/game/random/RandomGameMediator.java
trunk/src/picross/game/simple/SimpleGameMediator.java
trunk/src/picross/menus/GameMenuUI.java
trunk/src/picross/menus/MenuController.java
trunk/src/picross/menus/MenuMediator.java
trunk/src/picross/menus/MenuUI.java
Added Paths:
-----------
trunk/data/contents.txt
trunk/images/en/button-select.png
trunk/images/fr/button-select.png
trunk/lib/simpleButton.jar
trunk/src/picross/menus/LevelMenuMediator.java
trunk/src/picross/menus/LevelMenuModel.java
trunk/src/picross/menus/LevelMenuUI.java
Removed Paths:
-------------
trunk/data/anchor.xbm
trunk/data/bart.xbm
trunk/data/blarg.xbm
trunk/data/candle.xbm
trunk/data/crab.xbm
trunk/data/ghost_left.xbm
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/build.xml 2008-04-18 07:42:20 UTC (rev 52)
@@ -27,6 +27,8 @@
value="${lib.dir}/log4j.jar" />
<property name="mmvcs.jar"
value="${lib.dir}/mmvcs.jar" />
+ <property name="simpleButton.jar"
+ value="${lib.dir}/simpleButton.jar" />
<target name="-init"
depends="-setmode">
@@ -62,6 +64,7 @@
<pathelement location="${junit.jar}" />
<pathelement location="${log4j.jar}" />
<pathelement location="${mmvcs.jar}" />
+ <pathelement location="${simpleButton.jar}" />
</path>
<target name="compile"
@@ -107,6 +110,7 @@
<pathelement location="${bundleHelper.jar}" />
<pathelement location="${log4j.jar}" />
<pathelement location="${mmvcs.jar}" />
+ <pathelement location="${simpleButton.jar}" />
</classpath>
</java>
</target>
@@ -123,6 +127,7 @@
<pathelement location="${log4j.jar}" />
<pathelement location="${mmvcs.jar}" />
<pathelement location="${debug.jar}" />
+ <pathelement location="${simpleButton.jar}" />
</classpath>
</java>
</target>
Deleted: trunk/data/anchor.xbm
===================================================================
--- trunk/data/anchor.xbm 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/data/anchor.xbm 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,6 +0,0 @@
-#define anchor.xbm_width 16
-#define anchor.xbm_height 16
-static char anchor.xbm_bits[] = {
- 0x00, 0x00, 0xe0, 0x07, 0xe0, 0x07, 0x80, 0x05, 0x80, 0x05, 0x80, 0x05,
- 0x80, 0x03, 0x80, 0x01, 0x9e, 0x79, 0x8e, 0x71, 0x8e, 0x71, 0x8a, 0x51,
- 0x90, 0x09, 0xe0, 0x07, 0x80, 0x01, 0x00, 0x00};
Deleted: trunk/data/bart.xbm
===================================================================
--- trunk/data/bart.xbm 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/data/bart.xbm 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,27 +0,0 @@
-#define noname_width 43
-#define noname_height 58
-static char noname_bits[] = {
- 0x00,0x00,0x00,0xc4,0x00,0x00,0x00,0x00,0xc0,0xca,0x00,0x00,0x00,0x00,0xc0,
- 0xb2,0x00,0x00,0x00,0x00,0x4c,0xb3,0x00,0x00,0x00,0xc0,0x34,0x82,0x00,0x00,
- 0x00,0x4c,0x35,0x80,0x00,0x00,0x80,0x54,0x26,0x80,0x00,0x00,0x80,0x67,0x04,
- 0x80,0x00,0x00,0xb0,0x4c,0x00,0x80,0x00,0x00,0xd0,0x08,0x00,0x00,0x01,0x00,
- 0x90,0x01,0x00,0x00,0x01,0x00,0x17,0x00,0x00,0x00,0x01,0x00,0x39,0x00,0x00,
- 0x00,0x01,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00,0x02,0x00,
- 0x04,0x00,0x00,0x00,0x02,0x00,0x08,0x00,0x00,0x00,0x02,0x00,0x08,0x00,0x00,
- 0x00,0x0c,0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x1f,0x00,
- 0x20,0x00,0x00,0x80,0x20,0x00,0x20,0x00,0x80,0x43,0x40,0x00,0x40,0x00,0x60,
- 0x2c,0x80,0x00,0x40,0x00,0x18,0x10,0x80,0x00,0x40,0x00,0x04,0x20,0x8c,0x00,
- 0x80,0x00,0x04,0x40,0x8c,0x00,0x80,0x00,0x02,0x40,0x40,0x00,0x00,0x01,0x01,
- 0x40,0x70,0x00,0x00,0x01,0xc1,0xc0,0x8f,0x00,0x00,0x02,0xc1,0x40,0x00,0x01,
- 0x00,0x02,0x02,0x20,0x00,0x01,0x00,0x02,0x02,0x10,0x00,0x01,0x00,0x04,0x04,
- 0x10,0x00,0x01,0x00,0x04,0x08,0x0c,0x80,0x00,0x00,0x04,0xf0,0x03,0x40,0x00,
- 0x00,0x08,0x00,0x00,0xbe,0x00,0x00,0x08,0x00,0x00,0x80,0x00,0x00,0x30,0x00,
- 0x00,0x80,0x00,0x00,0x48,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00,0x01,
- 0x00,0x74,0x00,0x00,0x00,0x02,0x00,0x2a,0x00,0x00,0x00,0x04,0x00,0x6a,0x40,
- 0x00,0x00,0x03,0x00,0x04,0x20,0x00,0xc0,0x00,0x00,0x88,0x70,0x00,0x3e,0x00,
- 0x00,0x70,0x90,0xff,0x01,0x00,0x00,0x20,0x10,0x80,0x00,0x00,0x00,0x20,0x00,
- 0x80,0x00,0x00,0x00,0x20,0x00,0x60,0x00,0x00,0x00,0x20,0x00,0x10,0x00,0x00,
- 0x00,0x20,0x00,0x08,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x10,0x00,
- 0x08,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x60,0x00,0x08,0x00,0x00,
- 0x00,0x80,0x01,0x08,0x00,0x00,0x00,0x00,0x06,0x04,0x00,0x00,0x00,0x00,0xf8,
- 0x03,0x00,0x00};
Deleted: trunk/data/blarg.xbm
===================================================================
--- trunk/data/blarg.xbm 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/data/blarg.xbm 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,5 +0,0 @@
-#define test_width 16
-#define test_height 7
-static char test_bits[] = {
-0x13, 0x00, 0x15, 0x00, 0x93, 0xcd, 0x55, 0xa5, 0x93, 0xc5, 0x00, 0x80,
-0x00, 0x60, };
Deleted: trunk/data/candle.xbm
===================================================================
--- trunk/data/candle.xbm 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/data/candle.xbm 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,8 +0,0 @@
-#define noname_width 16
-#define noname_height 33
-static char noname_bits[] = {
- 0x00,0x01,0x00,0x03,0x00,0x03,0x00,0x03,0x80,0x06,0x40,0x06,0x40,0x06,0x40,
- 0x06,0x40,0x03,0x80,0x01,0xf0,0x0f,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,
- 0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,
- 0x0c,0x10,0x0c,0xfe,0x7f,0x01,0xc0,0x02,0x60,0x0c,0x38,0x10,0x0c,0x10,0x0c,
- 0x20,0x06,0x20,0x06,0x10,0x0c};
Added: trunk/data/contents.txt
===================================================================
--- trunk/data/contents.txt (rev 0)
+++ trunk/data/contents.txt 2008-04-18 07:42:20 UTC (rev 52)
@@ -0,0 +1,3 @@
+bunny.xbm
+halloween.xbm
+squares.xbm
Deleted: trunk/data/crab.xbm
===================================================================
--- trunk/data/crab.xbm 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/data/crab.xbm 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,7 +0,0 @@
-#define crab_width 16
-#define crab_height 16
-
-static char crab_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x70, 0x0e, 0x78, 0x1e, 0x18, 0x18, 0x44, 0x22,
- 0xc4, 0x23, 0xf8, 0x1f, 0xe0, 0x07, 0xf8, 0x1f, 0xe4, 0x27, 0xd0, 0x0b,
- 0x08, 0x10, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 };
Deleted: trunk/data/ghost_left.xbm
===================================================================
--- trunk/data/ghost_left.xbm 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/data/ghost_left.xbm 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,6 +0,0 @@
-#define pacman_left_width 16
-#define pacman_left_height 16
-static char pacman_left_bits[] = {
- 0xf0,0x07,0x0c,0x18,0x02,0x20,0x3a,0x2e,0x45,0x51,0x5d,0x57,0x5d,0x57,0x5d,
- 0x57,0x45,0x51,0x39,0x4e,0x01,0x40,0x01,0x40,0x11,0x44,0x29,0x4a,0x45,0x51,
- 0x82,0x20};
Added: trunk/images/en/button-select.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/en/button-select.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:keywords
+ Id
Added: trunk/images/fr/button-select.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/fr/button-select.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:keywords
+ Id
Modified: trunk/lib/mmvcs.jar
===================================================================
(Binary files differ)
Added: trunk/lib/simpleButton.jar
===================================================================
(Binary files differ)
Property changes on: trunk/lib/simpleButton.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:keywords
+ Id
Modified: trunk/src/picross/Picross.java
===================================================================
--- trunk/src/picross/Picross.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/Picross.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -33,17 +33,21 @@
package picross;
+import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Locale;
import javax.swing.ImageIcon;
-//import org.apache.log4j.Logger;
+import org.apache.log4j.Logger;
/**
* Helper class.
@@ -66,7 +70,7 @@
/*** Static field ***/
/** The class' logger. */
- //private static Logger log = Logger.getLogger(Picross.class);
+ private static Logger log = Logger.getLogger(Picross.class);
/*** Constructor ***/
@@ -163,5 +167,27 @@
return Picross.getFile(Picross.DATA_DIR + name).openStream();
}
+
+ public static List<String> listDataFiles() throws IOException {
+ List<String> list = new ArrayList<String>();
+
+ BufferedReader in = null;
+
+ try {
+ in = new BufferedReader(new InputStreamReader(Picross.loadDataFile("contents.txt")));
+
+ String line = null;
+
+ while ((line = in.readLine()) != null) {
+ list.add(line);
+ }
+ } catch (IOException ioEx) {
+ throw ioEx;
+ } finally {
+ in.close();
+ }
+
+ return list;
+ }
}
Modified: trunk/src/picross/PicrossController.java
===================================================================
--- trunk/src/picross/PicrossController.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/PicrossController.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -55,6 +55,8 @@
/** Select level command. */
public static final String SELECT_LEVEL_CMD = "SELECT_LEVEL_CMD";
+ public static final String LEVEL_CMD = "LEVEL_CMD";
+
/** Exit command. */
public static final String EXIT_CMD = "EXIT_CMD";
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/PicrossMediator.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -38,17 +38,24 @@
import fr.cle.mmvcs.Mediateur;
import fr.cle.mmvcs.SimpleEvent;
+import java.lang.reflect.InvocationTargetException;
+
import javax.swing.SwingUtilities;
-//import org.apache.log4j.Logger;
+import org.apache.log4j.Logger;
import picross.game.GameMediator;
+import picross.game.random.RandomGameMediator;
+
+import picross.game.simple.SimpleGameMediator;
+
import picross.grid.GridController;
import picross.menus.GameMenuMediator;
-
+import picross.menus.LevelMenuMediator;
import picross.menus.MainMenuMediator;
+import picross.menus.MenuMediator;
/**
* Application mediator.
@@ -59,7 +66,7 @@
/*** Static field ***/
/** Class' logger. */
- //private static Logger log = Logger.getLogger(PicrossMediator.class);
+ private static Logger log = Logger.getLogger(PicrossMediator.class);
/*** Field ***/
@@ -76,24 +83,10 @@
PicrossController controller = new PicrossController();
controller.setView(view);
-
this.addSimpleListener(controller);
- MainMenuMediator mediator = null;
+ this.displayMenu(MainMenuMediator.class);
- try {
- mediator = new MainMenuMediator(this.view);
- } catch (PicrossException picrossEx) {
- this.fireEventPerformed(PicrossController.ERROR_CMD,
- picrossEx.getMessage());
-
- this.exit();
- return;
- }
-
- mediator.addSimpleListener(this);
-
- this.view.setContent(mediator.getView());
this.view.showUI();
}
@@ -117,6 +110,16 @@
return;
}
+ if (cmd.equals(PicrossController.SELECT_LEVEL_CMD)) {
+ this.displaySelectLevelMenu();
+ return;
+ }
+
+ if (cmd.equals(PicrossController.LEVEL_CMD)) {
+ this.startGame(e.getComment());
+ return;
+ }
+
if (cmd.equals(PicrossController.EXIT_CMD)) {
this.exit();
return;
@@ -139,10 +142,36 @@
/** Displays the game menu. */
private void displayGameMenu() {
- GameMenuMediator menu = null;
+ this.displayMenu(GameMenuMediator.class);
+ }
+ /** Displays the level selection menu. */
+ private void displaySelectLevelMenu() {
+ this.displayMenu(LevelMenuMediator.class);
+ }
+
+ /**
+ * Helper method to display a menu.
+ *
+ * @param menuClass the menu's mediator class
+ */
+ private void displayMenu(Class<? extends MenuMediator> menuClass) {
+ MenuMediator menu = null;
+
try {
- menu = new GameMenuMediator(this.view);
+ try {
+ menu = menuClass.getConstructor(PicrossUI.class)
+ .newInstance(this.view);
+ } catch (NoSuchMethodException methodEx) {
+ throw new PicrossException(methodEx);
+ } catch (InstantiationException instantiationEx) {
+ throw new PicrossException(instantiationEx);
+ } catch (IllegalAccessException accessEx) {
+ throw new PicrossException(accessEx);
+ } catch (InvocationTargetException targetEx) {
+ targetEx.printStackTrace();
+ throw (PicrossException) targetEx.getCause();
+ }
} catch (PicrossException picrossEx) {
this.fireEventPerformed(PicrossController.ERROR_CMD,
picrossEx.getMessage());
@@ -162,15 +191,13 @@
GameMediator game = null;
try {
- game =
- new picross.game.random.RandomGameMediator();
+ game = new RandomGameMediator();
+ PicrossMediator.this.gameLoaded(game);
} catch (PicrossException picrossEx) {
PicrossMediator.this.view
.displayError(picrossEx.getMessage());
return;
}
-
- PicrossMediator.this.gameLoaded(game);
}
};
@@ -178,21 +205,25 @@
}
/** Starts a new game. */
- private void startGame() {
+ private void startGame(final String level) {
+ PicrossMediator.log.debug("startGame(" + level + ")");
+
Thread worker = new Thread() {
public void run() {
GameMediator game = null;
try {
- game =
- new picross.game.simple.SimpleGameMediator();
- } catch (PicrossException picrossEx) {
- PicrossMediator.this.view
- .displayError(picrossEx.getMessage());
- return;
+ game = new SimpleGameMediator(level);
+ PicrossMediator.this.gameLoaded(game);
+ } catch (final PicrossException picrossEx) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ PicrossMediator.this.view
+ .displayError(picrossEx.getMessage());
+ return;
+ }
+ });
}
-
- PicrossMediator.this.gameLoaded(game);
}
};
Modified: trunk/src/picross/game/GameMediator.java
===================================================================
--- trunk/src/picross/game/GameMediator.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/game/GameMediator.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -70,7 +70,8 @@
* @throws PicrossException if there is a problem loading the grid model
* or building the view
*/
- public GameMediator() throws PicrossException {
+ //public GameMediator() throws PicrossException {
+ protected void init() throws PicrossException {
PicrossGrid model = this.initModel();
final int width = model.getWidth();
Modified: trunk/src/picross/game/random/RandomGameMediator.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMediator.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/game/random/RandomGameMediator.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -66,7 +66,8 @@
* or building the view
*/
public RandomGameMediator() throws PicrossException {
- super();
+ //super();
+ this.init();
}
/*** Methods overloaded from the class GameMediator ***/
Modified: trunk/src/picross/game/simple/SimpleGameMediator.java
===================================================================
--- trunk/src/picross/game/simple/SimpleGameMediator.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/game/simple/SimpleGameMediator.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -47,6 +47,8 @@
* @author Y. Norsa
*/
public final class SimpleGameMediator extends GameMediator {
+ private String level;
+
/*** Constructor ***/
/**
@@ -55,8 +57,11 @@
* @throws PicrossException if there is a problem loading the grid model
* or building the view
*/
- public SimpleGameMediator() throws PicrossException {
- super();
+ public SimpleGameMediator(String levelName) throws PicrossException {
+ //super();
+
+ this.level = levelName;
+ this.init();
}
/*** Method overloaded from the class GameMediator ***/
@@ -64,7 +69,7 @@
/** {@inheritDoc} */
protected PicrossGrid initModel() throws PicrossException {
try {
- return new XBMModel(Picross.loadDataFile("halloween.xbm"));
+ return new XBMModel(Picross.loadDataFile(this.level));
} catch (IOException ioEx) {
throw new PicrossException(ioEx);
}
Modified: trunk/src/picross/menus/GameMenuUI.java
===================================================================
--- trunk/src/picross/menus/GameMenuUI.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/menus/GameMenuUI.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -59,19 +59,34 @@
/** "Random" button Y coordinate. */
private static final int RANDOM_BUTTON_Y = 175;
+ /** Image for the "select" button. */
+ private static final String SELECT_BUTTON_IMAGE = "button-select.png";
+
+ /** "Select" button X coordinate. */
+ private static final int SELECT_BUTTON_X = 150;
+
+ /** "Select" button Y coordinate. */
+ private static final int SELECT_BUTTON_Y = 250;
+
/*** Constructor ***/
/**
* Constructor.
*
- * @param listener listener for the button
- * @throws MissingImageException if the button image can't be found
+ * @param listener listener for the buttons
+ * @throws MissingImageException if a button image can't be found
*/
GameMenuUI(ActionListener listener) {
+ super();
+
this.addButton(GameMenuUI.RANDOM_BUTTON_IMAGE,
PicrossController.RANDOM_GAME_CMD,
listener,
GameMenuUI.RANDOM_BUTTON_X, GameMenuUI.RANDOM_BUTTON_Y);
+ this.addButton(GameMenuUI.SELECT_BUTTON_IMAGE,
+ PicrossController.SELECT_LEVEL_CMD,
+ listener,
+ GameMenuUI.SELECT_BUTTON_X, GameMenuUI.SELECT_BUTTON_Y);
}
}
Added: trunk/src/picross/menus/LevelMenuMediator.java
===================================================================
--- trunk/src/picross/menus/LevelMenuMediator.java (rev 0)
+++ trunk/src/picross/menus/LevelMenuMediator.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -0,0 +1,68 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import picross.PicrossException;
+import picross.PicrossUI;
+
+/**
+ * Level selection menu.
+ *
+ * @author Y. Norsa
+ */
+public class LevelMenuMediator extends MenuMediator {
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @param ui reference to the main UI
+ * @throws PicrossException if the instantiation of the view fails
+ */
+ public LevelMenuMediator(PicrossUI ui) throws PicrossException {
+ super(ui);
+ }
+
+ /*** Method overloaded from the class MenuMediator ***/
+
+ /** {@inheritDoc} */
+ @Override
+ protected MenuUI initView(PicrossUI ui, MenuController controller)
+ throws PicrossException {
+
+ LevelMenuModel model = new LevelMenuModel();
+ return new LevelMenuUI(controller, model.getLevelsList());
+ }
+}
+
Property changes on: trunk/src/picross/menus/LevelMenuMediator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/LevelMenuModel.java
===================================================================
--- trunk/src/picross/menus/LevelMenuModel.java (rev 0)
+++ trunk/src/picross/menus/LevelMenuModel.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -0,0 +1,80 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import java.io.IOException;
+
+import java.util.List;
+
+import picross.Picross;
+import picross.PicrossException;
+
+/**
+ * Model for the level selection menu.
+ *
+ * @author Y. Norsa
+ */
+class LevelMenuModel {
+ /*** Field ***/
+
+ /** Level list. */
+ private List<String> levels;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @throws PicrossException if an error arises during the levels listing
+ */
+ LevelMenuModel() throws PicrossException {
+ try {
+ this.levels = Picross.listDataFiles();
+ } catch (IOException ioEx) {
+ throw new PicrossException(ioEx);
+ }
+ }
+
+ /*** Method ***/
+
+ /**
+ * Returns the levels list.
+ *
+ * @return list of the level files
+ */
+ List<String> getLevelsList() {
+ return this.levels;
+ }
+}
+
Property changes on: trunk/src/picross/menus/LevelMenuModel.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/LevelMenuUI.java
===================================================================
--- trunk/src/picross/menus/LevelMenuUI.java (rev 0)
+++ trunk/src/picross/menus/LevelMenuUI.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -0,0 +1,82 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import fr.cle.mmvcs.SimpleEvent;
+import fr.cle.mmvcs.SimpleListener;
+
+import java.util.List;
+
+import picross.PicrossController;
+
+/**
+ * UI for the level selection menu.
+ *
+ * @author Y. Norsa
+ */
+class LevelMenuUI extends MenuUI {
+ /*** Constant ***/
+
+ /** Serialisation ID. */
+ private static final long serialVersionUID = 6178785913505637523L;
+
+ /*** Constructor ***/
+
+ /**
+ * Constructor.
+ *
+ * @param listener listener for the buttons
+ * @param levels levels list
+ */
+ LevelMenuUI(SimpleListener listener, List<String> levels) {
+ super();
+
+ int x = 50;
+ int y = 150;
+
+ for (String level : levels) {
+ SimpleEvent event = new SimpleEvent(PicrossController.LEVEL_CMD,
+ level);
+ this.addSimpleButton(level, event, listener, x, y);
+
+ y += 75;
+
+ if (y == 375) {
+ x = 250;
+ y = 150;
+ }
+ }
+ }
+}
+
Property changes on: trunk/src/picross/menus/LevelMenuUI.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/menus/MenuController.java
===================================================================
--- trunk/src/picross/menus/MenuController.java 2008-04-18 07:32:24 UTC (rev 51)
+++ trunk/src/picross/menus/MenuController.java 2008-04-18 07:42:20 UTC (rev 52)
@@ -48,6 +48,7 @@
/** {@inheritDoc} */
@Override
public void eventPerformed(SimpleEvent e) {
+ this.fireEventPerformed(e);
}
/*** Method implanted from the interface ActionListener ***/
Modified: trunk/src/picross/menus/MenuMediator.java
===================================================================
--- trunk/src/picross/...
[truncated message content] |
|
From: <yva...@us...> - 2008-04-18 08:34:20
|
Revision: 53
http://picross.svn.sourceforge.net/picross/?rev=53&view=rev
Author: yvan_norsa
Date: 2008-04-18 01:34:27 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
pretty buttons
Modified Paths:
--------------
trunk/images/en/button-random.png
trunk/images/en/button-select.png
trunk/images/fr/button-random.png
trunk/images/fr/button-select.png
trunk/src/picross/menus/LevelMenuUI.java
trunk/src/picross/menus/MenuUI.java
Added Paths:
-----------
trunk/images/empty-button.png
Added: trunk/images/empty-button.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/empty-button.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/images/en/button-random.png
===================================================================
(Binary files differ)
Modified: trunk/images/en/button-select.png
===================================================================
(Binary files differ)
Modified: trunk/images/fr/button-random.png
===================================================================
(Binary files differ)
Modified: trunk/images/fr/button-select.png
===================================================================
(Binary files differ)
Modified: trunk/src/picross/menus/LevelMenuUI.java
===================================================================
--- trunk/src/picross/menus/LevelMenuUI.java 2008-04-18 07:42:20 UTC (rev 52)
+++ trunk/src/picross/menus/LevelMenuUI.java 2008-04-18 08:34:27 UTC (rev 53)
@@ -62,7 +62,7 @@
LevelMenuUI(SimpleListener listener, List<String> levels) {
super();
- int x = 50;
+ int x = 150;
int y = 150;
for (String level : levels) {
@@ -71,11 +71,6 @@
this.addSimpleButton(level, event, listener, x, y);
y += 75;
-
- if (y == 375) {
- x = 250;
- y = 150;
- }
}
}
}
Modified: trunk/src/picross/menus/MenuUI.java
===================================================================
--- trunk/src/picross/menus/MenuUI.java 2008-04-18 07:42:20 UTC (rev 52)
+++ trunk/src/picross/menus/MenuUI.java 2008-04-18 08:34:27 UTC (rev 53)
@@ -140,9 +140,14 @@
protected void addSimpleButton(String label, SimpleEvent event,
SimpleListener listener,
int x, int y) {
- SimpleButton<JButton> button = new SimpleButton<JButton>(label, event) { };
+ SimpleButton<JButton> button = new SimpleButton<JButton>(label,
+ event) { };
button.addSimpleListener(listener);
+ button.getButton().setIcon(Picross.getImage("empty-button.png"));
+ button.getButton().setHorizontalTextPosition(JButton.CENTER);
+ button.getButton().setVerticalTextPosition(JButton.CENTER);
+
this.putButton(button.getButton(), x, y, 150, 50);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-18 11:55:48
|
Revision: 55
http://picross.svn.sourceforge.net/picross/?rev=55&view=rev
Author: yvan_norsa
Date: 2008-04-18 04:55:47 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
new xbm files
Modified Paths:
--------------
trunk/data/contents.txt
trunk/src/picross/menus/LevelMenuUI.java
Added Paths:
-----------
trunk/data/audio.xbm
trunk/data/batman2.xbm
Added: trunk/data/audio.xbm
===================================================================
--- trunk/data/audio.xbm (rev 0)
+++ trunk/data/audio.xbm 2008-04-18 11:55:47 UTC (rev 55)
@@ -0,0 +1,12 @@
+#define audio_width 32
+#define audio_height 32
+static char audio_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0xc0,0x07,0x00,0x00,0xe0,
+ 0x07,0x00,0x00,0xf8,0x06,0x00,0x00,0x7c,0x06,0x00,0x00,0x1f,0x06,0x00,0x80,
+ 0x0f,0x06,0x00,0xe0,0x03,0x06,0x00,0xf0,0x01,0x06,0x00,0x30,0x00,0x06,0x00,
+ 0x30,0x00,0x06,0x00,0x30,0x00,0x06,0x00,0x30,0x00,0x06,0x00,0x30,0xf0,0x06,
+ 0x00,0x30,0xf8,0x07,0x00,0x30,0xfc,0x07,0x00,0x30,0xfe,0x07,0x00,0x30,0xfe,
+ 0x07,0x00,0x30,0xfe,0x07,0x00,0x30,0xfe,0x07,0x00,0x30,0xfc,0x03,0x80,0x37,
+ 0xf8,0x01,0xc0,0x3f,0xf0,0x00,0xe0,0x3f,0x00,0x00,0xf0,0x3f,0x00,0x00,0xf0,
+ 0x3f,0x00,0x00,0xf0,0x3f,0x00,0x00,0xf0,0x3f,0x00,0x00,0xe0,0x1f,0x00,0x00,
+ 0xc0,0x0f,0x00,0x00,0x80,0x07,0x00,0x00};
Added: trunk/data/batman2.xbm
===================================================================
--- trunk/data/batman2.xbm (rev 0)
+++ trunk/data/batman2.xbm 2008-04-18 11:55:47 UTC (rev 55)
@@ -0,0 +1,12 @@
+#define t/batman_width 32
+#define t/batman_height 32
+static char t/batman_bits[] = {
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0xf0,0xff,0xff,0x63,
+ 0xc6,0xff,0xff,0xd8,0x1b,0xff,0x3f,0xc7,0xe3,0xfc,0xbf,0xc3,0xc3,0xfd,0xdf,
+ 0xc3,0xc3,0xfb,0xef,0xc7,0xe3,0xf7,0xef,0xff,0xff,0xf7,0xe7,0xff,0xff,0xe7,
+ 0xf7,0xff,0xff,0xef,0xf7,0xff,0xff,0xef,0xf7,0xff,0xff,0xef,0xf7,0xff,0xff,
+ 0xef,0xf7,0xff,0xff,0xef,0xe7,0xff,0xff,0xe7,0xef,0xdd,0xbb,0xf7,0xef,0x88,
+ 0x11,0xf7,0xdf,0x89,0x91,0xfb,0xff,0x81,0x80,0xff,0x3f,0x83,0xc0,0xfc,0xff,
+ 0x8c,0x30,0xff,0xff,0xf3,0xcf,0xff,0xff,0x0f,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
Modified: trunk/data/contents.txt
===================================================================
--- trunk/data/contents.txt 2008-04-18 11:54:01 UTC (rev 54)
+++ trunk/data/contents.txt 2008-04-18 11:55:47 UTC (rev 55)
@@ -1,3 +1,5 @@
+audio.xbm
+batman2.xbm
bunny.xbm
halloween.xbm
squares.xbm
Modified: trunk/src/picross/menus/LevelMenuUI.java
===================================================================
--- trunk/src/picross/menus/LevelMenuUI.java 2008-04-18 11:54:01 UTC (rev 54)
+++ trunk/src/picross/menus/LevelMenuUI.java 2008-04-18 11:55:47 UTC (rev 55)
@@ -62,7 +62,7 @@
LevelMenuUI(SimpleListener listener, List<String> levels) {
super();
- int x = 150;
+ int x = 50;
int y = 150;
for (String level : levels) {
@@ -71,6 +71,11 @@
this.addSimpleButton(level, event, listener, x, y);
y += 75;
+
+ if (y == 375) {
+ x = 250;
+ y = 150;
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-22 12:19:07
|
Revision: 58
http://picross.svn.sourceforge.net/picross/?rev=58&view=rev
Author: yvan_norsa
Date: 2008-04-22 05:18:30 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
highlight current row and column
Modified Paths:
--------------
trunk/lib/mmvcs.jar
trunk/src/picross/grid/GridController.java
trunk/src/picross/grid/GridMediator.java
trunk/src/picross/grid/GridModel.java
trunk/src/picross/grid/GridUI.java
trunk/src/picross/grid/IGridMediator.java
trunk/src/picross/grid/tests/IGridMediatorStub.java
Added Paths:
-----------
trunk/src/picross/grid/RepaintLeftHintsCommand.java
trunk/src/picross/grid/RepaintTopHintsCommand.java
Modified: trunk/lib/mmvcs.jar
===================================================================
(Binary files differ)
Modified: trunk/src/picross/grid/GridController.java
===================================================================
--- trunk/src/picross/grid/GridController.java 2008-04-18 12:58:30 UTC (rev 57)
+++ trunk/src/picross/grid/GridController.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -112,12 +112,14 @@
}
if (cmd.equals(GridController.REPAINT_TOP_HINTS_CMD)) {
- this.view.repaintColHints();
+ int col = ((RepaintTopHintsCommand) e.getCommand()).getColumn();
+ this.view.repaintColHints(col);
return;
}
if (cmd.equals(GridController.REPAINT_LEFT_HINTS_CMD)) {
- this.view.repaintRowHints();
+ int row = ((RepaintLeftHintsCommand) e.getCommand()).getRow();
+ this.view.repaintRowHints(row);
return;
}
}
@@ -200,6 +202,7 @@
this.fireEventPerformed(GridController.FILL_CMD,
new FillCommand(row, column, type));
+ this.view.rolloverHighlight(row, column);
}
}
Modified: trunk/src/picross/grid/GridMediator.java
===================================================================
--- trunk/src/picross/grid/GridMediator.java 2008-04-18 12:58:30 UTC (rev 57)
+++ trunk/src/picross/grid/GridMediator.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -157,13 +157,15 @@
}
/** Asks to repaint the column hints. */
- public void repaintColHints() {
- this.fireEventPerformed(GridController.REPAINT_TOP_HINTS_CMD);
+ public void repaintColHints(int column) {
+ this.fireEventPerformed(//GridController.REPAINT_TOP_HINTS_CMD);
+ new RepaintTopHintsCommand(column));
}
/** Asks to repaint the row hints. */
- public void repaintRowHints() {
- this.fireEventPerformed(GridController.REPAINT_LEFT_HINTS_CMD);
+ public void repaintRowHints(int row) {
+ this.fireEventPerformed(//GridController.REPAINT_LEFT_HINTS_CMD);
+ new RepaintLeftHintsCommand(row));
}
/*** Accessor ***/
Modified: trunk/src/picross/grid/GridModel.java
===================================================================
--- trunk/src/picross/grid/GridModel.java 2008-04-18 12:58:30 UTC (rev 57)
+++ trunk/src/picross/grid/GridModel.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -581,7 +581,7 @@
this.completedHints.setCompleteRowHint(row, index);
}
- this.mediator.repaintRowHints();
+ this.mediator.repaintRowHints(row);
}
/**
@@ -748,7 +748,7 @@
this.completedHints.setCompleteColHint(column, index);
}
- this.mediator.repaintColHints();
+ this.mediator.repaintColHints(column);
}
/** Checks wether the grid is finished. */
Modified: trunk/src/picross/grid/GridUI.java
===================================================================
--- trunk/src/picross/grid/GridUI.java 2008-04-18 12:58:30 UTC (rev 57)
+++ trunk/src/picross/grid/GridUI.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -151,17 +151,17 @@
/** Position of the bottom end of the grid. */
private int bottomBoundary;
- /** Rectangle occupied by the top hints. */
- private Rectangle topHintsRect;
+ /** Rectangles occupied by the top hints. */
+ private Rectangle[] topHintsRects;
- /** Precomputed image containing the top hints boxes. */
- private transient BufferedImage topHintsBoxes;
+ /** Precomputed images containing the top hints boxes. */
+ private transient BufferedImage[] topHintsBoxes;
- /** Rectangle occupied by the left hints. */
- private Rectangle leftHintsRect;
+ /** Rectangles occupied by the left hints. */
+ private Rectangle[] leftHintsRects;
- /** Precomputed image containing the left hints boxes. */
- private transient BufferedImage leftHintsBoxes;
+ /** Precomputed images containing the left hints boxes. */
+ private transient BufferedImage[] leftHintsBoxes;
/** Current state of the grid. */
private transient Box[][] boxes;
@@ -253,12 +253,16 @@
Rectangle clipRect = newG.getClipBounds();
- if (this.topHintsRect.intersects(clipRect)) {
- this.drawTopHints(newG);
+ for (int i = 0; i < this.topHintsRects.length; i++) {
+ if (this.topHintsRects[i].intersects(clipRect)) {
+ this.drawTopHints(newG, i);
+ }
}
- if (this.leftHintsRect.intersects(clipRect)) {
- this.drawLeftHints(newG);
+ for (int i = 0; i < this.leftHintsRects.length; i++) {
+ if (this.leftHintsRects[i].intersects(clipRect)) {
+ this.drawLeftHints(newG, i);
+ }
}
// Paints the boxes
@@ -337,15 +341,22 @@
+ (this.height * GridUI.BOX_HEIGHT);
// Space occupied by the hints
+ this.topHintsRects = new Rectangle[this.width];
- this.topHintsRect = new Rectangle(this.leftBoundary, 0,
- this.width * GridUI.BOX_WIDTH,
- this.topBoundary);
- this.leftHintsRect = new Rectangle(0, this.topBoundary,
- this.leftBoundary,
- this.height
- * GridUI.BOX_HEIGHT);
+ for (int i = 0; i < this.topHintsRects.length; i++) {
+ this.topHintsRects[i] =
+ new Rectangle(this.leftBoundary + (i * GridUI.BOX_WIDTH), 0,
+ GridUI.BOX_WIDTH, this.topBoundary);
+ }
+ this.leftHintsRects = new Rectangle[this.height];
+
+ for (int i = 0; i < this.leftHintsRects.length; i++) {
+ this.leftHintsRects[i] =
+ new Rectangle(0, this.topBoundary + (i * GridUI.BOX_HEIGHT),
+ this.leftBoundary, GridUI.BOX_HEIGHT);
+ }
+
this.topHintsX = this.leftBoundary
+ (GridUI.BOX_WIDTH / 2) - (hintBoxWidth / 2);
@@ -446,27 +457,28 @@
* @param topHintsStart coordinate where the boxes begin
*/
private void initTopHints(int topHintsStart) {
- this.topHintsBoxes = new BufferedImage(this.topHintsRect.width,
- this.topHintsRect.height,
- BufferedImage.TYPE_INT_RGB);
- Graphics2D g2d = this.topHintsBoxes.createGraphics();
- g2d.setColor(Color.WHITE);
- g2d.fillRect(0, 0, this.topHintsRect.width, this.topHintsRect.height);
+ this.topHintsBoxes = new BufferedImage[this.width];
- int y = 0;
+ for (int k = 0; k < this.topHintsBoxes.length; k++) {
+ this.topHintsBoxes[k] =
+ new BufferedImage(GridUI.BOX_WIDTH, this.topBoundary,
+ BufferedImage.TYPE_INT_RGB);
- for (int i = this.colData[0].length - 1; i >= 0; i--) {
- int x = topHintsStart;
+ Graphics2D g2d = this.topHintsBoxes[k].createGraphics();
+ g2d.setColor(Color.WHITE);
+ g2d.fillRect(0, 0,
+ this.topHintsRects[k].width,
+ this.topHintsRects[k].height);
- for (int j = 0; j < this.colData.length; j++) {
- if (this.colData[j][i] != GridModel.EMPTY_HINT) {
- this.hintBoxIcon.paintIcon(this, g2d, x, y);
+ int y = 0;
+
+ for (int i = (this.colData[0].length - 1); i >= 0; i--) {
+ if (this.colData[k][i] != GridModel.EMPTY_HINT) {
+ this.hintBoxIcon.paintIcon(this, g2d, topHintsStart, y);
}
- x += GridUI.BOX_WIDTH;
+ y += this.topHintsDecal;
}
-
- y += this.topHintsDecal;
}
}
@@ -476,28 +488,28 @@
* @param leftHintsStart coordinate where the boxes begin
*/
private void initLeftHints(int leftHintsStart) {
- this.leftHintsBoxes = new BufferedImage(this.leftHintsRect.width,
- this.leftHintsRect.height,
- BufferedImage.TYPE_INT_RGB);
- Graphics2D g2d = this.leftHintsBoxes.createGraphics();
- g2d.setColor(Color.WHITE);
- g2d.fillRect(0, 0,
- this.leftHintsRect.width, this.leftHintsRect.height);
+ this.leftHintsBoxes = new BufferedImage[this.height];
- int y = leftHintsStart;
+ for (int k = 0; k < this.leftHintsBoxes.length; k++) {
+ this.leftHintsBoxes[k] =
+ new BufferedImage(this.leftBoundary, GridUI.BOX_HEIGHT,
+ BufferedImage.TYPE_INT_RGB);
- for (int i = 0; i < this.rowData.length; i++) {
+ Graphics2D g2d = this.leftHintsBoxes[k].createGraphics();
+ g2d.setColor(Color.WHITE);
+ g2d.fillRect(0, 0,
+ this.leftHintsRects[k].width,
+ this.leftHintsRects[k].height);
+
int x = 0;
- for (int j = 0; j < this.rowData[i].length; j++) {
- if (this.rowData[i][j] != GridModel.EMPTY_HINT) {
- this.hintBoxIcon.paintIcon(this, g2d, x, y);
+ for (int j = 0; j < this.rowData[k].length; j++) {
+ if (this.rowData[k][j] != GridModel.EMPTY_HINT) {
+ this.hintBoxIcon.paintIcon(this, g2d, x, leftHintsStart);
}
x += this.leftHintsDecal;
}
-
- y += GridUI.BOX_HEIGHT;
}
}
@@ -506,24 +518,23 @@
*
* @param g the graphics context
*/
- private void drawTopHints(Graphics g) {
- g.drawImage(this.topHintsBoxes,
- this.topHintsRect.x, this.topHintsRect.y, null);
+ private void drawTopHints(Graphics g, int col) {
+ //GridUI.log.debug("drawTopHints(g, " + col + ")");
+ g.drawImage(this.topHintsBoxes[col],
+ this.topHintsRects[col].x, this.topHintsRects[col].y,
+ null);
+
g.setFont(GridUI.HINT_FONT);
+ int x = topHintsX + (col * GridUI.BOX_WIDTH);
int y = 0;
for (int i = this.colData[0].length - 1; i >= 0; i--) {
- int x = this.topHintsX;
-
- for (int j = 0; j < this.colData.length; j++) {
- if (this.colData[j][i] != GridModel.EMPTY_HINT) {
- this.drawHint(g, this.colData[j][i], x, y,
- this.completedHints.isColHintComplete(j, i));
- }
-
- x += GridUI.BOX_WIDTH;
+ if (this.colData[col][i] != GridModel.EMPTY_HINT) {
+ this.drawHint(g, this.colData[col][i], x, y,
+ this.completedHints.isColHintComplete(col, i),
+ (this.rolloverColumn == col));
}
y += this.topHintsDecal;
@@ -535,27 +546,24 @@
*
* @param g the graphics context
*/
- private void drawLeftHints(Graphics g) {
- g.drawImage(this.leftHintsBoxes,
- this.leftHintsRect.x, this.leftHintsRect.y, null);
+ private void drawLeftHints(Graphics g, int row) {
+ g.drawImage(this.leftHintsBoxes[row],
+ this.leftHintsRects[row].x, this.leftHintsRects[row].y,
+ null);
g.setFont(GridUI.HINT_FONT);
- int y = this.leftHintsY;
+ int y = this.leftHintsY + (row * GridUI.BOX_HEIGHT);
+ int x = 0;
- for (int i = 0; i < this.rowData.length; i++) {
- int x = 0;
-
- for (int j = 0; j < this.rowData[i].length; j++) {
- if (this.rowData[i][j] != GridModel.EMPTY_HINT) {
- this.drawHint(g, this.rowData[i][j], x, y,
- this.completedHints.isRowHintComplete(i, j));
- }
-
- x += this.leftHintsDecal;
+ for (int j = 0; j < this.rowData[row].length; j++) {
+ if (this.rowData[row][j] != GridModel.EMPTY_HINT) {
+ this.drawHint(g, this.rowData[row][j], x, y,
+ this.completedHints.isRowHintComplete(row, j),
+ (this.rolloverRow == row));
}
- y += GridUI.BOX_HEIGHT;
+ x += this.leftHintsDecal;
}
}
@@ -568,11 +576,19 @@
* @param y Y coordinate
*/
private void drawHint(Graphics g, int value, int x, int y,
- boolean complete) {
- if (complete) {
- g.setColor(GridUI.COMPLETED_HINT_COLOR);
+ boolean complete, boolean rollover) {
+ if (!rollover) {
+ if (complete) {
+ g.setColor(GridUI.COMPLETED_HINT_COLOR);
+ } else {
+ g.setColor(GridUI.HINT_TEXT_COLOR);
+ }
} else {
- g.setColor(GridUI.HINT_TEXT_COLOR);
+ if (complete) {
+ g.setColor(new Color(255, 122, 0));
+ } else {
+ g.setColor(Color.ORANGE);
+ }
}
y += this.centerHintHeight;
@@ -643,6 +659,9 @@
this.repaint(this.boxes[column][row].getRect());
}
+ private int rolloverRow = -1;
+ private int rolloverColumn = -1;
+
/**
* Allows to set the current rolled-over box.
*
@@ -655,10 +674,25 @@
this.rolloverEnded();
this.rollover = this.boxes[column][row];
this.repaint(this.rollover.getRect());
+
+ this.rolloverHighlight(row, column);
}
+ void rolloverHighlight(int row, int column) {
+ if ((this.rolloverColumn != column) || (this.rolloverRow != row)) {
+ this.repaintColHints(this.rolloverColumn);
+ this.repaintRowHints(this.rolloverRow);
+
+ this.rolloverColumn = column;
+ this.rolloverRow = row;
+
+ this.repaintColHints(this.rolloverColumn);
+ this.repaintRowHints(this.rolloverRow);
+ }
+ }
+
/** Indicates that no box is currently rolled over. */
- void rolloverEnded() {
+ void rolloverEnded() {
if (this.rollover != null) {
/*
* Save the old rolled-over box so we can draw it
@@ -672,12 +706,20 @@
}
/** Repaints top hints. */
- void repaintColHints() {
- this.repaint(this.topHintsRect);
+ void repaintColHints(int col) {
+ if (col < 0 || col >= this.width) {
+ return;
+ }
+
+ this.repaint(this.topHintsRects[col]);
}
/** Repaints left hints. */
- void repaintRowHints() {
- this.repaint(this.leftHintsRect);
+ void repaintRowHints(int row) {
+ if (row < 0 || row >= this.height) {
+ return;
+ }
+
+ this.repaint(this.leftHintsRects[row]);
}
}
Modified: trunk/src/picross/grid/IGridMediator.java
===================================================================
--- trunk/src/picross/grid/IGridMediator.java 2008-04-18 12:58:30 UTC (rev 57)
+++ trunk/src/picross/grid/IGridMediator.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -46,10 +46,10 @@
void repaint(int row, int column);
/** Asks to repaint the column hints. */
- void repaintColHints();
+ void repaintColHints(int col);
/** Asks to repaint the row hints. */
- void repaintRowHints();
+ void repaintRowHints(int row);
/** Tells the application mediator the grid has been filled. */
void congratulations();
Added: trunk/src/picross/grid/RepaintLeftHintsCommand.java
===================================================================
--- trunk/src/picross/grid/RepaintLeftHintsCommand.java (rev 0)
+++ trunk/src/picross/grid/RepaintLeftHintsCommand.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -0,0 +1,79 @@
+/*
+ * $Id$
+ * \xC9crit le 22/04/2008 par Y. Norsa
+ *
+ * Copyright (c) 2008
+ * Projet Carte Lorraine de l'Etudiant (CLE)
+ *
+ * Universit\xE9 Henri Poincar\xE9, Nancy
+ * Universit\xE9 Nancy2
+ * Institut National Polytechnique de Lorraine
+ * Universit\xE9 Paul Verlaine, Metz
+ *
+ * Ce projet regroupe les d\xE9veloppements concernant la production
+ * et l'exploitation de la Carte Lorraine de l'Etudiant
+ * (carte \xE0 puce sans contact Mifare).
+ *
+ * Ce logiciel est r\xE9gi par la licence CeCILL soumise au droit fran\xE7ais et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffus\xE9e par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilit\xE9 au code source et des droits de copie,
+ * de modification et de redistribution accord\xE9s par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limit\xE9e. Pour les m\xEAmes raisons,
+ * seule une responsabilit\xE9 restreinte p\xE8se sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les conc\xE9dants successifs.
+ *
+ * A cet \xE9gard l'attention de l'utilisateur est attir\xE9e sur les risques
+ * associ\xE9s au chargement, \xE0 l'utilisation, \xE0 la modification et/ou au
+ * d\xE9veloppement et \xE0 la reproduction du logiciel par l'utilisateur \xE9tant
+ * donn\xE9 sa sp\xE9cificit\xE9 de logiciel libre, qui peut le rendre complexe \xE0
+ * manipuler et qui le r\xE9serve donc \xE0 des d\xE9veloppeurs et des professionnels
+ * avertis poss\xE9dant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invit\xE9s \xE0 charger et tester l'ad\xE9quation du
+ * logiciel \xE0 leurs besoins dans des conditions permettant d'assurer la
+ * s\xE9curit\xE9 de leurs syst\xE8mes et ou de leurs donn\xE9es et, plus g\xE9n\xE9ralement,
+ * \xE0 l'utiliser et l'exploiter dans les m\xEAmes conditions de s\xE9curit\xE9.
+ *
+ * Le fait que vous puissiez acc\xE9der \xE0 cet en-t\xEAte signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accept\xE9 les
+ * termes.
+ */
+
+
+package picross.grid;
+
+import fr.cle.mmvcs.NamedCommand;
+
+/**
+ * @author Y. Norsa
+ */
+class RepaintLeftHintsCommand extends NamedCommand {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private int row;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ RepaintLeftHintsCommand(int rowNumber) {
+ super(GridController.REPAINT_LEFT_HINTS_CMD);
+
+ this.row = rowNumber;
+ }
+
+ /*** M\xE9thode ***/
+
+ int getRow() {
+ return this.row;
+ }
+}
+
Property changes on: trunk/src/picross/grid/RepaintLeftHintsCommand.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/grid/RepaintTopHintsCommand.java
===================================================================
--- trunk/src/picross/grid/RepaintTopHintsCommand.java (rev 0)
+++ trunk/src/picross/grid/RepaintTopHintsCommand.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -0,0 +1,79 @@
+/*
+ * $Id$
+ * \xC9crit le 22/04/2008 par Y. Norsa
+ *
+ * Copyright (c) 2008
+ * Projet Carte Lorraine de l'Etudiant (CLE)
+ *
+ * Universit\xE9 Henri Poincar\xE9, Nancy
+ * Universit\xE9 Nancy2
+ * Institut National Polytechnique de Lorraine
+ * Universit\xE9 Paul Verlaine, Metz
+ *
+ * Ce projet regroupe les d\xE9veloppements concernant la production
+ * et l'exploitation de la Carte Lorraine de l'Etudiant
+ * (carte \xE0 puce sans contact Mifare).
+ *
+ * Ce logiciel est r\xE9gi par la licence CeCILL soumise au droit fran\xE7ais et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffus\xE9e par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilit\xE9 au code source et des droits de copie,
+ * de modification et de redistribution accord\xE9s par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limit\xE9e. Pour les m\xEAmes raisons,
+ * seule une responsabilit\xE9 restreinte p\xE8se sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les conc\xE9dants successifs.
+ *
+ * A cet \xE9gard l'attention de l'utilisateur est attir\xE9e sur les risques
+ * associ\xE9s au chargement, \xE0 l'utilisation, \xE0 la modification et/ou au
+ * d\xE9veloppement et \xE0 la reproduction du logiciel par l'utilisateur \xE9tant
+ * donn\xE9 sa sp\xE9cificit\xE9 de logiciel libre, qui peut le rendre complexe \xE0
+ * manipuler et qui le r\xE9serve donc \xE0 des d\xE9veloppeurs et des professionnels
+ * avertis poss\xE9dant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invit\xE9s \xE0 charger et tester l'ad\xE9quation du
+ * logiciel \xE0 leurs besoins dans des conditions permettant d'assurer la
+ * s\xE9curit\xE9 de leurs syst\xE8mes et ou de leurs donn\xE9es et, plus g\xE9n\xE9ralement,
+ * \xE0 l'utiliser et l'exploiter dans les m\xEAmes conditions de s\xE9curit\xE9.
+ *
+ * Le fait que vous puissiez acc\xE9der \xE0 cet en-t\xEAte signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accept\xE9 les
+ * termes.
+ */
+
+
+package picross.grid;
+
+import fr.cle.mmvcs.NamedCommand;
+
+/**
+ * @author Y. Norsa
+ */
+class RepaintTopHintsCommand extends NamedCommand {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private int column;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ RepaintTopHintsCommand(int col) {
+ super(GridController.REPAINT_TOP_HINTS_CMD);
+
+ this.column = col;
+ }
+
+ /*** M\xE9thode ***/
+
+ int getColumn() {
+ return this.column;
+ }
+}
+
Property changes on: trunk/src/picross/grid/RepaintTopHintsCommand.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/grid/tests/IGridMediatorStub.java
===================================================================
--- trunk/src/picross/grid/tests/IGridMediatorStub.java 2008-04-18 12:58:30 UTC (rev 57)
+++ trunk/src/picross/grid/tests/IGridMediatorStub.java 2008-04-22 12:18:30 UTC (rev 58)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
@@ -59,9 +59,9 @@
public void repaint(int row, int column) { }
- public void repaintColHints() { }
+ public void repaintColHints(int col) { }
- public void repaintRowHints() { }
+ public void repaintRowHints(int row) { }
public void congratulations() { }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-22 12:46:13
|
Revision: 60
http://picross.svn.sourceforge.net/picross/?rev=60&view=rev
Author: yvan_norsa
Date: 2008-04-22 05:46:19 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
loading screen
Modified Paths:
--------------
trunk/src/picross/PicrossController.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/game/random/RandomGameController.java
trunk/src/picross/game/random/RandomGameMediator.java
Added Paths:
-----------
trunk/images/en/label-wait.png
trunk/images/fr/label-wait.png
trunk/src/picross/menus/WaitMenuMediator.java
trunk/src/picross/menus/WaitMenuUI.java
Added: trunk/images/en/label-wait.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/en/label-wait.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/images/fr/label-wait.png
===================================================================
(Binary files differ)
Property changes on: trunk/images/fr/label-wait.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/picross/PicrossController.java
===================================================================
--- trunk/src/picross/PicrossController.java 2008-04-22 12:23:45 UTC (rev 59)
+++ trunk/src/picross/PicrossController.java 2008-04-22 12:46:19 UTC (rev 60)
@@ -52,6 +52,8 @@
/** Random game command. */
public static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD";
+ public static final String NEXT_RANDOM_GAME_CMD = "NEXT_RANDOM_GAME_CMD";
+
/** Select level command. */
public static final String SELECT_LEVEL_CMD = "SELECT_LEVEL_CMD";
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2008-04-22 12:23:45 UTC (rev 59)
+++ trunk/src/picross/PicrossMediator.java 2008-04-22 12:46:19 UTC (rev 60)
@@ -56,6 +56,7 @@
import picross.menus.LevelMenuMediator;
import picross.menus.MainMenuMediator;
import picross.menus.MenuMediator;
+import picross.menus.WaitMenuMediator;
/**
* Application mediator.
@@ -106,16 +107,23 @@
}
if (cmd.equals(PicrossController.RANDOM_GAME_CMD)) {
+ this.displayWaitScreen();
this.startRandomGame();
return;
}
+ if (cmd.equals(PicrossController.NEXT_RANDOM_GAME_CMD)) {
+ this.startRandomGame();
+ return;
+ }
+
if (cmd.equals(PicrossController.SELECT_LEVEL_CMD)) {
this.displaySelectLevelMenu();
return;
}
if (cmd.equals(PicrossController.LEVEL_CMD)) {
+ this.displayWaitScreen();
this.startGame(e.getComment());
return;
}
@@ -150,6 +158,10 @@
this.displayMenu(LevelMenuMediator.class);
}
+ private void displayWaitScreen() {
+ this.displayMenu(WaitMenuMediator.class);
+ }
+
/**
* Helper method to display a menu.
*
Modified: trunk/src/picross/game/random/RandomGameController.java
===================================================================
--- trunk/src/picross/game/random/RandomGameController.java 2008-04-22 12:23:45 UTC (rev 59)
+++ trunk/src/picross/game/random/RandomGameController.java 2008-04-22 12:46:19 UTC (rev 60)
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (c) 2007
+ * Copyright (c) 2007-2008
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
Modified: trunk/src/picross/game/random/RandomGameMediator.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMediator.java 2008-04-22 12:23:45 UTC (rev 59)
+++ trunk/src/picross/game/random/RandomGameMediator.java 2008-04-22 12:46:19 UTC (rev 60)
@@ -93,7 +93,7 @@
String cmd = e.getCommandName();
if (cmd.equals(RandomGameController.NEXT_CMD)) {
- this.fireEventPerformed(PicrossController.RANDOM_GAME_CMD);
+ this.fireEventPerformed(PicrossController.NEXT_RANDOM_GAME_CMD);
return;
}
Added: trunk/src/picross/menus/WaitMenuMediator.java
===================================================================
--- trunk/src/picross/menus/WaitMenuMediator.java (rev 0)
+++ trunk/src/picross/menus/WaitMenuMediator.java 2008-04-22 12:46:19 UTC (rev 60)
@@ -0,0 +1,66 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import picross.PicrossException;
+import picross.PicrossUI;
+
+/**
+ * @author Y. Norsa
+ */
+public class WaitMenuMediator extends MenuMediator {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ public WaitMenuMediator(PicrossUI ui) throws PicrossException {
+ super(ui);
+ }
+
+ /*** M\xE9thode ***/
+
+ protected MenuUI initView(PicrossUI ui, MenuController controller)
+ throws PicrossException {
+
+ return new WaitMenuUI();
+ }
+}
+
Property changes on: trunk/src/picross/menus/WaitMenuMediator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/menus/WaitMenuUI.java
===================================================================
--- trunk/src/picross/menus/WaitMenuUI.java (rev 0)
+++ trunk/src/picross/menus/WaitMenuUI.java 2008-04-22 12:46:19 UTC (rev 60)
@@ -0,0 +1,68 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+
+import picross.Picross;
+
+/**
+ * @author Y. Norsa
+ */
+class WaitMenuUI extends MenuUI {
+ /*** Constante ***/
+ static final long serialVersionUID = -6083373008192848638L;
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ WaitMenuUI() {
+ super();
+
+ ImageIcon labelIcon = Picross.getLocalizedImage("label-wait.png");
+ JLabel label = new JLabel(labelIcon);
+ label.setBorder(null);
+ label.setBounds(75, 225,
+ labelIcon.getIconWidth(), labelIcon.getIconHeight());
+ this.add(label);
+ }
+}
+
Property changes on: trunk/src/picross/menus/WaitMenuUI.java
___________________________________________________________________
Name: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yva...@us...> - 2008-04-23 12:05:23
|
Revision: 61
http://picross.svn.sourceforge.net/picross/?rev=61&view=rev
Author: yvan_norsa
Date: 2008-04-23 05:05:30 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
size-based level selection ; dynamic game modes
Modified Paths:
--------------
trunk/build.xml
trunk/data/contents.txt
trunk/lib/mmvcs.jar
trunk/src/picross/Picross.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/game/GameMediator.java
trunk/src/picross/game/random/RandomGameMediator.java
trunk/src/picross/game/simple/SimpleGameMediator.java
trunk/src/picross/menus/GameMenuMediator.java
trunk/src/picross/menus/GameMenuUI.java
trunk/src/picross/menus/LevelMenuMediator.java
trunk/src/picross/menus/LevelMenuModel.java
trunk/src/picross/menus/LevelMenuUI.java
trunk/src/picross/menus/MenuController.java
trunk/src/picross/menus/MenuMediator.java
trunk/src/picross/menus/MenuUI.java
Added Paths:
-----------
trunk/list_contents.sh
trunk/services/
trunk/services/picross.game.GameMode
trunk/src/picross/game/GameCommand.java
trunk/src/picross/game/GameMode.java
trunk/src/picross/game/random/RandomGameMode.java
trunk/src/picross/game/simple/FileInfo.java
trunk/src/picross/game/simple/LevelInfo.java
trunk/src/picross/game/simple/SimpleGameMode.java
trunk/src/picross/menus/GameMenuModel.java
trunk/src/picross/menus/LevelMenuController.java
trunk/src/picross/menus/LevelsListCommand.java
trunk/src/picross/menus/MenuCommand.java
trunk/src/picross/menus/SelectSizeCommand.java
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/build.xml 2008-04-23 12:05:30 UTC (rev 61)
@@ -95,6 +95,10 @@
<fileset dir="data" />
</copy>
+ <copy todir="${build.dir}/META-INF/services">
+ <fileset dir="services" />
+ </copy>
+
<jar destfile="${jar.name}"
basedir="${build.dir}" />
</target>
Modified: trunk/data/contents.txt
===================================================================
--- trunk/data/contents.txt 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/data/contents.txt 2008-04-23 12:05:30 UTC (rev 61)
@@ -1,5 +1,5 @@
-audio.xbm
-batman2.xbm
-bunny.xbm
-halloween.xbm
-squares.xbm
+audio.xbm : 32x32
+batman2.xbm : 32x32
+bunny.xbm : 16x16
+halloween.xbm : 16x16
+squares.xbm : 16x16
Modified: trunk/lib/mmvcs.jar
===================================================================
(Binary files differ)
Added: trunk/list_contents.sh
===================================================================
--- trunk/list_contents.sh (rev 0)
+++ trunk/list_contents.sh 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,10 @@
+#!/bin/tcsh
+
+set dest = data/contents.txt
+rm $dest
+
+foreach file (`ls data/*.xbm`)
+ set width = `awk '/width/ {print $3}' $file`
+ set height = `awk '/height/ {print $3}' $file`
+ echo "$file:t : $width"x"$height" >> $dest
+end
Property changes on: trunk/list_contents.sh
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/services/picross.game.GameMode
===================================================================
--- trunk/services/picross.game.GameMode (rev 0)
+++ trunk/services/picross.game.GameMode 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,2 @@
+picross.game.random.RandomGameMode
+picross.game.simple.SimpleGameMode
Modified: trunk/src/picross/Picross.java
===================================================================
--- trunk/src/picross/Picross.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/Picross.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -49,6 +49,9 @@
import org.apache.log4j.Logger;
+import picross.game.simple.FileInfo;
+import picross.game.simple.LevelInfo;
+
/**
* Helper class.
*
@@ -168,8 +171,10 @@
return Picross.getFile(Picross.DATA_DIR + name).openStream();
}
- public static List<String> listDataFiles() throws IOException {
- List<String> list = new ArrayList<String>();
+ //public static List<String> listDataFiles() throws IOException {
+ public static List<LevelInfo> listDataFiles() throws IOException {
+ //List<String> list = new ArrayList<String>();
+ List<LevelInfo> list = new ArrayList<LevelInfo>();
BufferedReader in = null;
@@ -179,7 +184,11 @@
String line = null;
while ((line = in.readLine()) != null) {
- list.add(line);
+ //list.add(line);
+ String[] lineData = line.split(":");
+ String[] sizeData = lineData[1].trim().split("x");
+
+ list.add(new FileInfo(lineData[0].trim(), Integer.parseInt(sizeData[0]), Integer.parseInt(sizeData[1])));
}
} catch (IOException ioEx) {
throw ioEx;
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/PicrossMediator.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -44,6 +44,7 @@
import org.apache.log4j.Logger;
+import picross.game.GameCommand;
import picross.game.GameMediator;
import picross.game.random.RandomGameMediator;
@@ -55,6 +56,7 @@
import picross.menus.GameMenuMediator;
import picross.menus.LevelMenuMediator;
import picross.menus.MainMenuMediator;
+import picross.menus.MenuCommand;
import picross.menus.MenuMediator;
import picross.menus.WaitMenuMediator;
@@ -106,11 +108,13 @@
return;
}
+ /*
if (cmd.equals(PicrossController.RANDOM_GAME_CMD)) {
this.displayWaitScreen();
this.startRandomGame();
return;
}
+ */
if (cmd.equals(PicrossController.NEXT_RANDOM_GAME_CMD)) {
this.startRandomGame();
@@ -122,12 +126,30 @@
return;
}
+ /*
if (cmd.equals(PicrossController.LEVEL_CMD)) {
this.displayWaitScreen();
this.startGame(e.getComment());
return;
}
+ */
+ if (cmd.equals("MENU_CMD")) {
+ MenuCommand command = (MenuCommand) e.getCommand();
+ this.displayMenu(command.getMenuClass());
+
+ return;
+ }
+
+ if (cmd.equals(GameCommand.GAME_CMD)) {
+ this.displayWaitScreen();
+
+ GameCommand command = (GameCommand) e.getCommand();
+ this.startGame(command.getGame());
+
+ return;
+ }
+
if (cmd.equals(PicrossController.EXIT_CMD)) {
this.exit();
return;
@@ -196,6 +218,24 @@
this.view.setContent(menu.getView());
}
+ private void startGame(final GameMediator game) {
+ Thread worker = new Thread() {
+ public void run() {
+ try {
+ //game = new RandomGameMediator();
+ game.start();
+ PicrossMediator.this.gameLoaded(game);
+ } catch (PicrossException picrossEx) {
+ PicrossMediator.this.view
+ .displayError(picrossEx.getMessage());
+ return;
+ }
+ }
+ };
+
+ worker.start();
+ }
+
/** Starts a random game. */
private void startRandomGame() {
Thread worker = new Thread() {
@@ -204,6 +244,7 @@
try {
game = new RandomGameMediator();
+ game.start();
PicrossMediator.this.gameLoaded(game);
} catch (PicrossException picrossEx) {
PicrossMediator.this.view
@@ -217,6 +258,7 @@
}
/** Starts a new game. */
+ /*
private void startGame(final String level) {
PicrossMediator.log.debug("startGame(" + level + ")");
@@ -241,6 +283,7 @@
worker.start();
}
+ */
/**
* Callback used to display the game view.
Added: trunk/src/picross/game/GameCommand.java
===================================================================
--- trunk/src/picross/game/GameCommand.java (rev 0)
+++ trunk/src/picross/game/GameCommand.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,69 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game;
+
+import fr.cle.mmvcs.NamedCommand;
+
+/**
+ * @author Y. Norsa
+ */
+public class GameCommand extends NamedCommand {
+ /*** Constante ***/
+
+ public static final String GAME_CMD = "GAME_CMD";
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private GameMediator game;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ public GameCommand(GameMediator gameMediator) {
+ super(GameCommand.GAME_CMD);
+
+ this.game = gameMediator;
+ }
+
+ /*** M\xE9thode ***/
+
+ public GameMediator getGame() {
+ return this.game;
+ }
+}
+
Property changes on: trunk/src/picross/game/GameCommand.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/game/GameMediator.java
===================================================================
--- trunk/src/picross/game/GameMediator.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/game/GameMediator.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -113,6 +113,10 @@
*/
protected abstract PicrossGrid initModel() throws PicrossException;
+ public void start() throws PicrossException {
+ this.init();
+ }
+
/*** Method overloaded from the class Mediator ***/
/** {@inheritDoc} */
Added: trunk/src/picross/game/GameMode.java
===================================================================
--- trunk/src/picross/game/GameMode.java (rev 0)
+++ trunk/src/picross/game/GameMode.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,46 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game;
+
+import fr.cle.core.gui.SimpleButton;
+
+import javax.swing.JButton;
+
+/**
+ * @author Y. Norsa
+ */
+public interface GameMode {
+ SimpleButton<JButton> getButton();
+}
+
Property changes on: trunk/src/picross/game/GameMode.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/game/random/RandomGameMediator.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMediator.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/game/random/RandomGameMediator.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -65,9 +65,9 @@
* @throws PicrossException if there is a problem loading the grid model
* or building the view
*/
- public RandomGameMediator() throws PicrossException {
+ public RandomGameMediator() {//throws PicrossException {
//super();
- this.init();
+ //this.init();
}
/*** Methods overloaded from the class GameMediator ***/
Added: trunk/src/picross/game/random/RandomGameMode.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMode.java (rev 0)
+++ trunk/src/picross/game/random/RandomGameMode.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,86 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.random;
+
+import fr.cle.core.gui.SimpleButton;
+
+import fr.cle.mmvcs.SimpleEvent;
+
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+
+import picross.Picross;
+
+import picross.game.GameMode;
+
+/**
+ * @author Y. Norsa
+ */
+public class RandomGameMode implements GameMode {
+ /*** Constante ***/
+
+ /** Image for the "random" button. */
+ private static final String RANDOM_BUTTON_IMAGE = "button-random.png";
+
+ /** "Random" button X coordinate. */
+ private static final int RANDOM_BUTTON_X = 150;
+
+ /** "Random" button Y coordinate. */
+ private static final int RANDOM_BUTTON_Y = 175;
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ RandomGameMode() {
+ }
+ */
+ /*** M\xE9thode ***/
+
+ public SimpleButton<JButton> getButton() {
+ ImageIcon icon = Picross.getLocalizedImage(RandomGameMode.RANDOM_BUTTON_IMAGE);
+ SimpleEvent event = new SimpleEvent(new picross.game.GameCommand(new RandomGameMediator()));
+ SimpleButton<JButton> button = new SimpleButton<JButton>(null, event) { };
+ button.getButton().setIcon(icon);
+
+ return button;
+ }
+}
+
Property changes on: trunk/src/picross/game/random/RandomGameMode.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/game/simple/FileInfo.java
===================================================================
--- trunk/src/picross/game/simple/FileInfo.java (rev 0)
+++ trunk/src/picross/game/simple/FileInfo.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,71 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.simple;
+
+import java.awt.Dimension;
+
+/**
+ * @author Y. Norsa
+ */
+public class FileInfo implements LevelInfo {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ private String name;
+ private Dimension dimension;
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ public FileInfo(String levelName, int width, int height) {
+ this.name = levelName;
+ this.dimension = new Dimension(width, height);
+ }
+
+ /*** M\xE9thode ***/
+
+ public String getName() {
+ return this.name;
+ }
+
+ public Dimension getDimension() {
+ return this.dimension;
+ }
+}
+
Property changes on: trunk/src/picross/game/simple/FileInfo.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/game/simple/LevelInfo.java
===================================================================
--- trunk/src/picross/game/simple/LevelInfo.java (rev 0)
+++ trunk/src/picross/game/simple/LevelInfo.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,45 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.simple;
+
+import java.awt.Dimension;
+
+/**
+ * @author Y. Norsa
+ */
+public interface LevelInfo {
+ String getName();
+ Dimension getDimension();
+}
+
Property changes on: trunk/src/picross/game/simple/LevelInfo.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/game/simple/SimpleGameMediator.java
===================================================================
--- trunk/src/picross/game/simple/SimpleGameMediator.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/game/simple/SimpleGameMediator.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -57,11 +57,11 @@
* @throws PicrossException if there is a problem loading the grid model
* or building the view
*/
- public SimpleGameMediator(String levelName) throws PicrossException {
+ public SimpleGameMediator(String levelName) {//throws PicrossException {
//super();
this.level = levelName;
- this.init();
+ //this.init();
}
/*** Method overloaded from the class GameMediator ***/
Added: trunk/src/picross/game/simple/SimpleGameMode.java
===================================================================
--- trunk/src/picross/game/simple/SimpleGameMode.java (rev 0)
+++ trunk/src/picross/game/simple/SimpleGameMode.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,88 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.game.simple;
+
+import fr.cle.core.gui.SimpleButton;
+
+import fr.cle.mmvcs.SimpleEvent;
+
+import picross.Picross;
+
+import picross.game.GameMode;
+
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+
+/**
+ * @author Y. Norsa
+ */
+public class SimpleGameMode implements GameMode {
+ /*** Constante ***/
+
+ /** Image for the "select" button. */
+ private static final String SELECT_BUTTON_IMAGE = "button-select.png";
+
+ /** "Select" button X coordinate. */
+ private static final int SELECT_BUTTON_X = 150;
+
+ /** "Select" button Y coordinate. */
+ private static final int SELECT_BUTTON_Y = 250;
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ SimpleGameMode() {
+ }
+ */
+
+ /*** M\xE9thode ***/
+
+ public SimpleButton<JButton> getButton() {
+ ImageIcon icon =
+ Picross.getLocalizedImage(SimpleGameMode.SELECT_BUTTON_IMAGE);
+ SimpleEvent event = new SimpleEvent(new picross.menus.MenuCommand(picross.menus.LevelMenuMediator.class));
+ SimpleButton<JButton> button = new SimpleButton<JButton>("", event) { };
+ button.getButton().setIcon(icon);
+
+ return button;
+ }
+}
+
Property changes on: trunk/src/picross/game/simple/SimpleGameMode.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/menus/GameMenuMediator.java
===================================================================
--- trunk/src/picross/menus/GameMenuMediator.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/menus/GameMenuMediator.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -66,7 +66,7 @@
protected MenuUI initView(PicrossUI ui, MenuController controller)
throws PicrossException {
- return new GameMenuUI(controller);
+ return new GameMenuUI(controller, new GameMenuModel().getGameModes());
}
}
Added: trunk/src/picross/menus/GameMenuModel.java
===================================================================
--- trunk/src/picross/menus/GameMenuModel.java (rev 0)
+++ trunk/src/picross/menus/GameMenuModel.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -0,0 +1,67 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty and the software's author, the holder of the
+ * economic rights, and the successive licensors have only limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading, using, modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean that it is complicated to manipulate, and that also
+ * therefore means that it is reserved for developers and experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and, more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ */
+
+
+package picross.menus;
+
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+import picross.game.GameMode;
+
+/**
+ * @author Y. Norsa
+ */
+class GameMenuModel {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ /*
+ GameMenuModel() {
+ }
+ */
+
+ /*** M\xE9thode ***/
+
+ /*Iterator*/ServiceLoader<GameMode> getGameModes() {
+ return ServiceLoader.load(GameMode.class);//.iterator();
+ }
+}
+
Property changes on: trunk/src/picross/menus/GameMenuModel.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/picross/menus/GameMenuUI.java
===================================================================
--- trunk/src/picross/menus/GameMenuUI.java 2008-04-22 12:46:19 UTC (rev 60)
+++ trunk/src/picross/menus/GameMenuUI.java 2008-04-23 12:05:30 UTC (rev 61)
@@ -37,8 +37,14 @@
import java.io.FileNotFoundException;
+import java.util.Iterator;
+
+import org.apache.log4j.Logger;
+
import picross.PicrossController;
+import picross.game.GameMode;
+
/**
* UI for the game menu.
*
@@ -51,23 +57,25 @@
private static final long serialVersionUID = 4472277675596865332L;
/** Image for the "random" button. */
- private static final String RANDOM_BUTTON_IMAGE = "button-random.png";
+ //private static final String RANDOM_BUTTON_IMAGE = "b...
[truncated message content] |