From: Erik V. <ev...@us...> - 2009-12-13 21:14:20
|
Update of /cvsroot/rails/18xx/rails/ui/swing/hexmap In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv28388/rails/ui/swing/hexmap Modified Files: GUIHex.java Log Message: Draw company names in their home cities rather than on the hex. Index: GUIHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/GUIHex.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** GUIHex.java 13 Dec 2009 16:39:48 -0000 1.26 --- GUIHex.java 13 Dec 2009 21:14:12 -0000 1.27 *************** *** 293,300 **** FontMetrics fontMetrics = g2.getFontMetrics(); ! if (getHexModel().getTileCost() > 0 /* ! * && originalTileId == ! * currentTileId ! */) { g2.drawString( Bank.format(getHexModel().getTileCost()), --- 293,297 ---- FontMetrics fontMetrics = g2.getFontMetrics(); ! if (getHexModel().getTileCost() > 0 ) { g2.drawString( Bank.format(getHexModel().getTileCost()), *************** *** 306,311 **** } ! Map<PublicCompanyI, City> homes; ! if ((homes = getHexModel().getHomes()) != null) { StringBuffer b = new StringBuffer(); for (Iterator<PublicCompanyI> it = homes.keySet().iterator(); it.hasNext();) { --- 303,310 ---- } ! Map<PublicCompanyI, City> homes = getHexModel().getHomes(); ! if (homes != null) { ! //log.debug("+++ Home hex "+getName()); ! /* StringBuffer b = new StringBuffer(); for (Iterator<PublicCompanyI> it = homes.keySet().iterator(); it.hasNext();) { *************** *** 326,329 **** --- 325,350 ---- rectBound.y + ((fontMetrics.getHeight() + rectBound.height) * 3 / 10)); + */ + City city; + Point p; + homes: for (PublicCompanyI company : homes.keySet()) { + if (company.isClosed()) continue; + city = homes.get(company); + + // Only draw the company name if there isn't yet a token of that company + if (city.getTokens() != null) { + for (TokenI token : city.getTokens()) { + if (token instanceof BaseToken + && ((BaseToken)token).getCompany() == company) { + continue homes; + } + } + } + p = getTokenOrigin (1, 0, getHexModel().getCities().size(), + city.getNumber()-1); + //log.debug("+++ Home of "+company.getName()+" hex"+getName()+" city"+city.getName() + // + " x="+(p.x)+" y="+(p.y)); + drawHome (g2, company, p); + } } *************** *** 344,348 **** * 1 / 2, rectBound.y ! + ((fontMetrics.getHeight() + rectBound.height) * 7 / 15)); } } --- 365,369 ---- * 1 / 2, rectBound.y ! + ((fontMetrics.getHeight() + rectBound.height) * 5 / 15)); } } *************** *** 445,448 **** --- 466,488 ---- token.drawToken(g2); } + + private void drawHome (Graphics2D g2, PublicCompanyI co, Point origin) { + + Font oldFont = g2.getFont(); + Color oldColor = g2.getColor(); + + double tokenScale = 15.0 / 21.0; + String name = co.getName(); + + Font font = GUIToken.getTokenFont(name.length()); + g2.setFont(new Font("Helvetica", Font.BOLD, + (int) (font.getSize() * tokenScale))); + g2.setColor(Color.BLACK); + g2.drawString(name, (int) (origin.x + (12 - 3*name.length()) * tokenScale), + (int) (origin.y + 14 * tokenScale)); + + g2.setColor(oldColor); + g2.setFont(oldFont); + } private void drawBonusToken(Graphics2D g2, BonusToken bt, Point origin) { *************** *** 704,709 **** provisionalGUITile = null; ! log.debug("GUIHex " + model.getName() + " updated: new tile " ! + currentTileId + "/" + currentTileOrientation); if (GameUIManager.instance != null && GameUIManager.instance.orWindow != null) { --- 744,749 ---- provisionalGUITile = null; ! //log.debug("GUIHex " + model.getName() + " updated: new tile " ! // + currentTileId + "/" + currentTileOrientation); if (GameUIManager.instance != null && GameUIManager.instance.orWindow != null) { |