Statistics
| Revision:

gvsig-vectorediting / org.gvsig.vectorediting / trunk / org.gvsig.vectorediting / org.gvsig.vectorediting.lib / org.gvsig.vectorediting.lib.spi / src / main / java / org / gvsig / vectorediting / lib / spi / EditingProvider.java @ 2870

History | View | Annotate | Download (7.08 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2014 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 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
 * 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
package org.gvsig.vectorediting.lib.spi;
26

    
27
import java.util.List;
28
import org.gvsig.fmap.dal.feature.EditableFeature;
29
import org.gvsig.fmap.dal.feature.FeatureStore;
30
import org.gvsig.fmap.geom.Geometry;
31
import org.gvsig.fmap.geom.primitive.Point;
32
import org.gvsig.tools.service.spi.Provider;
33
import org.gvsig.vectorediting.lib.api.DrawingStatus;
34
import org.gvsig.vectorediting.lib.api.EditingServiceParameter;
35
import org.gvsig.vectorediting.lib.api.exceptions.DrawServiceException;
36
import org.gvsig.vectorediting.lib.api.exceptions.FinishServiceException;
37
import org.gvsig.vectorediting.lib.api.exceptions.InvalidEntryException;
38
import org.gvsig.vectorediting.lib.api.exceptions.StartServiceException;
39
import org.gvsig.vectorediting.lib.api.exceptions.StopServiceException;
40

    
41
/**
42
 * EditingProvider provides functionalities to services.
43
 * 
44
 * @author gvSIG team.
45
 * @version $Id$
46
 */
47
public interface EditingProvider extends Provider {
48

    
49
    /**
50
     * Gets next parameter needed by provider. The parameter has information
51
     * about its name, description and types. Returns <code>null</code> if all
52
     * parameters have values.
53
     *
54
     * @return An {@link EditingServiceParameter} object that represents the
55
     *         next parameter.
56
     */
57
    public EditingServiceParameter next();
58

    
59
    /**
60
     * Gets state of drawing. If this provider has sufficient values with mouse
61
     * position to create geometries returns a {@link DrawingStatus}. List of
62
     * geometries of drawing status object can be different from final
63
     * geometries. Use this method to get a draft status information while user
64
     * is drawing.
65
     *
66
     * @param mousePosition
67
     *            Mouse position to draw geometries.
68
     * @return A {@link DrawingStatus} object with a list of geometries and
69
     *         information.
70
     * @throws DrawServiceException
71
     *             if there are some error creating geometries.
72
     */
73
    public DrawingStatus getDrawingStatus(Point mousePosition)
74
        throws DrawServiceException;
75

    
76
    /**
77
     * Stops provider. Use this method to stop and clean values of provider.
78
     *
79
     * @throws StopServiceException
80
     *             Stops provider initializing necessary parameters of provider.
81
     *             This method is called when user cancels provider.
82
     */
83
    public void stop() throws StopServiceException;
84

    
85
    /**
86
     * Gets a <code>List</code> with all parameters of provider. Each parameter
87
     * has name, description and types. See {@link EditingServiceParameter}.
88
     *
89
     * @return A list of {@link EditingServiceParameter} objects.
90
     */
91
    public List<EditingServiceParameter> getParameters();
92

    
93
    /**
94
     * Sets value to provider. The value will be put in the next parameter need
95
     * by this provider.
96
     *
97
     * @param value
98
     *            Object to be set to next {@link EditingServiceParameter}
99
     * @throws InvalidEntryException
100
     *             If the next parameter needed does not accept this value.
101
     */
102
    public void setValue(Object value) throws InvalidEntryException;
103

    
104
    /**
105
     * Sets value into a paremeter of the provider.The value will be put in the parameter of this provider.
106
     *
107
     * @param parameter {@link EditingServiceParameter}
108
     * @param value
109
     *            Object to be set to {@link EditingServiceParameter}
110
     * @throws InvalidEntryException
111
     *             If the next parameter needed does not accept this value.
112
     */
113
    public void setValue(EditingServiceParameter parameter, Object value) throws InvalidEntryException;
114
    
115
    /**
116
     * Return true if the parameter is enabled
117
     * 
118
     * @param parameter
119
     * @return
120
     */
121
    public boolean isEnabled(EditingServiceParameter parameter);
122

    
123
    /**
124
     * Finalizes provider. Use this method to get the result of provider without
125
     * store it to {@link FeatureStore}. Make sure that provider has all required
126
     * values.
127
     *
128
     * @return Geometry created or modified from added values.
129
     * @throws FinishServiceException
130
     *             if there are some error getting values,
131
     *             creating geometries.
132
     */
133
    public Geometry finish() throws FinishServiceException;
134

    
135
    /**
136
     * Finalizes provider and stores the result to {@link FeatureStore} of this
137
     * provider. Use this method to store the result of this service. Make sure
138
     * that service has all required values.
139
     *
140
     * @throws FinishServiceException
141
     *             if there are some error getting values,
142
     *             creating geometries or inserting/updating/removing geometries
143
     *             from feature store.
144
     */
145
    public void finishAndStore() throws FinishServiceException;
146

    
147
    /**
148
     * Starts provider. Use this method before add values.
149
     *
150
     * @throws StartServiceException
151
     *             if there are some error starting service.
152
     * @throws InvalidEntryException
153
     *             if the entry of provider is not valid 
154
     */
155
    public void start() throws StartServiceException, InvalidEntryException;
156

    
157
    /**
158
     * Gets provider name. 
159
     *
160
     * @return Name of provider.
161
     */
162
    public String getName();
163
    
164
    /**
165
     * Activete the provider
166
     */
167
    public void activate();
168
    
169
    /**
170
     * Return parameter's value
171
     * 
172
     * @param parameter
173
     * @return
174
     */
175
    public Object getValue(EditingServiceParameter parameter);
176
    
177
    /**
178
     * Return parameter's value of type
179
     * 
180
     * @param parameter
181
     * @param type
182
     * @return
183
     */
184
    public Object getValue(EditingServiceParameter parameter, EditingServiceParameter.TYPE type);
185

    
186

    
187
    public void setDefaultFeatureValues(EditableFeature feature);
188
    
189
    public EditableFeature getDefaultFeatureValues();
190
    
191
    public void setShowPreviewSymbol(boolean showPreviewSymbol);
192
    
193
    public boolean isShowPreviewSymbol();
194
    
195
    /**
196
     * Restarts provider.
197
     *
198
     * @throws StartServiceException
199
     *             if there are some error starting service.
200
     * @throws InvalidEntryException
201
     *             if the entry of provider is not valid 
202
     */
203
    public void restart() throws StartServiceException, InvalidEntryException, StopServiceException;
204

    
205
    public void initDefaultValues();
206

    
207
}