diff --git a/src/net/sf/freecol/client/gui/ImageLibrary.java b/src/net/sf/freecol/client/gui/ImageLibrary.java index b351c48fb..0497b72dd 100644 --- a/src/net/sf/freecol/client/gui/ImageLibrary.java +++ b/src/net/sf/freecol/client/gui/ImageLibrary.java @@ -901,12 +901,18 @@ public final class ImageLibrary { } public BufferedImage getScaledBuildingImage(Building building) { + if (building == null) { + return null; + } return getScaledBuildingTypeImage(building.getType(), building.getOwner(), this.scaleFactor); } public BufferedImage getSmallBuildingImage(Building building) { + if (building == null) { + return null; + } return getScaledBuildingTypeImage(building.getType(), building.getOwner(), this.scaleFactor * SMALL_SCALE); @@ -947,12 +953,12 @@ public final class ImageLibrary { return this.imageCache.getScaledImage(key, this.scaleFactor, false); } - public BufferedImage getColonyDocks() { + public BufferedImage getColonyDocksBackground() { final String key = "image.colony.docks.background"; return this.imageCache.getScaledImage(key, this.scaleFactor, false); } - public BufferedImage getColonyDocksSky() { + public BufferedImage getColonyDocksSkyBackground() { final String key = "image.colony.docks.sky.background"; return this.imageCache.getScaledImage(key, this.scaleFactor, false); } diff --git a/src/net/sf/freecol/client/gui/panel/ColonyPanel.java b/src/net/sf/freecol/client/gui/panel/ColonyPanel.java index 87c45abab..f62fd05c3 100644 --- a/src/net/sf/freecol/client/gui/panel/ColonyPanel.java +++ b/src/net/sf/freecol/client/gui/panel/ColonyPanel.java @@ -519,23 +519,37 @@ public final class ColonyPanel extends PortPanel final Dimension size = getSize(); - final BufferedImage colonyDocks = getImageLibrary().getColonyDocks(); - if (colonyDocks != null) { + final BufferedImage colonyDocksBackground = getImageLibrary().getColonyDocksBackground(); + if (colonyDocksBackground != null) { final int docksBottomLeftX = inPortScroll.getX(); final int docksBottomLeftY = inPortScroll.getY() + inPortScroll.getHeight(); - int y = docksBottomLeftY - colonyDocks.getHeight(); - g.drawImage(colonyDocks, docksBottomLeftX, y, null); + int y = docksBottomLeftY - colonyDocksBackground.getHeight(); + g.drawImage(colonyDocksBackground, docksBottomLeftX, y, null); - final BufferedImage colonyDocksSky = getImageLibrary().getColonyDocksSky(); - if (colonyDocksSky != null) { + final BufferedImage colonyDocksSkyBackground = getImageLibrary().getColonyDocksSkyBackground(); + if (colonyDocksSkyBackground != null) { while (y > 0) { - y -= colonyDocksSky.getHeight(); - g.drawImage(colonyDocksSky, docksBottomLeftX, y, null); + y -= colonyDocksSkyBackground.getHeight(); + g.drawImage(colonyDocksSkyBackground, docksBottomLeftX, y, null); } } } + final Building docksBuilding = colony.getBuildings() + .stream() + .filter(b -> b.hasAbility(Ability.PRODUCE_IN_WATER)) + .sorted(Comparator.comparing(Building::getId)) // Stable sort, but there should only be one value. + .findFirst() + .orElse(null); + final BufferedImage docks = getImageLibrary().getScaledBuildingImage(docksBuilding); + if (docks != null) { + final int docksBottomLeftX = inPortScroll.getX(); + final int docksBottomLeftY = inPortScroll.getY() + inPortScroll.getHeight(); + final int y = docksBottomLeftY - docks.getHeight(); + g.drawImage(docks, docksBottomLeftX, y, null); + } + final List defensiveBuildings = colony.getBuildings() .stream() .filter(b -> b.getType().isDefenceType())