/[schmitzm]/branches/1.0-gt2-2.6/src/skrueger/geotools/StyledGridCoverageReader.java
ViewVC logotype

Annotation of /branches/1.0-gt2-2.6/src/skrueger/geotools/StyledGridCoverageReader.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations)
Tue Feb 24 22:43:52 2009 UTC (16 years ago) by mojays
Original Path: trunk/src/skrueger/geotools/StyledGridCoverageReader.java
File size: 8613 byte(s)
First Commit, corresponds to Revision 1008 of Wikisquare-SVN
includes:
- schmitzm.* (except schmitzm.test)
- org.geotools.* (all overridden classes)
- skrueger.geotools
- skrueger.i8n
- skrueger.swing
- appl.data.LateLoadable (dependency in SCHMITZM)
- appl.data.LoadingException (dependency in SCHMITZM)
- appl.util.RasterMetaData (dependency in SCHMITZM)

1 mojays 2 package skrueger.geotools;
2    
3     import java.net.URL;
4    
5     import javax.swing.ImageIcon;
6    
7     import org.geotools.styling.Style;
8     import org.geotools.coverage.grid.GridCoverage2D;
9     import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader;
10    
11     import schmitzm.geotools.JTSUtil;
12     import schmitzm.geotools.grid.GridUtil;
13    
14     import skrueger.i8n.Translation;
15     import skrueger.RasterLegendData;
16    
17     /**
18     * This class provides a simple implementation of {@link StyledMapInterface}
19     * for {@link AbstractGridCoverage2DReader}. The uncache functionality is not supported,
20     * because if the coverage is read once this class bases on an existing {@link GridCoverage2D}
21     * object in memory.
22     * @author <a href="mailto:[email protected]">Martin Schmitz</a> (University of Bonn/Germany)
23     * @version 1.0
24     */
25     public class StyledGridCoverageReader extends AbstractStyledMap<AbstractGridCoverage2DReader> implements StyledGridCoverageReaderInterface {
26    
27     /** Holds the meta data for displaying a legend. */
28     protected RasterLegendData legendData = null;
29    
30     /**
31     * Creates a styled grid with language-specific informations.
32     * @param gcr the grid reader
33     * @param id a unique ID for the object
34     * @param title a (language-specific) short description
35     * @param desc a (language-specific) long description
36     * @param keywords (language-specific) keywords for the geo objects
37     * @param style a display style (if {@code null}, a default style is created)
38     * @param legendData meta data for displaying a legend
39     * @param icon an icon for the object (can be {@code null})
40     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
41     */
42     public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, Translation title, Translation desc, Translation keywords, Style style, RasterLegendData legendData, ImageIcon icon) {
43     super(gcr, JTSUtil.createEnvelope(gcr.getOriginalEnvelope()), gcr.getCrs(), id, title, desc, keywords, style, icon);
44     setLegendMetaData(legendData);
45     }
46    
47     /**
48     * Creates a styled grid with language-specific informations.
49     * @param gcr the grid reader
50     * @param id a unique ID for the object
51     * @param title a (language-specific) short description
52     * @param desc a (language-specific) long description
53     * @param keywords (language-specific) keywords for the geo objects
54     * @param style a display style with legend information
55     * @param icon an icon for the object (can be {@code null})
56     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
57     */
58     public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, Translation title, Translation desc, Translation keywords, StyledMapStyle<RasterLegendData> style, ImageIcon icon) {
59     super(gcr, JTSUtil.createEnvelope(gcr.getOriginalEnvelope()), gcr.getCrs(), id, title, desc, keywords, style != null ? style.getGeoObjectStyle() : null, icon);
60     setLegendMetaData( style != null ? style.getMetaData() : null );
61     }
62    
63     /**
64     * Creates a styled grid with a language-specific title, no long description, no
65     * keywords and no icon.
66     * @param gcr the grid reader
67     * @param id a unique ID for the object
68     * @param title a short description
69     * @param style a display style (if {@code null}, a default style is created)
70     * @param legendData meta data for displaying a legend
71     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
72     */
73     public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, Translation title, Style style, RasterLegendData legendData) {
74     this(gcr, id, title, null, null, style, legendData, null);
75     }
76    
77     /**
78     * Creates a styled grid with non-translated informations.
79     * @param gcr the grid reader
80     * @param id a unique ID for the object
81     * @param title a short description
82     * @param desc a long description
83     * @param keywords keywords for the geo objects
84     * @param style a display style (if {@code null}, a default style is created)
85     * @param legendData meta data for displaying a legend
86     * @param icon an icon for the object (can be {@code null})
87     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
88     */
89     public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, String title, String desc, String keywords, Style style, RasterLegendData legendData, ImageIcon icon) {
90     this(gcr, id, (Translation)null, null, null, style, legendData, icon);
91     setTitle(title);
92     setDesc(desc);
93     setKeywords(keywords);
94     }
95    
96     /**
97     * Creates a styled grid with non-translated informations.
98     * @param gcr the grid reader
99     * @param id a unique ID for the object
100     * @param title a short description
101     * @param desc a long description
102     * @param keywords keywords for the geo objects
103     * @param style a display style with legend information
104     * @param icon an icon for the object (can be {@code null})
105     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
106     */
107     public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, String title, String desc, String keywords, StyledMapStyle<RasterLegendData> style, ImageIcon icon) {
108     this(gcr,
109     id,
110     title,
111     desc,
112     keywords,
113     style != null ? style.getGeoObjectStyle() : null,
114     style != null ? style.getMetaData() : null,
115     icon
116     );
117     }
118    
119     /**
120     * Creates a styled grid with a non-translated title, no long description, no
121     * keywords and no icon.
122     * @param gcr the grid reader
123     * @param id a unique ID for the object
124     * @param title a short description
125     * @param style a display style (if {@code null}, a default style is created)
126     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
127     */
128     public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, String title, Style style, RasterLegendData legendData) {
129     this(gcr, id, title, null, null, style, legendData, null);
130     }
131    
132     /**
133     * Creates a styled grid with a non-translated title, no long description, no
134     * keywords and no icon.
135     * @param gcr the grid reader
136     * @param id a unique ID for the object
137     * @param title a short description
138     * @param style a display style with legend information
139     * @exception IllegalArgumentException if {@code null} is given as ID or geo object
140     */
141     public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, String title, StyledMapStyle<RasterLegendData> style) {
142     this(gcr,
143     id,
144     title,
145     null,
146     null,
147     style != null ? style.getGeoObjectStyle() : null,
148     style != null ? style.getMetaData() : null,
149     null
150     );
151     }
152    
153     /**
154     * Creates a default style for a {@link GridCoverage2D}.
155     * @see GridUtil#createDefaultStyle()
156     */
157     protected Style createDefaultStyle() {
158     return GridUtil.createDefaultStyle();
159     }
160    
161     /**
162     * Returns the meta data needed for displaying a legend.
163     */
164     public RasterLegendData getLegendMetaData() {
165     return legendData;
166     }
167    
168     /**
169     * Sets the meta data needed for displaying a legend.
170     * If {@code legendData} is {@code null} an empty {@link RasterLegendData}
171     * (without gaps) is set, so {@link #getLegendMetaData()} never returns {@code null}.
172     * @param legendData legend meta data
173     */
174     public void setLegendMetaData(RasterLegendData legendData) {
175     this.legendData = (legendData != null) ? legendData : new RasterLegendData(false);
176     }
177    
178     /**
179     * Simply sets the {@link #geoObject}, {@link #crs}, {@link #envelope} and
180     * {@link #legendData} to {@code null}.
181     */
182     public void dispose() {
183     this.geoObject = null;
184     this.envelope = null;
185     this.crs = null;
186     this.legendData = null;
187     }
188    
189     /**
190     * Tests whether the geo object is disposed.
191     * @return boolean
192     */
193     public boolean isDisposed() {
194     return geoObject == null;
195     }
196    
197     /**
198     * Does nothing, because the {@link AbstractStyledMap} bases on existing
199     * objects (in memory) which can not be uncached and reloaded.
200     */
201     public void uncache() {
202     LOGGER.warn("Uncache functionality is not supported. Object remains in memory.");
203     }
204    
205     /*
206     * (non-Javadoc)
207     * @see skrueger.geotools.StyledMapInterface#getInfoURL()
208     */
209     public URL getInfoURL() {
210     return null;
211     }
212    
213     public boolean isHideInLegend() {
214     return false;
215     }
216    
217     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26