/** * Handle mouse clicks. * * @param event the event to handle */ @SuppressWarnings("ParameterNameDiffersFromOverriddenParameter") @Override public void mouseClicked(@Nullable final MouseEvent event) { if (event != null) { event.getComponent().requestFocusInWindow(); final java.awt.Point eventPoint = event.getPoint(); final VisibleDimensions dimensions = model.getDimensions(); final MapDimensions mapDim = model.getMapDimensions(); final int tileSize = TileViewSize.scaleZoom(model.getZoomLevel(), mapDim.getVersion()); final Point point = PointFactory.point( (eventPoint.y / tileSize) + dimensions.getMinimumRow(), (eventPoint.x / tileSize) + dimensions.getMinimumCol()); if ((point.getRow() < mapDim.getRows()) && (point.getCol() < mapDim.getColumns())) { model.setSelection(point); if (event.isPopupTrigger()) { menu.show(event.getComponent(), event.getX(), event.getY()); } } } }
/** * @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; } }