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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 40 - (hide annotations)
Mon Apr 6 19:31:02 2009 UTC (15 years, 10 months ago) by alfonx
File size: 9120 byte(s)
* Layers can be marked as "hide In Legend" in the GP and will be hidden in the AV's legend

Das Interface StyledMapInterface.java hatte bisher eine abstrakte Methode isHideInLegend, die nie benutzt wurde. Ich habe die Idee jetzt im Atlas implementiert, und dann gemekert, dass nicht unbedingt eine Eigenschaft dieses Interfaces sein sollte.
Ein Layer soll nicht generell auf verstecken/nicht verstecken gestellt werden können. Das sind Eigenschaften der Karte/MapContext, ebenso wie die Reihenfolge der Layer. Im Atlas verwaltet deshalb nun die Klasse skrueger.atlas.Map welche Layer nicht in der Legende auftauchen sollen.  

Meines Wissens hat keiner bisher die Funktion genutzt.

Ich habe in allen allen Klassen welche StyledMapInterface implementieren die Funktion auskommentiert.

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 alfonx 40 /**
214     * If true, this layer will not be shown in the legend. Default = false
215     */
216     /**
217     *
218     * Killed by SK: 6. April 09: Ein Layer soll nicht generell auf
219     * verstecken/nicht verstecken gestellt werden können. Das sind
220     * Eigenschaften der Karte/MapContext, ebenso wie die Reihenfolge der Layer.
221     * Im Atlas verwaltet deshalb nun die Klasse skrueger.atlas.Map welche Layer
222     * nicht in der Legende auftauchen sollen. Meines Wissens hat keiner bisher
223     * die Funktion genutzt.
224     *
225 mojays 2 public boolean isHideInLegend() {
226     return false;
227     }
228 alfonx 40 */
229 mojays 2
230     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26