Revision 923

View differences:

org.gvsig.topology/tags/org.gvsig.topology-1.0.6/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.6</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.6/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/buildNumber.properties
1
#Fri Jul 12 18:39:22 CEST 2019
2
buildNumber=10
org.gvsig.topology/tags/org.gvsig.topology-1.0.6/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.6/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 javax.swing.ImageIcon;
27
import javax.swing.event.TreeModelListener;
28
import javax.swing.tree.TreeModel;
29
import javax.swing.tree.TreePath;
30
import org.gvsig.andami.IconThemeHelper;
31
import org.gvsig.app.project.documents.view.ViewDocument;
32
import org.gvsig.fmap.dal.DataStore;
33
import org.gvsig.fmap.mapcontext.MapContextLocator;
34
import org.gvsig.fmap.mapcontext.layers.FLayer;
35
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer;
36
import org.gvsig.fmap.mapcontrol.CompoundLayersTreeModel;
37
import org.gvsig.fmap.mapcontrol.MapControlLocator;
38
import org.gvsig.tools.swing.api.ListElement;
39
import org.gvsig.topology.lib.api.TopologyDataSet;
40
import org.gvsig.topology.lib.api.TopologyLocator;
41
import org.gvsig.topology.swing.api.TopologySwingServices;
42

  
43
/**
44
 *
45
 * @author jjdelcerro
46
 */
47
public class DataSetsTreeModel implements TreeModel {
48

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

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

  
91
    @Override
92
    public int getChildCount(Object parent) {
93
        parent = this.getNode(parent);
94
        return this.deletaged.getChildCount(parent);
95
    }
96

  
97
    @Override
98
    public boolean isLeaf(Object node) {
99
        node = this.getNode(node);
100
        return this.deletaged.isLeaf(node);
101
    }
102

  
103
    @Override
104
    public void valueForPathChanged(TreePath path, Object newValue) {
105
        this.deletaged.valueForPathChanged(path, newValue);
106
    }
107

  
108
    @Override
109
    public int getIndexOfChild(Object parent, Object child) {
110
        parent = this.getNode(parent);
111
        return this.deletaged.getIndexOfChild(parent, child);
112
    }
113

  
114
    @Override
115
    public void addTreeModelListener(TreeModelListener l) {
116
        this.deletaged.addTreeModelListener(l);
117
    }
118

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

  
124
    public ImageIcon getTreeIcon(Object item) {
125
        if( this.getRoot()==item ) {
126
            return IconThemeHelper.getImageIcon("topology-tree-project");
127
        }
128
        if (item instanceof ListElement) {
129
            item = ((ListElement) item).getValue();
130
        }
131
        if( this.view.getMapContext().getLayers()==item ) {
132
            return IconThemeHelper.getImageIcon("document-view-tree-icon");
133
        }
134
        if (item instanceof TopologyDataSet) {
135
            DataStore store = ((TopologyDataSet)item).getStore();
136
            String iconName = MapContextLocator.getMapContextManager().getIconLayer(store);
137
            return IconThemeHelper.getImageIcon(iconName);
138
        }
139
        if (item instanceof FLayer) {
140
            String iconName = ((FLayer) item).getTocImageIcon();
141
            return IconThemeHelper.getImageIcon(iconName);
142
        }
143
        return IconThemeHelper.getImageIcon("topology-tree-folder");
144
    }
145
    
146
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.6/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.awt.event.ActionListener;
28
import org.apache.commons.lang.StringUtils;
29
import org.gvsig.andami.IconThemeHelper;
30
import org.gvsig.andami.plugins.Extension;
31
import org.gvsig.app.ApplicationLocator;
32
import org.gvsig.app.ApplicationManager;
33
import org.gvsig.app.project.documents.Document;
34
import org.gvsig.app.project.documents.view.ViewDocument;
35
import org.gvsig.app.project.documents.view.ViewManager;
36
import org.gvsig.tools.ToolsLocator;
37
import org.gvsig.tools.i18n.I18nManager;
38
import org.gvsig.tools.swing.api.ToolsSwingLocator;
39
import org.gvsig.tools.swing.api.windowmanager.Dialog;
40
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
41
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2;
42
import org.gvsig.topology.lib.api.TopologyLocator;
43
import org.gvsig.topology.lib.api.TopologyManager;
44
import org.gvsig.topology.lib.api.TopologyPlan;
45
import org.gvsig.topology.swing.api.JTopologyPlanProperties;
46
import org.gvsig.topology.swing.api.JTopologyReport;
47
import org.gvsig.topology.swing.api.TopologySwingLocator;
48
import org.gvsig.topology.swing.api.TopologySwingManager;
49

  
50
/**
51
 *
52
 * @author jjdelcerro
53
 */
54
public class TopologyExtension extends Extension {
55

  
56
    @Override
57
    public void initialize() {
58
        
59
    }
60

  
61
    @Override
62
    public void postInitialize() {
63
        AppTopologyServices services = new AppTopologyServices();
64
        
65
        TopologyManager manager = TopologyLocator.getTopologyManager();
66
        manager.setDefaultServices(services);
67
        
68
        TopologySwingManager swingManager = TopologySwingLocator.getTopologySwingManager();
69
        swingManager.setDefaultServices(services);
70
  
71
        IconThemeHelper.registerIcon("document", "document-view-tree-icon", this);
72
        IconThemeHelper.registerIcon("topology", "topology-tree-folder", this);
73
        IconThemeHelper.registerIcon("topology", "topology-tree-project", this);
74
    }
75

  
76
    
77
    @Override
78
    public void execute(String action) {
79
        if( StringUtils.equalsIgnoreCase("tools-topology-create-or-modify", action) ) {
80
            I18nManager i18n = ToolsLocator.getI18nManager();
81
            ApplicationManager application = ApplicationLocator.getManager();
82
            final ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
83
            if( view==null ) {
84
                // TODO: Mensaje de se necesita una vista 
85
                return;
86
            }
87
            TopologyManager manager = TopologyLocator.getTopologyManager();
88
            TopologySwingManager swingManager = TopologySwingLocator.getTopologySwingManager();
89
            WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
90
            
91
            final JTopologyPlanProperties panel = swingManager.createJTopologyPlan();
92

  
93
            TopologyPlan plan = manager.createTopologyPlan();
94
            String jsonPlan = (String) view.getProperty("TopologyPlan");
95
            if( !StringUtils.isEmpty(jsonPlan) ) {
96
                plan.fromJSON(jsonPlan);
97
            } 
98
            panel.put(plan);
99
            
100
            final Dialog dlg = winManager.createDialog(
101
                    panel.asJComponent(),
102
                    i18n.getTranslation("_Topology_plan"),
103
                    null, 
104
                    WindowManager_v2.BUTTONS_OK_CANCEL
105
            );
106
            dlg.addActionListener(new ActionListener() {
107
                @Override
108
                public void actionPerformed(ActionEvent e) {
109
                    if( dlg.getAction()==WindowManager_v2.BUTTON_OK ) {
110
                        TopologyPlan plan = panel.fetch(null);
111
                        view.setProperty("TopologyPlan", plan.toJSON().toString());
112
                    }
113
                }
114
            });
115
            dlg.show(WindowManager.MODE.WINDOW);
116

  
117
        } else if( StringUtils.equalsIgnoreCase("tools-topology-execute", action) ) {
118
            I18nManager i18n = ToolsLocator.getI18nManager();
119
            ApplicationManager application = ApplicationLocator.getManager();
120
            final ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
121
            if( view==null ) {
122
                // TODO: Mensaje de se necesita una vista 
123
                return;
124
            }
125
            TopologyManager manager = TopologyLocator.getTopologyManager();
126
            final TopologySwingManager swingManager = TopologySwingLocator.getTopologySwingManager();
127
            final WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
128
            
129

  
130
            String jsonPlan = (String) view.getProperty("TopologyPlan");
131
            if( StringUtils.isEmpty(jsonPlan) ) {
132
                // TODO: Mensaje de crear plan
133
                return;
134
            }
135
           
136
            final TopologyPlan plan = manager.createTopologyPlan();
137
            plan.fromJSON(jsonPlan);
138
            JTopologyReport panel = swingManager.createJTopologyReport(plan);
139
            panel.put(plan);
140
            winManager.showWindow(
141
                    panel.asJComponent(), 
142
                    i18n.getTranslation("_Topology_plan_error_inspector") + " ("+plan.getName()+")",
143
                    WindowManager.MODE.TOOL
144
            );
145

  
146
            Thread th = new Thread(new Runnable() {
147
                @Override
148
                public void run() {
149
                    plan.execute();
150
                }
151
            }, "TopologyPlan-"+ plan.getName());
152
            th.start();
153
        }
154
    }
155

  
156
    @Override
157
    public boolean isEnabled() {
158
        ApplicationManager application = ApplicationLocator.getManager();
159
        Document view = application.getActiveDocument(ViewManager.TYPENAME);
160
        return view!=null;
161
    }
162

  
163
    @Override
164
    public boolean isVisible() {
165
        return true;
166
    }
167
    
168
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.6/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.HashMap;
29
import java.util.List;
30
import java.util.Map;
31
import javax.swing.ImageIcon;
32
import javax.swing.tree.TreeModel;
33
import org.apache.commons.lang3.mutable.Mutable;
34
import org.apache.commons.lang3.mutable.MutableObject;
35
import org.gvsig.andami.IconThemeHelper;
36
import org.gvsig.andami.PluginsLocator;
37
import org.gvsig.app.ApplicationLocator;
38
import org.gvsig.app.ApplicationManager;
39
import org.gvsig.app.project.Project;
40
import org.gvsig.app.project.documents.Document;
41
import org.gvsig.app.project.documents.view.ViewDocument;
42
import org.gvsig.app.project.documents.view.ViewManager;
43
import org.gvsig.fmap.dal.EditingNotification;
44
import org.gvsig.fmap.dal.EditingNotificationManager;
45
import org.gvsig.fmap.dal.feature.FeatureStore;
46
import org.gvsig.fmap.dal.swing.DALSwingLocator;
47
import org.gvsig.fmap.geom.Geometry;
48
import org.gvsig.fmap.geom.aggregate.MultiCurve;
49
import org.gvsig.fmap.geom.aggregate.MultiPoint;
50
import org.gvsig.fmap.geom.aggregate.MultiSurface;
51
import org.gvsig.fmap.geom.primitive.Curve;
52
import org.gvsig.fmap.geom.primitive.Envelope;
53
import org.gvsig.fmap.geom.primitive.Point;
54
import org.gvsig.fmap.geom.primitive.Surface;
55
import org.gvsig.fmap.mapcontext.MapContext;
56
import org.gvsig.fmap.mapcontext.MapContextLocator;
57
import org.gvsig.fmap.mapcontext.ViewPort;
58
import org.gvsig.fmap.mapcontext.events.ColorEvent;
59
import org.gvsig.fmap.mapcontext.events.ExtentEvent;
60
import org.gvsig.fmap.mapcontext.events.ProjectionEvent;
61
import org.gvsig.fmap.mapcontext.events.listeners.ViewPortListener;
62
import org.gvsig.fmap.mapcontext.layers.FLayer;
63
import org.gvsig.fmap.mapcontext.layers.FLayers;
64
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
65
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer;
66
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
67
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol_v2;
68
import org.gvsig.fmap.mapcontrol.MapControlLocator;
69
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor;
70
import org.gvsig.tools.dynobject.DynObject;
71
import org.gvsig.tools.exception.BaseException;
72
import org.gvsig.tools.observer.Observable;
73
import org.gvsig.tools.observer.Observer;
74
import org.gvsig.tools.swing.api.ListElement;
75
import org.gvsig.tools.visitor.VisitCanceledException;
76
import org.gvsig.tools.visitor.Visitor;
77
import org.gvsig.topology.lib.api.TopologyDataSet;
78
import org.gvsig.topology.swing.api.TopologySwingServices;
79
import org.slf4j.Logger;
80
import org.slf4j.LoggerFactory;
81

  
82
/**
83
 *
84
 * @author jjdelcerro
85
 */
86
@SuppressWarnings("UseSpecificCatch")
87
public class AppTopologyServices implements TopologySwingServices {
88

  
89
    private static final Logger LOGGER = LoggerFactory.getLogger(AppTopologyServices.class);
90

  
91
    private class WorkingAreaViewPortListener implements ViewPortListener {
92

  
93
        private WorkingAreaChangedListener workingAreaChangedListener;
94
        private ViewPort viewPort;
95

  
96
        public WorkingAreaViewPortListener(ViewPort viewPort, WorkingAreaChangedListener workingAreaChangedListener) {
97
            this.workingAreaChangedListener = workingAreaChangedListener;
98
            this.viewPort = viewPort;
99
        }
100

  
101
        public ViewPort getViewPort() {
102
            return this.viewPort;
103
        }
104

  
105
        @Override
106
        public void extentChanged(ExtentEvent e) {
107
            this.workingAreaChangedListener.workingAreaChanged(e.getNewExtent());
108
        }
109

  
110
        @Override
111
        public void backColorChanged(ColorEvent e) {
112
        }
113

  
114
        @Override
115
        public void projectionChanged(ProjectionEvent e) {
116
        }
117
    }
118

  
119
    private class EditingNotificationObserver implements Observer {
120

  
121
        public EditingNotificationObserver() {
122

  
123
        }
124

  
125
        @Override
126
        public void update(Observable o, Object notification) {
127
            EditingNotification n = (EditingNotification) notification;
128
            if (n.isCancelable() && n.getFeature() != null) {
129
                try {
130
                    DynObject data = n.getFeature().getAsDynObject();
131
                    DynObjectEditor editor = new DynObjectEditor(data);
132
                    editor.setTitle("Topology - " + n.getFeature().getType().getName());
133
                    editor.editObject(true);
134
                    if (editor.isCanceled()) {
135
                        n.cancel();
136
                    } else {
137
                        editor.getData(data);
138
                    }
139
                } catch (Exception ex) {
140
                    LOGGER.warn("Problems showing the feature in a form.", ex);
141
                }
142
            }
143
        }
144
    }
145

  
146
    private Map<WorkingAreaChangedListener, WorkingAreaViewPortListener> workingAreaListener;
147
    private ISymbol errorPolygonSymbol = null;
148
    private ISymbol errorPointSymbol = null;
149
    private ISymbol errorLineSymbol = null;
150
    private EditingNotificationObserver editingNotificationObserver = null;
151

  
152
    public AppTopologyServices() {
153
        this.workingAreaListener = new HashMap<>();
154
    }
155

  
156
    @Override
157
    public TreeModel getDataSetTreeModel() {
158
        ApplicationManager application = ApplicationLocator.getManager();
159
        ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
160
        return new DataSetsTreeModel(this, view);
161
    }
162

  
163
    @Override
164
    public FeatureStore getFeatureStore(final TopologyDataSet dataSet) {
165
        final Mutable<FeatureStore> store = new MutableObject<>();
166
        store.setValue(null);
167

  
168
        ApplicationManager application = ApplicationLocator.getManager();
169
        Project project = application.getCurrentProject();
170

  
171
        List<Document> views = new ArrayList<>();
172
        views.add(project.getActiveDocument(ViewManager.TYPENAME));
173
//        views.addAll(project.getDocuments(ViewManager.TYPENAME));
174

  
175
        for (Document view : views) {
176
            if (view == null) {
177
                continue;
178
            }
179
            FLayers layers = ((ViewDocument) view).getMapContext().getLayers();
180
            try {
181
                layers.accept(new Visitor() {
182
                    @Override
183
                    public void visit(Object o) throws VisitCanceledException, BaseException {
184
                        if (o instanceof FLyrVect) {
185
                            FLyrVect layer = (FLyrVect) o;
186
                            if (dataSet.isThisStore(layer.getFeatureStore())) {
187
                                store.setValue(layer.getFeatureStore());
188
                                throw new VisitCanceledException();
189
                            }
190
                        }
191
                    }
192
                });
193
            } catch (VisitCanceledException ex) {
194
                break;
195
            } catch (Exception ex) {
196
                throw new RuntimeException(ex);
197
            }
198
        }
199
        return store.getValue();
200
    }
201

  
202
    @Override
203
    public void zoomTo(Envelope envelope) {
204
        ApplicationManager application = ApplicationLocator.getManager();
205
        ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
206
        if (viewdoc == null) {
207
            return;
208
        }
209
        ViewPort viewPort = viewdoc.getMapContext().getViewPort();
210
        viewPort.setEnvelope(envelope);
211
    }
212

  
213
    @Override
214
    public void refreshView() {
215
        try {
216
            ApplicationManager application = ApplicationLocator.getManager();
217
            ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
218
            if (viewdoc == null) {
219
                return;
220
            }
221
            viewdoc.getMapContext().invalidate();
222
        } catch (Exception ex) {
223
            LOGGER.warn("Cant refresh view", ex);
224
        }
225
    }
226

  
227
    @Override
228
    public void centerTo(Point point) {
229
        try {
230
            ApplicationManager application = ApplicationLocator.getManager();
231
            ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
232
            if (viewdoc == null) {
233
                return;
234
            }
235
            ViewPort viewPort = viewdoc.getMapContext().getViewPort();
236
            Envelope envelope = (Envelope) viewPort.getEnvelope().clone();
237
            envelope.centerTo(point);
238
            viewPort.setEnvelope(envelope);
239
        } catch (Exception ex) {
240
            LOGGER.warn("Cant center view", ex);
241
        }
242
    }
243

  
244
    @Override
245
    public Envelope getWorkingArea() {
246
        ApplicationManager application = ApplicationLocator.getManager();
247
        ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
248
        if (viewdoc == null) {
249
            return null;
250
        }
251
        ViewPort viewPort = viewdoc.getMapContext().getViewPort();
252
        return viewPort.getEnvelope();
253
    }
254

  
255
    @Override
256
    public void addWorkingAreaChangedListener(WorkingAreaChangedListener listener) {
257
        ApplicationManager application = ApplicationLocator.getManager();
258
        ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
259
        if (viewdoc == null) {
260
            return;
261
        }
262
        ViewPort viewPort = viewdoc.getMapContext().getViewPort();
263
        WorkingAreaViewPortListener viewPortListener = this.workingAreaListener.get(listener);
264
        if (viewPortListener == null) {
265
            viewPortListener = new WorkingAreaViewPortListener(viewPort, listener);
266
            this.workingAreaListener.put(listener, viewPortListener);
267
        } else {
268
            if (viewPort != viewPortListener.getViewPort()) {
269
                viewPortListener.getViewPort().removeViewPortListener(viewPortListener);
270
                viewPortListener = new WorkingAreaViewPortListener(viewPort, listener);
271
                this.workingAreaListener.put(listener, viewPortListener);
272
            }
273
        }
274
        viewPortListener.getViewPort().addViewPortListener(viewPortListener);
275
    }
276

  
277
    @Override
278
    public void removeWorkingAreaChangedListener(WorkingAreaChangedListener listener) {
279
        WorkingAreaViewPortListener viewPortListener = this.workingAreaListener.get(listener);
280
        if (viewPortListener == null) {
281
            return;
282
        }
283
        viewPortListener.getViewPort().removeViewPortListener(viewPortListener);
284
    }
285

  
286
    @Override
287
    public void addError(Geometry geom) {
288
        if (this.errorPointSymbol == null) {
289
            try {
290
                File pluginfolder = PluginsLocator.getManager().getPlugin(this).getPluginDirectory();
291
                File folder = new File(pluginfolder, "symbols");
292
                ISymbol[] symbols = MapContextLocator.getSymbolManager().loadSymbols(folder);
293
                for (ISymbol symbol : symbols) {
294
                    if (symbol instanceof ISymbol_v2) {
295
                        String symbolid = ((ISymbol_v2) symbol).getID();
296
                        switch(symbolid) {
297
                            case "topology-error-polygon":
298
                                this.errorPolygonSymbol = symbol;
299
                                break;
300
                            case "topology-error-line":
301
                                this.errorLineSymbol = symbol;
302
                                break;
303
                            case "topology-error-point":
304
                                this.errorPointSymbol = symbol;
305
                                break;
306
                        }
307
                    }
308
                }
309
            } catch (Exception ex) {
310
            }
311
        }
312
        ApplicationManager application = ApplicationLocator.getManager();
313
        ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
314
        MapContext mapContext = viewdoc.getMapContext();
315
        GraphicLayer gl = mapContext.getGraphicsLayer();
316
        gl.removeGraphics("topology-errors");
317
        if ( geom!=null ) {
318
            ISymbol symbol = null;
319
            if( geom instanceof Point || geom instanceof MultiPoint) {
320
                symbol = this.errorPointSymbol;
321
            } else if( geom instanceof Curve || geom instanceof MultiCurve ) {
322
                symbol = this.errorLineSymbol;
323
            } else if( geom instanceof Surface || geom instanceof MultiSurface ) {
324
                symbol = this.errorPolygonSymbol;
325
            }
326
            if (symbol != null) {
327
                int symbolid = gl.getSymbolId(symbol);
328
                if (symbolid < 0) {
329
                    gl.addSymbol(symbol);
330
                    symbolid = gl.getSymbolId(symbol);
331
                }
332
                gl.addGraphic("topology-errors", geom, symbolid);
333
            }
334
        }
335
        mapContext.invalidate();
336
    }
337

  
338
    @Override
339
    public void setShowFormWhenEdit(boolean showFormWhenEdit) {
340
        if (this.editingNotificationObserver == null) {
341
            this.editingNotificationObserver = new EditingNotificationObserver();
342
        }
343
        EditingNotificationManager editingNotificationManager = DALSwingLocator.getEditingNotificationManager();
344
        if (showFormWhenEdit) {
345
            editingNotificationManager.addObserver(this.editingNotificationObserver);
346
        } else {
347
            editingNotificationManager.deleteObserver(this.editingNotificationObserver);
348
        }
349
    }
350

  
351
    @Override
352
    public ImageIcon getTreeIcon(TreeModel model, Object item) {
353
        return ((DataSetsTreeModel)model).getTreeIcon(item);
354
    }
355

  
356
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.6/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
  <resourceBundle name="text" />
16
  <libraries library-dir="lib" />
17
  <extensions>
18

  
19

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

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

  
57

  
58
  </extensions>
59
</plugin-config>
org.gvsig.topology/tags/org.gvsig.topology-1.0.6/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
org.gvsig.topology/tags/org.gvsig.topology-1.0.6/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
org.gvsig.topology/tags/org.gvsig.topology-1.0.6/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.6</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
  </dependencies>
37

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

  
51
</project>
0 52

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.6/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/TopologyImplLibrary.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.lib.impl;
25

  
26
import org.gvsig.fmap.dal.DALLibrary;
27
import org.gvsig.fmap.geom.GeometryLibrary;
28
import org.gvsig.tools.ToolsLibrary;
29
import org.gvsig.tools.library.AbstractLibrary;
30
import org.gvsig.tools.library.LibraryException;
31
import org.gvsig.topology.lib.api.TopologyLibrary;
32
import org.gvsig.topology.lib.api.TopologyLocator;
33
import org.gvsig.topology.lib.api.TopologyManager;
34
import org.gvsig.topology.rule.ContainsNullRuleFactory;
35
import org.gvsig.topology.rule.ContainsPointRuleFactory;
36
import org.gvsig.topology.rule.MustBeLargerThanToleranceLineRuleFactory;
37
import org.gvsig.topology.rule.MustNotOverlapPolygonRuleFactory;
38
import org.gvsig.topology.rule.PointMustBeProperlyInsidePolygonRuleFactory;
39

  
40
/**
41
 *
42
 * @author jjdelcerro
43
 */
44
public class TopologyImplLibrary extends AbstractLibrary {
45

  
46
    @Override
47
    public void doRegistration() {
48
        super.doRegistration();
49
        registerAsImplementationOf(TopologyLibrary.class);
50
        this.require(ToolsLibrary.class);
51
        this.require(DALLibrary.class);
52
        this.require(GeometryLibrary.class);
53
    }
54

  
55
    @Override
56
    protected void doInitialize() throws LibraryException {
57
        TopologyLocator.registerDefaultTopologyManager(DefaultTopologyManager.class);
58
    }
59

  
60
    @Override
61
    protected void doPostInitialize() throws LibraryException {
62
        ContainsNullRuleFactory.selfRegister();
63
        ContainsPointRuleFactory.selfRegister();
64
        MustBeLargerThanToleranceLineRuleFactory.selfRegister();
65
        MustNotOverlapPolygonRuleFactory.selfRegister();
66
        PointMustBeProperlyInsidePolygonRuleFactory.selfRegister();
67
    }
68

  
69
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.6/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/DefaultTopologyReportLine.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.lib.impl;
25

  
26
import org.gvsig.fmap.dal.feature.FeatureReference;
27
import org.gvsig.fmap.geom.Geometry;
28
import org.gvsig.topology.lib.api.TopologyDataSet;
29
import org.gvsig.topology.lib.api.TopologyReport;
30
import org.gvsig.topology.lib.api.TopologyReportLine;
31
import org.gvsig.topology.lib.api.TopologyRule;
32

  
33
/**
34
 *
35
 * @author jjdelcerro
36
 */
37
public class DefaultTopologyReportLine implements TopologyReportLine {
38
    
39
    private final TopologyReport report;
40
    private final TopologyRule rule;
41
    private final TopologyDataSet dataSet1;
42
    private final TopologyDataSet dataSet2;
43
    private final Geometry geometry;
44
    private final FeatureReference feature1;
45
    private final FeatureReference feature2;
46
    private final int primitive1;
47
    private final int primitive2;
48
    private boolean exception;
49
    private final String description;
50
    private final String data;
51
    private final Geometry errorGeometry;
52
    
53
    DefaultTopologyReportLine(DefaultTopologyReport report, 
54
            TopologyRule rule, 
55
            TopologyDataSet dataSet1, 
56
            TopologyDataSet dataSet2, 
57
            Geometry geometry,
58
            Geometry error,
59
            FeatureReference feature1, 
60
            FeatureReference feature2, 
61
            int primitive1,
62
            int primitive2,
63
            boolean exception,
64
            String description,
65
            String data
66
        ) {
67
        this.report = report;
68
        this.rule = rule;
69
        this.dataSet1 = dataSet1;
70
        this.dataSet2 = dataSet2;
71
        this.geometry = geometry;
72
        this.feature1 = feature1;
73
        this.feature2 = feature2;
74
        this.primitive1 = primitive1;
75
        this.primitive2 = primitive2;
76
        this.exception = exception;
77
        this.description = description;
78
        this.errorGeometry = error;
79
        this.data = data;
80
    }
81

  
82
    @Override
83
    public TopologyRule getRule() {
84
        return this.rule;
85
    }
86

  
87
    @Override
88
    public TopologyDataSet getDataSet1() {
89
        return this.dataSet1;
90
    }
91

  
92
    @Override
93
    public TopologyDataSet getDataSet2() {
94
        return this.dataSet2;
95
    }
96

  
97
    @Override
98
    public Geometry getGeometry() {
99
        return this.geometry;
100
    }
101

  
102
    @Override
103
    public FeatureReference getFeature1() {
104
        return this.feature1;
105
    }
106

  
107
    @Override
108
    public FeatureReference getFeature2() {
109
        return this.feature2;
110
    }
111

  
112
    @Override
113
    public boolean isException() {
114
        return this.exception;
115
    }
116
    
117
    public void setException(boolean exception) {
118
        this.exception = exception;
119
    }
120

  
121
    @Override
122
    public String getDescription() {
123
        return description;
124
    }
125

  
126
    @Override
127
    public Geometry getError() {
128
        return this.errorGeometry;
129
    }
130

  
131
    @Override
132
    public int getPrimitiveNumber1() {
133
        return this.primitive1;
134
    }
135

  
136
    @Override
137
    public int getPrimitiveNumber2() {
138
        return this.primitive2;
139
    }
140

  
141
    @Override
142
    public String getData() {
143
        return this.data;
144
    }
145
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.6/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/DefaultTopologyDataSet.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.lib.impl;
25

  
26
import java.util.Iterator;
27
import java.util.Map;
28
import org.apache.commons.collections.IteratorUtils;
29
import org.apache.commons.lang3.StringUtils;
30
import org.apache.commons.lang3.mutable.MutableObject;
31
import org.gvsig.expressionevaluator.Expression;
32
import org.gvsig.expressionevaluator.ExpressionBuilder;
33
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
34
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager;
35
import org.gvsig.fmap.dal.DataStore;
36
import org.gvsig.fmap.dal.EditingNotification;
37
import org.gvsig.fmap.dal.EditingNotificationManager;
38
import org.gvsig.fmap.dal.exception.DataException;
39
import org.gvsig.fmap.dal.feature.EditableFeature;
40
import org.gvsig.fmap.dal.feature.Feature;
41
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
42
import org.gvsig.fmap.dal.feature.FeatureReference;
43
import org.gvsig.fmap.dal.feature.FeatureSet;
44
import org.gvsig.fmap.dal.feature.FeatureStore;
45
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory;
46
import org.gvsig.fmap.dal.feature.FeatureType;
47
import org.gvsig.fmap.dal.swing.DALSwingLocator;
48
import org.gvsig.fmap.geom.Geometry;
49
import org.gvsig.fmap.geom.GeometryLocator;
50
import org.gvsig.fmap.geom.GeometryManager;
51
import org.gvsig.fmap.geom.GeometryUtils;
52
import org.gvsig.fmap.geom.SpatialIndex;
53
import org.gvsig.fmap.geom.type.GeometryType;
54
import org.gvsig.tools.dispose.DisposableIterator;
55
import org.gvsig.tools.exception.BaseException;
56
import org.gvsig.tools.util.PropertiesSupportHelper;
57
import org.gvsig.tools.visitor.VisitCanceledException;
58
import org.gvsig.tools.visitor.Visitor;
59
import org.gvsig.topology.lib.api.CancelOperationException;
60
import org.gvsig.topology.lib.api.PerformOperationException;
61
import org.gvsig.topology.lib.api.TopologyDataSet;
62
import org.gvsig.topology.lib.api.TopologyLocator;
63
import org.gvsig.topology.lib.api.TopologyManager;
64
import org.json.JSONObject;
65
import org.gvsig.topology.lib.api.TopologyServices;
66
import org.slf4j.Logger;
67
import org.slf4j.LoggerFactory;
68

  
69
/**
70
 *
71
 * @author jjdelcerro
72
 */
73
@SuppressWarnings({"EqualsAndHashcode","UseSpecificCatch"})
74
public class DefaultTopologyDataSet implements TopologyDataSet {
75

  
76
    private final static Logger LOGGER = LoggerFactory.getLogger(DefaultTopologyDataSet.class);
77
    
78
    private TopologyServices services;
79
    private String name;
80
    private DataStore store;
81
    private boolean needFinishEditing;
82
    private String fullName;
83
    private PropertiesSupportHelper propertiesHelper;
84
    private MutableObject<SpatialIndex> spatialIndex = null;
85
    
86
    public DefaultTopologyDataSet() {
87
        this.services = null;
88
        this.name = null;
89
        this.store = null;
90
        this.needFinishEditing = false;
91
        this.fullName = null;
92
        this.propertiesHelper = new PropertiesSupportHelper();
93
    }
94

  
95
    public DefaultTopologyDataSet(TopologyServices services, String name, DataStore store) {
96
        this.services = services;
97
        this.name = name;
98
        this.store = store;
99
        this.needFinishEditing = false;
100
        if( store!=null ) {
101
            this.fullName = store.getFullName();
102
        }
103
    }
104

  
105
    @Override
106
    public void restart() {
107
        this.store  = null;
108
        this.spatialIndex = null;
109
    }
110
    
111
    @Override
112
    public boolean equals(Object obj) {
113
        if( !(obj instanceof DefaultTopologyDataSet) ) {
114
            return false;
115
        }
116
        DefaultTopologyDataSet other = (DefaultTopologyDataSet)obj;
117
        if( this.store != other.store ) {
118
            return false;
119
        }
120
        if( !StringUtils.equals(this.getName(), other.getName()) ) {
121
            return false;
122
        }
123
        return true;
124
    }
125

  
126
    @Override
127
    public String getName() {
128
        return this.name;
129
    }
130

  
131
    @Override
132
    public void setName(String name) {
133
        this.name = name;
134
    }
135

  
136
    @Override
137
    public String toString() {
138
        try {
139
            FeatureAttributeDescriptor attr = this.getFeatureStore().getDefaultFeatureType().getDefaultGeometryAttribute();
140
            String geomType = attr.getGeomType().getName();
141
            return this.name + " ("+ geomType + ")";
142
        } catch(Exception ex) {
143
            return this.name ;
144
        }
145
    }
146

  
147
    @Override
148
    public DataStore getStore() {
149
        if (this.store == null) {
150
            this.store = this.services.getFeatureStore(this);
151
        }
152
        return this.store;
153
    }
154

  
155
    @Override
156
    public FeatureStore getFeatureStore() {
157
        if (this.store == null) {
158
            this.store = this.services.getFeatureStore(this);
159
        }
160
        return (FeatureStore) this.store;
161
    }
162

  
163
    @Override
164
    public long getSize() {
165
        try {
166
            long size = this.getFeatureStore().getFeatureCount();
167
            return size;
168
        } catch (DataException ex) {
169
            // TODO: mensage al log
170
            return 0;
171
        }
172
    }
173

  
174
    @Override
175
    public boolean isThisStore(FeatureStore store) {
176
        if( store == null ) {
177
            return false;
178
        }
179
        return StringUtils.equals(this.fullName, store.getFullName());
180
    }
181
    
182
    @Override
183
    public int getGeometryType() {
184
        try {
185
            FeatureStore theStore = this.getFeatureStore();
186
            FeatureType featureType = theStore.getDefaultFeatureType();
187
            FeatureAttributeDescriptor attr = featureType.getDefaultGeometryAttribute();
188
            GeometryType geomType = attr.getGeomType();
189
            return geomType.getType();
190
        } catch (Exception ex) {
191
            return Geometry.TYPES.GEOMETRY;
192
        }
193
    }
194

  
195
    @Override
196
    public void accept(Visitor visitor) throws VisitCanceledException {
197
        FeatureStore st = this.getFeatureStore();
198
        try {
199
            st.accept(visitor);
200
        } catch(VisitCanceledException ex) {
201
            throw ex;
202
        } catch(BaseException ex) {
203
            throw new RuntimeException(ex);
204
        }
205
    }
206

  
207
    @Override
208
    public void edit() throws DataException {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff