use of com.revolsys.raster.GeoreferencedImage in project com.revolsys.open by revolsys.
the class LayerRendererOverlay method paintComponent.
@Override
public void paintComponent(final Graphics g) {
if (!(this.layer instanceof NullLayer)) {
GeoreferencedImage image;
synchronized (this.loadSync) {
image = this.image;
if ((image == null || this.loadImage) && this.imageWorker == null) {
final BoundingBox boundingBox = this.viewport.getBoundingBox();
final int viewWidthPixels = this.viewport.getViewWidthPixels();
final int viewHeightPixels = this.viewport.getViewHeightPixels();
final GeoreferencedImage loadImage = new BufferedGeoreferencedImage(boundingBox, viewWidthPixels, viewHeightPixels);
this.imageWorker = new LayerRendererOverlaySwingWorker(this, loadImage);
Invoke.worker(this.imageWorker);
}
}
if (image != null) {
render((Graphics2D) g);
}
}
}
use of com.revolsys.raster.GeoreferencedImage in project com.revolsys.open by revolsys.
the class GeoreferencedImageLayer method getBoundingBox.
@Override
public BoundingBox getBoundingBox() {
final GeoreferencedImage image = getImage();
if (image == null) {
return BoundingBox.empty();
} else {
BoundingBox boundingBox = image.getBoundingBox();
if (boundingBox.isEmpty()) {
final boolean hasChanges = isHasChanges();
boundingBox = fitToViewport();
if (hasChanges) {
saveChanges();
} else {
cancelChanges();
}
}
return boundingBox;
}
}
use of com.revolsys.raster.GeoreferencedImage in project com.revolsys.open by revolsys.
the class TiledImageLayerRenderer method renderTile.
@Override
protected void renderTile(final Viewport2D viewport, final Cancellable cancellable, final T tile) {
final Graphics2D graphics = viewport.getGraphics();
if (graphics != null) {
final GeometryFactory viewportGeometryFactory = viewport.getGeometryFactory();
final GeoreferencedImage image = tile.getImage(viewportGeometryFactory);
if (image != null) {
GeoreferencedImageLayerRenderer.render(viewport, graphics, image, false);
}
}
}
use of com.revolsys.raster.GeoreferencedImage 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.raster.GeoreferencedImage in project com.revolsys.open by revolsys.
the class GeoreferencedImageLayerRenderer method render.
@Override
public void render(final Viewport2D viewport, final Cancellable cancellable, final GeoreferencedImageLayer layer) {
final double scaleForVisible = viewport.getScaleForVisible();
if (layer.isVisible(scaleForVisible)) {
if (!layer.isEditable()) {
final GeoreferencedImage image = layer.getImage();
if (image != null) {
BoundingBox boundingBox = layer.getBoundingBox();
if (boundingBox == null || boundingBox.isEmpty()) {
boundingBox = layer.fitToViewport();
}
final Graphics2D graphics = viewport.getGraphics();
if (graphics != null) {
if (!cancellable.isCancelled()) {
renderAlpha(viewport, graphics, image, true, layer.getOpacity() / 255.0, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
}
if (!cancellable.isCancelled()) {
renderDifferentCoordinateSystem(viewport, graphics, boundingBox);
}
}
}
}
}
}
Aggregations