Calculate overlay bounds also for dynamic overlays

In order to use their's bounds later, calculate the bounds for dynamic
and tooltip overlays too.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-03-23 10:13:45 +01:00
parent 3d15de294b
commit 553fee70c4

View File

@@ -335,13 +335,10 @@ public class OverlayRenderer extends MouseListener implements KeyListener
location.setLocation(overlay.getPreferredLocation());
}
final Dimension overlayDimension = MoreObjects.firstNonNull(
safeRender(overlay, graphics, location),
new Dimension());
safeRender(overlay, graphics, location);
dimension.setSize(overlay.getBounds().getSize());
overlay.setBounds(new Rectangle(location, overlayDimension));
if (overlayDimension.width == 0 && overlayDimension.height == 0)
if (dimension.width == 0 && dimension.height == 0)
{
continue;
}
@@ -486,13 +483,13 @@ public class OverlayRenderer extends MouseListener implements KeyListener
}
}
private Dimension safeRender(RenderableEntity entity, Graphics2D graphics, Point point)
private void safeRender(Overlay overlay, Graphics2D graphics, Point point)
{
final Graphics2D subGraphics = (Graphics2D) graphics.create();
subGraphics.translate(point.x, point.y);
final Dimension dimension = entity.render(subGraphics, point);
final Dimension dimension = MoreObjects.firstNonNull(overlay.render(subGraphics, point), new Dimension());
subGraphics.dispose();
return dimension;
overlay.setBounds(new Rectangle(point, dimension));
}
private boolean shouldInvalidateOverlays()