Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.fmap.control / src / main / java / org / gvsig / fmap / mapcontrol / MapControlManager.java @ 47779

History | View | Annotate | Download (10.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
/* gvSIG. Geographic Information System of the Valencian Government
25
*
26
* Copyright (C) 2007-2008 Infrastructures and Transports Department
27
* of the Valencian Government (CIT)
28
* 
29
* This program is free software; you can redistribute it and/or
30
* modify it under the terms of the GNU General Public License
31
* as published by the Free Software Foundation; either version 2
32
* of the License, or (at your option) any later version.
33
* 
34
* This program is distributed in the hope that it will be useful,
35
* but WITHOUT ANY WARRANTY; without even the implied warranty of
36
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
* GNU General Public License for more details.
38
* 
39
* You should have received a copy of the GNU General Public License
40
* along with this program; if not, write to the Free Software
41
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
42
* MA  02110-1301, USA.
43
* 
44
*/
45

    
46
/*
47
* AUTHORS (In addition to CIT):
48
* 2009 {Iver T.I.}   {Task}
49
*/
50
 
51
package org.gvsig.fmap.mapcontrol;
52

    
53
import java.util.Map;
54
import java.util.function.Predicate;
55
import java.util.function.Supplier;
56
import java.util.prefs.Preferences;
57
import javax.swing.JButton;
58
import javax.swing.JComboBox;
59
import javax.swing.JTextField;
60
import javax.swing.JToggleButton;
61
import javax.swing.text.JTextComponent;
62
import javax.swing.tree.TreeModel;
63
import org.cresques.cts.IProjection;
64
import org.gvsig.fmap.dal.DataStore;
65
import org.gvsig.fmap.geom.Geometry;
66
import org.gvsig.fmap.geom.primitive.Envelope;
67

    
68
import org.gvsig.fmap.mapcontext.MapContext;
69
import org.gvsig.fmap.mapcontext.layers.FLayers;
70
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
71
import org.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent;
72
import org.gvsig.fmap.mapcontrol.swing.pickercontroller.impl.EnvelopePickerControllerImpl;
73
import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapper;
74
import org.gvsig.tools.dynobject.DynObject;
75
import org.gvsig.tools.dynobject.DynObjectSet;
76
import org.gvsig.tools.swing.api.pickercontroller.PickerController;
77

    
78
/**
79
 * <p>
80
 * This class is the manager of the MapControl library. It is used to
81
 * manage all the properties related with the drawing of objects 
82
 * in a map, including default symbols used to draw objects
83
 * in a map, the tolerance used by the selection or edition tools...
84
 * </p>
85
 * <p>
86
 * It also holds the implementations of the {@link MapControlDrawer}'s, 
87
 * that is the responsible to draw graphical objects in a map.
88
 * </p> 
89
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
90
 */
91
public interface MapControlManager {
92

    
93
        public MapControl createJMapControlPanel(MapContext mapContext) throws MapControlCreationException;
94
          
95
    public void addMapControlCreationListener(MapControlCreationListener listener);
96
        
97
        /**
98
         * Register a <code>MapControlDrawer</code> by name.
99
         * @param name
100
         * Name of the <code>MapControlDrawer</code>.
101
         * @param mapControolDrawerClass
102
         * Class used to draw graphical objects on a map.
103
         */
104
        public void registerMapControlDrawer(String name, Class mapControolDrawerClass);
105
        
106
        /**
107
         * Creates a <code>MapControlDrawer</code> from a name.
108
         * @param name
109
         * Name of the <code>MapControlDrawer</code>.
110
         * @return
111
         * A <code>MapControlDrawer</code>.
112
         * @throws MapControlCreationException
113
         */
114
        public MapControlDrawer createMapControlDrawer(String name) throws MapControlCreationException;
115
        
116
        /**
117
         * It registers the default implementation for the <code>MapControlDrawer</code>.
118
         * @param mapControlDrawerClass
119
         * A <code>MapControlDrawer</code>. 
120
         */
121
        public void registerDefaultMapControlDrawer(Class mapControlDrawerClass);
122
        
123
        /**
124
         * It returns the default implementation for the <code>MapControlDrawer</code>.
125
         * @return
126
         * The default <code>MapControlDrawer</code>.
127
         * @throws MapControlCreationException
128
         */
129
        public MapControlDrawer createDefaultMapControlDrawer() throws MapControlCreationException;
130
        
131
        /**
132
         * Returns a snapper in a concrete position;
133
         * @param index
134
         * Snapper position.
135
         * @return
136
         * A snapper. 
137
         */
138
        public ISnapper getSnapperAt(int index);
139
        
140
        /**
141
         * Returns the number of registered snappers.
142
         * @return
143
         * The number of registered snappers.
144
         */
145
        public int getSnapperCount();
146
        
147
        /**
148
         * Add a snapper.
149
         * @param snapper
150
         */
151
        public void registerSnapper(String name, Class snapperClass);
152
        
153
        
154
        public Preferences getEditionPreferences();
155
        
156
        /**
157
         * Tolerance (in pixels) that has to be used by the tools
158
         * that use snapping.
159
         * @return
160
         * The distance in pixels.
161
         */
162
        public int getTolerance();
163
        
164
        /**
165
         * Sets the tolerance (in pixels) that has to be used by the
166
         * tools that use snapping.
167
         * @param tolerance
168
         * The tolerance to apply
169
         */
170
        public void setTolerance(int tolerance);
171
        
172
        /**
173
         * Sets the symbol that has to be used to draw a geometry when
174
         * it is selected.
175
         * @param selectionSymbol
176
         * The symbol to apply.
177
         * @deprecated the symbol for edition is the selection symbol
178
         */
179
        public void setSelectionSymbol(ISymbol selectionSymbol);
180
        
181
        /**
182
         * Gets the symbol used to draw the selected geometries.
183
         * @return
184
         * The symbol used to draw the selected geometries.
185
         * @deprecated the symbol for edition is the selection symbol
186
         */
187
        public ISymbol getSelectionSymbol();
188
        
189
        /**
190
         * Sets the symbol that has to be used to draw a geometry that
191
         * represent the axis of a geometry.
192
         * @param axisReferencesSymbol
193
         * The symbol to apply.
194
         */
195
        public void setAxisReferenceSymbol(ISymbol axisReferencesSymbol);
196
        
197
        /**
198
         * Gets the symbol used to draw the axis of a geometry.
199
         * @return
200
         * The symbol used to draw the axis of a geometry.
201
         */
202
        public ISymbol getAxisReferenceSymbol();
203
        
204
        /**
205
         * Sets the symbol that has to be used to draw a geometry when
206
         * it is selected.
207
         * @param geometrySelectionSymbol
208
         * The symbol to apply.
209
         */
210
        public void setGeometrySelectionSymbol(ISymbol geometrySelectionSymbol);
211
        
212
        /**
213
         * Gets the symbol used to draw the selected geometries.
214
         * @return
215
         * The symbol used to draw the selected geometries.
216
         */
217
        public ISymbol getGeometrySelectionSymbol();
218
        
219
        /**
220
         * Sets the symbol that has to be used to draw the handlers.
221
         * @param handlerSymbol
222
         * The symbol to apply.
223
         */
224
        public void setHandlerSymbol(ISymbol handlerSymbol);
225
        
226
        /**
227
         * Gets the symbol used to draw the handlers.
228
         * @return
229
         * The symbol used to draw the handlers.
230
         */
231
        public ISymbol getHandlerSymbol();
232

    
233
    /**
234
     * Creates a readonly component to view information of a set of layers. The
235
     * information must be provided as a set of {@link DynObject}s, through a
236
     * {@link DynObjectSet}.
237
     * 
238
     * @param layerName2InfoByPoint
239
     *            the map of {@link DynObjectSet} for each layer.
240
     * @return the component to view the information
241
     */
242
    public LayersDynObjectSetComponent createLayersDynObjectSetComponent(
243
        Map<String, DynObjectSet> layerName2InfoByPoint);
244

    
245
    /**
246
     * Creates a component to view information of a set of layers. The
247
     * information must be provided as a set of {@link DynObject}s, through a
248
     * {@link DynObjectSet}.
249
     * 
250
     * @param layerName2InfoByPoint
251
     *            the map of {@link DynObjectSet} for each layer.
252
     * @param writable
253
     *            if the DynObjects loaded must be able to be edited
254
     * @return the component to view the information
255
     */
256
    public LayersDynObjectSetComponent createLayersDynObjectSetComponent(
257
        Map<String, DynObjectSet> layerName2InfoByPoint, boolean writable);
258
    
259
    /**
260
     * Create a TreeModel based in the MapControl's layers.
261
     * 
262
     * @param mapContext
263
     * @return the TreeModel 
264
     */
265
    public TreeModel createLayersTreeModel(MapContext mapContext);
266
    
267
    /**
268
     * Create a TreeModel based in the layers collection.
269
     * @param layers the layers collection to use for create the TreeModel
270
     * @return the TreeModel
271
     */
272
    public TreeModel createLayersTreeModel(FLayers layers);
273
    
274
    /**
275
     * Create a TreeModel based in the layers collection of all project's views.
276
     * @return the TreeModel
277
     */
278
    public TreeModel createCompoundLayersTreeModel();
279

    
280
    public CompoundStoresTreeModel createCompoundStoresTreeModel();
281
    
282
    public double perimeter(Geometry geom, IProjection proj, int distanceUnits);
283
    
284
    public double area(Geometry geom, IProjection proj, int areaUnits);
285
    
286
    public PickerController<Envelope> createEnvelopePickerController(
287
            MapControl mapControl,
288
            JTextField txtUpperLeftX, 
289
            JTextField txtUpperLeftY, 
290
            JTextField txtLowerRightX, 
291
            JTextField txtLowerRightY, 
292
            JButton btnMapControlEnvelope, 
293
            JToggleButton btnCapture
294
    );
295
    
296
    public PickerController<Envelope> createEnvelopePickerController(
297
            MapControl mapControl,
298
            JTextComponent txtEnvelope, 
299
            JButton btnMapControlEnvelope, 
300
            final JToggleButton btnCapture
301
    );
302

    
303
    public PickerController<Envelope> createEnvelopePickerController(
304
            Supplier<MapControl> mapControl,
305
            JTextComponent txtEnvelope, 
306
            JButton btnMapControlEnvelope, 
307
            final JToggleButton btnCapture
308
    );
309

    
310
    public PickerController<Double> createScalePickerController(
311
            MapControl mapControl,
312
            JComboBox cboScale, 
313
            JButton btnMapControlScale, 
314
            final JToggleButton btnCapture
315
    );
316
}
317