svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.symbology / org.gvsig.symbology.lib / org.gvsig.symbology.lib.impl / src / main / java / org / gvsig / symbology / impl / DefaultSymbologyManager.java @ 43599
History | View | Annotate | Download (10.4 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
/* gvSIG. Geographic Information System of the Valencian Government
|
25 |
*
|
26 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
27 |
* of the Valencian Government (CIT)
|
28 |
*
|
29 |
* This program is free software; you can redistribute it and/or
|
30 |
* modify it under the terms of the GNU General Public License
|
31 |
* as published by the Free Software Foundation; either version 3
|
32 |
* of the License, or (at your option) any later version.
|
33 |
*
|
34 |
* This program is distributed in the hope that it will be useful,
|
35 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
36 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
37 |
* GNU General Public License for more details.
|
38 |
*
|
39 |
* You should have received a copy of the GNU General Public License
|
40 |
* along with this program; if not, write to the Free Software
|
41 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
42 |
* MA 02110-1301, USA.
|
43 |
*
|
44 |
*/
|
45 |
|
46 |
package org.gvsig.symbology.impl; |
47 |
|
48 |
import java.awt.Shape; |
49 |
import java.io.IOException; |
50 |
import java.net.URL; |
51 |
import java.util.Collection; |
52 |
import java.util.Collections; |
53 |
import java.util.HashMap; |
54 |
import java.util.Map; |
55 |
|
56 |
import org.apache.batik.ext.awt.geom.DefaultPathLength; |
57 |
|
58 |
import org.gvsig.fmap.mapcontext.rendering.legend.IInterval; |
59 |
import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendWriter; |
60 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelClass; |
61 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelClassFactory; |
62 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingMethod; |
63 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingStrategy; |
64 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.IZoomConstraints; |
65 |
import org.gvsig.fmap.mapcontext.rendering.symbols.styles.IBackgroundFileStyle; |
66 |
import org.gvsig.fmap.mapcontext.rendering.symbols.styles.ILabelStyle; |
67 |
import org.gvsig.symbology.PathLength; |
68 |
import org.gvsig.symbology.SymbologyLocator; |
69 |
import org.gvsig.symbology.SymbologyManager; |
70 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.driver.impl.PersistenceBasedLegendWriter; |
71 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.FInterval; |
72 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy; |
73 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.DefaultLabelingMethod; |
74 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.IAttrInTableLabelingStrategy; |
75 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.ZoomConstraintsImpl; |
76 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.IMultiShapeSymbol; |
77 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IMarkerFillSymbol; |
78 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IPictureFillSymbol; |
79 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.ISimpleFillSymbol; |
80 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.MarkerFillSymbol; |
81 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.PictureFillSymbol; |
82 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.SimpleFillSymbol; |
83 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.MultiShapeSymbol; |
84 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.IPictureLineSymbol; |
85 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ISimpleLineSymbol; |
86 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.impl.PictureLineSymbol; |
87 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.impl.SimpleLineSymbol; |
88 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IPictureMarkerSymbol; |
89 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.ISimpleMarkerSymbol; |
90 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.PictureMarkerSymbol; |
91 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.SimpleMarkerSymbol; |
92 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ArrowDecoratorStyle; |
93 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.BackgroundFileStyle; |
94 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.DefaultMask; |
95 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IArrowDecoratorStyle; |
96 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IMarkerFillPropertiesStyle; |
97 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IMask; |
98 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ISimpleLineStyle; |
99 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SimpleLabelStyle; |
100 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SimpleLineStyle; |
101 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SimpleMarkerFillPropertiesStyle; |
102 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.ISimpleTextSymbol; |
103 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.impl.SimpleTextSymbol; |
104 |
import org.gvsig.tools.util.Callable; |
105 |
|
106 |
/**
|
107 |
* Default {@link SymbologyManager} implementation.
|
108 |
*
|
109 |
* @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
|
110 |
*/
|
111 |
public class DefaultSymbologyManager implements SymbologyManager { |
112 |
|
113 |
private Map labelClassFactories = new HashMap(); |
114 |
private ILabelClassFactory defaultLabelClassFactory;
|
115 |
|
116 |
public IInterval createInterval(double min, double max) { |
117 |
return new FInterval(min, max); |
118 |
} |
119 |
|
120 |
public static class RegisterSymbologyManager implements Callable { |
121 |
|
122 |
public Object call() throws Exception { |
123 |
|
124 |
SymbologyLocator.registerSymbologyManager(DefaultSymbologyManager.class); |
125 |
|
126 |
return Boolean.TRUE; |
127 |
} |
128 |
|
129 |
} |
130 |
|
131 |
public IArrowDecoratorStyle createArrowDecoratorStyle() {
|
132 |
return new ArrowDecoratorStyle(); |
133 |
} |
134 |
|
135 |
// public IMarkerSymbol createMarkerSymbol(){
|
136 |
// return new SimpleMarkerSymbol();
|
137 |
// }
|
138 |
|
139 |
public ISimpleMarkerSymbol createSimpleMarkerSymbol() {
|
140 |
return new SimpleMarkerSymbol(); |
141 |
} |
142 |
|
143 |
public IMask createMask() {
|
144 |
return new DefaultMask(); |
145 |
} |
146 |
|
147 |
public IMultiShapeSymbol createMultiShapeSymbol() {
|
148 |
return new MultiShapeSymbol(); |
149 |
} |
150 |
|
151 |
public ISimpleFillSymbol createSimpleFillSymbol() {
|
152 |
return new SimpleFillSymbol(); |
153 |
} |
154 |
|
155 |
public ISimpleLineSymbol createSimpleLineSymbol() {
|
156 |
return new SimpleLineSymbol(); |
157 |
} |
158 |
|
159 |
public ISimpleLineStyle createSimpleLineStyle() {
|
160 |
return new SimpleLineStyle(); |
161 |
} |
162 |
|
163 |
public IBackgroundFileStyle createBackgroundFileStyle(URL imgURL) |
164 |
throws IOException { |
165 |
return BackgroundFileStyle.createStyleByURL(imgURL);
|
166 |
} |
167 |
|
168 |
public ISimpleTextSymbol createSimpleTextSymbol() {
|
169 |
return new SimpleTextSymbol(); |
170 |
} |
171 |
|
172 |
public IMarkerFillPropertiesStyle createSimpleMarkerFillPropertiesStyle() {
|
173 |
return new SimpleMarkerFillPropertiesStyle(); |
174 |
} |
175 |
|
176 |
public IPictureFillSymbol createPictureFillSymbol(URL imageURL, |
177 |
URL selImageURL) throws IOException { |
178 |
return new PictureFillSymbol(imageURL, selImageURL); |
179 |
} |
180 |
|
181 |
public IPictureLineSymbol createPictureLineSymbol(URL imageURL, |
182 |
URL selImageURL) throws IOException { |
183 |
return new PictureLineSymbol(imageURL, selImageURL); |
184 |
} |
185 |
|
186 |
public IPictureMarkerSymbol createPictureMarkerSymbol(URL imageURL, |
187 |
URL selImageURL) throws IOException { |
188 |
return new PictureMarkerSymbol(imageURL, selImageURL); |
189 |
|
190 |
} |
191 |
|
192 |
public IMarkerFillSymbol createMarkerFillSymbol() {
|
193 |
return new MarkerFillSymbol(); |
194 |
} |
195 |
|
196 |
public IAttrInTableLabelingStrategy createAttrInTableLabelingStrategy() {
|
197 |
return new AttrInTableLabelingStrategy(); |
198 |
} |
199 |
|
200 |
public ILabelingStrategy createDefaultLabelingStrategy() {
|
201 |
return new AttrInTableLabelingStrategy(); |
202 |
} |
203 |
|
204 |
public ILabelingMethod createDefaultLabelingMethod() {
|
205 |
return new DefaultLabelingMethod(); |
206 |
} |
207 |
|
208 |
public IZoomConstraints createDefaultZoomConstraints() {
|
209 |
return new ZoomConstraintsImpl(); |
210 |
} |
211 |
|
212 |
public ILabelStyle createDefaultLabelStyle() {
|
213 |
return new SimpleLabelStyle(); |
214 |
} |
215 |
|
216 |
public void registerLabelClass(ILabelClassFactory factory) { |
217 |
this.labelClassFactories.put(factory.getID().toLowerCase(), factory);
|
218 |
if( this.defaultLabelClassFactory==null ) { |
219 |
this.defaultLabelClassFactory = factory;
|
220 |
} |
221 |
} |
222 |
|
223 |
public Collection<ILabelClassFactory> getLabelClassFactories() { |
224 |
return Collections.unmodifiableCollection(this.labelClassFactories.values()); |
225 |
} |
226 |
|
227 |
public ILabelClassFactory getLabelClassFactory(String id) { |
228 |
if( id==null ) { |
229 |
return null; |
230 |
} |
231 |
return (ILabelClassFactory) this.labelClassFactories.get(id.toLowerCase()); |
232 |
} |
233 |
|
234 |
public ILabelClass createDefaultLabel() {
|
235 |
ILabelClassFactory f = this.getDefaultLabelFactory();
|
236 |
if( f==null ) { |
237 |
return null; |
238 |
} |
239 |
return f.create();
|
240 |
} |
241 |
|
242 |
public ILabelClassFactory getDefaultLabelFactory() {
|
243 |
return this.defaultLabelClassFactory; |
244 |
} |
245 |
|
246 |
public void setDefaultLabelFactory(String id) { |
247 |
ILabelClassFactory f = this.getLabelClassFactory(id);
|
248 |
if( f==null ) { |
249 |
throw new IllegalArgumentException("factory id is null"); |
250 |
} |
251 |
this.setDefaultLabelFactory(f);
|
252 |
} |
253 |
|
254 |
public void setDefaultLabelFactory(ILabelClassFactory factory) { |
255 |
if( !this.labelClassFactories.containsValue(factory) ) { |
256 |
this.labelClassFactories.put(factory.getID().toLowerCase(), factory);
|
257 |
} |
258 |
this.defaultLabelClassFactory = factory;
|
259 |
} |
260 |
|
261 |
@Override
|
262 |
public PathLength createPathLength(Shape path) { |
263 |
return new DefaultPathLength(path); |
264 |
} |
265 |
|
266 |
public ILegendWriter getDefaultLegendWriter() {
|
267 |
return new PersistenceBasedLegendWriter(); |
268 |
} |
269 |
|
270 |
|
271 |
|
272 |
} |