Search in sources :

Example 21 with BaseCloseable

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);
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Punctual(com.revolsys.geometry.model.Punctual) TextStyle(com.revolsys.swing.map.layer.record.style.TextStyle) Point(com.revolsys.geometry.model.Point) Polygon(com.revolsys.geometry.model.Polygon)

Example 22 with BaseCloseable

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;
}
Also used : Project(com.revolsys.swing.map.layer.Project) Viewport2D(com.revolsys.swing.map.Viewport2D) BaseCloseable(com.revolsys.io.BaseCloseable) ImageViewport(com.revolsys.swing.map.ImageViewport) Point(com.revolsys.geometry.model.Point) Graphics2D(java.awt.Graphics2D)

Example 23 with BaseCloseable

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();
    }
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) LayerRendererOverlay(com.revolsys.swing.map.overlay.LayerRendererOverlay)

Example 24 with BaseCloseable

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());
        }
    }
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable) BoundingBox(com.revolsys.geometry.model.BoundingBox) Point(com.revolsys.geometry.model.Point)

Example 25 with BaseCloseable

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);
    }
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable) FolderConnectionRegistry(com.revolsys.io.file.FolderConnectionRegistry) WebServiceConnectionRegistry(com.revolsys.webservice.WebServiceConnectionRegistry) PathResource(com.revolsys.spring.resource.PathResource) Resource(com.revolsys.spring.resource.Resource) RecordStoreConnectionRegistry(com.revolsys.record.io.RecordStoreConnectionRegistry)

Aggregations

BaseCloseable (com.revolsys.io.BaseCloseable)46 Point (com.revolsys.geometry.model.Point)9 BoundingBox (com.revolsys.geometry.model.BoundingBox)8 Geometry (com.revolsys.geometry.model.Geometry)7 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)6 Polygon (com.revolsys.geometry.model.Polygon)6 Record (com.revolsys.record.Record)5 LineString (com.revolsys.geometry.model.LineString)4 Identifier (com.revolsys.identifier.Identifier)4 RecordReader (com.revolsys.record.io.RecordReader)4 Graphics2D (java.awt.Graphics2D)4 ArrayList (java.util.ArrayList)4 Vertex (com.revolsys.geometry.model.vertex.Vertex)3 RecordDefinition (com.revolsys.record.schema.RecordDefinition)3 CloseableAffineTransform (com.revolsys.awt.CloseableAffineTransform)2 GeoreferencedImage (com.revolsys.raster.GeoreferencedImage)2 ArrayRecord (com.revolsys.record.ArrayRecord)2 RecordStore (com.revolsys.record.schema.RecordStore)2 Resource (com.revolsys.spring.resource.Resource)2 MapPanel (com.revolsys.swing.map.MapPanel)2