1 |
package skrueger; |
/******************************************************************************* |
2 |
import java.util.Arrays; |
* Copyright (c) 2009 Martin O. J. Schmitz. |
3 |
import java.util.HashMap; |
* |
4 |
import java.util.LinkedList; |
* This file is part of the SCHMITZM library - a collection of utility |
5 |
import java.util.List; |
* classes based on Java 1.6, focusing (not only) on Java Swing |
6 |
|
* and the Geotools library. |
7 |
import org.apache.log4j.Logger; |
* |
8 |
|
* The SCHMITZM project is hosted at: |
9 |
import skrueger.i8n.Translation; |
* http://wald.intevation.org/projects/schmitzm/ |
10 |
|
* |
11 |
/** |
* This program is free software; you can redistribute it and/or |
12 |
* Holds all the additional information needed to paint a Legend for a RasterLayer. |
* modify it under the terms of the GNU Lesser General Public License |
13 |
* So far, only Legends for one-band raster layers are supported. |
* as published by the Free Software Foundation; either version 3 |
14 |
* |
* of the License, or (at your option) any later version. |
15 |
* @author <a href="mailto:[email protected]">Stefan Alfons Krüger</a> |
* |
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 |
public class RasterLegendData extends HashMap<Double, Translation> { |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 |
static private final Logger LOGGER = Logger.getLogger(RasterLegendData.class); |
* GNU General Public License for more details. |
20 |
private Boolean paintGaps = false; |
* |
21 |
|
* You should have received a copy of the GNU Lesser General Public License (license.txt) |
22 |
public Boolean isPaintGaps() { |
* along with this program; if not, write to the Free Software |
23 |
return paintGaps; |
* 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 |
public void setPaintGaps(boolean paintPaps) { |
* Contributors: |
27 |
this.paintGaps = paintPaps; |
* Martin O. J. Schmitz - initial API and implementation |
28 |
} |
* Stefan A. Krüger - additional utility classes |
29 |
|
******************************************************************************/ |
30 |
/** |
package skrueger; |
31 |
* {@link #paintGaps} defines, if gaps should be painted between the legends colors, |
import java.util.Arrays; |
32 |
* indicating nominal values in the raster (e.g. classifications) |
import java.util.HashMap; |
33 |
*/ |
import java.util.LinkedList; |
34 |
public RasterLegendData(boolean paintGaps) { |
import java.util.List; |
35 |
super(); |
|
36 |
this.paintGaps = paintGaps; |
import org.apache.log4j.Logger; |
37 |
} |
|
38 |
|
import skrueger.i8n.Translation; |
39 |
public boolean getPaintGaps() { |
|
40 |
return paintGaps ; |
/** |
41 |
} |
* Holds all the additional information needed to paint a Legend for a RasterLayer. |
42 |
|
* So far, only Legends for one-band raster layers are supported. |
43 |
public List<Double> getSortedKeys(){ |
* |
44 |
Object[] array = keySet().toArray(); |
* @author <a href="mailto:[email protected]">Stefan Alfons Krüger</a> |
45 |
|
* |
46 |
Arrays.sort(array); |
*/ |
47 |
|
public class RasterLegendData extends HashMap<Double, Translation> { |
48 |
final LinkedList<Double> linkedList = new LinkedList<Double>(); |
static private final Logger LOGGER = Logger.getLogger(RasterLegendData.class); |
49 |
for (Object o : array){ |
private Boolean paintGaps = false; |
50 |
linkedList.add( (Double)o); |
|
51 |
} |
public Boolean isPaintGaps() { |
52 |
|
return paintGaps; |
53 |
return linkedList; |
} |
54 |
|
|
55 |
} |
public void setPaintGaps(boolean paintPaps) { |
56 |
} |
this.paintGaps = paintPaps; |
57 |
|
} |
58 |
|
|
59 |
|
/** |
60 |
|
* {@link #paintGaps} defines, if gaps should be painted between the legends colors, |
61 |
|
* indicating nominal values in the raster (e.g. classifications) |
62 |
|
*/ |
63 |
|
public RasterLegendData(boolean paintGaps) { |
64 |
|
this.paintGaps = paintGaps; |
65 |
|
} |
66 |
|
|
67 |
|
public boolean getPaintGaps() { |
68 |
|
return paintGaps ; |
69 |
|
} |
70 |
|
|
71 |
|
public List<Double> getSortedKeys(){ |
72 |
|
Object[] array = keySet().toArray(); |
73 |
|
|
74 |
|
Arrays.sort(array); |
75 |
|
|
76 |
|
final LinkedList<Double> linkedList = new LinkedList<Double>(); |
77 |
|
for (Object o : array){ |
78 |
|
linkedList.add( (Double)o); |
79 |
|
} |
80 |
|
|
81 |
|
return linkedList; |
82 |
|
|
83 |
|
} |
84 |
|
} |