Statistics
| Revision:

root / trunk / extensions / extDerivedGeometries / src / es / iver / derivedGeom / process / DerivedGeometryProcessParameters.java @ 27865

History | View | Annotate | Download (5.32 KB)

1
package es.iver.derivedGeom.process;
2

    
3
/* gvSIG. Geographic Information System of the Valencian Government
4
 *
5
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
6
 * of the Valencian Government (CIT)
7
 * 
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 * 
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *  
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
21
 * MA  02110-1301, USA.
22
 * 
23
 */
24

    
25
import java.io.File;
26

    
27
import com.iver.andami.PluginServices;
28
import com.iver.cit.gvsig.fmap.MapControl;
29
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
30
import com.iver.cit.gvsig.project.documents.view.gui.View;
31

    
32
/**
33
 *
34
 *
35
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
36
 */
37
public class DerivedGeometryProcessParameters {
38
        public static final short UNDEFINED_TYPE = -1;
39
        
40
        public static final String POINTS_TO_LINE_PROCESS_NAME = PluginServices.getText(null, "Points_to_line");
41
        public static final String POINTS_TO_POLYGON_PROCESS_NAME = PluginServices.getText(null, "Points_to_polygon");
42
        public static final String CLOSE_MULTILINE_PROCESS_NAME = PluginServices.getText(null, "Close_multiline");
43
        public static final String POINTS_TO_LINE_OR_POLYGON_NAME = PluginServices.getText(null, "PointsToLineOrPolygon");
44
        public static final short POINTS_TO_LINE_PROCESS_ID = 0;
45
        public static final short POINTS_TO_POLYGON_PROCESS_ID = 1;
46
        public static final short CLOSE_MULTILINE_PROCESS_ID = 2;
47
        public static final short POINTS_TO_LINE_OR_POLYGON_ID = 3;
48

    
49
        
50
        private MapControl mapControl;
51
        private FLyrVect sourceLayer;
52
        private File destinationFile;
53
        private String destinationLayerName;
54
        private long[][] geometryIndexes;
55
        private int destinationLayerShapeType = UNDEFINED_TYPE;
56
        private short processID = UNDEFINED_TYPE;
57
        private View view;
58
        private FLyrVect destLayer;
59
        
60
        public DerivedGeometryProcessParameters(FLyrVect source, File destinationFile, String destinationLayerName, long[][] geometryIndexes, short dType, View view, short processID) {
61
                this.sourceLayer = source;
62
                this.destinationFile = destinationFile;
63
                this.destinationLayerName = destinationLayerName;
64
                this.geometryIndexes = geometryIndexes;
65
                this.destinationLayerShapeType = dType;
66
                this.view = view;
67
                this.mapControl = view.getMapControl();
68
                this.processID = processID;
69
                this.destLayer = null;
70
        }
71
        
72
        public MapControl getMapControl() {
73
                return mapControl;
74
        }
75

    
76
        public FLyrVect getSourceLayer() {
77
                return sourceLayer;
78
        }
79

    
80
        public File getDestinationFile() {
81
                return destinationFile;
82
        }
83

    
84
        public String getDestinationLayerName() {
85
                return destinationLayerName;
86
        }
87
        
88
        /**
89
         * Lines to polygons -> only one row
90
         * Points to lines or polygons -> one row for each new geometry, with the points selected
91
         * 
92
         * @return
93
         */
94
        public long[][] getGeometryIndexes() {
95
                return geometryIndexes;
96
        }
97

    
98
        public int getDestinationLayerShapeType() {
99
                return destinationLayerShapeType;
100
        }
101
        
102
        public View getView() {
103
                return view;
104
        }
105
        
106
        public short getProcessID() {
107
                return processID;
108
        }
109
        
110
        public FLyrVect getDestLayer() {
111
                return destLayer;
112
        }
113

    
114
        public void setSourceLayer(FLyrVect sourceLayer) {
115
                this.sourceLayer = sourceLayer;
116
        }
117

    
118
        public void setDestinationFile(File destinationFile) {
119
                this.destinationFile = destinationFile;
120
        }
121

    
122
        public void setDestinationLayerName(String destinationLayerName) {
123
                this.destinationLayerName = destinationLayerName;
124
        }
125

    
126
        public void setGeometryIndexes(long[][] geometryIndexes) {
127
                this.geometryIndexes = geometryIndexes;
128
        }
129

    
130
        public void setDestinationLayerShapeType(int destinationLayerShapeType) {
131
                this.destinationLayerShapeType = destinationLayerShapeType;
132
        }
133

    
134
        public void setView(View view) {
135
                this.view = view;
136
        }
137
        
138
        public void setProcessID(short processID) {
139
                this.processID = processID;
140
        }
141
        
142
        public void setDestLayer(FLyrVect layer) {
143
                destLayer = layer;
144
        }
145
        
146
        public boolean requiredDefined() {
147
                return (sourceLayer != null) && (destinationFile != null) && (destinationLayerName != null) 
148
                && (destinationLayerShapeType != -1) && (view != null) && (mapControl != null);
149
        }
150
        
151
        public static String getProcessName(short processID) {
152
                switch (processID) {
153
                        case POINTS_TO_LINE_PROCESS_ID:
154
                                return POINTS_TO_LINE_PROCESS_NAME;
155
                        case POINTS_TO_POLYGON_PROCESS_ID:
156
                                return POINTS_TO_POLYGON_PROCESS_NAME;
157
                        case CLOSE_MULTILINE_PROCESS_ID:
158
                                return CLOSE_MULTILINE_PROCESS_NAME;
159
                        case POINTS_TO_LINE_OR_POLYGON_ID:
160
                                return POINTS_TO_LINE_OR_POLYGON_NAME;
161
                }
162
                
163
                return null;
164
        }
165
        
166
        public String getProcessName() {
167
                if (processID == UNDEFINED_TYPE)
168
                        return null;
169
                
170
                switch (processID) {
171
                        case POINTS_TO_LINE_PROCESS_ID:
172
                                return POINTS_TO_LINE_PROCESS_NAME;
173
                        case POINTS_TO_POLYGON_PROCESS_ID:
174
                                return POINTS_TO_POLYGON_PROCESS_NAME;
175
                        case CLOSE_MULTILINE_PROCESS_ID:
176
                                return CLOSE_MULTILINE_PROCESS_NAME;
177
                        case POINTS_TO_LINE_OR_POLYGON_ID:
178
                                return POINTS_TO_LINE_OR_POLYGON_NAME;
179
                }
180
                
181
                return null;
182
        }
183
}