/[schmitzm]/trunk/src/skrueger/geotools/StyledGridCoverage.java
ViewVC logotype

Contents of /trunk/src/skrueger/geotools/StyledGridCoverage.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 224 - (show annotations)
Tue Jul 14 15:57:19 2009 UTC (15 years, 7 months ago) by alfonx
File size: 8804 byte(s)
* big biG BIG refactoring: StyledMap[Interface,Util,Style] never dealt with Maps (=Orchestrations of layers), but always only with single Layers. Now it has been refactored to StyledLayer[Interface,Util,Style]. 
* Some variable names and methodNames have been corrected also, but many will still be missing.
* New JARs committed
1 package skrueger.geotools;
2
3 import java.net.URL;
4
5 import javax.swing.ImageIcon;
6
7 import org.geotools.coverage.grid.GridCoverage2D;
8 import org.geotools.styling.Style;
9
10 import schmitzm.geotools.JTSUtil;
11 import schmitzm.geotools.grid.GridUtil;
12 import skrueger.RasterLegendData;
13 import skrueger.i8n.Translation;
14
15 /**
16 * This class provides a simple implementation of {@link StyledLayerInterface}
17 * for {@link GridCoverage2D}. The uncache functionality is not supported,
18 * because this class bases on an existing {@link GridCoverage2D} object in
19 * memory.
20 * @author <a href="mailto:[email protected]">Martin Schmitz</a> (University of Bonn/Germany)
21 * @version 1.0
22 */
23 public class StyledGridCoverage extends AbstractStyledLayer<GridCoverage2D> implements StyledGridCoverageInterface {
24
25 /** Holds the meta data for displaying a legend. */
26 protected RasterLegendData legendData = null;
27
28 /**
29 * Creates a styled grid with language-specific informations.
30 * @param gc the grid
31 * @param id a unique ID for the object
32 * @param title a (language-specific) short description
33 * @param desc a (language-specific) long description
34 * @param keywords (language-specific) keywords for the geo objects
35 * @param style a display style (if {@code null}, a default style is created)
36 * @param legendData meta data for displaying a legend
37 * @param icon an icon for the object (can be {@code null})
38 * @exception IllegalArgumentException if {@code null} is given as ID or geo object
39 */
40 public StyledGridCoverage(GridCoverage2D gc, String id, Translation title, Translation desc, Translation keywords, Style style, RasterLegendData legendData, ImageIcon icon) {
41 super(gc, JTSUtil.createEnvelope(gc.getEnvelope()), gc.getCoordinateReferenceSystem(), id, title, desc, keywords, style, icon);
42 setLegendMetaData(legendData);
43 }
44
45 /**
46 * Creates a styled grid with language-specific informations.
47 * @param gc the grid
48 * @param id a unique ID for the object
49 * @param title a (language-specific) short description
50 * @param desc a (language-specific) long description
51 * @param keywords (language-specific) keywords for the geo objects
52 * @param style a display style with legend information
53 * @param icon an icon for the object (can be {@code null})
54 * @exception IllegalArgumentException if {@code null} is given as ID or geo object
55 */
56 public StyledGridCoverage(GridCoverage2D gc, String id, Translation title, Translation desc, Translation keywords, StyledLayerStyle<RasterLegendData> style, ImageIcon icon) {
57 super(gc, JTSUtil.createEnvelope(gc.getEnvelope()), gc.getCoordinateReferenceSystem(), id, title, desc, keywords, style != null ? style.getGeoObjectStyle() : null, icon);
58 setLegendMetaData( style != null ? style.getMetaData() : null );
59 }
60
61 /**
62 * Creates a styled grid with a language-specific title, no long description, no
63 * keywords and no icon.
64 * @param gc the grid
65 * @param id a unique ID for the object
66 * @param title a short description
67 * @param style a display style (if {@code null}, a default style is created)
68 * @param legendData meta data for displaying a legend
69 * @exception IllegalArgumentException if {@code null} is given as ID or geo object
70 */
71 public StyledGridCoverage(GridCoverage2D gc, String id, Translation title, Style style, RasterLegendData legendData) {
72 this(gc, id, title, null, null, style, legendData, null);
73 }
74
75 /**
76 * Creates a styled grid with non-translated informations.
77 * @param gc the grid
78 * @param id a unique ID for the object
79 * @param title a short description
80 * @param desc a long description
81 * @param keywords keywords for the geo objects
82 * @param style a display style (if {@code null}, a default style is created)
83 * @param legendData meta data for displaying a legend
84 * @param icon an icon for the object (can be {@code null})
85 * @exception IllegalArgumentException if {@code null} is given as ID or geo object
86 */
87 public StyledGridCoverage(GridCoverage2D gc, String id, String title, String desc, String keywords, Style style, RasterLegendData legendData, ImageIcon icon) {
88 this(gc, id, (Translation)null, null, null, style, legendData, icon);
89 setTitle(title);
90 setDesc(desc);
91 setKeywords(keywords);
92 }
93
94 /**
95 * Creates a styled grid with non-translated informations.
96 * @param gc the grid
97 * @param id a unique ID for the object
98 * @param title a short description
99 * @param desc a long description
100 * @param keywords keywords for the geo objects
101 * @param style a display style with legend information
102 * @param icon an icon for the object (can be {@code null})
103 * @exception IllegalArgumentException if {@code null} is given as ID or geo object
104 */
105 public StyledGridCoverage(GridCoverage2D gc, String id, String title, String desc, String keywords, StyledLayerStyle<RasterLegendData> style, ImageIcon icon) {
106 this(gc,
107 id,
108 title,
109 desc,
110 keywords,
111 style != null ? style.getGeoObjectStyle() : null,
112 style != null ? style.getMetaData() : null,
113 icon
114 );
115 }
116
117 /**
118 * Creates a styled grid with a non-translated title, no long description, no
119 * keywords and no icon.
120 * @param gc the grid
121 * @param id a unique ID for the object
122 * @param title a short description
123 * @param style a display style (if {@code null}, a default style is created)
124 * @exception IllegalArgumentException if {@code null} is given as ID or geo object
125 */
126 public StyledGridCoverage(GridCoverage2D gc, String id, String title, Style style, RasterLegendData legendData) {
127 this(gc, id, title, null, null, style, legendData, null);
128 }
129
130 /**
131 * Creates a styled grid with a non-translated title, no long description, no
132 * keywords and no icon.
133 * @param gc the grid
134 * @param id a unique ID for the object
135 * @param title a short description
136 * @param style a display style with legend information
137 * @exception IllegalArgumentException if {@code null} is given as ID or geo object
138 */
139 public StyledGridCoverage(GridCoverage2D gc, String id, String title, StyledLayerStyle<RasterLegendData> style) {
140 this(gc,
141 id,
142 title,
143 null,
144 null,
145 style != null ? style.getGeoObjectStyle() : null,
146 style != null ? style.getMetaData() : null,
147 null
148 );
149 }
150
151 /**
152 * Creates a default style for a {@link GridCoverage2D}.
153 * @see GridUtil#createDefaultStyle()
154 */
155 protected Style createDefaultStyle() {
156 return GridUtil.createDefaultStyle();
157 }
158
159 /**
160 * Returns the meta data needed for displaying a legend.
161 */
162 public RasterLegendData getLegendMetaData() {
163 return legendData;
164 }
165
166 /**
167 * Sets the meta data needed for displaying a legend.
168 * If {@code legendData} is {@code null} an empty {@link RasterLegendData}
169 * (without gaps) is set, so {@link #getLegendMetaData()} never returns {@code null}.
170 * @param legendData legend meta data
171 */
172 public void setLegendMetaData(RasterLegendData legendData) {
173 this.legendData = (legendData != null) ? legendData : new RasterLegendData(false);
174 }
175
176 /**
177 * Simply sets the {@link #geoObject}, {@link #crs}, {@link #envelope} and
178 * {@link #legendData} to {@code null}.
179 */
180 public void dispose() {
181 this.geoObject = null;
182 this.envelope = null;
183 this.crs = null;
184 this.legendData = null;
185 }
186
187 /**
188 * Tests whether the geo object is disposed.
189 * @return boolean
190 */
191 public boolean isDisposed() {
192 return geoObject == null;
193 }
194
195 /**
196 * Does nothing, because the {@link AbstractStyledLayer} bases on existing
197 * objects (in memory) which can not be uncached and reloaded.
198 */
199 public void uncache() {
200 LOGGER.warn("Uncache functionality is not supported. Object remains in memory.");
201 }
202
203 /*
204 * (non-Javadoc)
205 * @see skrueger.geotools.StyledLayerInterface#getInfoURL()
206 */
207 public URL getInfoURL() {
208 return null;
209 }
210
211 /**
212 * If true, this layer will not be shown in the legend. Default = false
213 */
214 /**
215 *
216 * Killed by SK: 6. April 09: Ein Layer soll nicht generell auf
217 * verstecken/nicht verstecken gestellt werden können. Das sind
218 * Eigenschaften der Karte/MapContext, ebenso wie die Reihenfolge der Layer.
219 * Im Atlas verwaltet deshalb nun die Klasse skrueger.atlas.Map welche Layer
220 * nicht in der Legende auftauchen sollen. Meines Wissens hat keiner bisher
221 * die Funktion genutzt.
222 *
223 public boolean isHideInLegend() {
224 return false;
225 }
226 */
227
228 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26