From e392475299d6bedfef4cb2ee1879f85ccb1c850c Mon Sep 17 00:00:00 2001 From: Michael Vehrs Date: Sat, 19 Jun 2010 08:21:10 +0000 Subject: [PATCH] Remove static Specification from gui/panel. --- build/installer/lang.xml_alb | 36 --------------- build/installer/lang.xml_nds | 36 --------------- src/net/sf/freecol/client/gui/Canvas.java | 10 ++++ .../client/gui/action/NewEmptyMapAction.java | 2 +- .../client/gui/panel/AdvantageCellEditor.java | 6 +-- .../client/gui/panel/BuildQueuePanel.java | 27 +++++------ .../freecol/client/gui/panel/ColonyPanel.java | 7 ++- .../client/gui/panel/ColopediaPanel.java | 46 +++++++++---------- .../gui/panel/DefaultTransferHandler.java | 4 +- .../client/gui/panel/DifficultyDialog.java | 8 ++-- .../client/gui/panel/DragListener.java | 6 +-- .../gui/panel/EditSettlementDialog.java | 3 +- .../freecol/client/gui/panel/EuropePanel.java | 3 +- .../client/gui/panel/FreeColDialog.java | 11 ++--- .../client/gui/panel/FreeColPanel.java | 2 +- .../freecol/client/gui/panel/LabourData.java | 5 +- .../freecol/client/gui/panel/MapControls.java | 4 +- .../gui/panel/MapEditorTransformPanel.java | 17 ++++--- .../sf/freecol/client/gui/panel/MiniMap.java | 3 +- .../client/gui/panel/PlayersTable.java | 4 +- .../client/gui/panel/RebelToolTip.java | 2 +- .../client/gui/panel/RecruitDialog.java | 2 +- .../client/gui/panel/ReportCargoPanel.java | 2 +- .../client/gui/panel/ReportColonyPanel.java | 7 ++- .../panel/ReportContinentalCongressPanel.java | 3 +- .../client/gui/panel/ReportLabourPanel.java | 7 ++- .../client/gui/panel/ReportMilitaryPanel.java | 7 ++- .../client/gui/panel/ReportNavalPanel.java | 2 +- .../gui/panel/ReportProductionPanel.java | 5 +- .../gui/panel/ReportReligiousPanel.java | 2 +- .../gui/panel/ReportRequirementsPanel.java | 9 ++-- .../client/gui/panel/ReportTradePanel.java | 5 +- .../freecol/client/gui/panel/TilePanel.java | 7 ++- .../gui/panel/TradeRouteInputDialog.java | 3 +- .../freecol/client/gui/panel/TrainDialog.java | 7 ++- .../freecol/client/gui/panel/UnitLabel.java | 5 +- .../client/gui/panel/WarehouseDialog.java | 3 +- 37 files changed, 117 insertions(+), 201 deletions(-) delete mode 100644 build/installer/lang.xml_alb delete mode 100644 build/installer/lang.xml_nds diff --git a/build/installer/lang.xml_alb b/build/installer/lang.xml_alb deleted file mode 100644 index 2f6454506..000000000 --- a/build/installer/lang.xml_alb +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/build/installer/lang.xml_nds b/build/installer/lang.xml_nds deleted file mode 100644 index 0e5518c56..000000000 --- a/build/installer/lang.xml_nds +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/net/sf/freecol/client/gui/Canvas.java b/src/net/sf/freecol/client/gui/Canvas.java index 88e1a3ef7..22a6184be 100644 --- a/src/net/sf/freecol/client/gui/Canvas.java +++ b/src/net/sf/freecol/client/gui/Canvas.java @@ -114,6 +114,7 @@ import net.sf.freecol.common.model.Map.Direction; import net.sf.freecol.common.model.ModelMessage; import net.sf.freecol.common.model.Player; import net.sf.freecol.common.model.Settlement; +import net.sf.freecol.common.model.Specification; import net.sf.freecol.common.model.StringTemplate; import net.sf.freecol.common.model.Tile; import net.sf.freecol.common.model.TradeRoute; @@ -1668,6 +1669,15 @@ public final class Canvas extends JDesktopPane { return freeColClient; } + /** + * Describe getSpecification method here. + * + * @return a Specification value + */ + public Specification getSpecification() { + return freeColClient.getGame().getSpecification(); + } + /** * Displays a quit dialog and, if desired, logs out of the current game and * shows the new game panel. diff --git a/src/net/sf/freecol/client/gui/action/NewEmptyMapAction.java b/src/net/sf/freecol/client/gui/action/NewEmptyMapAction.java index d649ff512..591d262ca 100644 --- a/src/net/sf/freecol/client/gui/action/NewEmptyMapAction.java +++ b/src/net/sf/freecol/client/gui/action/NewEmptyMapAction.java @@ -65,7 +65,7 @@ public class NewEmptyMapAction extends MapboardAction { final Canvas canvas = getFreeColClient().getCanvas(); final Game game = freeColClient.getGame(); - Dimension size = canvas.showFreeColDialog(FreeColDialog.createMapSizeDialog()); + Dimension size = canvas.showFreeColDialog(FreeColDialog.createMapSizeDialog(canvas)); if (size == null) { return; } diff --git a/src/net/sf/freecol/client/gui/panel/AdvantageCellEditor.java b/src/net/sf/freecol/client/gui/panel/AdvantageCellEditor.java index 317a7b6af..84ee96ee9 100644 --- a/src/net/sf/freecol/client/gui/panel/AdvantageCellEditor.java +++ b/src/net/sf/freecol/client/gui/panel/AdvantageCellEditor.java @@ -20,13 +20,13 @@ package net.sf.freecol.client.gui.panel; +import java.util.List; import java.util.Vector; import javax.swing.DefaultCellEditor; import javax.swing.JComboBox; import javax.swing.JLabel; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.gui.i18n.Messages; import net.sf.freecol.client.gui.plaf.FreeColComboBoxRenderer; import net.sf.freecol.common.model.EuropeanNationType; @@ -42,8 +42,8 @@ public final class AdvantageCellEditor extends DefaultCellEditor { /** * A standard constructor. */ - public AdvantageCellEditor() { - super(new JComboBox(new Vector(FreeCol.getSpecification().getEuropeanNationTypes()))); + public AdvantageCellEditor(List nationTypes) { + super(new JComboBox(new Vector(nationTypes))); ((JComboBox) getComponent()).setRenderer(new AdvantageRenderer()); } diff --git a/src/net/sf/freecol/client/gui/panel/BuildQueuePanel.java b/src/net/sf/freecol/client/gui/panel/BuildQueuePanel.java index 8bc606ecf..fc4dc12ca 100644 --- a/src/net/sf/freecol/client/gui/panel/BuildQueuePanel.java +++ b/src/net/sf/freecol/client/gui/panel/BuildQueuePanel.java @@ -68,7 +68,6 @@ import net.sf.freecol.client.gui.i18n.Messages; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.plaf.FreeColComboBoxRenderer; -import net.sf.freecol.FreeCol; import net.sf.freecol.common.model.Ability; import net.sf.freecol.common.model.AbstractGoods; import net.sf.freecol.common.model.BuildableType; @@ -116,16 +115,7 @@ public class BuildQueuePanel extends FreeColPanel implements ActionListener, Ite * A list of unit types that can be build. Most unit types are * human and can never be built. */ - private static final List buildableUnits = new ArrayList(); - - static { - for (UnitType unitType : FreeCol.getSpecification().getUnitTypeList()) { - if (!unitType.getGoodsRequired().isEmpty()) { - // can be built - buildableUnits.add(unitType); - } - } - } + private List buildableUnits = new ArrayList(); public BuildQueuePanel(Colony colony, Canvas parent) { @@ -133,6 +123,13 @@ public class BuildQueuePanel extends FreeColPanel implements ActionListener, Ite this.colony = colony; this.unitCount = colony.getUnitCount(); + for (UnitType unitType : getSpecification().getUnitTypeList()) { + if (!unitType.getGoodsRequired().isEmpty()) { + // can be built + buildableUnits.add(unitType); + } + } + DefaultListModel current = new DefaultListModel(); for (BuildableType type : colony.getBuildQueue()) { current.addElement(type); @@ -256,7 +253,7 @@ public class BuildQueuePanel extends FreeColPanel implements ActionListener, Ite .hasAbility("model.ability.build", unitType, getGame().getTurn()) || featureContainer.hasAbility("model.ability.build", unitType))) { boolean builderFound = false; - for (Ability ability : FreeCol.getSpecification().getAbilities("model.ability.build")) { + for (Ability ability : getSpecification().getAbilities("model.ability.build")) { if (ability.appliesTo(unitType) && ability.getValue() && ability.getSource() != null @@ -276,7 +273,7 @@ public class BuildQueuePanel extends FreeColPanel implements ActionListener, Ite for (Entry entry : requiredAbilities.entrySet()) { if (colony.hasAbility(entry.getKey()) != entry.getValue() && featureContainer.hasAbility(entry.getKey()) != entry.getValue()) { - List sources = FreeCol.getSpecification() + List sources = getSpecification() .getTypesProviding(entry.getKey(), entry.getValue()); if (sources.isEmpty()) { // no type provides the required ability @@ -303,7 +300,7 @@ public class BuildQueuePanel extends FreeColPanel implements ActionListener, Ite DefaultListModel buildings = (DefaultListModel) buildingList.getModel(); DefaultListModel current = (DefaultListModel) buildQueueList.getModel(); buildings.clear(); - loop: for (BuildingType buildingType : FreeCol.getSpecification().getBuildingTypeList()) { + loop: for (BuildingType buildingType : getSpecification().getBuildingTypeList()) { // compare colony.getNoBuildReason() List lockReason = new ArrayList(); Building colonyBuilding = colony.getBuilding(buildingType); @@ -330,7 +327,7 @@ public class BuildQueuePanel extends FreeColPanel implements ActionListener, Ite for (Entry entry : requiredAbilities.entrySet()) { if (colony.hasAbility(entry.getKey()) != entry.getValue() && featureContainer.hasAbility(entry.getKey()) != entry.getValue()) { - List sources = FreeCol.getSpecification() + List sources = getSpecification() .getTypesProviding(entry.getKey(), entry.getValue()); if (sources.isEmpty()) { // no type provides the required ability diff --git a/src/net/sf/freecol/client/gui/panel/ColonyPanel.java b/src/net/sf/freecol/client/gui/panel/ColonyPanel.java index c9f9fd98f..5ad85f481 100644 --- a/src/net/sf/freecol/client/gui/panel/ColonyPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ColonyPanel.java @@ -63,7 +63,6 @@ import javax.swing.SwingUtilities; import javax.swing.border.BevelBorder; import net.miginfocom.swing.MigLayout; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.GUI; @@ -507,11 +506,11 @@ public final class ColonyPanel extends FreeColPanel implements ActionListener,Pr public void updateProductionPanel() { rightProductionPanel.removeAll(); - GoodsType grain = Specification.getSpecification().getGoodsType("model.goods.food"); + GoodsType grain = getSpecification().getGoodsType("model.goods.food"); int food = 0; List foodProduction = new ArrayList(); - for (GoodsType goodsType : Specification.getSpecification().getGoodsTypeList()) { + for (GoodsType goodsType : getSpecification().getGoodsTypeList()) { int production = colony.getProductionOf(goodsType); if (production != 0) { if (goodsType.isFoodType()) { @@ -1154,7 +1153,7 @@ public final class ColonyPanel extends FreeColPanel implements ActionListener,Pr private void update() { removeAll(); - for (GoodsType goodsType : FreeCol.getSpecification().getGoodsTypeList()) { + for (GoodsType goodsType : getSpecification().getGoodsTypeList()) { if (goodsType.isStorable()) { Goods goods = colony.getGoodsContainer().getGoods(goodsType); if (goods.getAmount() >= getClient().getClientOptions() diff --git a/src/net/sf/freecol/client/gui/panel/ColopediaPanel.java b/src/net/sf/freecol/client/gui/panel/ColopediaPanel.java index d7dc50b37..e47362f0f 100644 --- a/src/net/sf/freecol/client/gui/panel/ColopediaPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ColopediaPanel.java @@ -327,7 +327,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL * @param parent */ private void buildTerrainSubtree(DefaultMutableTreeNode parent) { - for (TileType t : Specification.getSpecification().getTileTypeList()) { + for (TileType t : getSpecification().getTileTypeList()) { buildTerrainItem(t, parent); } } @@ -337,7 +337,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL * @param parent */ private void buildResourceSubtree(DefaultMutableTreeNode parent) { - for (ResourceType r : Specification.getSpecification().getResourceTypeList()) { + for (ResourceType r : getSpecification().getResourceTypeList()) { buildResourceItem(r, parent); } } @@ -347,7 +347,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL * @param parent */ private void buildUnitSubtree(DefaultMutableTreeNode parent) { - for (UnitType u : Specification.getSpecification().getUnitTypeList()) { + for (UnitType u : getSpecification().getUnitTypeList()) { if (u.getSkill() <= 0 || u.hasAbility("model.ability.expertSoldier")) { buildUnitItem(u, 0.5f, parent); @@ -360,7 +360,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL * @param parent */ private void buildGoodsSubtree(DefaultMutableTreeNode parent) { - for (GoodsType g : Specification.getSpecification().getGoodsTypeList()) { + for (GoodsType g : getSpecification().getGoodsTypeList()) { buildGoodsItem(g, parent); } } @@ -370,7 +370,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL * @param parent */ private void buildSkillsSubtree(DefaultMutableTreeNode parent) { - for (UnitType u : Specification.getSpecification().getUnitTypeList()) { + for (UnitType u : getSpecification().getUnitTypeList()) { if (u.getSkill() > 0) { buildUnitItem(u, 0.5f, parent); } @@ -388,7 +388,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL List buildingTypes = new ArrayList(); Map buildingHash = new HashMap(); - for (BuildingType buildingType : Specification.getSpecification().getBuildingTypeList()) { + for (BuildingType buildingType : getSpecification().getBuildingTypeList()) { if (buildingType.getUpgradesFrom() == null) { String name = Messages.message(buildingType.getNameKey()); DefaultMutableTreeNode item = @@ -431,7 +431,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL for (FoundingFatherType fatherType : FoundingFatherType.values()) { fathersByType.put(fatherType, new ArrayList()); } - for (FoundingFather foundingFather : Specification.getSpecification().getFoundingFathers()) { + for (FoundingFather foundingFather : getSpecification().getFoundingFathers()) { fathersByType.get(foundingFather.getType()).add(foundingFather); } for (FoundingFatherType fatherType : FoundingFatherType.values()) { @@ -451,10 +451,10 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL * @param parent */ private void buildNationsSubtree(DefaultMutableTreeNode parent) { - for (Nation type : Specification.getSpecification().getEuropeanNations()) { + for (Nation type : getSpecification().getEuropeanNations()) { buildNationItem(type, parent); } - for (Nation type : Specification.getSpecification().getIndianNations()) { + for (Nation type : getSpecification().getIndianNations()) { buildNationItem(type, parent); } } @@ -465,9 +465,9 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL */ private void buildNationTypesSubtree(DefaultMutableTreeNode parent) { List nations = new ArrayList(); - nations.addAll(Specification.getSpecification().getEuropeanNationTypes()); - nations.addAll(Specification.getSpecification().getREFNationTypes()); - nations.addAll(Specification.getSpecification().getIndianNationTypes()); + nations.addAll(getSpecification().getEuropeanNationTypes()); + nations.addAll(getSpecification().getREFNationTypes()); + nations.addAll(getSpecification().getIndianNationTypes()); for (NationType type : nations) { buildNationTypeItem(type, parent); } @@ -723,7 +723,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL List scopeStrings = new ArrayList(); for (Scope scope : modifier.getScopes()) { if (scope.getType() != null) { - FreeColGameObjectType objectType = Specification.getSpecification() + FreeColGameObjectType objectType = getSpecification() .getType(scope.getType()); scopeStrings.add(Messages.message(objectType.getNameKey())); } @@ -733,7 +733,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL } } - GoodsType goodsType = Specification.getSpecification().getGoodsType(modifier.getId()); + GoodsType goodsType = getSpecification().getGoodsType(modifier.getId()); JButton goodsButton = getGoodsButton(goodsType, text); goodsPanel.add(goodsButton); } @@ -784,7 +784,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL detailPanel.add(new JLabel(Integer.toString(type.getSkill()))); List schools = new ArrayList(); - for (final BuildingType buildingType : Specification.getSpecification().getBuildingTypeList()) { + for (final BuildingType buildingType : getSpecification().getBuildingTypeList()) { if (buildingType.hasAbility("model.ability.teach") && buildingType.canAdd(type)) { schools.add(buildingType); @@ -834,7 +834,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL } List bonusList = new ArrayList(); - for (GoodsType goodsType : Specification.getSpecification().getGoodsTypeList()) { + for (GoodsType goodsType : getSpecification().getGoodsTypeList()) { bonusList.addAll(type.getModifierSet(goodsType.getId())); } int bonusNumber = bonusList.size(); @@ -844,7 +844,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL JPanel productionPanel = new JPanel(new GridLayout(0, MODIFIERS_PER_ROW)); productionPanel.setOpaque(false); for (Modifier productionBonus : bonusList) { - GoodsType goodsType = Specification.getSpecification().getGoodsType(productionBonus.getId()); + GoodsType goodsType = getSpecification().getGoodsType(productionBonus.getId()); String bonus = getModifierAsString(productionBonus); productionPanel.add(getGoodsButton(goodsType, bonus)); } @@ -901,7 +901,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL List improvements = new ArrayList(); List modifiers = new ArrayList(); for (TileImprovementType improvementType : - Specification.getSpecification().getTileImprovementTypeList()) { + getSpecification().getTileImprovementTypeList()) { Modifier productionModifier = improvementType.getProductionModifier(type); if (productionModifier != null) { improvements.add(improvementType); @@ -1029,7 +1029,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL JPanel production = new JPanel(); production.setOpaque(false); production.setLayout(new MigLayout("wrap 3, gapx 20", "", "")); - for (UnitType unitType2 : Specification.getSpecification().getUnitTypeList()) { + for (UnitType unitType2 : getSpecification().getUnitTypeList()) { if (buildingType.canAdd(unitType2)) { production.add(getButton(unitType2)); } @@ -1060,7 +1060,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL // Specialist if (workplaces > 0) { detailPanel.add(new JLabel(Messages.message("colopedia.buildings.specialist"))); - final UnitType unitType = Specification.getSpecification() + final UnitType unitType = getSpecification() .getExpertForProducing(buildingType.getProducedGoodsType()); if (unitType == null) { detailPanel.add(new JLabel(none)); @@ -1078,7 +1078,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL for (Modifier productionBonus : bonusList) { try { - GoodsType goodsType = Specification.getSpecification() + GoodsType goodsType = getSpecification() .getGoodsType(productionBonus.getId()); String bonus = getModifierAsString(productionBonus); productionPanel.add(getGoodsButton(goodsType, bonus)); @@ -1395,7 +1395,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL Messages.message(entry.getKey() + ".name"), doc.getStyle("regular")); List requiredTypes = new ArrayList(); - for (FreeColGameObjectType type : Specification.getSpecification() + for (FreeColGameObjectType type : getSpecification() .getTypesProviding(entry.getKey(), entry.getValue())) { JButton typeButton = getButton(type); typeButton.addActionListener(this); @@ -1428,7 +1428,7 @@ public final class ColopediaPanel extends FreeColPanel implements TreeSelectionL if (OK.equals(command)) { getCanvas().remove(this); } else { - FreeColGameObjectType type = Specification.getSpecification().getType(command); + FreeColGameObjectType type = getSpecification().getType(command); initialize(type); } } diff --git a/src/net/sf/freecol/client/gui/panel/DefaultTransferHandler.java b/src/net/sf/freecol/client/gui/panel/DefaultTransferHandler.java index ed64f05f1..896e94cff 100644 --- a/src/net/sf/freecol/client/gui/panel/DefaultTransferHandler.java +++ b/src/net/sf/freecol/client/gui/panel/DefaultTransferHandler.java @@ -362,7 +362,7 @@ public final class DefaultTransferHandler extends TransferHandler { Unit unit = unitLabel.getUnit(); if (unit.hasAbility("model.ability.canBeEquipped")) { Goods goods = label.getGoods(); - for (EquipmentType equipment : Specification.getSpecification() + for (EquipmentType equipment : canvas.getSpecification() .getEquipmentTypeList()) { if (unit.canBeEquippedWith(equipment) && equipment.getGoodsRequired().size() == 1) { AbstractGoods requiredGoods = equipment.getGoodsRequired().get(0); @@ -428,7 +428,7 @@ public final class DefaultTransferHandler extends TransferHandler { UnitLabel unitLabel = (UnitLabel) comp; Unit unit = unitLabel.getUnit(); if (unit.hasAbility("model.ability.canBeEquipped")) { - for (EquipmentType equipment : Specification.getSpecification() + for (EquipmentType equipment : canvas.getSpecification() .getEquipmentTypeList()) { if (unit.canBeEquippedWith(equipment) && equipment.getGoodsRequired().size() == 1) { AbstractGoods requiredGoods = equipment.getGoodsRequired().get(0); diff --git a/src/net/sf/freecol/client/gui/panel/DifficultyDialog.java b/src/net/sf/freecol/client/gui/panel/DifficultyDialog.java index 4eaeb328a..c8782db65 100644 --- a/src/net/sf/freecol/client/gui/panel/DifficultyDialog.java +++ b/src/net/sf/freecol/client/gui/panel/DifficultyDialog.java @@ -79,12 +79,12 @@ public final class DifficultyDialog extends FreeColDialog imple level = getGame().getDifficultyLevel(); if (level == null) { // compatibility code - level = Specification.getSpecification().getDifficultyLevel(0); + level = getSpecification().getDifficultyLevel(0); } difficultyBox.addItem(Messages.message(level.getId())); difficultyBox.setEnabled(false); } else { - for (DifficultyLevel dLevel : Specification.getSpecification().getDifficultyLevels()) { + for (DifficultyLevel dLevel : getSpecification().getDifficultyLevels()) { String id = dLevel.getId(); if ("model.difficulty.medium".equals(id)) { DEFAULT_INDEX = difficultyBox.getItemCount(); @@ -160,7 +160,7 @@ public final class DifficultyDialog extends FreeColDialog imple ui.rollback(); ui.unregister(); getCanvas().remove(this); - setResponse(Specification.getSpecification().getDifficultyLevel(DEFAULT_INDEX)); + setResponse(getSpecification().getDifficultyLevel(DEFAULT_INDEX)); } else if (RESET.equals(command)) { ui.reset(); } else { @@ -170,7 +170,7 @@ public final class DifficultyDialog extends FreeColDialog imple public void itemStateChanged(ItemEvent event) { int index = difficultyBox.getSelectedIndex(); - level = Specification.getSpecification().getDifficultyLevel(index); + level = getSpecification().getDifficultyLevel(index); ui = new OptionMapUI(new DifficultyOptionMap(level), (index == CUSTOM_INDEX)); optionPanel.removeAll(); optionPanel.add(ui); diff --git a/src/net/sf/freecol/client/gui/panel/DragListener.java b/src/net/sf/freecol/client/gui/panel/DragListener.java index 065481e77..038cb1833 100644 --- a/src/net/sf/freecol/client/gui/panel/DragListener.java +++ b/src/net/sf/freecol/client/gui/panel/DragListener.java @@ -249,7 +249,7 @@ public final class DragListener extends MouseAdapter { Colony colony = tempUnit.getLocation().getColony(); boolean separatorNeeded = false; - List farmedGoods = Specification.getSpecification().getFarmedGoodsTypeList(); + List farmedGoods = canvas.getSpecification().getFarmedGoodsTypeList(); // Work in Field - automatically find the best location for (GoodsType goodsType : farmedGoods) { ColonyTile bestTile = colony.getVacantColonyTileFor(tempUnit, false, goodsType); @@ -349,7 +349,7 @@ public final class DragListener extends MouseAdapter { } int experience = Math.min(tempUnit.getExperience(), 200); if (experience > 0 && tempUnit.getWorkType() != null) { - UnitType workType = Specification.getSpecification() + UnitType workType = canvas.getSpecification() .getExpertForProducing(tempUnit.getWorkType()); if (tempUnit.getType().canBeUpgraded(workType, ChangeType.EXPERIENCE)) { JMenuItem experienceItem = new JMenuItem(Messages.message("menuBar.experience") + @@ -437,7 +437,7 @@ public final class DragListener extends MouseAdapter { EquipmentType horses = null; EquipmentType muskets = null; - for (EquipmentType equipmentType : Specification.getSpecification().getEquipmentTypeList()) { + for (EquipmentType equipmentType : canvas.getSpecification().getEquipmentTypeList()) { int count = tempUnit.getEquipment().getCount(equipmentType); if (count > 0) { // "remove current equipment" action diff --git a/src/net/sf/freecol/client/gui/panel/EditSettlementDialog.java b/src/net/sf/freecol/client/gui/panel/EditSettlementDialog.java index 2199cf422..e0d547e50 100644 --- a/src/net/sf/freecol/client/gui/panel/EditSettlementDialog.java +++ b/src/net/sf/freecol/client/gui/panel/EditSettlementDialog.java @@ -62,8 +62,6 @@ public final class EditSettlementDialog extends FreeColDialog @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(EditSettlementDialog.class.getName()); - private static final UnitType BRAVE = Specification.getSpecification().getUnitType("model.unit.brave"); - private static final String REMOVE = "REMOVE"; private final IndianSettlement settlement; @@ -184,6 +182,7 @@ public final class EditSettlementDialog extends FreeColDialog settlement.setLearnableSkill((UnitType) skill.getSelectedItem()); int numberOfUnits = (Integer) units.getValue() - settlement.getUnitCount(); if (numberOfUnits > 0) { + UnitType BRAVE = getSpecification().getUnitType("model.unit.brave"); for (int index = 0; index < numberOfUnits; index++) { settlement.add(new Unit(settlement.getGame(), settlement, settlement.getOwner(), BRAVE, UnitState.ACTIVE)); diff --git a/src/net/sf/freecol/client/gui/panel/EuropePanel.java b/src/net/sf/freecol/client/gui/panel/EuropePanel.java index 553aa2572..d25d4847b 100644 --- a/src/net/sf/freecol/client/gui/panel/EuropePanel.java +++ b/src/net/sf/freecol/client/gui/panel/EuropePanel.java @@ -51,7 +51,6 @@ import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleConstants; import javax.swing.text.StyledDocument; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.i18n.Messages; @@ -341,7 +340,7 @@ public final class EuropePanel extends FreeColPanel { } } - List goodsTypes = FreeCol.getSpecification().getGoodsTypeList(); + List goodsTypes = getSpecification().getGoodsTypeList(); for (GoodsType goodsType : goodsTypes) { if (goodsType.isStorable()) { MarketLabel marketLabel = new MarketLabel(goodsType, getMyPlayer().getMarket(), getCanvas()); diff --git a/src/net/sf/freecol/client/gui/panel/FreeColDialog.java b/src/net/sf/freecol/client/gui/panel/FreeColDialog.java index 25a9f48f7..f4b500ebd 100644 --- a/src/net/sf/freecol/client/gui/panel/FreeColDialog.java +++ b/src/net/sf/freecol/client/gui/panel/FreeColDialog.java @@ -357,9 +357,9 @@ public class FreeColDialog extends FreeColPanel { } - public static FreeColDialog createMapSizeDialog() { + public static FreeColDialog createMapSizeDialog(final Canvas canvas) { - final int defaultSize = FreeCol.getSpecification().getRangeOption("model.option.mapSize") + final int defaultSize = canvas.getSpecification().getRangeOption("model.option.mapSize") .getValue(); final int defaultHeight = MapGeneratorOptions.getHeight(defaultSize); final int defaultWidth = MapGeneratorOptions.getWidth(defaultSize); @@ -371,10 +371,9 @@ public class FreeColDialog extends FreeColPanel { final JTextField inputWidth = new JTextField(Integer.toString(defaultWidth), COLUMNS); final JTextField inputHeight = new JTextField(Integer.toString(defaultHeight), COLUMNS); - final FreeColDialog mapSizeDialog = - new FreeColDialog(FreeCol.getFreeColClient().getCanvas()); + final FreeColDialog mapSizeDialog = new FreeColDialog(canvas); - mapSizeDialog.setLayout(new MigLayout("wrap 2", "", "")); + mapSizeDialog.setLayout(new MigLayout("wrap 2")); mapSizeDialog.okButton.setText(Messages.message("ok")); mapSizeDialog.okButton.addActionListener(new ActionListener() { @@ -387,7 +386,7 @@ public class FreeColDialog extends FreeColPanel { } mapSizeDialog.setResponse(new Dimension(width, height)); } catch (NumberFormatException nfe) { - FreeCol.getFreeColClient().getCanvas().errorMessage("integerAboveZero"); + canvas.errorMessage("integerAboveZero"); } } }); diff --git a/src/net/sf/freecol/client/gui/panel/FreeColPanel.java b/src/net/sf/freecol/client/gui/panel/FreeColPanel.java index 47cd511ec..8120e6959 100644 --- a/src/net/sf/freecol/client/gui/panel/FreeColPanel.java +++ b/src/net/sf/freecol/client/gui/panel/FreeColPanel.java @@ -240,7 +240,7 @@ public class FreeColPanel extends JPanel implements ActionListener { * @return a Specification value */ public Specification getSpecification() { - return getGame().getSpecification(); + return canvas.getSpecification(); } /** diff --git a/src/net/sf/freecol/client/gui/panel/LabourData.java b/src/net/sf/freecol/client/gui/panel/LabourData.java index a31f64218..6805b4165 100644 --- a/src/net/sf/freecol/client/gui/panel/LabourData.java +++ b/src/net/sf/freecol/client/gui/panel/LabourData.java @@ -19,7 +19,6 @@ package net.sf.freecol.client.gui.panel; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.gui.i18n.Messages; import net.sf.freecol.common.model.Specification; @@ -376,7 +375,7 @@ public class LabourData { private UnitData scout; public LabourData(FreeColClient client) { - Specification spec = FreeCol.getSpecification(); + Specification spec = client.getGame().getSpecification(); for (UnitType unitType : spec.getUnitTypeList()) { if (!unitType.isAvailableTo(client.getMyPlayer())) { continue; @@ -447,7 +446,7 @@ public class LabourData { } public static List getLabourTypes(Player player) { - List unitTypes = FreeCol.getSpecification().getUnitTypeList(); + List unitTypes = player.getSpecification().getUnitTypeList(); ArrayList labourTypes = new ArrayList(); for (UnitType unitType : unitTypes) { if (unitType.hasSkill() && unitType.isAvailableTo(player)) { diff --git a/src/net/sf/freecol/client/gui/panel/MapControls.java b/src/net/sf/freecol/client/gui/panel/MapControls.java index bccb268e6..ce05d73e4 100644 --- a/src/net/sf/freecol/client/gui/panel/MapControls.java +++ b/src/net/sf/freecol/client/gui/panel/MapControls.java @@ -30,7 +30,6 @@ import javax.swing.Action; import javax.swing.JLabel; import javax.swing.JLayeredPane; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.gui.Canvas; @@ -92,7 +91,8 @@ public final class MapControls { ubList.add(new UnitButton(am.getFreeColAction(SkipUnitAction.id))); ubList.add(new UnitButton(am.getFreeColAction(SentryAction.id))); ubList.add(new UnitButton(am.getFreeColAction(FortifyAction.id))); - for (ImprovementActionType iaType : FreeCol.getSpecification().getImprovementActionTypeList()) { + for (ImprovementActionType iaType : freeColClient.getGame().getSpecification() + .getImprovementActionTypeList()) { ubList.add(new UnitButton(am.getFreeColAction(iaType.getId()))); } ubList.add(new UnitButton(am.getFreeColAction(BuildColonyAction.id))); diff --git a/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java b/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java index 2892c123f..39bde374c 100644 --- a/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java +++ b/src/net/sf/freecol/client/gui/panel/MapEditorTransformPanel.java @@ -81,16 +81,11 @@ public final class MapEditorTransformPanel extends FreeColPanel { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(MapEditorTransformPanel.class.getName()); - private static final UnitType BRAVE = Specification.getSpecification().getUnitType("model.unit.brave"); - private final JPanel listPanel; private JToggleButton settlementButton; private ButtonGroup group; - private static final TileImprovementType riverType = - Specification.getSpecification().getTileImprovementType("model.improvement.river"); - /** * Describe nativePlayer here. */ @@ -109,7 +104,7 @@ public final class MapEditorTransformPanel extends FreeColPanel { if (server.getAIMain() == null) { server.setAIMain(new AIMain(server)); } - for (Nation nation : Specification.getSpecification().getIndianNations()) { + for (Nation nation : getSpecification().getIndianNations()) { server.addAIPlayer(nation); } } @@ -134,7 +129,7 @@ public final class MapEditorTransformPanel extends FreeColPanel { * Builds the buttons for all the terrains. */ private void buildList() { - List tileList = Specification.getSpecification().getTileTypeList(); + List tileList = getSpecification().getTileTypeList(); for (TileType type : tileList) { listPanel.add(buildButton(getLibrary().getCompoundTerrainImage(type, 0.5), Messages.message(type.getNameKey()), @@ -146,7 +141,7 @@ public final class MapEditorTransformPanel extends FreeColPanel { listPanel.add(buildButton(getLibrary().getRiverImage(20, 0.5), Messages.message("majorRiver"), new RiverTransform(TileImprovement.LARGE_RIVER))); - listPanel.add(buildButton(getLibrary().getBonusImage(Specification.getSpecification() + listPanel.add(buildButton(getLibrary().getBonusImage(getSpecification() .getResourceTypeList().get(0), 0.8), Messages.message("editor.resource"), new ResourceTransform())); listPanel.add(buildButton(getLibrary().getMiscImage(ImageLibrary.LOST_CITY_RUMOUR, 0.66), @@ -283,6 +278,9 @@ public final class MapEditorTransformPanel extends FreeColPanel { } public void transform(Tile tile) { + TileImprovementType riverType = + tile.getSpecification().getTileImprovementType("model.improvement.river"); + if (tile.getType().canHaveImprovement(riverType)) { TileItemContainer tic = tile.getTileItemContainer(); if (tic == null) { @@ -400,9 +398,10 @@ public final class MapEditorTransformPanel extends FreeColPanel { settlement = new IndianSettlement(t.getGame(), nativePlayer, t, name, false, skill, new HashSet(), null); t.setSettlement(settlement); + UnitType brave = getSpecification().getUnitType("model.unit.brave"); for (int index = 0; index < 5; index++) { settlement.add(new Unit(settlement.getGame(), settlement, settlement.getOwner(), - BRAVE, UnitState.ACTIVE)); + brave, UnitState.ACTIVE)); } } } diff --git a/src/net/sf/freecol/client/gui/panel/MiniMap.java b/src/net/sf/freecol/client/gui/panel/MiniMap.java index aa588283e..c7389ce55 100644 --- a/src/net/sf/freecol/client/gui/panel/MiniMap.java +++ b/src/net/sf/freecol/client/gui/panel/MiniMap.java @@ -37,7 +37,6 @@ import javax.swing.JPanel; import javax.swing.border.BevelBorder; import javax.swing.event.MouseInputListener; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.ClientOptions; import net.sf.freecol.client.FreeColClient; import net.sf.freecol.client.gui.ImageLibrary; @@ -343,7 +342,7 @@ public final class MiniMap extends JPanel implements MouseInputListener { * miniRectX/Y are the center of the rectangle. * Use miniRectWidth/Height / 2 to get the upper left corner. * x/yTiles are the number of tiles that fit on the large map */ - TileType tileType = FreeCol.getSpecification().getTileTypeList().get(0); + TileType tileType = freeColClient.getGame().getSpecification().getTileTypeList().get(0); int miniRectX = (freeColClient.getGUI().getFocus().getX() - firstColumn) * tileSize; int miniRectY = (freeColClient.getGUI().getFocus().getY() - firstRow) * tileSize / 4; int miniRectWidth = (getParent().getWidth() / library.getTerrainImageWidth(tileType) + 1) * tileSize; diff --git a/src/net/sf/freecol/client/gui/panel/PlayersTable.java b/src/net/sf/freecol/client/gui/panel/PlayersTable.java index a8f59417d..ee5da673c 100644 --- a/src/net/sf/freecol/client/gui/panel/PlayersTable.java +++ b/src/net/sf/freecol/client/gui/panel/PlayersTable.java @@ -143,7 +143,7 @@ public final class PlayersTable extends JTable { TableColumn advantagesColumn = getColumnModel().getColumn(ADVANTAGE_COLUMN); if (nationOptions.getNationalAdvantages() == NationOptions.Advantages.SELECTABLE) { - advantagesColumn.setCellEditor(new AdvantageCellEditor()); + advantagesColumn.setCellEditor(new AdvantageCellEditor(canvas.getSpecification().getEuropeanNationTypes())); } advantagesColumn.setCellRenderer(new AdvantageCellRenderer(nationOptions.getNationalAdvantages())); advantagesColumn.setHeaderRenderer(renderer); @@ -394,7 +394,7 @@ public final class PlayersTable extends JTable { public PlayersTableModel(PreGameController pgc, NationOptions nationOptions, Player owningPlayer) { nations = new ArrayList(); players = new HashMap(); - for (Nation nation : Specification.getSpecification().getNations()) { + for (Nation nation : owningPlayer.getSpecification().getNations()) { NationState state = nationOptions.getNations().get(nation); if (state != null) { nations.add(nation); diff --git a/src/net/sf/freecol/client/gui/panel/RebelToolTip.java b/src/net/sf/freecol/client/gui/panel/RebelToolTip.java index 2001055b7..66977c94a 100644 --- a/src/net/sf/freecol/client/gui/panel/RebelToolTip.java +++ b/src/net/sf/freecol/client/gui/panel/RebelToolTip.java @@ -58,7 +58,7 @@ public class RebelToolTip extends JToolTip { add(new JLabel(Integer.toString(colony.getTory()) + "%")); int libertyProduction = 0; - for (GoodsType goodsType : Specification.getSpecification().getLibertyGoodsTypeList()) { + for (GoodsType goodsType : colony.getSpecification().getLibertyGoodsTypeList()) { add(new JLabel(Messages.message(goodsType.getNameKey()))); int netProduction = colony.getProductionNetOf(goodsType); libertyProduction += netProduction; diff --git a/src/net/sf/freecol/client/gui/panel/RecruitDialog.java b/src/net/sf/freecol/client/gui/panel/RecruitDialog.java index 69f1fb9c7..d0fa8e54b 100644 --- a/src/net/sf/freecol/client/gui/panel/RecruitDialog.java +++ b/src/net/sf/freecol/client/gui/panel/RecruitDialog.java @@ -101,7 +101,7 @@ public final class RecruitDialog extends FreeColDialog implements Actio int production = 0; for (Colony colony : player.getColonies()) { - production += colony.getProductionOf(Specification.getSpecification() + production += colony.getProductionOf(getSpecification() .getGoodsType("model.goods.crosses")); } int turns = 100; diff --git a/src/net/sf/freecol/client/gui/panel/ReportCargoPanel.java b/src/net/sf/freecol/client/gui/panel/ReportCargoPanel.java index c669ccf02..9b627d64a 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportCargoPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportCargoPanel.java @@ -89,7 +89,7 @@ public final class ReportCargoPanel extends ReportPanel { reportPanel.add(new JSeparator(JSeparator.HORIZONTAL), "growx"); List cargoTypes = new ArrayList(); - for (UnitType unitType : Specification.getSpecification().getUnitTypeList()) { + for (UnitType unitType : getSpecification().getUnitTypeList()) { if (unitType.isAvailableTo(player) && (unitType.canCarryUnits() || unitType.canCarryGoods())) { cargoTypes.add(new AbstractUnit(unitType, Role.DEFAULT, carriers.getCount(unitType))); diff --git a/src/net/sf/freecol/client/gui/panel/ReportColonyPanel.java b/src/net/sf/freecol/client/gui/panel/ReportColonyPanel.java index 90fd8731d..c1f0b4856 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportColonyPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportColonyPanel.java @@ -27,7 +27,6 @@ import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JSeparator; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.i18n.Messages; import net.sf.freecol.common.model.Specification; @@ -95,8 +94,8 @@ public final class ReportColonyPanel extends ReportPanel { } // Production - GoodsType food = Specification.getSpecification().getGoodsType("model.goods.food"); - GoodsType horses = Specification.getSpecification().getGoodsType("model.goods.horses"); + GoodsType food = getSpecification().getGoodsType("model.goods.food"); + GoodsType horses = getSpecification().getGoodsType("model.goods.horses"); int count = 0; int netFood = colony.getFoodProduction() - colony.getFoodConsumption(); if (netFood != 0) { @@ -105,7 +104,7 @@ public final class ReportColonyPanel extends ReportPanel { reportPanel.add(productionLabel, "span 2, top"); count++; } - for (GoodsType goodsType : FreeCol.getSpecification().getGoodsTypeList()) { + for (GoodsType goodsType : getSpecification().getGoodsTypeList()) { if (goodsType.isFoodType()) { continue; } diff --git a/src/net/sf/freecol/client/gui/panel/ReportContinentalCongressPanel.java b/src/net/sf/freecol/client/gui/panel/ReportContinentalCongressPanel.java index 3172c3a2e..d21d96c9a 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportContinentalCongressPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportContinentalCongressPanel.java @@ -23,7 +23,6 @@ package net.sf.freecol.client.gui.panel; import javax.swing.ImageIcon; import javax.swing.JLabel; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.i18n.Messages; import net.sf.freecol.common.model.Colony; @@ -69,7 +68,7 @@ public final class ReportContinentalCongressPanel extends ReportPanel { currentFatherLabel.setVerticalTextPosition(JLabel.TOP); currentFatherLabel.setHorizontalTextPosition(JLabel.CENTER); reportPanel.add(currentFatherLabel); - GoodsType bellsType = FreeCol.getSpecification().getGoodsType("model.goods.bells"); + GoodsType bellsType = getSpecification().getGoodsType("model.goods.bells"); FreeColProgressBar progressBar = new FreeColProgressBar(getCanvas(), bellsType); int total = 0; for (Colony colony : player.getColonies()) { diff --git a/src/net/sf/freecol/client/gui/panel/ReportLabourPanel.java b/src/net/sf/freecol/client/gui/panel/ReportLabourPanel.java index f5592ed9a..995365bb2 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportLabourPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportLabourPanel.java @@ -33,7 +33,6 @@ import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.i18n.Messages; import net.sf.freecol.common.model.Specification; @@ -77,7 +76,7 @@ public final class ReportLabourPanel extends ReportPanel implements ActionListen unitOnLand = new TypeCountMap(); unitInEurope = new TypeCountMap(); unitLocations = new HashMap>(); - for (UnitType type : Specification.getSpecification().getUnitTypeList()) { + for (UnitType type : getSpecification().getUnitTypeList()) { unitLocations.put(type, new HashMap()); } @@ -117,7 +116,7 @@ public final class ReportLabourPanel extends ReportPanel implements ActionListen public void displayData() { - List unitTypes = FreeCol.getSpecification().getUnitTypeList(); + List unitTypes = getSpecification().getUnitTypeList(); ArrayList colonists = new ArrayList(); for (UnitType unitType : unitTypes) { if (unitType.hasSkill()) { @@ -223,7 +222,7 @@ public final class ReportLabourPanel extends ReportPanel implements ActionListen if (OK.equals(command)) { super.actionPerformed(event); } else { - UnitType unitType = FreeCol.getSpecification().getUnitType(command); + UnitType unitType = getSpecification().getUnitType(command); ReportLabourDetailPanel details = new ReportLabourDetailPanel(getCanvas()); details.setDetailPanel(createUnitDetails(unitType, details)); getCanvas().addAsFrame(details); diff --git a/src/net/sf/freecol/client/gui/panel/ReportMilitaryPanel.java b/src/net/sf/freecol/client/gui/panel/ReportMilitaryPanel.java index d990ae7f2..3178236c2 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportMilitaryPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportMilitaryPanel.java @@ -78,9 +78,6 @@ public final class ReportMilitaryPanel extends ReportPanel { private Map unitMap; */ - private static final UnitType defaultType = - Specification.getSpecification().getUnitType("model.unit.freeColonist"); - private List colonyNames; private List otherNames; @@ -130,7 +127,7 @@ public final class ReportMilitaryPanel extends ReportPanel { List scoutUnits = new ArrayList(); List dragoonUnits = new ArrayList(); List soldierUnits = new ArrayList(); - for (UnitType unitType : Specification.getSpecification().getUnitTypeList()) { + for (UnitType unitType : getSpecification().getUnitTypeList()) { if (unitType.isAvailableTo(player) && !unitType.hasAbility("model.ability.navalUnit") && (unitType.hasAbility("model.ability.expertSoldier") || @@ -144,6 +141,7 @@ public final class ReportMilitaryPanel extends ReportPanel { } } } + UnitType defaultType = getSpecification().getUnitType("model.unit.freeColonist"); dragoonUnits.add(new AbstractUnit(defaultType, Role.DRAGOON, dragoons.getCount(defaultType))); soldierUnits.add(new AbstractUnit(defaultType, Role.SOLDIER, soldiers.getCount(defaultType))); scoutUnits.add(new AbstractUnit(defaultType, Role.SCOUT, scouts.getCount(defaultType))); @@ -203,6 +201,7 @@ public final class ReportMilitaryPanel extends ReportPanel { otherNames.add(Messages.message(player.getEurope().getNameKey())); } + UnitType defaultType = getSpecification().getUnitType("model.unit.freeColonist"); for (Unit unit : player.getUnits()) { if (unit.isOffensiveUnit() && !unit.isNaval()) { UnitType unitType = defaultType; diff --git a/src/net/sf/freecol/client/gui/panel/ReportNavalPanel.java b/src/net/sf/freecol/client/gui/panel/ReportNavalPanel.java index 85feefa85..2aa8a6cf2 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportNavalPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportNavalPanel.java @@ -95,7 +95,7 @@ public final class ReportNavalPanel extends ReportPanel { reportPanel.add(new JSeparator(JSeparator.HORIZONTAL), "growx"); List ships = new ArrayList(); - for (UnitType unitType : Specification.getSpecification().getUnitTypeList()) { + for (UnitType unitType : getSpecification().getUnitTypeList()) { if (unitType.isAvailableTo(player) && unitType.hasAbility("model.ability.navalUnit")) { ships.add(new AbstractUnit(unitType, Role.DEFAULT, navalUnits.getCount(unitType))); } diff --git a/src/net/sf/freecol/client/gui/panel/ReportProductionPanel.java b/src/net/sf/freecol/client/gui/panel/ReportProductionPanel.java index 74450c1d7..8a7f0d6c1 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportProductionPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportProductionPanel.java @@ -29,7 +29,6 @@ import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JLabel; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.i18n.Messages; import net.sf.freecol.common.model.Specification; @@ -67,7 +66,7 @@ public final class ReportProductionPanel extends ReportPanel { goodsTypes = new ArrayList(); List goodsNames = new ArrayList(); goodsNames.add(Messages.message("nothing")); - for (GoodsType goodsType : Specification.getSpecification().getGoodsTypeList()) { + for (GoodsType goodsType : getSpecification().getGoodsTypeList()) { if (!goodsType.isFarmed()) { goodsTypes.add(goodsType); goodsNames.add(Messages.message(goodsType.getNameKey())); @@ -117,7 +116,7 @@ public final class ReportProductionPanel extends ReportPanel { List> basicBuildingTypes = new ArrayList>(); for (GoodsType goodsType : selectedTypes) { List buildingTypes = new ArrayList(); - for (BuildingType buildingType : FreeCol.getSpecification().getBuildingTypeList()) { + for (BuildingType buildingType : getSpecification().getBuildingTypeList()) { if (goodsType.equals(buildingType.getProducedGoodsType()) || !buildingType.getModifierSet(goodsType.getId()).isEmpty()) { BuildingType firstLevel = buildingType.getFirstLevel(); diff --git a/src/net/sf/freecol/client/gui/panel/ReportReligiousPanel.java b/src/net/sf/freecol/client/gui/panel/ReportReligiousPanel.java index 047a650df..f0702c57b 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportReligiousPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportReligiousPanel.java @@ -53,7 +53,7 @@ public final class ReportReligiousPanel extends ReportPanel implements ActionLis Player player = getMyPlayer(); reportPanel.add(new JLabel(Messages.message("crosses"))); - GoodsType crosses = Specification.getSpecification().getGoodsType("model.goods.crosses"); + GoodsType crosses = getSpecification().getGoodsType("model.goods.crosses"); FreeColProgressBar progressBar = new FreeColProgressBar(getCanvas(), crosses); reportPanel.add(progressBar, "span"); diff --git a/src/net/sf/freecol/client/gui/panel/ReportRequirementsPanel.java b/src/net/sf/freecol/client/gui/panel/ReportRequirementsPanel.java index 20f07198f..d506d888d 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportRequirementsPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportRequirementsPanel.java @@ -29,7 +29,6 @@ import javax.swing.JViewport; import javax.swing.text.StyleConstants; import javax.swing.text.StyledDocument; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.i18n.Messages; import net.sf.freecol.common.model.Building; @@ -86,13 +85,13 @@ public final class ReportRequirementsPanel extends ReportPanel { JTextPane textPane = getDefaultTextPane(); StyledDocument doc = textPane.getStyledDocument(); - int numberUnitTypes = FreeCol.getSpecification().numberOfUnitTypes(); - int numberGoodsTypes = FreeCol.getSpecification().numberOfGoodsTypes(); + int numberUnitTypes = getSpecification().numberOfUnitTypes(); + int numberGoodsTypes = getSpecification().numberOfGoodsTypes(); unitCount = new int[colonies.size()][numberUnitTypes]; canTrain = new boolean[colonies.size()][numberUnitTypes]; surplus = new int[colonies.size()][numberGoodsTypes]; - List goodsTypes = FreeCol.getSpecification().getGoodsTypeList(); + List goodsTypes = getSpecification().getGoodsTypeList(); // check which colonies can train which units for (int index = 0; index < colonies.size(); index++) { Colony colony = colonies.get(index); @@ -127,7 +126,7 @@ public final class ReportRequirementsPanel extends ReportPanel { Unit unit = colonyTile.getUnit(); if (unit != null) { GoodsType workType = unit.getWorkType(); - UnitType expert = FreeCol.getSpecification().getExpertForProducing(workType); + UnitType expert = getSpecification().getExpertForProducing(workType); int expertIndex = expert.getIndex(); if (unitCount[index][expertIndex] == 0 && !expertWarning[expertIndex]) { addExpertWarning(doc, index, workType, expert); diff --git a/src/net/sf/freecol/client/gui/panel/ReportTradePanel.java b/src/net/sf/freecol/client/gui/panel/ReportTradePanel.java index 69acf8329..715d84a7a 100644 --- a/src/net/sf/freecol/client/gui/panel/ReportTradePanel.java +++ b/src/net/sf/freecol/client/gui/panel/ReportTradePanel.java @@ -19,7 +19,6 @@ package net.sf.freecol.client.gui.panel; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.i18n.Messages; import net.sf.freecol.common.model.Colony; @@ -84,7 +83,7 @@ public final class ReportTradePanel extends ReportPanel { goodsHeader.setBorder(new EmptyBorder(20, 20, 0, 20)); scrollPane.setColumnHeaderView(goodsHeader); - for (GoodsType goodsType : FreeCol.getSpecification().getGoodsTypeList()) { + for (GoodsType goodsType : getSpecification().getGoodsTypeList()) { if (goodsType.isStorable()) { storableGoods.add(goodsType); } @@ -200,7 +199,7 @@ public final class ReportTradePanel extends ReportPanel { JButton colonyButton = createColonyButton(colony, colonyIndex); reportPanel.add(colonyButton, "cell 0 " + row + " 1 2"); column = 0; - for (GoodsType goodsType : FreeCol.getSpecification().getGoodsTypeList()) { + for (GoodsType goodsType : getSpecification().getGoodsTypeList()) { if (!goodsType.isStorable()) { continue; } diff --git a/src/net/sf/freecol/client/gui/panel/TilePanel.java b/src/net/sf/freecol/client/gui/panel/TilePanel.java index d5b8c374b..84db53d23 100644 --- a/src/net/sf/freecol/client/gui/panel/TilePanel.java +++ b/src/net/sf/freecol/client/gui/panel/TilePanel.java @@ -36,7 +36,6 @@ import javax.swing.JLabel; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.i18n.Messages; import net.sf.freecol.common.model.GoodsType; @@ -108,13 +107,13 @@ public final class TilePanel extends FreeColPanel { if (tileType != null) { // TODO: make this more generic - UnitType colonist = FreeCol.getSpecification().getUnitType("model.unit.freeColonist"); + UnitType colonist = getSpecification().getUnitType("model.unit.freeColonist"); JLabel label = null; boolean first = true; - for (GoodsType goodsType : FreeCol.getSpecification().getFarmedGoodsTypeList()) { + for (GoodsType goodsType : getSpecification().getFarmedGoodsTypeList()) { int potential = tile.potential(goodsType, colonist); - UnitType expert = FreeCol.getSpecification().getExpertForProducing(goodsType); + UnitType expert = getSpecification().getExpertForProducing(goodsType); int expertPotential = tile.potential(goodsType, expert); if (potential > 0) { label = new JLabel(String.valueOf(potential), diff --git a/src/net/sf/freecol/client/gui/panel/TradeRouteInputDialog.java b/src/net/sf/freecol/client/gui/panel/TradeRouteInputDialog.java index 3e48da09c..5f6a8a431 100644 --- a/src/net/sf/freecol/client/gui/panel/TradeRouteInputDialog.java +++ b/src/net/sf/freecol/client/gui/panel/TradeRouteInputDialog.java @@ -49,7 +49,6 @@ import javax.swing.TransferHandler; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.i18n.Messages; import net.sf.freecol.common.model.Colony; @@ -342,7 +341,7 @@ public final class TradeRouteInputDialog extends FreeColDialog implemen public GoodsPanel() { super(new GridLayout(0, 5, margin, margin)); - for (GoodsType goodsType : FreeCol.getSpecification().getGoodsTypeList()) { + for (GoodsType goodsType : getSpecification().getGoodsTypeList()) { if (goodsType.isStorable()) { CargoLabel label = new CargoLabel(goodsType); add(label); diff --git a/src/net/sf/freecol/client/gui/panel/TrainDialog.java b/src/net/sf/freecol/client/gui/panel/TrainDialog.java index d45417b76..495962654 100644 --- a/src/net/sf/freecol/client/gui/panel/TrainDialog.java +++ b/src/net/sf/freecol/client/gui/panel/TrainDialog.java @@ -31,7 +31,6 @@ import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.i18n.Messages; @@ -79,13 +78,13 @@ public final class TrainDialog extends FreeColDialog implements ActionL switch(europeAction) { case TRAIN: - trainableUnits.addAll(FreeCol.getSpecification().getUnitTypesTrainedInEurope()); + trainableUnits.addAll(getSpecification().getUnitTypesTrainedInEurope()); question = new JLabel(Messages.message("trainDialog.clickOn")); setLayout(new MigLayout("wrap 3", "[sg]", "")); break; case PURCHASE: default: - trainableUnits.addAll(FreeCol.getSpecification().getUnitTypesPurchasedInEurope()); + trainableUnits.addAll(getSpecification().getUnitTypesPurchasedInEurope()); question = new JLabel(Messages.message("purchaseDialog.clickOn")); setLayout(new MigLayout("wrap 2", "[sg]", "")); } @@ -154,7 +153,7 @@ public final class TrainDialog extends FreeColDialog implements ActionL if (TRAIN_DONE.equals(command)) { setResponse(new Integer(-1)); } else { - UnitType unitType = FreeCol.getSpecification().getUnitType(command); + UnitType unitType = getSpecification().getUnitType(command); getController().trainUnitInEurope(unitType); initialize(); } diff --git a/src/net/sf/freecol/client/gui/panel/UnitLabel.java b/src/net/sf/freecol/client/gui/panel/UnitLabel.java index ed70aa75a..77cbf892e 100644 --- a/src/net/sf/freecol/client/gui/panel/UnitLabel.java +++ b/src/net/sf/freecol/client/gui/panel/UnitLabel.java @@ -38,7 +38,6 @@ import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.UIManager; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.control.InGameController; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.ImageLibrary; @@ -326,7 +325,7 @@ public final class UnitLabel extends JLabel implements ActionListener, PropertyC } break; case WORK_TILE: - GoodsType goodsType = FreeCol.getSpecification().getGoodsType(arg); + GoodsType goodsType = parent.getSpecification().getGoodsType(arg); // Change workType first for the benefit of change listeners inGameController.changeWorkType(unit, goodsType); // Move unit to best producing ColonyTile @@ -336,7 +335,7 @@ public final class UnitLabel extends JLabel implements ActionListener, PropertyC } break; case WORK_BUILDING: - BuildingType buildingType = FreeCol.getSpecification().getBuildingType(arg); + BuildingType buildingType = parent.getSpecification().getBuildingType(arg); Building building = unit.getColony().getBuilding(buildingType); inGameController.work(unit, building); break; diff --git a/src/net/sf/freecol/client/gui/panel/WarehouseDialog.java b/src/net/sf/freecol/client/gui/panel/WarehouseDialog.java index 392436a99..efd2d2f42 100644 --- a/src/net/sf/freecol/client/gui/panel/WarehouseDialog.java +++ b/src/net/sf/freecol/client/gui/panel/WarehouseDialog.java @@ -34,7 +34,6 @@ import javax.swing.JScrollPane; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; -import net.sf.freecol.FreeCol; import net.sf.freecol.client.gui.Canvas; import net.sf.freecol.client.gui.i18n.Messages; import net.sf.freecol.common.model.Colony; @@ -94,7 +93,7 @@ public final class WarehouseDialog extends FreeColDialog implements Act add(ok, "newline 20, split 2, tag ok"); add(cancel, "tag cancel"); - for (GoodsType goodsType : FreeCol.getSpecification().getGoodsTypeList()) { + for (GoodsType goodsType : getSpecification().getGoodsTypeList()) { if (goodsType.isStorable()) { warehouseDialog.add(new WarehouseGoodsPanel(colony, goodsType)); }