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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 621 - (hide annotations)
Thu Jan 28 10:06:05 2010 UTC (15 years, 1 month ago) by alfonx
Original Path: branches/2.0-RC2/src/skrueger/geotools/StyledGridCoverage.java
File size: 9991 byte(s)
2.0-RC2 ist für die weiterentwicklung und soll bald in den trunk mergen
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.geotools;
31    
32     import java.net.URL;
33    
34     import javax.swing.ImageIcon;
35    
36     import org.geotools.coverage.grid.GridCoverage2D;
37     import org.geotools.styling.Style;
38    
39     import schmitzm.geotools.JTSUtil;
40     import schmitzm.geotools.grid.GridUtil;
41     import skrueger.RasterLegendData;
42     import skrueger.i8n.Translation;
43    
44     /**
45     * This class provides a simple implementation of {@link StyledLayerInterface}
46     * for {@link GridCoverage2D}. The uncache functionality is not supported,
47     * because this class bases on an existing {@link GridCoverage2D} object in
48     * memory.
49     * @author <a href="mailto:[email protected]">Martin Schmitz</a> (University of Bonn/Germany)
50     * @version 1.0
51     */
52     public class StyledGridCoverage extends AbstractStyledLayer<GridCoverage2D> implements StyledGridCoverageInterface {
53    
54     /** Holds the meta data for displaying a legend. */
55     protected RasterLegendData legendData = null;
56    
57     /**
58     * Creates a styled grid with language-specific informations.
59     * @param gc the grid
60     * @param id a unique ID for the object
61     * @param title a (language-specific) short description
62     * @param desc a (language-specific) long description
63     * @param keywords (language-specific) keywords for the geo objects
64     * @param style a display style (if {@code null}, a default style is created)
65     * @param legendData meta data for displaying a legend
66     * @param icon an icon for the object (can be {@code null})
67     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
68     */
69     public StyledGridCoverage(GridCoverage2D gc, String id, Translation title, Translation desc, Translation keywords, Style style, RasterLegendData legendData, ImageIcon icon) {
70     super(gc, JTSUtil.createEnvelope(gc.getEnvelope()), gc.getCoordinateReferenceSystem(), id, title, desc, keywords, style, icon);
71     setLegendMetaData(legendData);
72     }
73    
74     /**
75     * Creates a styled grid with language-specific informations.
76     * @param gc the grid
77     * @param id a unique ID for the object
78     * @param title a (language-specific) short description
79     * @param desc a (language-specific) long description
80     * @param keywords (language-specific) keywords for the geo objects
81     * @param style a display style with legend information
82     * @param icon an icon for the object (can be {@code null})
83     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
84     */
85     public StyledGridCoverage(GridCoverage2D gc, String id, Translation title, Translation desc, Translation keywords, StyledLayerStyle<RasterLegendData> style, ImageIcon icon) {
86     super(gc, JTSUtil.createEnvelope(gc.getEnvelope()), gc.getCoordinateReferenceSystem(), id, title, desc, keywords, style != null ? style.getGeoObjectStyle() : null, icon);
87     setLegendMetaData( style != null ? style.getMetaData() : null );
88     }
89    
90     /**
91     * Creates a styled grid with a language-specific title, no long description, no
92     * keywords and no icon.
93     * @param gc the grid
94     * @param id a unique ID for the object
95     * @param title a short description
96     * @param style a display style (if {@code null}, a default style is created)
97     * @param legendData meta data for displaying a legend
98     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
99     */
100     public StyledGridCoverage(GridCoverage2D gc, String id, Translation title, Style style, RasterLegendData legendData) {
101     this(gc, id, title, null, null, style, legendData, null);
102     }
103    
104     /**
105     * Creates a styled grid with non-translated informations.
106     * @param gc the grid
107     * @param id a unique ID for the object
108     * @param title a short description
109     * @param desc a long description
110     * @param keywords keywords for the geo objects
111     * @param style a display style (if {@code null}, a default style is created)
112     * @param legendData meta data for displaying a legend
113     * @param icon an icon for the object (can be {@code null})
114     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
115     */
116     public StyledGridCoverage(GridCoverage2D gc, String id, String title, String desc, String keywords, Style style, RasterLegendData legendData, ImageIcon icon) {
117     this(gc, id, (Translation)null, null, null, style, legendData, icon);
118     setTitle(title);
119     setDesc(desc);
120     setKeywords(keywords);
121     }
122    
123     /**
124     * Creates a styled grid with non-translated informations.
125     * @param gc the grid
126     * @param id a unique ID for the object
127     * @param title a short description
128     * @param desc a long description
129     * @param keywords keywords for the geo objects
130     * @param style a display style with legend information
131     * @param icon an icon for the object (can be {@code null})
132     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
133     */
134     public StyledGridCoverage(GridCoverage2D gc, String id, String title, String desc, String keywords, StyledLayerStyle<RasterLegendData> style, ImageIcon icon) {
135     this(gc,
136     id,
137     title,
138     desc,
139     keywords,
140     style != null ? style.getGeoObjectStyle() : null,
141     style != null ? style.getMetaData() : null,
142     icon
143     );
144     }
145    
146     /**
147     * Creates a styled grid with a non-translated title, no long description, no
148     * keywords and no icon.
149     * @param gc the grid
150     * @param id a unique ID for the object
151     * @param title a short description
152     * @param style a display style (if {@code null}, a default style is created)
153     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
154     */
155     public StyledGridCoverage(GridCoverage2D gc, String id, String title, Style style, RasterLegendData legendData) {
156     this(gc, id, title, null, null, style, legendData, null);
157     }
158    
159     /**
160     * Creates a styled grid with a non-translated title, no long description, no
161     * keywords and no icon.
162     * @param gc the grid
163     * @param id a unique ID for the object
164     * @param title a short description
165     * @param style a display style with legend information
166     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
167     */
168     public StyledGridCoverage(GridCoverage2D gc, String id, String title, StyledLayerStyle<RasterLegendData> style) {
169     this(gc,
170     id,
171     title,
172     null,
173     null,
174     style != null ? style.getGeoObjectStyle() : null,
175     style != null ? style.getMetaData() : null,
176     null
177     );
178     }
179    
180     /**
181     * Creates a default style for a {@link GridCoverage2D}.
182     * @see GridUtil#createDefaultStyle()
183     */
184     protected Style createDefaultStyle() {
185     return GridUtil.createDefaultStyle();
186     }
187    
188     /**
189     * Returns the meta data needed for displaying a legend.
190     */
191     public RasterLegendData getLegendMetaData() {
192     return legendData;
193     }
194    
195     /**
196     * Sets the meta data needed for displaying a legend.
197     * If {@code legendData} is {@code null} an empty {@link RasterLegendData}
198     * (without gaps) is set, so {@link #getLegendMetaData()} never returns {@code null}.
199     * @param legendData legend meta data
200     */
201     public void setLegendMetaData(RasterLegendData legendData) {
202     this.legendData = (legendData != null) ? legendData : new RasterLegendData(false);
203     }
204    
205     /**
206     * Simply sets the {@link #geoObject}, {@link #crs}, {@link #envelope} and
207     * {@link #legendData} to {@code null}.
208     */
209     public void dispose() {
210     this.geoObject = null;
211     this.envelope = null;
212     this.crs = null;
213     this.legendData = null;
214     }
215    
216     /**
217     * Tests whether the geo object is disposed.
218     * @return boolean
219     */
220     public boolean isDisposed() {
221     return geoObject == null;
222     }
223    
224     /**
225     * Does nothing, because the {@link AbstractStyledLayer} bases on existing
226     * objects (in memory) which can not be uncached and reloaded.
227     */
228     public void uncache() {
229     LOGGER.warn("Uncache functionality is not supported. Object remains in memory.");
230     }
231    
232     /*
233     * (non-Javadoc)
234     * @see skrueger.geotools.StyledLayerInterface#getInfoURL()
235     */
236     public URL getInfoURL() {
237     return null;
238     }
239    
240     /**
241     * If true, this layer will not be shown in the legend. Default = false
242     */
243     /**
244     *
245     * Killed by SK: 6. April 09: Ein Layer soll nicht generell auf
246     * verstecken/nicht verstecken gestellt werden können. Das sind
247     * Eigenschaften der Karte/MapContext, ebenso wie die Reihenfolge der Layer.
248     * Im Atlas verwaltet deshalb nun die Klasse skrueger.atlas.Map welche Layer
249     * nicht in der Legende auftauchen sollen. Meines Wissens hat keiner bisher
250     * die Funktion genutzt.
251     *
252     public boolean isHideInLegend() {
253     return false;
254     }
255     */
256    
257     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26