From: Freek D. <mac...@us...> - 2010-01-31 22:23:12
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv382/rails/ui/swing Modified Files: GUIToken.java GameSetupWindow.java GameStatus.java GameUIManager.java GridPanel.java ImageLoader.java MapPanel.java ORPanel.java ORUIManager.java ORWindow.java StartRoundWindow.java StatusWindow.java UpgradesPanel.java Log Message: Fix indentation: Java files contain 4 spaces, not tabs Index: StatusWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StatusWindow.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** StatusWindow.java 20 Jan 2010 19:52:43 -0000 1.36 --- StatusWindow.java 31 Jan 2010 22:22:34 -0000 1.37 *************** *** 203,207 **** if ("yes".equalsIgnoreCase(Config.get("report.window.open"))) { ! enableCheckBoxMenuItem(REPORT_CMD); } } --- 203,207 ---- if ("yes".equalsIgnoreCase(Config.get("report.window.open"))) { ! enableCheckBoxMenuItem(REPORT_CMD); } } *************** *** 409,413 **** // Request turn if (possibleActions.contains(RequestTurn.class)) { ! for (RequestTurn action : possibleActions.getType(RequestTurn.class)) { ActionMenuItem item = new ActionMenuItem(action.toString()); item.addActionListener(this); --- 409,413 ---- // Request turn if (possibleActions.contains(RequestTurn.class)) { ! for (RequestTurn action : possibleActions.getType(RequestTurn.class)) { ActionMenuItem item = new ActionMenuItem(action.toString()); item.addActionListener(this); *************** *** 417,421 **** specialActionItems.add(item); specialMenu.add(item); ! } } --- 417,421 ---- specialActionItems.add(item); specialMenu.add(item); ! } } *************** *** 507,511 **** process(executedAction); } else if (command.equals(DONE_CMD) || command.equals(PASS_CMD) ! || command.equals(AUTOPASS_CMD)) { if (gameUIManager.isGameOver()) { System.exit(0); --- 507,511 ---- process(executedAction); } else if (command.equals(DONE_CMD) || command.equals(PASS_CMD) ! || command.equals(AUTOPASS_CMD)) { if (gameUIManager.isGameOver()) { System.exit(0); *************** *** 514,518 **** } else if (executedAction instanceof UseSpecialProperty ! || executedAction instanceof RequestTurn) { process(executedAction); --- 514,518 ---- } else if (executedAction instanceof UseSpecialProperty ! || executedAction instanceof RequestTurn) { process(executedAction); Index: GUIToken.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GUIToken.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** GUIToken.java 19 Dec 2009 18:32:32 -0000 1.10 --- GUIToken.java 31 Jan 2010 22:22:33 -0000 1.11 *************** *** 27,31 **** @Override ! public void paintComponent(Graphics g) { clear(g); Graphics2D g2d = (Graphics2D) g; --- 27,31 ---- @Override ! public void paintComponent(Graphics g) { clear(g); Graphics2D g2d = (Graphics2D) g; *************** *** 86,90 **** circle = new Ellipse2D.Double(xCenter - 0.5*diameter, ! yCenter-0.5*diameter, diameter, diameter); this.setForeground(fgColor); --- 86,90 ---- circle = new Ellipse2D.Double(xCenter - 0.5*diameter, ! yCenter-0.5*diameter, diameter, diameter); this.setForeground(fgColor); *************** *** 107,111 **** @Override ! public String getName() { return name; } --- 107,111 ---- @Override ! public String getName() { return name; } Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** ORUIManager.java 24 Jan 2010 16:21:28 -0000 1.47 --- ORUIManager.java 31 Jan 2010 22:22:34 -0000 1.48 *************** *** 83,87 **** public void setGameUIManager (GameUIManager gameUIManager) { ! this.gameUIManager = gameUIManager; } --- 83,87 ---- public void setGameUIManager (GameUIManager gameUIManager) { ! this.gameUIManager = gameUIManager; } *************** *** 240,244 **** sp = tokenLay.getSpecialProperty(); if (sp != null && sp instanceof SpecialTokenLay) { ! extraMessage += "<br>" + sp.getHelp(); } else if ((locations = tokenLay.getLocationNameString()) != null) { if (normalTokenMessage.length() > 1) { --- 240,244 ---- sp = tokenLay.getSpecialProperty(); if (sp != null && sp instanceof SpecialTokenLay) { ! extraMessage += "<br>" + sp.getHelp(); } else if ((locations = tokenLay.getLocationNameString()) != null) { if (normalTokenMessage.length() > 1) { *************** *** 286,290 **** } else if (actionType == BuyBonusToken.class) { ! buyBonusToken ((BuyBonusToken)actions.get(0)); } else if (actionType == NullAction.class --- 286,290 ---- } else if (actionType == BuyBonusToken.class) { ! buyBonusToken ((BuyBonusToken)actions.get(0)); } else if (actionType == NullAction.class *************** *** 376,380 **** private void buyBonusToken (BuyBonusToken action) { ! orWindow.process(action); } --- 376,380 ---- private void buyBonusToken (BuyBonusToken action) { ! orWindow.process(action); } *************** *** 402,407 **** public void dialogActionPerformed () { ! JDialog currentDialog = getCurrentDialog(); ! PossibleAction currentDialogAction = getCurrentDialogAction(); if (currentDialog instanceof CheckBoxDialog --- 402,407 ---- public void dialogActionPerformed () { ! JDialog currentDialog = getCurrentDialog(); ! PossibleAction currentDialogAction = getCurrentDialogAction(); if (currentDialog instanceof CheckBoxDialog *************** *** 432,444 **** public JDialog getCurrentDialog() { ! return gameUIManager.getCurrentDialog(); } public PossibleAction getCurrentDialogAction () { ! return gameUIManager.getCurrentDialogAction(); } public void setCurrentDialog (JDialog dialog, PossibleAction action) { ! gameUIManager.setCurrentDialog(dialog, action); } --- 432,444 ---- public JDialog getCurrentDialog() { ! return gameUIManager.getCurrentDialog(); } public PossibleAction getCurrentDialogAction () { ! return gameUIManager.getCurrentDialogAction(); } public void setCurrentDialog (JDialog dialog, PossibleAction action) { ! gameUIManager.setCurrentDialog(dialog, action); } *************** *** 624,640 **** return; } ! // If more than one City to choose from, ask the player. Otherwise use Element zero (first) for the station. ! if (prompts.size() > 1) { ! String selected = (String) JOptionPane.showInputDialog(orWindow, ! LocalText.getText("SelectStationForToken"), ! LocalText.getText("WhichStation"), ! JOptionPane.PLAIN_MESSAGE, null, ! prompts.toArray(), prompts.get(0)); ! if (selected == null) return; ! station = promptToCityMap.get(selected).getNumber(); ! } else { ! station = promptToCityMap.get(prompts.toArray() [0]).getNumber(); ! } } --- 624,640 ---- return; } ! // If more than one City to choose from, ask the player. Otherwise use Element zero (first) for the station. ! if (prompts.size() > 1) { ! String selected = (String) JOptionPane.showInputDialog(orWindow, ! LocalText.getText("SelectStationForToken"), ! LocalText.getText("WhichStation"), ! JOptionPane.PLAIN_MESSAGE, null, ! prompts.toArray(), prompts.get(0)); ! if (selected == null) return; ! station = promptToCityMap.get(selected).getNumber(); ! } else { ! station = promptToCityMap.get(prompts.toArray() [0]).getNumber(); ! } } *************** *** 690,705 **** continue; } ! if (prompts.size () > 1) { ! String selected = ! (String) JOptionPane.showInputDialog(orWindow, ! LocalText.getText("SelectStationForToken"), ! LocalText.getText("WhichStation"), ! JOptionPane.PLAIN_MESSAGE, null, ! prompts.toArray(), prompts.get(0)); ! if (selected == null) return; ! action.addRelayBaseToken(company.getName(), promptToCityMap.get(selected)); ! } else { ! action.addRelayBaseToken(company.getName(), promptToCityMap.get(prompts.toArray() [0])); ! } } } --- 690,705 ---- continue; } ! if (prompts.size () > 1) { ! String selected = ! (String) JOptionPane.showInputDialog(orWindow, ! LocalText.getText("SelectStationForToken"), ! LocalText.getText("WhichStation"), ! JOptionPane.PLAIN_MESSAGE, null, ! prompts.toArray(), prompts.get(0)); ! if (selected == null) return; ! action.addRelayBaseToken(company.getName(), promptToCityMap.get(selected)); ! } else { ! action.addRelayBaseToken(company.getName(), promptToCityMap.get(prompts.toArray() [0])); ! } } } *************** *** 1049,1053 **** } else { //List<String> options = new ArrayList<String>(); ! String[] options = new String[maxNumber-minNumber+1]; for (int i=minNumber, j=0; i<=maxNumber; i++, j++) { if (i == 0) { --- 1049,1053 ---- } else { //List<String> options = new ArrayList<String>(); ! String[] options = new String[maxNumber-minNumber+1]; for (int i=minNumber, j=0; i<=maxNumber; i++, j++) { if (i == 0) { *************** *** 1061,1068 **** } RadioButtonDialog currentDialog = new RadioButtonDialog (gameUIManager, ! LocalText.getText("Select"), LocalText.getText("SelectLoansToRepay", action.getCompanyName()), ! options, ! 0); gameUIManager.setCurrentDialog (currentDialog, action); } --- 1061,1068 ---- } RadioButtonDialog currentDialog = new RadioButtonDialog (gameUIManager, ! LocalText.getText("Select"), LocalText.getText("SelectLoansToRepay", action.getCompanyName()), ! options, ! 0); gameUIManager.setCurrentDialog (currentDialog, action); } *************** *** 1169,1178 **** // TEMPORARY extra message about having no route for (BuyTrain bTrain : possibleActions.getType(BuyTrain.class)) { ! if (bTrain.hasNoTrains()) { ! b.append("<br><font color=\"red\">"); ! b.append(LocalText.getText("MustBuyTrainIfNoRoute")); ! b.append("</font>"); ! break; ! } } --- 1169,1178 ---- // TEMPORARY extra message about having no route for (BuyTrain bTrain : possibleActions.getType(BuyTrain.class)) { ! if (bTrain.hasNoTrains()) { ! b.append("<br><font color=\"red\">"); ! b.append(LocalText.getText("MustBuyTrainIfNoRoute")); ! b.append("</font>"); ! break; ! } } *************** *** 1392,1396 **** public GameUIManager getGameUIManager () { ! return gameUIManager; } --- 1392,1396 ---- public GameUIManager getGameUIManager () { ! return gameUIManager; } Index: UpgradesPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/UpgradesPanel.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** UpgradesPanel.java 20 Dec 2009 21:16:07 -0000 1.22 --- UpgradesPanel.java 31 Jan 2010 22:22:34 -0000 1.23 *************** *** 120,124 **** description = text = comp.getName(); if (action.getSpecialProperty() != null) { ! description += " (" + action.getSpecialProperty().getCompany().getName()+")"; } } else if (action instanceof LayBonusToken) { --- 120,124 ---- description = text = comp.getName(); if (action.getSpecialProperty() != null) { ! description += " (" + action.getSpecialProperty().getCompany().getName()+")"; } } else if (action instanceof LayBonusToken) { Index: GameUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameUIManager.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** GameUIManager.java 24 Jan 2010 14:43:24 -0000 1.38 --- GameUIManager.java 31 Jan 2010 22:22:34 -0000 1.39 *************** *** 140,144 **** public boolean processOnServer(PossibleAction action) { ! boolean result = true; // In some cases an Undo requires a different follow-up --- 140,144 ---- public boolean processOnServer(PossibleAction action) { ! boolean result = true; // In some cases an Undo requires a different follow-up *************** *** 146,179 **** if (action == null) { ! // If the action is null, we can skip processing ! // and continue with following up a previous action. ! // This occurs after a nonmodal Message dialog. ! result = previousResult; } else { ! action.setActed(); ! action.setPlayerName(getCurrentPlayer().getName()); ! log.debug("==Passing to server: " + action); ! Player player = getCurrentPlayer(); ! if (player != null) { ! action.setPlayerName(player.getName()); ! } ! // Process the action on the server ! result = previousResult = gameManager.process(action); ! // Follow-up the result ! log.debug("==Result from server: " + result); ! reportWindow.addLog(); ! /* ! if (DisplayBuffer.getAutoDisplay()) { ! if (displayServerMessage()) { ! // Interrupt processing. ! // Will be continued via dialogActionPerformed(). ! return true; ! } ! }*/ } --- 146,179 ---- if (action == null) { ! // If the action is null, we can skip processing ! // and continue with following up a previous action. ! // This occurs after a nonmodal Message dialog. ! result = previousResult; } else { ! action.setActed(); ! action.setPlayerName(getCurrentPlayer().getName()); ! log.debug("==Passing to server: " + action); ! Player player = getCurrentPlayer(); ! if (player != null) { ! action.setPlayerName(player.getName()); ! } ! // Process the action on the server ! result = previousResult = gameManager.process(action); ! // Follow-up the result ! log.debug("==Result from server: " + result); ! reportWindow.addLog(); ! /* ! if (DisplayBuffer.getAutoDisplay()) { ! if (displayServerMessage()) { ! // Interrupt processing. ! // Will be continued via dialogActionPerformed(). ! return true; ! } ! }*/ } *************** *** 199,212 **** // Is this perhaps the right place to display messages...? if (DisplayBuffer.getAutoDisplay()) { ! if (displayServerMessage()) { ! // Interrupt processing. ! // Will be continued via dialogActionPerformed(). ! return true; ! } } if (!result) return false; ! return activeWindow.processImmediateAction(); } --- 199,212 ---- // Is this perhaps the right place to display messages...? if (DisplayBuffer.getAutoDisplay()) { ! if (displayServerMessage()) { ! // Interrupt processing. ! // Will be continued via dialogActionPerformed(). ! return true; ! } } if (!result) return false; ! return activeWindow.processImmediateAction(); } *************** *** 215,221 **** if (message != null) { setCurrentDialog(new MessageDialog(this, ! LocalText.getText("Message"), ! "<html>" + Util.joinWithDelimiter(message, "<br>")), ! null); return true; } --- 215,221 ---- if (message != null) { setCurrentDialog(new MessageDialog(this, ! LocalText.getText("Message"), ! "<html>" + Util.joinWithDelimiter(message, "<br>")), ! null); return true; } *************** *** 301,333 **** // before each sequence of settings (usually at the start of a round). for (GuiHints.VisibilityHint hint : uiHints.getVisibilityHints()) { ! switch (hint.getType()) { ! case STOCK_MARKET: boolean stockChartVisibilityHint = hint.getVisibility() ! || configuredStockChartVisibility; if (stockChartVisibilityHint != previousStockChartVisibilityHint) { ! stockChart.setVisible(stockChartVisibilityHint); ! previousStockChartVisibilityHint = stockChartVisibilityHint; } ! if (hint.getVisibility()) stockChart.toFront(); break; ! case STATUS: boolean statusWindowVisibilityHint = hint.getVisibility(); if (statusWindowVisibilityHint != previousStatusWindowVisibilityHint) { ! statusWindow.setVisible(statusWindowVisibilityHint); ! previousStatusWindowVisibilityHint = statusWindowVisibilityHint; } ! if (statusWindowVisibilityHint) statusWindow.toFront(); break; ! case MAP: boolean orWindowVisibilityHint = hint.getVisibility(); if (orWindowVisibilityHint != previousORWindowVisibilityHint) { ! orWindow.setVisible(orWindowVisibilityHint); ! previousORWindowVisibilityHint = orWindowVisibilityHint; } ! if (orWindowVisibilityHint) orWindow.toFront(); break; ! case START_ROUND: ! // Handled elsewhere ! } } --- 301,333 ---- // before each sequence of settings (usually at the start of a round). for (GuiHints.VisibilityHint hint : uiHints.getVisibilityHints()) { ! switch (hint.getType()) { ! case STOCK_MARKET: boolean stockChartVisibilityHint = hint.getVisibility() ! || configuredStockChartVisibility; if (stockChartVisibilityHint != previousStockChartVisibilityHint) { ! stockChart.setVisible(stockChartVisibilityHint); ! previousStockChartVisibilityHint = stockChartVisibilityHint; } ! if (hint.getVisibility()) stockChart.toFront(); break; ! case STATUS: boolean statusWindowVisibilityHint = hint.getVisibility(); if (statusWindowVisibilityHint != previousStatusWindowVisibilityHint) { ! statusWindow.setVisible(statusWindowVisibilityHint); ! previousStatusWindowVisibilityHint = statusWindowVisibilityHint; } ! if (statusWindowVisibilityHint) statusWindow.toFront(); break; ! case MAP: boolean orWindowVisibilityHint = hint.getVisibility(); if (orWindowVisibilityHint != previousORWindowVisibilityHint) { ! orWindow.setVisible(orWindowVisibilityHint); ! previousORWindowVisibilityHint = orWindowVisibilityHint; } ! if (orWindowVisibilityHint) orWindow.toFront(); break; ! case START_ROUND: ! // Handled elsewhere ! } } *************** *** 493,569 **** public void dialogActionPerformed () { ! dialogActionPerformed(false); } public void dialogActionPerformed (boolean ready) { ! if (!ready) { ! if (currentDialog instanceof RadioButtonDialog ! && currentDialogAction instanceof StartCompany) { ! RadioButtonDialog dialog = (RadioButtonDialog) currentDialog; ! StartCompany action = (StartCompany) currentDialogAction; ! int index = dialog.getSelectedOption(); ! if (index >= 0) { ! int price = action.getStartPrices()[index]; ! action.setStartPrice(price); ! action.setNumberBought(action.getCertificate().getShares()); ! } else { ! // No selection done - no action ! return; ! } ! } else if (currentDialog instanceof CheckBoxDialog ! && currentDialogAction instanceof ExchangeTokens) { ! CheckBoxDialog dialog = (CheckBoxDialog) currentDialog; ! ExchangeTokens action = (ExchangeTokens) currentDialogAction; ! boolean[] exchanged = dialog.getSelectedOptions(); ! String[] options = dialog.getOptions(); ! int numberSelected = 0; ! for (int index=0; index < options.length; index++) { ! if (exchanged[index]) { ! numberSelected++; ! } ! } ! int minNumber = action.getMinNumberToExchange(); ! int maxNumber = action.getMaxNumberToExchange(); ! if (numberSelected < minNumber ! || numberSelected > maxNumber) { ! if (minNumber == maxNumber) { ! JOptionPane.showMessageDialog(null, ! LocalText.getText("YouMustSelect1", minNumber)); ! } else { ! JOptionPane.showMessageDialog(null, ! LocalText.getText("YouMustSelect2", minNumber, maxNumber)); ! } ! exchangeTokens (action); ! return; ! } ! for (int index=0; index < options.length; index++) { ! if (exchanged[index]) { ! action.getTokensToExchange().get(index).setSelected(true); ! } ! } ! } else if (currentDialog instanceof RadioButtonDialog ! && currentDialogAction instanceof RepayLoans) { ! RadioButtonDialog dialog = (RadioButtonDialog) currentDialog; ! RepayLoans action = (RepayLoans) currentDialogAction; ! int selected = dialog.getSelectedOption(); ! action.setNumberTaken(action.getMinNumber() + selected); ! } else if (currentDialog instanceof MessageDialog) { ! // Nothing to do ! currentDialogAction = null; // Should already be null ! } else { ! return; ! } ! } processOnServer(currentDialogAction); --- 493,569 ---- public void dialogActionPerformed () { ! dialogActionPerformed(false); } public void dialogActionPerformed (boolean ready) { ! if (!ready) { ! if (currentDialog instanceof RadioButtonDialog ! && currentDialogAction instanceof StartCompany) { ! RadioButtonDialog dialog = (RadioButtonDialog) currentDialog; ! StartCompany action = (StartCompany) currentDialogAction; ! int index = dialog.getSelectedOption(); ! if (index >= 0) { ! int price = action.getStartPrices()[index]; ! action.setStartPrice(price); ! action.setNumberBought(action.getCertificate().getShares()); ! } else { ! // No selection done - no action ! return; ! } ! } else if (currentDialog instanceof CheckBoxDialog ! && currentDialogAction instanceof ExchangeTokens) { ! CheckBoxDialog dialog = (CheckBoxDialog) currentDialog; ! ExchangeTokens action = (ExchangeTokens) currentDialogAction; ! boolean[] exchanged = dialog.getSelectedOptions(); ! String[] options = dialog.getOptions(); ! int numberSelected = 0; ! for (int index=0; index < options.length; index++) { ! if (exchanged[index]) { ! numberSelected++; ! } ! } ! int minNumber = action.getMinNumberToExchange(); ! int maxNumber = action.getMaxNumberToExchange(); ! if (numberSelected < minNumber ! || numberSelected > maxNumber) { ! if (minNumber == maxNumber) { ! JOptionPane.showMessageDialog(null, ! LocalText.getText("YouMustSelect1", minNumber)); ! } else { ! JOptionPane.showMessageDialog(null, ! LocalText.getText("YouMustSelect2", minNumber, maxNumber)); ! } ! exchangeTokens (action); ! return; ! } ! for (int index=0; index < options.length; index++) { ! if (exchanged[index]) { ! action.getTokensToExchange().get(index).setSelected(true); ! } ! } ! } else if (currentDialog instanceof RadioButtonDialog ! && currentDialogAction instanceof RepayLoans) { ! RadioButtonDialog dialog = (RadioButtonDialog) currentDialog; ! RepayLoans action = (RepayLoans) currentDialogAction; ! int selected = dialog.getSelectedOption(); ! action.setNumberTaken(action.getMinNumber() + selected); ! } else if (currentDialog instanceof MessageDialog) { ! // Nothing to do ! currentDialogAction = null; // Should already be null ! } else { ! return; ! } ! } processOnServer(currentDialogAction); *************** *** 571,587 **** public JDialog getCurrentDialog() { ! return currentDialog; } public PossibleAction getCurrentDialogAction () { ! return currentDialogAction; } public void setCurrentDialog (JDialog dialog, PossibleAction action) { ! if (currentDialog != null) { ! currentDialog.dispose(); ! } ! currentDialog = dialog; ! currentDialogAction = action; } --- 571,587 ---- public JDialog getCurrentDialog() { ! return currentDialog; } public PossibleAction getCurrentDialogAction () { ! return currentDialogAction; } public void setCurrentDialog (JDialog dialog, PossibleAction action) { ! if (currentDialog != null) { ! currentDialog.dispose(); ! } ! currentDialog = dialog; ! currentDialogAction = action; } Index: ImageLoader.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ImageLoader.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ImageLoader.java 19 Dec 2009 16:48:32 -0000 1.15 --- ImageLoader.java 31 Jan 2010 22:22:34 -0000 1.16 *************** *** 73,95 **** try { ! // Experimental new version, that stacks the XML to allow zooming ! if (svgMap == null) { ! svgMap = new HashMap<Integer, Document>(64); ! } ! if (!svgMap.containsKey(tileID)) { ! Document doc = null; ! // Step 1: create a DocumentBuilderFactory and setNamespaceAware ! DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); ! dbf.setNamespaceAware(true); ! // Step 2: create a DocumentBuilder ! DocumentBuilder db = dbf.newDocumentBuilder(); ! // Step 3: parse the input file to get a Document object ! doc = ! db.parse(ResourceLoader.getInputStream(fn, ! directories)); ! // Cache the doc ! svgMap.put(tileID, doc); ! } BufferedImageTranscoder t = new BufferedImageTranscoder(); t.addTranscodingHint(ImageTranscoder.KEY_MAX_WIDTH, new Float(svgWidth * zoomFactor)); --- 73,95 ---- try { ! // Experimental new version, that stacks the XML to allow zooming ! if (svgMap == null) { ! svgMap = new HashMap<Integer, Document>(64); ! } ! if (!svgMap.containsKey(tileID)) { ! Document doc = null; ! // Step 1: create a DocumentBuilderFactory and setNamespaceAware ! DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); ! dbf.setNamespaceAware(true); ! // Step 2: create a DocumentBuilder ! DocumentBuilder db = dbf.newDocumentBuilder(); ! // Step 3: parse the input file to get a Document object ! doc = ! db.parse(ResourceLoader.getInputStream(fn, ! directories)); ! // Cache the doc ! svgMap.put(tileID, doc); ! } BufferedImageTranscoder t = new BufferedImageTranscoder(); t.addTranscodingHint(ImageTranscoder.KEY_MAX_WIDTH, new Float(svgWidth * zoomFactor)); *************** *** 111,122 **** if (tileMap == null) { ! tileMap = new HashMap<Integer, Map<Integer, BufferedImage>>(64); } if (!tileMap.containsKey(tileID)) { ! tileMap.put(tileID, new HashMap<Integer, BufferedImage>(4)); ! } ! if (!tileMap.get(tileID).containsKey(zoomStep)) { ! BufferedImage image = getSVGTile(tileID, getZoomFactor(zoomStep)); ! tileMap.get(tileID).put(zoomStep, image); } --- 111,122 ---- if (tileMap == null) { ! tileMap = new HashMap<Integer, Map<Integer, BufferedImage>>(64); } if (!tileMap.containsKey(tileID)) { ! tileMap.put(tileID, new HashMap<Integer, BufferedImage>(4)); ! } ! if (!tileMap.get(tileID).containsKey(zoomStep)) { ! BufferedImage image = getSVGTile(tileID, getZoomFactor(zoomStep)); ! tileMap.get(tileID).put(zoomStep, image); } *************** *** 125,134 **** public double getZoomFactor (int zoomStep) { ! if (zoomStep < 0) zoomStep = 0; ! else if (zoomStep > 20) zoomStep = 20; ! if (zoomFactors[zoomStep] == 0.0) { ! zoomFactors[zoomStep] = 1.0 * Math.pow(2.0, 0.25*(zoomStep-10)); ! } ! return zoomFactors[zoomStep]; } --- 125,134 ---- public double getZoomFactor (int zoomStep) { ! if (zoomStep < 0) zoomStep = 0; ! else if (zoomStep > 20) zoomStep = 20; ! if (zoomFactors[zoomStep] == 0.0) { ! zoomFactors[zoomStep] = 1.0 * Math.pow(2.0, 0.25*(zoomStep-10)); ! } ! return zoomFactors[zoomStep]; } Index: GameSetupWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameSetupWindow.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** GameSetupWindow.java 14 Jan 2010 20:50:08 -0000 1.20 --- GameSetupWindow.java 31 Jan 2010 22:22:34 -0000 1.21 *************** *** 379,383 **** JOptionPane.showMessageDialog(this, startError, "", JOptionPane.ERROR_MESSAGE); ! System.exit(-1); } startGameUIManager (game); --- 379,383 ---- JOptionPane.showMessageDialog(this, startError, "", JOptionPane.ERROR_MESSAGE); ! System.exit(-1); } startGameUIManager (game); Index: ORWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORWindow.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** ORWindow.java 20 Jan 2010 19:52:44 -0000 1.33 --- ORWindow.java 31 Jan 2010 22:22:34 -0000 1.34 *************** *** 146,157 **** public void activate(OperatingRound or) { ! GameManager gameManager = (GameManager) gameUIManager.getGameManager(); ! String numORs = gameManager.getNumOfORs (); orPanel.recreate(or); setTitle(LocalText.getText("MapWindowORTitle", ! gameManager.getORId(), ! String.valueOf(gameManager.getRelativeORNumber()), ! numORs )); pack(); if (lastBounds != null) { --- 146,157 ---- public void activate(OperatingRound or) { ! GameManager gameManager = (GameManager) gameUIManager.getGameManager(); ! String numORs = gameManager.getNumOfORs (); orPanel.recreate(or); setTitle(LocalText.getText("MapWindowORTitle", ! gameManager.getORId(), ! String.valueOf(gameManager.getRelativeORNumber()), ! numORs )); pack(); if (lastBounds != null) { *************** *** 165,171 **** public void updateStatus() { ! // Safety check. Do nothing if this method is called outside Operating Rounds, ! // for instance when a token is exchanged during a Stock Round. ! if (!(gameUIManager.getCurrentRound() instanceof OperatingRound)) return; orUIManager.updateStatus(); --- 165,171 ---- public void updateStatus() { ! // Safety check. Do nothing if this method is called outside Operating Rounds, ! // for instance when a token is exchanged during a Stock Round. ! if (!(gameUIManager.getCurrentRound() instanceof OperatingRound)) return; orUIManager.updateStatus(); Index: GameStatus.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GameStatus.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** GameStatus.java 14 Jan 2010 20:50:08 -0000 1.37 --- GameStatus.java 31 Jan 2010 22:22:34 -0000 1.38 *************** *** 390,398 **** } if (hasCompanyLoans) { ! if (c.getLoanValueModel() != null) { ! f = compLoans[i] = new Field (c.getLoanValueModel()); ! } else { ! f = compLoans[i] = new Field (""); ! } addField (f, compLoansXOffset, compLoansYOffset+i, 1, 1, 0, visible); } --- 390,398 ---- } if (hasCompanyLoans) { ! if (c.getLoanValueModel() != null) { ! f = compLoans[i] = new Field (c.getLoanValueModel()); ! } else { ! f = compLoans[i] = new Field (""); ! } addField (f, compLoansXOffset, compLoansYOffset+i, 1, 1, 0, visible); } *************** *** 489,493 **** String text = gameUIManager.getGameManager().getTrainManager().getTrainCostOverview(); addField (new Caption(text), poolTrainsXOffset, newTrainsYOffset + 1, ! futureTrainsWidth + 2, 1, 0, true); dummyButton = new ClickField("", "", "", this, buySellGroup); --- 489,493 ---- String text = gameUIManager.getGameManager().getTrainManager().getTrainCostOverview(); addField (new Caption(text), poolTrainsXOffset, newTrainsYOffset + 1, ! futureTrainsWidth + 2, 1, 0, true); dummyButton = new ClickField("", "", "", this, buySellGroup); *************** *** 626,630 **** if (options.size() > 1) { if (startCompany) { ! RadioButtonDialog dialog = new RadioButtonDialog (gameUIManager, LocalText.getText("PleaseSelect"), LocalText.getText("WHICH_START_PRICE", --- 626,630 ---- if (options.size() > 1) { if (startCompany) { ! RadioButtonDialog dialog = new RadioButtonDialog (gameUIManager, LocalText.getText("PleaseSelect"), LocalText.getText("WHICH_START_PRICE", *************** *** 632,637 **** companyName), options.toArray(new String[0]), -1); ! gameUIManager.setCurrentDialog(dialog, actions.get(0)); ! return; } else { String sp = --- 632,637 ---- companyName), options.toArray(new String[0]), -1); ! gameUIManager.setCurrentDialog(dialog, actions.get(0)); ! return; } else { String sp = Index: ORPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORPanel.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** ORPanel.java 19 Jan 2010 19:51:57 -0000 1.43 --- ORPanel.java 31 Jan 2010 22:22:34 -0000 1.44 *************** *** 415,419 **** if (hasCompanyLoans) { //if (c.canLoan()) { ! if (c.getLoanValueModel() != null) { f = compLoans[i] = new Field (c.getLoanValueModel()); } else { --- 415,419 ---- if (hasCompanyLoans) { //if (c.canLoan()) { ! if (c.getLoanValueModel() != null) { f = compLoans[i] = new Field (c.getLoanValueModel()); } else { *************** *** 508,513 **** protected void addTrainsInfo() { ! TrainManager tm = orWindow.getGameUIManager().getGameManager().getTrainManager(); ! List<TrainTypeI> types = tm.getTrainTypes(); JMenu item; StringBuffer b = new StringBuffer("<html>"); --- 508,513 ---- protected void addTrainsInfo() { ! TrainManager tm = orWindow.getGameUIManager().getGameManager().getTrainManager(); ! List<TrainTypeI> types = tm.getTrainTypes(); JMenu item; StringBuffer b = new StringBuffer("<html>"); *************** *** 518,532 **** for (TrainTypeI type : types) { ! b.setLength(6); ! if (Util.hasValue(type.getStartedPhaseName())) { ! appendInfoText(b, LocalText.getText("StartsPhase", type.getStartedPhaseName())); ! } ! if (type.getRustedTrainType() != null) { ! appendInfoText(b, LocalText.getText("RustsTrains", type.getRustedTrainType().getName())); ! } ! if (type.getReleasedTrainType() != null) { ! appendInfoText(b, LocalText.getText("ReleasesTrains", type.getReleasedTrainType().getName())); ! } ! if (b.length() == 6) b.append(LocalText.getText("None")); item = new JMenu (LocalText.getText("N_Train", type.getName())); --- 518,532 ---- for (TrainTypeI type : types) { ! b.setLength(6); ! if (Util.hasValue(type.getStartedPhaseName())) { ! appendInfoText(b, LocalText.getText("StartsPhase", type.getStartedPhaseName())); ! } ! if (type.getRustedTrainType() != null) { ! appendInfoText(b, LocalText.getText("RustsTrains", type.getRustedTrainType().getName())); ! } ! if (type.getReleasedTrainType() != null) { ! appendInfoText(b, LocalText.getText("ReleasesTrains", type.getReleasedTrainType().getName())); ! } ! if (b.length() == 6) b.append(LocalText.getText("None")); item = new JMenu (LocalText.getText("N_Train", type.getName())); *************** *** 534,544 **** item.add(new JMenuItem(b.toString())); trainsInfoMenu.add(item); ! } } protected void addPhasesInfo() { ! PhaseManager pm = orWindow.getGameUIManager().getGameManager().getPhaseManager(); ! List<Phase> phases = pm.getPhases(); JMenu item; StringBuffer b = new StringBuffer("<html>"); --- 534,544 ---- item.add(new JMenuItem(b.toString())); trainsInfoMenu.add(item); ! } } protected void addPhasesInfo() { ! PhaseManager pm = orWindow.getGameUIManager().getGameManager().getPhaseManager(); ! List<Phase> phases = pm.getPhases(); JMenu item; StringBuffer b = new StringBuffer("<html>"); *************** *** 549,575 **** for (Phase phase : phases) { ! b.setLength(6); ! appendInfoText(b, LocalText.getText("PhaseTileColours", phase.getTileColoursString())); ! appendInfoText(b, LocalText.getText("PhaseNumberOfORs", phase.getNumberOfOperatingRounds())); ! appendInfoText(b, LocalText.getText("PhaseOffBoardStep", phase.getOffBoardRevenueStep())); ! if (phase.doPrivatesClose()) { ! appendInfoText(b, LocalText.getText("PhaseClosesAllPrivates")); ! } ! if (phase.getClosedObjects() != null) { ! for (Closeable object : phase.getClosedObjects()) { ! appendInfoText(b, LocalText.getText("PhaseRemoves", Util.lowerCaseFirst(object.getInfo()))); ! } ! } item = new JMenu (LocalText.getText("PhaseX", phase.getName())); item.setEnabled(true); item.add(new JMenuItem(b.toString())); phasesInfoMenu.add(item); ! } } private void appendInfoText (StringBuffer b, String text) { ! if (text == null || text.length() == 0) return; ! if (b.length() > 6) b.append("<br>"); ! b.append(text); } --- 549,575 ---- for (Phase phase : phases) { ! b.setLength(6); ! appendInfoText(b, LocalText.getText("PhaseTileColours", phase.getTileColoursString())); ! appendInfoText(b, LocalText.getText("PhaseNumberOfORs", phase.getNumberOfOperatingRounds())); ! appendInfoText(b, LocalText.getText("PhaseOffBoardStep", phase.getOffBoardRevenueStep())); ! if (phase.doPrivatesClose()) { ! appendInfoText(b, LocalText.getText("PhaseClosesAllPrivates")); ! } ! if (phase.getClosedObjects() != null) { ! for (Closeable object : phase.getClosedObjects()) { ! appendInfoText(b, LocalText.getText("PhaseRemoves", Util.lowerCaseFirst(object.getInfo()))); ! } ! } item = new JMenu (LocalText.getText("PhaseX", phase.getName())); item.setEnabled(true); item.add(new JMenuItem(b.toString())); phasesInfoMenu.add(item); ! } } private void appendInfoText (StringBuffer b, String text) { ! if (text == null || text.length() == 0) return; ! if (b.length() > 6) b.append("<br>"); ! b.append(text); } *************** *** 611,617 **** orUIManager.processAction(command, executedActions); } else if (source == zoomIn) { ! orWindow.getMapPanel().zoomIn(); } else if (source == zoomOut) { ! orWindow.getMapPanel().zoomOut(); } else { orUIManager.processAction(command, null); --- 611,617 ---- orUIManager.processAction(command, executedActions); } else if (source == zoomIn) { ! orWindow.getMapPanel().zoomIn(); } else if (source == zoomOut) { ! orWindow.getMapPanel().zoomOut(); } else { orUIManager.processAction(command, null); Index: StartRoundWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StartRoundWindow.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** StartRoundWindow.java 20 Jan 2010 19:52:44 -0000 1.35 --- StartRoundWindow.java 31 Jan 2010 22:22:34 -0000 1.36 *************** *** 468,473 **** buyButton.setEnabled(buyAllowed); if (includeBidding) { ! bidButton.setEnabled(bidAllowed); ! bidAmount.setEnabled(bidAllowed); } passButton.setEnabled(passAllowed); --- 468,473 ---- buyButton.setEnabled(buyAllowed); if (includeBidding) { ! bidButton.setEnabled(bidAllowed); ! bidAmount.setEnabled(bidAllowed); } passButton.setEnabled(passAllowed); Index: GridPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/GridPanel.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GridPanel.java 20 Jan 2010 19:52:44 -0000 1.3 --- GridPanel.java 31 Jan 2010 22:22:34 -0000 1.4 *************** *** 113,126 **** public void setRowVisibility (int rowIndex, boolean value) { ! List<JComponent> dependents; ! for (int j=0; j < fields.length; j++) { if (fields[j][rowIndex] != null) { fields[j][rowIndex].setVisible(value); if (fields[j][rowIndex] instanceof Field ! && (dependents = ((Field)fields[j][rowIndex]).getDependents()) != null) { ! for (JComponent dependent : dependents) { ! dependent.setVisible(value); ! } } } --- 113,126 ---- public void setRowVisibility (int rowIndex, boolean value) { ! List<JComponent> dependents; ! for (int j=0; j < fields.length; j++) { if (fields[j][rowIndex] != null) { fields[j][rowIndex].setVisible(value); if (fields[j][rowIndex] instanceof Field ! && (dependents = ((Field)fields[j][rowIndex]).getDependents()) != null) { ! for (JComponent dependent : dependents) { ! dependent.setVisible(value); ! } } } Index: MapPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/MapPanel.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** MapPanel.java 18 Dec 2009 20:04:31 -0000 1.13 --- MapPanel.java 31 Jan 2010 22:22:34 -0000 1.14 *************** *** 52,58 **** add(scrollPane, BorderLayout.CENTER); ! scrollPane.setSize(map.getPreferredSize()); ! setSize(map.getPreferredSize().width, map.getPreferredSize().height); setLocation(25, 25); } --- 52,58 ---- add(scrollPane, BorderLayout.CENTER); ! scrollPane.setSize(map.getPreferredSize()); ! setSize(map.getPreferredSize().width, map.getPreferredSize().height); setLocation(25, 25); } *************** *** 68,76 **** public void zoomIn() { ! map.zoomIn(); } public void zoomOut() { ! map.zoomOut(); } --- 68,76 ---- public void zoomIn() { ! map.zoomIn(); } public void zoomOut() { ! map.zoomOut(); } |