Statistics
| Revision:

root / tags / v2_0_0_Build_2049 / libraries / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / rendering / symbols / SymbolManager.java @ 38488

History | View | Annotate | Download (9.09 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {DiSiD Technologies}  {{Task}}
26
 */
27
package org.gvsig.fmap.mapcontext.rendering.symbols;
28

    
29
import java.awt.Color;
30
import java.io.File;
31
import java.io.FileFilter;
32

    
33
import org.gvsig.fmap.geom.Geometry;
34
import org.gvsig.fmap.mapcontext.MapContextException;
35
import org.gvsig.fmap.mapcontext.MapContextRuntimeException;
36
import org.gvsig.tools.persistence.PersistenceManager;
37

    
38
/**
39
 * Symbols management: creation, registration, etc.
40
 * 
41
 * @author gvSIG team
42
 */
43
public interface SymbolManager {
44

    
45
    public static final String LEGEND_FILE_EXTENSION = ".gvsleg";
46
    public static final String LABELINGSTRATEGY_FILE_EXTENSION = ".gvslab";
47
    
48
        /**
49
         * Loads the symbols persisted into a folder. It loads the symbols through
50
         * the use of the current {@link PersistenceManager}, loading all files
51
         * found into the folder.
52
         * 
53
         * @param folder
54
         *            to load the persisted symbols from
55
         * @return the list of loaded symbols
56
         * @throws SymbolException
57
         *             if there is an error loading the symbols
58
         */
59
        ISymbol[] loadSymbols(File folder) throws SymbolException;
60

    
61
        /**
62
         * Loads the symbols persisted into a folder. It loads the symbols through
63
         * the use of the current {@link PersistenceManager}, loading the files
64
         * found into the folder which apply to the provided filter.
65
         * 
66
         * @param folder
67
         *            to load the persisted symbols from
68
         * @param filter
69
         *            to apply to know which files to load
70
         * @return the list of loaded symbols
71
         * @throws SymbolException
72
         *             if there is an error loading the symbols
73
         */
74
        ISymbol[] loadSymbols(File folder, FileFilter filter)
75
                        throws SymbolException;
76

    
77
        /**
78
         * Persists a {@link ISymbol} into the given folder, with the given file
79
         * name.
80
         * 
81
         * @param symbol
82
         *            to persist
83
         * @param fileName
84
         *            of the file to create
85
         * @param folder
86
         *            where to create the file
87
         * @throws SymbolException
88
         *             if there is an error persisting the symbol, or the file to
89
         *             create already exists
90
         */
91
        void saveSymbol(ISymbol symbol, String fileName, File folder)
92
                        throws SymbolException;
93

    
94
        /**
95
         * Persists a {@link ISymbol} into the given folder, with the given file
96
         * name.
97
         * 
98
         * @param symbol
99
         *            to persist
100
         * @param fileName
101
         *            of the file to create
102
         * @param folder
103
         *            where to create the file
104
         * @param overwrite
105
         *            what to do if the file to create already exists
106
         * @throws SymbolException
107
         *             if there is an error persisting the symbol, or the file to
108
         *             create already exists and overwrite is false
109
         */
110
        void saveSymbol(ISymbol symbol, String fileName, File folder,
111
                        boolean overwrite) throws SymbolException;
112

    
113
        /**
114
         * Returns the current {@link SymbolPreferences}.
115
         * 
116
         * @return the current {@link SymbolPreferences}
117
         */
118
        SymbolPreferences getSymbolPreferences();
119

    
120
        /**
121
         * Creates a new {@link ISymbol}.
122
         * 
123
         * @param symbolName
124
         *            the name of the symbol to create
125
         * @return a new {@link ISymbol}
126
         * @throws MapContextRuntimeException
127
         *             if there is an error creating the symbol
128
         */
129
        ISymbol createSymbol(String symbolName) throws MapContextRuntimeException;
130

    
131
        /**
132
         * Creates a new {@link ISymbol} which can be used to render the given
133
         * {@link Geometry} type.
134
         * 
135
         * @param geomType
136
         *            the {@link Geometry} type to render
137
         * @return a new {@link ISymbol}
138
         * @throws MapContextRuntimeException
139
         *             if there is an error creating the symbol
140
         */
141
        ISymbol createSymbol(int geomType) throws MapContextRuntimeException;
142

    
143
        /**
144
         * Creates a new {@link ISymbol} with the given {@link Color}.
145
         * 
146
         * @param symbolName
147
         *            the name of the symbol to create
148
         * @param color
149
         *            the color for the symbol
150
         * @return a new {@link ISymbol}
151
         * @throws MapContextRuntimeException
152
         *             if there is an error creating the symbol
153
         */
154
        ISymbol createSymbol(String symbolName, Color color)
155
                        throws MapContextRuntimeException;
156

    
157
        /**
158
         * Creates a new {@link ISymbol} which can be used to render the given
159
         * {@link Geometry} type, with the given {@link Color}.
160
         * 
161
         * @param geomType
162
         *            the {@link Geometry} type to render
163
         * @param color
164
         *            the color for the symbol
165
         * @return a new {@link ISymbol}
166
         * @throws MapContextRuntimeException
167
         *             if there is an error creating the symbol
168
         */
169
        ISymbol createSymbol(int geomType, Color color)
170
                        throws MapContextRuntimeException;
171

    
172
        /**
173
         * Creates a new {@link IMultiLayerSymbol}.
174
         * 
175
         * @param symbolName
176
         *            the name of the symbol to create
177
         * @return a new {@link IMultiLayerSymbol}
178
         * @throws MapContextRuntimeException
179
         *             if there is an error creating the symbol
180
         */
181
        IMultiLayerSymbol createMultiLayerSymbol(String symbolName)
182
                        throws MapContextRuntimeException;
183

    
184
        /**
185
         * Creates a new {@link IMultiLayerSymbol} which can be used to render the
186
         * given {@link Geometry} type.
187
         * 
188
         * @param geomType
189
         *            the {@link Geometry} type to render
190
         * @return a new {@link IMultiLayerSymbol}
191
         * @throws MapContextRuntimeException
192
         *             if there is an error creating the symbol
193
         */
194
        IMultiLayerSymbol createMultiLayerSymbol(int geomType)
195
                        throws MapContextRuntimeException;
196

    
197
        /**
198
         * Registers a {@link ISymbol} implementation class with a name. This way
199
         * the symbol class is not related to any geometry type, so it can be
200
         * created only through the {@link #createSymbol(String)} method.
201
         * 
202
         * @param symbolName
203
         *            the symbol name
204
         * @param symbolClass
205
         *            the symbol implementation class
206
         * @throws MapContextRuntimeException
207
         *             if the provided class does not implement the ISymbol
208
         *             interface
209
         */
210
        void registerSymbol(String symbolName, Class symbolClass)
211
                        throws MapContextRuntimeException;
212

    
213
        /**
214
         * Registers a {@link ISymbol} implementation class with a name and a list
215
         * of geometry types which the symbol is able to render.
216
         * 
217
         * @param symbolName
218
         *            the symbol name
219
         * @param geomTypes
220
         *            the list of geometry types the symbol is able to render
221
         * @param symbolClass
222
         *            the symbol implementation class
223
         * @throws MapContextRuntimeException
224
         *             if the provided class does not implement the ISymbol
225
         *             interface
226
         */
227
        void registerSymbol(String symbolName, int[] geomTypes, Class symbolClass)
228
                        throws MapContextException;
229

    
230
        /**
231
         * Registers a {@link IMultiLayerSymbol} implementation class with a name.
232
         * This way the symbol class is not related to any geometry type, so it can
233
         * be created only through the {@link #createMultiLayerSymbol(String)}
234
         * method.
235
         * 
236
         * @param symbolName
237
         *            the symbol name
238
         * @param symbolClass
239
         *            the symbol implementation class
240
         * @throws MapContextRuntimeException
241
         *             if the provided class does not implement the
242
         *             {@link IMultiLayerSymbol} interface
243
         */
244
        void registerMultiLayerSymbol(String symbolName, Class symbolClass)
245
                        throws MapContextRuntimeException;
246

    
247
        /**
248
         * Registers a {@link IMultiLayerSymbol} implementation class with a name
249
         * and a list of geometry types which the symbol is able to render.
250
         * 
251
         * @param symbolName
252
         *            the symbol name
253
         * @param geomTypes
254
         *            the list of geometry types the symbol is able to render
255
         * @param symbolClass
256
         *            the symbol implementation class
257
         * @throws MapContextRuntimeException
258
         *             if the provided class does not implement the
259
         *             {@link IMultiLayerSymbol} interface
260
         */
261
        void registerMultiLayerSymbol(String symbolName, int[] geomTypes,
262
                        Class symbolClass) throws MapContextRuntimeException;
263

    
264
        /**
265
         * Returns an instance of {@link IWarningSymbol}.
266
         * 
267
         * TODO: revisar el uso de esto, a ver si es necesario o se puede ocultar
268
         * dentro de la implementaci?n.
269
         * 
270
         * @param message
271
         * @param symbolDesc
272
         * @param symbolDrawExceptionType
273
         * @return the warning symbol
274
         * @throws MapContextRuntimeException
275
         */
276
        IWarningSymbol getWarningSymbol(String message, String symbolDesc,
277
                        int symbolDrawExceptionType) throws MapContextRuntimeException;
278
        
279
        void setSymbolPreferences(SymbolPreferences symbolPreferences);
280

    
281
}