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

Diff of /trunk/src/skrueger/geotools/StyledGridCoverageReader.java

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

revision 1203 by alfonx, Tue Nov 2 22:53:55 2010 UTC revision 1212 by alfonx, Wed Nov 3 10:49:38 2010 UTC
# Line 45  import skrueger.i8n.Translation; Line 45  import skrueger.i8n.Translation;
45    
46  /**  /**
47   * This class provides a simple implementation of {@link StyledLayerInterface}   * This class provides a simple implementation of {@link StyledLayerInterface}
48   * for {@link AbstractGridCoverage2DReader}. The uncache functionality is not supported,   * for {@link AbstractGridCoverage2DReader}. The uncache functionality is not
49   * because if the coverage is read once this class bases on an existing {@link GridCoverage2D}   * supported, because if the coverage is read once this class bases on an
50   * object in memory.   * existing {@link GridCoverage2D} object in memory.
51   * @author <a href="mailto:[email protected]">Martin Schmitz</a> (University of Bonn/Germany)   *
52     * @author <a href="mailto:[email protected]">Martin Schmitz</a>
53     *         (University of Bonn/Germany)
54   * @version 1.0   * @version 1.0
55   */   */
56  public class StyledGridCoverageReader extends AbstractStyledLayer<AbstractGridCoverage2DReader> implements StyledGridCoverageReaderInterface {  public class StyledGridCoverageReader extends
57                    AbstractStyledLayer<AbstractGridCoverage2DReader> implements
58                    StyledGridCoverageReaderInterface {
59          @Override          @Override
60          public ReferencedEnvelope getReferencedEnvelope() {          public ReferencedEnvelope getReferencedEnvelope() {
61                  return new ReferencedEnvelope(getEnvelope(), getCrs());                  return new ReferencedEnvelope(getEnvelope(), getCrs());
62          }          }
63    
64    /** Holds the meta data for displaying a legend. */          /** Holds the meta data for displaying a legend. */
65    protected RasterLegendData legendData = null;          protected RasterLegendData legendData = null;
66    
67    /**          /**
68     * Creates a styled grid with language-specific informations.           * Creates a styled grid with language-specific informations.
69     * @param gcr the grid reader           *
70     * @param id a unique ID for the object           * @param gcr
71     * @param title a (language-specific) short description           *            the grid reader
72     * @param desc a (language-specific) long description           * @param id
73     * @param keywords (language-specific) keywords for the geo objects           *            a unique ID for the object
74     * @param style a display style (if {@code null}, a default style is created)           * @param title
75     * @param legendData meta data for displaying a legend           *            a (language-specific) short description
76     * @param icon an icon for the object (can be {@code null})           * @param desc
77     * @exception IllegalArgumentException if {@code null} is given as ID or geo object           *            a (language-specific) long description
78     */           * @param keywords
79    public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, Translation title, Translation desc, Translation keywords, Style style, RasterLegendData legendData, ImageIcon icon) {           *            (language-specific) keywords for the geo objects
80      super(gcr, JTSUtil.createEnvelope(gcr.getOriginalEnvelope()), gcr.getCrs(), id, title, desc, keywords, style, icon);           * @param style
81      setLegendMetaData(legendData);           *            a display style (if {@code null}, a default style is created)
82    }           * @param legendData
83             *            meta data for displaying a legend
84    /**           * @param icon
85     * Creates a styled grid with language-specific informations.           *            an icon for the object (can be {@code null})
86     * @param gcr the grid reader           * @exception IllegalArgumentException
87     * @param id a unique ID for the object           *                if {@code null} is given as ID or geo object
88     * @param title a (language-specific) short description           */
89     * @param desc a (language-specific) long description          public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr,
90     * @param keywords (language-specific) keywords for the geo objects                          String id, Translation title, Translation desc,
91     * @param style a display style with legend information                          Translation keywords, Style style, RasterLegendData legendData,
92     * @param icon an icon for the object (can be {@code null})                          ImageIcon icon) {
93     * @exception IllegalArgumentException if {@code null} is given as ID or geo object                  super(gcr, JTSUtil.createEnvelope(gcr.getOriginalEnvelope()), gcr
94     */                                  .getCrs(), id, title, desc, keywords, style, icon);
95    public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, Translation title, Translation desc, Translation keywords, StyledLayerStyle<RasterLegendData> style, ImageIcon icon) {                  setLegendMetaData(legendData);
96      super(gcr, JTSUtil.createEnvelope(gcr.getOriginalEnvelope()), gcr.getCrs(), id, title, desc, keywords, style != null ? style.getGeoObjectStyle() : null, icon);          }
97      setLegendMetaData( style != null ? style.getMetaData() : null );  
98    }          /**
99             * Creates a styled grid with language-specific informations.
100    /**           *
101     * Creates a styled grid with a language-specific title, no long description, no           * @param gcr
102     * keywords and no icon.           *            the grid reader
103     * @param gcr the grid reader           * @param id
104     * @param id a unique ID for the object           *            a unique ID for the object
105     * @param title a short description           * @param title
106     * @param style a display style (if {@code null}, a default style is created)           *            a (language-specific) short description
107     * @param legendData meta data for displaying a legend           * @param desc
108     * @exception IllegalArgumentException if {@code null} is given as ID or geo object           *            a (language-specific) long description
109     */           * @param keywords
110    public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, Translation title, Style style, RasterLegendData legendData) {           *            (language-specific) keywords for the geo objects
111      this(gcr, id, title, null, null, style, legendData, null);           * @param style
112    }           *            a display style with legend information
113             * @param icon
114    /**           *            an icon for the object (can be {@code null})
115     * Creates a styled grid with non-translated informations.           * @exception IllegalArgumentException
116     * @param gcr the grid reader           *                if {@code null} is given as ID or geo object
117     * @param id a unique ID for the object           */
118     * @param title a short description          public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr,
119     * @param desc a long description                          String id, Translation title, Translation desc,
120     * @param keywords keywords for the geo objects                          Translation keywords, StyledLayerStyle<RasterLegendData> style,
121     * @param style a display style (if {@code null}, a default style is created)                          ImageIcon icon) {
122     * @param legendData meta data for displaying a legend                  super(gcr, JTSUtil.createEnvelope(gcr.getOriginalEnvelope()), gcr
123     * @param icon an icon for the object (can be {@code null})                                  .getCrs(), id, title, desc, keywords, style != null ? style
124     * @exception IllegalArgumentException if {@code null} is given as ID or geo object                                  .getGeoObjectStyle() : null, icon);
125     */                  setLegendMetaData(style != null ? style.getMetaData() : null);
126    public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, String title, String desc, String keywords, Style style, RasterLegendData legendData, ImageIcon icon) {          }
127      this(gcr, id, (Translation)null, null, null, style, legendData, icon);  
128      setTitle(title);          /**
129      setDesc(desc);           * Creates a styled grid with a language-specific title, no long
130      setKeywords(keywords);           * description, no keywords and no icon.
131    }           *
132             * @param gcr
133    /**           *            the grid reader
134     * Creates a styled grid with non-translated informations.           * @param id
135     * @param gcr the grid reader           *            a unique ID for the object
136     * @param id a unique ID for the object           * @param title
137     * @param title a short description           *            a short description
138     * @param desc a long description           * @param style
139     * @param keywords keywords for the geo objects           *            a display style (if {@code null}, a default style is created)
140     * @param style a display style with legend information           * @param legendData
141     * @param icon an icon for the object (can be {@code null})           *            meta data for displaying a legend
142     * @exception IllegalArgumentException if {@code null} is given as ID or geo object           * @exception IllegalArgumentException
143     */           *                if {@code null} is given as ID or geo object
144    public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, String title, String desc, String keywords, StyledLayerStyle<RasterLegendData> style, ImageIcon icon) {           */
145      this(gcr,          public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr,
146           id,                          String id, Translation title, Style style,
147           title,                          RasterLegendData legendData) {
148           desc,                  this(gcr, id, title, null, null, style, legendData, null);
149           keywords,          }
150           style != null ? style.getGeoObjectStyle() : null,  
151           style != null ? style.getMetaData() : null,          /**
152           icon           * Creates a styled grid with non-translated informations.
153      );           *
154    }           * @param gcr
155             *            the grid reader
156    /**           * @param id
157     * Creates a styled grid with a non-translated title, no long description, no           *            a unique ID for the object
158     * keywords and no icon.           * @param title
159     * @param gcr the grid reader           *            a short description
160     * @param id a unique ID for the object           * @param desc
161     * @param title a short description           *            a long description
162     * @param style a display style (if {@code null}, a default style is created)           * @param keywords
163     * @exception IllegalArgumentException if {@code null} is given as ID or geo object           *            keywords for the geo objects
164     */           * @param style
165    public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, String title, Style style, RasterLegendData legendData) {           *            a display style (if {@code null}, a default style is created)
166      this(gcr, id, title, null, null, style, legendData, null);           * @param legendData
167    }           *            meta data for displaying a legend
168             * @param icon
169    /**           *            an icon for the object (can be {@code null})
170     * Creates a styled grid with a non-translated title, no long description, no           * @exception IllegalArgumentException
171     * keywords and no icon.           *                if {@code null} is given as ID or geo object
172     * @param gcr the grid reader           */
173     * @param id a unique ID for the object          public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr,
174     * @param title a short description                          String id, String title, String desc, String keywords, Style style,
175     * @param style a display style with legend information                          RasterLegendData legendData, ImageIcon icon) {
176     * @exception IllegalArgumentException if {@code null} is given as ID or geo object                  this(gcr, id, (Translation) null, null, null, style, legendData, icon);
177     */                  setTitle(title);
178    public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr, String id, String title, StyledLayerStyle<RasterLegendData> style) {                  setDesc(desc);
179      this(gcr,                  setKeywords(keywords);
180           id,          }
181           title,  
182           null,          /**
183           null,           * Creates a styled grid with non-translated informations.
184           style != null ? style.getGeoObjectStyle() : null,           *
185           style != null ? style.getMetaData() : null,           * @param gcr
186           null           *            the grid reader
187      );           * @param id
188    }           *            a unique ID for the object
189             * @param title
190    /**           *            a short description
191     * Creates a default style for a {@link GridCoverage2D}.           * @param desc
192     * @see GridUtil#createDefaultStyle()           *            a long description
193     */           * @param keywords
194    protected Style createDefaultStyle() {           *            keywords for the geo objects
195      return GridUtil.createDefaultStyle();           * @param style
196    }           *            a display style with legend information
197             * @param icon
198    /**           *            an icon for the object (can be {@code null})
199     * Returns the meta data needed for displaying a legend.           * @exception IllegalArgumentException
200     */           *                if {@code null} is given as ID or geo object
201    public RasterLegendData getLegendMetaData() {           */
202      return legendData;          public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr,
203    }                          String id, String title, String desc, String keywords,
204                            StyledLayerStyle<RasterLegendData> style, ImageIcon icon) {
205    /**                  this(gcr, id, title, desc, keywords, style != null ? style
206     * Sets the meta data needed for displaying a legend.                                  .getGeoObjectStyle() : null, style != null ? style
207     * If {@code legendData} is {@code null} an empty {@link RasterLegendData}                                  .getMetaData() : null, icon);
208     * (without gaps) is set, so {@link #getLegendMetaData()} never returns {@code null}.          }
209     * @param legendData legend meta data  
210     */          /**
211    public void setLegendMetaData(RasterLegendData legendData) {           * Creates a styled grid with a non-translated title, no long description,
212      this.legendData = (legendData != null) ? legendData : new RasterLegendData(false);           * no keywords and no icon.
213    }           *
214             * @param gcr
215    /**           *            the grid reader
216     * Simply sets the {@link #geoObject}, {@link #crs}, {@link #envelope} and           * @param id
217     * {@link #legendData} to {@code null}.           *            a unique ID for the object
218     */           * @param title
219    public void dispose() {           *            a short description
220      this.geoObject  = null;           * @param style
221      this.envelope   = null;           *            a display style (if {@code null}, a default style is created)
222      this.crs        = null;           * @exception IllegalArgumentException
223      this.legendData = null;           *                if {@code null} is given as ID or geo object
224    }           */
225            public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr,
226    /**                          String id, String title, Style style, RasterLegendData legendData) {
227     * Tests whether the geo object is disposed.                  this(gcr, id, title, null, null, style, legendData, null);
228     * @return boolean          }
229     */  
230    public boolean isDisposed() {          /**
231      return geoObject == null;           * Creates a styled grid with a non-translated title, no long description,
232    }           * no keywords and no icon.
233             *
234    /**           * @param gcr
235     * Does nothing, because the {@link AbstractStyledLayer} bases on existing           *            the grid reader
236     * objects (in memory) which can not be uncached and reloaded.           * @param id
237     */           *            a unique ID for the object
238    public void uncache() {           * @param title
239      LOGGER.warn("Uncache functionality is not supported. Object remains in memory.");           *            a short description
240    }           * @param style
241             *            a display style with legend information
242    /*           * @exception IllegalArgumentException
243     * (non-Javadoc)           *                if {@code null} is given as ID or geo object
244     * @see skrueger.geotools.StyledLayerInterface#getInfoURL()           */
245     */          public StyledGridCoverageReader(AbstractGridCoverage2DReader gcr,
246    public URL getInfoURL() {                          String id, String title, StyledLayerStyle<RasterLegendData> style) {
247      return null;                  this(gcr, id, title, null, null, style != null ? style
248    }                                  .getGeoObjectStyle() : null, style != null ? style
249                                    .getMetaData() : null, null);
250            }
251    
252            public StyledGridCoverageReader(AbstractGridCoverage2DReader reader) {
253                    this(reader, "", "", null, null);
254            }
255    
256            /**
257             * Creates a default style for a {@link GridCoverage2D}.
258             *
259             * @see GridUtil#createDefaultStyle()
260             */
261            protected Style createDefaultStyle() {
262                    return GridUtil.createDefaultStyle();
263            }
264    
265            /**
266             * Returns the meta data needed for displaying a legend.
267             */
268            public RasterLegendData getLegendMetaData() {
269                    return legendData;
270            }
271    
272            /**
273             * Sets the meta data needed for displaying a legend. If {@code legendData}
274             * is {@code null} an empty {@link RasterLegendData} (without gaps) is set,
275             * so {@link #getLegendMetaData()} never returns {@code null}.
276             *
277             * @param legendData
278             *            legend meta data
279             */
280            public void setLegendMetaData(RasterLegendData legendData) {
281                    this.legendData = (legendData != null) ? legendData
282                                    : new RasterLegendData(false);
283            }
284    
285            /**
286             * Simply sets the {@link #geoObject}, {@link #crs}, {@link #envelope} and
287             * {@link #legendData} to {@code null}.
288             */
289            public void dispose() {
290                    this.geoObject = null;
291                    this.envelope = null;
292                    this.crs = null;
293                    this.legendData = null;
294            }
295    
296    /**          /**
297             * Tests whether the geo object is disposed.
298             *
299             * @return boolean
300             */
301            public boolean isDisposed() {
302                    return geoObject == null;
303            }
304    
305            /**
306             * Does nothing, because the {@link AbstractStyledLayer} bases on existing
307             * objects (in memory) which can not be uncached and reloaded.
308             */
309            public void uncache() {
310                    LOGGER.warn("Uncache functionality is not supported. Object remains in memory.");
311            }
312    
313            /*
314             * (non-Javadoc)
315             *
316             * @see skrueger.geotools.StyledLayerInterface#getInfoURL()
317             */
318            public URL getInfoURL() {
319                    return null;
320            }
321    
322            /**
323           * If true, this layer will not be shown in the legend. Default = false           * If true, this layer will not be shown in the legend. Default = false
324           */           */
325          /**          /**
# Line 256  public class StyledGridCoverageReader ex Line 331  public class StyledGridCoverageReader ex
331           * nicht in der Legende auftauchen sollen. Meines Wissens hat keiner bisher           * nicht in der Legende auftauchen sollen. Meines Wissens hat keiner bisher
332           * die Funktion genutzt.           * die Funktion genutzt.
333           *           *
334    public boolean isHideInLegend() {           * public boolean isHideInLegend() { return false; }
     return false;  
   }  
335           */           */
336      
337  }  }

Legend:
Removed from v.1203  
changed lines
  Added in v.1212

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26