Search in sources :

Example 1 with ColorGradientGriddedElevationModelRasterizer

use of com.revolsys.elevation.gridded.rasterizer.ColorGradientGriddedElevationModelRasterizer in project com.revolsys.open by revolsys.

the class GriddedElevationModelStylePanel method newField.

@Override
protected Field newField(final String fieldName, final Class<?> fieldClass, final Object value) {
    if ("opacity".equals(fieldName)) {
        final PercentSlider opacityField = new PercentSlider("opacity", (float) value);
        Property.addListener(opacityField, this);
        opacityField.setMaximumSize(new Dimension(100, 25));
        return opacityField;
    } else if ("gradient".equals(fieldName)) {
        final ColorGradientField field = new ColorGradientField((ColorGradientGriddedElevationModelRasterizer) this.rasterizer);
        Property.addListener(field, this);
        return field;
    } else {
        return super.newField(fieldName, fieldClass, value);
    }
}
Also used : PercentSlider(com.revolsys.swing.field.PercentSlider) ColorGradientGriddedElevationModelRasterizer(com.revolsys.elevation.gridded.rasterizer.ColorGradientGriddedElevationModelRasterizer) Dimension(java.awt.Dimension)

Example 2 with ColorGradientGriddedElevationModelRasterizer

use of com.revolsys.elevation.gridded.rasterizer.ColorGradientGriddedElevationModelRasterizer in project com.revolsys.open by revolsys.

the class GriddedElevationModel method serviceInit.

public static void serviceInit() {
    IoFactoryRegistry.addFactory(new ScaledIntegerGriddedDigitalElevation());
    IoFactoryRegistry.addFactory(new EsriAsciiGriddedElevation());
    IoFactoryRegistry.addFactory(new UsgsGriddedElevation());
    IoFactoryRegistry.addFactory(new Byn());
    MapObjectFactoryRegistry.newFactory("gradientStop", GradientStop::new);
    MapObjectFactoryRegistry.newFactory("multiStopLinearGradient", MultiStopLinearGradient::new);
    // Rasterizers
    MapObjectFactoryRegistry.newFactory("colorGriddedElevationModelRasterizer", ColorGriddedElevationModelRasterizer::new);
    MapObjectFactoryRegistry.newFactory("colorGradientGriddedElevationModelRasterizer", ColorGradientGriddedElevationModelRasterizer::new);
    MapObjectFactoryRegistry.newFactory("hillShadeGriddedElevationModelRasterizer", HillShadeGriddedElevationModelRasterizer::new);
}
Also used : ColorGriddedElevationModelRasterizer(com.revolsys.elevation.gridded.rasterizer.ColorGriddedElevationModelRasterizer) HillShadeGriddedElevationModelRasterizer(com.revolsys.elevation.gridded.rasterizer.HillShadeGriddedElevationModelRasterizer) ScaledIntegerGriddedDigitalElevation(com.revolsys.elevation.gridded.scaledint.ScaledIntegerGriddedDigitalElevation) Byn(com.revolsys.elevation.gridded.byn.Byn) EsriAsciiGriddedElevation(com.revolsys.elevation.gridded.esriascii.EsriAsciiGriddedElevation) GradientStop(com.revolsys.elevation.gridded.rasterizer.gradient.GradientStop) ColorGradientGriddedElevationModelRasterizer(com.revolsys.elevation.gridded.rasterizer.ColorGradientGriddedElevationModelRasterizer) UsgsGriddedElevation(com.revolsys.elevation.gridded.usgsdem.UsgsGriddedElevation) MultiStopLinearGradient(com.revolsys.elevation.gridded.rasterizer.gradient.MultiStopLinearGradient)

Example 3 with ColorGradientGriddedElevationModelRasterizer

use of com.revolsys.elevation.gridded.rasterizer.ColorGradientGriddedElevationModelRasterizer 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();
                        }
                    }
                }
            }
        }
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) ColorGradientGriddedElevationModelRasterizer(com.revolsys.elevation.gridded.rasterizer.ColorGradientGriddedElevationModelRasterizer) GriddedElevationModel(com.revolsys.elevation.gridded.GriddedElevationModel) GriddedElevationModelImage(com.revolsys.elevation.gridded.GriddedElevationModelImage) Graphics2D(java.awt.Graphics2D)

Example 4 with ColorGradientGriddedElevationModelRasterizer

use of com.revolsys.elevation.gridded.rasterizer.ColorGradientGriddedElevationModelRasterizer in project com.revolsys.open by revolsys.

the class RasterizerGriddedElevationModelLayerRenderer method newColorGradient.

public static RasterizerGriddedElevationModelLayerRenderer newColorGradient(final ElevationModelLayer layer, final IMultipleGriddedElevationModelLayerRenderer parent) {
    final ColorGradientGriddedElevationModelRasterizer rasterizer = new ColorGradientGriddedElevationModelRasterizer();
    final RasterizerGriddedElevationModelLayerRenderer renderer = new RasterizerGriddedElevationModelLayerRenderer(layer, parent, rasterizer);
    renderer.setOpacity(0.8f);
    return renderer;
}
Also used : ColorGradientGriddedElevationModelRasterizer(com.revolsys.elevation.gridded.rasterizer.ColorGradientGriddedElevationModelRasterizer)

Aggregations

ColorGradientGriddedElevationModelRasterizer (com.revolsys.elevation.gridded.rasterizer.ColorGradientGriddedElevationModelRasterizer)4 GriddedElevationModel (com.revolsys.elevation.gridded.GriddedElevationModel)1 GriddedElevationModelImage (com.revolsys.elevation.gridded.GriddedElevationModelImage)1 Byn (com.revolsys.elevation.gridded.byn.Byn)1 EsriAsciiGriddedElevation (com.revolsys.elevation.gridded.esriascii.EsriAsciiGriddedElevation)1 ColorGriddedElevationModelRasterizer (com.revolsys.elevation.gridded.rasterizer.ColorGriddedElevationModelRasterizer)1 HillShadeGriddedElevationModelRasterizer (com.revolsys.elevation.gridded.rasterizer.HillShadeGriddedElevationModelRasterizer)1 GradientStop (com.revolsys.elevation.gridded.rasterizer.gradient.GradientStop)1 MultiStopLinearGradient (com.revolsys.elevation.gridded.rasterizer.gradient.MultiStopLinearGradient)1 ScaledIntegerGriddedDigitalElevation (com.revolsys.elevation.gridded.scaledint.ScaledIntegerGriddedDigitalElevation)1 UsgsGriddedElevation (com.revolsys.elevation.gridded.usgsdem.UsgsGriddedElevation)1 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 PercentSlider (com.revolsys.swing.field.PercentSlider)1 Dimension (java.awt.Dimension)1 Graphics2D (java.awt.Graphics2D)1