Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv28822/rails/game Modified Files: StockSpaceTypeI.java PublicCompany.java StockSpaceI.java StockSpace.java StockSpaceType.java StockMarket.java Log Message: Implemented request to show low-price colours in SR and OR panels. Added a generic Model-to-View update mechanism (used by above) All configurable colours can now be specified as RGB decimally or hexadecimally. Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** PublicCompany.java 26 Nov 2009 20:13:19 -0000 1.73 --- PublicCompany.java 13 Dec 2009 16:39:48 -0000 1.74 *************** *** 268,275 **** /* Configure public company features */ fgHexColour = tag.getAttributeAsString("fgColour", fgHexColour); ! fgColour = new Color(Integer.parseInt(fgHexColour, 16)); bgHexColour = tag.getAttributeAsString("bgColour", bgHexColour); ! bgColour = new Color(Integer.parseInt(bgHexColour, 16)); floatPerc = tag.getAttributeAsInteger("floatPerc", floatPerc); --- 268,277 ---- /* Configure public company features */ fgHexColour = tag.getAttributeAsString("fgColour", fgHexColour); ! //fgColour = new Color(Integer.parseInt(fgHexColour, 16)); ! fgColour = Util.parseColour(fgHexColour); bgHexColour = tag.getAttributeAsString("bgColour", bgHexColour); ! //bgColour = new Color(Integer.parseInt(bgHexColour, 16)); ! bgColour = Util.parseColour(bgHexColour); floatPerc = tag.getAttributeAsInteger("floatPerc", floatPerc); Index: StockSpace.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockSpace.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** StockSpace.java 31 Oct 2009 17:08:27 -0000 1.8 --- StockSpace.java 13 Dec 2009 16:39:49 -0000 1.9 *************** *** 1,5 **** package rails.game; ! import java.util.*; import org.apache.log4j.Logger; --- 1,7 ---- package rails.game; ! import java.awt.Color; ! import java.util.ArrayList; ! import java.util.List; import org.apache.log4j.Logger; *************** *** 52,58 **** /** * Add a token at the end of the array (i.e. at the bottom of the pile) ! * * Always returns true; ! * * @param company The company object to add. */ --- 54,60 ---- /** * Add a token at the end of the array (i.e. at the bottom of the pile) ! * * Always returns true; ! * * @param company The company object to add. */ *************** *** 66,70 **** /** * Remove a token from the pile. ! * * @param company The company object to remove. * @return False if the token was not found. --- 68,72 ---- /** * Remove a token from the pile. ! * * @param company The company object to remove. * @return False if the token was not found. *************** *** 91,95 **** /** * Find the stack position of a company token ! * * @return Stock position: 0 = top, increasing towards the bottom. -1 if not * found. --- 93,97 ---- /** * Find the stack position of a company token ! * * @return Stock position: 0 = top, increasing towards the bottom. -1 if not * found. *************** *** 126,134 **** * @return The square's colour. */ ! public String getColour() { if (type != null) { return type.getColour(); } else { ! return ""; } } --- 128,136 ---- * @return The square's colour. */ ! public Color getColour() { if (type != null) { return type.getColour(); } else { ! return Color.WHITE; } } *************** *** 254,262 **** } ! public String getText() { return Bank.format(price); } ! public String toString() { return getText(); } --- 256,266 ---- } ! @Override ! public String getText() { return Bank.format(price); } ! @Override ! public String toString() { return getText(); } Index: StockSpaceType.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockSpaceType.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** StockSpaceType.java 4 Jun 2008 19:00:30 -0000 1.3 --- StockSpaceType.java 13 Dec 2009 16:39:49 -0000 1.4 *************** *** 2,5 **** --- 2,9 ---- package rails.game; + import java.awt.Color; + + import rails.util.Util; + /** * Objects of this class represent a type of square on the StockMarket with *************** *** 13,29 **** /*--- Instance attributes ---*/ protected String name; ! protected String colour; protected boolean noCertLimit = false; // In yellow zone protected boolean noHoldLimit = false; // In orange zone (1830) protected boolean noBuyLimit = false; // In brown zone (1830) /*--- Contructors ---*/ ! public StockSpaceType(String name) { this(name, ""); } ! public StockSpaceType(String name, String colour) { this.name = name; ! this.colour = colour; } --- 17,38 ---- /*--- Instance attributes ---*/ protected String name; ! protected String colourString; ! protected Color colour; protected boolean noCertLimit = false; // In yellow zone protected boolean noHoldLimit = false; // In orange zone (1830) protected boolean noBuyLimit = false; // In brown zone (1830) + public static final String WHITE = "FFFFFF"; + /*--- Contructors ---*/ ! public StockSpaceType(String name) throws ConfigurationException { this(name, ""); } ! public StockSpaceType(String name, String colour) throws ConfigurationException { this.name = name; ! this.colourString = colour; ! //this.colour = new Color(Integer.parseInt(colourString, 16)); ! this.colour = Util.parseColour(colourString); } *************** *** 39,43 **** * @return The square type's colour. */ ! public String getColour() { return colour; } --- 48,52 ---- * @return The square type's colour. */ ! public Color getColour() { return colour; } Index: StockMarket.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockMarket.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** StockMarket.java 11 Nov 2009 22:26:47 -0000 1.23 --- StockMarket.java 13 Dec 2009 16:39:49 -0000 1.24 *************** *** 20,23 **** --- 20,24 ---- protected ArrayList<StockSpaceI> startSpaces = new ArrayList<StockSpaceI>(); protected int[] startPrices; + protected StockSpaceTypeI defaultType; /* Game-specific flags */ *************** *** 35,39 **** --- 36,43 ---- ArrayList<PublicCertificate> ipoPile; + public static final String DEFAULT = "default"; + public StockMarket() { + } *************** *** 42,46 **** */ public void configureFromXML(Tag tag) throws ConfigurationException { ! /* Read and configure the stock market space types */ List<Tag> typeTags = tag.getChildren(StockSpaceTypeI.ELEMENT_ID); --- 46,55 ---- */ public void configureFromXML(Tag tag) throws ConfigurationException { ! ! // Define a default stockspace type with colour white ! defaultType = new StockSpaceType(DEFAULT, StockSpaceType.WHITE); ! stockSpaceTypes.put (DEFAULT, defaultType); ! ! /* Read and configure the stock market space types */ List<Tag> typeTags = tag.getChildren(StockSpaceTypeI.ELEMENT_ID); *************** *** 99,102 **** --- 108,112 ---- "StockSpaceTypeUndefined", type)); } + if (type == null) type = defaultType; if (stockChartSpaces.get(name) != null) { *************** *** 270,274 **** else if (row < numRows - 1 && (newsquare = getStockSpace(row + 1, col)) != null) {} ! else { newsquare = oldsquare; } --- 280,284 ---- else if (row < numRows - 1 && (newsquare = getStockSpace(row + 1, col)) != null) {} ! else { newsquare = oldsquare; } Index: StockSpaceTypeI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockSpaceTypeI.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** StockSpaceTypeI.java 4 Jun 2008 19:00:32 -0000 1.3 --- StockSpaceTypeI.java 13 Dec 2009 16:39:48 -0000 1.4 *************** *** 2,5 **** --- 2,7 ---- package rails.game; + import java.awt.Color; + /** * The interface for StockSpaceType. *************** *** 44,48 **** * @return Color */ ! public abstract String getColour(); /** --- 46,50 ---- * @return Color */ ! public abstract Color getColour(); /** Index: StockSpaceI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockSpaceI.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** StockSpaceI.java 4 Jun 2008 19:00:31 -0000 1.4 --- StockSpaceI.java 13 Dec 2009 16:39:49 -0000 1.5 *************** *** 2,5 **** --- 2,6 ---- package rails.game; + import java.awt.Color; import java.util.*; *************** *** 53,57 **** * @return The square's colour. */ ! public abstract String getColour(); /** --- 54,58 ---- * @return The square's colour. */ ! public abstract Color getColour(); /** |