2 |
* Copyright (c) 2009 Martin O. J. Schmitz. |
* Copyright (c) 2009 Martin O. J. Schmitz. |
3 |
* |
* |
4 |
* This file is part of the SCHMITZM library - a collection of utility |
* This file is part of the SCHMITZM library - a collection of utility |
5 |
* classes based on Java 1.6, focussing (not only) on Java Swing |
* classes based on Java 1.6, focusing (not only) on Java Swing |
6 |
* and the Geotools library. |
* and the Geotools library. |
7 |
* |
* |
8 |
* The SCHMITZM project is hosted at: |
* The SCHMITZM project is hosted at: |
32 |
import java.util.HashMap; |
import java.util.HashMap; |
33 |
import java.util.LinkedList; |
import java.util.LinkedList; |
34 |
import java.util.List; |
import java.util.List; |
35 |
|
import java.util.Map; |
36 |
|
|
37 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
38 |
|
import org.geotools.coverage.grid.GridCoverage2D; |
39 |
|
import org.geotools.geometry.Envelope2D; |
40 |
|
import org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer; |
41 |
|
|
42 |
|
import schmitzm.geotools.GTUtil; |
43 |
|
import schmitzm.geotools.grid.GridUtil; |
44 |
import skrueger.i8n.Translation; |
import skrueger.i8n.Translation; |
45 |
|
|
46 |
/** |
/** |
67 |
* indicating nominal values in the raster (e.g. classifications) |
* indicating nominal values in the raster (e.g. classifications) |
68 |
*/ |
*/ |
69 |
public RasterLegendData(boolean paintGaps) { |
public RasterLegendData(boolean paintGaps) { |
|
super(); |
|
70 |
this.paintGaps = paintGaps; |
this.paintGaps = paintGaps; |
71 |
} |
} |
72 |
|
|
87 |
return linkedList; |
return linkedList; |
88 |
|
|
89 |
} |
} |
90 |
|
|
91 |
|
/** |
92 |
|
* Creates a sample {@link GridCoverage2D} (size 1x1, WGS84) for each |
93 |
|
* legend value. These rasters can be used to do visualize the |
94 |
|
* legend item in the corresponding color via {@link GridCoverageRenderer}. |
95 |
|
*/ |
96 |
|
public Map<Double, GridCoverage2D> createSampleRasters() { |
97 |
|
Map<Double, GridCoverage2D> sampleRaster = new HashMap<Double, GridCoverage2D>(); |
98 |
|
|
99 |
|
for (Double rasterValue : keySet()) { |
100 |
|
GridCoverage2D grid = GridUtil.GRID_FAC.create( |
101 |
|
"Legend_"+rasterValue, |
102 |
|
new float[][] { { rasterValue.floatValue() } }, |
103 |
|
new Envelope2D(GTUtil.WGS84, 0,0,1,1) |
104 |
|
); |
105 |
|
sampleRaster.put(rasterValue, grid); |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
|
return sampleRaster; |
110 |
|
} |
111 |
} |
} |