use of com.revolsys.gis.grid.RectangularMapTile in project com.revolsys.open by revolsys.
the class GridLayerRenderer method render.
@Override
public void render(final Viewport2D viewport, final Cancellable cancellable, final GridLayer layer) {
try {
final double scaleForVisible = viewport.getScaleForVisible();
if (layer.isVisible(scaleForVisible)) {
final BoundingBox boundingBox = viewport.getBoundingBox();
final RectangularMapGrid grid = layer.getGrid();
final List<RectangularMapTile> tiles = grid.getTiles(boundingBox);
final Graphics2D graphics = viewport.getGraphics();
if (graphics != null) {
final Font font = graphics.getFont();
for (final RectangularMapTile tile : cancellable.cancellable(tiles)) {
final BoundingBox tileBoundingBox = tile.getBoundingBox();
final BoundingBox intersectBoundingBox = boundingBox.intersection(tileBoundingBox);
if (!intersectBoundingBox.isEmpty()) {
final GeometryFactory geometryFactory = viewport.getGeometryFactory();
final Polygon polygon = tile.getPolygon(geometryFactory, 50);
try (BaseCloseable transformCloseable = viewport.setUseModelCoordinates(graphics, true)) {
viewport.drawGeometryOutline(polygon, this.geometryStyle);
}
try (BaseCloseable transformClosable = viewport.setUseModelCoordinates(false)) {
viewport.drawText(tile, polygon, this.textStyle);
}
}
graphics.setFont(font);
}
}
}
} catch (final IllegalArgumentException e) {
}
}
use of com.revolsys.gis.grid.RectangularMapTile in project com.revolsys.open by revolsys.
the class GridLayer method zoomToSheet.
public void zoomToSheet(final String mapsheet) {
final Project project = getProject();
if (project != null) {
if (Property.hasValue(mapsheet)) {
final MapPanel map = getMapPanel();
final RectangularMapGrid grid = getGrid();
final String gridName = grid.getName();
try {
final RectangularMapTile mapTile = grid.getTileByName(mapsheet);
final BoundingBox boundingBox = mapTile.getBoundingBox();
project.setViewBoundingBox(boundingBox);
} catch (final Throwable e) {
final String message = "Invalid mapsheet " + mapsheet + " for " + gridName;
JOptionPane.showMessageDialog(map, message);
} finally {
final String preferenceName = CaseConverter.toCapitalizedWords(gridName) + "Mapsheet";
PreferencesUtil.setString(getClass(), preferenceName, mapsheet);
}
}
}
}
Aggregations