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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26