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

History | View | Annotate | Download (17.9 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
    public boolean registerLayer(Factory<FLayer> factory);
105

    
106
    /**
107
     * Create a new layer from the data parameters passed as parameter.
108
     *
109
     * @param layerName name used in for the new layer.
110
     * @param parameters used for create the {@link DataStore} of the new layer
111
     *
112
     * @return the new FLayer
113
     *
114
     * @throws LoadLayerException
115
     */
116
    public FLayer createLayer(String layerName,
117
            DataStoreParameters parameters) throws LoadLayerException;
118

    
119
    public FLayer createLayer(
120
            String layerName,
121
            CreateLayerParameters parameters
122
    ) throws LoadLayerException;
123

    
124
    /**
125
     * Create a layer from a {@link DataStore}.
126
     *
127
     * @param layerName name used in for the new layer.
128
     * @param store used for the new layer
129
     *
130
     * @return the new FLayer
131
     *
132
     * @throws LoadLayerException
133
     */
134
    public FLayer createLayer(String layerName, DataStore store)
135
            throws LoadLayerException;
136

    
137
    public FLayer createLayer(
138
            String layerName,
139
            DataStore store,
140
            CreateLayerParameters parameters
141
    ) throws LoadLayerException;
142

    
143
    /**
144
     * Create a layer to be used as the {@link GraphicLayer}.
145
     *
146
     * @param projection used in the layer.
147
     *
148
     * @return the new {@link GraphicLayer}.
149
     */
150
    public GraphicLayer createGraphicsLayer(IProjection projection);
151

    
152
    /**
153
     * Returns the current {@link SymbolManager}.
154
     *
155
     * @return the {@link SymbolManager}
156
     */
157
    SymbolManager getSymbolManager();
158

    
159
    /**
160
     * Sets the class to use as the default implementation for the
161
     * {@link MapContextDrawer}.
162
     *
163
     * @param drawerClazz the {@link MapContextDrawer} class to use
164
     * @throws MapContextException if there is any error setting the class
165
     */
166
    public void setDefaultMapContextDrawer(Class drawerClazz)
167
            throws MapContextException;
168

    
169
    public void validateMapContextDrawer(Class drawerClazz) throws MapContextException;
170

    
171
    /**
172
     * Creates a new instance of the default {@link MapContextDrawer}
173
     * implementation.
174
     *
175
     * @return the new {@link MapContextDrawer} instance
176
     * @throws MapContextException if there is an error creating the new object
177
     * instance
178
     */
179
    public MapContextDrawer createDefaultMapContextDrawerInstance()
180
            throws MapContextException;
181

    
182
    /**
183
     * Creates a new instance of the provided {@link MapContextDrawer}
184
     * implementation.
185
     *
186
     * @param drawerClazz the {@link MapContextDrawer} implementation class
187
     * @return the new {@link MapContextDrawer} instance
188
     * @throws MapContextException if there is an error creating the new object
189
     * instance
190
     */
191
    public MapContextDrawer createMapContextDrawerInstance(Class drawerClazz)
192
            throws MapContextException;
193

    
194
    public void registerLegend(String legendName, Class legendClass)
195
            throws MapContextRuntimeException;
196

    
197
    public ILegend createLegend(String legendName) throws MapContextRuntimeException;
198

    
199
    public String getDefaultVectorLegend();
200

    
201
    public void setDefaultVectorLegend(String legendName);
202

    
203
    public String getDefaultRasterLegend();
204

    
205
    public void setDefaultRasterLegend(String defaultRasterLegend);
206

    
207
    public IVectorLegend createDefaultVectorLegend(int shapeType) throws MapContextRuntimeException;
208

    
209
    public RasterLegend createDefaultRasterLegend(List<BandDescriptor> bands);
210

    
211
    // ================================================================
212
    // = Legend reading/writing (GVSLEG, SLD, etc)
213
    /**
214
     * Registers legend writer. Format is a MIME type string. Examples:
215
     *
216
     * "application/zip; subtype=gvsleg", "text/xml; subtype=sld/1.0.0",
217
     * "text/xml; subtype=sld/1.1.0",
218
     *
219
     * @param legendClass Legend class
220
     * @param format File type in mime format.
221
     * @param writerClass Class object of the writer
222
     * @throws MapContextRuntimeException
223
     */
224
    void registerLegendWriter(Class legendClass, String format,
225
            Class writerClass) throws MapContextRuntimeException;
226

    
227
    /**
228
     *
229
     * Registers legend reader. Format is a MIME type string. Examples:
230
     *
231
     * "application/zip; subtype=gvsleg", "text/xml; subtype=sld/1.0.0",
232
     * "text/xml; subtype=sld/1.1.0",
233
     *
234
     * @param format
235
     * @param readerClass
236
     * @throws MapContextRuntimeException
237
     */
238
    void registerLegendReader(String format, Class readerClass)
239
            throws MapContextRuntimeException;
240

    
241
    /**
242
     * Creates a legend writer for the specified legend class
243
     *
244
     * @param legendClass
245
     * @param format
246
     * @return
247
     * @throws org.gvsig.fmap.mapcontext.MapContextException
248
     */
249
    ILegendWriter createLegendWriter(Class legendClass, String format)
250
            throws MapContextException;
251

    
252
    /**
253
     * Creates a legend reader for the given format ("sld", "gvsleg", etc are
254
     * extracted from the MIME long string)
255
     *
256
     * @param format
257
     * @return
258
     */
259
    ILegendReader createLegendReader(String format)
260
            throws MapContextRuntimeException;
261

    
262
    /**
263
     *
264
     * Format is a MIME type string. Examples:
265
     *
266
     * "application/zip; subtype=gvsleg", "text/xml; subtype=sld/1.0.0",
267
     * "text/xml; subtype=sld/1.1.0",
268
     *
269
     * @return A list of Strings with the available formats for reading legends
270
     */
271
    List getLegendReadingFormats();
272

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

    
284
    // ================================================================
285
    /**
286
     * @return @deprecated to be removed in gvSIG 2.0
287
     * @see {@link SymbolPreferences}.
288
     */
289
    int getDefaultCartographicSupportMeasureUnit();
290

    
291
    /**
292
     * @param defaultCartographicSupportMeasureUnit
293
     * @deprecated to be removed in gvSIG 2.0
294
     * @see {@link SymbolPreferences}.
295
     */
296
    void setDefaultCartographicSupportMeasureUnit(
297
            int defaultCartographicSupportMeasureUnit);
298

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

    
305
    /**
306
     * @param defaultCartographicSupportReferenceSystem
307
     * @deprecated to be removed in gvSIG 2.0
308
     * @see {@link SymbolPreferences}.
309
     */
310
    void setDefaultCartographicSupportReferenceSystem(
311
            int defaultCartographicSupportReferenceSystem);
312

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

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

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

    
332
    /**
333
     * @return @deprecated to be removed in gvSIG 2.0
334
     * @see {@link SymbolPreferences}.
335
     */
336
    Color getDefaultSymbolFillColor();
337

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

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

    
351
    /**
352
     * @return @deprecated to be removed in gvSIG 2.0
353
     * @see {@link SymbolPreferences}.
354
     */
355
    boolean isDefaultSymbolFillColorAleatory();
356

    
357
    /**
358
     * @param defaultSymbolFillColorAleatory
359
     * @deprecated to be removed in gvSIG 2.0
360
     * @see {@link SymbolPreferences}.
361
     */
362
    void setDefaultSymbolFillColorAleatory(
363
            boolean defaultSymbolFillColorAleatory);
364

    
365
    /**
366
     * @deprecated to be removed in gvSIG 2.0
367
     * @see {@link SymbolPreferences}.
368
     */
369
    void resetDefaultSymbolFillColorAleatory();
370

    
371
    /**
372
     * @return @deprecated to be removed in gvSIG 2.0
373
     * @see {@link SymbolPreferences}.
374
     */
375
    Font getDefaultSymbolFont();
376

    
377
    /**
378
     * @param defaultSymbolFont
379
     * @deprecated to be removed in gvSIG 2.0
380
     * @see {@link SymbolPreferences}.
381
     */
382
    void setDefaultSymbolFont(Font defaultSymbolFont);
383

    
384
    /**
385
     * @deprecated to be removed in gvSIG 2.0
386
     * @see {@link SymbolPreferences}.
387
     */
388
    void resetDefaultSymbolFont();
389

    
390
    /**
391
     * @return @deprecated to be removed in gvSIG 2.0
392
     * @see {@link SymbolPreferences}.
393
     */
394
    String getSymbolLibraryPath();
395

    
396
    /**
397
     * @param symbolLibraryPath
398
     * @deprecated to be removed in gvSIG 2.0
399
     * @see {@link SymbolPreferences}.
400
     */
401
    void setSymbolLibraryPath(String symbolLibraryPath);
402

    
403
    /**
404
     * @deprecated to be removed in gvSIG 2.0
405
     * @see {@link SymbolPreferences}.
406
     */
407
    void resetSymbolLibraryPath();
408

    
409
    /**
410
     * @param symbolName
411
     * @return
412
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
413
     */
414
    ISymbol createSymbol(String symbolName) throws MapContextRuntimeException;
415

    
416
    /**
417
     * @param shapeType
418
     * @return
419
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
420
     */
421
    ISymbol createSymbol(int shapeType) throws MapContextRuntimeException;
422

    
423
    /**
424
     * @param symbolName
425
     * @param color
426
     * @return
427
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
428
     */
429
    ISymbol createSymbol(String symbolName, Color color)
430
            throws MapContextRuntimeException;
431

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

    
441
    /**
442
     * @param symbolName
443
     * @return
444
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
445
     */
446
    IMultiLayerSymbol createMultiLayerSymbol(String symbolName)
447
            throws MapContextRuntimeException;
448

    
449
    /**
450
     * @param shapeType
451
     * @return
452
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
453
     */
454
    IMultiLayerSymbol createMultiLayerSymbol(int shapeType)
455
            throws MapContextRuntimeException;
456

    
457
    /**
458
     * @param symbolName
459
     * @param symbolClass
460
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
461
     */
462
    void registerSymbol(String symbolName, Class symbolClass)
463
            throws MapContextRuntimeException;
464

    
465
    /**
466
     * @param symbolName
467
     * @param shapeTypes
468
     * @param symbolClass
469
     * @throws org.gvsig.fmap.mapcontext.MapContextException
470
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
471
     */
472
    void registerSymbol(String symbolName, int[] shapeTypes, Class symbolClass)
473
            throws MapContextException;
474

    
475
    /**
476
     * @param symbolName
477
     * @param symbolClass
478
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
479
     */
480
    void registerMultiLayerSymbol(String symbolName, Class symbolClass)
481
            throws MapContextRuntimeException;
482

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

    
492
    /**
493
     * @param message
494
     * @param symbolDesc
495
     * @param symbolDrawExceptionType
496
     * @return
497
     * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
498
     */
499
    IWarningSymbol getWarningSymbol(String message, String symbolDesc,
500
            int symbolDrawExceptionType) throws MapContextRuntimeException;
501

    
502
    /**
503
     * It returns the legend associated with a {@link DataStore}. If the legend
504
     * doesn't exist it returns <code>null</code>.
505
     *
506
     * @param dataStore the store that could have a legend.
507
     * @return the legend or <code>null</code>.
508
     */
509
    ILegend getLegend(DataStore dataStore);
510

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

    
520
    void registerIconLayer(String store, String iconName);
521

    
522
    String getIconLayer(DataStore store);
523

    
524
    String getIconLayer(String providerName);
525

    
526
    // TODO:
527
    // DynObjectModel getFeatureTypeUIModel(DataStore store,
528
    // FeatureType featureType);
529
    
530
    
531
    /**
532
     * Returns the default CRS. This is NOT taken from the app preferences
533
     * because this is a library. It is a "hard-coded" default CRS, used as a
534
     * last resort.
535
     *
536
     * @return the default CRS
537
     */
538
    IProjection getDefaultCRS();
539

    
540
    public File getColorTableLibraryFolder();
541

    
542
    public void setColorTableLibraryFolder(File colorTableLibraryFolder);
543

    
544
    public LayerInformationBuilder createLayerInformationBuilder();
545

    
546
    public Icon getIcon(int geometryType, boolean hasSelection);
547

    
548
}