Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.mapcontext / org.gvsig.fmap.mapcontext.api / src / main / java / org / gvsig / fmap / mapcontext / MapContextManager.java @ 41347

History | View | Annotate | Download (14.6 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
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2009 {DiSiD Technologies}  {Create Manager to register MapContextDrawer implementation}
27
 */
28
package org.gvsig.fmap.mapcontext;
29

    
30
import java.awt.Color;
31
import java.awt.Font;
32
import java.io.File;
33
import java.util.List;
34

    
35
import org.cresques.cts.IProjection;
36

    
37
import org.gvsig.fmap.dal.DataStore;
38
import org.gvsig.fmap.dal.DataStoreParameters;
39
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
40
import org.gvsig.fmap.mapcontext.layers.FLayer;
41
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer;
42
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
43
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
44
import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendReader;
45
import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendWriter;
46
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingStrategy;
47
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol;
48
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
49
import org.gvsig.fmap.mapcontext.rendering.symbols.IWarningSymbol;
50
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
51
import org.gvsig.tools.observer.Observable;
52

    
53
/**
54
 * Manager of the MapContext library.
55
 * 
56
 * Holds the default implementation of the {@link MapContextDrawer}.
57
 * 
58
 * @author <a href="mailto:cordinyana@gvsig.org">C?sar Ordi?ana</a>
59
 * @author <a href="mailto:jjdelcerro@gvsig.org">Joaquin Jose del Cerro</a>
60
 */
61
public interface MapContextManager extends Observable {
62

    
63
        public static final String GET_DEFAULT_CRS = "MAPCONTEXTMANAGER_GET_DEFAULT_CRS";
64
        public static final String CREATE_LEGEND = "MAPCONTEXTMANAGER_CREATE_LEGEND";
65
        public static final String CREATE_MAPCONTEXT_DRAWER = "MAPCONTEXTMANAGER_CREATE_MAPCONTEXT_DRAWER";
66
        public static final String SET_MAPCONTEXT_DRAWER = "MAPCONTEXTMANAGER_SET_MAPCONTEXT_DRAWER";
67
        public static final String CREATE_GRAPHICS_LAYER = "MAPCONTEXTMANAGER_CREATE_GRAPHICS_LAYER";
68
        public static final String REGISTER_LEGEND = "MAPCONTEXTMANAGER_REGISTER_LEGEND";
69
        public static final String REGISTER_LEGEND_READER = "MAPCONTEXTMANAGER_REGISTER_LEGEND_READER";
70
        public static final String CREATE_LEGEND_READER = "MAPCONTEXTMANAGER_CREATE_LEGEND_READER";
71
        public static final String REGISTER_LEGEND_WRITER = "MAPCONTEXTMANAGER_REGISTER_LEGEND_WRITER";
72
        public static final String CREATE_SYMBOL = "MAPCONTEXTMANAGER_CREATE_SYMBOL";
73
        public static final String LOAD_SYMBOLS = "MAPCONTEXTMANAGER_LOAD_SYMBOLS";
74
        public static final String REGISTER_MULTILAYER_SYMBOL = "MAPCONTEXTMANAGER_REGISTER_MULTILAYER_SYMBOL";
75
        public static final String REGISTER_SYMBOL = "MAPCONTEXTMANAGER_REGISTER_SYMBOL";
76
        public static final String CREATE_LAYER = "MAPCONTEXTMANAGER_CREATE_LAYER";
77
        public static final String LOAD_LAYER = "MAPCONTEXTMANAGER_LOAD_LAYER";
78
        public static final String REGISTER_ICON_LAYER = "MAPCONTEXTMANAGER_REGISTER_ICON_LAYER";
79
        public static final String CREATE_MAPCONTEXT = "MAPCONTEXTMANAGER_CREATE_MAPCONTEXT";
80
        public static final String LOAD_MAPCONTEXT = "MAPCONTEXTMANAGER_LOAD_MAPCONTEXT";
81

    
82

    
83
        public MapContext createMapContext();
84
        
85
        /**
86
         * Create a new layer from the data parameters passed as parameter.
87
         * 
88
         * @param layerName name used in for the new layer. 
89
         * @param parameters used for create the {@link DataStore} of the new layer
90
         * 
91
         * @return the new FLayer
92
         * 
93
         * @throws LoadLayerException
94
         */
95
        public FLayer createLayer(String layerName,
96
                        DataStoreParameters parameters) throws LoadLayerException;
97

    
98
        /**
99
         * Create a layer from a {@link DataStore}.
100
         * 
101
         * @param layerName name used in for the new layer. 
102
         * @param store used for the new layer
103
         * 
104
         * @return the new FLayer
105
         * 
106
         * @throws LoadLayerException
107
         */
108
        public FLayer createLayer(String layerName, DataStore store)
109
                        throws LoadLayerException;
110

    
111
        /**
112
         * Create a layer to be used as the {@link GraphicLayer}.
113
         * 
114
         * @param projection used in the layer.
115
         * 
116
         * @return the new {@link GraphicLayer}.
117
         */
118
        public GraphicLayer createGraphicsLayer(IProjection projection);
119

    
120
        /**
121
         * Returns the current {@link SymbolManager}.
122
         * 
123
         * @return the {@link SymbolManager}
124
         */
125
        SymbolManager getSymbolManager();
126

    
127
        /**
128
         * Sets the class to use as the default implementation for the
129
         * {@link MapContextDrawer}.
130
         * 
131
         * @param drawerClazz
132
         *            the {@link MapContextDrawer} class to use
133
         * @throws MapContextException
134
         *             if there is any error setting the class
135
         */
136
        public void setDefaultMapContextDrawer(Class drawerClazz)
137
                        throws MapContextException;
138

    
139
        public void validateMapContextDrawer(Class drawerClazz) throws MapContextException;
140

    
141
        /**
142
         * Creates a new instance of the default {@link MapContextDrawer}
143
         * implementation.
144
         * 
145
         * @return the new {@link MapContextDrawer} instance
146
         * @throws MapContextException
147
         *             if there is an error creating the new object instance
148
         */
149
        public MapContextDrawer createDefaultMapContextDrawerInstance()
150
                        throws MapContextException;
151

    
152
        /**
153
         * Creates a new instance of the provided {@link MapContextDrawer}
154
         * implementation.
155
         * 
156
         * @param drawerClazz
157
         *            the {@link MapContextDrawer} implementation class
158
         * @return the new {@link MapContextDrawer} instance
159
         * @throws MapContextException
160
         *             if there is an error creating the new object instance
161
         */
162
        public MapContextDrawer createMapContextDrawerInstance(Class drawerClazz)
163
                        throws MapContextException;
164

    
165
        
166
        
167
        void registerLegend(String legendName, Class legendClass)
168
                        throws MapContextRuntimeException;
169

    
170
        ILegend createLegend(String legendName) throws MapContextRuntimeException;
171

    
172
        void setDefaultVectorLegend(String legendName);
173

    
174
        IVectorLegend createDefaultVectorLegend(int shapeType)
175
                        throws MapContextRuntimeException;
176

    
177
    // ================================================================
178
        // = Legend reading/writing (GVSLEG, SLD, etc)
179
        
180
        /**
181
         * Registers legend writer.
182
     * Format is a MIME type string. Examples:
183
         * 
184
         * "application/zip; subtype=gvsleg",
185
     * "text/xml; subtype=sld/1.0.0",
186
     * "text/xml; subtype=sld/1.1.0",
187
         * 
188
         * @param legendClass Legend class
189
         * @param format File type in mime format.
190
         * @param writerClass Class object of the writer
191
         * @throws MapContextRuntimeException
192
         */
193
        void registerLegendWriter(Class legendClass, String format,
194
                        Class writerClass) throws MapContextRuntimeException;
195

    
196
        /**
197
         * 
198
     * Registers legend reader.
199
     * Format is a MIME type string. Examples:
200
     * 
201
     * "application/zip; subtype=gvsleg",
202
     * "text/xml; subtype=sld/1.0.0",
203
     * "text/xml; subtype=sld/1.1.0",
204
         * 
205
         * @param format
206
         * @param readerClass
207
         * @throws MapContextRuntimeException
208
         */
209
        void registerLegendReader(String format, Class readerClass)
210
                        throws MapContextRuntimeException;
211

    
212
        /**
213
         * Creates a legend writer for the specified legend class
214
         * 
215
         */
216
        ILegendWriter createLegendWriter(Class legendClass, String format)
217
                        throws MapContextException;
218

    
219
        /**
220
         * Creates a legend reader for the given format
221
         * ("sld", "gvsleg", etc are extracted from the MIME long string)
222
         */
223
        ILegendReader createLegendReader(String format)
224
                        throws MapContextRuntimeException;
225
        
226
        /**
227
         * 
228
     * Format is a MIME type string. Examples:
229
     * 
230
     * "application/zip; subtype=gvsleg",
231
     * "text/xml; subtype=sld/1.0.0",
232
     * "text/xml; subtype=sld/1.1.0",
233
         * 
234
         * @return A list of Strings with the available formats for reading
235
         * legends
236
         */
237
        List getLegendReadingFormats();
238

    
239
        /**
240
         * 
241
     * Format is a MIME type string. Examples:
242
     * 
243
     * "application/zip; subtype=gvsleg",
244
     * "text/xml; subtype=sld/1.0.0",
245
     * "text/xml; subtype=sld/1.1.0",
246
         * 
247
         * @return A list of Strings with the available formats for writing
248
         * legends
249
         */
250
        List getLegendWritingFormats();
251

    
252
        
253
    // ================================================================
254

    
255
        /**
256
         * @deprecated to be removed in gvSIG 2.0
257
         * @see {@link SymbolPreferences}.
258
         */
259
        int getDefaultCartographicSupportMeasureUnit();
260

    
261
        /**
262
         * @deprecated to be removed in gvSIG 2.0
263
         * @see {@link SymbolPreferences}.
264
         */
265
        void setDefaultCartographicSupportMeasureUnit(
266
                        int defaultCartographicSupportMeasureUnit);
267

    
268
        /**
269
         * @deprecated to be removed in gvSIG 2.0
270
         * @see {@link SymbolPreferences}.
271
         */
272
        int getDefaultCartographicSupportReferenceSystem();
273

    
274
        /**
275
         * @deprecated to be removed in gvSIG 2.0
276
         * @see {@link SymbolPreferences}.
277
         */
278
        void setDefaultCartographicSupportReferenceSystem(
279
                        int defaultCartographicSupportReferenceSystem);
280

    
281
        /**
282
         * @deprecated to be removed in gvSIG 2.0
283
         * @see {@link SymbolPreferences}.
284
         */
285
        Color getDefaultSymbolColor();
286

    
287
        /**
288
         * @deprecated to be removed in gvSIG 2.0
289
         * @see {@link SymbolPreferences}.
290
         */
291
        void setDefaultSymbolColor(Color defaultSymbolColor);
292

    
293
        /**
294
         * @deprecated to be removed in gvSIG 2.0
295
         * @see {@link SymbolPreferences}.
296
         */
297
        void resetDefaultSymbolColor();
298

    
299
        /**
300
         * @deprecated to be removed in gvSIG 2.0
301
         * @see {@link SymbolPreferences}.
302
         */
303
        Color getDefaultSymbolFillColor();
304

    
305
        /**
306
         * @deprecated to be removed in gvSIG 2.0
307
         * @see {@link SymbolPreferences}.
308
         */
309
        void setDefaultSymbolFillColor(Color defaultSymbolFillColor);
310

    
311
        /**
312
         * @deprecated to be removed in gvSIG 2.0
313
         * @see {@link SymbolPreferences}.
314
         */
315
        void resetDefaultSymbolFillColor();
316

    
317
        /**
318
         * @deprecated to be removed in gvSIG 2.0
319
         * @see {@link SymbolPreferences}.
320
         */
321
        boolean isDefaultSymbolFillColorAleatory();
322

    
323
        /**
324
         * @deprecated to be removed in gvSIG 2.0
325
         * @see {@link SymbolPreferences}.
326
         */
327
        void setDefaultSymbolFillColorAleatory(
328
                        boolean defaultSymbolFillColorAleatory);
329

    
330
        /**
331
         * @deprecated to be removed in gvSIG 2.0
332
         * @see {@link SymbolPreferences}.
333
         */
334
        void resetDefaultSymbolFillColorAleatory();
335

    
336
        /**
337
         * @deprecated to be removed in gvSIG 2.0
338
         * @see {@link SymbolPreferences}.
339
         */
340
        Font getDefaultSymbolFont();
341

    
342
        /**
343
         * @deprecated to be removed in gvSIG 2.0
344
         * @see {@link SymbolPreferences}.
345
         */
346
        void setDefaultSymbolFont(Font defaultSymbolFont);
347

    
348
        /**
349
         * @deprecated to be removed in gvSIG 2.0
350
         * @see {@link SymbolPreferences}.
351
         */
352
        void resetDefaultSymbolFont();
353

    
354
        /**
355
         * @deprecated to be removed in gvSIG 2.0
356
         * @see {@link SymbolPreferences}.
357
         */
358
        String getSymbolLibraryPath();
359

    
360
        /**
361
         * @deprecated to be removed in gvSIG 2.0
362
         * @see {@link SymbolPreferences}.
363
         */
364
        void setSymbolLibraryPath(String symbolLibraryPath);
365

    
366
        /**
367
         * @deprecated to be removed in gvSIG 2.0
368
         * @see {@link SymbolPreferences}.
369
         */
370
        void resetSymbolLibraryPath();
371
        
372
        
373
        /**
374
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
375
         */
376
        ISymbol createSymbol(String symbolName) throws MapContextRuntimeException;
377

    
378
        /**
379
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
380
         */
381
        ISymbol createSymbol(int shapeType) throws MapContextRuntimeException;
382

    
383
        /**
384
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
385
         */
386
        ISymbol createSymbol(String symbolName, Color color)
387
                        throws MapContextRuntimeException;
388

    
389
        /**
390
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
391
         */
392
        ISymbol createSymbol(int shapeType, Color color)
393
                        throws MapContextRuntimeException;
394

    
395
        /**
396
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
397
         */
398
        IMultiLayerSymbol createMultiLayerSymbol(String symbolName)
399
                        throws MapContextRuntimeException;
400

    
401
        /**
402
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
403
         */
404
        IMultiLayerSymbol createMultiLayerSymbol(int shapeType)
405
                        throws MapContextRuntimeException;
406

    
407
        /**
408
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
409
         */
410
        void registerSymbol(String symbolName, Class symbolClass)
411
                        throws MapContextRuntimeException;
412

    
413
        /**
414
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
415
         */
416
        void registerSymbol(String symbolName, int[] shapeTypes, Class symbolClass)
417
                        throws MapContextException;
418

    
419
        /**
420
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
421
         */
422
        void registerMultiLayerSymbol(String symbolName, Class symbolClass)
423
                        throws MapContextRuntimeException;
424

    
425
        /**
426
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
427
         */
428
        void registerMultiLayerSymbol(String symbolName, int[] shapeTypes,
429
                        Class symbolClass) throws MapContextRuntimeException;
430

    
431
        /**
432
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
433
         */
434
        IWarningSymbol getWarningSymbol(String message, String symbolDesc,
435
                        int symbolDrawExceptionType) throws MapContextRuntimeException;
436
        
437
        /**
438
         * It returns the legend associated with a {@link DataStore}.
439
         * If the legend doesn't exist it returns <code>null</code>.
440
         * @param dataStore
441
         * the store that could have a legend.
442
         * @return
443
         * the legend or <code>null</code>.
444
         */
445
        ILegend getLegend(DataStore dataStore);        
446
        
447
        /**
448
     * It returns the labeling strategy associated with a {@link DataStore}.
449
     * If the labeling strategy doesn't exist it returns <code>null</code>.
450
     * @param dataStore
451
     * the store that could have a labeling strategy.
452
     * @return
453
     * the labeling strategy or <code>null</code>.
454
     */
455
        ILabelingStrategy getLabelingStrategy(DataStore dataStore);
456

    
457

    
458
        void registerIconLayer(String store, String iconName);
459
        
460
        String getIconLayer(DataStore store);
461
        
462
    // TODO:
463
    // DynObjectModel getFeatureTypeUIModel(DataStore store,
464
    // FeatureType featureType);
465
        
466
        /**
467
         * Returns the default CRS.
468
         * This is NOT taken from the app
469
         * preferences because this is a library. It is a
470
         * "hard-coded" default CRS, used as a last resort.
471
         * @return the default CRS
472
         */
473
        IProjection getDefaultCRS();
474
        
475
        public File getColorTableLibraryFolder();
476
        
477
        public void setColorTableLibraryFolder(File colorTableLibraryFolder);
478
        
479
}