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 @ 40927

History | View | Annotate | Download (12.7 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.util.List;
33

    
34
import org.cresques.cts.IProjection;
35

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

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

    
62
        /**
63
         * Create a new layer from the data parameters passed as parameter.
64
         * 
65
         * @param layerName name used in for the new layer. 
66
         * @param parameters used for create the {@link DataStore} of the new layer
67
         * 
68
         * @return the new FLayer
69
         * 
70
         * @throws LoadLayerException
71
         */
72
        public FLayer createLayer(String layerName,
73
                        DataStoreParameters parameters) throws LoadLayerException;
74

    
75
        /**
76
         * Create a layer from a {@link DataStore}.
77
         * 
78
         * @param layerName name used in for the new layer. 
79
         * @param store used for the new layer
80
         * 
81
         * @return the new FLayer
82
         * 
83
         * @throws LoadLayerException
84
         */
85
        public FLayer createLayer(String layerName, DataStore store)
86
                        throws LoadLayerException;
87

    
88
        /**
89
         * Create a layer to be used as the {@link GraphicLayer}.
90
         * 
91
         * @param projection used in the layer.
92
         * 
93
         * @return the new {@link GraphicLayer}.
94
         */
95
        public GraphicLayer createGraphicsLayer(IProjection projection);
96

    
97
        /**
98
         * Returns the current {@link SymbolManager}.
99
         * 
100
         * @return the {@link SymbolManager}
101
         */
102
        SymbolManager getSymbolManager();
103

    
104
        /**
105
         * Sets the class to use as the default implementation for the
106
         * {@link MapContextDrawer}.
107
         * 
108
         * @param drawerClazz
109
         *            the {@link MapContextDrawer} class to use
110
         * @throws MapContextException
111
         *             if there is any error setting the class
112
         */
113
        public void setDefaultMapContextDrawer(Class drawerClazz)
114
                        throws MapContextException;
115

    
116
        public void validateMapContextDrawer(Class drawerClazz) throws MapContextException;
117

    
118
        /**
119
         * Creates a new instance of the default {@link MapContextDrawer}
120
         * implementation.
121
         * 
122
         * @return the new {@link MapContextDrawer} instance
123
         * @throws MapContextException
124
         *             if there is an error creating the new object instance
125
         */
126
        public MapContextDrawer createDefaultMapContextDrawerInstance()
127
                        throws MapContextException;
128

    
129
        /**
130
         * Creates a new instance of the provided {@link MapContextDrawer}
131
         * implementation.
132
         * 
133
         * @param drawerClazz
134
         *            the {@link MapContextDrawer} implementation class
135
         * @return the new {@link MapContextDrawer} instance
136
         * @throws MapContextException
137
         *             if there is an error creating the new object instance
138
         */
139
        public MapContextDrawer createMapContextDrawerInstance(Class drawerClazz)
140
                        throws MapContextException;
141

    
142
        
143
        
144
        void registerLegend(String legendName, Class legendClass)
145
                        throws MapContextRuntimeException;
146

    
147
        ILegend createLegend(String legendName) throws MapContextRuntimeException;
148

    
149
        void setDefaultVectorLegend(String legendName);
150

    
151
        IVectorLegend createDefaultVectorLegend(int shapeType)
152
                        throws MapContextRuntimeException;
153

    
154
    // ================================================================
155
        // = Legend reading/writing (GVSLEG, SLD, etc)
156
        
157
        /**
158
         * Registers legend writer.
159
     * Format is a MIME type string. Examples:
160
         * 
161
         * "application/zip; subtype=gvsleg",
162
     * "text/xml; subtype=sld/1.0.0",
163
     * "text/xml; subtype=sld/1.1.0",
164
         * 
165
         * @param legendClass Legend class
166
         * @param format File type in mime format.
167
         * @param writerClass Class object of the writer
168
         * @throws MapContextRuntimeException
169
         */
170
        void registerLegendWriter(Class legendClass, String format,
171
                        Class writerClass) throws MapContextRuntimeException;
172

    
173
        /**
174
         * 
175
     * Registers legend reader.
176
     * Format is a MIME type string. Examples:
177
     * 
178
     * "application/zip; subtype=gvsleg",
179
     * "text/xml; subtype=sld/1.0.0",
180
     * "text/xml; subtype=sld/1.1.0",
181
         * 
182
         * @param format
183
         * @param readerClass
184
         * @throws MapContextRuntimeException
185
         */
186
        void registerLegendReader(String format, Class readerClass)
187
                        throws MapContextRuntimeException;
188

    
189
        /**
190
         * Creates a legend writer for the specified legend class
191
         * 
192
         */
193
        ILegendWriter createLegendWriter(Class legendClass, String format)
194
                        throws MapContextException;
195

    
196
        /**
197
         * Creates a legend reader for the given format
198
         * ("sld", "gvsleg", etc are extracted from the MIME long string)
199
         */
200
        ILegendReader createLegendReader(String format)
201
                        throws MapContextRuntimeException;
202
        
203
        /**
204
         * 
205
     * Format is a MIME type string. Examples:
206
     * 
207
     * "application/zip; subtype=gvsleg",
208
     * "text/xml; subtype=sld/1.0.0",
209
     * "text/xml; subtype=sld/1.1.0",
210
         * 
211
         * @return A list of Strings with the available formats for reading
212
         * legends
213
         */
214
        List getLegendReadingFormats();
215

    
216
        /**
217
         * 
218
     * Format is a MIME type string. Examples:
219
     * 
220
     * "application/zip; subtype=gvsleg",
221
     * "text/xml; subtype=sld/1.0.0",
222
     * "text/xml; subtype=sld/1.1.0",
223
         * 
224
         * @return A list of Strings with the available formats for writing
225
         * legends
226
         */
227
        List getLegendWritingFormats();
228

    
229
        
230
    // ================================================================
231

    
232
        /**
233
         * @deprecated to be removed in gvSIG 2.0
234
         * @see {@link SymbolPreferences}.
235
         */
236
        int getDefaultCartographicSupportMeasureUnit();
237

    
238
        /**
239
         * @deprecated to be removed in gvSIG 2.0
240
         * @see {@link SymbolPreferences}.
241
         */
242
        void setDefaultCartographicSupportMeasureUnit(
243
                        int defaultCartographicSupportMeasureUnit);
244

    
245
        /**
246
         * @deprecated to be removed in gvSIG 2.0
247
         * @see {@link SymbolPreferences}.
248
         */
249
        int getDefaultCartographicSupportReferenceSystem();
250

    
251
        /**
252
         * @deprecated to be removed in gvSIG 2.0
253
         * @see {@link SymbolPreferences}.
254
         */
255
        void setDefaultCartographicSupportReferenceSystem(
256
                        int defaultCartographicSupportReferenceSystem);
257

    
258
        /**
259
         * @deprecated to be removed in gvSIG 2.0
260
         * @see {@link SymbolPreferences}.
261
         */
262
        Color getDefaultSymbolColor();
263

    
264
        /**
265
         * @deprecated to be removed in gvSIG 2.0
266
         * @see {@link SymbolPreferences}.
267
         */
268
        void setDefaultSymbolColor(Color defaultSymbolColor);
269

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

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

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

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

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

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

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

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

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

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

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

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

    
343
        /**
344
         * @deprecated to be removed in gvSIG 2.0
345
         * @see {@link SymbolPreferences}.
346
         */
347
        void resetSymbolLibraryPath();
348
        
349
        
350
        /**
351
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
352
         */
353
        ISymbol createSymbol(String symbolName) throws MapContextRuntimeException;
354

    
355
        /**
356
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
357
         */
358
        ISymbol createSymbol(int shapeType) throws MapContextRuntimeException;
359

    
360
        /**
361
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
362
         */
363
        ISymbol createSymbol(String symbolName, Color color)
364
                        throws MapContextRuntimeException;
365

    
366
        /**
367
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
368
         */
369
        ISymbol createSymbol(int shapeType, Color color)
370
                        throws MapContextRuntimeException;
371

    
372
        /**
373
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
374
         */
375
        IMultiLayerSymbol createMultiLayerSymbol(String symbolName)
376
                        throws MapContextRuntimeException;
377

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

    
384
        /**
385
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
386
         */
387
        void registerSymbol(String symbolName, Class symbolClass)
388
                        throws MapContextRuntimeException;
389

    
390
        /**
391
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
392
         */
393
        void registerSymbol(String symbolName, int[] shapeTypes, Class symbolClass)
394
                        throws MapContextException;
395

    
396
        /**
397
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
398
         */
399
        void registerMultiLayerSymbol(String symbolName, Class symbolClass)
400
                        throws MapContextRuntimeException;
401

    
402
        /**
403
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
404
         */
405
        void registerMultiLayerSymbol(String symbolName, int[] shapeTypes,
406
                        Class symbolClass) throws MapContextRuntimeException;
407

    
408
        /**
409
         * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
410
         */
411
        IWarningSymbol getWarningSymbol(String message, String symbolDesc,
412
                        int symbolDrawExceptionType) throws MapContextRuntimeException;
413
        
414
        /**
415
         * It returns the legend associated with a {@link DataStore}.
416
         * If the legend doesn't exist it returns <code>null</code>.
417
         * @param dataStore
418
         * the store that could have a legend.
419
         * @return
420
         * the legend or <code>null</code>.
421
         */
422
        ILegend getLegend(DataStore dataStore);        
423
        
424
        /**
425
     * It returns the labeling strategy associated with a {@link DataStore}.
426
     * If the labeling strategy doesn't exist it returns <code>null</code>.
427
     * @param dataStore
428
     * the store that could have a labeling strategy.
429
     * @return
430
     * the labeling strategy or <code>null</code>.
431
     */
432
        ILabelingStrategy getLabelingStrategy(DataStore dataStore);
433

    
434

    
435
        void registerIconLayer(String store, String iconName);
436
        
437
        String getIconLayer(DataStore store);
438
        
439
    // TODO:
440
    // DynObjectModel getFeatureTypeUIModel(DataStore store,
441
    // FeatureType featureType);
442
        
443
        /**
444
         * Returns the default CRS.
445
         * This is NOT taken from the app
446
         * preferences because this is a library. It is a
447
         * "hard-coded" default CRS, used as a last resort.
448
         * @return the default CRS
449
         */
450
        IProjection getDefaultCRS();
451
}