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

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

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

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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26