diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/OrderOfLossesInputPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/OrderOfLossesInputPanel.java index ad8218e911d..b24c0e1c55a 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/OrderOfLossesInputPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/OrderOfLossesInputPanel.java @@ -10,7 +10,6 @@ import games.strategy.engine.data.UnitTypeList; import games.strategy.triplea.delegate.Matches; import games.strategy.triplea.image.UnitImageFactory.ImageKey; -import games.strategy.triplea.ui.TooltipProperties; import games.strategy.triplea.ui.UiContext; import games.strategy.triplea.util.UnitCategory; import java.awt.Color; @@ -271,7 +270,8 @@ private JPanel getUnitButtonPanel( "" + category.getType().getName() + ": " - + new TooltipProperties(uiContext) + + uiContext + .getTooltipProperties() .getTooltip(category.getType(), category.getOwner()) + ""; final ImageIcon img = uiContext.getUnitImageFactory().getIcon(ImageKey.of(category)); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/UnitPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/UnitPanel.java index 1367e821b0d..37fb9d60e33 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/UnitPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/odds/calculator/UnitPanel.java @@ -5,7 +5,6 @@ import games.strategy.engine.data.Unit; import games.strategy.engine.data.UnitType; import games.strategy.triplea.delegate.Matches; -import games.strategy.triplea.ui.TooltipProperties; import games.strategy.triplea.ui.UiContext; import games.strategy.triplea.util.UnitCategory; import games.strategy.ui.ScrollableTextField; @@ -38,7 +37,7 @@ public class UnitPanel extends JPanel { + ": " + costs.getInt(category.getType()) + " cost,
     " - + new TooltipProperties(uiContext).getTooltip(category.getType(), category.getOwner()) + + uiContext.getTooltipProperties().getTooltip(category.getType(), category.getOwner()) + ""; setCount(category.getUnits().size()); setLayout(new GridBagLayout()); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/MapUnitTooltipManager.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/MapUnitTooltipManager.java index cd6ea1656c5..b38c1789d82 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/MapUnitTooltipManager.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/MapUnitTooltipManager.java @@ -129,7 +129,7 @@ public static String getTooltipTextForUnit( count == 1 ? "" : (count + " "), StringUtils.capitalize(unitType.getName()), player.getName()); - return firstLine + new TooltipProperties(uiContext).getTooltip(unitType, player); + return firstLine + uiContext.getTooltipProperties().getTooltip(unitType, player); } /** diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionPanel.java index 018d1c0d19f..05937076451 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ProductionPanel.java @@ -337,7 +337,7 @@ protected JPanel getPanelComponent() { tooltip .append(type.getName()) .append(": ") - .append(new TooltipProperties(uiContext).getTooltip(type, player)); + .append(uiContext.getTooltipProperties().getTooltip(type, player)); name.setText(type.getName()); if (attach.getConsumesUnits().totalValues() == 1) { name.setForeground(Color.CYAN); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/UiContext.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/UiContext.java index 0e1a10cdd80..094fdacc961 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/UiContext.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/UiContext.java @@ -70,6 +70,7 @@ public class UiContext { @Getter private final TileImageFactory tileImageFactory = new TileImageFactory(); @Getter private UnitImageFactory unitImageFactory; @Getter private final ResourceImageFactory resourceImageFactory = new ResourceImageFactory(); + @Getter private final TooltipProperties tooltipProperties; @Getter private final TerritoryEffectImageFactory territoryEffectImageFactory = @@ -152,6 +153,7 @@ public class UiContext { log.error("Failed to create cursor from: " + cursorUrl, e); } } + tooltipProperties = new TooltipProperties(this); } public JLabel newUnitImageLabel(final ImageKey imageKey) { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/UnitStatsTable.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/UnitStatsTable.java index 5d93bbf183d..62fa409392e 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/UnitStatsTable.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/menubar/help/UnitStatsTable.java @@ -11,7 +11,6 @@ import games.strategy.engine.data.UnitType; import games.strategy.triplea.image.UnitImageFactory; import games.strategy.triplea.image.UnitImageFactory.ImageKey; -import games.strategy.triplea.ui.TooltipProperties; import games.strategy.triplea.ui.UiContext; import games.strategy.triplea.util.TuvUtils; import java.util.ArrayList; @@ -72,7 +71,7 @@ public static String getUnitStatsTable(final GameData gameData, final UiContext .append(costs.get(player).get(ut).toStringForHtml()) .append("") .append("") - .append(new TooltipProperties(uiContext).getTooltip(ut, player)) + .append(uiContext.getTooltipProperties().getTooltip(ut, player)) .append(""); } } diff --git a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/TerritoryDetailPanel.java b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/TerritoryDetailPanel.java index 95cd3a0540a..b9f9a38b3e4 100644 --- a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/TerritoryDetailPanel.java +++ b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/TerritoryDetailPanel.java @@ -199,7 +199,7 @@ private static JPanel unitsInTerritoryPanel( "" + item.getType().getName() + ": " - + new TooltipProperties(uiContext).getTooltip(item.getType(), currentPlayer) + + uiContext.getTooltipProperties().getTooltip(item.getType(), currentPlayer) + ""; label.setToolTipText(toolTipText); panel.add(label);