picross-commit Mailing List for picross (Page 6)
Status: Pre-Alpha
Brought to you by:
yvan_norsa
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(40) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
|
Feb
|
Mar
|
Apr
(30) |
May
(15) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(10) |
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(38) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
(1) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <yva...@us...> - 2007-06-06 15:02:51
|
Revision: 16 http://picross.svn.sourceforge.net/picross/?rev=16&view=rev Author: yvan_norsa Date: 2007-06-06 07:57:34 -0700 (Wed, 06 Jun 2007) Log Message: ----------- fixed the victory conditions Modified Paths: -------------- trunk/src/picross/grid/PicrossGridModel.java Modified: trunk/src/picross/grid/PicrossGridModel.java =================================================================== --- trunk/src/picross/grid/PicrossGridModel.java 2007-06-06 14:26:30 UTC (rev 15) +++ trunk/src/picross/grid/PicrossGridModel.java 2007-06-06 14:57:34 UTC (rev 16) @@ -264,7 +264,6 @@ if (type == PicrossGridController.CHECK_ACTION) { this.boxes[row][column].check(); - this.checkCompleted(); } else { //if (type == PicrossGridController.CROSS_ACTION) { this.boxes[row][column].cross(); } @@ -297,12 +296,12 @@ this.boxes[row][column].check(); this.mediator.check(row, column, PicrossGridController.CHECK_ACTION); - this.checkCompleted(); } } } this.lastModified = this.boxes[row][column]; + this.checkCompleted(); } /** Checks wether the grid is finished. */ @@ -311,7 +310,11 @@ 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.boxes[i][j].isChecked()) { + boolean isCurrentBoxChecked = this.boxes[i][j].isChecked(); + + if ((this.data[i][j] && !isCurrentBoxChecked) + || (!this.data[i][j] && isCurrentBoxChecked)) { + completed = false; break; } 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 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 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 12:07:45
|
Revision: 12 http://picross.svn.sourceforge.net/picross/?rev=12&view=rev Author: yvan_norsa Date: 2007-06-06 05:07:47 -0700 (Wed, 06 Jun 2007) Log Message: ----------- allows to directly cross a checked box and vice-versa Modified Paths: -------------- trunk/src/picross/grid/PicrossGridController.java trunk/src/picross/grid/PicrossGridModel.java Modified: trunk/src/picross/grid/PicrossGridController.java =================================================================== --- trunk/src/picross/grid/PicrossGridController.java 2007-06-06 11:42:57 UTC (rev 11) +++ trunk/src/picross/grid/PicrossGridController.java 2007-06-06 12:07:47 UTC (rev 12) @@ -172,6 +172,8 @@ int column = this.view.getColumn(point); int type = PicrossGridController.modifiersToType(modifiers); + //PicrossGridController.log.debug("type : " + type); + this.fireEventPerformed(PicrossGridController.FILL_CMD, new FillCommand(row, column, type)); @@ -189,7 +191,7 @@ case MouseEvent.BUTTON1_MASK: return PicrossGridController.CHECK_ACTION; - case MouseEvent.BUTTON2_MASK: + case MouseEvent.BUTTON3_MASK: return PicrossGridController.CROSS_ACTION; default: Modified: trunk/src/picross/grid/PicrossGridModel.java =================================================================== --- trunk/src/picross/grid/PicrossGridModel.java 2007-06-06 11:42:57 UTC (rev 11) +++ trunk/src/picross/grid/PicrossGridModel.java 2007-06-06 12:07:47 UTC (rev 12) @@ -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,9 +234,9 @@ * @param column column of the box */ void checkBox(int row, int column, int type) { - //PicrossGridModel.log.debug("checkBox(" + row + ", " + column + ")"); - //PicrossGridModel.log.debug("lastChecked == null : " - // + (lastChecked == null)); + PicrossGridModel.log.debug("checkBox(" + row + ", " + column + ")"); + //PicrossGridModel.log.debug("lastModified == null : " + // + (lastModified == null)); /* * If we are trying to check the last box we just checked @@ -264,6 +264,7 @@ if (type == PicrossGridController.CHECK_ACTION) { this.boxes[row][column].check(); + this.checkCompleted(); } else { //if (type == PicrossGridController.CROSS_ACTION) { this.boxes[row][column].cross(); } @@ -272,13 +273,36 @@ } else if (!this.boxes[row][column].isEmpty() && (this.lastModified == null || this.lastModified.isEmpty())) { - this.boxes[row][column].empty(); - this.mediator.uncheck(row, column, type); + if (this.boxes[row][column].isChecked()) { + //PicrossGridModel.log.debug("checked"); + + if (type == PicrossGridController.CHECK_ACTION) { + this.boxes[row][column].empty(); + this.mediator.uncheck(row, column, type); + } else { //if (type == PicrossGridController.CROSS_ACTION) { + this.boxes[row][column].cross(); + this.mediator.check(row, column, + PicrossGridController.CROSS_ACTION); + } + } else { //if (this.boxes[row][column].isCrossed())\xA0{ + //PicrossGridModel.log.debug("crossed"); + + if (type == PicrossGridController.CROSS_ACTION) { + this.boxes[row][column].empty(); + this.mediator.uncheck(row, column, type); + } else { + //PicrossGridModel.log.debug("check()"); + + this.boxes[row][column].check(); + this.mediator.check(row, column, + PicrossGridController.CHECK_ACTION); + this.checkCompleted(); + } + } } this.lastModified = this.boxes[row][column]; - this.checkCompleted(); } /** Checks wether the grid is finished. */ 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-06 08:27:55
|
Revision: 10 http://picross.svn.sourceforge.net/picross/?rev=10&view=rev Author: yvan_norsa Date: 2007-06-06 01:27:54 -0700 (Wed, 06 Jun 2007) Log Message: ----------- code cleanup, comments Modified Paths: -------------- trunk/src/picross/PicrossController.java trunk/src/picross/PicrossMediator.java trunk/src/picross/PicrossModel.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 trunk/src/picross/grid/PicrossGridUI.java Modified: trunk/src/picross/PicrossController.java =================================================================== --- trunk/src/picross/PicrossController.java 2007-06-05 14:44:56 UTC (rev 9) +++ trunk/src/picross/PicrossController.java 2007-06-06 08:27:54 UTC (rev 10) @@ -43,7 +43,7 @@ * * @author Y. Norsa */ -class PicrossController extends Controller { +final class PicrossController extends Controller { /*** Static field ***/ /** The class's logger. */ Modified: trunk/src/picross/PicrossMediator.java =================================================================== --- trunk/src/picross/PicrossMediator.java 2007-06-05 14:44:56 UTC (rev 9) +++ trunk/src/picross/PicrossMediator.java 2007-06-06 08:27:54 UTC (rev 10) @@ -36,7 +36,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; @@ -46,11 +46,11 @@ * * @author Y. Norsa */ -class PicrossMediator extends Mediateur { +final class PicrossMediator extends Mediateur { /*** Static field ***/ /** Class' logger. */ - private static Logger log = Logger.getLogger(PicrossMediator.class); + //private static Logger log = Logger.getLogger(PicrossMediator.class); /*** Constructor ***/ @@ -75,7 +75,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/PicrossModel.java =================================================================== --- trunk/src/picross/PicrossModel.java 2007-06-05 14:44:56 UTC (rev 9) +++ trunk/src/picross/PicrossModel.java 2007-06-06 08:27:54 UTC (rev 10) @@ -38,7 +38,7 @@ * * @author Y. Norsa */ -class PicrossModel { +final class PicrossModel { /*** Fields ***/ /** Grid width. */ Modified: trunk/src/picross/PicrossUI.java =================================================================== --- trunk/src/picross/PicrossUI.java 2007-06-05 14:44:56 UTC (rev 9) +++ trunk/src/picross/PicrossUI.java 2007-06-06 08:27:54 UTC (rev 10) @@ -43,7 +43,7 @@ * * @author Y. Norsa */ -class PicrossUI extends JFrame { +final class PicrossUI extends JFrame { /*** Constant ***/ /** Serialisation ID. */ Modified: trunk/src/picross/grid/FillCommand.java =================================================================== --- trunk/src/picross/grid/FillCommand.java 2007-06-05 14:44:56 UTC (rev 9) +++ trunk/src/picross/grid/FillCommand.java 2007-06-06 08:27:54 UTC (rev 10) @@ -40,7 +40,7 @@ * * @author Y. Norsa */ -class FillCommand extends Command { +final class FillCommand extends Command { /*** Fields ***/ /** Row of the box to fill. */ Modified: trunk/src/picross/grid/PicrossGridController.java =================================================================== --- trunk/src/picross/grid/PicrossGridController.java 2007-06-05 14:44:56 UTC (rev 9) +++ trunk/src/picross/grid/PicrossGridController.java 2007-06-06 08:27:54 UTC (rev 10) @@ -42,14 +42,14 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; -import org.apache.log4j.Logger; +//import org.apache.log4j.Logger; /** * Grid controller. * * @author Y. Norsa */ -public class PicrossGridController extends Controller +public final class PicrossGridController extends Controller implements MouseListener, MouseMotionListener { /*** Constants ***/ @@ -60,15 +60,19 @@ /** Command indicating the grid is filled. */ public static final String GRID_FILLED_CMD = "GRID_FILLED_CMD"; + /** Command indicating the action has reached its end. */ static final String END_ACTION_CMD = "END_ACTION_CMD"; + /** Command to check a box. */ static final String CHECK_CMD = "CHECK_CMD"; + + /** Command to uncheck a box. */ static final String UNCHECK_CMD = "UNCHECK_CMD"; /*** Static field ***/ /** The class' logger. */ - private static Logger log = Logger.getLogger(PicrossGridController.class); + //private static Logger log = Logger.getLogger(PicrossGridController.class); /*** Field ***/ @@ -79,7 +83,7 @@ /** {@inheritDoc} */ public void eventPerformed(SimpleEvent e) { - PicrossGridController.log.debug("eventPerformed(" + e + ")"); + //PicrossGridController.log.debug("eventPerformed(" + e + ")"); String cmd = e.getCommandName(); @@ -106,9 +110,7 @@ /*** Methods implanted from the interface MouseListener ***/ /** {@inheritDoc} */ - public void mouseClicked(MouseEvent e) { - this.checkAndFill(e); - } + public void mouseClicked(MouseEvent e) { } /** {@inheritDoc} */ public void mouseEntered(MouseEvent e) { } @@ -121,7 +123,8 @@ /** {@inheritDoc} */ public void mouseReleased(MouseEvent e) { - PicrossGridController.log.debug("mouseReleased()"); + //PicrossGridController.log.debug("mouseReleased()"); + this.checkAndFill(e); this.fireEventPerformed(PicrossGridController.END_ACTION_CMD); } @@ -155,7 +158,7 @@ if (this.view.isInGrid(point)) { int row = this.view.getRow(point); int column = this.view.getColumn(point); - + this.fireEventPerformed(PicrossGridController.FILL_CMD, new FillCommand(row, column)); } Modified: trunk/src/picross/grid/PicrossGridMediator.java =================================================================== --- trunk/src/picross/grid/PicrossGridMediator.java 2007-06-05 14:44:56 UTC (rev 9) +++ trunk/src/picross/grid/PicrossGridMediator.java 2007-06-06 08:27:54 UTC (rev 10) @@ -45,7 +45,7 @@ * * @author Y. Norsa */ -public class PicrossGridMediator extends Mediateur { +public final class PicrossGridMediator extends Mediateur { /*** Static field ***/ /** Class' logger. */ @@ -104,18 +104,30 @@ } } - /*** Method ***/ + /*** Methods ***/ /** Tells the application mediator the grid has been filled. */ void congratulations() { this.fireEventPerformed(PicrossGridController.GRID_FILLED_CMD); } + /** + * Checks a box. + * + * @param row row of the box + * @param column column of the box + */ void check(int row, int column) { this.fireEventPerformed(PicrossGridController.CHECK_CMD, new FillCommand(row, column)); } + /** + * Unchecks a box. + * + * @param row row of the box + * @param column column of the box + */ void uncheck(int row, int column) { this.fireEventPerformed(PicrossGridController.UNCHECK_CMD, new FillCommand(row, column)); Modified: trunk/src/picross/grid/PicrossGridModel.java =================================================================== --- trunk/src/picross/grid/PicrossGridModel.java 2007-06-05 14:44:56 UTC (rev 9) +++ trunk/src/picross/grid/PicrossGridModel.java 2007-06-06 08:27:54 UTC (rev 10) @@ -43,7 +43,12 @@ * * @author Y. Norsa */ -class PicrossGridModel { +final class PicrossGridModel { + /*** Constant ***/ + + /** Empty hint value. */ + static final int EMPTY_HINT = -1; + /*** Static field ***/ /** The class' logger. */ @@ -58,16 +63,20 @@ private boolean[][] data; /** The grid as filled by the user. */ - private Boolean[][] checked; + private DummyBoolean[][] checked; + /** + * The last modified box. Permis to know if we are in a serie or + * a single action. + */ + private DummyBoolean lastChecked = null; + /** Columns hints. */ private int[][] colData; /** Rows hints. */ private int[][] rowData; - private Boolean lastChecked = null; - /*** Constructor ***/ /** @@ -80,26 +89,31 @@ this.mediator = mediator; this.data = data; - this.checked = new Boolean[this.data.length][this.data[0].length]; + this.checked = new DummyBoolean[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] = Boolean.valueOf(false); + this.checked[i][j] = new DummyBoolean(false); } } - List<List<Integer>> colRawData = new ArrayList<List<Integer>>(); + // Grid of columns hints + List<List<Integer>> colHints = new ArrayList<List<Integer>>(); + + // Largest number of hints for a column int max = 0; for (boolean[] col : data) { List<Integer> current = new ArrayList<Integer>(); + // Current hint int chain = 0; for (boolean cell : col) { if (cell) { chain++; } else if (chain > 0) { + // We've reached the end of a series of checked boxes current.add(chain); chain = 0; } @@ -108,6 +122,7 @@ if (chain > 0) { current.add(chain); } else if (current.size() == 0) { + // If this column is empty, we add a "0" hint current.add(0); } @@ -117,24 +132,48 @@ max = currentSize; } - colRawData.add(current); + colHints.add(current); } + /* + * Final array containing the hints, in the following form : + * + * 1 + * 0 2 1 + * + * Which corresponds to the following grid : + * + * |-----| + * |_|X|_| + * |_|_|X| + * |_|X|_| + * |_|X|_| + * |-----| + */ this.colData = new int[data.length][max]; for (int i = 0; i < max; i++) { - for (int j = 0; j < colRawData.size(); j++) { - if (colRawData.get(j).size() >= (max - i)) { - this.colData[j][max - 1 - i] - = colRawData.get(j).get(colRawData.get(j).size() - - max + i); + // Minimal number of hints for the current column to be considered + int ref = max - i; + + // Current hint row + int currentRow = ref - 1; + + for (int j = 0; j < colHints.size(); j++) { + List<Integer> currentCol = colHints.get(j); + int size = currentCol.size(); + + if (size >= ref) { + this.colData[j][currentRow] = currentCol.get(size - ref); } else { - this.colData[j][max - 1 - i] = -1; + this.colData[j][currentRow] = PicrossGridModel.EMPTY_HINT; } } } - List<List<Integer>> rowRawData = new ArrayList<List<Integer>>(); + // Same operations as for the columns, basically + + List<List<Integer>> rowHints = new ArrayList<List<Integer>>(); max = 0; for (int i = 0; i < data[0].length; i++) { @@ -163,66 +202,104 @@ max = currentSize; } - rowRawData.add(current); + rowHints.add(current); } this.rowData = new int[data[0].length][max]; + int nbRows = rowHints.size(); for (int i = 0; i < max; i++) { - for (int j = 0; j < rowRawData.size(); j++) { - if (rowRawData.get(j).size() >= (max - i)) { - int index = i - Math.abs(rowRawData.get(j).size() - max); - this.rowData[j][i] = rowRawData.get(j).get(index); + int ref = max - i; + + for (int j = 0; j < nbRows; j++) { + List<Integer> currentRow = rowHints.get(j); + int size = currentRow.size(); + + if (size >= ref) { + this.rowData[j][i] = + currentRow.get(i - Math.abs(size - max)); } else { - this.rowData[j][i] = -1; + this.rowData[j][i] = PicrossGridModel.EMPTY_HINT; } } } } - /*** Method ***/ + /*** Methods ***/ /** - * Indicates a box has been checked. + * Method called during an action. * * @param row row of the box * @param column column of the box */ void checkBox(int row, int column) { - if (this.lastChecked == null || - !this.lastChecked.equals(this.checked[row][column])) { + //PicrossGridModel.log.debug("checkBox(" + row + ", " + column + ")"); + //PicrossGridModel.log.debug("lastChecked == null : " + // + (lastChecked == null)); - if (!this.checked[row][column]) { - //PicrossGridModel.log.debug("checking " + row + "," + column); + /* + * 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]) { - this.checked[row][column] = true; - this.lastChecked = this.checked[row][column]; + return; + } - this.mediator.check(row, column); + boolean currentValue = this.checked[row][column].getValue(); - boolean completed = true; + /* + * The value of the last checked box tells us if we are in + * a checks serie or a uncheck serie + */ + boolean lastValue = false; - 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 (this.lastChecked != null) { + lastValue = this.lastChecked.getValue(); - if (completed) { - this.mediator.congratulations(); + /* + * 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) { + 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); + } + + this.lastChecked = this.checked[row][column]; + this.checkCompleted(); + } + + /** Checks wether the grid is finished. */ + private void checkCompleted() { + 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].getValue()) { + completed = false; + break; } - } else { - this.checked[row][column] = false; - this.lastChecked = this.checked[row][column]; - - this.mediator.uncheck(row, column); } } + + if (completed) { + this.mediator.congratulations(); + } } + /** Indicates the current action has come to an end. */ void endAction() { this.lastChecked = null; } @@ -246,5 +323,49 @@ 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-05 14:44:56 UTC (rev 9) +++ trunk/src/picross/grid/PicrossGridUI.java 2007-06-06 08:27:54 UTC (rev 10) @@ -40,14 +40,14 @@ import javax.swing.JPanel; -import org.apache.log4j.Logger; +//import org.apache.log4j.Logger; /** * Grid UI. * * @author Y. Norsa */ -class PicrossGridUI extends JPanel { +final class PicrossGridUI extends JPanel { /*** Constants ***/ /** Serialisation ID. */ @@ -83,7 +83,7 @@ /*** Static field ***/ /** Class' logger. */ - private static Logger log = Logger.getLogger(PicrossGridUI.class); + //private static Logger log = Logger.getLogger(PicrossGridUI.class); /*** Fields ***/ @@ -114,6 +114,7 @@ /** Filled boxes. */ private boolean[][] filled; + /** Controller attached to this view. */ private transient PicrossGridController controller; /*** Constructor ***/ @@ -161,8 +162,8 @@ this.bottomBoundary = this.topBoundary + (this.height * PicrossGridUI.BOX_HEIGHT); - PicrossGridUI.log.debug("rightBoundary : " + this.rightBoundary); - PicrossGridUI.log.debug("bottomBoundary : " + this.bottomBoundary); + //PicrossGridUI.log.debug("rightBoundary : " + this.rightBoundary); + //PicrossGridUI.log.debug("bottomBoundary : " + this.bottomBoundary); this.setPreferredSize(new Dimension(this.rightBoundary + PicrossGridUI.RIGHT_SPACE, @@ -183,7 +184,7 @@ x = this.leftBoundary + PicrossGridUI.COL_HINT_WIDTH; for (int j = 0; j < this.colData.length; j++) { - if (this.colData[j][i] != -1) { + if (this.colData[j][i] != PicrossGridModel.EMPTY_HINT) { g.drawString(String.valueOf(this.colData[j][i]), x, y); } @@ -200,7 +201,7 @@ x = 0; for (int j = 0; j < this.rowData[i].length; j++) { - if (this.rowData[i][j] != -1) { + if (this.rowData[i][j] != PicrossGridModel.EMPTY_HINT) { g.drawString(String.valueOf(this.rowData[i][j]), x, y + PicrossGridUI.ROW_HINT_HEIGHT); } @@ -283,19 +284,42 @@ return (int) (x / PicrossGridUI.BOX_WIDTH); } - + + /** Removes the listeners to disable the grid. */ void disableGrid() { this.removeMouseListener(this.controller); this.removeMouseMotionListener(this.controller); } + /** + * Checks a row. + * + * @param row row of the box + * @param column column of the box + */ void check(int row, int column) { - this.filled[row][column] = true; - this.repaint(); + this.setBoxState(row, column, true); } + /** + * Unchecks a row. + * + * @param row row of the box + * @param column column of the box + */ void uncheck(int row, int column) { - this.filled[row][column] = false; + this.setBoxState(row, column, false); + } + + /** + * Modifies a box and repaints the grid. + * + * @param row row of the box + * @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; 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-05 14:44:54
|
Revision: 9 http://picross.svn.sourceforge.net/picross/?rev=9&view=rev Author: yvan_norsa Date: 2007-06-05 07:44:56 -0700 (Tue, 05 Jun 2007) Log Message: ----------- disable the grid at the end; allows to uncheck boxes Modified Paths: -------------- trunk/src/picross/grid/PicrossGridController.java trunk/src/picross/grid/PicrossGridMediator.java trunk/src/picross/grid/PicrossGridModel.java trunk/src/picross/grid/PicrossGridUI.java Modified: trunk/src/picross/grid/PicrossGridController.java =================================================================== --- trunk/src/picross/grid/PicrossGridController.java 2007-06-05 11:32:56 UTC (rev 8) +++ trunk/src/picross/grid/PicrossGridController.java 2007-06-05 14:44:56 UTC (rev 9) @@ -60,6 +60,11 @@ /** Command indicating the grid is filled. */ public static final String GRID_FILLED_CMD = "GRID_FILLED_CMD"; + static final String END_ACTION_CMD = "END_ACTION_CMD"; + + static final String CHECK_CMD = "CHECK_CMD"; + static final String UNCHECK_CMD = "UNCHECK_CMD"; + /*** Static field ***/ /** The class' logger. */ @@ -75,6 +80,27 @@ /** {@inheritDoc} */ public void eventPerformed(SimpleEvent e) { PicrossGridController.log.debug("eventPerformed(" + e + ")"); + + String cmd = e.getCommandName(); + + if (cmd.equals(PicrossGridController.GRID_FILLED_CMD)) { + this.view.disableGrid(); + return; + } + + if (cmd.equals(PicrossGridController.CHECK_CMD)) { + FillCommand command = (FillCommand) e.getCommand(); + this.view.check(command.getRow(), command.getColumn()); + + return; + } + + if (cmd.equals(PicrossGridController.UNCHECK_CMD)) { + FillCommand command = (FillCommand) e.getCommand(); + this.view.uncheck(command.getRow(), command.getColumn()); + + return; + } } /*** Methods implanted from the interface MouseListener ***/ @@ -94,7 +120,10 @@ public void mousePressed(MouseEvent e) { } /** {@inheritDoc} */ - public void mouseReleased(MouseEvent e) { } + public void mouseReleased(MouseEvent e) { + PicrossGridController.log.debug("mouseReleased()"); + this.fireEventPerformed(PicrossGridController.END_ACTION_CMD); + } /*** Methods implanted from the interface MouseMotionListener ***/ @@ -115,16 +144,20 @@ * @param e mouse event to handle */ private void checkAndFill(MouseEvent e) { + //PicrossGridController.log.debug(e); + + if (e.getModifiers() != MouseEvent.BUTTON1_MASK) { + return; + } + Point point = e.getPoint(); if (this.view.isInGrid(point)) { int row = this.view.getRow(point); int column = this.view.getColumn(point); - + this.fireEventPerformed(PicrossGridController.FILL_CMD, new FillCommand(row, column)); - - this.view.fillBox(row, column); } } Modified: trunk/src/picross/grid/PicrossGridMediator.java =================================================================== --- trunk/src/picross/grid/PicrossGridMediator.java 2007-06-05 11:32:56 UTC (rev 8) +++ trunk/src/picross/grid/PicrossGridMediator.java 2007-06-05 14:44:56 UTC (rev 9) @@ -38,7 +38,7 @@ import javax.swing.JPanel; -import org.apache.log4j.Logger; +//import org.apache.log4j.Logger; /** * Picross grid mediator. @@ -49,7 +49,7 @@ /*** Static field ***/ /** Class' logger. */ - private static Logger log = Logger.getLogger(PicrossGridMediator.class); + //private static Logger log = Logger.getLogger(PicrossGridMediator.class); /*** Fields ***/ @@ -73,6 +73,7 @@ PicrossGridController controller = new PicrossGridController(); controller.addSimpleListener(this); + this.addSimpleListener(controller); this.view = new PicrossGridUI(width, height, this.model.getColData(), @@ -86,15 +87,21 @@ /** {@inheritDoc} */ public void eventPerformed(SimpleEvent e) { - PicrossGridMediator.log.debug("eventPerformed(" + 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()); - this.model.checkBox(command.getRow(), command.getColumn()); + return; } + + if (cmd.equals(PicrossGridController.END_ACTION_CMD)) { + this.model.endAction(); + return; + } } /*** Method ***/ @@ -104,6 +111,16 @@ this.fireEventPerformed(PicrossGridController.GRID_FILLED_CMD); } + void check(int row, int column) { + this.fireEventPerformed(PicrossGridController.CHECK_CMD, + new FillCommand(row, column)); + } + + void uncheck(int row, int column) { + this.fireEventPerformed(PicrossGridController.UNCHECK_CMD, + new FillCommand(row, column)); + } + /*** Accessor ***/ /** Modified: trunk/src/picross/grid/PicrossGridModel.java =================================================================== --- trunk/src/picross/grid/PicrossGridModel.java 2007-06-05 11:32:56 UTC (rev 8) +++ trunk/src/picross/grid/PicrossGridModel.java 2007-06-05 14:44:56 UTC (rev 9) @@ -58,7 +58,7 @@ private boolean[][] data; /** The grid as filled by the user. */ - private boolean[][] checked; + private Boolean[][] checked; /** Columns hints. */ private int[][] colData; @@ -66,6 +66,8 @@ /** Rows hints. */ private int[][] rowData; + private Boolean lastChecked = null; + /*** Constructor ***/ /** @@ -78,14 +80,18 @@ this.mediator = mediator; this.data = data; - this.checked = new boolean[this.data.length][this.data[0].length]; + this.checked = new Boolean[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] = Boolean.valueOf(false); + } + } + List<List<Integer>> colRawData = new ArrayList<List<Integer>>(); int max = 0; for (boolean[] col : data) { - //PicrossGridModel.log.debug("col.length : " + col.length); - List<Integer> current = new ArrayList<Integer>(); int chain = 0; @@ -105,8 +111,6 @@ current.add(0); } - //PicrossGridModel.log.debug("current : " + current); - int currentSize = current.size(); if (currentSize > max) { @@ -116,53 +120,20 @@ colRawData.add(current); } - //PicrossGridModel.log.debug("data.length : " + data.length); - //PicrossGridModel.log.debug("max : " + max); - this.colData = new int[data.length][max]; for (int i = 0; i < max; i++) { - //PicrossGridModel.log.debug("i = " + i); - for (int j = 0; j < colRawData.size(); j++) { - //PicrossGridModel.log.debug("colonne courante.size() : " - //+ colRawData.get(j).size()); - if (colRawData.get(j).size() >= (max - i)) { - //PicrossGridModel.log.debug("this.colData[" + j + "][" - //+ (max - 1 - i) + "] = " + "colData.get(" + j + ").get(" - //+ (colRawData.get(j).size() - max + i) + ") = " - //+ colRawData.get(j).get(colRawData.get(j).size() - //- max + i)); - this.colData[j][max - 1 - i] = colRawData.get(j).get(colRawData.get(j).size() - max + i); } else { - //PicrossGridModel.log.debug("this.colData[" + j + "][" - //+ (max - 1 - i) + "] = -1"); - this.colData[j][max - 1 - i] = -1; } } } - /* - System.out.println("this.colData : "); - - for (int i = this.colData[0].length - 1; i >= 0; i--) { - for (int j = 0; j < this.colData.length; j++) { - if (this.colData[j][i] == -1) { - System.out.print(" "); - } else { - System.out.print(this.colData[j][i]); - } - } - - System.out.println(""); - } - */ - /***/ List<List<Integer>> rowRawData = new ArrayList<List<Integer>>(); max = 0; @@ -192,58 +163,21 @@ max = currentSize; } - //PicrossGridModel.log.debug("current : " + current); rowRawData.add(current); } - /**/ - - //PicrossGridModel.log.debug("data.length : " + data[0].length); - //PicrossGridModel.log.debug("max : " + max); - this.rowData = new int[data[0].length][max]; for (int i = 0; i < max; i++) { - //PicrossGridModel.log.debug("i = " + i); - for (int j = 0; j < rowRawData.size(); j++) { - //PicrossGridModel.log.debug("j = " + j); - //PicrossGridModel.log.debug("ligne courante.size() : " - //+ rowRawData.get(j).size()); - if (rowRawData.get(j).size() >= (max - i)) { - //int index = max - 1 - i; int index = i - Math.abs(rowRawData.get(j).size() - max); - - //System.out.print("this.rowData[" + j + "][" + i + "] = " - //+ "rowRawData.get(" + j + ").get(" + index + ") = "); - //System.out.println(rowRawData.get(j).get(index)); - this.rowData[j][i] = rowRawData.get(j).get(index); } else { - //PicrossGridModel.log.debug("this.rowData[" + j + "][" - //+ i + "] = -1"); - this.rowData[j][i] = -1; } } } - - /* - System.out.println("this.rowData : "); - - for (int i = 0; i < this.rowData.length; i++) { - for (int j = 0; j < this.rowData[i].length; j++) { - if (this.rowData[i][j] == -1) { - System.out.print(" "); - } else { - System.out.print(this.rowData[i][j]); - } - } - - System.out.println(""); - } - */ } /*** Method ***/ @@ -255,22 +189,42 @@ * @param column column of the box */ void checkBox(int row, int column) { - this.checked[row][column] = true; + if (this.lastChecked == null || + !this.lastChecked.equals(this.checked[row][column])) { - boolean completed = true; + if (!this.checked[row][column]) { + //PicrossGridModel.log.debug("checking " + row + "," + column); - 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; + this.checked[row][column] = true; + this.lastChecked = this.checked[row][column]; + + this.mediator.check(row, column); + + 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(); + } + } else { + this.checked[row][column] = false; + this.lastChecked = this.checked[row][column]; + + this.mediator.uncheck(row, column); } } + } - if (completed) { - this.mediator.congratulations(); - } + void endAction() { + this.lastChecked = null; } /*** Accessors ***/ Modified: trunk/src/picross/grid/PicrossGridUI.java =================================================================== --- trunk/src/picross/grid/PicrossGridUI.java 2007-06-05 11:32:56 UTC (rev 8) +++ trunk/src/picross/grid/PicrossGridUI.java 2007-06-05 14:44:56 UTC (rev 9) @@ -114,6 +114,8 @@ /** Filled boxes. */ private boolean[][] filled; + private transient PicrossGridController controller; + /*** Constructor ***/ /** @@ -131,9 +133,11 @@ PicrossGridController controller) { super(); - this.addMouseListener(controller); - this.addMouseMotionListener(controller); + this.controller = controller; + this.addMouseListener(this.controller); + this.addMouseMotionListener(this.controller); + this.setOpaque(true); this.setBackground(Color.WHITE); @@ -214,13 +218,20 @@ 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); + PicrossGridUI.BOX_WIDTH, + PicrossGridUI.BOX_HEIGHT); + + g.setColor(Color.WHITE); + g.fillRect(x + 1, y + 1, + PicrossGridUI.BOX_WIDTH - 1, + PicrossGridUI.BOX_HEIGHT - 1); } x += PicrossGridUI.BOX_WIDTH; @@ -272,16 +283,20 @@ return (int) (x / PicrossGridUI.BOX_WIDTH); } + + void disableGrid() { + this.removeMouseListener(this.controller); + this.removeMouseMotionListener(this.controller); + } - /** - * Fills a box in the grid. - * - * @param row row of the box - * @param column column of the box - */ - void fillBox(int row, int column) { + void check(int row, int column) { this.filled[row][column] = true; this.repaint(); } + + void uncheck(int row, int column) { + this.filled[row][column] = false; + 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-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-05 08:52:11
|
Revision: 7 http://picross.svn.sourceforge.net/picross/?rev=7&view=rev Author: yvan_norsa Date: 2007-06-05 01:52:12 -0700 (Tue, 05 Jun 2007) Log Message: ----------- handles mouse drags Modified Paths: -------------- trunk/src/picross/grid/PicrossGridController.java trunk/src/picross/grid/PicrossGridUI.java Modified: trunk/src/picross/grid/PicrossGridController.java =================================================================== --- trunk/src/picross/grid/PicrossGridController.java 2007-06-05 08:35:50 UTC (rev 6) +++ trunk/src/picross/grid/PicrossGridController.java 2007-06-05 08:52:12 UTC (rev 7) @@ -40,6 +40,7 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; import org.apache.log4j.Logger; @@ -48,7 +49,8 @@ * * @author Y. Norsa */ -class PicrossGridController extends Controller implements MouseListener { +class PicrossGridController extends Controller implements MouseListener, + MouseMotionListener { /*** Constant ***/ /** Fill command. */ @@ -75,17 +77,7 @@ /** {@inheritDoc} */ public void mouseClicked(MouseEvent e) { - Point point = e.getPoint(); - - if (this.view.isInGrid(point)) { - int row = this.view.getRow(point); - int column = this.view.getColumn(point); - - this.fireEventPerformed(PicrossGridController.FILL_CMD, - new FillCommand(row, column)); - - this.view.fillBox(row, column); - } + this.checkAndFill(e); } /** {@inheritDoc} */ @@ -100,6 +92,38 @@ /** {@inheritDoc} */ public void mouseReleased(MouseEvent e) { } + /*** Methods implanted from the interface MouseMotionListener ***/ + + /** {@inheritDoc} */ + public void mouseDragged(MouseEvent e) { + this.checkAndFill(e); + } + + /** {@inheritDoc} */ + public void mouseMoved(MouseEvent e) { } + + /*** Method ***/ + + /** + * Checks if the mouse current click's location is inside the grid + * and eventually fills the corresponding box. + * + * @param e mouse event to handle + */ + private void checkAndFill(MouseEvent e) { + Point point = e.getPoint(); + + if (this.view.isInGrid(point)) { + int row = this.view.getRow(point); + int column = this.view.getColumn(point); + + this.fireEventPerformed(PicrossGridController.FILL_CMD, + new FillCommand(row, column)); + + this.view.fillBox(row, column); + } + } + /*** Accessor ***/ /** Modified: trunk/src/picross/grid/PicrossGridUI.java =================================================================== --- trunk/src/picross/grid/PicrossGridUI.java 2007-06-05 08:35:50 UTC (rev 6) +++ trunk/src/picross/grid/PicrossGridUI.java 2007-06-05 08:52:12 UTC (rev 7) @@ -38,8 +38,6 @@ import java.awt.Graphics; import java.awt.Point; -import java.awt.event.MouseListener; - import javax.swing.JPanel; import org.apache.log4j.Logger; @@ -125,14 +123,16 @@ * @param height grid height * @param colData columns hints * @param rowData rows hints + * @param controller controller for the grid */ PicrossGridUI(int width, int height, int[][] colData, int[][] rowData, - MouseListener controller) { + PicrossGridController controller) { super(); this.addMouseListener(controller); + this.addMouseMotionListener(controller); this.setOpaque(true); this.setBackground(Color.WHITE); @@ -157,6 +157,9 @@ this.bottomBoundary = this.topBoundary + (this.height * PicrossGridUI.BOX_HEIGHT); + PicrossGridUI.log.debug("rightBoundary : " + this.rightBoundary); + PicrossGridUI.log.debug("bottomBoundary : " + this.bottomBoundary); + this.setPreferredSize(new Dimension(this.rightBoundary + PicrossGridUI.RIGHT_SPACE, this.bottomBoundary @@ -236,11 +239,13 @@ * @return boolean telling if the point is inside the grid */ boolean isInGrid(Point point) { + //PicrossGridUI.log.debug("isInGrid(" + point + ")"); + double x = point.getX(); double y = point.getY(); - return (x >= this.leftBoundary && x <= this.rightBoundary - && y >= this.topBoundary && y <= this.bottomBoundary); + return (x >= this.leftBoundary && x < this.rightBoundary + && y >= this.topBoundary && y < this.bottomBoundary); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2007-06-05 08:35:50
|
Revision: 6 http://picross.svn.sourceforge.net/picross/?rev=6&view=rev Author: yvan_norsa Date: 2007-06-05 01:35:50 -0700 (Tue, 05 Jun 2007) Log Message: ----------- first interaction handling Modified Paths: -------------- trunk/src/picross/PicrossModel.java trunk/src/picross/grid/PicrossGridMediator.java trunk/src/picross/grid/PicrossGridUI.java Added Paths: ----------- trunk/src/picross/grid/FillCommand.java trunk/src/picross/grid/PicrossGridController.java Modified: trunk/src/picross/PicrossModel.java =================================================================== --- trunk/src/picross/PicrossModel.java 2007-06-05 07:37:02 UTC (rev 5) +++ trunk/src/picross/PicrossModel.java 2007-06-05 08:35:50 UTC (rev 6) @@ -59,15 +59,22 @@ this.data = new boolean[this.width][this.height]; - this.data[0][0] = true; - this.data[0][4] = 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[2][2] = 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[4][0] = true; - this.data[4][4] = true; + this.data[3][4] = true; + this.data[4][1] = true; + this.data[4][3] = true; } /*** Accessors ***/ Added: trunk/src/picross/grid/FillCommand.java =================================================================== --- trunk/src/picross/grid/FillCommand.java (rev 0) +++ trunk/src/picross/grid/FillCommand.java 2007-06-05 08:35:50 UTC (rev 6) @@ -0,0 +1,92 @@ +/* + * $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 containing informations about the box to fill. + * + * @author Y. Norsa + */ +class FillCommand extends Command { + /*** Fields ***/ + + /** Row of the box to fill. */ + private int row; + + /** Column of the box to fill. */ + private int column; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param row row of the box to fill + * @param column column of the box to fill + */ + FillCommand(int row, int column) { + this.row = row; + this.column = column; + } + + /*** Method overloaded from the class Command ***/ + + /** {@inheritDoc} */ + public String toString() { + return this.row + ", " + this.column; + } + + /*** Accessors ***/ + + /** + * Returns the row. + * + * @return row of the box to fill + */ + int getRow() { + return this.row; + } + + /** + * Returns the column. + * + * @return column of the box to fill + */ + int getColumn() { + return this.column; + } +} + Property changes on: trunk/src/picross/grid/FillCommand.java ___________________________________________________________________ Name: svn:keywords + Id Added: trunk/src/picross/grid/PicrossGridController.java =================================================================== --- trunk/src/picross/grid/PicrossGridController.java (rev 0) +++ trunk/src/picross/grid/PicrossGridController.java 2007-06-05 08:35:50 UTC (rev 6) @@ -0,0 +1,114 @@ +/* + * $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.Controller; +import fr.cle.mmvcs.SimpleEvent; + +import java.awt.Point; + +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +import org.apache.log4j.Logger; + +/** + * Grid controller. + * + * @author Y. Norsa + */ +class PicrossGridController extends Controller implements MouseListener { + /*** Constant ***/ + + /** Fill command. */ + static final String FILL_CMD = "FILL_CMD"; + + /*** Static field ***/ + + /** The class' logger. */ + private static Logger log = Logger.getLogger(PicrossGridController.class); + + /*** Field ***/ + + /** The view to which the controller is attached. */ + private PicrossGridUI view = null; + + /*** Method overloaded from the class Controller ***/ + + /** {@inheritDoc} */ + public void eventPerformed(SimpleEvent e) { + PicrossGridController.log.debug("eventPerformed(" + e + ")"); + } + + /*** Methods implanted from the interface MouseListener ***/ + + /** {@inheritDoc} */ + public void mouseClicked(MouseEvent e) { + Point point = e.getPoint(); + + if (this.view.isInGrid(point)) { + int row = this.view.getRow(point); + int column = this.view.getColumn(point); + + this.fireEventPerformed(PicrossGridController.FILL_CMD, + new FillCommand(row, column)); + + this.view.fillBox(row, column); + } + } + + /** {@inheritDoc} */ + public void mouseEntered(MouseEvent e) { } + + /** {@inheritDoc} */ + public void mouseExited(MouseEvent e) { } + + /** {@inheritDoc} */ + public void mousePressed(MouseEvent e) { } + + /** {@inheritDoc} */ + public void mouseReleased(MouseEvent e) { } + + /*** Accessor ***/ + + /** + * Allows to set the view. + * + * @param view view to which this controller is attached + */ + void setView(PicrossGridUI view) { + this.view = view; + } +} + Property changes on: trunk/src/picross/grid/PicrossGridController.java ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/src/picross/grid/PicrossGridMediator.java =================================================================== --- trunk/src/picross/grid/PicrossGridMediator.java 2007-06-05 07:37:02 UTC (rev 5) +++ trunk/src/picross/grid/PicrossGridMediator.java 2007-06-05 08:35:50 UTC (rev 6) @@ -54,7 +54,7 @@ /*** Field ***/ /** The grid view. */ - private JPanel view; + private PicrossGridUI view; /*** Constructor ***/ @@ -68,10 +68,16 @@ public PicrossGridMediator(int width, int height, boolean[][] data) { PicrossGridModel model = new PicrossGridModel(data); + PicrossGridController controller = new PicrossGridController(); + controller.addSimpleListener(this); + this.addSimpleListener(controller); + this.view = new PicrossGridUI(width, height, model.getColData(), model.getRowData(), - data); + controller); + + controller.setView(this.view); } /*** Method overloaded from the class Mediateur ***/ Modified: trunk/src/picross/grid/PicrossGridUI.java =================================================================== --- trunk/src/picross/grid/PicrossGridUI.java 2007-06-05 07:37:02 UTC (rev 5) +++ trunk/src/picross/grid/PicrossGridUI.java 2007-06-05 08:35:50 UTC (rev 6) @@ -36,7 +36,10 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; +import java.awt.Point; +import java.awt.event.MouseListener; + import javax.swing.JPanel; import org.apache.log4j.Logger; @@ -93,16 +96,26 @@ private int height; /** Columns hints. */ - private int[][] listePassages; + private int[][] colData; /** Rows hints. */ - private int[][] listePassages2; + private int[][] rowData; - private boolean[][] data; - - /** Amount of space left before columns hints and the grid. */ + /** Amount of space left before the grid. */ private int leftBoundary; + /** Position of the right end of the grid. */ + private int rightBoundary; + + /** Amount of space left before the grid. */ + private int topBoundary; + + /** Position of the bottom end of the grid. */ + private int bottomBoundary; + + /** Filled boxes. */ + private boolean[][] filled; + /*** Constructor ***/ /** @@ -116,32 +129,37 @@ PicrossGridUI(int width, int height, int[][] colData, int[][] rowData, - boolean[][] data) { + MouseListener controller) { super(); + this.addMouseListener(controller); + this.setOpaque(true); this.setBackground(Color.WHITE); this.width = width; this.height = height; - this.listePassages = colData; - this.listePassages2 = rowData; + this.colData = colData; + this.rowData = rowData; - this.data = data; + this.filled = new boolean[this.width][this.height]; this.leftBoundary = - this.listePassages2[0].length * PicrossGridUI.ROW_HINT_WIDTH; + this.rowData[0].length * PicrossGridUI.ROW_HINT_WIDTH; - this.setPreferredSize(new Dimension(this.leftBoundary - + (this.width - * PicrossGridUI.BOX_WIDTH) + this.rightBoundary = this.leftBoundary + + (this.width * PicrossGridUI.BOX_WIDTH); + + this.topBoundary = PicrossGridUI.TOP_HINTS + + (this.colData[0].length * PicrossGridUI.COL_HINT_HEIGHT); + + this.bottomBoundary = this.topBoundary + + (this.height * PicrossGridUI.BOX_HEIGHT); + + this.setPreferredSize(new Dimension(this.rightBoundary + PicrossGridUI.RIGHT_SPACE, - PicrossGridUI.TOP_HINTS - + (this.listePassages[0].length - * PicrossGridUI.COL_HINT_HEIGHT) - + (this.height - * PicrossGridUI.BOX_HEIGHT) + this.bottomBoundary + PicrossGridUI.BOTTOM_SPACE)); } @@ -154,12 +172,12 @@ int x = 0; int y = PicrossGridUI.TOP_HINTS; - for (int i = this.listePassages[0].length - 1; i >= 0; i--) { + for (int i = this.colData[0].length - 1; i >= 0; i--) { x = this.leftBoundary + PicrossGridUI.COL_HINT_WIDTH; - for (int j = 0; j < this.listePassages.length; j++) { - if (this.listePassages[j][i] != -1) { - g.drawString(String.valueOf(this.listePassages[j][i]), + for (int j = 0; j < this.colData.length; j++) { + if (this.colData[j][i] != -1) { + g.drawString(String.valueOf(this.colData[j][i]), x, y); } @@ -171,12 +189,12 @@ int gridY = y; - for (int i = 0; i < this.listePassages2.length; i++) { + for (int i = 0; i < this.rowData.length; i++) { x = 0; - for (int j = 0; j < this.listePassages2[i].length; j++) { - if (this.listePassages2[i][j] != -1) { - g.drawString(String.valueOf(this.listePassages2[i][j]), + for (int j = 0; j < this.rowData[i].length; j++) { + if (this.rowData[i][j] != -1) { + g.drawString(String.valueOf(this.rowData[i][j]), x, y + PicrossGridUI.ROW_HINT_HEIGHT); } @@ -192,13 +210,14 @@ x = this.leftBoundary; for (int j = 0; j < this.width; j++) { - if (!this.data[j][i]) { - g.drawRect(x, y, - PicrossGridUI.BOX_WIDTH, PicrossGridUI.BOX_HEIGHT); - } else { + if (this.filled[i][j]) { g.fillRect(x, y, PicrossGridUI.BOX_WIDTH, PicrossGridUI.BOX_HEIGHT); + } else { + g.drawRect(x, y, + PicrossGridUI.BOX_WIDTH, + PicrossGridUI.BOX_HEIGHT); } x += PicrossGridUI.BOX_WIDTH; @@ -207,5 +226,57 @@ y += PicrossGridUI.BOX_HEIGHT; } } + + /*** Methods ***/ + + /** + * This methods tells wether a point is inside the grid or not. + * + * @param point point to be tested + * @return boolean telling if the point is inside the grid + */ + boolean isInGrid(Point point) { + double x = point.getX(); + double y = point.getY(); + + return (x >= this.leftBoundary && x <= this.rightBoundary + && y >= this.topBoundary && y <= this.bottomBoundary); + } + + /** + * Allows to get the row number corresponding to a point inside the grid. + * + * @param point a point inside the grid + * @return the row corresponding to the point + */ + int getRow(Point point) { + double y = point.getY() - this.topBoundary; + + return (int) (y / PicrossGridUI.BOX_HEIGHT); + } + + /** + * Allows to get the column number corresponding to a point + * inside the grid. + * + * @param point a point inside the grid + * @return the column corresponding to the point + */ + int getColumn(Point point) { + double x = point.getX() - this.leftBoundary; + + return (int) (x / PicrossGridUI.BOX_WIDTH); + } + + /** + * Fills a box in the grid. + * + * @param row row of the box + * @param column column of the box + */ + void fillBox(int row, int column) { + this.filled[row][column] = true; + 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-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 06:53:16
|
Revision: 4 http://picross.svn.sourceforge.net/picross/?rev=4&view=rev Author: yvan_norsa Date: 2007-06-04 23:53:14 -0700 (Mon, 04 Jun 2007) Log Message: ----------- removed trailing spaces Modified Paths: -------------- trunk/src/picross/Picross.java trunk/src/picross/PicrossMediator.java trunk/src/picross/PicrossModel.java trunk/src/picross/PicrossUI.java trunk/src/picross/grid/PicrossGridMediator.java trunk/src/picross/grid/PicrossGridModel.java trunk/src/picross/grid/PicrossGridUI.java Modified: trunk/src/picross/Picross.java =================================================================== --- trunk/src/picross/Picross.java 2007-06-05 06:52:53 UTC (rev 3) +++ trunk/src/picross/Picross.java 2007-06-05 06:53:14 UTC (rev 4) @@ -4,16 +4,16 @@ * 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, + * 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". - * + * "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. + * liability. * * In this respect, the user's attention is drawn to the risks associated * with loading, using, modifying and/or developing or reproducing the @@ -22,9 +22,9 @@ * 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. + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. Modified: trunk/src/picross/PicrossMediator.java =================================================================== --- trunk/src/picross/PicrossMediator.java 2007-06-05 06:52:53 UTC (rev 3) +++ trunk/src/picross/PicrossMediator.java 2007-06-05 06:53:14 UTC (rev 4) @@ -4,16 +4,16 @@ * 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, + * 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". - * + * "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. + * liability. * * In this respect, the user's attention is drawn to the risks associated * with loading, using, modifying and/or developing or reproducing the @@ -22,9 +22,9 @@ * 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. + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. Modified: trunk/src/picross/PicrossModel.java =================================================================== --- trunk/src/picross/PicrossModel.java 2007-06-05 06:52:53 UTC (rev 3) +++ trunk/src/picross/PicrossModel.java 2007-06-05 06:53:14 UTC (rev 4) @@ -4,16 +4,16 @@ * 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, + * 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". - * + * "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. + * liability. * * In this respect, the user's attention is drawn to the risks associated * with loading, using, modifying and/or developing or reproducing the @@ -22,9 +22,9 @@ * 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. + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. Modified: trunk/src/picross/PicrossUI.java =================================================================== --- trunk/src/picross/PicrossUI.java 2007-06-05 06:52:53 UTC (rev 3) +++ trunk/src/picross/PicrossUI.java 2007-06-05 06:53:14 UTC (rev 4) @@ -4,16 +4,16 @@ * 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, + * 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". - * + * "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. + * liability. * * In this respect, the user's attention is drawn to the risks associated * with loading, using, modifying and/or developing or reproducing the @@ -22,9 +22,9 @@ * 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. + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. Modified: trunk/src/picross/grid/PicrossGridMediator.java =================================================================== --- trunk/src/picross/grid/PicrossGridMediator.java 2007-06-05 06:52:53 UTC (rev 3) +++ trunk/src/picross/grid/PicrossGridMediator.java 2007-06-05 06:53:14 UTC (rev 4) @@ -4,16 +4,16 @@ * 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, + * 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". - * + * "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. + * liability. * * In this respect, the user's attention is drawn to the risks associated * with loading, using, modifying and/or developing or reproducing the @@ -22,9 +22,9 @@ * 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. + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. Modified: trunk/src/picross/grid/PicrossGridModel.java =================================================================== --- trunk/src/picross/grid/PicrossGridModel.java 2007-06-05 06:52:53 UTC (rev 3) +++ trunk/src/picross/grid/PicrossGridModel.java 2007-06-05 06:53:14 UTC (rev 4) @@ -4,16 +4,16 @@ * 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, + * 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". - * + * "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. + * liability. * * In this respect, the user's attention is drawn to the risks associated * with loading, using, modifying and/or developing or reproducing the @@ -22,9 +22,9 @@ * 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. + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. Modified: trunk/src/picross/grid/PicrossGridUI.java =================================================================== --- trunk/src/picross/grid/PicrossGridUI.java 2007-06-05 06:52:53 UTC (rev 3) +++ trunk/src/picross/grid/PicrossGridUI.java 2007-06-05 06:53:14 UTC (rev 4) @@ -4,16 +4,16 @@ * 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, + * 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". - * + * "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. + * liability. * * In this respect, the user's attention is drawn to the risks associated * with loading, using, modifying and/or developing or reproducing the @@ -22,9 +22,9 @@ * 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. + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2007-06-05 06:52:52
|
Revision: 3 http://picross.svn.sourceforge.net/picross/?rev=3&view=rev Author: yvan_norsa Date: 2007-06-04 23:52:53 -0700 (Mon, 04 Jun 2007) Log Message: ----------- packages javadoc Added Paths: ----------- trunk/src/picross/grid/package.html trunk/src/picross/package.html Added: trunk/src/picross/grid/package.html =================================================================== --- trunk/src/picross/grid/package.html (rev 0) +++ trunk/src/picross/grid/package.html 2007-06-05 06:52:53 UTC (rev 3) @@ -0,0 +1,12 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <!-- + $Id$ + --> + </head> + + <body bgcolor="white"> + Classes modelling the puzzle grid. + </body> +</html> Property changes on: trunk/src/picross/grid/package.html ___________________________________________________________________ Name: svn:keywords + Id Added: trunk/src/picross/package.html =================================================================== --- trunk/src/picross/package.html (rev 0) +++ trunk/src/picross/package.html 2007-06-05 06:52:53 UTC (rev 3) @@ -0,0 +1,12 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <!-- + $Id$ + --> + </head> + + <body bgcolor="white"> + Provides the base classes for Picross. + </body> +</html> Property changes on: trunk/src/picross/package.html ___________________________________________________________________ Name: svn:keywords + Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |