/[schmitzm]/trunk/src/skrueger/RasterLegendData.java
ViewVC logotype

Diff of /trunk/src/skrueger/RasterLegendData.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/src/skrueger/RasterLegendData.java revision 244 by alfonx, Wed Jul 29 09:33:33 2009 UTC branches/1.0-gt2-2.6/src/skrueger/RasterLegendData.java revision 398 by mojays, Mon Sep 14 11:42:49 2009 UTC
# Line 2  Line 2 
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:
# Line 32  import java.util.Arrays; Line 32  import java.util.Arrays;
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    import java.util.SortedMap;
37    import java.util.TreeMap;
38    
39  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
40    import org.geotools.coverage.grid.GridCoverage2D;
41    import org.geotools.geometry.Envelope2D;
42    import org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer;
43    
44    import schmitzm.geotools.GTUtil;
45    import schmitzm.geotools.grid.GridUtil;
46  import skrueger.i8n.Translation;  import skrueger.i8n.Translation;
47    
48  /**  /**
# Line 44  import skrueger.i8n.Translation; Line 52  import skrueger.i8n.Translation;
52   * @author <a href="mailto:[email protected]">Stefan Alfons Kr&uuml;ger</a>   * @author <a href="mailto:[email protected]">Stefan Alfons Kr&uuml;ger</a>
53   *   *
54   */   */
55  public class RasterLegendData extends HashMap<Double, Translation> {  public class RasterLegendData extends TreeMap<Double, Translation> {
56          static private final Logger LOGGER = Logger.getLogger(RasterLegendData.class);          static private final Logger LOGGER = Logger.getLogger(RasterLegendData.class);
57          private Boolean paintGaps = false;          private Boolean paintGaps = false;
58    
# Line 61  public class RasterLegendData extends Ha Line 69  public class RasterLegendData extends Ha
69           * indicating nominal values in the raster (e.g. classifications)           * indicating nominal values in the raster (e.g. classifications)
70           */           */
71          public RasterLegendData(boolean paintGaps) {          public RasterLegendData(boolean paintGaps) {
                 super();  
72                  this.paintGaps = paintGaps;                  this.paintGaps = paintGaps;
73          }          }
74    
# Line 69  public class RasterLegendData extends Ha Line 76  public class RasterLegendData extends Ha
76                  return paintGaps ;                  return paintGaps ;
77          }          }
78    
79          public List<Double> getSortedKeys(){  //      public List<Double> getSortedKeys(){
80                  Object[] array = keySet().toArray();  //              Object[] array = keySet().toArray();
81    //
82                  Arrays.sort(array);  //              Arrays.sort(array);
83    //
84                  final LinkedList<Double> linkedList = new LinkedList<Double>();  //              final LinkedList<Double> linkedList = new LinkedList<Double>();
85                  for (Object o : array){  //              for (Object o : array){
86                          linkedList.add( (Double)o);  //                      linkedList.add( (Double)o);
87                  }  //              }
88    //
89                  return linkedList;  //              return linkedList;
90    //
91          }  //      }
92    
93        /**
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        public SortedMap<Double, GridCoverage2D> createSampleRasters() {
99          SortedMap<Double, GridCoverage2D> sampleRaster = new TreeMap<Double, GridCoverage2D>();
100          
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  }  }

Legend:
Removed from v.244  
changed lines
  Added in v.398

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26