Statistics
| Revision:

svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.mapcontext / org.gvsig.fmap.mapcontext.api / src / main / java / org / gvsig / fmap / mapcontext / MapContextManager.java @ 43876

History | View | Annotate | Download (15.2 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.dal.raster.BandDescriptor;
40
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
41
import org.gvsig.fmap.mapcontext.layers.FLayer;
42
import org.gvsig.fmap.mapcontext.layers.LayerInformationBuilder;
43
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer;
44
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
45
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
46
import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendReader;
47
import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendWriter;
48
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingStrategy;
49
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol;
50
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
51
import org.gvsig.fmap.mapcontext.rendering.symbols.IWarningSymbol;
52
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
53
import org.gvsig.raster.lib.legend.api.RasterLegend;
54
import org.gvsig.tools.observer.Observable;
55

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

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

    
85

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

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

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

    
123
        /**
124
         * Returns the current {@link SymbolManager}.
125
         * 
126
         * @return the {@link SymbolManager}
127
         */
128
        SymbolManager getSymbolManager();
129

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

    
142
        public void validateMapContextDrawer(Class drawerClazz) throws MapContextException;
143

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

    
155
        /**
156
         * Creates a new instance of the provided {@link MapContextDrawer}
157
         * implementation.
158
         * 
159
         * @param drawerClazz
160
         *            the {@link MapContextDrawer} implementation class
161
         * @return the new {@link MapContextDrawer} instance
162
         * @throws MapContextException
163
         *             if there is an error creating the new object instance
164
         */
165
        public MapContextDrawer createMapContextDrawerInstance(Class drawerClazz)
166
                        throws MapContextException;
167
        
168
        public void registerLegend(String legendName, Class legendClass)
169
                        throws MapContextRuntimeException;
170

    
171
        public ILegend createLegend(String legendName) throws MapContextRuntimeException;
172

    
173
        public String getDefaultVectorLegend();
174

    
175
        public void setDefaultVectorLegend(String legendName);
176

    
177
        public String getDefaultRasterLegend();
178
        
179
        public void setDefaultRasterLegend(String defaultRasterLegend);
180
        
181
        public IVectorLegend createDefaultVectorLegend(int shapeType) throws MapContextRuntimeException;
182
        
183
        public RasterLegend createDefaultRasterLegend(List<BandDescriptor> bands);
184

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

    
204
        /**
205
         * 
206
     * Registers legend reader.
207
     * Format is a MIME type string. Examples:
208
     * 
209
     * "application/zip; subtype=gvsleg",
210
     * "text/xml; subtype=sld/1.0.0",
211
     * "text/xml; subtype=sld/1.1.0",
212
         * 
213
         * @param format
214
         * @param readerClass
215
         * @throws MapContextRuntimeException
216
         */
217
        void registerLegendReader(String format, Class readerClass)
218
                        throws MapContextRuntimeException;
219

    
220
        /**
221
         * Creates a legend writer for the specified legend class
222
         * 
223
         */
224
        ILegendWriter createLegendWriter(Class legendClass, String format)
225
                        throws MapContextException;
226

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

    
247
        /**
248
         * 
249
     * Format is a MIME type string. Examples:
250
     * 
251
     * "application/zip; subtype=gvsleg",
252
     * "text/xml; subtype=sld/1.0.0",
253
     * "text/xml; subtype=sld/1.1.0",
254
         * 
255
         * @return A list of Strings with the available formats for writing
256
         * legends
257
         */
258
        List getLegendWritingFormats();
259

    
260
        
261
    // ================================================================
262

    
263
        /**
264
         * @deprecated to be removed in gvSIG 2.0
265
         * @see {@link SymbolPreferences}.
266
         */
267
        int getDefaultCartographicSupportMeasureUnit();
268

    
269
        /**
270
         * @deprecated to be removed in gvSIG 2.0
271
         * @see {@link SymbolPreferences}.
272
         */
273
        void setDefaultCartographicSupportMeasureUnit(
274
                        int defaultCartographicSupportMeasureUnit);
275

    
276
        /**
277
         * @deprecated to be removed in gvSIG 2.0
278
         * @see {@link SymbolPreferences}.
279
         */
280
        int getDefaultCartographicSupportReferenceSystem();
281

    
282
        /**
283
         * @deprecated to be removed in gvSIG 2.0
284
         * @see {@link SymbolPreferences}.
285
         */
286
        void setDefaultCartographicSupportReferenceSystem(
287
                        int defaultCartographicSupportReferenceSystem);
288

    
289
        /**
290
         * @deprecated to be removed in gvSIG 2.0
291
         * @see {@link SymbolPreferences}.
292
         */
293
        Color getDefaultSymbolColor();
294

    
295
        /**
296
         * @deprecated to be removed in gvSIG 2.0
297
         * @see {@link SymbolPreferences}.
298
         */
299
        void setDefaultSymbolColor(Color defaultSymbolColor);
300

    
301
        /**
302
         * @deprecated to be removed in gvSIG 2.0
303
         * @see {@link SymbolPreferences}.
304
         */
305
        void resetDefaultSymbolColor();
306

    
307
        /**
308
         * @deprecated to be removed in gvSIG 2.0
309
         * @see {@link SymbolPreferences}.
310
         */
311
        Color getDefaultSymbolFillColor();
312

    
313
        /**
314
         * @deprecated to be removed in gvSIG 2.0
315
         * @see {@link SymbolPreferences}.
316
         */
317
        void setDefaultSymbolFillColor(Color defaultSymbolFillColor);
318

    
319
        /**
320
         * @deprecated to be removed in gvSIG 2.0
321
         * @see {@link SymbolPreferences}.
322
         */
323
        void resetDefaultSymbolFillColor();
324

    
325
        /**
326
         * @deprecated to be removed in gvSIG 2.0
327
         * @see {@link SymbolPreferences}.
328
         */
329
        boolean isDefaultSymbolFillColorAleatory();
330

    
331
        /**
332
         * @deprecated to be removed in gvSIG 2.0
333
         * @see {@link SymbolPreferences}.
334
         */
335
        void setDefaultSymbolFillColorAleatory(
336
                        boolean defaultSymbolFillColorAleatory);
337

    
338
        /**
339
         * @deprecated to be removed in gvSIG 2.0
340
         * @see {@link SymbolPreferences}.
341
         */
342
        void resetDefaultSymbolFillColorAleatory();
343

    
344
        /**
345
         * @deprecated to be removed in gvSIG 2.0
346
         * @see {@link SymbolPreferences}.
347
         */
348
        Font getDefaultSymbolFont();
349

    
350
        /**
351
         * @deprecated to be removed in gvSIG 2.0
352
         * @see {@link SymbolPreferences}.
353
         */
354
        void setDefaultSymbolFont(Font defaultSymbolFont);
355

    
356
        /**
357
         * @deprecated to be removed in gvSIG 2.0
358
         * @see {@link SymbolPreferences}.
359
         */
360
        void resetDefaultSymbolFont();
361

    
362
        /**
363
         * @deprecated to be removed in gvSIG 2.0
364
         * @see {@link SymbolPreferences}.
365
         */
366
        String getSymbolLibraryPath();
367

    
368
        /**
369
         * @deprecated to be removed in gvSIG 2.0
370
         * @see {@link SymbolPreferences}.
371
         */
372
        void setSymbolLibraryPath(String symbolLibraryPath);
373

    
374
        /**
375
         * @deprecated to be removed in gvSIG 2.0
376
         * @see {@link SymbolPreferences}.
377
         */
378
        void resetSymbolLibraryPath();
379
        
380
        
381
        /**
382
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
383
         */
384
        ISymbol createSymbol(String symbolName) throws MapContextRuntimeException;
385

    
386
        /**
387
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
388
         */
389
        ISymbol createSymbol(int shapeType) throws MapContextRuntimeException;
390

    
391
        /**
392
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
393
         */
394
        ISymbol createSymbol(String symbolName, Color color)
395
                        throws MapContextRuntimeException;
396

    
397
        /**
398
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
399
         */
400
        ISymbol createSymbol(int shapeType, Color color)
401
                        throws MapContextRuntimeException;
402

    
403
        /**
404
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
405
         */
406
        IMultiLayerSymbol createMultiLayerSymbol(String symbolName)
407
                        throws MapContextRuntimeException;
408

    
409
        /**
410
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
411
         */
412
        IMultiLayerSymbol createMultiLayerSymbol(int shapeType)
413
                        throws MapContextRuntimeException;
414

    
415
        /**
416
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
417
         */
418
        void registerSymbol(String symbolName, Class symbolClass)
419
                        throws MapContextRuntimeException;
420

    
421
        /**
422
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
423
         */
424
        void registerSymbol(String symbolName, int[] shapeTypes, Class symbolClass)
425
                        throws MapContextException;
426

    
427
        /**
428
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
429
         */
430
        void registerMultiLayerSymbol(String symbolName, Class symbolClass)
431
                        throws MapContextRuntimeException;
432

    
433
        /**
434
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
435
         */
436
        void registerMultiLayerSymbol(String symbolName, int[] shapeTypes,
437
                        Class symbolClass) throws MapContextRuntimeException;
438

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

    
465

    
466
        void registerIconLayer(String store, String iconName);
467
        
468
        String getIconLayer(DataStore store);
469
        String getIconLayer(String providerName);
470
        
471
    // TODO:
472
    // DynObjectModel getFeatureTypeUIModel(DataStore store,
473
    // FeatureType featureType);
474
        
475
        /**
476
         * Returns the default CRS.
477
         * This is NOT taken from the app
478
         * preferences because this is a library. It is a
479
         * "hard-coded" default CRS, used as a last resort.
480
         * @return the default CRS
481
         */
482
        IProjection getDefaultCRS();
483
        
484
        public File getColorTableLibraryFolder();
485
        
486
        public void setColorTableLibraryFolder(File colorTableLibraryFolder);
487
        
488
        public LayerInformationBuilder createLayerInformationBuilder();
489
        
490
}