use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.
the class MeasureOverlay method paintComponent.
@Override
protected void paintComponent(final Viewport2D viewport, final Graphics2D graphics) {
if (!this.measureGeometry.isEmpty()) {
final GeometryFactory geometryFactory = getGeometryFactory2d();
try (BaseCloseable transformCloseable = viewport.setUseModelCoordinates(graphics, true)) {
MEASURE_RENDERER.paintSelected(viewport, graphics, geometryFactory, this.measureGeometry);
if (this.measureGeometry instanceof Polygon) {
final Polygon polygon = (Polygon) this.measureGeometry;
GeometryStyleRenderer.renderPolygon(viewport, graphics, polygon, POLYGON_STYLE);
}
}
if (!(this.measureGeometry instanceof Punctual)) {
final TextStyle measureTextStyle = new TextStyle();
measureTextStyle.setTextBoxColor(WebColors.Violet);
measureTextStyle.setTextSize(Quantities.getQuantity(14, CustomUnits.PIXEL));
measureTextStyle.setTextFaceName(Font.MONOSPACED);
Point textPoint;
measureTextStyle.setTextHorizontalAlignment("right");
if (this.measureDataType == DataTypes.POLYGON && this.measureGeometry instanceof Polygon) {
measureTextStyle.setTextDx(Quantities.getQuantity(-5, CustomUnits.PIXEL));
measureTextStyle.setTextPlacementType("vertex(n-1)");
measureTextStyle.setTextVerticalAlignment("middle");
textPoint = this.measureGeometry.getToVertex(0, 1);
} else {
measureTextStyle.setTextDx(Quantities.getQuantity(-7, CustomUnits.PIXEL));
measureTextStyle.setTextDy(Quantities.getQuantity(-2, CustomUnits.PIXEL));
measureTextStyle.setTextPlacementType("vertex(n)");
measureTextStyle.setTextVerticalAlignment("top");
textPoint = this.measureGeometry.getToVertex(0);
}
TextStyleRenderer.renderText(viewport, graphics, this.measureLabel, textPoint, measureTextStyle);
}
}
drawXorGeometry(graphics);
}
use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.
the class SelectRecordsOverlay method refreshImageSelected.
private GeoreferencedImage refreshImageSelected() {
final Viewport2D viewport = getViewport();
if (viewport != null) {
final int width = viewport.getViewWidthPixels();
final int height = viewport.getViewHeightPixels();
if (width > 0 && height > 0) {
try (final ImageViewport imageViewport = new ImageViewport(viewport, BufferedImage.TYPE_INT_ARGB_PRE);
BaseCloseable transformCloseable = imageViewport.setUseModelCoordinates(true)) {
final Graphics2D graphics = imageViewport.getGraphics();
final Project project = getProject();
refreshImageRenderer(imageViewport, project);
refreshImageSelectedAndHighlighted(imageViewport, graphics, project);
return imageViewport.getGeoreferencedImage();
}
}
}
return null;
}
use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.
the class SelectRecordsOverlay method selectRecords.
public void selectRecords(final BoundingBox boundingBox) {
try (BaseCloseable closeable = this.selectingRecords.closeable(true)) {
final LayerGroup project = getProject();
selectRecords(project, boundingBox);
final LayerRendererOverlay overlay = getMap().getLayerOverlay();
overlay.redraw();
redrawAndRepaint();
}
}
use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.
the class MapPanel method setZoomHistoryIndex.
private void setZoomHistoryIndex(int zoomHistoryIndex) {
synchronized (this.zoomHistory) {
try (BaseCloseable updateZoomHistory = this.updateZoomHistory.closeable(false)) {
final boolean zoomPreviousEnabled = isZoomPreviousEnabled();
final boolean zoomNextEnabled = isZoomNextEnabled();
final int zoomHistorySize = this.zoomHistory.size();
if (zoomHistoryIndex < 1) {
zoomHistoryIndex = 0;
} else if (zoomHistoryIndex >= zoomHistorySize) {
zoomHistoryIndex = zoomHistorySize - 2;
}
this.zoomHistoryIndex = zoomHistoryIndex;
final BoundingBox boundingBox = this.zoomHistory.get(zoomHistoryIndex);
this.viewport.setBoundingBoxAndGeometryFactory(boundingBox);
this.project.setViewBoundingBoxAndGeometryFactory(boundingBox);
firePropertyChange("zoomPreviousEnabled", zoomPreviousEnabled, isZoomPreviousEnabled());
firePropertyChange("zoomNextEnabled", zoomNextEnabled, isZoomNextEnabled());
}
}
}
use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.
the class Project method readProject.
public void readProject(final Project rootProject, final Resource resource) {
this.resource = resource;
if (this.resource.exists()) {
String name;
try (final BaseCloseable booleanValueCloseable = eventsDisabled()) {
final RecordStoreConnectionRegistry oldRecordStoreConnections = RecordStoreConnectionRegistry.getForThread();
try {
final boolean readOnly = isReadOnly();
final Resource folderConnectionsDirectory = this.resource.newChildResource("Folder Connections");
this.folderConnections.clear(folderConnectionsDirectory, readOnly);
final Resource recordStoresDirectory = this.resource.newChildResource("Record Stores");
this.recordStores.clear(recordStoresDirectory, readOnly);
final Resource webServicesDirectory = this.resource.newChildResource("Web Services");
this.webServices.clear(webServicesDirectory, readOnly);
if (rootProject == null) {
RecordStoreConnectionRegistry.setForThread(this.recordStores);
} else {
final WebServiceConnectionRegistry rootWebServices = rootProject.getWebServices();
importConnections("Web Service", this, this.webServices, rootWebServices);
final RecordStoreConnectionRegistry rootRecordStores = rootProject.getRecordStores();
rootProject.importConnections("Record Store", this, this.recordStores, rootRecordStores);
final FolderConnectionRegistry rootFolderConnections = rootProject.getFolderConnections();
rootProject.importConnections("Folder Connection", this, this.folderConnections, rootFolderConnections);
}
final Resource layersDir = this.resource.newChildResource("Layers");
final boolean hasLayers = layersDir.exists();
if (hasLayers) {
readProperties(layersDir);
}
if (hasLayers) {
readLayers(rootProject, layersDir);
}
readBaseMapsLayers(rootProject, this.resource);
} finally {
RecordStoreConnectionRegistry.setForThread(oldRecordStoreConnections);
}
name = getName();
setName(null);
}
setName(name);
}
}
Aggregations