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 @ 45518
History | View | Annotate | Download (11.6 KB)
1 | 40560 | jjdelcerro | /**
|
---|---|---|---|
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 | 40435 | jjdelcerro | /* 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 | 43599 | fdiaz | *
|
29 | 40435 | jjdelcerro | * This program is free software; you can redistribute it and/or
|
30 | * modify it under the terms of the GNU General Public License
|
||
31 | 43326 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
32 | 40435 | jjdelcerro | * of the License, or (at your option) any later version.
|
33 | 43599 | fdiaz | *
|
34 | 40435 | jjdelcerro | * 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 | 43599 | fdiaz | *
|
39 | 40435 | jjdelcerro | * 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 | 43599 | fdiaz | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
42 | 40435 | jjdelcerro | * MA 02110-1301, USA.
|
43 | 43599 | fdiaz | *
|
44 | 40435 | jjdelcerro | */
|
45 | |||
46 | package org.gvsig.symbology.impl; |
||
47 | |||
48 | 43156 | jjdelcerro | import java.awt.Shape; |
49 | 40435 | jjdelcerro | import java.io.IOException; |
50 | import java.net.URL; |
||
51 | 41670 | jjdelcerro | import java.util.Collection; |
52 | import java.util.Collections; |
||
53 | import java.util.HashMap; |
||
54 | import java.util.Map; |
||
55 | 43599 | fdiaz | |
56 | 43156 | jjdelcerro | import org.apache.batik.ext.awt.geom.DefaultPathLength; |
57 | 40435 | jjdelcerro | |
58 | import org.gvsig.fmap.mapcontext.rendering.legend.IInterval; |
||
59 | 43599 | fdiaz | import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendWriter; |
60 | 40679 | jldominguez | import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelClass; |
61 | 41670 | jjdelcerro | import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelClassFactory; |
62 | 40679 | jldominguez | 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 | 40680 | jldominguez | import org.gvsig.fmap.mapcontext.rendering.symbols.styles.ILabelStyle; |
67 | 43156 | jjdelcerro | import org.gvsig.symbology.PathLength; |
68 | 40435 | jjdelcerro | import org.gvsig.symbology.SymbologyLocator; |
69 | import org.gvsig.symbology.SymbologyManager; |
||
70 | 44247 | omartinez | import org.gvsig.symbology.fmap.mapcontext.rendering.dynamiclegend.DefaultDynamicSymbol; |
71 | import org.gvsig.symbology.fmap.mapcontext.rendering.dynamiclegend.DefaultDynamicLabelingStrategy; |
||
72 | import org.gvsig.symbology.fmap.mapcontext.rendering.dynamiclegend.DefaultDynamicVectorLegend; |
||
73 | 44256 | omartinez | import org.gvsig.symbology.fmap.mapcontext.rendering.dynamiclegend.DynamicLabelingStrategy; |
74 | 44247 | omartinez | import org.gvsig.symbology.fmap.mapcontext.rendering.dynamiclegend.DynamicSymbol; |
75 | import org.gvsig.symbology.fmap.mapcontext.rendering.dynamiclegend.DynamicVectorLegend; |
||
76 | 43599 | fdiaz | import org.gvsig.symbology.fmap.mapcontext.rendering.legend.driver.impl.PersistenceBasedLegendWriter; |
77 | 40435 | jjdelcerro | import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.FInterval; |
78 | import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy; |
||
79 | 40679 | jldominguez | import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.DefaultLabelingMethod; |
80 | 40435 | jjdelcerro | import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.IAttrInTableLabelingStrategy; |
81 | 40679 | jldominguez | import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.ZoomConstraintsImpl; |
82 | 40435 | jjdelcerro | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.IMultiShapeSymbol; |
83 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IMarkerFillSymbol; |
||
84 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IPictureFillSymbol; |
||
85 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.ISimpleFillSymbol; |
||
86 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.MarkerFillSymbol; |
||
87 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.PictureFillSymbol; |
||
88 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.SimpleFillSymbol; |
||
89 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.MultiShapeSymbol; |
||
90 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.IPictureLineSymbol; |
||
91 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ISimpleLineSymbol; |
||
92 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.impl.PictureLineSymbol; |
||
93 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.impl.SimpleLineSymbol; |
||
94 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IPictureMarkerSymbol; |
||
95 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.ISimpleMarkerSymbol; |
||
96 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.PictureMarkerSymbol; |
||
97 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.SimpleMarkerSymbol; |
||
98 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ArrowDecoratorStyle; |
||
99 | 40679 | jldominguez | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.BackgroundFileStyle; |
100 | 40435 | jjdelcerro | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.DefaultMask; |
101 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IArrowDecoratorStyle; |
||
102 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IMarkerFillPropertiesStyle; |
||
103 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IMask; |
||
104 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ISimpleLineStyle; |
||
105 | 40680 | jldominguez | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SimpleLabelStyle; |
106 | 40435 | jjdelcerro | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SimpleLineStyle; |
107 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SimpleMarkerFillPropertiesStyle; |
||
108 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.ISimpleTextSymbol; |
||
109 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.impl.SimpleTextSymbol; |
||
110 | import org.gvsig.tools.util.Callable; |
||
111 | 44534 | omartinez | import org.gvsig.tools.util.Factory; |
112 | 40435 | jjdelcerro | |
113 | /**
|
||
114 | * Default {@link SymbologyManager} implementation.
|
||
115 | 43599 | fdiaz | *
|
116 | 40435 | jjdelcerro | * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
|
117 | */
|
||
118 | public class DefaultSymbologyManager implements SymbologyManager { |
||
119 | |||
120 | 41670 | jjdelcerro | private Map labelClassFactories = new HashMap(); |
121 | 44534 | omartinez | private Map<String, Factory> labelStrategyFactories = new HashMap<>(); |
122 | 41670 | jjdelcerro | private ILabelClassFactory defaultLabelClassFactory;
|
123 | 43599 | fdiaz | |
124 | 40435 | jjdelcerro | public IInterval createInterval(double min, double max) { |
125 | return new FInterval(min, max); |
||
126 | } |
||
127 | |||
128 | 44534 | omartinez | |
129 | @Override
|
||
130 | public void registerLabelingStrategy(Factory factory) { |
||
131 | labelStrategyFactories.put(factory.getName(), factory); |
||
132 | } |
||
133 | |||
134 | @Override
|
||
135 | public ILabelingStrategy createLabelingStrategy(String nameFactory, Object... parameters) { |
||
136 | Factory factory = labelStrategyFactories.get(nameFactory); |
||
137 | return (ILabelingStrategy) factory.create(parameters);
|
||
138 | } |
||
139 | |||
140 | 40435 | jjdelcerro | public static class RegisterSymbologyManager implements Callable { |
141 | |||
142 | public Object call() throws Exception { |
||
143 | |||
144 | SymbologyLocator.registerSymbologyManager(DefaultSymbologyManager.class); |
||
145 | 43599 | fdiaz | |
146 | 40435 | jjdelcerro | return Boolean.TRUE; |
147 | } |
||
148 | 43599 | fdiaz | |
149 | 40435 | jjdelcerro | } |
150 | 44247 | omartinez | |
151 | public DynamicLabelingStrategy createDynamicLabelingStrategy() {
|
||
152 | return new DefaultDynamicLabelingStrategy(); |
||
153 | } |
||
154 | |||
155 | 40435 | jjdelcerro | public IArrowDecoratorStyle createArrowDecoratorStyle() {
|
156 | return new ArrowDecoratorStyle(); |
||
157 | } |
||
158 | 43599 | fdiaz | |
159 | 40435 | jjdelcerro | // public IMarkerSymbol createMarkerSymbol(){
|
160 | // return new SimpleMarkerSymbol();
|
||
161 | // }
|
||
162 | |||
163 | public ISimpleMarkerSymbol createSimpleMarkerSymbol() {
|
||
164 | return new SimpleMarkerSymbol(); |
||
165 | } |
||
166 | |||
167 | public IMask createMask() {
|
||
168 | return new DefaultMask(); |
||
169 | } |
||
170 | |||
171 | public IMultiShapeSymbol createMultiShapeSymbol() {
|
||
172 | return new MultiShapeSymbol(); |
||
173 | } |
||
174 | |||
175 | public ISimpleFillSymbol createSimpleFillSymbol() {
|
||
176 | return new SimpleFillSymbol(); |
||
177 | } |
||
178 | |||
179 | public ISimpleLineSymbol createSimpleLineSymbol() {
|
||
180 | return new SimpleLineSymbol(); |
||
181 | } |
||
182 | |||
183 | public ISimpleLineStyle createSimpleLineStyle() {
|
||
184 | return new SimpleLineStyle(); |
||
185 | } |
||
186 | 43599 | fdiaz | |
187 | 40679 | jldominguez | public IBackgroundFileStyle createBackgroundFileStyle(URL imgURL) |
188 | throws IOException { |
||
189 | return BackgroundFileStyle.createStyleByURL(imgURL);
|
||
190 | } |
||
191 | 40435 | jjdelcerro | |
192 | public ISimpleTextSymbol createSimpleTextSymbol() {
|
||
193 | return new SimpleTextSymbol(); |
||
194 | } |
||
195 | |||
196 | public IMarkerFillPropertiesStyle createSimpleMarkerFillPropertiesStyle() {
|
||
197 | return new SimpleMarkerFillPropertiesStyle(); |
||
198 | } |
||
199 | |||
200 | public IPictureFillSymbol createPictureFillSymbol(URL imageURL, |
||
201 | URL selImageURL) throws IOException { |
||
202 | return new PictureFillSymbol(imageURL, selImageURL); |
||
203 | } |
||
204 | |||
205 | public IPictureLineSymbol createPictureLineSymbol(URL imageURL, |
||
206 | URL selImageURL) throws IOException { |
||
207 | return new PictureLineSymbol(imageURL, selImageURL); |
||
208 | } |
||
209 | |||
210 | public IPictureMarkerSymbol createPictureMarkerSymbol(URL imageURL, |
||
211 | URL selImageURL) throws IOException { |
||
212 | return new PictureMarkerSymbol(imageURL, selImageURL); |
||
213 | |||
214 | } |
||
215 | |||
216 | public IMarkerFillSymbol createMarkerFillSymbol() {
|
||
217 | return new MarkerFillSymbol(); |
||
218 | } |
||
219 | |||
220 | public IAttrInTableLabelingStrategy createAttrInTableLabelingStrategy() {
|
||
221 | return new AttrInTableLabelingStrategy(); |
||
222 | } |
||
223 | |||
224 | 40679 | jldominguez | public ILabelingStrategy createDefaultLabelingStrategy() {
|
225 | return new AttrInTableLabelingStrategy(); |
||
226 | } |
||
227 | 43599 | fdiaz | |
228 | 40679 | jldominguez | public ILabelingMethod createDefaultLabelingMethod() {
|
229 | return new DefaultLabelingMethod(); |
||
230 | } |
||
231 | 43599 | fdiaz | |
232 | 40679 | jldominguez | public IZoomConstraints createDefaultZoomConstraints() {
|
233 | return new ZoomConstraintsImpl(); |
||
234 | } |
||
235 | |||
236 | 40680 | jldominguez | public ILabelStyle createDefaultLabelStyle() {
|
237 | return new SimpleLabelStyle(); |
||
238 | } |
||
239 | 40679 | jldominguez | |
240 | 41670 | jjdelcerro | public void registerLabelClass(ILabelClassFactory factory) { |
241 | this.labelClassFactories.put(factory.getID().toLowerCase(), factory);
|
||
242 | if( this.defaultLabelClassFactory==null ) { |
||
243 | this.defaultLabelClassFactory = factory;
|
||
244 | } |
||
245 | } |
||
246 | 43599 | fdiaz | |
247 | 41670 | jjdelcerro | public Collection<ILabelClassFactory> getLabelClassFactories() { |
248 | return Collections.unmodifiableCollection(this.labelClassFactories.values()); |
||
249 | } |
||
250 | 43599 | fdiaz | |
251 | 41670 | jjdelcerro | public ILabelClassFactory getLabelClassFactory(String id) { |
252 | if( id==null ) { |
||
253 | return null; |
||
254 | } |
||
255 | return (ILabelClassFactory) this.labelClassFactories.get(id.toLowerCase()); |
||
256 | } |
||
257 | 43599 | fdiaz | |
258 | 41670 | jjdelcerro | public ILabelClass createDefaultLabel() {
|
259 | ILabelClassFactory f = this.getDefaultLabelFactory();
|
||
260 | if( f==null ) { |
||
261 | return null; |
||
262 | } |
||
263 | return f.create();
|
||
264 | } |
||
265 | 43599 | fdiaz | |
266 | 41670 | jjdelcerro | public ILabelClassFactory getDefaultLabelFactory() {
|
267 | return this.defaultLabelClassFactory; |
||
268 | } |
||
269 | 43599 | fdiaz | |
270 | 41670 | jjdelcerro | public void setDefaultLabelFactory(String id) { |
271 | ILabelClassFactory f = this.getLabelClassFactory(id);
|
||
272 | if( f==null ) { |
||
273 | throw new IllegalArgumentException("factory id is null"); |
||
274 | } |
||
275 | this.setDefaultLabelFactory(f);
|
||
276 | } |
||
277 | 43599 | fdiaz | |
278 | 41670 | jjdelcerro | public void setDefaultLabelFactory(ILabelClassFactory factory) { |
279 | if( !this.labelClassFactories.containsValue(factory) ) { |
||
280 | this.labelClassFactories.put(factory.getID().toLowerCase(), factory);
|
||
281 | } |
||
282 | this.defaultLabelClassFactory = factory;
|
||
283 | } |
||
284 | 43156 | jjdelcerro | |
285 | @Override
|
||
286 | public PathLength createPathLength(Shape path) { |
||
287 | return new DefaultPathLength(path); |
||
288 | } |
||
289 | 43599 | fdiaz | |
290 | public ILegendWriter getDefaultLegendWriter() {
|
||
291 | return new PersistenceBasedLegendWriter(); |
||
292 | } |
||
293 | |||
294 | 40435 | jjdelcerro | } |