| 20 | import static micropolisj.gui.MainWindow.formatGameDate; |
| 21 | |
| 22 | public class BudgetDialog extends JDialog |
| 23 | { |
| 24 | Micropolis engine; |
| 25 | |
| 26 | JSpinner taxRateEntry; |
| 27 | int origTaxRate; |
| 28 | double origRoadPct; |
| 29 | double origFirePct; |
| 30 | double origPolicePct; |
| 31 | |
| 32 | JLabel roadFundRequest = new JLabel(); |
| 33 | JLabel roadFundAlloc = new JLabel(); |
| 34 | JSlider roadFundEntry; |
| 35 | |
| 36 | JLabel policeFundRequest = new JLabel(); |
| 37 | JLabel policeFundAlloc = new JLabel(); |
| 38 | JSlider policeFundEntry; |
| 39 | |
| 40 | JLabel fireFundRequest = new JLabel(); |
| 41 | JLabel fireFundAlloc = new JLabel(); |
| 42 | JSlider fireFundEntry; |
| 43 | |
| 44 | JLabel taxRevenueLbl = new JLabel(); |
| 45 | |
| 46 | static ResourceBundle strings = MainWindow.strings; |
| 47 | |
| 48 | JCheckBox autoBudgetBtn = new JCheckBox(strings.getString("budgetdlg.auto_budget")); |
| 49 | JCheckBox pauseBtn = new JCheckBox(strings.getString("budgetdlg.pause_game")); |
| 50 | |
| 51 | private void applyChange() |
| 52 | { |
| 53 | int newTaxRate = ((Number) taxRateEntry.getValue()).intValue(); |
| 54 | int newRoadPct = ((Number) roadFundEntry.getValue()).intValue(); |
| 55 | int newPolicePct = ((Number) policeFundEntry.getValue()).intValue(); |
| 56 | int newFirePct = ((Number) fireFundEntry.getValue()).intValue(); |
| 57 | |
| 58 | engine.cityTax = newTaxRate; |
| 59 | engine.roadPercent = (double)newRoadPct / 100.0; |
| 60 | engine.policePercent = (double)newPolicePct / 100.0; |
| 61 | engine.firePercent = (double)newFirePct / 100.0; |
| 62 | |
| 63 | loadBudgetNumbers(false); |
| 64 | } |
| 65 | |
| 66 | private void loadBudgetNumbers(boolean updateEntries) |
| 67 | { |
| 68 | BudgetNumbers b = engine.generateBudget(); |
| 69 | if (updateEntries) |
| 70 | { |
| 71 | taxRateEntry.setValue(b.taxRate); |
| 72 | roadFundEntry.setValue((int)Math.round(b.roadPercent*100.0)); |
| 73 | policeFundEntry.setValue((int)Math.round(b.policePercent*100.0)); |
| 74 | fireFundEntry.setValue((int)Math.round(b.firePercent*100.0)); |
| 75 | } |
| 76 | |
| 77 | taxRevenueLbl.setText(formatFunds(b.taxIncome)); |
| 78 | |
| 79 | roadFundRequest.setText(formatFunds(b.roadRequest)); |
nothing calls this directly
no outgoing calls
no test coverage detected