Statistics
| Revision:

gvsig-vectorediting / org.gvsig.vectorediting / trunk / org.gvsig.vectorediting / org.gvsig.vectorediting.lib / org.gvsig.vectorediting.lib.api / src / main / java / org / gvsig / vectorediting / lib / api / EditingService.java @ 2616

History | View | Annotate | Download (7.5 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.api;
26

    
27
import java.util.List;
28
import org.gvsig.fmap.dal.feature.EditableFeature;
29

    
30
import org.gvsig.fmap.dal.feature.FeatureStore;
31
import org.gvsig.fmap.geom.Geometry;
32
import org.gvsig.fmap.geom.primitive.Point;
33
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
34
import org.gvsig.tools.observer.Observable;
35
import org.gvsig.tools.service.Service;
36
import org.gvsig.vectorediting.lib.api.exceptions.DrawServiceException;
37
import org.gvsig.vectorediting.lib.api.exceptions.FinishServiceException;
38
import org.gvsig.vectorediting.lib.api.exceptions.InvalidEntryException;
39
import org.gvsig.vectorediting.lib.api.exceptions.StartServiceException;
40
import org.gvsig.vectorediting.lib.api.exceptions.StopServiceException;
41

    
42
/**
43
 * This service is used to interact with Editing providers. Each instance of
44
 * this has linked an Editing provider. At this moment services delegate all
45
 * functionality to providers. To get an instance of this use
46
 * {@link EditingManager#getEditingService(String, org.gvsig.fmap.dal.feature.FeatureStore)}
47
 * 
48
 * @author gvSIG team.
49
 */
50
public interface EditingService extends Service, Observable {
51

    
52
    public static final String PARAMETER_CHANGED2_NOTIFICATION = "EditingService.ParameterChanged2";
53
    public static final String ACTIVATE_NOTIFICATION = "EditingService.Activate";
54
    public static final String NEXT_NOTIFICATION = "EditingService.Next";
55
    public static final String PARAMETER_CHANGED1_NOTIFICATION = "EditingService.ParameterChanged1";
56
    public static final String STOP_NOTIFICATION = "EditingService.Stop";
57
    public static final String FINISH_AND_STORE_NOTIFICATION = "EditingService.FinishAndStore";
58
    public static final String FINISH_NOTIFICATION = "EditingService.Finish";
59
    public static final String START_NOTIFICATION = "EditingService.Start";
60

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

    
78
    /**
79
     * Gets a <code>List</code> with all parameters of service. Each parameter
80
     * has name, description and types. See {@link EditingServiceParameter}.
81
     *
82
     * @return A list of {@link EditingServiceParameter} objects.
83
     */
84
    public List<EditingServiceParameter> getParameters();
85

    
86
    /**
87
     * Gets next parameter needed by service. The parameter has information
88
     * about its name, description and types. Returns <code>null</code> if all
89
     * parameters have values.
90
     *
91
     * @return An {@link EditingServiceParameter} object that represents the
92
     *         next parameter.
93
     */
94
    public EditingServiceParameter next();
95

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

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

    
126
    /**
127
     * Stops service. Use this method to stop and clean values of service.
128
     *
129
     * @throws StopServiceException
130
     *             Stops service initializing necessary parameters of service.
131
     *             This method is called when user cancels service.
132
     */
133
    public void stop() throws StopServiceException;
134

    
135
    /**
136
     * Finalizes service. Use this method to get the result of service without
137
     * store it to {@link FeatureStore}. Make sure that service has all required
138
     * values.
139
     *
140
     * @return Geometry created or modified from added values.
141
     * @throws FinishServiceException
142
     *             if there are some error getting values,
143
     *             creating geometries.
144
     */
145
    public Geometry finish() throws FinishServiceException;
146

    
147
    /**
148
     * Finalizes service and stores the result to {@link FeatureStore} of this
149
     * service. Use this method to store the result of this service. Make sure
150
     * that service has all required values.
151
     *
152
     * @throws FinishServiceException
153
     *             if there are some error getting values,
154
     *             creating geometries or inserting/updating/removing geometries
155
     *             from feature store.
156
     */
157
    public void finishAndStore() throws FinishServiceException;
158

    
159
    /**
160
     * Starts service. Use this method before add values.
161
     *
162
     * @throws StartServiceException
163
     *             if there are some error starting service.
164
     * @throws InvalidEntryException
165
     *             if the entry of provider is not valid
166
     */
167
    public void start() throws StartServiceException, InvalidEntryException;
168

    
169
    /**
170
     * Gets service name. The name of service is the same name of linked
171
     * provider.
172
     *
173
     * @return Name of service.
174
     */
175
    public String getName();
176
    
177
    /**
178
     * Activate service
179
     */
180
    public void activate();
181
    
182
    /**
183
     * Return the parameter's value
184
     * 
185
     * @param parameter
186
     * @return
187
     */
188
    public Object getValue(EditingServiceParameter parameter);
189

    
190
    public void setDefaultFeatureValues(EditableFeature feature);
191
    
192
    public EditableFeature getDefaultFeatureValues();
193
    
194
    public FeatureStore getStore();
195
    
196
    public IVectorLegend getLegend();
197
    
198
    public String getDescription();
199
    
200
    public void setShowPreviewSymbol(boolean showPreviewSymbol);
201
    
202
}