use of com.revolsys.elevation.gridded.GriddedElevationModelImage in project com.revolsys.open by revolsys.
the class RasterizerGriddedElevationModelLayerRenderer method render.
@Override
public void render(final Viewport2D viewport, final Cancellable cancellable, final ElevationModelLayer layer) {
// TODO cancel
final double scaleForVisible = viewport.getScaleForVisible();
if (layer.isVisible(scaleForVisible)) {
if (!layer.isEditable()) {
final GriddedElevationModel elevationModel = getElevationModel();
if (elevationModel != null) {
synchronized (this) {
if (this.rasterizer == null) {
final ColorGradientGriddedElevationModelRasterizer rasterizer = new ColorGradientGriddedElevationModelRasterizer();
setRasterizer(rasterizer);
final String name = this.rasterizer.getName();
setName(name);
}
if (this.image == null) {
this.image = new GriddedElevationModelImage(this.rasterizer);
}
if (this.image.getElevationModel() != elevationModel) {
this.image.setElevationModel(elevationModel);
this.redraw = true;
}
if (this.rasterizer != this.image.getRasterizer()) {
this.image.setRasterizer(this.rasterizer);
this.redraw = true;
}
}
if (this.image.hasImage() && !(this.image.isCached() && this.redraw)) {
final BoundingBox boundingBox = layer.getBoundingBox();
final Graphics2D graphics = viewport.getGraphics();
if (graphics != null) {
final Object interpolationMethod = null;
GeoreferencedImageLayerRenderer.renderAlpha(viewport, graphics, this.image, true, this.opacity, interpolationMethod);
GeoreferencedImageLayerRenderer.renderDifferentCoordinateSystem(viewport, graphics, boundingBox);
}
} else {
synchronized (this) {
if (this.redraw && this.worker == null) {
this.redraw = false;
this.worker = new Thread(() -> {
synchronized (this) {
if (this.worker == Thread.currentThread()) {
this.image.redraw();
this.worker = null;
}
layer.redraw();
}
});
this.worker.start();
}
}
}
}
}
}
}
Aggregations