From: Freek D. <mac...@us...> - 2010-01-31 22:22:45
|
Update of /cvsroot/rails/18xx/rails/util In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv382/rails/util Modified Files: BuildInfo.java MakeGameTileSets.java RunGame.java Tag.java Util.java Log Message: Fix indentation: Java files contain 4 spaces, not tabs Index: MakeGameTileSets.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/util/MakeGameTileSets.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MakeGameTileSets.java 18 Dec 2009 20:03:52 -0000 1.8 --- MakeGameTileSets.java 31 Jan 2010 22:22:37 -0000 1.9 *************** *** 79,83 **** for (int i = 0; i < games.length; i++) { ! System.out.println("Preparing "+games[i]); makeTileSet(games[i], tileMap); --- 79,83 ---- for (int i = 0; i < games.length; i++) { ! System.out.println("Preparing "+games[i]); makeTileSet(games[i], tileMap); *************** *** 89,93 **** throws ConfigurationException { ! directories.clear(); directories.add("data/" + gameName); --- 89,93 ---- throws ConfigurationException { ! directories.clear(); directories.add("data/" + gameName); Index: Util.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/util/Util.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Util.java 19 Jan 2010 19:50:03 -0000 1.19 --- Util.java 31 Jan 2010 22:22:37 -0000 1.20 *************** *** 37,42 **** StringBuffer b = new StringBuffer(); for (String s : sa) { ! if (b.length() > 0) b.append(delimiter); ! b.append(s); } return b.toString(); --- 37,42 ---- StringBuffer b = new StringBuffer(); for (String s : sa) { ! if (b.length() > 0) b.append(delimiter); ! b.append(s); } return b.toString(); *************** *** 103,128 **** */ public static Color parseColour (String s) throws ConfigurationException{ ! Color c = null; ! if (s.indexOf(',') == -1) { ! // Assume hexadecimal RRGGBB ! try { ! c = new Color (Integer.parseInt(s, 16)); ! } catch (NumberFormatException e) { ! getLogger().error ("Invalid hex RGB colour: "+s, e); ! throw new ConfigurationException (e); ! } ! } else { ! // Assume decimal r,g,b ! try { ! String[] parts = s.split(","); ! c = new Color (Integer.parseInt(parts[0]), ! Integer.parseInt(parts[1]), ! Integer.parseInt(parts[2])); ! } catch (NumberFormatException e) { ! getLogger().error ("Invalid nummeric RGB colour: "+s, e); ! throw new ConfigurationException (e); ! } ! } ! return c; } --- 103,128 ---- */ public static Color parseColour (String s) throws ConfigurationException{ ! Color c = null; ! if (s.indexOf(',') == -1) { ! // Assume hexadecimal RRGGBB ! try { ! c = new Color (Integer.parseInt(s, 16)); ! } catch (NumberFormatException e) { ! getLogger().error ("Invalid hex RGB colour: "+s, e); ! throw new ConfigurationException (e); ! } ! } else { ! // Assume decimal r,g,b ! try { ! String[] parts = s.split(","); ! c = new Color (Integer.parseInt(parts[0]), ! Integer.parseInt(parts[1]), ! Integer.parseInt(parts[2])); ! } catch (NumberFormatException e) { ! getLogger().error ("Invalid nummeric RGB colour: "+s, e); ! throw new ConfigurationException (e); ! } ! } ! return c; } *************** *** 131,150 **** */ public static boolean isDark(Color c) { ! if (c == null) return false; ! return Math.sqrt(0.241*c.getRed()*c.getRed() ! + 0.691*c.getBlue()*c.getBlue() ! + 0.068*c.getGreen()*c.getGreen()) < 128; ! // Copied this formula from ! // http://www.nbdtech.com/blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx } public static Logger getLogger () { ! if (log == null) log = Logger.getLogger(Util.class.getPackage().getName()); ! return log; } public static String lowerCaseFirst (String text) { ! return text.substring(0, 1).toLowerCase() + text.substring(1); } } --- 131,150 ---- */ public static boolean isDark(Color c) { ! if (c == null) return false; ! return Math.sqrt(0.241*c.getRed()*c.getRed() ! + 0.691*c.getBlue()*c.getBlue() ! + 0.068*c.getGreen()*c.getGreen()) < 128; ! // Copied this formula from ! // http://www.nbdtech.com/blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx } public static Logger getLogger () { ! if (log == null) log = Logger.getLogger(Util.class.getPackage().getName()); ! return log; } public static String lowerCaseFirst (String text) { ! return text.substring(0, 1).toLowerCase() + text.substring(1); } } Index: BuildInfo.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/util/BuildInfo.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BuildInfo.java 6 Nov 2009 20:20:36 -0000 1.1 --- BuildInfo.java 31 Jan 2010 22:22:36 -0000 1.2 *************** *** 3,7 **** public class BuildInfo { ! public static final String buildDate = "2009-11-06"; } ! \ No newline at end of file --- 3,7 ---- public class BuildInfo { ! public static final String buildDate = "2009-11-06"; } ! \ No newline at end of file Index: RunGame.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/util/RunGame.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RunGame.java 14 Jan 2010 20:50:34 -0000 1.2 --- RunGame.java 31 Jan 2010 22:22:37 -0000 1.3 *************** *** 34,79 **** System.out.println("Configuration file = " + myConfigFile); ! int nargs = 0; ! if (args != null && args.length > 0) { ! nargs = args.length; ! System.out.println("Number of args: "+nargs); ! for (String arg : args) { ! System.out.println ("Arg: "+arg); ! } ! } ! if (nargs >= 1) { ! loadGame (args); ! } else { ! /* Start the rails.game selector, which will do all the rest. */ ! new GameSetupWindow(); ! } } static void loadGame (String[] args) { ! Game game = null; ! String filepath = args[0]; ! System.out.println("Starting game from saved file "+filepath); if ((game = Game.load(filepath)) == null) { ! System.err.println("Loading file "+filepath+" was unsuccessful"); return; } ! GameManagerI gameManager = game.getGameManager(); ! GameUIManager gameUIManager; ! String gameUIManagerClassName = gameManager.getClassName(GuiDef.ClassName.GAME_UI_MANAGER); ! try { ! Class<? extends GameUIManager> gameUIManagerClass = ! Class.forName(gameUIManagerClassName).asSubclass(GameUIManager.class); ! gameUIManager = gameUIManagerClass.newInstance(); ! gameUIManager.init(gameManager); ! gameUIManager.startLoadedGame(); ! } catch (Exception e) { ! System.err.println("Cannot instantiate class " + gameUIManagerClassName + ": "+e.getMessage()); ! e.printStackTrace(System.err); ! System.exit(1); ! } } --- 34,79 ---- System.out.println("Configuration file = " + myConfigFile); ! int nargs = 0; ! if (args != null && args.length > 0) { ! nargs = args.length; ! System.out.println("Number of args: "+nargs); ! for (String arg : args) { ! System.out.println ("Arg: "+arg); ! } ! } ! if (nargs >= 1) { ! loadGame (args); ! } else { ! /* Start the rails.game selector, which will do all the rest. */ ! new GameSetupWindow(); ! } } static void loadGame (String[] args) { ! Game game = null; ! String filepath = args[0]; ! System.out.println("Starting game from saved file "+filepath); if ((game = Game.load(filepath)) == null) { ! System.err.println("Loading file "+filepath+" was unsuccessful"); return; } ! GameManagerI gameManager = game.getGameManager(); ! GameUIManager gameUIManager; ! String gameUIManagerClassName = gameManager.getClassName(GuiDef.ClassName.GAME_UI_MANAGER); ! try { ! Class<? extends GameUIManager> gameUIManagerClass = ! Class.forName(gameUIManagerClassName).asSubclass(GameUIManager.class); ! gameUIManager = gameUIManagerClass.newInstance(); ! gameUIManager.init(gameManager); ! gameUIManager.startLoadedGame(); ! } catch (Exception e) { ! System.err.println("Cannot instantiate class " + gameUIManagerClassName + ": "+e.getMessage()); ! e.printStackTrace(System.err); ! System.exit(1); ! } } Index: Tag.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/util/Tag.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Tag.java 22 Jan 2010 21:44:34 -0000 1.14 --- Tag.java 31 Jan 2010 22:22:37 -0000 1.15 *************** *** 43,56 **** public Tag (Element element, Map<String, String> gameOptions) { ! this (element); ! this.gameOptions = gameOptions; } public void setGameOptions (Map<String, String> gameOptions) { ! this.gameOptions = gameOptions; } public Map<String, String> getGameOptions () { ! return gameOptions; } --- 43,56 ---- public Tag (Element element, Map<String, String> gameOptions) { ! this (element); ! this.gameOptions = gameOptions; } public void setGameOptions (Map<String, String> gameOptions) { ! this.gameOptions = gameOptions; } public Map<String, String> getGameOptions () { ! return gameOptions; } *************** *** 297,302 **** // rest if (gameOptions == null) { ! throw new ConfigurationException ( ! "No GameOptions available in tag "+element.getNodeName()); } --- 297,302 ---- // rest if (gameOptions == null) { ! throw new ConfigurationException ( ! "No GameOptions available in tag "+element.getNodeName()); } |