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

History | View | Annotate | Download (18.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
import javax.swing.Icon;
35
import org.cresques.cts.ICoordTrans;
36
import org.cresques.cts.IProjection;
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
import org.gvsig.tools.util.Factory;
56

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

    
67
    public interface CreateLayerParameters {
68

    
69
        public DataStoreParameters getDataParameters();
70

    
71
        public boolean useCache();
72

    
73
        public ICoordTrans getCoordTrans();
74
        
75
        public boolean isVisible();
76
    }
77

    
78
    public static final String GET_DEFAULT_CRS = "MAPCONTEXTMANAGER_GET_DEFAULT_CRS";
79
    public static final String CREATE_LEGEND = "MAPCONTEXTMANAGER_CREATE_LEGEND";
80
    public static final String CREATE_MAPCONTEXT_DRAWER = "MAPCONTEXTMANAGER_CREATE_MAPCONTEXT_DRAWER";
81
    public static final String SET_MAPCONTEXT_DRAWER = "MAPCONTEXTMANAGER_SET_MAPCONTEXT_DRAWER";
82
    public static final String CREATE_GRAPHICS_LAYER = "MAPCONTEXTMANAGER_CREATE_GRAPHICS_LAYER";
83
    public static final String REGISTER_LEGEND = "MAPCONTEXTMANAGER_REGISTER_LEGEND";
84
    public static final String REGISTER_LEGEND_READER = "MAPCONTEXTMANAGER_REGISTER_LEGEND_READER";
85
    public static final String CREATE_LEGEND_READER = "MAPCONTEXTMANAGER_CREATE_LEGEND_READER";
86
    public static final String REGISTER_LEGEND_WRITER = "MAPCONTEXTMANAGER_REGISTER_LEGEND_WRITER";
87
    public static final String CREATE_SYMBOL = "MAPCONTEXTMANAGER_CREATE_SYMBOL";
88
    public static final String LOAD_SYMBOLS = "MAPCONTEXTMANAGER_LOAD_SYMBOLS";
89
    public static final String REGISTER_MULTILAYER_SYMBOL = "MAPCONTEXTMANAGER_REGISTER_MULTILAYER_SYMBOL";
90
    public static final String REGISTER_SYMBOL = "MAPCONTEXTMANAGER_REGISTER_SYMBOL";
91
    public static final String CREATE_LAYER = "MAPCONTEXTMANAGER_CREATE_LAYER";
92
    public static final String LOAD_LAYER = "MAPCONTEXTMANAGER_LOAD_LAYER";
93
    public static final String REGISTER_ICON_LAYER = "MAPCONTEXTMANAGER_REGISTER_ICON_LAYER";
94
    public static final String CREATE_MAPCONTEXT = "MAPCONTEXTMANAGER_CREATE_MAPCONTEXT";
95
    public static final String LOAD_MAPCONTEXT = "MAPCONTEXTMANAGER_LOAD_MAPCONTEXT";
96

    
97
    public MapContext createMapContext();
98

    
99
    public boolean registerLayer(
100
            Class theClass, 
101
            Class<? extends FLayer> layerClass
102
    );
103

    
104
    /**
105
     * Register a factory to create new layers based on the parameters 
106
     * of the store and the store itself. 
107
     * If the factory cannot create the layer, it returns null 
108
     * without throwing an exception. 
109
     * The returned layer must be fully initialized.
110
     * 
111
     * @param factory
112
     * @return 
113
     */
114
    public boolean registerLayer(Factory<FLayer> factory);
115

    
116
    /**
117
     * Create a new layer from the data parameters passed as parameter.
118
     *
119
     * @param layerName name used in for the new layer.
120
     * @param parameters used for create the {@link DataStore} of the new layer
121
     *
122
     * @return the new FLayer
123
     *
124
     * @throws LoadLayerException
125
     */
126
    public FLayer createLayer(String layerName,
127
            DataStoreParameters parameters) throws LoadLayerException;
128

    
129
    public FLayer createLayer(
130
            String layerName,
131
            CreateLayerParameters parameters
132
    ) throws LoadLayerException;
133

    
134
    /**
135
     * Create a layer from a {@link DataStore}.
136
     *
137
     * @param layerName name used in for the new layer.
138
     * @param store used for the new layer
139
     *
140
     * @return the new FLayer
141
     *
142
     * @throws LoadLayerException
143
     */
144
    public FLayer createLayer(String layerName, DataStore store)
145
            throws LoadLayerException;
146

    
147
    public FLayer createLayer(
148
            String layerName,
149
            DataStore store,
150
            CreateLayerParameters parameters
151
    ) throws LoadLayerException;
152

    
153
    /**
154
     * Create a layer to be used as the {@link GraphicLayer}.
155
     *
156
     * @param projection used in the layer.
157
     *
158
     * @return the new {@link GraphicLayer}.
159
     */
160
    public GraphicLayer createGraphicsLayer(IProjection projection);
161

    
162
    /**
163
     * Returns the current {@link SymbolManager}.
164
     *
165
     * @return the {@link SymbolManager}
166
     */
167
    SymbolManager getSymbolManager();
168

    
169
    /**
170
     * Sets the class to use as the default implementation for the
171
     * {@link MapContextDrawer}.
172
     *
173
     * @param drawerClazz the {@link MapContextDrawer} class to use
174
     * @throws MapContextException if there is any error setting the class
175
     */
176
    public void setDefaultMapContextDrawer(Class drawerClazz)
177
            throws MapContextException;
178

    
179
    public void validateMapContextDrawer(Class drawerClazz) throws MapContextException;
180

    
181
    /**
182
     * Creates a new instance of the default {@link MapContextDrawer}
183
     * implementation.
184
     *
185
     * @return the new {@link MapContextDrawer} instance
186
     * @throws MapContextException if there is an error creating the new object
187
     * instance
188
     */
189
    public MapContextDrawer createDefaultMapContextDrawerInstance()
190
            throws MapContextException;
191

    
192
    /**
193
     * Creates a new instance of the provided {@link MapContextDrawer}
194
     * implementation.
195
     *
196
     * @param drawerClazz the {@link MapContextDrawer} implementation class
197
     * @return the new {@link MapContextDrawer} instance
198
     * @throws MapContextException if there is an error creating the new object
199
     * instance
200
     */
201
    public MapContextDrawer createMapContextDrawerInstance(Class drawerClazz)
202
            throws MapContextException;
203

    
204
    public void registerLegend(String legendName, Class legendClass)
205
            throws MapContextRuntimeException;
206

    
207
    public ILegend createLegend(String legendName) throws MapContextRuntimeException;
208

    
209
    public String getDefaultVectorLegend();
210

    
211
    public void setDefaultVectorLegend(String legendName);
212

    
213
    public String getDefaultRasterLegend();
214

    
215
    public void setDefaultRasterLegend(String defaultRasterLegend);
216

    
217
    public IVectorLegend createDefaultVectorLegend(int shapeType) throws MapContextRuntimeException;
218

    
219
    public RasterLegend createDefaultRasterLegend(List<BandDescriptor> bands);
220

    
221
    // ================================================================
222
    // = Legend reading/writing (GVSLEG, SLD, etc)
223
    /**
224
     * Registers legend writer. Format is a MIME type string. Examples:
225
     *
226
     * "application/zip; subtype=gvsleg", "text/xml; subtype=sld/1.0.0",
227
     * "text/xml; subtype=sld/1.1.0",
228
     *
229
     * @param legendClass Legend class
230
     * @param format File type in mime format.
231
     * @param writerClass Class object of the writer
232
     * @throws MapContextRuntimeException
233
     */
234
    void registerLegendWriter(Class legendClass, String format,
235
            Class writerClass) throws MapContextRuntimeException;
236

    
237
    /**
238
     *
239
     * Registers legend reader. Format is a MIME type string. Examples:
240
     *
241
     * "application/zip; subtype=gvsleg", "text/xml; subtype=sld/1.0.0",
242
     * "text/xml; subtype=sld/1.1.0",
243
     *
244
     * @param format
245
     * @param readerClass
246
     * @throws MapContextRuntimeException
247
     */
248
    void registerLegendReader(String format, Class readerClass)
249
            throws MapContextRuntimeException;
250

    
251
    /**
252
     * Creates a legend writer for the specified legend class
253
     *
254
     * @param legendClass
255
     * @param format
256
     * @return
257
     * @throws org.gvsig.fmap.mapcontext.MapContextException
258
     */
259
    ILegendWriter createLegendWriter(Class legendClass, String format)
260
            throws MapContextException;
261

    
262
    /**
263
     * Creates a legend reader for the given format ("sld", "gvsleg", etc are
264
     * extracted from the MIME long string)
265
     *
266
     * @param format
267
     * @return
268
     */
269
    ILegendReader createLegendReader(String format)
270
            throws MapContextRuntimeException;
271

    
272
    /**
273
     *
274
     * Format is a MIME type string. Examples:
275
     *
276
     * "application/zip; subtype=gvsleg", "text/xml; subtype=sld/1.0.0",
277
     * "text/xml; subtype=sld/1.1.0",
278
     *
279
     * @return A list of Strings with the available formats for reading legends
280
     */
281
    List getLegendReadingFormats();
282

    
283
    /**
284
     *
285
     * Format is a MIME type string. Examples:
286
     *
287
     * "application/zip; subtype=gvsleg", "text/xml; subtype=sld/1.0.0",
288
     * "text/xml; subtype=sld/1.1.0",
289
     *
290
     * @return A list of Strings with the available formats for writing legends
291
     */
292
    List getLegendWritingFormats();
293

    
294
    // ================================================================
295
    /**
296
     * @return @deprecated to be removed in gvSIG 2.0
297
     * @see {@link SymbolPreferences}.
298
     */
299
    int getDefaultCartographicSupportMeasureUnit();
300

    
301
    /**
302
     * @param defaultCartographicSupportMeasureUnit
303
     * @deprecated to be removed in gvSIG 2.0
304
     * @see {@link SymbolPreferences}.
305
     */
306
    void setDefaultCartographicSupportMeasureUnit(
307
            int defaultCartographicSupportMeasureUnit);
308

    
309
    /**
310
     * @return @deprecated to be removed in gvSIG 2.0
311
     * @see {@link SymbolPreferences}.
312
     */
313
    int getDefaultCartographicSupportReferenceSystem();
314

    
315
    /**
316
     * @param defaultCartographicSupportReferenceSystem
317
     * @deprecated to be removed in gvSIG 2.0
318
     * @see {@link SymbolPreferences}.
319
     */
320
    void setDefaultCartographicSupportReferenceSystem(
321
            int defaultCartographicSupportReferenceSystem);
322

    
323
    /**
324
     * @return @deprecated to be removed in gvSIG 2.0
325
     * @see {@link SymbolPreferences}.
326
     */
327
    Color getDefaultSymbolColor();
328

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

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

    
342
    /**
343
     * @return @deprecated to be removed in gvSIG 2.0
344
     * @see {@link SymbolPreferences}.
345
     */
346
    Color getDefaultSymbolFillColor();
347

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

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

    
361
    /**
362
     * @return @deprecated to be removed in gvSIG 2.0
363
     * @see {@link SymbolPreferences}.
364
     */
365
    boolean isDefaultSymbolFillColorAleatory();
366

    
367
    /**
368
     * @param defaultSymbolFillColorAleatory
369
     * @deprecated to be removed in gvSIG 2.0
370
     * @see {@link SymbolPreferences}.
371
     */
372
    void setDefaultSymbolFillColorAleatory(
373
            boolean defaultSymbolFillColorAleatory);
374

    
375
    /**
376
     * @deprecated to be removed in gvSIG 2.0
377
     * @see {@link SymbolPreferences}.
378
     */
379
    void resetDefaultSymbolFillColorAleatory();
380

    
381
    /**
382
     * @return @deprecated to be removed in gvSIG 2.0
383
     * @see {@link SymbolPreferences}.
384
     */
385
    Font getDefaultSymbolFont();
386

    
387
    /**
388
     * @param defaultSymbolFont
389
     * @deprecated to be removed in gvSIG 2.0
390
     * @see {@link SymbolPreferences}.
391
     */
392
    void setDefaultSymbolFont(Font defaultSymbolFont);
393

    
394
    /**
395
     * @deprecated to be removed in gvSIG 2.0
396
     * @see {@link SymbolPreferences}.
397
     */
398
    void resetDefaultSymbolFont();
399

    
400
    /**
401
     * @return @deprecated to be removed in gvSIG 2.0
402
     * @see {@link SymbolPreferences}.
403
     */
404
    String getSymbolLibraryPath();
405

    
406
    /**
407
     * @param symbolLibraryPath
408
     * @deprecated to be removed in gvSIG 2.0
409
     * @see {@link SymbolPreferences}.
410
     */
411
    void setSymbolLibraryPath(String symbolLibraryPath);
412

    
413
    /**
414
     * @deprecated to be removed in gvSIG 2.0
415
     * @see {@link SymbolPreferences}.
416
     */
417
    void resetSymbolLibraryPath();
418

    
419
    /**
420
     * @param symbolName
421
     * @return
422
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
423
     */
424
    ISymbol createSymbol(String symbolName) throws MapContextRuntimeException;
425

    
426
    /**
427
     * @param shapeType
428
     * @return
429
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
430
     */
431
    ISymbol createSymbol(int shapeType) throws MapContextRuntimeException;
432

    
433
    /**
434
     * @param symbolName
435
     * @param color
436
     * @return
437
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
438
     */
439
    ISymbol createSymbol(String symbolName, Color color)
440
            throws MapContextRuntimeException;
441

    
442
    /**
443
     * @param shapeType
444
     * @param color
445
     * @return
446
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
447
     */
448
    ISymbol createSymbol(int shapeType, Color color)
449
            throws MapContextRuntimeException;
450

    
451
    /**
452
     * @param symbolName
453
     * @return
454
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
455
     */
456
    IMultiLayerSymbol createMultiLayerSymbol(String symbolName)
457
            throws MapContextRuntimeException;
458

    
459
    /**
460
     * @param shapeType
461
     * @return
462
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
463
     */
464
    IMultiLayerSymbol createMultiLayerSymbol(int shapeType)
465
            throws MapContextRuntimeException;
466

    
467
    /**
468
     * @param symbolName
469
     * @param symbolClass
470
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
471
     */
472
    void registerSymbol(String symbolName, Class symbolClass)
473
            throws MapContextRuntimeException;
474

    
475
    /**
476
     * @param symbolName
477
     * @param shapeTypes
478
     * @param symbolClass
479
     * @throws org.gvsig.fmap.mapcontext.MapContextException
480
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
481
     */
482
    void registerSymbol(String symbolName, int[] shapeTypes, Class symbolClass)
483
            throws MapContextException;
484

    
485
    /**
486
     * @param symbolName
487
     * @param symbolClass
488
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
489
     */
490
    void registerMultiLayerSymbol(String symbolName, Class symbolClass)
491
            throws MapContextRuntimeException;
492

    
493
    /**
494
     * @param symbolName
495
     * @param shapeTypes
496
     * @param symbolClass
497
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
498
     */
499
    void registerMultiLayerSymbol(String symbolName, int[] shapeTypes,
500
            Class symbolClass) throws MapContextRuntimeException;
501

    
502
    /**
503
     * @param message
504
     * @param symbolDesc
505
     * @param symbolDrawExceptionType
506
     * @return
507
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
508
     */
509
    IWarningSymbol getWarningSymbol(String message, String symbolDesc,
510
            int symbolDrawExceptionType) throws MapContextRuntimeException;
511

    
512
    /**
513
     * It returns the legend associated with a {@link DataStore}. If the legend
514
     * doesn't exist it returns <code>null</code>.
515
     *
516
     * @param dataStore the store that could have a legend.
517
     * @return the legend or <code>null</code>.
518
     */
519
    ILegend getLegend(DataStore dataStore);
520

    
521
    /**
522
     * It returns the labeling strategy associated with a {@link DataStore}. If
523
     * the labeling strategy doesn't exist it returns <code>null</code>.
524
     *
525
     * @param dataStore the store that could have a labeling strategy.
526
     * @return the labeling strategy or <code>null</code>.
527
     */
528
    ILabelingStrategy getLabelingStrategy(DataStore dataStore);
529

    
530
    void registerIconLayer(String store, String iconName);
531

    
532
    String getIconLayer(DataStore store);
533

    
534
    String getIconLayer(String providerName);
535

    
536
    // TODO:
537
    // DynObjectModel getFeatureTypeUIModel(DataStore store,
538
    // FeatureType featureType);
539
    
540
    
541
    /**
542
     * Returns the default CRS. This is NOT taken from the app preferences
543
     * because this is a library. It is a "hard-coded" default CRS, used as a
544
     * last resort.
545
     *
546
     * @return the default CRS
547
     */
548
    IProjection getDefaultCRS();
549

    
550
    public File getColorTableLibraryFolder();
551

    
552
    public void setColorTableLibraryFolder(File colorTableLibraryFolder);
553

    
554
    public LayerInformationBuilder createLayerInformationBuilder();
555

    
556
    public Icon getIcon(int geometryType, boolean hasSelection);
557

    
558
}