use of com.revolsys.swing.map.layer.raster.GeoreferencedImageLayer in project com.revolsys.open by revolsys.
the class EditGeoreferencedImageOverlay method setLayer.
public void setLayer(final GeoreferencedImageLayer layer) {
final GeoreferencedImageLayer oldLayer = this.layer;
if (oldLayer != layer) {
clear();
this.layer = layer;
final Viewport2D viewport = getViewport();
setGeometryFactory(viewport.getGeometryFactory());
setEnabled(layer != null);
if (layer != null) {
this.image = layer.getImage();
setImageBoundingBox(layer.getBoundingBox());
}
if (oldLayer != null) {
oldLayer.setEditable(false);
}
}
firePropertyChange("layer", oldLayer, layer);
}
use of com.revolsys.swing.map.layer.raster.GeoreferencedImageLayer in project com.revolsys.open by revolsys.
the class EditGeoreferencedImageOverlay method paintComponent.
@Override
protected void paintComponent(final Viewport2D viewport, final Graphics2D graphics) {
super.paintComponent(viewport, graphics);
final GeoreferencedImageLayer layer = this.layer;
final GeoreferencedImage image = this.image;
final BoundingBox moveImageBoundingBox = this.moveImageBoundingBox;
if (layer != null && layer.isVisible() && layer.isExists() && image != null) {
try (BaseCloseable transformCloseable = viewport.setUseModelCoordinates(graphics, true)) {
final GeometryFactory viewportGeometryFactory = viewport.getGeometryFactory();
final boolean showOriginalImage = layer.isShowOriginalImage();
final BoundingBox imageBoundingBox = getImageBoundingBox();
BoundingBox boundingBox = imageBoundingBox;
BoundingBox outlineBoundingBox = boundingBox;
if (moveImageBoundingBox != null) {
if (showOriginalImage) {
boundingBox = moveImageBoundingBox;
}
outlineBoundingBox = moveImageBoundingBox;
}
final GeoreferencedImage cachedImage = getCachedImage(boundingBox);
GeoreferencedImageLayerRenderer.renderAlpha(viewport, graphics, cachedImage, false, layer.getOpacity() / 255.0, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
GeoreferencedImageLayerRenderer.renderDifferentCoordinateSystem(viewport, graphics, imageBoundingBox);
if (outlineBoundingBox != null && !outlineBoundingBox.isEmpty()) {
final Polygon imageBoundary = outlineBoundingBox.convert(getViewportGeometryFactory()).toPolygon(1);
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
viewport.drawGeometryOutline(imageBoundary, STYLE_BOX_OUTLINE);
MarkerStyleRenderer.renderMarkerVertices(viewport, graphics, imageBoundary, STYLE_BOX_CORNER);
final List<MappedLocation> tiePoints = image.getTiePoints();
final int tiePointCount = tiePoints.size();
final GeometryFactory viewGeometryFactory = getGeometryFactory();
if (tiePointCount > 0) {
for (final MappedLocation mappedLocation : tiePoints) {
LineString line = mappedLocation.getSourceToTargetLine(image, boundingBox, !showOriginalImage);
if (line != null) {
line = line.convertGeometry(viewportGeometryFactory);
try (BaseCloseable transformCloseable1 = viewport.setUseModelCoordinates(graphics, true)) {
TIE_POINT_RENDERER.paintSelected(viewport, graphics, viewportGeometryFactory, line);
}
}
}
for (final MappedLocation mappedLocation : tiePoints) {
LineString line = mappedLocation.getSourceToTargetLine(image, boundingBox, !showOriginalImage);
if (line != null) {
line = line.convertGeometry(viewportGeometryFactory);
TIE_POINT_VERTEX_RENDERER.paintSelected(viewport, graphics, viewportGeometryFactory, line);
}
}
}
if (!showOriginalImage) {
final double width = image.getImageWidth() - 1;
final double height = image.getImageHeight() - 1;
final double[] targetCoordinates = MappedLocation.toModelCoordinates(image, boundingBox, true, 0, height, width, height, width, 0, 0, 0, 0, height);
final LineString line = viewGeometryFactory.lineString(2, targetCoordinates);
GeometryStyleRenderer.renderLineString(viewport, graphics, line, STYLE_IMAGE_LINE);
}
}
final MappedLocation moveTiePoint = getMoveTiePoint();
if (moveTiePoint != null) {
final LineString line = moveTiePoint.getSourceToTargetLine(image, boundingBox, !showOriginalImage);
Vertex vertex;
if (this.moveTiePointSource) {
vertex = line.getVertex(0);
} else {
vertex = line.getToVertex(0);
}
TIE_POINT_CLOSE_VERTEX_RENDERER.paintSelected(viewport, graphics, viewportGeometryFactory, vertex);
}
}
}
drawXorGeometry(graphics);
}
use of com.revolsys.swing.map.layer.raster.GeoreferencedImageLayer in project com.revolsys.open by revolsys.
the class LayerGroup method openFile.
public int openFile(int index, final URL url) {
final String urlString = url.toString();
final Map<String, Object> properties = new HashMap<>();
properties.put("url", urlString);
String name = UrlUtil.getFileBaseName(url);
name = FileUtil.fromSafeName(name);
properties.put("name", name);
Layer layer;
if (IoFactory.hasFactory(TriangulatedIrregularNetworkReadFactory.class, url)) {
layer = new TriangulatedIrregularNetworkLayer(properties);
} else if (IoFactory.hasFactory(GriddedElevationModelReadFactory.class, url)) {
layer = new GriddedElevationModelLayer(properties);
} else if (IoFactory.hasFactory(GeoreferencedImageReadFactory.class, url)) {
layer = new GeoreferencedImageLayer(properties);
} else if (IoFactory.hasFactory(PointCloudReadFactory.class, url)) {
layer = new PointCloudLayer(properties);
} else if (IoFactory.hasFactory(RecordReaderFactory.class, url)) {
final FileRecordLayer recordLayer = new FileRecordLayer(properties);
final GeometryStyleRenderer renderer = recordLayer.getRenderer();
renderer.setStyle(GeometryStyle.newStyle());
layer = recordLayer;
} else {
layer = null;
}
if (layer != null) {
layer.setProperty("showTableView", isShowNewLayerTableView());
if (index == -1) {
addLayer(layer);
} else {
addLayer(index++, layer);
}
}
return index;
}
use of com.revolsys.swing.map.layer.raster.GeoreferencedImageLayer in project com.revolsys.open by revolsys.
the class LayerGroup method openFile.
public int openFile(final Class<? extends IoFactory> factoryClass, int index, final URL url) {
final String urlString = url.toString();
final Map<String, Object> properties = new HashMap<>();
properties.put("url", urlString);
String name = UrlUtil.getFileBaseName(url);
name = FileUtil.fromSafeName(name);
properties.put("name", name);
Layer layer;
if (factoryClass == TriangulatedIrregularNetworkReadFactory.class) {
layer = new TriangulatedIrregularNetworkLayer(properties);
} else if (factoryClass == GriddedElevationModelReadFactory.class) {
layer = new GriddedElevationModelLayer(properties);
} else if (factoryClass == GeoreferencedImageReadFactory.class) {
layer = new GeoreferencedImageLayer(properties);
} else if (factoryClass == PointCloudReadFactory.class) {
layer = new PointCloudLayer(properties);
} else if (factoryClass == RecordReaderFactory.class) {
final FileRecordLayer recordLayer = new FileRecordLayer(properties);
final GeometryStyleRenderer renderer = recordLayer.getRenderer();
renderer.setStyle(GeometryStyle.newStyle());
layer = recordLayer;
} else {
layer = null;
}
if (layer != null) {
layer.setProperty("showTableView", isShowNewLayerTableView());
if (index == -1) {
addLayer(layer);
} else {
addLayer(index++, layer);
}
}
return index;
}
use of com.revolsys.swing.map.layer.raster.GeoreferencedImageLayer in project com.revolsys.open by revolsys.
the class EditGeoreferencedImageOverlay method propertyChange.
@Override
public void propertyChange(final PropertyChangeEvent event) {
super.propertyChange(event);
final Object source = event.getSource();
final String propertyName = event.getPropertyName();
if (source instanceof GeoreferencedImageLayer) {
final GeoreferencedImageLayer layer = (GeoreferencedImageLayer) source;
if ("editable".equals(propertyName)) {
if (!Booleans.getBoolean(event.getNewValue())) {
if (this.layer == layer) {
setLayer(null);
}
} else {
setLayer(layer);
}
} else if (this.layer == layer) {
clearCachedImage();
if ("boundingBox".equals(propertyName)) {
final BoundingBox boundingBox = layer.getBoundingBox();
setImageBoundingBox(boundingBox);
} else if ("hasChanges".equals(propertyName)) {
clear();
setLayer(layer);
} else if ("deleted".equals(propertyName)) {
clear();
}
}
} else if (source == this.image) {
clearCachedImage();
} else if ("scale".equals(propertyName)) {
clearCachedImage();
}
}
Aggregations