[Picross-commit] SF.net SVN: picross: [13] trunk
Status: Pre-Alpha
Brought to you by:
yvan_norsa
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. |