Search in sources :

Example 1 with GriddedElevationModelRasterizerDataBuffer

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

the class GriddedElevationModelImage method redraw.

public void redraw() {
    synchronized (this) {
        if (this.imageBuffer == null) {
            final int width = this.elevationModel.getGridWidth();
            final int height = this.elevationModel.getGridHeight();
            final ColorModel colorModel = ColorModel.getRGBdefault();
            final DataBuffer imageBuffer;
            if (this.cached) {
                imageBuffer = new TempFileMappedIntDataBuffer(width, height);
            } else {
                imageBuffer = new GriddedElevationModelRasterizerDataBuffer(this.rasterizer);
            }
            final SampleModel sampleModel = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, width, height, new int[] { // Red
            0x00ff0000, // Green
            0x0000ff00, // Blue
            0x000000ff, // Alpha
            0xff000000 });
            final WritableRaster raster = new IntegerRaster(sampleModel, imageBuffer);
            final BufferedImage image = new BufferedImage(colorModel, raster, false, null);
            if (this.cached) {
                this.rasterizer.rasterize(imageBuffer);
            }
            setRenderedImage(image);
            this.imageBuffer = imageBuffer;
        } else {
            if (this.cached) {
                this.rasterizer.rasterize(this.imageBuffer);
            }
        }
    }
}
Also used : SinglePixelPackedSampleModel(java.awt.image.SinglePixelPackedSampleModel) SampleModel(java.awt.image.SampleModel) ColorModel(java.awt.image.ColorModel) WritableRaster(java.awt.image.WritableRaster) GriddedElevationModelRasterizerDataBuffer(com.revolsys.elevation.gridded.rasterizer.GriddedElevationModelRasterizerDataBuffer) SinglePixelPackedSampleModel(java.awt.image.SinglePixelPackedSampleModel) BufferedImage(java.awt.image.BufferedImage) GriddedElevationModelRasterizerDataBuffer(com.revolsys.elevation.gridded.rasterizer.GriddedElevationModelRasterizerDataBuffer) DataBuffer(java.awt.image.DataBuffer)

Aggregations

GriddedElevationModelRasterizerDataBuffer (com.revolsys.elevation.gridded.rasterizer.GriddedElevationModelRasterizerDataBuffer)1 BufferedImage (java.awt.image.BufferedImage)1 ColorModel (java.awt.image.ColorModel)1 DataBuffer (java.awt.image.DataBuffer)1 SampleModel (java.awt.image.SampleModel)1 SinglePixelPackedSampleModel (java.awt.image.SinglePixelPackedSampleModel)1 WritableRaster (java.awt.image.WritableRaster)1