Revision 5329

View differences:

org.gvsig.topology/tags/org.gvsig.topology-1.0.87/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/buildNumber.properties
1
#Mon Jan 10 01:32:59 CET 2022
2
buildNumber=93
org.gvsig.topology/tags/org.gvsig.topology-1.0.87/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/src/main/java/org/gvsig/topology/app/mainplugin/DataSetsTreeModel.java
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
package org.gvsig.topology.app.mainplugin;
25

  
26
import java.util.Map;
27
import javax.swing.ImageIcon;
28
import javax.swing.event.TreeModelListener;
29
import javax.swing.tree.TreeModel;
30
import javax.swing.tree.TreePath;
31
import org.gvsig.andami.IconThemeHelper;
32
import org.gvsig.app.project.documents.view.ViewDocument;
33
import org.gvsig.fmap.dal.DALLocator;
34
import org.gvsig.fmap.dal.DataManager;
35
import org.gvsig.fmap.dal.DataStore;
36
import org.gvsig.fmap.mapcontext.MapContextLocator;
37
import org.gvsig.fmap.mapcontext.layers.FLayer;
38
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer;
39
import org.gvsig.fmap.mapcontrol.CompoundLayersTreeModel;
40
import org.gvsig.fmap.mapcontrol.MapControlLocator;
41
import org.gvsig.tools.swing.api.ListElement;
42
import org.gvsig.topology.lib.api.TopologyDataSet;
43
import org.gvsig.topology.lib.api.TopologyLocator;
44
import org.gvsig.topology.swing.api.TopologySwingServices;
45

  
46
/**
47
 *
48
 * @author jjdelcerro
49
 */
50
public class DataSetsTreeModel implements TreeModel {
51

  
52
    private final ViewDocument view;
53
    private final CompoundLayersTreeModel deletaged;
54
    private final TopologySwingServices services;
55
    private final ListElement<Object> root;
56
    
57
    public DataSetsTreeModel(TopologySwingServices services, ViewDocument view) {
58
        this.services = services;
59
        CompoundLayersTreeModel model = (CompoundLayersTreeModel) MapControlLocator.getMapControlManager().createCompoundLayersTreeModel();
60
        this.view = view;
61
        if( view!=null ) {
62
            model.addLayers(view.getMapContext().getLayers());
63
        }
64
        this.deletaged = model;
65
        this.root = new ListElement<>("Project", this.deletaged.getRoot());
66
                
67
    }
68
    
69
    private Object getNode(Object value) {
70
        if( value instanceof ListElement ) {
71
            return ((ListElement) value).getValue();
72
        }
73
        return value;
74
    }
75
    
76
    @Override
77
    public Object getRoot() {
78
        return this.root;
79
    }
80

  
81
    @Override
82
    public Object getChild(Object parent, int index) {
83
        parent = this.getNode(parent);
84
        Object x = this.deletaged.getChild(parent, index);
85
        if( x instanceof SingleLayer ) {
86
            SingleLayer layer = (SingleLayer)x;
87
            DataStore store = layer.getDataStore();
88
            x = TopologyLocator.getTopologyManager().createDataSet(
89
                    layer.getName(),
90
                    store
91
            );
92
        }
93
        return x;
94
    }
95

  
96
    @Override
97
    public int getChildCount(Object parent) {
98
        parent = this.getNode(parent);
99
        return this.deletaged.getChildCount(parent);
100
    }
101

  
102
    @Override
103
    public boolean isLeaf(Object node) {
104
        node = this.getNode(node);
105
        return this.deletaged.isLeaf(node);
106
    }
107

  
108
    @Override
109
    public void valueForPathChanged(TreePath path, Object newValue) {
110
        this.deletaged.valueForPathChanged(path, newValue);
111
    }
112

  
113
    @Override
114
    public int getIndexOfChild(Object parent, Object child) {
115
        parent = this.getNode(parent);
116
        return this.deletaged.getIndexOfChild(parent, child);
117
    }
118

  
119
    @Override
120
    public void addTreeModelListener(TreeModelListener l) {
121
        this.deletaged.addTreeModelListener(l);
122
    }
123

  
124
    @Override
125
    public void removeTreeModelListener(TreeModelListener l) {
126
        this.deletaged.removeTreeModelListener(l);
127
    }
128

  
129
    public ImageIcon getTreeIcon(Object item) {
130
        if( this.getRoot()==item ) {
131
            return IconThemeHelper.getImageIcon("topology-tree-project");
132
        }
133
        if (item instanceof ListElement) {
134
            item = ((ListElement) item).getValue();
135
        }
136
        if( this.view!=null && this.view.getMapContext().getLayers()==item ) {
137
            return IconThemeHelper.getImageIcon("document-view-tree-icon");
138
        }
139
        if (item instanceof TopologyDataSet) {
140
            DataStore store = ((TopologyDataSet)item).getStore();
141
            String iconName = MapContextLocator.getMapContextManager().getIconLayer(store);
142
            return IconThemeHelper.getImageIcon(iconName);
143
        }
144
        if (item instanceof FLayer) {
145
            String iconName = ((FLayer) item).getTocImageIcon();
146
            return IconThemeHelper.getImageIcon(iconName);
147
        }
148
        return IconThemeHelper.getImageIcon("topology-tree-folder");
149
    }
150
    
151
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.87/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/src/main/java/org/gvsig/topology/app/mainplugin/TopologyExtension.java
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
package org.gvsig.topology.app.mainplugin;
25

  
26
import java.awt.event.ActionEvent;
27
import java.io.File;
28
import java.io.IOException;
29
import java.nio.charset.StandardCharsets;
30
import javax.swing.AbstractAction;
31
import static javax.swing.Action.ACTION_COMMAND_KEY;
32
import static javax.swing.Action.NAME;
33
import javax.swing.JFileChooser;
34
import javax.swing.JOptionPane;
35
import javax.swing.filechooser.FileFilter;
36
import org.apache.commons.io.FileUtils;
37
import org.apache.commons.io.FilenameUtils;
38
import org.apache.commons.lang.StringUtils;
39
import org.gvsig.andami.IconThemeHelper;
40
import org.gvsig.andami.plugins.Extension;
41
import org.gvsig.app.ApplicationLocator;
42
import org.gvsig.app.ApplicationManager;
43
import org.gvsig.app.project.Project;
44
import org.gvsig.configurableactions.ConfigurableActionsMamager;
45
import org.gvsig.filedialogchooser.FileDialogChooser;
46
import org.gvsig.filedialogchooser.FileDialogChooserManager;
47
import org.gvsig.json.Json;
48
import org.gvsig.tools.ToolsLocator;
49
import org.gvsig.tools.i18n.I18nManager;
50
import org.gvsig.tools.swing.api.ToolsSwingLocator;
51
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager;
52
import org.gvsig.tools.swing.api.windowmanager.Dialog;
53
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
54
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2;
55
import org.gvsig.tools.util.ToolsUtilLocator;
56
import org.gvsig.topology.lib.api.TopologyLocator;
57
import org.gvsig.topology.lib.api.TopologyManager;
58
import org.gvsig.topology.lib.api.TopologyPlan;
59
import org.gvsig.topology.swing.api.JTopologyPlanProperties;
60
import org.gvsig.topology.swing.api.JTopologyReport;
61
import org.gvsig.topology.swing.api.TopologySwingLocator;
62
import org.gvsig.topology.swing.api.TopologySwingManager;
63

  
64
/**
65
 *
66
 * @author gvSIG Team
67
 */
68
@SuppressWarnings("UseSpecificCatch")
69
public class TopologyExtension extends Extension {
70

  
71
    public static final String TOPOLOGYPLAN_FILE_EXTENSION = "gvtoplan";
72
    
73
    @Override
74
    public void initialize() {
75
        
76
    }
77

  
78
    @Override
79
    public void postInitialize() {
80
        AppTopologyServices services = new AppTopologyServices();
81
        
82
        TopologyManager manager = TopologyLocator.getTopologyManager();
83
        manager.setDefaultServices(services);
84
        
85
        TopologySwingManager swingManager = TopologySwingLocator.getTopologySwingManager();
86
        swingManager.setDefaultServices(services);
87
  
88
        IconThemeHelper.registerIcon("document", "document-view-tree-icon", this);
89
        IconThemeHelper.registerIcon("topology", "topology-tree-folder", this);
90
        IconThemeHelper.registerIcon("topology", "topology-tree-project", this);
91
        
92
        ConfigurableActionsMamager cfgActionsManager = ToolsUtilLocator.getConfigurableActionsMamager();
93
        cfgActionsManager.addConfigurableAction(JTopologyPlanProperties.CONFIGURABLE_PANEL_ID, new SaveTopologyPlan());
94
        cfgActionsManager.addConfigurableAction(JTopologyPlanProperties.CONFIGURABLE_PANEL_ID, new LoadTopologyPlan());
95
    }
96

  
97
    
98
    @Override
99
    public void execute(String action) {
100
        if( StringUtils.equalsIgnoreCase("tools-topology-create-or-modify", action) ) {
101
            I18nManager i18n = ToolsLocator.getI18nManager();
102
            ApplicationManager application = ApplicationLocator.getManager();
103
            
104
            TopologyManager manager = TopologyLocator.getTopologyManager();
105
            TopologySwingManager swingManager = TopologySwingLocator.getTopologySwingManager();
106
            WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
107
            
108
            final JTopologyPlanProperties panel = swingManager.createJTopologyPlan();
109

  
110
            TopologyPlan plan = getCurrentTopologyPlan();
111
            if( plan == null ) {
112
                plan = manager.createTopologyPlan();
113
            }
114
            panel.put(plan);
115
            
116
            final Dialog dlg = winManager.createDialog(
117
                    panel.asJComponent(),
118
                    i18n.getTranslation("_Topology_plan"),
119
                    null, 
120
                    WindowManager_v2.BUTTONS_APPLY_OK_CANCEL
121
            );
122
            dlg.setButtonLabel(WindowManager_v2.BUTTON_APPLY, i18n.getTranslation("_Execute"));
123
            dlg.addActionListener((ActionEvent e) -> {
124
                TopologyPlan plan1;
125
                switch(dlg.getAction()) {
126
                    case WindowManager_v2.BUTTON_OK:
127
                        plan1 = panel.fetch(null);
128
                        setCurrentTopologyPlan(plan1);
129
                        break;
130
                    case WindowManager_v2.BUTTON_APPLY:
131
                        plan1 = panel.fetch(null);
132
                        setCurrentTopologyPlan(plan1);
133
                        JTopologyReport jreport = swingManager.createJTopologyReport(plan1);
134
                        jreport.put(plan1);
135
                        winManager.showWindow(
136
                                jreport.asJComponent(), 
137
                                i18n.getTranslation("_Topology_plan_error_inspector") + " ("+plan1.getName()+")",
138
                                WindowManager.MODE.TOOL
139
                        );
140
                        Thread th = new Thread(() -> {
141
                            plan1.execute();
142
                        }, "TopologyPlan-"+ plan1.getName());
143
                        th.start();
144
                        break;
145
                }
146
            });
147
            dlg.show(WindowManager.MODE.WINDOW);
148

  
149
        } else if( StringUtils.equalsIgnoreCase("tools-topology-execute", action) ) {
150
            I18nManager i18n = ToolsLocator.getI18nManager();
151
            final TopologySwingManager swingManager = TopologySwingLocator.getTopologySwingManager();
152
            final WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
153
            
154

  
155
            final TopologyPlan plan = getCurrentTopologyPlan();
156
            if( plan == null ) {
157
                // TODO: Mensaje de crear plan
158
                return;
159
            }
160
            JTopologyReport panel = swingManager.createJTopologyReport(plan);
161
            panel.put(plan);
162
            winManager.showWindow(
163
                    panel.asJComponent(), 
164
                    i18n.getTranslation("_Topology_plan_error_inspector") + " ("+plan.getName()+")",
165
                    WindowManager.MODE.TOOL
166
            );
167

  
168
            Thread th = new Thread(() -> {
169
                plan.execute();
170
            }, "TopologyPlan-"+ plan.getName());
171
            th.start();
172
        }
173
    }
174

  
175
    
176
    private static String getCurrentTopologyPlanAsJson() {
177
        ApplicationManager application = ApplicationLocator.getManager();
178
//        final ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
179
//        if( view==null ) {
180
//            return null;
181
//        }
182
//        String jsonPlan = (String) view.getProperty("TopologyPlan");
183
        Project project = application.getCurrentProject();
184
        String jsonPlan = (String) project.getProperty("TopologyPlan");
185
        return jsonPlan;
186
    }
187
    
188
    private static boolean setCurrentTopologyPlan(String jsonPlan) {
189
        ApplicationManager application = ApplicationLocator.getManager();
190
//        final ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
191
//        if( view==null ) {
192
//            return false;
193
//        }
194
//        view.setProperty("TopologyPlan", jsonPlan);
195
        Project project = application.getCurrentProject();
196
        project.setProperty("TopologyPlan", jsonPlan);
197
        return true;
198
    }
199
    
200
    public static TopologyPlan getCurrentTopologyPlan() {
201
        String jsonPlan_s = getCurrentTopologyPlanAsJson();
202
        if( StringUtils.isBlank(jsonPlan_s) ) {
203
            return null;
204
        }
205
        try {
206
            TopologyManager manager = TopologyLocator.getTopologyManager();
207
            TopologyPlan plan = manager.createTopologyPlan();
208
            plan.fromJson(Json.createObject(jsonPlan_s));
209
            return plan;
210
        } catch (Exception ex) {
211
            throw new RuntimeException("Can't retrieve topology plan from json.",ex);
212
        }
213
    }
214
    
215
    public static boolean setCurrentTopologyPlan(TopologyPlan plan) {
216
        return setCurrentTopologyPlan(plan.toJson().toString());
217
    }
218
    
219
    @Override
220
    public boolean isEnabled() {
221
//        ApplicationManager application = ApplicationLocator.getManager();
222
//        Document view = application.getActiveDocument(ViewManager.TYPENAME);
223
//        return view!=null;
224
        return true;
225
    }
226

  
227
    @Override
228
    public boolean isVisible() {
229
        return true;
230
    }
231

  
232
    private static class SaveTopologyPlan extends AbstractAction {
233
    
234
        @SuppressWarnings("OverridableMethodCallInConstructor")
235
        public SaveTopologyPlan() {
236
            I18nManager i18n = ToolsLocator.getI18nManager();
237

  
238
            this.putValue(NAME, i18n.getTranslation("_Save_topology_plan"));
239
            this.putValue(ACTION_COMMAND_KEY, "SaveTopologyPLanToFile");
240
        }
241

  
242
        @Override
243
        public void actionPerformed(ActionEvent e) {
244
            final I18nManager i18n = ToolsLocator.getI18nManager();
245

  
246
            JTopologyPlanProperties panel = (JTopologyPlanProperties) e.getSource();
247
            TopologyPlan plan = panel.fetch(null);
248
            
249
            // _Select_topology_plan_file
250
            // Select topology plan file
251
            // Seleccionar archivo de plan de topología 
252
            
253
            FileDialogChooserManager fileDislogs = ToolsUtilLocator.getFileDialogChooserManager();
254
            FileDialogChooser dialog = fileDislogs.create("TopologyPlan");
255
            dialog.setCurrentDirectory(null);
256
            dialog.setDialogTitle(i18n.getTranslation("_Select_topology_plan_file"));
257
            dialog.setMultiSelectionEnabled(false);
258
            dialog.addChoosableFileFilter(new FileFilter() {
259
                @Override
260
                public boolean accept(File f) {
261
                    return f.getName().endsWith(","+TOPOLOGYPLAN_FILE_EXTENSION);
262
                }
263

  
264
                @Override
265
                public String getDescription() {
266
                    final I18nManager i18n = ToolsLocator.getI18nManager();
267
                    return i18n.getTranslation("_Topology_plan");
268
                }
269
            });
270
            int n = dialog.showSaveDialog(panel.asJComponent());
271
            if( n == JFileChooser.APPROVE_OPTION ) {
272
                File file = dialog.getSelectedFile();
273
                if( FilenameUtils.indexOfExtension(file.getName())<0 ) {
274
                    file = new File(file.getAbsolutePath()+"."+TOPOLOGYPLAN_FILE_EXTENSION);
275
                }
276
                try {
277
                    String fcontents = plan.toJson().toString();
278
                    FileUtils.write(file, fcontents, StandardCharsets.UTF_8);
279
                } catch (IOException ex) {
280
                    logger.warn("Can't save topology plan",ex);
281
                    ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager();
282
                    dialogs.messageDialog(
283
                            i18n.getTranslation("_Cant_save_topology_plan"), 
284
                            i18n.getTranslation("_Topology_plan"), 
285
                            JOptionPane.WARNING_MESSAGE
286
                    );
287
                }
288
            }
289
        }
290
    }
291

  
292
    private static class LoadTopologyPlan extends AbstractAction {
293
    
294
        @SuppressWarnings("OverridableMethodCallInConstructor")
295
        public LoadTopologyPlan() {
296
            I18nManager i18n = ToolsLocator.getI18nManager();
297

  
298
            this.putValue(NAME, i18n.getTranslation("_Load_topology_plan"));
299
            this.putValue(ACTION_COMMAND_KEY, "LoadTopologyPLanFromFile");
300
        }
301

  
302
        @Override
303
        public void actionPerformed(ActionEvent e) {
304
            final I18nManager i18n = ToolsLocator.getI18nManager();
305

  
306
            JTopologyPlanProperties panel = (JTopologyPlanProperties) e.getSource();
307
            
308
            FileDialogChooserManager fileDislogs = ToolsUtilLocator.getFileDialogChooserManager();
309
            FileDialogChooser dialog = fileDislogs.create("TopologyPlan");
310
            dialog.setCurrentDirectory(null);
311
            dialog.setDialogTitle(i18n.getTranslation("_Select_topology_plan_file"));
312
            dialog.setMultiSelectionEnabled(false);
313
            dialog.addChoosableFileFilter(new FileFilter() {
314
                @Override
315
                public boolean accept(File f) {
316
                    if( f.isDirectory() ) {
317
                        return true;
318
                    }
319
                    return FilenameUtils.isExtension(f.getName(), TOPOLOGYPLAN_FILE_EXTENSION);
320
                }
321

  
322
                @Override
323
                public String getDescription() {
324
                    return "Topology plan ("+TOPOLOGYPLAN_FILE_EXTENSION+")";
325
                }
326
            });
327
            int n = dialog.showOpenDialog(panel.asJComponent());
328
            if( n == JFileChooser.APPROVE_OPTION ) {
329
                File file = dialog.getSelectedFile();
330
                try {
331
                    String fcontents = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
332
                    TopologyManager manager = TopologyLocator.getTopologyManager();
333
                    TopologyPlan plan = manager.createTopologyPlan();
334
                    plan.fromJson(Json.createObject(fcontents));
335
                    panel.put(plan);
336
                } catch (IOException ex) {
337
                    logger.warn("Can't load topology plan",ex);
338
                    ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager();
339
                    dialogs.messageDialog(
340
                            i18n.getTranslation("_Cant_load_topology_plan"), 
341
                            i18n.getTranslation("_Topology_plan"), 
342
                            JOptionPane.WARNING_MESSAGE
343
                    );
344
                }
345
            }
346
        }
347
    }
348
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.87/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/src/main/java/org/gvsig/topology/app/mainplugin/AppTopologyServices.java
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
package org.gvsig.topology.app.mainplugin;
25

  
26
import java.io.File;
27
import java.util.ArrayList;
28
import java.util.Collections;
29
import java.util.HashMap;
30
import java.util.Iterator;
31
import java.util.List;
32
import java.util.Map;
33
import java.util.function.Predicate;
34
import javax.swing.DefaultListModel;
35
import javax.swing.ImageIcon;
36
import javax.swing.ListModel;
37
import javax.swing.tree.TreeModel;
38
import org.apache.commons.lang.StringUtils;
39
import org.apache.commons.lang3.mutable.Mutable;
40
import org.apache.commons.lang3.mutable.MutableObject;
41
import org.gvsig.andami.PluginsLocator;
42
import org.gvsig.app.ApplicationLocator;
43
import org.gvsig.app.ApplicationManager;
44
import org.gvsig.app.project.Project;
45
import org.gvsig.app.project.documents.Document;
46
import org.gvsig.app.project.documents.table.TableDocument;
47
import org.gvsig.app.project.documents.table.TableManager;
48
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
49
import org.gvsig.app.project.documents.view.ViewDocument;
50
import org.gvsig.app.project.documents.view.ViewManager;
51
import org.gvsig.app.project.documents.view.gui.IView;
52
import org.gvsig.fmap.dal.EditingNotification;
53
import org.gvsig.fmap.dal.EditingNotificationManager;
54
import org.gvsig.fmap.dal.exception.DataException;
55
import org.gvsig.fmap.dal.feature.FeatureReference;
56
import org.gvsig.fmap.dal.feature.FeatureSelection;
57
import org.gvsig.fmap.dal.feature.FeatureStore;
58
import org.gvsig.fmap.dal.swing.DALSwingLocator;
59
import org.gvsig.fmap.geom.Geometry;
60
import org.gvsig.fmap.geom.aggregate.MultiCurve;
61
import org.gvsig.fmap.geom.aggregate.MultiPoint;
62
import org.gvsig.fmap.geom.aggregate.MultiSurface;
63
import org.gvsig.fmap.geom.primitive.Curve;
64
import org.gvsig.fmap.geom.primitive.Envelope;
65
import org.gvsig.fmap.geom.primitive.Point;
66
import org.gvsig.fmap.geom.primitive.Surface;
67
import org.gvsig.fmap.mapcontext.MapContext;
68
import org.gvsig.fmap.mapcontext.MapContextLocator;
69
import org.gvsig.fmap.mapcontext.ViewPort;
70
import org.gvsig.fmap.mapcontext.events.ColorEvent;
71
import org.gvsig.fmap.mapcontext.events.ExtentEvent;
72
import org.gvsig.fmap.mapcontext.events.ProjectionEvent;
73
import org.gvsig.fmap.mapcontext.events.listeners.ViewPortListener;
74
import org.gvsig.fmap.mapcontext.layers.FLayer;
75
import org.gvsig.fmap.mapcontext.layers.FLayers;
76
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
77
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer;
78
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
79
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol_v2;
80
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor;
81
import org.gvsig.tools.dynobject.DynObject;
82
import org.gvsig.tools.observer.Observable;
83
import org.gvsig.tools.observer.Observer;
84
import org.gvsig.tools.visitor.VisitCanceledException;
85
import org.gvsig.topology.lib.api.TopologyDataSet;
86
import org.gvsig.topology.lib.api.TopologyLocator;
87
import org.gvsig.topology.lib.api.TopologyManager;
88
import org.gvsig.topology.swing.api.TopologySwingServices;
89
import org.slf4j.Logger;
90
import org.slf4j.LoggerFactory;
91

  
92
/**
93
 *
94
 * @author jjdelcerro
95
 */
96
@SuppressWarnings("UseSpecificCatch")
97
public class AppTopologyServices implements TopologySwingServices {
98

  
99
    private static final Logger LOGGER = LoggerFactory.getLogger(AppTopologyServices.class);
100

  
101
    private class WorkingAreaViewPortListener implements ViewPortListener {
102

  
103
        private final WorkingAreaChangedListener workingAreaChangedListener;
104
        private final ViewPort viewPort;
105

  
106
        public WorkingAreaViewPortListener(ViewPort viewPort, WorkingAreaChangedListener workingAreaChangedListener) {
107
            this.workingAreaChangedListener = workingAreaChangedListener;
108
            this.viewPort = viewPort;
109
        }
110

  
111
        public ViewPort getViewPort() {
112
            return this.viewPort;
113
        }
114

  
115
        @Override
116
        public void extentChanged(ExtentEvent e) {
117
            this.workingAreaChangedListener.workingAreaChanged(e.getNewExtent());
118
        }
119

  
120
        @Override
121
        public void backColorChanged(ColorEvent e) {
122
        }
123

  
124
        @Override
125
        public void projectionChanged(ProjectionEvent e) {
126
        }
127
    }
128

  
129
    private class EditingNotificationObserver implements Observer {
130

  
131
        public EditingNotificationObserver() {
132

  
133
        }
134

  
135
        @Override
136
        public void update(Observable o, Object notification) {
137
            EditingNotification n = (EditingNotification) notification;
138
            if (n.isCancelable() && n.getFeature() != null) {
139
                try {
140
                    DynObject data = n.getFeature().getAsDynObject();
141
                    DynObjectEditor editor = new DynObjectEditor(data);
142
                    editor.setTitle("Topology - " + n.getFeature().getType().getName());
143
                    editor.editObject(true);
144
                    if (editor.isCanceled()) {
145
                        n.cancel();
146
                    } else {
147
                        editor.getData(data);
148
                    }
149
                } catch (Exception ex) {
150
                    LOGGER.warn("Problems showing the feature in a form.", ex);
151
                }
152
            }
153
        }
154
    }
155

  
156
    private final Map<WorkingAreaChangedListener, WorkingAreaViewPortListener> workingAreaListener;
157
    private ISymbol errorPolygonSymbol = null;
158
    private ISymbol errorPointSymbol = null;
159
    private ISymbol errorLineSymbol = null;
160
    private EditingNotificationObserver editingNotificationObserver = null;
161

  
162
    public AppTopologyServices() {
163
        this.workingAreaListener = new HashMap<>();
164
    }
165

  
166
    @Override
167
    public TreeModel getDataSetTreeModel() {
168
        ApplicationManager application = ApplicationLocator.getManager();
169
        ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
170
        return new DataSetsTreeModel(this, view);
171
    }
172

  
173
    @Override
174
    public ListModel getTablesListModel() {
175
        ApplicationManager application = ApplicationLocator.getManager();
176
        Project project = application.getCurrentProject();
177
        TopologyManager manager = TopologyLocator.getTopologyManager();
178
        
179
        DefaultListModel<TopologyDataSet> model = new DefaultListModel<>();
180
        
181
        List<Document> docs = project.getDocuments(TableManager.TYPENAME);
182
        for (Document doc : docs) {
183
            TableDocument table=(TableDocument) doc;
184
            TopologyDataSet dataset = manager.createDataSet(table.getName(), table.getFeatureStore());
185
            model.addElement(dataset);   
186
        }
187
        return model;
188
    }
189
    
190
    
191

  
192
    @Override
193
    public FeatureStore getFeatureStore(final TopologyDataSet dataSet) {
194
        final Mutable<FeatureStore> store = new MutableObject<>();
195
        store.setValue(null);
196

  
197

  
198
        ApplicationManager application = ApplicationLocator.getManager();
199
        Project project = application.getCurrentProject();
200

  
201
        List<Document> views = new ArrayList<>();
202
        views.add(project.getActiveDocument(ViewManager.TYPENAME));
203
//        views.addAll(project.getDocuments(ViewManager.TYPENAME));
204

  
205
        for (Document view : views) {
206
            if (view == null) {
207
                continue;
208
            }
209
            FLayers layers = ((ViewDocument) view).getMapContext().getLayers();
210
            try {
211
                layers.accept((Object o) -> {
212
                    if (o instanceof FLyrVect) {
213
                        FLyrVect layer = (FLyrVect) o;
214
                        if (dataSet.isThisStore(layer.getFeatureStore())) {
215
                            store.setValue(layer.getFeatureStore());
216
                            throw new VisitCanceledException();
217
                        }
218
                    }
219
                });
220
            } catch (VisitCanceledException ex) {
221
                break;
222
            } catch (Exception ex) {
223
                throw new RuntimeException(ex);
224
            }
225
        }
226
        if (store.getValue()==null){
227
            for (Document document : project.getDocuments(TableManager.TYPENAME)) {
228
                TableDocument table= (TableDocument) document;
229
                if (dataSet.isThisStore(table.getFeatureStore())) {
230
                    store.setValue(table.getFeatureStore());
231
                    break;
232
                }   
233
            } 
234
        }
235
        return store.getValue();
236
    }
237

  
238
    @Override
239
    public void zoomTo(Envelope envelope) {
240
        ApplicationManager application = ApplicationLocator.getManager();
241
        ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
242
        if (viewdoc == null) {
243
            return;
244
        }
245
        ViewPort viewPort = viewdoc.getMapContext().getViewPort();
246
        viewPort.setEnvelope(envelope);
247
    }
248

  
249
    @Override
250
    public void refreshView() {
251
        try {
252
            ApplicationManager application = ApplicationLocator.getManager();
253
            ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
254
            if (viewdoc == null) {
255
                return;
256
            }
257
            viewdoc.getMapContext().invalidate();
258
        } catch (Exception ex) {
259
            LOGGER.warn("Cant refresh view", ex);
260
        }
261
    }
262

  
263
    @Override
264
    public void centerTo(Point point) {
265
        try {
266
            ApplicationManager application = ApplicationLocator.getManager();
267
            ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
268
            if (viewdoc == null) {
269
                return;
270
            }
271
            ViewPort viewPort = viewdoc.getMapContext().getViewPort();
272
            Envelope envelope = (Envelope) viewPort.getEnvelope().clone();
273
            envelope.centerTo(point);
274
            viewPort.setEnvelope(envelope);
275
        } catch (Exception ex) {
276
            LOGGER.warn("Cant center view", ex);
277
        }
278
    }
279

  
280
    @Override
281
    public Envelope getWorkingArea() {
282
        ApplicationManager application = ApplicationLocator.getManager();
283
        ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
284
        if (viewdoc == null) {
285
            return null;
286
        }
287
        ViewPort viewPort = viewdoc.getMapContext().getViewPort();
288
        return viewPort.getEnvelope();
289
    }
290

  
291
    @Override
292
    public void addWorkingAreaChangedListener(WorkingAreaChangedListener listener) {
293
        ApplicationManager application = ApplicationLocator.getManager();
294
        ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
295
        if (viewdoc == null) {
296
            return;
297
        }
298
        ViewPort viewPort = viewdoc.getMapContext().getViewPort();
299
        WorkingAreaViewPortListener viewPortListener = this.workingAreaListener.get(listener);
300
        if (viewPortListener == null) {
301
            viewPortListener = new WorkingAreaViewPortListener(viewPort, listener);
302
            this.workingAreaListener.put(listener, viewPortListener);
303
        } else {
304
            if (viewPort != viewPortListener.getViewPort()) {
305
                viewPortListener.getViewPort().removeViewPortListener(viewPortListener);
306
                viewPortListener = new WorkingAreaViewPortListener(viewPort, listener);
307
                this.workingAreaListener.put(listener, viewPortListener);
308
            }
309
        }
310
        viewPortListener.getViewPort().addViewPortListener(viewPortListener);
311
    }
312

  
313
    @Override
314
    public void removeWorkingAreaChangedListener(WorkingAreaChangedListener listener) {
315
        WorkingAreaViewPortListener viewPortListener = this.workingAreaListener.get(listener);
316
        if (viewPortListener == null) {
317
            return;
318
        }
319
        viewPortListener.getViewPort().removeViewPortListener(viewPortListener);
320
    }
321

  
322
    @Override
323
    public void addError(Geometry geom) {
324
        if (this.errorPointSymbol == null) {
325
            try {
326
                File pluginfolder = PluginsLocator.getManager().getPlugin(this).getPluginDirectory();
327
                File folder = new File(pluginfolder, "symbols");
328
                ISymbol[] symbols = MapContextLocator.getSymbolManager().loadSymbols(folder);
329
                for (ISymbol symbol : symbols) {
330
                    if (symbol instanceof ISymbol_v2) {
331
                        String symbolid = ((ISymbol_v2) symbol).getID();
332
                        switch(symbolid) {
333
                            case "topology-error-polygon":
334
                                this.errorPolygonSymbol = symbol;
335
                                break;
336
                            case "topology-error-line":
337
                                this.errorLineSymbol = symbol;
338
                                break;
339
                            case "topology-error-point":
340
                                this.errorPointSymbol = symbol;
341
                                break;
342
                        }
343
                    }
344
                }
345
            } catch (Exception ex) {
346
            }
347
        }
348
        ApplicationManager application = ApplicationLocator.getManager();
349
        ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
350
        if(viewdoc != null){
351
            MapContext mapContext = viewdoc.getMapContext();
352
            GraphicLayer gl = mapContext.getGraphicsLayer();
353
            gl.removeGraphics("topology-errors");
354
            if ( geom!=null ) {
355
                ISymbol symbol = null;
356
                if( geom instanceof Point || geom instanceof MultiPoint) {
357
                    symbol = this.errorPointSymbol;
358
                } else if( geom instanceof Curve || geom instanceof MultiCurve ) {
359
                    symbol = this.errorLineSymbol;
360
                } else if( geom instanceof Surface || geom instanceof MultiSurface ) {
361
                    symbol = this.errorPolygonSymbol;
362
                }
363
                if (symbol != null) {
364
                    int symbolid = gl.getSymbolId(symbol);
365
                    if (symbolid < 0) {
366
                        gl.addSymbol(symbol);
367
                        symbolid = gl.getSymbolId(symbol);
368
                    }
369
                    gl.addGraphic("topology-errors", geom, symbolid);
370
                }
371
            }
372
            mapContext.invalidate();
373
        }
374
    }
375

  
376
    @Override
377
    public void setShowFormWhenEdit(boolean showFormWhenEdit) {
378
        if (this.editingNotificationObserver == null) {
379
            this.editingNotificationObserver = new EditingNotificationObserver();
380
        }
381
        EditingNotificationManager editingNotificationManager = DALSwingLocator.getEditingNotificationManager();
382
        if (showFormWhenEdit) {
383
            editingNotificationManager.addObserver(this.editingNotificationObserver);
384
        } else {
385
            editingNotificationManager.deleteObserver(this.editingNotificationObserver);
386
        }
387
    }
388

  
389
    @Override
390
    public ImageIcon getTreeIcon(TreeModel model, Object item) {
391
        return ((DataSetsTreeModel)model).getTreeIcon(item);
392
    }
393

  
394
    @Override
395
    public void selectFeature(FeatureStore store, FeatureReference ref) {
396
        try {
397
            FeatureStore targetLayerStore = getStoreOfActiveView(store);
398
            if (targetLayerStore != null) {
399
                FeatureSelection targetSelection = targetLayerStore.getFeatureSelection();
400
                targetSelection.deselectAll();
401
                FeatureReference targetReference = targetLayerStore.getFeatureReference(ref.getCode());
402
                targetSelection.select(targetReference);
403
            }
404
            FeatureStore targetTableStore = getStoreOfActiveTable(store);
405
            if (targetTableStore != null && targetTableStore!=targetLayerStore ) {
406
                FeatureSelection targetSelection = targetTableStore.getFeatureSelection();
407
                targetSelection.deselectAll();
408
                FeatureReference targetReference = targetTableStore.getFeatureReference(ref.getCode());
409
                targetSelection.select(targetReference);
410
            }
411
        } catch (DataException ex) {
412
            LOGGER.warn("Can't select feature.", ex);
413
        }
414
    }
415
    
416
    private FeatureStore getStoreOfActiveView(FeatureStore store) {
417
        ApplicationManager application = ApplicationLocator.getManager();
418
        IView view = (IView) application.getActiveComponent(ViewDocument.class);
419
        if (view == null) {
420
            return null;
421
        }
422
        Iterator<FLayer> it = view.getMapControl().getMapContext().deepiterator();
423
        while(it.hasNext()){
424
            FLayer layer = it.next();
425
            if (layer instanceof FLyrVect) {
426
                try {
427
                    FeatureStore x = ((FLyrVect)layer).getFeatureStore();
428
                    if (x != null && StringUtils.equals(x.getFullName(), store.getFullName())) {
429
                        return x;
430
                    }
431

  
432
                } catch (Exception ex) {
433
                    LOGGER.warn("Can't check if the layer can be valid", ex);
434
                }
435
            }
436
        }
437
        return null;
438
    }
439
    
440
    private FeatureStore getStoreOfActiveTable(FeatureStore store) {
441
        ApplicationManager application = ApplicationLocator.getManager();
442
        FeatureTableDocumentPanel table = (FeatureTableDocumentPanel) application.getActiveComponent(TableDocument.class);
443
        if (table == null) {
444
            return null;
445
        }
446
        try {
447
            FeatureStore x = table.getFeatureStore();
448
            if (x != null && StringUtils.equals(x.getFullName(), store.getFullName())) {
449
                return x;
450
            }
451

  
452
        } catch (Exception ex) {
453
            LOGGER.warn("Can't check if the layer can be valid", ex);
454
        }
455
        return null;
456
    }
457
    
458
    private List<FLyrVect> getLayers(IView view, Predicate<FLyrVect> valid) {
459
        if (view == null) {
460
            return Collections.EMPTY_LIST;
461
        }
462
        List<FLyrVect> layers = new ArrayList<>();
463
        ViewDocument viewDocument = view.getViewDocument();
464
        FLayer[] actives = viewDocument.getMapContext().getLayers().getActives();
465
        for (FLayer layer : actives) {
466
            if (layer instanceof FLyrVect && valid.test((FLyrVect) layer)) {
467
                layers.add((FLyrVect) layer);
468
            }
469
        }
470
        return layers;
471
    }
472

  
473

  
474
    
475
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.87/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/src/main/resources-plugin/i18n/text.properties
1
#Translations for language [es]
2
#Thu Nov 20 10:10:09 CET 2014
3
_Topology=Topologia
4
_Create_or_edit_plan=Crear o modificar plan
5
_Execute_plan=Ejecutar plan
6
_Topology_plan_error_inspector=Inspector de errores del Plan de topologia
7
_Topology_plan=Plan de topologia
8
_Show=Mostrar
9
_Show_errors=Mostrar errores
10
_Show_exceptions=Mostrar excepciones
11
_Show_only_in_visible_extent=Mostrar solo en el area visible
12
_Show_form_when_modify_geometry=Mostrar formulario al modificar la geometria
13
_Zoom=Zoom
14
Center_geometry=Centrar geometria
15
_Center_error=Centrar error
16
_Actions=Acciones
17
_Action=Acci\u00f3n
18
_Update=Actualizar
19
_Name=Nombre
20
_Tolerance=Tolerancia
21
_DataSets=Conjuntos de datos
22
_Dataset1=Conjunto de datos1
23
_Dataset2=Conjunto de datos2
24
_Rules=Reglas
25
_Remove_dataset=Eliminar conjunto de datos
26
_Add_dataset=A\u00f1adir conjunto de datos
27
_Remove_rule=Eliminar regla
28
_Add_rule=A\u00f1adir regla
29
_Edit_rule=Modificar regla
30
_Contains_Point=Contiene punto
31
_Primary_dataset=Conjunto de datos primario
32
_Secondary_dataset=Conjunto de datos secundario
33
_Rule=Regla
34
_Add_new_rule=A\u00f1adir nueva regla
35
_Exception=Excepcion
36
_Errors=Errores
37
_Parameters=Parametros
38
_Accept=Aceptar
39
_Execute=Ejecutar
40
_Any_rule=Cualquier regla
41
_Erase_error_marks=Eliminar marcas de errores
42
_Select_a_dataset=Seleccione un conjunto de datos
43
_The_polygon_overlay_with_other=El pol\u00edgono se superpone con otro
44
_The_geometry_is_null=La geometr\u00eda es nula.
45
_Point_is_not_contained_in_a_polygon=El punto no est\u00e1 contenido en un pol\u00edgono
46
_The_polygon_does_not_contain_any_points=El  pol\u00edgono  no  contiene ning\u00fan punto
47
_The_length_of_the_line_is_less_than_the_specified_tolerance=La longitud de la l\u00ednea es menore que la tolerancia dada
48
_Polygon_is_not_covered_by_any_other_polygon=El pol\u00edgono no est\u00e1 cubierto por ning\u00fan otro pol\u00edgono
49
_Line_is_not_covered_by_boundary_of_any_polygon=La l\u00ednea no est\u00e1 cubierta por el l\u00edmite de ning\u00fan pol\u00edgono
50
_Line_is_not_covered_by_boundary_of_the_polygon=La l\u00ednea no est\u00e1 cubierta por el l\u00edmite del pol\u00edgono
51
_Line_crosses_too_many_polygons=La l\u00ednea cruza por demasiados pol\u00edgonos
52
The_solution_cannot_be_automated_because_the_line_crosses_too_many_polygons=No se puede automatizar la soluci\u00f3n porque la l\u00ednea cruza por demasiados pol\u00edgonos
53
_The_polygon_does_not_contain_any_polygons=El  pol\u00edgono  no  contiene ning\u00fan pol\u00edgono
54
_The_polygon_contains_more_than_a_point=El pol\u00edgono contiene m\u00e1s de un punto
55
_Add_dataset=A\u00f1adir conjunto de datos
56
_The_dataset_XnameX_is_neither_2D_nor_2DM_The_result_of_the_topological_checks_may_not_be_what_you_expect_Do_you_want_to_continue=El conjunto de datos "{0}" no es 2D ni 2DM. El resultado de las comprobaciones topol\u00f3gicas puede no ser el esperado.\n\u00bfDesea continuar?
57
_Add_non_2D_topology_dataset=A\u00f1adir conjunto de datos no 2D a topolog\u00eda
58
_Accept_exceptions=Aceptar excepciones
59
_Copy_topology_Plan_to_clipboard=Copiar el plan de topologia al portapapeles
60
_Customizable=Personalizable
61
_Check_code=C\u00f3digo de verificaci\u00f3n
62
_Action_code=C\u00f3digo de la acci\u00f3n
63
_Save_topology_plan=Guardar plan de topolog\u00eda
64
_Select_topology_plan_file=Seleccionar archivo de plan de topolog\u00eda
65
_Cant_save_topology_plan=No se puede guardar el plan de topolog\u00eda
66
_Load_topology_plan=Cargar plan de topolog\u00eda
67
_Cant_load_topology_plan=No se puede cargar el plan de topolog\u00eda
68
_Modify_rule=Modificar regla
69
_Check_expression=Expressi\u00f3n de verificaci\u00f3n
70
_Verification_expression_If_false_the_rule_fails=Expresi\u00f3n de verificaci\u00f3n. Si devuelve false la regla falla.
71
_Error_message=Mensaje de error.
72
_Message_to_show_if_check_fail=Mensaje a mostrar cuando la regla falla.
73
_The_verification_expression_was_not_met=No se ha cumplido la expresi\u00f3n de verificaci\u00f3n.
74
_Name_of_the_rule=Nombre de la regla
75

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.87/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
1
#Translations for language [en]
2
#Thu Nov 20 10:10:15 CET 2014
3
_Topology=Topology
4
_Create_or_edit_plan=Create or edit plan
5
_Execute_plan=Execute plan
6
_Topology_plan_error_inspector=Topology plan error inspector
7
_Topology_plan=Topology plan
8
_Show=Show
9
_Show_errors=Show errors
10
_Show_exceptions=Show exceptions
11
_Show_only_in_visible_extent=Show only in visible extent
12
_Show_form_when_modify_geometry=Show form when modify geometry
13
_Zoom=Zoom
14
_Center_geometry=Center geometry
15
_Center_error=Center error
16
_Actions=Actions
17
_Action=Action
18
_Update=Update
19
_Name=Name
20
_Tolerance=Tolerance
21
_DataSets=Datasets
22
_Dataset1=Dataset1
23
_Dataset2=Dataset2
24
_Rules=Rules
25
_Remove_dataset=Remove dataset
26
_Add_dataset=Add dataset
27
_Remove_rule=Remove rule
28
_Add_rule=Add rule
29
_Edit_rule=Edit rule
30
_Primary_dataset=Primary dataset
31
_Secondary_dataset=Secondary dataset
32
_Rule=Rule
33
_Add_new_rule=Add new rule
34
_Exception=Exception
35
_Errors=Errors
36
_Parameters=Parameters
37
_Accept=Accept
38
_Execute=Execute
39
_Any_rule=Any rule
40
_Erase_error_marks=Erase error marks
41
_Select_a_dataset=Select a dataset
42
_The_polygon_overlay_with_other=The polygon overlay with other.
43
_The_geometry_is_null=The geometry is null.
44
_Point_is_not_contained_in_a_polygon=Point is not contained in a polygon
45
_The_polygon_does_not_contain_any_points=The polygon does not contain any points
46
_The_length_of_the_line_is_less_than_the_specified_tolerance=The length of the line is less than the specified tolerance
47
_Polygon_is_not_covered_by_any_other_polygon=The polygon is not covered by any other polygon
48
_Line_is_not_covered_by_boundary_of_any_polygon=Line is not covered by boundary of any polygon
49
_Line_is_not_covered_by_boundary_of_the_polygon=Line is not covered by boundary of thes polygon
50
_Line_crosses_too_many_polygons=Line crosses too many polygons
51
The_solution_cannot_be_automated_because_the_line_crosses_too_many_polygons=The solution cannot be automated because the line crosses too many polygons 
52
_The_polygon_does_not_contain_any_polygons=The polygon does not contain any polygons
53
_The_polygon_contains_more_than_a_point=The polygon contains more than a point
54
_Add_dataset=Add dataset
55
_The_dataset_XnameX_is_neither_2D_nor_2DM_The_result_of_the_topological_checks_may_not_be_what_you_expect_Do_you_want_to_continue=The dataset "{0}" is neither 2D nor 2DM. The result of the topological checks may not be what you expect.\nDo you want to continue?
56
_Add_non_2D_topology_dataset=Add non 2D topology dataset
57
_Accept_exceptions=Accept exceptions
58
_Copy_topology_Plan_to_clipboard=Copy topology plan to clipboard
59
_Customizable=Customizable
60
_Check_code=Check code
61
_Action_code=Action code
62
_Save_topology_plan=Save topology plan
63
_Select_topology_plan_file=Select topology plan file
64
_Cant_save_topology_plan=Can't save topology plan
65
_Load_topology_plan=Load topology plan
66
_Cant_load_topology_plan=Can't load topology plan
67
_Modify_rule=Modify rule
68
_Check_expression=Check expression
69
_Verification_expression_If_false_the_rule_fails=Verification expression. If false the rule fails.
70
_Error_message=Error message
71
_Message_to_show_if_check_fail=Message to show if check fail.
72
_The_verification_expression_was_not_met=The verification expression was not met.
73
_Name_of_the_rule=Name of the rule
org.gvsig.topology/tags/org.gvsig.topology-1.0.87/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/src/main/resources-plugin/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2014 gvSIG
3
  Association. This program is free software; you can redistribute it and/or modify
4
  it under the terms of the GNU General Public License as published by the Free Software
5
  Foundation; either version 3 of the License, or (at your option) any later version.
6
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
7
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8
  PURPOSE. See the GNU General Public License for more details. You should have received
9
  a copy of the GNU General Public License along with this program; if not, write to
10
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
11
  USA. For any additional information, do not hesitate to contact us at info AT gvsig.com,
12
  or visit our website www.gvsig.com. -->
13
<plugin-config>
14
  <depends plugin-name="org.gvsig.app.mainplugin" />
15
  <depends plugin-name="org.gvsig.app.document.table.app.mainplugin" />
16
  <resourceBundle name="text" />
17
  <libraries library-dir="lib" />
18
  <extensions>
19

  
20

  
21
    <extension class-name="org.gvsig.topology.app.mainplugin.TopologyExtension"
22
      description="" active="true" priority="1">
23
            <action 
24
                name="tools-topology-create-or-modify"
25
                label="_Show_create_or_edit_topology_plan" 
26
                position="908300100"  
27
                tooltip="_Show_create_or_edit_topology_plan" 
28
                action-command="tools-topology-create-or-modify"
29
                icon="tools-topology-create-or-modify"
30
                accelerator=""
31
            />
32
            <action 
33
                name="tools-topology-execute"
34
                label="_Execute_topology_plan" 
35
                position="908300200"  
36
                tooltip="_Execute_topology_plan" 
37
                action-command="tools-topology-execute"
38
                icon="tools-topology-execute"
39
                accelerator=""
40
            />
41

  
42
            <menu text="tools/_Topology"
43
                              position="908300000" 
44
                              is_separator="true"/>
45
            <menu text="tools/_Topology/_Create_or_edit_plan" 
46
                              name="tools-topology-create-or-modify"/>
47
            <menu text="tools/_Topology/_Execute_plan" 
48
                              name="tools-topology-execute"/>
49
				
50
            <!--
51
            <tool-bar name="topology" position="2000">
52
                <action-tool name="tools-topology-create-or-modify"/>				
53
                <action-tool name="tools-topology-execute"/>				
54
            </tool-bar>                    
55
            -->
56
    </extension>
57

  
58

  
59
  </extensions>
60
</plugin-config>
org.gvsig.topology/tags/org.gvsig.topology-1.0.87/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<!--
2

  
3
    gvSIG. Desktop Geographic Information System.
4

  
5
    Copyright (C) 2007-2013 gvSIG Association.
6

  
7
    This program is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU General Public License
9
    as published by the Free Software Foundation; either version 3
10
    of the License, or (at your option) any later version.
11

  
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16

  
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
    MA  02110-1301, USA.
21

  
22
    For any additional information, do not hesitate to contact us
23
    at info AT gvsig.com, or visit our website www.gvsig.com.
24

  
25
-->
26
<assembly>
27
    <id>gvsig-plugin-package</id>
28
    <formats>
29
        <format>zip</format>
30
    </formats>
31
    <baseDirectory>${project.artifactId}</baseDirectory>
32
    <includeBaseDirectory>true</includeBaseDirectory>
33
    <files>
34
        <file>
35
            <source>target/${project.artifactId}-${project.version}.jar</source>
36
            <outputDirectory>lib</outputDirectory>
37
        </file>
38
        <file>
39
            <source>target/package.info</source>
40
        </file>
41
    </files>
42

  
43
    <fileSets>
44
        <fileSet>
45
            <directory>src/main/resources-plugin</directory>
46
            <outputDirectory>.</outputDirectory>
47
        </fileSet>
48
    </fileSets>
49

  
50

  
51
    <dependencySets>
52
        <dependencySet>
53
            <useProjectArtifact>false</useProjectArtifact>
54
            <useTransitiveDependencies>false</useTransitiveDependencies>
55
            <outputDirectory>lib</outputDirectory>
56
            <includes>
57
                <include>org.gvsig:org.gvsig.topology.lib.api</include>
58
                <include>org.gvsig:org.gvsig.topology.lib.impl</include>
59
                <include>org.gvsig:org.gvsig.topology.swing.api</include>
60
                <include>org.gvsig:org.gvsig.topology.swing.impl</include>
61
            </includes>
62
        </dependencySet>
63
    </dependencySets>
64

  
65
</assembly>
66

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.87/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
  <modelVersion>4.0.0</modelVersion>
3
  <parent>
4
    <groupId>org.gvsig</groupId>
5
    <artifactId>org.gvsig.topology.app</artifactId>
6
    <version>1.0.87</version>
7
  </parent>
8
  <artifactId>org.gvsig.topology.app.mainplugin</artifactId>
9
  <name>${project.artifactId}</name>
10
  <dependencies>
11
    <dependency>
12
        <groupId>org.gvsig</groupId>
13
        <artifactId>org.gvsig.app.mainplugin</artifactId>
14
        <scope>compile</scope>
15
    </dependency>
16
    <dependency>
17
    	<groupId>org.gvsig</groupId>
18
    	<artifactId>org.gvsig.topology.lib.api</artifactId>
19
        <scope>compile</scope>
20
    </dependency>
21
    <dependency>
22
    	<groupId>org.gvsig</groupId>
23
    	<artifactId>org.gvsig.topology.lib.impl</artifactId>
24
        <scope>runtime</scope>
25
    </dependency>
26
    <dependency>
27
    	<groupId>org.gvsig</groupId>
28
    	<artifactId>org.gvsig.topology.swing.api</artifactId>
29
        <scope>compile</scope>
30
    </dependency>
31
    <dependency>
32
    	<groupId>org.gvsig</groupId>
33
    	<artifactId>org.gvsig.topology.swing.impl</artifactId>
34
        <scope>runtime</scope>
35
    </dependency>
36
    <dependency>
37
      <groupId>org.gvsig</groupId>
38
      <artifactId>org.gvsig.app.document.table.app.mainplugin</artifactId>
39
      <scope>compile</scope>
40
    </dependency>
41
  </dependencies>
42

  
43
  <properties>
44
    <gvsig.package.info.state>testing</gvsig.package.info.state>
45
    <gvsig.package.info.official>true</gvsig.package.info.official>
46
    <gvsig.package.info.dependencies>required: org.gvsig.app -ge 2.2.0</gvsig.package.info.dependencies>
47
    <gvsig.package.info.categories />
48
    <gvsig.package.info.name>Topology framework</gvsig.package.info.name>
49
    <gvsig.package.info.description>Topology framework and basic rules</gvsig.package.info.description>
50
    <gvsig.package.info.owner>gvSIG Association</gvsig.package.info.owner>
51
    <gvsig.package.info.javaVM>j1_8</gvsig.package.info.javaVM>
52
    <gvsig.package.info.sourcesURL>${project.scm.url}</gvsig.package.info.sourcesURL>
53
    <gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-topology/pool</gvsig.package.info.poolURL>
54
  </properties>
55

  
56
</project>
0 57

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.87/org.gvsig.topology.app/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
  <modelVersion>4.0.0</modelVersion>
3
  <parent>
4
    <groupId>org.gvsig</groupId>
5
    <artifactId>org.gvsig.topology</artifactId>
6
    <version>1.0.87</version>
7
  </parent>
8
  <artifactId>org.gvsig.topology.app</artifactId>
9
  <packaging>pom</packaging>
10
  <name>${project.artifactId}</name>
11
  <modules>
12
  	<module>org.gvsig.topology.app.mainplugin</module>
13
  </modules>
14
</project>
org.gvsig.topology/tags/org.gvsig.topology-1.0.87/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/PolygonMustNotOverlapPolygonRuleFactory.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2021 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
package org.gvsig.topology.rule;
25

  
26
import org.gvsig.fmap.geom.Geometry;
27
import org.gvsig.json.Json;
28
import org.gvsig.tools.util.ListBuilder;
29
import org.gvsig.topology.lib.api.TopologyLocator;
30
import org.gvsig.topology.lib.api.TopologyManager;
31
import org.gvsig.topology.lib.api.TopologyRule;
32
import org.gvsig.topology.lib.spi.AbstractTopologyRuleFactory;
33

  
34
/**
35
 *
36
 * @author jjdelcerro
37
 */
38
@SuppressWarnings("UseSpecificCatch")
39
public class PolygonMustNotOverlapPolygonRuleFactory extends AbstractTopologyRuleFactory {
40

  
41
    public static final String NAME = "PolygonMustNotOverlapPolygon";
42
    
43
    public PolygonMustNotOverlapPolygonRuleFactory() {
44
        super(
45
                NAME, 
46
                "Must Not Overlap", 
47
                "Requires that the interior of polygons in the dataset not overlap. The polygons can share edges or vertices. This rule is used when an area cannot belong to two or more polygons. It is useful for modeling administrative boundaries, such as ZIP Codes or voting districts, and mutually exclusive area classifications, such as land cover or landform type.", 
48
                new ListBuilder<Integer>()
49
                        .add(Geometry.TYPES.SURFACE)
50
                        .add(Geometry.TYPES.MULTISURFACE)
51
                        .asList()
52
                
53
        );
54
    }
55
    
56
    @Override
57
    public TopologyRule createRule(String dataSet1, String dataSet2, double tolerance) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff