/[schmitzm]/branches/2.0-RC2/src/skrueger/RasterLegendData.java
ViewVC logotype

Annotation of /branches/2.0-RC2/src/skrueger/RasterLegendData.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 398 - (hide annotations)
Mon Sep 14 11:42:49 2009 UTC (15 years, 5 months ago) by mojays
Original Path: branches/1.0-gt2-2.6/src/skrueger/RasterLegendData.java
File size: 3831 byte(s)
RasterLegendData converted to TreeMap
1 alfonx 244 /*******************************************************************************
2     * Copyright (c) 2009 Martin O. J. Schmitz.
3     *
4     * This file is part of the SCHMITZM library - a collection of utility
5 alfonx 256 * classes based on Java 1.6, focusing (not only) on Java Swing
6 alfonx 244 * and the Geotools library.
7     *
8     * The SCHMITZM project is hosted at:
9     * http://wald.intevation.org/projects/schmitzm/
10     *
11     * This program is free software; you can redistribute it and/or
12     * modify it under the terms of the GNU Lesser General Public License
13     * as published by the Free Software Foundation; either version 3
14     * of the License, or (at your option) any later version.
15     *
16     * This program is distributed in the hope that it will be useful,
17     * but WITHOUT ANY WARRANTY; without even the implied warranty of
18     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19     * GNU General Public License for more details.
20     *
21     * You should have received a copy of the GNU Lesser General Public License (license.txt)
22     * along with this program; if not, write to the Free Software
23     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24     * or try this link: http://www.gnu.org/licenses/lgpl.html
25     *
26     * Contributors:
27     * Martin O. J. Schmitz - initial API and implementation
28     * Stefan A. Krüger - additional utility classes
29     ******************************************************************************/
30     package skrueger;
31     import java.util.Arrays;
32     import java.util.HashMap;
33     import java.util.LinkedList;
34     import java.util.List;
35 mojays 395 import java.util.Map;
36 mojays 398 import java.util.SortedMap;
37     import java.util.TreeMap;
38 alfonx 244
39     import org.apache.log4j.Logger;
40 mojays 395 import org.geotools.coverage.grid.GridCoverage2D;
41     import org.geotools.geometry.Envelope2D;
42     import org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer;
43 alfonx 244
44 mojays 395 import schmitzm.geotools.GTUtil;
45     import schmitzm.geotools.grid.GridUtil;
46 alfonx 244 import skrueger.i8n.Translation;
47    
48     /**
49     * Holds all the additional information needed to paint a Legend for a RasterLayer.
50     * So far, only Legends for one-band raster layers are supported.
51     *
52     * @author <a href="mailto:[email protected]">Stefan Alfons Kr&uuml;ger</a>
53     *
54     */
55 mojays 398 public class RasterLegendData extends TreeMap<Double, Translation> {
56 alfonx 244 static private final Logger LOGGER = Logger.getLogger(RasterLegendData.class);
57     private Boolean paintGaps = false;
58    
59     public Boolean isPaintGaps() {
60     return paintGaps;
61     }
62    
63     public void setPaintGaps(boolean paintPaps) {
64     this.paintGaps = paintPaps;
65     }
66    
67     /**
68     * {@link #paintGaps} defines, if gaps should be painted between the legends colors,
69     * indicating nominal values in the raster (e.g. classifications)
70     */
71     public RasterLegendData(boolean paintGaps) {
72     this.paintGaps = paintGaps;
73     }
74    
75     public boolean getPaintGaps() {
76     return paintGaps ;
77     }
78    
79 mojays 398 // public List<Double> getSortedKeys(){
80     // Object[] array = keySet().toArray();
81     //
82     // Arrays.sort(array);
83     //
84     // final LinkedList<Double> linkedList = new LinkedList<Double>();
85     // for (Object o : array){
86     // linkedList.add( (Double)o);
87     // }
88     //
89     // return linkedList;
90     //
91     // }
92 alfonx 244
93 mojays 395 /**
94     * Creates a sample {@link GridCoverage2D} (size 1x1, WGS84) for each
95     * legend value. These rasters can be used to do visualize the
96     * legend item in the corresponding color via {@link GridCoverageRenderer}.
97     */
98 mojays 398 public SortedMap<Double, GridCoverage2D> createSampleRasters() {
99     SortedMap<Double, GridCoverage2D> sampleRaster = new TreeMap<Double, GridCoverage2D>();
100 mojays 395
101     for (Double rasterValue : keySet()) {
102     GridCoverage2D grid = GridUtil.GRID_FAC.create(
103     "Legend_"+rasterValue,
104     new float[][] { { rasterValue.floatValue() } },
105     new Envelope2D(GTUtil.WGS84, 0,0,1,1)
106     );
107     sampleRaster.put(rasterValue, grid);
108     }
109    
110    
111     return sampleRaster;
112     }
113 alfonx 244 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26