1 |
alfonx |
244 |
/******************************************************************************* |
2 |
|
|
* Copyright (c) 2009 Martin O. J. Schmitz. |
3 |
|
|
* |
4 |
|
|
* This file is part of the SCHMITZM library - a collection of utility |
5 |
alfonx |
256 |
* classes based on Java 1.6, focusing (not only) on Java Swing |
6 |
alfonx |
244 |
* and the Geotools library. |
7 |
|
|
* |
8 |
|
|
* The SCHMITZM project is hosted at: |
9 |
|
|
* http://wald.intevation.org/projects/schmitzm/ |
10 |
|
|
* |
11 |
|
|
* This program is free software; you can redistribute it and/or |
12 |
|
|
* modify it under the terms of the GNU Lesser General Public License |
13 |
|
|
* as published by the Free Software Foundation; either version 3 |
14 |
|
|
* of the License, or (at your option) any later version. |
15 |
|
|
* |
16 |
|
|
* This program is distributed in the hope that it will be useful, |
17 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 |
|
|
* GNU General Public License for more details. |
20 |
|
|
* |
21 |
|
|
* You should have received a copy of the GNU Lesser General Public License (license.txt) |
22 |
|
|
* along with this program; if not, write to the Free Software |
23 |
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
|
|
* or try this link: http://www.gnu.org/licenses/lgpl.html |
25 |
|
|
* |
26 |
|
|
* Contributors: |
27 |
|
|
* Martin O. J. Schmitz - initial API and implementation |
28 |
alfonx |
862 |
* Stefan A. Tzeggai - additional utility classes |
29 |
alfonx |
244 |
******************************************************************************/ |
30 |
|
|
package skrueger.geotools; |
31 |
|
|
|
32 |
|
|
import java.net.URL; |
33 |
|
|
|
34 |
|
|
import javax.swing.ImageIcon; |
35 |
|
|
|
36 |
|
|
import org.geotools.feature.FeatureCollection; |
37 |
alfonx |
1203 |
import org.geotools.geometry.jts.ReferencedEnvelope; |
38 |
alfonx |
244 |
import org.geotools.styling.Style; |
39 |
|
|
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
40 |
|
|
|
41 |
alfonx |
769 |
import skrueger.AttributeMetadataImpl; |
42 |
alfonx |
244 |
import skrueger.RasterLegendData; |
43 |
|
|
import skrueger.i8n.Translation; |
44 |
|
|
|
45 |
|
|
import com.vividsolutions.jts.geom.Envelope; |
46 |
|
|
|
47 |
|
|
/** |
48 |
|
|
* This class is the top interface for styled objects to be managed in |
49 |
|
|
* {@link MapContextManagerInterface}. The (rough) classe structure is the |
50 |
|
|
* following: |
51 |
|
|
* <ul> |
52 |
|
|
* <li><b>{@link StyledLayerInterface StyledLayerInterface<E>}</b> |
53 |
|
|
* <ul> |
54 |
|
|
* <li>{@link #getId()} -> String</li> |
55 |
|
|
* <li>{@link #getKeywords() get/setKeywords()} -> {@link Translation}</li> |
56 |
|
|
* <li>{@link #getTitle() set/getTitle()} -> {@link Translation} (short |
57 |
|
|
* description for layer list)</li> |
58 |
|
|
* <li>{@link #getDesc() set/getDesc()} -> {@link Translation} (long description |
59 |
|
|
* for details)</li> |
60 |
|
|
* <li>{@link #getCrs()} -> {@link CoordinateReferenceSystem}</li> |
61 |
|
|
* <li>{@link #getCRSString()} -> String (readable description of CRS)</li> |
62 |
|
|
* <li>{@link #getEnvelope()} -> {@link Envelope} (JTS-Envelope)</li> |
63 |
|
|
* <li>{@link #getGeoObject()} -> E (GridCoverage/FeatureCollection/...)</li> |
64 |
|
|
* <li>{@link #getStyle() set/getStyle()} -> {@link Style}</li> |
65 |
|
|
* <li>{@link #uncache()}</li> |
66 |
|
|
* <li>{@link #dispose()}</li> |
67 |
|
|
* </ul> |
68 |
|
|
* </li> |
69 |
|
|
* <li><b>{@link StyledFeatureCollectionInterface} extends |
70 |
|
|
* {@link StyledLayerInterface StyledLayerInterface<FeatureCollection>}</b> |
71 |
|
|
* <ul> |
72 |
|
|
* <li>{@link StyledFeatureCollectionInterface#getAttributeMetaDataMap()} -> |
73 |
|
|
* Map<Integer,AttributeMetaData></li> |
74 |
|
|
* </ul> |
75 |
|
|
* </li> |
76 |
|
|
* <li><b>{@link StyledRasterInterface} extends {@link StyledLayerInterface |
77 |
|
|
* StyledLayerInterface<GridCoverage2D>}</b> |
78 |
|
|
* <ul> |
79 |
|
|
* <li>{@link StyledRasterInterface#getLegendMetaData()} -> |
80 |
|
|
* {@link RasterLegendData}</li> |
81 |
|
|
* </ul> |
82 |
|
|
* </li> |
83 |
|
|
* </ul> |
84 |
|
|
* <br> |
85 |
|
|
* <b>Restrictions:</b> |
86 |
|
|
* <ul> |
87 |
|
|
* <li>layer list only depends on {@link StyledLayerInterface}</li> |
88 |
|
|
* <li>methods returning {@link Translation} must not return {@code null}</li> |
89 |
alfonx |
769 |
* <li>methods returning {@link AttributeMetadataImpl}-Map must not return {@code |
90 |
alfonx |
244 |
* null}</li> |
91 |
alfonx |
769 |
* <li>static helper method to get a new {@link AttributeMetadataImpl}-map withe the |
92 |
alfonx |
244 |
* visible attributes only</li> |
93 |
alfonx |
769 |
* <li>static helper method to create a "default" {@link AttributeMetadataImpl}-map |
94 |
alfonx |
244 |
* for a {@link FeatureCollection} with all attributes visible and without real |
95 |
|
|
* translations, but the attribute name as description.</li> |
96 |
|
|
* </ul> |
97 |
|
|
*/ |
98 |
|
|
public interface StyledLayerInterface<E> { |
99 |
|
|
public String getId(); |
100 |
|
|
|
101 |
|
|
public Translation getTitle(); |
102 |
|
|
|
103 |
|
|
public void setTitle(Translation title); |
104 |
|
|
|
105 |
|
|
public Translation getDesc(); |
106 |
|
|
|
107 |
|
|
public void setDesc(Translation dec); |
108 |
|
|
|
109 |
|
|
public Translation getKeywords(); |
110 |
|
|
|
111 |
|
|
public void setKeywords(Translation keywords); |
112 |
|
|
|
113 |
|
|
public CoordinateReferenceSystem getCrs(); |
114 |
|
|
|
115 |
|
|
public String getCRSString(); |
116 |
|
|
|
117 |
|
|
public Envelope getEnvelope(); |
118 |
|
|
|
119 |
|
|
/** |
120 |
alfonx |
1203 |
* @return <code>null</code> is no CRS is available |
121 |
|
|
*/ |
122 |
|
|
public ReferencedEnvelope getReferencedEnvelope(); |
123 |
|
|
|
124 |
|
|
|
125 |
|
|
/** |
126 |
alfonx |
244 |
* @return return an ImageIcon - <code>null</code> is valid and no icon or a |
127 |
|
|
* default icon will then be shown |
128 |
|
|
*/ |
129 |
|
|
public ImageIcon getImageIcon(); |
130 |
|
|
|
131 |
|
|
public void setImageIcon(ImageIcon icon); |
132 |
|
|
|
133 |
|
|
/** |
134 |
|
|
* Returns the underlying GeoTools Object |
135 |
|
|
* |
136 |
|
|
* @throws RuntimeException |
137 |
|
|
*/ |
138 |
|
|
public E getGeoObject(); |
139 |
|
|
|
140 |
|
|
public Style getStyle(); |
141 |
|
|
|
142 |
|
|
public void setStyle(Style style); |
143 |
|
|
|
144 |
|
|
/** |
145 |
|
|
* Returns the {@link URL} to a (HTML) file that provides more information |
146 |
|
|
* about this layer. If no HTML if associated with this |
147 |
|
|
* {@link StyledLayerInterface}, then <code>null</code> will be returned. |
148 |
|
|
* |
149 |
|
|
* @return null or an {@link URL} |
150 |
|
|
*/ |
151 |
|
|
public URL getInfoURL(); |
152 |
alfonx |
615 |
|
153 |
alfonx |
244 |
/** |
154 |
|
|
* Should be called when this Object is not needed anymore. |
155 |
|
|
*/ |
156 |
|
|
public void dispose(); |
157 |
|
|
|
158 |
|
|
/** Is the object already disposed? * */ |
159 |
|
|
public boolean isDisposed(); |
160 |
|
|
|
161 |
|
|
/** |
162 |
|
|
* Clears any caches. For example the GeoObject could be released, and |
163 |
|
|
* reread on next call of getGeoObject() |
164 |
|
|
*/ |
165 |
|
|
public void uncache(); |
166 |
alfonx |
1159 |
// public String getLegendHtml(); |
167 |
alfonx |
244 |
} |