[Picross-commit] SF.net SVN: picross: [20] trunk
Status: Pre-Alpha
Brought to you by:
yvan_norsa
From: <yva...@us...> - 2007-06-07 11:18:40
|
Revision: 20 http://picross.svn.sourceforge.net/picross/?rev=20&view=rev Author: yvan_norsa Date: 2007-06-07 04:18:40 -0700 (Thu, 07 Jun 2007) Log Message: ----------- applet version Modified Paths: -------------- trunk/build.xml trunk/src/picross/Picross.java trunk/src/picross/PicrossController.java trunk/src/picross/PicrossMediator.java trunk/src/picross/PicrossUI.java trunk/src/picross/grid/GridBox.java trunk/src/picross/menus/MainMenuController.java trunk/src/picross/menus/MainMenuMediator.java trunk/src/picross/menus/MainMenuUI.java Added Paths: ----------- trunk/applet/ trunk/applet/index.html trunk/images/crossed-rollover.png trunk/src/picross/PicrossException.java trunk/src/picross/app/ trunk/src/picross/app/MainMenuAppUI.java trunk/src/picross/app/PicrossApp.java trunk/src/picross/app/PicrossFrame.java trunk/src/picross/app/package.html trunk/src/picross/applet/ trunk/src/picross/applet/MainMenuAppletUI.java trunk/src/picross/applet/PicrossApplet.java trunk/src/picross/applet/package.html Added: trunk/applet/index.html =================================================================== --- trunk/applet/index.html (rev 0) +++ trunk/applet/index.html 2007-06-07 11:18:40 UTC (rev 20) @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> + <head> + <title>Picross</title> + <meta name="author" content="Yvan Norsa"> + </head> + + <body> + <h1>Picross</h1> + + <applet code="picross.applet.PicrossApplet" + archive="picross.jar,bundleHelper.jar,log4j.jar,mmvcs.jar" + width="450" + height="375" /> + </body> +</html> Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2007-06-07 04:22:39 UTC (rev 19) +++ trunk/build.xml 2007-06-07 11:18:40 UTC (rev 20) @@ -2,14 +2,19 @@ encoding="ISO-8859-1"?> <project name="picross" - default="run"> + default="dist"> <property name="build.dir" value="build" /> + <property name="dist.dir" + value="dist" /> <property name="lib.dir" value="lib" /> <property name="src.dir" value="src" /> + <property name="jar.name" + value="${dist.dir}/${ant.project.name}.jar" /> + <property name="bundleHelper.jar" value="${lib.dir}/bundleHelper.jar" /> <property name="mmvcs.jar" @@ -20,6 +25,7 @@ <target name="-init" depends="-setmode"> <mkdir dir="${build.dir}" /> + <mkdir dir="${dist.dir}" /> </target> <target name="release"> @@ -61,26 +67,41 @@ <classpath refid="classpath" /> </javac> + </target> + <target name="dist" + depends="compile"> <copy todir="${build.dir}/picross/properties" failonerror="false"> <fileset dir="${src.dir}/picross/properties" /> </copy> + <copy todir="${build.dir}/picross/images"> + <fileset dir="images" /> + </copy> + + <jar destfile="${jar.name}" + basedir="${build.dir}" /> </target> <target name="run" - depends="compile"> - <java classname="picross.Picross" + depends="dist"> + <java classname="picross.app.PicrossApp" failonerror="true" fork="true" dir="."> - <classpath refid="classpath" /> + <classpath> + <pathelement location="${jar.name}" /> + <pathelement location="${bundleHelper.jar}" /> + <pathelement location="${log4j.jar}" /> + <pathelement location="${mmvcs.jar}" /> + </classpath> </java> </target> <target name="clean"> <delete dir="${build.dir}" /> + <delete dir="${dist.dir}" /> <delete> <fileset dir="." @@ -90,7 +111,7 @@ </target> <target name="rebuild" - depends="clean, compile" /> + depends="clean, dist" /> <property file="checkstyle.properties" /> Added: trunk/images/crossed-rollover.png =================================================================== --- trunk/images/crossed-rollover.png (rev 0) +++ trunk/images/crossed-rollover.png 2007-06-07 11:18:40 UTC (rev 20) @@ -0,0 +1 @@ +link crossed.png \ No newline at end of file Property changes on: trunk/images/crossed-rollover.png ___________________________________________________________________ Name: svn:special + * Modified: trunk/src/picross/Picross.java =================================================================== --- trunk/src/picross/Picross.java 2007-06-07 04:22:39 UTC (rev 19) +++ trunk/src/picross/Picross.java 2007-06-07 11:18:40 UTC (rev 20) @@ -33,59 +33,49 @@ package picross; -import java.io.File; - import java.util.Locale; import javax.swing.ImageIcon; -import javax.swing.SwingUtilities; -import org.apache.log4j.PropertyConfigurator; +//import org.apache.log4j.Logger; /** - * Application main class. + * Helper class. * * @author Y. Norsa */ public final class Picross { /*** Constants ***/ - /** Log4j config file. */ - private static final String LOG4J_CONFIG = "log4j.properties"; - /** Images directory. */ - private static final String IMAGES_DIR = "images" + File.separator; + private static final String IMAGES_DIR = "/picross/images/"; /** Images directory corresponding to the default locale. */ private static final String LOCAL_IMAGES_PATH = Picross.IMAGES_DIR - + Locale.getDefault().getLanguage() + File.separator; + + Locale.getDefault().getLanguage() + "/"; - /*** Constructor ***/ + /*** Static field ***/ - /** Constructor. */ - private Picross() { - PropertyConfigurator.configure(Picross.LOG4J_CONFIG); + /** The class' logger. */ + //private static Logger log = Logger.getLogger(Picross.class); - new PicrossMediator(); - } + /*** Constructor ***/ - /*** Main method ***/ + /** Fake constructor. */ + private Picross() { } + /*** Static methods ***/ + /** - * Application main method. + * Loads an image. * - * @param args command line parameters + * @param path path of the image + * @return the image */ - public static void main(String[] args) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - new Picross(); - } - }); + private static ImageIcon loadImage(String path) { + return new ImageIcon(Picross.class.getResource(path)); } - /*** Static methods ***/ - /** * Returns an image. * @@ -93,7 +83,7 @@ * @return the image */ public static ImageIcon getImage(String name) { - return new ImageIcon(Picross.IMAGES_DIR + name); + return Picross.loadImage(Picross.IMAGES_DIR + name); } /** @@ -103,7 +93,7 @@ * @return the image */ public static ImageIcon getLocalizedImage(String name) { - return new ImageIcon(Picross.LOCAL_IMAGES_PATH + name); + return Picross.loadImage(Picross.LOCAL_IMAGES_PATH + name); } } Modified: trunk/src/picross/PicrossController.java =================================================================== --- trunk/src/picross/PicrossController.java 2007-06-07 04:22:39 UTC (rev 19) +++ trunk/src/picross/PicrossController.java 2007-06-07 11:18:40 UTC (rev 20) @@ -64,7 +64,18 @@ if (cmd.equals(PicrossController.MESSAGE_CMD)) { this.view.displayMessage(e.getComment()); + return; } + + if (cmd.equals(PicrossController.ERROR_CMD)) { + this.view.displayError(e.getComment()); + return; + } + + if (cmd.equals(PicrossController.DISPOSE_CMD)) { + this.view.exit(); + return; + } } /*** Accessor ***/ Added: trunk/src/picross/PicrossException.java =================================================================== --- trunk/src/picross/PicrossException.java (rev 0) +++ trunk/src/picross/PicrossException.java 2007-06-07 11:18:40 UTC (rev 20) @@ -0,0 +1,58 @@ +/* + * $Id$ + * + * Copyright (c) 2007 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross; + +/** + * General exception. + * + * @author Y. Norsa + */ +public final class PicrossException extends Exception { + /*** Constant ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = 1716838910721477345L; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param cause parent exception + */ + public PicrossException(Throwable cause) { + super(cause); + } +} + Property changes on: trunk/src/picross/PicrossException.java ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/src/picross/PicrossMediator.java =================================================================== --- trunk/src/picross/PicrossMediator.java 2007-06-07 04:22:39 UTC (rev 19) +++ trunk/src/picross/PicrossMediator.java 2007-06-07 11:18:40 UTC (rev 20) @@ -51,33 +51,46 @@ * * @author Y. Norsa */ -final class PicrossMediator extends Mediateur { +public final class PicrossMediator extends Mediateur { /*** Static field ***/ /** Class' logger. */ //private static Logger log = Logger.getLogger(PicrossMediator.class); - /*** Fields ***/ + /*** Field ***/ - /** The view's controller. */ - private PicrossController controller; - /** Main view. */ private PicrossUI view; /*** Constructor ***/ /** Constructor. */ - PicrossMediator() { + public PicrossMediator(PicrossUI view) { BundleHelper.loadBundle("picross.properties.messages_picross"); - this.controller = new PicrossController(); - this.addSimpleListener(this.controller); + this.view = view; - MainMenuMediator mediator = new MainMenuMediator(); + PicrossController controller = new PicrossController(); + controller.setView(view); + + this.addSimpleListener(controller); + + MainMenuMediator mediator = null; + + try { + mediator = new MainMenuMediator(view); + } catch (PicrossException picrossEx) { + this.fireEventPerformed(PicrossController.ERROR_CMD, + picrossEx.getMessage()); + + this.exit(); + return; + } + mediator.addSimpleListener(this); - this.view = new PicrossUI(mediator.getView()); + //this.view = new PicrossUI(mediator.getView()); + this.view.setContent(mediator.getView()); } /*** Method overloaded from the Mediateur class ***/ @@ -97,13 +110,12 @@ grid.addSimpleListener(this); this.view.setContent(grid.getView()); - this.controller.setView(this.view); return; } if (cmd.equals(MainMenuController.EXIT_CMD)) { - this.view.dispose(); + this.exit(); return; } @@ -113,5 +125,12 @@ return; } } + + /*** Method ***/ + + /** Exits the application. */ + private void exit() { + this.fireEventPerformed(PicrossController.DISPOSE_CMD); + } } Modified: trunk/src/picross/PicrossUI.java =================================================================== --- trunk/src/picross/PicrossUI.java 2007-06-07 04:22:39 UTC (rev 19) +++ trunk/src/picross/PicrossUI.java 2007-06-07 11:18:40 UTC (rev 20) @@ -33,87 +33,43 @@ package picross; -import javax.swing.JFrame; -import javax.swing.JOptionPane; import javax.swing.JPanel; -import javax.swing.SwingUtilities; /** * Main window. * * @author Y. Norsa */ -final class PicrossUI extends JFrame { - /*** Constant ***/ - - /** Serialisation ID. */ - private static final long serialVersionUID = -6091243469021691734L; - - /*** Constructor ***/ - - /** Constructor. */ - PicrossUI(JPanel content) { - super("Picross"); - - this.setContent(content); - this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - this.setVisible(true); - } - - /*** Method ***/ - +public interface PicrossUI { /** - * Sets the frame panel and resizes the window. + * Sets the content panel. * * @param content new content panel */ - void setContent(JPanel content) { - this.setContentPane(content); - this.pack(); - } + void setContent(JPanel content); /** * Displays a message box. * * @param msg message to be displayed */ - void displayMessage(String msg) { - SwingUtilities.invokeLater(new RunnableDialog(this, msg)); - } + void displayMessage(String msg); /** - * Inner class displaying a message asynchronously. + * Displays an error message. * - * @author Y. Norsa + * @param msg error message */ - private static final class RunnableDialog implements Runnable { - /*** Fields ***/ + void displayError(String msg); - /** Parent frame. */ - private JFrame parent; + /** + * Returns the name of the main menu class. + * + * @return name of the main menu class + */ + String getMainMenuClass(); - /** Message to be displayed. */ - private String msg; - - /*** Constructor ***/ - - /** - * Constructor. - * - * @param parent parent frame - * @param msg message to be displayed - */ - private RunnableDialog(JFrame parent, String msg) { - this.parent = parent; - this.msg = msg; - } - - /*** Method implanted from the interface Runnable ***/ - - /** {@inheritDoc} */ - public void run() { - JOptionPane.showMessageDialog(this.parent, this.msg); - } - } + /** Method called when the application exits. */ + void exit(); } Added: trunk/src/picross/app/MainMenuAppUI.java =================================================================== --- trunk/src/picross/app/MainMenuAppUI.java (rev 0) +++ trunk/src/picross/app/MainMenuAppUI.java 2007-06-07 11:18:40 UTC (rev 20) @@ -0,0 +1,108 @@ +/* + * $Id$ + * + * Copyright (c) 2007 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.app; + +import java.awt.event.ActionListener; + +import javax.swing.ImageIcon; +import javax.swing.JButton; + +import picross.Picross; + +import picross.menus.MainMenuController; +import picross.menus.MainMenuUI; + +/** + * Main menu for the application version. + * + * @author Y. Norsa + */ +public final class MainMenuAppUI extends MainMenuUI { + /*** Constans ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = 8153436550520127667L; + + /** "Play" button X coordinate. */ + private static final int PLAY_BUTTON_X = 50; + + /** "Play" button Y coordinate. */ + private static final int PLAY_BUTTON_Y = 225; + + /** Image for the "exit" button. */ + private static final String EXIT_BUTTON_IMAGE = "button-exit.png"; + + /** "Exit" button X coordinate. */ + private static final int EXIT_BUTTON_X = 250; + + /** "Exit" button Y coordinate. */ + private static final int EXIT_BUTTON_Y = 225; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param controller controller for the buttons + */ + public MainMenuAppUI(ActionListener controller) { + super(controller); + + ImageIcon exitIcon = + Picross.getLocalizedImage(MainMenuAppUI.EXIT_BUTTON_IMAGE); + JButton exitButton = new JButton(exitIcon); + exitButton.setActionCommand(MainMenuController.EXIT_CMD); + exitButton.addActionListener(controller); + exitButton.setBorder(null); + exitButton.setBounds(MainMenuAppUI.EXIT_BUTTON_X, + MainMenuAppUI.EXIT_BUTTON_Y, + exitIcon.getIconWidth(), + exitIcon.getIconHeight()); + this.add(exitButton); + } + + /*** Methods overloaded from MainMenuUI ***/ + + /** {@inheritDoc} */ + protected int getPlayButtonX() { + return MainMenuAppUI.PLAY_BUTTON_X; + } + + /** {@inheritDoc} */ + protected int getPlayButtonY() { + return MainMenuAppUI.PLAY_BUTTON_Y; + } +} + + Property changes on: trunk/src/picross/app/MainMenuAppUI.java ___________________________________________________________________ Name: svn:keywords + Id Added: trunk/src/picross/app/PicrossApp.java =================================================================== --- trunk/src/picross/app/PicrossApp.java (rev 0) +++ trunk/src/picross/app/PicrossApp.java 2007-06-07 11:18:40 UTC (rev 20) @@ -0,0 +1,76 @@ +/* + * $Id$ + * + * Copyright (c) 2007 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.app; + +import javax.swing.SwingUtilities; + +import org.apache.log4j.PropertyConfigurator; + +import picross.PicrossMediator; + +/** + * Main class of the application version. + * + * @author Y. Norsa + */ +public final class PicrossApp { + /*** Constant ***/ + + /** Log4j config file. */ + private static final String LOG4J_CONFIG = "log4j.properties"; + + /** Constructor. */ + + /** Constructor. */ + private PicrossApp() { + PropertyConfigurator.configure(PicrossApp.LOG4J_CONFIG); + new PicrossMediator(new PicrossFrame()); + } + + /*** Main method ***/ + + /** + * Application main method. + * + * @param args command line parameters + */ + public static void main(String[] args) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + new PicrossApp(); + } + }); + } +} + Property changes on: trunk/src/picross/app/PicrossApp.java ___________________________________________________________________ Name: svn:keywords + Id Added: trunk/src/picross/app/PicrossFrame.java =================================================================== --- trunk/src/picross/app/PicrossFrame.java (rev 0) +++ trunk/src/picross/app/PicrossFrame.java 2007-06-07 11:18:40 UTC (rev 20) @@ -0,0 +1,95 @@ +/* + * $Id$ + * + * Copyright (c) 2007 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.app; + +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JPanel; + +import picross.PicrossUI; + +/** + * Main window of the application version. + * + * @author Y. Norsa + */ +public final class PicrossFrame extends JFrame implements PicrossUI { + /*** Constants ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = -6091243469021691734L; + + /** Main menu class. */ + private static final String MAIN_MENU_CLASS = "picross.app.MainMenuAppUI"; + + /*** Constructor ***/ + + /** Constructor. */ + public PicrossFrame() { + super("Picross"); + + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setVisible(true); + } + + /*** Methods implanted from the interface PicrossUI ***/ + + /** {@inheritDoc} */ + public void setContent(JPanel content) { + this.setContentPane(content); + this.pack(); + } + + /** {@inheritDoc} */ + public void displayMessage(String msg) { + JOptionPane.showMessageDialog(this, msg); + } + + /** {@inheritDoc} */ + public void displayError(String msg) { + JOptionPane.showMessageDialog(this, msg, + "Picross", JOptionPane.ERROR_MESSAGE); + } + + /** {@inheritDoc} */ + public void exit() { + this.dispose(); + } + + /** {@inheritDoc} */ + public String getMainMenuClass() { + return PicrossFrame.MAIN_MENU_CLASS; + } +} + Property changes on: trunk/src/picross/app/PicrossFrame.java ___________________________________________________________________ Name: svn:keywords + Id Added: trunk/src/picross/app/package.html =================================================================== --- trunk/src/picross/app/package.html (rev 0) +++ trunk/src/picross/app/package.html 2007-06-07 11:18:40 UTC (rev 20) @@ -0,0 +1,12 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <!-- + $Id$ + --> + </head> + + <body bgcolor="white"> + Classes for the application version. + </body> +</html> Property changes on: trunk/src/picross/app/package.html ___________________________________________________________________ Name: svn:keywords + Id Added: trunk/src/picross/applet/MainMenuAppletUI.java =================================================================== --- trunk/src/picross/applet/MainMenuAppletUI.java (rev 0) +++ trunk/src/picross/applet/MainMenuAppletUI.java 2007-06-07 11:18:40 UTC (rev 20) @@ -0,0 +1,92 @@ +/* + * $Id$ + * \xC9crit le 07/06/2007 par Y. Norsa + * + * Copyright (c) 2007 + * Projet Carte Lorraine de l'Etudiant (CLE) + * + * Universit\xE9 Henri Poincar\xE9, Nancy + * Universit\xE9 Nancy2 + * Institut National Polytechnique de Lorraine + * Universit\xE9 Paul Verlaine, Metz + * + * Ce projet regroupe les d\xE9veloppements concernant la production + * et l'exploitation de la Carte Lorraine de l'Etudiant + * (carte \xE0 puce sans contact Mifare). + * + * Ce logiciel est r\xE9gi par la licence CeCILL soumise au droit fran\xE7ais et + * respectant les principes de diffusion des logiciels libres. Vous pouvez + * utiliser, modifier et/ou redistribuer ce programme sous les conditions + * de la licence CeCILL telle que diffus\xE9e par le CEA, le CNRS et l'INRIA + * sur le site "http://www.cecill.info". + * + * En contrepartie de l'accessibilit\xE9 au code source et des droits de copie, + * de modification et de redistribution accord\xE9s par cette licence, il n'est + * offert aux utilisateurs qu'une garantie limit\xE9e. Pour les m\xEAmes raisons, + * seule une responsabilit\xE9 restreinte p\xE8se sur l'auteur du programme, le + * titulaire des droits patrimoniaux et les conc\xE9dants successifs. + * + * A cet \xE9gard l'attention de l'utilisateur est attir\xE9e sur les risques + * associ\xE9s au chargement, \xE0 l'utilisation, \xE0 la modification et/ou au + * d\xE9veloppement et \xE0 la reproduction du logiciel par l'utilisateur \xE9tant + * donn\xE9 sa sp\xE9cificit\xE9 de logiciel libre, qui peut le rendre complexe \xE0 + * manipuler et qui le r\xE9serve donc \xE0 des d\xE9veloppeurs et des professionnels + * avertis poss\xE9dant des connaissances informatiques approfondies. Les + * utilisateurs sont donc invit\xE9s \xE0 charger et tester l'ad\xE9quation du + * logiciel \xE0 leurs besoins dans des conditions permettant d'assurer la + * s\xE9curit\xE9 de leurs syst\xE8mes et ou de leurs donn\xE9es et, plus g\xE9n\xE9ralement, + * \xE0 l'utiliser et l'exploiter dans les m\xEAmes conditions de s\xE9curit\xE9. + * + * Le fait que vous puissiez acc\xE9der \xE0 cet en-t\xEAte signifie que vous avez + * pris connaissance de la licence CeCILL, et que vous en avez accept\xE9 les + * termes. + */ + + +package picross.applet; + +import java.awt.event.ActionListener; + +import picross.menus.MainMenuUI; + +/** + * Main menu for the applet version. + * + * @author Y. Norsa + */ +public final class MainMenuAppletUI extends MainMenuUI { + /*** Constants ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = 5820728724819549202L; + + /** "Play" button X coordinate. */ + private static final int PLAY_BUTTON_X = 149; + + /** "Play" button Y coordinate. */ + private static final int PLAY_BUTTON_Y = 225; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param controller controller for the buttons + */ + public MainMenuAppletUI(ActionListener controller) { + super(controller); + } + + /*** Methods inherited from the class MainMenuUI ***/ + + /** {@inheritDoc} */ + protected int getPlayButtonX() { + return MainMenuAppletUI.PLAY_BUTTON_X; + } + + /** {@inheritDoc} */ + protected int getPlayButtonY() { + return MainMenuAppletUI.PLAY_BUTTON_Y; + } +} + Property changes on: trunk/src/picross/applet/MainMenuAppletUI.java ___________________________________________________________________ Name: svn:keywords + Id Added: trunk/src/picross/applet/PicrossApplet.java =================================================================== --- trunk/src/picross/applet/PicrossApplet.java (rev 0) +++ trunk/src/picross/applet/PicrossApplet.java 2007-06-07 11:18:40 UTC (rev 20) @@ -0,0 +1,98 @@ +/* + * $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.applet; + +import javax.swing.JApplet; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import picross.PicrossMediator; +import picross.PicrossUI; + +/** + * Main class of the applet version. + * + * @author Y. Norsa + */ +public final class PicrossApplet extends JApplet implements PicrossUI { + /*** Constants ***/ + + /** Serialisation ID. */ + private static final long serialVersionUID = 2701753715418652408L; + + /** Main menu class. */ + private static final String MAIN_MENU_CLASS = + "picross.applet.MainMenuAppletUI"; + + /*** Methods overloaded from the class JApplet ***/ + + /** {@inheritDoc} */ + public void init() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + new PicrossMediator(PicrossApplet.this); + } + }); + } + + /*** Methods implanted from the interface PicrossUI ***/ + + /** {@inheritDoc} */ + public String getMainMenuClass() { + return PicrossApplet.MAIN_MENU_CLASS; + } + + /** {@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 setContent(JPanel content) { + this.setContentPane(content); + this.validate(); + } + + /** {@inheritDoc} */ + public void exit() { + } +} + Property changes on: trunk/src/picross/applet/PicrossApplet.java ___________________________________________________________________ Name: svn:keywords + Id Added: trunk/src/picross/applet/package.html =================================================================== --- trunk/src/picross/applet/package.html (rev 0) +++ trunk/src/picross/applet/package.html 2007-06-07 11:18:40 UTC (rev 20) @@ -0,0 +1,12 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <!-- + $Id$ + --> + </head> + + <body bgcolor="white"> + Classes for the applet version. + </body> +</html> Property changes on: trunk/src/picross/applet/package.html ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/src/picross/grid/GridBox.java =================================================================== --- trunk/src/picross/grid/GridBox.java 2007-06-07 04:22:39 UTC (rev 19) +++ trunk/src/picross/grid/GridBox.java 2007-06-07 11:18:40 UTC (rev 20) @@ -59,10 +59,6 @@ GridBox.images.put(state, img); } - - // We don't have a rollover icon for crossed boxes - GridBox.images.get(Box.BoxState.CROSSED)[GridBox.ROLLOVER_ICON_INDEX] = - GridBox.images.get(Box.BoxState.CROSSED)[GridBox.ICON_INDEX]; } /*** Constructor ***/ Modified: trunk/src/picross/menus/MainMenuController.java =================================================================== --- trunk/src/picross/menus/MainMenuController.java 2007-06-07 04:22:39 UTC (rev 19) +++ trunk/src/picross/menus/MainMenuController.java 2007-06-07 11:18:40 UTC (rev 20) @@ -75,6 +75,8 @@ String cmd = e.getActionCommand(); + //javax.swing.JOptionPane.showMessageDialog(null, "click : " + cmd); + if (cmd.equals(MainMenuController.PLAY_CMD) || cmd.equals(MainMenuController.EXIT_CMD)) { Modified: trunk/src/picross/menus/MainMenuMediator.java =================================================================== --- trunk/src/picross/menus/MainMenuMediator.java 2007-06-07 04:22:39 UTC (rev 19) +++ trunk/src/picross/menus/MainMenuMediator.java 2007-06-07 11:18:40 UTC (rev 20) @@ -36,8 +36,15 @@ import fr.cle.mmvcs.Mediateur; import fr.cle.mmvcs.SimpleEvent; +import java.awt.event.ActionListener; + +import java.lang.reflect.InvocationTargetException; + import org.apache.log4j.Logger; +import picross.PicrossException; +import picross.PicrossUI; + /** * Mediator for the main menu. * @@ -56,12 +63,29 @@ /*** Constructor ***/ - /** Constructor. */ - public MainMenuMediator() { + /** + * Constructor. + * + * @throws PicrossException if the instantiation of the main menu UI fails + */ + public MainMenuMediator(PicrossUI ui) throws PicrossException { MainMenuController controller = new MainMenuController(); controller.addSimpleListener(this); - this.view = new MainMenuUI(controller); + try { + this.view = (MainMenuUI) Class.forName(ui.getMainMenuClass()) + .getConstructor(ActionListener.class).newInstance(controller); + } catch (ClassNotFoundException classEx) { + throw new PicrossException(classEx); + } catch (NoSuchMethodException methodEx) { + throw new PicrossException(methodEx); + } catch (InstantiationException instantiationEx) { + throw new PicrossException(instantiationEx); + } catch (IllegalAccessException accessEx) { + throw new PicrossException(accessEx); + } catch (InvocationTargetException targetEx) { + throw new PicrossException(targetEx.getCause()); + } } /*** Method overloaded from the class Mediateur ***/ @@ -69,6 +93,7 @@ /** {@inheritDoc} */ public void eventPerformed(SimpleEvent e) { MainMenuMediator.log.debug("eventPerformed(" + e + ")"); + this.fireEventPerformed(e); } Modified: trunk/src/picross/menus/MainMenuUI.java =================================================================== --- trunk/src/picross/menus/MainMenuUI.java 2007-06-07 04:22:39 UTC (rev 19) +++ trunk/src/picross/menus/MainMenuUI.java 2007-06-07 11:18:40 UTC (rev 20) @@ -50,7 +50,7 @@ * * @author Y. Norsa */ -class MainMenuUI extends JPanel { +public abstract class MainMenuUI extends JPanel { /*** Constants ***/ /** Serialisation ID. */ @@ -62,21 +62,6 @@ /** 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. */ @@ -89,7 +74,7 @@ * * @param controller controller for the buttons */ - MainMenuUI(ActionListener controller) { + public MainMenuUI(ActionListener controller) { ImageIcon icon = Picross.getImage(MainMenuUI.BACKGROUND_IMAGE); this.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight())); @@ -103,21 +88,27 @@ playButton.setActionCommand(MainMenuController.PLAY_CMD); playButton.addActionListener(controller); playButton.setBorder(null); - playButton.setBounds(MainMenuUI.PLAY_BUTTON_X, MainMenuUI.PLAY_BUTTON_Y, + playButton.setBounds(this.getPlayButtonX(), this.getPlayButtonY(), playIcon.getIconWidth(), playIcon.getIconHeight()); this.add(playButton); - - 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); } + /*** Abstract methods ***/ + + /** + * Returns the "play" button X position. + * + * @return X position of the "play" button + */ + protected abstract int getPlayButtonX(); + + /** + * Returns the "play" button Y position. + * + * @return Y position of the "play" button + */ + protected abstract int getPlayButtonY(); + /*** Method overloaded from the class JPanel ***/ /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |