/** * @param point a point * @return a HTML-wrapped String (including final newline entity) representing the TerrainFixtures * at that point, and the fixture the user can see as its top fixture. */ private String getTerrainFixturesAndTop(final Point point) { final IMapNG map = model.getMap(); final Collection<TileFixture> fixes = new ArraySet<>(); if (map.isMountainous(point)) { fixes.add(new Mountain()); } final Ground ground = map.getGround(point); if (ground != null) { fixes.add(ground); } final Forest forest = map.getForest(point); if (forest != null) { fixes.add(forest); } final Optional<TileFixture> first = map.streamOtherFixtures(point).findAny(); first.ifPresent(fixes::add); map.streamOtherFixtures(point).filter(TerrainFixture.class::isInstance).forEach(fixes::add); return fixes.stream().map(TileFixture::toString).collect(Collectors.joining("<br />")); }
/** * @param event an event representing the current mouse position * @return a tool-tip message for the tile the mouse is currently over */ @Nullable public String getToolTipText(final MouseEvent event) { final java.awt.Point eventPoint = event.getPoint(); final MapDimensions mapDim = model.getMapDimensions(); final int tileSize = TileViewSize.scaleZoom(model.getZoomLevel(), mapDim.getVersion()); final VisibleDimensions dimensions = model.getDimensions(); final Point point = PointFactory.point( (eventPoint.y / tileSize) + dimensions.getMinimumRow(), (eventPoint.x / tileSize) + dimensions.getMinimumCol()); if ((point.getRow() < mapDim.getRows()) && (point.getCol() < mapDim.getColumns())) { return concat( "<html><body>", point.toString(), ": ", model.getMap().getBaseTerrain(point).toString(), "<br />", getTerrainFixturesAndTop(point), "<br/></body></html>"); } else { return null; } }