From: Rainer M. <rai...@we...> - 2007-01-22 20:45:56
|
### Eclipse Workspace Patch 1.0 #P rails Index: util/LocalText.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/rails/18xx/util/LocalText.java,v retrieving revision 1.5 diff -u -r1.5 LocalText.java --- util/LocalText.java 18 Jan 2007 18:12:10 -0000 1.5 +++ util/LocalText.java 22 Jan 2007 20:42:32 -0000 @@ -19,6 +19,40 @@ =20 protected static Logger log =3D = Logger.getLogger(LocalText.class.getPackage().getName()); =20 + public LocalText(){ + // do nothing + } + + public static ResourceBundle getLocalisedText(){ + /* Load the texts */ + if (localisedText =3D=3D null) + { + /* Check what locale has been configured, if any. + * If not, we use the default assigned above. + */ + String item; + if (Util.hasValue(item =3D Config.get("language"))) { + language =3D item.toLowerCase(); + } + if (Util.hasValue(item =3D Config.get("country"))) { + country =3D item.toUpperCase(); + localeCode =3D language + "_" + country; + } + if (Util.hasValue(item =3D Config.get("locale"))) { + localeCode =3D item; + if (localeCode.length()>=3D2) language =3D = localeCode.substring(0,2); + if (localeCode.length()>=3D5) country =3D = localeCode.substring(3,5); + } + log.debug ("Language=3D"+language+", country=3D"+country + +", locale=3D"+localeCode); + =20 + /* Create the locale and get the resource bundle. */ + locale =3D new Locale(language, country); + localisedText =3D ResourceBundle.getBundle("LocalisedText", = locale); + } + return localisedText; + } + public static String getText(String key) { return getText (key, null); } @@ -34,32 +68,6 @@ if (key =3D=3D null || key.length() =3D=3D 0) return ""; =20 - /* Load the texts */ - if (localisedText =3D=3D null) - { - /* Check what locale has been configured, if any. - * If not, we use the default assigned above. - */ - String item; - if (Util.hasValue(item =3D Config.get("language"))) { - language =3D item.toLowerCase(); - } - if (Util.hasValue(item =3D Config.get("country"))) { - country =3D item.toUpperCase(); - localeCode =3D language + "_" + country; - } - if (Util.hasValue(item =3D Config.get("locale"))) { - localeCode =3D item; - if (localeCode.length()>=3D2) language =3D = localeCode.substring(0,2); - if (localeCode.length()>=3D5) country =3D = localeCode.substring(3,5); - } - log.debug ("Language=3D"+language+", country=3D"+country - +", locale=3D"+localeCode); - =09 - /* Create the locale and get the resource bundle. */ - locale =3D new Locale(language, country); - localisedText =3D ResourceBundle.getBundle("LocalisedText", locale); - } =20 /* If the key contains a space, something is wrong, check who did = that! */ if (key.indexOf(" ") > -1) @@ -77,7 +85,7 @@ /* Find the text */ try { - result =3D localisedText.getString(key); + result =3D LocalText.getLocalisedText().getString(key); } catch (MissingResourceException e) { Index: util/Util.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/rails/18xx/util/Util.java,v retrieving revision 1.9 diff -u -r1.9 Util.java --- util/Util.java 18 Jan 2007 18:12:10 -0000 1.9 +++ util/Util.java 22 Jan 2007 20:42:32 -0000 @@ -82,4 +82,17 @@ return null; } } + =20 + /** + * Are two objects equal? + * You will not get a NullPointerException if value is null, as you = get by value.equals(equalValue)) + * @param value + * @param equalValue + * @return true, if value.equals(equalValue) or both are null + */ + public static boolean isEqual(Object value, Object equalValue) + { + return (value =3D=3D equalValue || (value !=3D null && = value.equals(equalValue))); + } + } Index: ui/StatusWindow.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/rails/18xx/ui/StatusWindow.java,v retrieving revision 1.59 diff -u -r1.59 StatusWindow.java --- ui/StatusWindow.java 12 Jan 2007 22:51:31 -0000 1.59 +++ ui/StatusWindow.java 22 Jan 2007 20:42:32 -0000 @@ -9,6 +9,8 @@ import java.awt.event.*; import javax.swing.*; =20 +import rails.ui.swing.AboutDialog; + import java.util.List; =20 import util.LocalText; @@ -30,6 +32,7 @@ protected static final String SELL_CMD =3D "Sell"; protected static final String DONE_CMD =3D "Done"; protected static final String SWAP_CMD =3D "Swap"; + protected static final String ABOUT_CMD =3D "About"; =20 private JPanel buttonPanel; private GameStatus gameStatus; @@ -58,7 +61,7 @@ JPanel pane =3D new JPanel(new BorderLayout()); =20 private JMenuBar menuBar; - private static JMenu fileMenu, optMenu, moveMenu; + private static JMenu fileMenu, optMenu, moveMenu, helpMenu; private JMenuItem menuItem, undoItem, redoItem; =20 /** @@ -75,10 +78,12 @@ fileMenu =3D new JMenu(LocalText.getText("FILE")); optMenu =3D new JMenu(LocalText.getText("OPTIONS")); moveMenu =3D new JMenu(LocalText.getText("MOVE")); + helpMenu =3D new JMenu(LocalText.getText("MenuHelp")); =20 fileMenu.setMnemonic(KeyEvent.VK_F); optMenu.setMnemonic(KeyEvent.VK_O); moveMenu.setMnemonic(KeyEvent.VK_M); + helpMenu.setMnemonic(KeyEvent.VK_H); =20 menuItem =3D new JMenuItem(LocalText.getText("SAVE")); //menuItem.setName(SAVE_CMD); @@ -153,14 +158,21 @@ =09 menuBar.add (moveMenu); =20 + menuItem =3D new = JMenuItem(LocalText.getText("MenuItemAboutRails")); + menuItem.setActionCommand(ABOUT_CMD); + menuItem.setMnemonic(KeyEvent.VK_A); + menuItem.addActionListener(this); + helpMenu.add(menuItem); + + menuBar.add(helpMenu); + setJMenuBar(menuBar); } =20 public StatusWindow() { cm =3D Game.getCompanyManager(); - companies =3D (PublicCompanyI[]) cm.getAllPublicCompanies() - .toArray(new PublicCompanyI[0]); + companies =3D (PublicCompanyI[]) = cm.getAllPublicCompanies().toArray(new PublicCompanyI[0]); ipo =3D Bank.getIpo(); pool =3D Bank.getPool(); =20 @@ -487,7 +499,11 @@ MoveSet.redo(); updateStatus(); return; - }=20 + } else if (actor.getActionCommand().equals(ABOUT_CMD)) + { + new AboutDialog(this, true); + return; + } =20 ReportWindow.addLog(); =20 Index: LocalisedText.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/rails/18xx/LocalisedText.properties,v retrieving revision 1.24 diff -u -r1.24 LocalisedText.properties --- LocalisedText.properties 18 Jan 2007 18:12:09 -0000 1.24 +++ LocalisedText.properties 22 Jan 2007 20:42:32 -0000 @@ -1,3 +1,7 @@ +AboutDialogNameLabel=3DProgram name +AboutDialogVersionLabel=3DVersion +AboutDialogDisclaimerLabel=3DDisclaimer +AboutDialogCloseButton=3DClose ALL=3DAll ALL_PASSED=3DAll players have passed. ALSO_GETS=3D{0} also gets {1} @@ -80,6 +84,7 @@ ComponentManagerNotReconfigured=3DCannot reconfigure the = ComponentManager. ComponentManagerNotYetConfigured=3DComponentManager has not yet been = configured. ConfirmToken=3DPress Lay Token to confirm token, click another city = hex, or press the No Token button. +Disclaimer=3DRails is a Java clone of the '18xx'-style games produced = by \nMayfair Games(tm), Avalon Hill(tm), David Hecht, John Galt, Francis = Tresham, and various other authors. \nAll rights reserved by the = respective owners. \nNo challenge to their status is intended. \n\nRails = is intended as a play aid for owners of each respective boardgame. = \n\nIf you are a copyright owner of one of the games, \nand want us to = remove the version of your game from this program, \nplease write an = email to rai...@so.... \n We will remove your version as = soon as posible. DoesNotExist=3DItem does not exist DoesNotHaveTheShares=3DDoes not have the shares Done=3DDone @@ -136,6 +141,8 @@ LaysTileAtFor=3D{0} lays tile #{1} at hex {2} for {3} MAP=3DMap MARKET=3DStock Market +MenuHelp=3DHelp +MenuItemAboutRails=3DAbout Rails MINIMUM_BID=3D<html>Min.<br>Bid</html> MOVE=3DMove NegativeAmountNotAllowed=3DNegative amount {0} not allowed @@ -253,6 +260,7 @@ UnnamedStockSpace=3DUnnamed stock space found. UnnamedStockSpaceType=3DUnnamed stock space type found. UpgradeNotFound=3DTile {0}: upgrade {1} not found +UserConfirmation=3DI own the choosen boardgame and will use the = programm as a play aid. VariantIs=3DVariant is {0}. WHICH_PRICE=3DWhich price? WHICH_PRIVATE=3DWhich Private? Index: README =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/rails/18xx/README,v retrieving revision 1.1 diff -u -r1.1 README --- README 7 Mar 2005 23:39:13 -0000 1.1 +++ README 22 Jan 2007 20:42:32 -0000 @@ -14,3 +14,18 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, = USA. + + +Disclaimer: +Rails is a Java clone of the '18xx'-style games produced by +Mayfair Games(tm), Avalon Hill(tm), David Hecht, John Galt,=20 +Francis Tresham, and various other authors. +All rights reserved by the respective owners. +No challenge to their status is intended. + +Rails is intended as a play aid for owners of each respective = boardgame. + +If you are a copyright owner of one of the games, +and want us to remove the version of your game from this program, +please write an email to rai...@so.... +We will remove your version as soon as posible. \ No newline at end of file Index: rails/ui/swing/AboutDialog.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: rails/ui/swing/AboutDialog.java diff -N rails/ui/swing/AboutDialog.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ rails/ui/swing/AboutDialog.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,158 @@ +package rails.ui.swing; + +import java.awt.AWTEvent; +import java.awt.Color; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextArea; + +import rails.RailsSystem; +import util.LocalText; + +/** + * Shows the About Dialog + * @author Rainer + * + */ +public class AboutDialog extends JDialog +{ + + /** + ** Creates new About Dialog + */ + public AboutDialog(JFrame parent, boolean modal) + { + super(parent, modal); + this.initGUI(); + this.pack(); + this.setVisible(true); + } + + /** + ** This method is called from within the constructor to initialize = the dialog. + */ + private void initGUI() + { + // Dialog + this.setTitle(LocalText.getText("MenuItemAboutRails")); + this.setResizable(false); + + Container contentPane =3D getContentPane(); + contentPane.setLayout(new GridBagLayout()); + + // Picture + JLabel picture =3D new JLabel(RailsSystem.getRailsImage()); + contentPane.add(picture, new GridBagConstraints(0, 0, 1, 1, 0.0, = 0.0, + = GridBagConstraints.CENTER, GridBagConstraints.NONE, + new = Insets(SwingUtil.INSETS_TL_MEDIUM, SwingUtil.INSETS_TL_MEDIUM,=20 + = SwingUtil.INSETS_BR_NONE, SwingUtil.INSETS_BR_NONE), + 0, 0)); + + // Informationen + JPanel infoPane =3D new JPanel(); + infoPane.setLayout(new GridBagLayout()); + =20 + JLabel prgNameLabel =3D new = JLabel(LocalText.getText("AboutDialogNameLabel") + ":"); + JTextArea prgNameInfo =3D new JTextArea(RailsSystem.getName()); + prgNameInfo.setEnabled(false); + prgNameInfo.setDisabledTextColor(Color.BLACK); + infoPane.add(prgNameLabel, new GridBagConstraints(0, 0, 1, 1, = 0.0, 0.0, + = GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, + new = Insets(SwingUtil.INSETS_TL_MEDIUM, SwingUtil.INSETS_TL_MEDIUM,=20 + = SwingUtil.INSETS_BR_NONE, SwingUtil.INSETS_BR_NONE), + 0, 0)); + infoPane.add(prgNameInfo , new GridBagConstraints(1, 0, 1, 1, = 1.0, 0.0, + = GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, + new = Insets(SwingUtil.INSETS_TL_MEDIUM, SwingUtil.INSETS_TL_MEDIUM,=20 + = SwingUtil.INSETS_BR_NONE, SwingUtil.INSETS_BR_NONE), + 0, 0)); + + JLabel versionLabel =3D new = JLabel(LocalText.getText("AboutDialogVersionLabel") + ":"); + JTextArea versionInfo =3D new = JTextArea(RailsSystem.getVersion()); + versionInfo.setEnabled(false); + versionInfo.setDisabledTextColor(Color.BLACK); + infoPane.add(versionLabel, new GridBagConstraints(0, 1, 1, 1, = 0.0, 0.0, + = GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, + new = Insets(SwingUtil.INSETS_TL_MEDIUM, SwingUtil.INSETS_TL_MEDIUM,=20 + = SwingUtil.INSETS_BR_NONE, SwingUtil.INSETS_BR_NONE), + 0, 0)); + infoPane.add(versionInfo , new GridBagConstraints(1, 1, 1, 1, = 1.0, 0.0, + = GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, + new = Insets(SwingUtil.INSETS_TL_MEDIUM, SwingUtil.INSETS_TL_MEDIUM,=20 + = SwingUtil.INSETS_BR_NONE, SwingUtil.INSETS_BR_NONE), + 0, 0)); + + JLabel disclaimerLabel =3D new = JLabel(LocalText.getText("AboutDialogDisclaimerLabel") + ":"); + JTextArea disclaimerInfo =3D new = JTextArea(LocalText.getText("Disclaimer")); + disclaimerInfo.setEnabled(false); + disclaimerInfo.setDisabledTextColor(Color.BLACK); + infoPane.add(disclaimerLabel, new GridBagConstraints(0, 2, 1, 1, = 0.0, 0.0, + = GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, + new = Insets(SwingUtil.INSETS_TL_MEDIUM, SwingUtil.INSETS_TL_MEDIUM,=20 + = SwingUtil.INSETS_BR_NONE, SwingUtil.INSETS_BR_NONE), + 0, 0)); + infoPane.add(disclaimerInfo , new GridBagConstraints(1, 2, 1, 1, = 1.0, 0.0, + = GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, + new = Insets(SwingUtil.INSETS_TL_MEDIUM, SwingUtil.INSETS_TL_MEDIUM,=20 + = SwingUtil.INSETS_BR_NONE, SwingUtil.INSETS_BR_NONE), + 0, 0)); + + + contentPane.add(infoPane, new GridBagConstraints(1, 0, 1, 1, 1.0, = 1.0, + = GridBagConstraints.CENTER, GridBagConstraints.BOTH, + new = Insets(SwingUtil.INSETS_TL_MEDIUM, SwingUtil.INSETS_TL_MEDIUM,=20 + = SwingUtil.INSETS_BR_NONE, SwingUtil.INSETS_BR_MEDIUM), + 0, = 0)); + + // okButton + JButton okButton =3D new = JButton(LocalText.getText("AboutDialogCloseButton")); + okButton.setSelected(true); + okButton.setDefaultCapable(true); + okButton.addActionListener(new PrivateActionListener()); + + contentPane.add(okButton, new GridBagConstraints(0, 1, 2, 1, 0.0, = 0.0, + = GridBagConstraints.CENTER, GridBagConstraints.NONE, + new = Insets(SwingUtil.INSETS_TL_LARGE, SwingUtil.INSETS_TL_MEDIUM,=20 + = SwingUtil.INSETS_BR_MEDIUM, SwingUtil.INSETS_BR_MEDIUM), + 0, 0)); + this.getRootPane().setDefaultButton(okButton); + + // Windows-Listener + this.addWindowListener(new PrivateWindowListener());=20 + + } + + /** + * Closes the dialog + * @param Event, who wants the closing of the dialog + */ + private void closeDialog(AWTEvent evt) + { + this.setVisible(false); + this.dispose(); + } + + private class PrivateActionListener implements ActionListener{ + public void actionPerformed(ActionEvent evt){ + closeDialog(evt); + } + } + + private class PrivateWindowListener extends WindowAdapter{ + public void windowClosing(WindowEvent evt){ + closeDialog(evt); + } + } +} Index: rails/ui/swing/RailsSwing.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: rails/ui/swing/RailsSwing.java diff -N rails/ui/swing/RailsSwing.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ rails/ui/swing/RailsSwing.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,99 @@ +/** + *=20 + */ +package rails.ui.swing; + +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JOptionPane; + +import org.apache.log4j.Logger; + +import rails.RailsSystem; + +import game.Game; +import game.GameManager; +import ui.GameUILoader; +import ui.ImageLoader; +import ui.ORWindow; +import ui.ReportWindow; +import ui.StatusWindow; +import ui.StockChart; +import util.LocalText; +import util.Util; + +/** + * @author Rainer + * @pattern Singelton + */ +public class RailsSwing { + + private static Logger log =3D null; // Logger for this class. You = cannot initialize it before calling the init-method of RailsSystem + + /** + * Start Rails with the Swing-UI + *=20 + * @param args <br/>=20 + * - none: start with an empty Frame <br/>=20 + * - 18xx: load the saved game 18xx (after load/save is implemented = <br/>=20 + * - 18xx gv p1 p2 ...: create a game of the 18xx, using = game-variant gv (- for none/main) with the players p1 p2 ... <br/>=20 + */ + public static void main(String[] args) { + new RailsSwing().start(args); + } + + private RailsSwing() { + } + + /** + * Start Rails with the Swing-UI + *=20 + * @param args see main(String[] args) + */ + private void start(String[] args){ + RailsSystem.init(); + this.log =3D RailsSystem.getLogger(this); + + this.initGUI(); + =20 + if (args.length =3D=3D 0) { + new GameUILoader(); // Will start with the option-panel to = choose players and game + } + else if (args.length =3D=3D 1){ + String savedGame =3D args[0]; + // XXX: Load/Save is not implemented by now + } + else + { + String gameName =3D args[0]; + String gameVariant =3D args[1]; + ArrayList playerNames =3D new ArrayList(args.length-2); + for (int i=3D2; i<args.length; i++) { + playerNames.add(args[i]); + } + try { + Game.initialise(gameName); + if (!Util.isEqual(gameVariant, "-")) = GameManager.setVariant(gameVariant); + Game.getPlayerManager(playerNames); + GameManager.getInstance().startGame(); + GameUILoader.gameUIInit(); + } + catch (NullPointerException e){ + this.log.fatal("Unable to start game", e); + System.out.println("Unable to load game. See log-file for = more information"); + } + + } + =20 + } + =20 + private void initGUI(){ +// imageLoader =3D new ImageLoader(); +// stockChart =3D new StockChart(); +// reportWindow =3D new ReportWindow(); +// orWindow =3D new ORWindow(); +// mapPanel =3D orWindow.getMapPanel(); +// StatusWindow statusWindow =3D new StatusWindow(); + } +} Index: rails/ui/swing/SwingUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: rails/ui/swing/SwingUtil.java diff -N rails/ui/swing/SwingUtil.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ rails/ui/swing/SwingUtil.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,15 @@ +package rails.ui.swing; + +public class SwingUtil { + public static final int INSETS_TL_NOSPACE =3D -2; + public static final int INSETS_TL_NONE =3D 0; + public static final int INSETS_TL_SMALL =3D 3; + public static final int INSETS_TL_MEDIUM =3D 6; + public static final int INSETS_TL_LARGE =3D 12; + + public static final int INSETS_BR_NOSPACE =3D -1; + public static final int INSETS_BR_NONE =3D 0; + public static final int INSETS_BR_SMALL =3D 2; + public static final int INSETS_BR_MEDIUM =3D 5; + public static final int INSETS_BR_LARGE =3D 11; +} Index: rails/RailsSystem.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: rails/RailsSystem.java diff -N rails/RailsSystem.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ rails/RailsSystem.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,117 @@ +package rails; + +import java.awt.Image; + +import javax.swing.ImageIcon; + +import game.Game; + +import org.apache.log4j.Logger; + +import util.Config; +import util.LocalText; +import util.Util; + +/** + * Rails spezific, UI undependent System wide settings and resources, + * @pattern Static Singelton=20 + * @author Rainer + */ +public class RailsSystem { + + private static final String NAME =3D "Rails";=20 + private static final String VERSION =3D "1.0.1"; // Better 1.00.01, = so you will have no sorting problem with multible versin-dirs + private static final String DEFAULT_USER_CONFIG_FILE =3D = "my.properties"; // The default properties file name + private static final ImageIcon RAILS_IMAGE =3D null; // XXX: We can = need an Image for Rails + =20 + private static Logger log =3D null; // Logger for this class. You = cannot initialize it before calling the init-method + + =20 +// private static final String AUTHORS =3D "Brett, Eric, Rainer"; +// private static final String COPYRIGHT =3D "The Software is under = Open Licence ..."; +// private static final String DEVELOPMENT_YEARS =3D "2005-2007"; +// private static final String IMAGE_ICON_NAME =3D ""; +// private static final String ABOUT_PICTURE_NAME =3D ""; + + private RailsSystem(){ + // do nothing + } + + /** + * Initialize the Rails envirement + * @param -Dconfigfile=3D<property-filename> as argument at start of = the main program + * + */ + public static final void init(){ + =20 + // Init userspezific property file + String myConfigFile =3D System.getProperty("configfile"); // Get = the name of the configfile from commandline, if set + if (!Util.hasValue(myConfigFile)) { + myConfigFile =3D DEFAULT_USER_CONFIG_FILE; + } + =20 + // Set the system property that tells log4j to use this file.=20 + // (Note: this MUST be done before updating Config)=20 + System.setProperty("log4j.configuration", myConfigFile); + Config.setConfigFile(myConfigFile); // Tell the properties loader = to read this file. + + // Init log + log =3D RailsSystem.getLogger(RailsSystem.class); + log.info("Initialize Rails with " + myConfigFile + " as the user = spezifig configuraion file."); + } + + /** + *=20 + * @return Versionnumber of Rails in xx.yy.zz </br> + * - xx: Major Version </br> + * - yy: Minor Version </br> + * - zz: BugFixes + */ + public static final String getVersion(){ + return RailsSystem.VERSION; + } + =20 + /** + *=20 + * @return Name of the Programm + */ + public static final String getName(){ + return RailsSystem.NAME; + } + + /** + *=20 + * @return Image for Rails + */ + public static final ImageIcon getRailsImage(){ + return RAILS_IMAGE; + } + =20 + /** + * Get the logger for a class + * @param clazz Class, for with you need a logger + * @return Logger for clazz, by now the Logger of the package of the = class + */ + public static final Logger getLogger(final Class clazz){ + return Logger.getLogger(clazz.getPackage().getName()); + } + + /** + * Get the logger for a object + * @param obj Object, for with you need a logger + * @return Logger for obj, by now the Logger of the package of the = class of the object + */ + public static final Logger getLogger(final Object obj){ + return Logger.getLogger(obj.getClass().getPackage().getName()); + } + + /** + * Get the user choosen value for a key + * @param key + * @return value, defined by user in the user property file=20 + */ + public static final String getUserConfig(String key){ + return Config.get(key); + } + +} |