[Picross-commit] SF.net SVN: picross: [21] trunk/src/picross
Status: Pre-Alpha
Brought to you by:
yvan_norsa
From: <yva...@us...> - 2007-06-07 11:29:19
|
Revision: 21 http://picross.svn.sourceforge.net/picross/?rev=21&view=rev Author: yvan_norsa Date: 2007-06-07 04:29:21 -0700 (Thu, 07 Jun 2007) Log Message: ----------- classes renaming Modified Paths: -------------- trunk/src/picross/PicrossMediator.java trunk/src/picross/app/PicrossApp.java Added Paths: ----------- trunk/src/picross/app/PicrossAppUI.java trunk/src/picross/grid/GridController.java trunk/src/picross/grid/GridMediator.java trunk/src/picross/grid/GridModel.java trunk/src/picross/grid/GridUI.java Removed Paths: ------------- trunk/src/picross/app/PicrossFrame.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/PicrossMediator.java =================================================================== --- trunk/src/picross/PicrossMediator.java 2007-06-07 11:18:40 UTC (rev 20) +++ trunk/src/picross/PicrossMediator.java 2007-06-07 11:29:21 UTC (rev 21) @@ -40,8 +40,8 @@ //import org.apache.log4j.Logger; -import picross.grid.PicrossGridController; -import picross.grid.PicrossGridMediator; +import picross.grid.GridController; +import picross.grid.GridMediator; import picross.menus.MainMenuController; import picross.menus.MainMenuMediator; @@ -104,9 +104,9 @@ if (cmd.equals(MainMenuController.PLAY_CMD)) { PicrossModel model = new PicrossModel(); - PicrossGridMediator grid = - new PicrossGridMediator(model.getWidth(), model.getHeight(), - model.getData()); + GridMediator grid = new GridMediator(model.getWidth(), + model.getHeight(), + model.getData()); grid.addSimpleListener(this); this.view.setContent(grid.getView()); @@ -119,7 +119,7 @@ return; } - if (cmd.equals(PicrossGridController.GRID_FILLED_CMD)) { + if (cmd.equals(GridController.GRID_FILLED_CMD)) { this.fireEventPerformed(PicrossController.MESSAGE_CMD, BundleHelper.getString(this, "victory")); return; Modified: trunk/src/picross/app/PicrossApp.java =================================================================== --- trunk/src/picross/app/PicrossApp.java 2007-06-07 11:18:40 UTC (rev 20) +++ trunk/src/picross/app/PicrossApp.java 2007-06-07 11:29:21 UTC (rev 21) @@ -55,7 +55,7 @@ /** Constructor. */ private PicrossApp() { PropertyConfigurator.configure(PicrossApp.LOG4J_CONFIG); - new PicrossMediator(new PicrossFrame()); + new PicrossMediator(new PicrossAppUI()); } /*** Main method ***/ Copied: trunk/src/picross/app/PicrossAppUI.java (from rev 20, trunk/src/picross/app/PicrossFrame.java) =================================================================== --- trunk/src/picross/app/PicrossAppUI.java (rev 0) +++ trunk/src/picross/app/PicrossAppUI.java 2007-06-07 11:29:21 UTC (rev 21) @@ -0,0 +1,95 @@ +/* + * $Id$ + * + * Copyright (c) 2007 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.app; + +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JPanel; + +import picross.PicrossUI; + +/** + * Main window of the application version. + * + * @author Y. Norsa + */ +public final class PicrossAppUI extends JFrame implements PicrossUI { + /*** Constants ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = -6091243469021691734L; + + /** Main menu class. */ + private static final String MAIN_MENU_CLASS = "picross.app.MainMenuAppUI"; + + /*** Constructor ***/ + + /** Constructor. */ + public PicrossAppUI() { + super("Picross"); + + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setVisible(true); + } + + /*** Methods implanted from the interface PicrossUI ***/ + + /** {@inheritDoc} */ + public void setContent(JPanel content) { + this.setContentPane(content); + this.pack(); + } + + /** {@inheritDoc} */ + public void displayMessage(String msg) { + JOptionPane.showMessageDialog(this, msg); + } + + /** {@inheritDoc} */ + public void displayError(String msg) { + JOptionPane.showMessageDialog(this, msg, + "Picross", JOptionPane.ERROR_MESSAGE); + } + + /** {@inheritDoc} */ + public void exit() { + this.dispose(); + } + + /** {@inheritDoc} */ + public String getMainMenuClass() { + return PicrossAppUI.MAIN_MENU_CLASS; + } +} + Deleted: trunk/src/picross/app/PicrossFrame.java =================================================================== --- trunk/src/picross/app/PicrossFrame.java 2007-06-07 11:18:40 UTC (rev 20) +++ trunk/src/picross/app/PicrossFrame.java 2007-06-07 11:29:21 UTC (rev 21) @@ -1,95 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.app; - -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.JPanel; - -import picross.PicrossUI; - -/** - * Main window of the application version. - * - * @author Y. Norsa - */ -public final class PicrossFrame extends JFrame implements PicrossUI { - /*** Constants ***/ - - /** Serialisation ID. */ - private static final long serialVersionUID = -6091243469021691734L; - - /** Main menu class. */ - private static final String MAIN_MENU_CLASS = "picross.app.MainMenuAppUI"; - - /*** Constructor ***/ - - /** Constructor. */ - public PicrossFrame() { - super("Picross"); - - this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - this.setVisible(true); - } - - /*** Methods implanted from the interface PicrossUI ***/ - - /** {@inheritDoc} */ - public void setContent(JPanel content) { - this.setContentPane(content); - this.pack(); - } - - /** {@inheritDoc} */ - public void displayMessage(String msg) { - JOptionPane.showMessageDialog(this, msg); - } - - /** {@inheritDoc} */ - public void displayError(String msg) { - JOptionPane.showMessageDialog(this, msg, - "Picross", JOptionPane.ERROR_MESSAGE); - } - - /** {@inheritDoc} */ - public void exit() { - this.dispose(); - } - - /** {@inheritDoc} */ - public String getMainMenuClass() { - return PicrossFrame.MAIN_MENU_CLASS; - } -} - Copied: trunk/src/picross/grid/GridController.java (from rev 19, trunk/src/picross/grid/PicrossGridController.java) =================================================================== --- trunk/src/picross/grid/GridController.java (rev 0) +++ trunk/src/picross/grid/GridController.java 2007-06-07 11:29:21 UTC (rev 21) @@ -0,0 +1,229 @@ +/* + * $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 java.awt.event.MouseMotionListener; + +//import org.apache.log4j.Logger; + +/** + * Grid controller. + * + * @author Y. Norsa + */ +public final class GridController 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"; + + /** 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"; + + /** Checking a box. */ + static final int CHECK_ACTION = 0; + + /** Crossing a box. */ + static final int CROSS_ACTION = 1; + + /*** Static field ***/ + + /** The class' logger. */ + //private static Logger log = Logger.getLogger(GridController.class); + + /*** Field ***/ + + /** The view to which the controller is attached. */ + private GridUI view = null; + + /*** Method overloaded from the class Controller ***/ + + /** {@inheritDoc} */ + public void eventPerformed(SimpleEvent e) { + //GridController.log.debug("eventPerformed(" + e + ")"); + + String cmd = e.getCommandName(); + + if (cmd.equals(GridController.GRID_FILLED_CMD)) { + this.view.disableGrid(); + return; + } + + if (cmd.equals(GridController.CHECK_CMD)) { + FillCommand command = (FillCommand) e.getCommand(); + this.view.check(command.getRow(), command.getColumn(), + command.getType()); + + return; + } + + if (cmd.equals(GridController.UNCHECK_CMD)) { + FillCommand command = (FillCommand) e.getCommand(); + this.view.uncheck(command.getRow(), command.getColumn(), + command.getType()); + + return; + } + } + + /*** Methods implanted from the interface MouseListener ***/ + + /** {@inheritDoc} */ + public void mouseClicked(MouseEvent e) { } + + /** {@inheritDoc} */ + public void mouseEntered(MouseEvent e) { } + + /** {@inheritDoc} */ + public void mouseExited(MouseEvent e) { } + + /** {@inheritDoc} */ + public void mousePressed(MouseEvent e) { + this.view.rolloverEnded(); + } + + /** {@inheritDoc} */ + public void mouseReleased(MouseEvent e) { + //GridController.log.debug("mouseReleased()"); + this.checkAndFill(e); + this.fireEventPerformed(GridController.END_ACTION_CMD); + } + + /*** Methods implanted from the interface MouseMotionListener ***/ + + /** {@inheritDoc} */ + public void mouseDragged(MouseEvent e) { + this.checkAndFill(e); + } + + /** {@inheritDoc} */ + public void mouseMoved(MouseEvent e) { + //GridController.log.debug(e.getPoint()); + + Point point = e.getPoint(); + + if (this.view.isInGrid(point)) { + int row = this.view.getRow(point); + int column = this.view.getColumn(point); + + this.view.setRollover(row, column); + } else { + this.view.rolloverEnded(); + } + + } + + /*** Methods ***/ + + /** + * 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) { + //GridController.log.debug(e); + + int modifiers = e.getModifiers(); + + if (modifiers != MouseEvent.BUTTON1_MASK + && modifiers != MouseEvent.BUTTON3_MASK) { + + return; + } + + Point point = e.getPoint(); + + if (this.view.isInGrid(point)) { + int row = this.view.getRow(point); + int column = this.view.getColumn(point); + int type = GridController.modifiersToType(modifiers); + + //GridController.log.debug("type : " + type); + + this.fireEventPerformed(GridController.FILL_CMD, + 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 GridController.CHECK_ACTION; + + case MouseEvent.BUTTON3_MASK: + return GridController.CROSS_ACTION; + + default: + return -1; + } + } + + /*** Accessor ***/ + + /** + * Allows to set the view. + * + * @param view view to which this controller is attached + */ + void setView(GridUI view) { + this.view = view; + } +} + Added: trunk/src/picross/grid/GridMediator.java =================================================================== --- trunk/src/picross/grid/GridMediator.java (rev 0) +++ trunk/src/picross/grid/GridMediator.java 2007-06-07 11:29:21 UTC (rev 21) @@ -0,0 +1,148 @@ +/* + * $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.Mediateur; +import fr.cle.mmvcs.SimpleEvent; + +import javax.swing.JPanel; + +//import org.apache.log4j.Logger; + +/** + * Picross grid mediator. + * + * @author Y. Norsa + */ +public final class GridMediator extends Mediateur { + /*** Static field ***/ + + /** Class' logger. */ + //private static Logger log = Logger.getLogger(GridMediator.class); + + /*** Fields ***/ + + /** The grid model. */ + private GridModel model; + + /** The grid view. */ + private GridUI view; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param width grid width + * @param height grid height + * @param data grid content + */ + public GridMediator(int width, int height, boolean[][] data) { + this.model = new GridModel(this, data); + + GridController controller = new GridController(); + controller.addSimpleListener(this); + this.addSimpleListener(controller); + + this.view = new GridUI(width, height, + this.model.getColData(), + this.model.getRowData(), + controller); + + controller.setView(this.view); + } + + /*** Method overloaded from the class Mediateur ***/ + + /** {@inheritDoc} */ + public void eventPerformed(SimpleEvent e) { + //GridMediator.log.debug("eventPerformed(" + e + ")"); + + String cmd = e.getCommandName(); + + if (cmd.equals(GridController.FILL_CMD)) { + FillCommand command = (FillCommand) e.getCommand(); + this.model.checkBox(command.getRow(), command.getColumn(), + command.getType()); + + return; + } + + if (cmd.equals(GridController.END_ACTION_CMD)) { + this.model.endAction(); + return; + } + } + + /*** Methods ***/ + + /** Tells the application mediator the grid has been filled. */ + void congratulations() { + this.fireEventPerformed(GridController.GRID_FILLED_CMD); + } + + /** + * Checks a box. + * + * @param row row of the box + * @param column column of the box + */ + void check(int row, int column, int type) { + this.fireEventPerformed(GridController.CHECK_CMD, + new FillCommand(row, column, type)); + } + + /** + * Unchecks a box. + * + * @param row row of the box + * @param column column of the box + */ + void uncheck(int row, int column, int type) { + this.fireEventPerformed(GridController.UNCHECK_CMD, + new FillCommand(row, column, type)); + } + + /*** Accessor ***/ + + /** + * Returns the view. + * + * @return the grid view + */ + public JPanel getView() { + return this.view; + } +} + Property changes on: trunk/src/picross/grid/GridMediator.java ___________________________________________________________________ Name: svn:keywords + Id Copied: trunk/src/picross/grid/GridModel.java (from rev 19, trunk/src/picross/grid/PicrossGridModel.java) =================================================================== --- trunk/src/picross/grid/GridModel.java (rev 0) +++ trunk/src/picross/grid/GridModel.java 2007-06-07 11:29:21 UTC (rev 21) @@ -0,0 +1,355 @@ +/* + * $Id$ + * + * Copyright (c) 2007 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.grid; + +import java.util.ArrayList; +import java.util.List; + +//import org.apache.log4j.Logger; + +/** + * The grid model. + * + * @author Y. Norsa + */ +final class GridModel { + /*** Constant ***/ + + /** Empty hint value. */ + static final int EMPTY_HINT = -1; + + /*** Static field ***/ + + /** The class' logger. */ + //private static Logger log = Logger.getLogger(GridModel.class); + + /*** Fields ***/ + + /** This model's mediator. */ + private GridMediator mediator; + + /** The original grid. */ + private boolean[][] data; + + /** The grid as filled by the user. */ + private Box[][] boxes; + + /** + * The last modified box. Permis to know if we are in a serie or + * a single action. + */ + private Box lastModified = null; + + /** Columns hints. */ + private int[][] colData; + + /** Rows hints. */ + private int[][] rowData; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param mediator this model's mediator + * @param data grid content + */ + GridModel(GridMediator mediator, boolean[][] data) { + this.mediator = mediator; + + this.data = data; + this.boxes = new Box[this.data.length][this.data[0].length]; + + 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(); + } + } + + // Grid of columns hints + List<List<Integer>> colHints = new ArrayList<List<Integer>>(); + + // Largest number of hints for a column + int max = 0; + + for (boolean[] col : data) { + List<Integer> current = new ArrayList<Integer>(); + + // Current hint + int chain = 0; + + for (boolean cell : col) { + if (cell) { + chain++; + } else if (chain > 0) { + // We've reached the end of a series of checked boxes + current.add(chain); + chain = 0; + } + } + + if (chain > 0) { + current.add(chain); + } else if (current.size() == 0) { + // If this column is empty, we add a "0" hint + current.add(0); + } + + int currentSize = current.size(); + + if (currentSize > max) { + max = currentSize; + } + + colHints.add(current); + } + + /* + * Final array containing the hints, in the following form : + * + * 1 + * 0 2 1 + * + * Which corresponds to the following grid : + * + * |-----| + * |_|X|_| + * |_|_|X| + * |_|X|_| + * |_|X|_| + * |-----| + */ + this.colData = new int[data.length][max]; + + for (int i = 0; i < max; i++) { + // Minimal number of hints for the current column to be considered + int ref = max - i; + + // Current hint row + int currentRow = ref - 1; + + for (int j = 0; j < colHints.size(); j++) { + List<Integer> currentCol = colHints.get(j); + int size = currentCol.size(); + + if (size >= ref) { + this.colData[j][currentRow] = currentCol.get(size - ref); + } else { + this.colData[j][currentRow] = GridModel.EMPTY_HINT; + } + } + } + + // 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++) { + List<Integer> current = new ArrayList<Integer>(); + + int chain = 0; + + for (int j = 0; j < data.length; j++) { + if (data[j][i]) { + chain++; + } else if (chain > 0) { + current.add(chain); + chain = 0; + } + } + + if (chain > 0) { + current.add(chain); + } else if (current.size() == 0) { + current.add(0); + } + + int currentSize = current.size(); + + if (currentSize > max) { + max = currentSize; + } + + rowHints.add(current); + } + + this.rowData = new int[data[0].length][max]; + int nbRows = rowHints.size(); + + for (int i = 0; i < max; i++) { + int ref = max - i; + + for (int j = 0; j < nbRows; j++) { + List<Integer> currentRow = rowHints.get(j); + int size = currentRow.size(); + + if (size >= ref) { + this.rowData[j][i] = + currentRow.get(i - Math.abs(size - max)); + } else { + this.rowData[j][i] = GridModel.EMPTY_HINT; + } + } + } + } + + /*** Methods ***/ + + /** + * Method called during an action. + * + * @param row row of the box + * @param column column of the box + */ + void checkBox(int row, int column, int type) { + //GridModel.log.debug("checkBox(" + row + ", " + column + ")"); + //GridModel.log.debug("lastModified == null : " + // + (lastModified == null)); + + /* + * If we are trying to check the last box we just checked + * (while dragging), do nothing + */ + if (this.lastModified != null + && this.lastModified == this.boxes[row][column]) { + + return; + } + + if (this.lastModified != null) { + /* + * If we are in a box which is in the same state as our aim + * (if we are in a checks serie and we are on a box which + * is already checked), do nothing + */ + if (this.boxes[row][column].equals(this.lastModified)) { + return; + } + } + + if (this.boxes[row][column].isEmpty() + && (this.lastModified == null || !this.lastModified.isEmpty())) { + + if (type == GridController.CHECK_ACTION) { + this.boxes[row][column].check(); + } else { //if (type == GridController.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())) { + + if (this.boxes[row][column].isChecked()) { + //GridModel.log.debug("checked"); + + if (type == GridController.CHECK_ACTION) { + this.boxes[row][column].empty(); + this.mediator.uncheck(row, column, type); + } else { //if (type == GridController.CROSS_ACTION) { + this.boxes[row][column].cross(); + this.mediator.check(row, column, + GridController.CROSS_ACTION); + } + } else { //if (this.boxes[row][column].isCrossed()) { + //GridModel.log.debug("crossed"); + + if (type == GridController.CROSS_ACTION) { + this.boxes[row][column].empty(); + this.mediator.uncheck(row, column, type); + } else { + //GridModel.log.debug("check()"); + + this.boxes[row][column].check(); + this.mediator.check(row, column, + GridController.CHECK_ACTION); + } + } + } + + this.lastModified = this.boxes[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++) { + boolean isCurrentBoxChecked = this.boxes[i][j].isChecked(); + + if ((this.data[i][j] && !isCurrentBoxChecked) + || (!this.data[i][j] && isCurrentBoxChecked)) { + + completed = false; + break; + } + } + } + + if (completed) { + this.mediator.congratulations(); + } + } + + /** Indicates the current action has come to an end. */ + void endAction() { + //this.lastChecked = null; + this.lastModified = null; + } + + /*** Accessors ***/ + + /** + * Returns the vertical hints. + * + * @return columns hints + */ + int[][] getColData() { + return this.colData; + } + + /** + * Returns the horizontal hints. + * + * @return rows hints + */ + int[][] getRowData() { + return this.rowData; + } +} + Copied: trunk/src/picross/grid/GridUI.java (from rev 19, trunk/src/picross/grid/PicrossGridUI.java) =================================================================== --- trunk/src/picross/grid/GridUI.java (rev 0) +++ trunk/src/picross/grid/GridUI.java 2007-06-07 11:29:21 UTC (rev 21) @@ -0,0 +1,396 @@ +/* + * $Id$ + * + * Copyright (c) 2007 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.grid; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; + +import javax.swing.JPanel; + +import org.apache.log4j.Logger; + +/** + * Grid UI. + * + * @author Y. Norsa + */ +final class GridUI extends JPanel { + /*** Constants ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = 2050855523399115878L; + + /** Space left before the top hints. */ + private static final int TOP_HINTS = 10; + + /** Width occupied by a row hint. */ + private static final int ROW_HINT_WIDTH = 10; + + /** Height occupied by a row hint. */ + private static final int ROW_HINT_HEIGHT = 15; + + /** Width occupied by a column hint. */ + private static final int COL_HINT_WIDTH = 5; + + /** Height occupied by a column hint. */ + private static final int COL_HINT_HEIGHT = 12; + + /** A box width. */ + private static final int BOX_WIDTH = 25; + + /** A box height. */ + private static final int BOX_HEIGHT = 25; + + /** Extra space at the right end of the grid. */ + private static final int RIGHT_SPACE = 5; + + /** Extra space at the bottom of the grid. */ + private static final int BOTTOM_SPACE = 5; + + /*** Static field ***/ + + /** Class' logger. */ + private static Logger log = Logger.getLogger(GridUI.class); + + /*** Fields ***/ + + /** Grid width. */ + private int width; + + /** Grid height. */ + private int height; + + /** Columns hints. */ + private int[][] colData; + + /** Rows hints. */ + private int[][] rowData; + + /** 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; + + /** Rectangle occupied by the top hints. */ + private Rectangle topHintsRect; + + /** Rectangle occupied by the left hints. */ + private Rectangle leftHintsRect; + + /** Current state of the grid. */ + private GridBox[][] boxes; + + /** Current rolled-over box. */ + private transient GridBox rollover; + + /** Controller attached to this view. */ + private transient GridController controller; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param width grid width + * @param height grid height + * @param colData columns hints + * @param rowData rows hints + * @param controller controller for the grid + */ + GridUI(int width, int height, + int[][] colData, + int[][] rowData, + GridController controller) { + super(true); + + this.controller = controller; + + this.addMouseListener(this.controller); + this.addMouseMotionListener(this.controller); + + this.setOpaque(true); + this.setBackground(Color.WHITE); + + this.width = width; + this.height = height; + + this.colData = colData; + this.rowData = rowData; + + this.leftBoundary = + this.rowData[0].length * GridUI.ROW_HINT_WIDTH; + + this.rightBoundary = this.leftBoundary + + (this.width * GridUI.BOX_WIDTH); + + this.topBoundary = GridUI.TOP_HINTS + + (this.colData[0].length * GridUI.COL_HINT_HEIGHT); + + this.bottomBoundary = this.topBoundary + + (this.height * GridUI.BOX_HEIGHT); + + this.topHintsRect = new Rectangle(this.leftBoundary, 0, + this.width * GridUI.BOX_WIDTH, + this.topBoundary); + this.leftHintsRect = new Rectangle(0, this.topBoundary, + this.leftBoundary, + this.height + * GridUI.BOX_HEIGHT); + + this.boxes = new GridBox[this.width][this.height]; + + for (int i = 0; i < this.boxes.length; i++) { + for (int j = 0; j < this.boxes[i].length; j++) { + /* + * We compute here the rectangle corresponding to each box + * so we'll be able + * to redraw only what is needed + */ + this.boxes[i][j] = + new GridBox(new Rectangle(this.leftBoundary + + (j * GridUI.BOX_WIDTH), + this.topBoundary + + (i * GridUI.BOX_WIDTH), + GridUI.BOX_WIDTH, + GridUI.BOX_HEIGHT)); + } + } + + //GridUI.log.debug("rightBoundary : " + this.rightBoundary); + //GridUI.log.debug("bottomBoundary : " + this.bottomBoundary); + + this.setPreferredSize(new Dimension(this.rightBoundary + + GridUI.RIGHT_SPACE, + this.bottomBoundary + + GridUI.BOTTOM_SPACE)); + } + + /*** Method overloaded from JPanel ***/ + + /** {@inheritDoc} */ + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + Rectangle clipRect = g.getClipBounds(); + + if (this.topHintsRect.intersects(clipRect)) { + GridUI.log.debug("top hints"); + + int x = 0; + int y = GridUI.TOP_HINTS; + + for (int i = this.colData[0].length - 1; i >= 0; i--) { + x = this.leftBoundary + GridUI.COL_HINT_WIDTH; + + for (int j = 0; j < this.colData.length; j++) { + if (this.colData[j][i] != GridModel.EMPTY_HINT) { + g.drawString(String.valueOf(this.colData[j][i]), + x, y); + } + + x += GridUI.BOX_WIDTH; + } + + y += GridUI.COL_HINT_HEIGHT; + } + } + + if (this.leftHintsRect.intersects(clipRect)) { + GridUI.log.debug("left hints"); + + int y = this.topBoundary; + + for (int i = 0; i < this.rowData.length; i++) { + int x = 0; + + for (int j = 0; j < this.rowData[i].length; j++) { + if (this.rowData[i][j] != GridModel.EMPTY_HINT) { + g.drawString(String.valueOf(this.rowData[i][j]), + x, y + GridUI.ROW_HINT_HEIGHT); + } + + x += GridUI.ROW_HINT_WIDTH; + } + + y += GridUI.BOX_HEIGHT; + } + } + + for (int i = 0; i < this.height; i++) { + for (int j = 0; j < this.width; j++) { + Rectangle currentRect = this.boxes[i][j].getRect(); + + if (currentRect.intersects(clipRect)) { + if (this.boxes[i][j] == this.rollover) { + this.boxes[i][j].getRolloverIcon() + .paintIcon(this, g, currentRect.x, currentRect.y); + } else { + this.boxes[i][j].getIcon().paintIcon(this, g, + currentRect.x, + currentRect.y); + } + } + } + } + } + + /*** 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) { + //GridUI.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); + } + + /** + * 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 / GridUI.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 / GridUI.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, int type) { + this.setBoxState(row, column, true, type); + } + + /** + * Unchecks a row. + * + * @param row row of the box + * @param column column of the box + */ + void uncheck(int row, int column, int type) { + this.setBoxState(row, column, false, type); + } + + /** + * 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, int type) { + if (!state) { + this.boxes[row][column].empty(); + } else { + if (type == GridController.CHECK_ACTION) { + this.boxes[row][column].check(); + } else { //if (type == GridController.CROSS_ACTION) { + this.boxes[row][column].cross(); + } + } + + this.repaint(this.boxes[row][column].getRect()); + } + + /** + * Allows to set the current rolled-over box. + * + * @param row row of the box + * @param column column of the box + */ + void setRollover(int row, int column) { + //GridUI.log.debug("setRollover(" + row + ", " + column + ")"); + + this.rolloverEnded(); + this.rollover = this.boxes[row][column]; + this.repaint(this.rollover.getRect()); + } + + /** Indicates that no box is currently rolled over. */ + void rolloverEnded() { + if (this.rollover != null) { + /* + * Save the old rolled-over box so we can draw it + * in its initial state + */ + Rectangle rect = this.rollover.getRect(); + + this.rollover = null; + this.repaint(rect); + } + } +} + Deleted: trunk/src/picross/grid/PicrossGridController.java =================================================================== --- trunk/src/picross/grid/PicrossGridController.java 2007-06-07 11:18:40 UTC (rev 20) +++ trunk/src/picross/grid/PicrossGridController.java 2007-06-07 11:29:21 UTC (rev 21) @@ -1,229 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import fr.cle.mmvcs.Controller; -import fr.cle.mmvcs.SimpleEvent; - -import java.awt.Point; - -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; - -//import org.apache.log4j.Logger; - -/** - * Grid controller. - * - * @author Y. Norsa - */ -public final 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"; - - /** 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"; - - /** Checking a box. */ - static final int CHECK_ACTION = 0; - - /** Crossing a box. */ - static final int CROSS_ACTION = 1; - - /*** 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 + ")"); - - 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(), - command.getType()); - - return; - } - - if (cmd.equals(PicrossGridController.UNCHECK_CMD)) { - FillCommand command = (FillCommand) e.getCommand(); - this.view.uncheck(command.getRow(), command.getColumn(), - command.getType()); - - return; - } - } - - /*** Methods implanted from the interface MouseListener ***/ - - /** {@inheritDoc} */ - public void mouseClicked(MouseEvent e) { } - - /** {@inheritDoc} */ - public void mouseEntered(MouseEvent e) { } - - /** {@inheritDoc} */ - public void mouseExited(MouseEvent e) { } - - /** {@inheritDoc} */ - public void mousePressed(MouseEvent e) { - this.view.rolloverEnded(); - } - - /** {@inheritDoc} */ - public void mouseReleased(MouseEvent e) { - //PicrossGridController.log.debug("mouseReleased()"); - this.checkAndFill(e); - this.fireEventPerformed(PicrossGridController.END_ACTION_CMD); - } - - /*** Methods implanted from the interface MouseMotionListener ***/ - - /** {@inheritDoc} */ - public void mouseDragged(MouseEvent e) { - this.checkAndFill(e); - } - - /** {@inheritDoc} */ - public void mouseMoved(MouseEvent e) { - //PicrossGridController.log.debug(e.getPoint()); - - Point point = e.getPoint(); - - if (this.view.isInGrid(point)) { - int row = this.view.getRow(point); - int column = this.view.getColumn(point); - - this.view.setRollover(row, column); - } else { - this.view.rolloverEnded(); - } - - } - - /*** Methods ***/ - - /** - * 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) { - //PicrossGridController.log.debug(e); - - int modifiers = e.getModifiers(); - - if (modifiers != MouseEvent.BUTTON1_MASK - && modifiers != MouseEvent.BUTTON3_MASK) { - - return; - } - - Point point = e.getPoint(); - - if (this.view.isInGrid(point)) { - int row = this.view.getRow(point); - 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)); - - } - } - - /** - * 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.BUTTON3_MASK: - return PicrossGridController.CROSS_ACTION; - - default: - return -1; - } - } - - /*** Accessor ***/ - - /** - * Allows to set the view. - * - * @param view view to which this controller is attached - */ - void setView(PicrossGridUI view) { - this.view = view; - } -} - Deleted: trunk/src/picross/grid/PicrossGridMediator.java =================================================================== --- trunk/src/picross/grid/PicrossGridMediator.java 2007-06-07 11:18:40 UTC (rev 20) +++ trunk/src/picross/grid/PicrossGridMediator.java 2007-06-07 11:29:21 UTC (rev 21) @@ -1,148 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import fr.cle.mmvcs.Mediateur; -import fr.cle.mmvcs.SimpleEvent; - -import javax.swing.JPanel; - -//import org.apache.log4j.Logger; - -/** - * Picross grid mediator. - * - * @author Y. Norsa - */ -public final class PicrossGridMediator extends Mediateur { - /*** Static field ***/ - - /** Class' logger. */ - //private static Logger log = Logger.getLogger(PicrossGridMediator.class); - - /*** Fields ***/ - - /** The grid model. */ - private PicrossGridModel model; - - /** The grid view. */ - private PicrossGridUI view; - - /*** Constructor ***/ - - /** - * Constructor. - * - * @param width grid width - * @param height grid height - * @param data grid content - */ - public PicrossGridMediator(int width, int height, boolean[][] data) { - this.model = new PicrossGridModel(this, data); - - PicrossGridController controller = new PicrossGridController(); - controller.addSimpleListener(this); - this.addSimpleListener(controller); - - this.view = new PicrossGridUI(width, height, - this.model.getColData(), - this.model.getRowData(), - controller); - - controller.setView(this.view); - } - - /*** Method overloaded from the class Mediateur ***/ - - /** {@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(), - command.getType()); - - return; - } - - if (cmd.equals(PicrossGridController.END_ACTION_CMD)) { - this.model.endAction(); - return; - } - } - - /*** 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, int type) { - this.fireEventPerformed(PicrossGridController.CHECK_CMD, - new FillCommand(row, column, type)); - } - - /** - * Unchecks a box. - * - * @param row row of the box - * @param column column of the box - */ - void uncheck(int row, int column, int type) { - this.fireEventPerformed(PicrossGridController.UNCHECK_CMD, - new FillCommand(row, column, type)); - } - - /*** Accessor ***/ - - /** - * Returns the view. - * - * @return the grid view - */ - public JPanel getView() { - return this.view; - } -} - Deleted: trunk/src/picross/grid/PicrossGridModel.java =================================================================== --- trunk/src/picross/grid/PicrossGridModel.java 2007-06-07 11:18:40 UTC (rev 20) +++ trunk/src/picross/grid/PicrossGridModel.java 2007-06-07 11:29:21 UTC (rev 21) @@ -1,355 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import java.util.ArrayList; -import java.util.List; - -//import org.apache.log4j.Logger; - -/** - * The grid model. - * - * @author Y. Norsa - */ -final class PicrossGridModel { - /*** Constant ***/ - - /** Empty hint value. */ - static final int EMPTY_HINT = -1; - - /*** Static field ***/ - - /** The class' logger. */ - //private static Logger log = Logger.getLogger(PicrossGridModel.class); - - /*** Fields ***/ - - /** This model's mediator. */ - private PicrossGridMediator mediator; - - /** The original grid. */ - private boolean[][] data; - - /** The grid as filled by the user. */ - private Box[][] boxes; - - /** - * The last modified box. Permis to know if we are in a serie or - * a single action. - */ - private Box lastModified = null; - - /** Columns hints. */ - private int[][] colData; - - /** Rows hints. */ - private int[][] rowData; - - /*** Constructor ***/ - - /** - * Constructor. - * - * @param mediator this model's mediator - * @param data gr... [truncated message content] |