Revision 2900

View differences:

org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.170/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/test/resources/README.txt
1
====
2
    gvSIG. Desktop Geographic Information System.
3

  
4
    Copyright (C) 2007-2012 gvSIG Association.
5

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

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

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

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

  
25
Put into this folder the resources needed by your test classes.
26

  
27
This folder is added to the Tests classpath, so you can load any resources 
28
through the ClassLoader.
29

  
30
By default, in this folder you can find an example of log4j configuration,
31
prepared to log messages through the console, so logging works when you
32
run your tests classes.
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.170/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2012 gvSIG Association.
7

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

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

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

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

  
26
-->
27
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
28

  
29
<!-- 
30
Log4J configuration file for unit tests execution.
31
 -->
32
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
33

  
34
	<!-- Appender configuration to show logging messages through the console -->
35
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
36
		<layout class="org.apache.log4j.PatternLayout">
37
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
38
		</layout>
39
	</appender>
40

  
41
	<!-- 
42
	Activate logging messages of DEBUG level of higher only for the
43
	org.gvsig.tools packages.
44
	You can put full classes names or packages instead, to configure
45
	logging for all the classes and subpackages of the package.
46
	-->
47
	<category name="org.gvsig.tools">
48
		<priority value="DEBUG" />
49
	</category>
50
	<category name="org.gvsig.vectorediting">
51
		<priority value="DEBUG" />
52
	</category>
53

  
54
	<!-- 
55
	By default, show only logging messages of INFO level or higher, 
56
	through the previously configured CONSOLE appender. 
57
	-->
58
	<root>
59
		<priority value="INFO" />
60
		<appender-ref ref="CONSOLE" />
61
	</root>
62
</log4j:configuration>
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.170/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.vectorediting.swing.impl.DefaultEditingSwingLibrary
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.170/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/DefaultEditingSwingLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2014 gvSIG Association
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.vectorediting.swing.impl;
26

  
27
import org.gvsig.fmap.dal.DALLibrary;
28
import org.gvsig.fmap.geom.GeometryLibrary;
29
import org.gvsig.fmap.mapcontrol.MapControlLibrary;
30
import org.gvsig.fmap.mapcontrol.MapControlLocator;
31
import org.gvsig.fmap.mapcontrol.MapControlManager;
32
import org.gvsig.tools.library.AbstractLibrary;
33
import org.gvsig.tools.library.LibraryException;
34
import org.gvsig.vectorediting.swing.api.EditingSwingLibrary;
35
import org.gvsig.vectorediting.swing.api.EditingSwingLocator;
36

  
37
public class DefaultEditingSwingLibrary extends AbstractLibrary {
38

  
39
    @Override
40
    public void doRegistration() {
41
        registerAsImplementationOf(EditingSwingLibrary.class);
42
        require(DALLibrary.class);
43
        require(MapControlLibrary.class);
44
        require(GeometryLibrary.class);
45
    }
46

  
47
    @Override
48
    protected void doInitialize() throws LibraryException {
49
        EditingSwingLocator.registerManager(DefaultEditingSwingManager.class);
50
    }
51

  
52
    @Override
53
    protected void doPostInitialize() throws LibraryException {
54
        MapControlManager mapControlManager =
55
            MapControlLocator.getMapControlManager();
56

  
57
        mapControlManager
58
        .addMapControlCreationListener(new DefaultMapCreationListener());
59
    }
60

  
61
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.170/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/SelectionBehavior.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2014 gvSIG Association
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.vectorediting.swing.impl;
26

  
27
import java.awt.event.InputEvent;
28
import java.awt.event.MouseEvent;
29
import java.awt.event.MouseWheelEvent;
30

  
31
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
32
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
33
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
34

  
35
public class SelectionBehavior extends Behavior {
36

  
37
    @Override
38
    public ToolListener getListener() {
39
        // TODO Auto-generated method stub
40
        return null;
41
    }
42

  
43
    @Override
44
    public void mouseClicked(MouseEvent e) throws BehaviorException {
45
        int clickWithShiftDown =
46
            InputEvent.SHIFT_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK;
47
        int ctrlDown = InputEvent.CTRL_DOWN_MASK;
48
        if ((e.getModifiersEx() & (clickWithShiftDown | ctrlDown)) == clickWithShiftDown) {
49

  
50
        }
51

  
52
    }
53

  
54
    @Override
55
    public void mouseEntered(MouseEvent e) throws BehaviorException {
56
        // TODO Auto-generated method stub
57

  
58
    }
59

  
60
    @Override
61
    public void mouseExited(MouseEvent e) throws BehaviorException {
62
        // TODO Auto-generated method stub
63

  
64
    }
65

  
66
    @Override
67
    public void mousePressed(MouseEvent e) throws BehaviorException {
68
        // TODO Auto-generated method stub
69

  
70
    }
71

  
72
    @Override
73
    public void mouseReleased(MouseEvent e) throws BehaviorException {
74
        // TODO Auto-generated method stub
75

  
76
    }
77

  
78
    @Override
79
    public void mouseDragged(MouseEvent e) throws BehaviorException {
80
        // TODO Auto-generated method stub
81

  
82
    }
83

  
84
    @Override
85
    public void mouseMoved(MouseEvent e) throws BehaviorException {
86
        // TODO Auto-generated method stub
87

  
88
    }
89

  
90
    @Override
91
    public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException {
92
        // TODO Auto-generated method stub
93

  
94
    }
95

  
96
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.170/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/EditingContextSymbolTable.java
1
/*
2
 * gvSIG. Desktop Geographic Information System.
3
 * 
4
 * Copyright (C) 2007-2020 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, see <https://www.gnu.org/licenses/>. 
18
 * 
19
 * For any additional information, do not hesitate to contact us
20
 * at info AT gvsig.com, or visit our website www.gvsig.com.
21
 */
22

  
23
package org.gvsig.vectorediting.swing.impl;
24

  
25
import java.util.ArrayList;
26
import java.util.Collection;
27
import java.util.Collections;
28
import java.util.List;
29
import org.apache.commons.lang3.StringUtils;
30
import org.gvsig.expressionevaluator.ExpressionUtils;
31
import org.gvsig.expressionevaluator.spi.AbstractSymbolTable;
32
import org.gvsig.fmap.geom.Geometry;
33
import org.gvsig.fmap.geom.primitive.Point;
34
import org.gvsig.temporarystorage.TemporaryStorageGroup;
35
import org.gvsig.temporarystorage.TemporaryStorageLocator;
36
import org.gvsig.temporarystorage.TemporaryStorageManager;
37

  
38
/**
39
 *
40
 * @author gvSIG Team
41
 */
42
public class EditingContextSymbolTable extends AbstractSymbolTable {
43

  
44
    private static class ListWithMaximumSize<T> extends ArrayList<T> {
45
        
46
        private final int maximumSize;
47
        
48
        public ListWithMaximumSize(int maximumSize) {
49
            this.maximumSize = maximumSize;
50
        }
51

  
52
        @Override
53
        public boolean add(T e) {
54
            if( this.size()>this.maximumSize ) {
55
                this.remove(0);
56
            }
57
            return super.add(e);
58
        }
59

  
60
        @Override
61
        public void add(int index, T element) {
62
            if( this.size()>this.maximumSize ) {
63
                this.remove(0);
64
            }
65
            super.add(index, element);
66
        }
67
    }
68

  
69
    private final List<Point> lastPoints;
70
    private final TemporaryStorageGroup globalPointsStorage;
71
    
72
    public EditingContextSymbolTable() {
73
        this.lastPoints = new ListWithMaximumSize(100);
74
        TemporaryStorageManager manager = TemporaryStorageLocator.getTemporaryStorageManager();
75
        this.globalPointsStorage = manager.create("Points",Point.class);
76
        this.addSymbolTable(ExpressionUtils.createSymbolTable());
77
    }
78
    
79
    public void addPoint(Point point) {
80
        this.lastPoints.add(point);
81
    }
82

  
83
    @Override
84
    public boolean exists(String name) {
85
        if( globalPointsStorage.contains(name) ) {
86
            return true;
87
        }
88
        if( globalPointsStorage.contains(name+"$x") ) {
89
            return true;
90
        }
91
        if( globalPointsStorage.contains(name+"$y") ) {
92
            return true;
93
        }
94
        if( this.lastPoints.isEmpty() || StringUtils.isBlank(name) ) {
95
            return false;
96
        }
97
        name = name.toLowerCase();
98
        int index = -1;
99
        if( name.length()==2 ) {
100
            index = this.lastPoints.size()-1;
101
        } else if( name.length()<3 ) {
102
            return false;
103
        } else {
104
            try {
105
                index = Integer.parseUnsignedInt(name.substring(2));
106
            } catch(NumberFormatException ex) {
107
                return false;
108
            }
109
        }
110
        if( index < 0 || index >= this.lastPoints.size() ) {
111
            return false;
112
        }
113
        if( name.startsWith("$p") || name.startsWith("$x") || name.startsWith("$y") ) {
114
            return true;
115
        }
116
        return false;
117
    }
118

  
119
    @Override
120
    public Object value(String name) {
121
        if( globalPointsStorage.contains(name) ) {
122
            return globalPointsStorage.get(name);
123
        }
124
        if( globalPointsStorage.contains(name+"$x") ) {
125
            Point point = (Point) globalPointsStorage.get(name+"$x");
126
            return point.getX();
127
        }
128
        if( globalPointsStorage.contains(name+"$y") ) {
129
            Point point = (Point) globalPointsStorage.get(name+"$y");
130
            return point.getY();
131
        }
132
        if( this.lastPoints.isEmpty() || StringUtils.isBlank(name) ) {
133
            return null;
134
        }
135
        name = name.toLowerCase();
136
        int index = -1;
137
        if( name.length()==2 ) {
138
            index = 0;
139
        } else if( name.length()<3 ) {
140
            return null;
141
        } else {
142
            try {
143
                index = Integer.parseUnsignedInt(name.substring(2));
144
            } catch(NumberFormatException ex) {
145
                return null;
146
            }
147
        }
148
        if( index < 0 || index >= this.lastPoints.size() ) {
149
            return false;
150
        }
151
        // El index 0 es el ultimo en la lista
152
        index =  (this.lastPoints.size() - index) - 1;
153
        
154
        if( name.startsWith("$p") ) {
155
            Point point = this.lastPoints.get(index);
156
            return point;
157
        }
158
        if( name.startsWith("$x") ) {
159
            Point point = this.lastPoints.get(index);
160
            return point.getX();
161
        }
162
        if( name.startsWith("$y") ) {
163
            Point point = this.lastPoints.get(index);
164
            return point.getY();
165
        }
166
        return null;
167
    }
168

  
169
    @Override
170
    public Collection<String> localvariables() {
171
        if( this.lastPoints.isEmpty() ) {
172
            return Collections.EMPTY_LIST;
173
        }
174
        List<String> names = new ArrayList<>();
175
        names.add("$p");
176
        names.add("$x");
177
        names.add("$y");
178
        for (int i = 0; i < this.lastPoints.size(); i++) {
179
            names.add("$p"+i);
180
            names.add("$x"+i);
181
            names.add("$y"+i);
182
        }
183
        return names;
184
    }
185
    
186
    
187
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.170/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/DefaultEditingBehavior.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2014 gvSIG Association
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.vectorediting.swing.impl;
26

  
27
import java.awt.Color;
28
import java.awt.Graphics;
29
import java.awt.Image;
30
import java.awt.event.MouseEvent;
31
import java.awt.geom.Point2D;
32
import java.awt.image.BufferedImage;
33
import java.util.Iterator;
34
import java.util.Set;
35
import javax.swing.SwingUtilities;
36
import org.gvsig.fmap.geom.Geometry;
37
import org.gvsig.fmap.geom.GeometryLocator;
38
import org.gvsig.fmap.geom.aggregate.MultiPoint;
39
import org.gvsig.fmap.geom.primitive.Point;
40
import org.gvsig.fmap.mapcontext.ViewPort;
41
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
42
import org.gvsig.fmap.mapcontext.rendering.symbols.ITextSymbol;
43
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
44
import org.gvsig.fmap.mapcontrol.MapControlLocator;
45
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
46
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
47
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
48
import org.gvsig.tools.ToolsLocator;
49
import org.gvsig.tools.exception.BaseException;
50
import org.gvsig.tools.i18n.I18nManager;
51
import org.gvsig.vectorediting.lib.api.DrawingStatus;
52
import org.gvsig.vectorediting.lib.api.DrawingStatus.Status;
53
import org.gvsig.vectorediting.lib.api.EditingService;
54
import org.gvsig.vectorediting.lib.api.EditingServiceParameter;
55
import org.gvsig.vectorediting.lib.api.EditingServiceParameter.TYPE;
56
import org.gvsig.vectorediting.lib.api.exceptions.CreateEditingBehaviorException;
57
import org.gvsig.vectorediting.lib.api.exceptions.VectorEditingException;
58
import org.gvsig.vectorediting.swing.api.EditingSwingLocator;
59
import org.gvsig.vectorediting.swing.api.EditingSwingManager;
60
import org.gvsig.vectorediting.swing.api.contextmenu.EditingContextMenu;
61
import org.slf4j.Logger;
62
import org.slf4j.LoggerFactory;
63

  
64
public class DefaultEditingBehavior extends Behavior {
65

  
66
    private static final Logger logger = LoggerFactory
67
        .getLogger(DefaultEditingBehavior.class);
68

  
69
    private DefaultEditingContext editingContext;
70

  
71
    private Point adjustedPoint;
72

  
73
    private static final Image imageCursor = new BufferedImage(32, 32,
74
        BufferedImage.TYPE_INT_ARGB);
75
    static {
76
        Graphics g = imageCursor.getGraphics();
77
        int size1 = 15;
78
        int x = 16;
79
        int y = 16;
80
        g.setColor(Color.MAGENTA);
81
        g.drawLine((x - size1), (y), (x + size1), (y));
82
        g.drawLine((x), (y - size1), (x), (y + size1));
83
        g.drawRect((x - 6), (y - 6), 12, 12);
84
        g.drawRect((x - 3), (y - 3), 6, 6);
85
    }
86

  
87
    public DefaultEditingBehavior(DefaultEditingContext editingContext)
88
        throws CreateEditingBehaviorException {
89

  
90
        if (editingContext.getMapControl() != null) {
91
            this.editingContext = editingContext;
92
            setMapControl(editingContext.getMapControl());
93
        }
94
    }
95

  
96
    @Override
97
    public ToolListener getListener() {
98
        return new ToolListener() {
99

  
100
            @Override
101
            public boolean cancelDrawing() {
102
                return false;
103
            }
104

  
105
            @Override
106
            public Image getImageCursor() {
107
                return imageCursor;
108
            }
109
        };
110
    }
111

  
112
    @Override
113
    public void mouseClicked(MouseEvent e) {
114
        ViewPort vp = editingContext.getMapControl().getViewPort();
115
        EditingServiceParameter currentParam = editingContext.getCurrentParam();
116
        EditingService activeService = editingContext.getActiveService();
117

  
118
        if ((activeService != null) && (currentParam != null)) {
119

  
120
            if (SwingUtilities.isLeftMouseButton(e)) {
121

  
122
                Set<TYPE> typesOfParam = currentParam.getTypes();
123

  
124
                if (typesOfParam.contains(TYPE.LIST_POSITIONS)) {
125
                    if (e.getClickCount() == 2) {
126
                        editingContext.finishService();
127
                        return;
128
                    }
129
                }
130

  
131
                Point point = null;
132
                Point2D point2D = getMapControl().getMapAdjustedPoint();
133
                if (point2D == null) {
134
                    point2D = getMapControl().getAdjustedPoint();
135
                    point = vp.convertToMapPoint(point2D);
136
                } else {
137
                    try {
138
                        point =
139
                            GeometryLocator.getGeometryManager().createPoint(
140
                                point2D.getX(), point2D.getY(),
141
                                Geometry.SUBTYPES.GEOM2D);
142
                    } catch (BaseException ex) {
143
                        logger.warn("Can't create point geometry from "
144
                            + point2D.toString());
145
                    }
146
                }
147

  
148
                try {
149
                    //FIXME: Estar?a bien hacer esto
150
                    editingContext.setValue(currentParam, point);
151
                    editingContext.nextParameter();
152

  
153
//                    editingContext.getActiveService().setValue(point);
154
                } catch (VectorEditingException ex) {
155
                    I18nManager i18nManager = ToolsLocator.getI18nManager();
156
                    editingContext.showConsoleMessage(i18nManager
157
                        .getTranslation("invalid_option"));
158
                }
159

  
160
//                editingContext.nextParameter();
161

  
162
            } else if (SwingUtilities.isRightMouseButton(e)) {
163

  
164
                EditingSwingManager swingManager =
165
                    EditingSwingLocator.getSwingManager();
166

  
167
                    EditingContextMenu contextMenu =
168
                        swingManager.getContextualMenu(getMapControl(), (Object value) -> {
169
                            editingContext.textEntered((String) value);
170
                    }, currentParam, editingContext);
171

  
172
                    contextMenu.show(getMapControl(), e.getX(), e.getY());
173
            }
174
        }
175
    }
176

  
177
    @Override
178
    public void mouseEntered(MouseEvent e) throws BehaviorException {
179
    }
180

  
181
    @Override
182
    public void mouseMoved(MouseEvent e) throws BehaviorException {
183
        ViewPort vp = editingContext.getMapControl().getViewPort();
184
        adjustedPoint = vp.convertToMapPoint(e.getX(), e.getY());
185
    }
186

  
187
    @Override
188
    public void mousePressed(MouseEvent e) throws BehaviorException {
189
    }
190

  
191
    @Override
192
    public void mouseReleased(MouseEvent e) throws BehaviorException {
193
    }
194

  
195
    @Override
196
    @SuppressWarnings("rawtypes")
197
    public void paintComponent(MapControlDrawer mapControlDrawer) {
198
        super.paintComponent(mapControlDrawer);
199

  
200
        if ((editingContext.getActiveService() == null)
201
            || (adjustedPoint == null)) {
202
            return;
203
        }
204

  
205
        DrawingStatus helperGeo = null;
206

  
207
        try {
208
            helperGeo =
209
                editingContext.getActiveService().getDrawingStatus(
210
                    adjustedPoint);
211
        } catch (VectorEditingException e) {
212
            logger.info("An error ocurred when draw service geometries", e);
213
        }
214

  
215
        if (helperGeo != null) {
216
            for (Iterator iterator = helperGeo.getStatus().iterator(); iterator
217
                .hasNext();) {
218
                Status status = (Status) iterator.next();
219
                ISymbol symbol = status.getSymbol();
220
                if (symbol == null) {
221
                    symbol =
222
                        MapControlLocator.getMapControlManager()
223
                            .getAxisReferenceSymbol();
224
                }
225
                if (symbol instanceof ITextSymbol) {
226
                    ((ITextSymbol) symbol).setText(status.getText());
227
                }
228
                Geometry geom = status.getGeometry();
229
                if(geom != null){
230
                    if(geom.getGeometryType().isTypeOf(Geometry.TYPES.MULTIPOINT)){
231
                        MultiPoint multipoint = (MultiPoint)geom;
232
                        for (Geometry geometry : multipoint) {
233
                            editingContext.getMapControl().getMapControlDrawer()
234
                                .draw(geometry, symbol);
235
                        }
236
                    } else {
237
                        editingContext.getMapControl().getMapControlDrawer()
238
                            .draw(geom, symbol);
239
                    }
240
                }
241
            }
242
        }
243
    }
244
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.170/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/EditingCompoundBehavior.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2014 gvSIG Association
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.vectorediting.swing.impl;
26

  
27
import java.awt.Image;
28
import java.awt.event.MouseEvent;
29
import java.awt.event.MouseWheelEvent;
30

  
31
import org.gvsig.fmap.mapcontrol.MapControl;
32
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
33
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
34
import org.gvsig.fmap.mapcontrol.tools.CompoundBehavior;
35
import org.gvsig.fmap.mapcontrol.tools.PointSelectionListener;
36
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
37
import org.gvsig.fmap.mapcontrol.tools.Behavior.IBehavior;
38
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseWheelBehavior;
39
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior;
40
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
41

  
42
public class EditingCompoundBehavior extends CompoundBehavior {
43

  
44
    private enum Mode {
45
        EDITING, SELECTION
46
    };
47

  
48
    private Mode mode = Mode.EDITING;
49
    private IBehavior editing;
50
    private IBehavior selection;
51

  
52
    public final static int EDITING_INDEX = 0;
53
    public final static int SELECTION_INDEX = 1;
54

  
55
    public EditingCompoundBehavior(IBehavior editing) {
56
        super(new Behavior[0]);
57
        this.editing = editing;
58

  
59
        this.selection = null;
60
    }
61

  
62
    @Override
63
    public void addMapBehavior(Behavior mt, boolean draw) {
64
        if (mt instanceof MouseWheelBehavior) {
65
            return;
66
        }
67
        throw new UnsupportedOperationException();
68
    }
69

  
70
    @Override
71
    public void removeMapBehavior(Behavior mt) {
72
        throw new UnsupportedOperationException();
73
    }
74

  
75
    @Override
76
    public boolean containsBehavior(Behavior mt) {
77
        return ((mt == this.editing) || (mt == this.selection));
78
    }
79

  
80
    @Override
81
    public Behavior getBehavior(int index) {
82
        switch (index) {
83
        case EDITING_INDEX:
84
            return (Behavior) this.editing;
85
        case SELECTION_INDEX:
86
            return (Behavior) this.selection;
87
        default:
88
            throw new IndexOutOfBoundsException();
89
        }
90
    }
91

  
92
    @Override
93
    public boolean isDrawnBehavior(int index) {
94
        switch (mode) {
95
        case EDITING:
96
            return index == EDITING_INDEX;
97
        case SELECTION:
98
            return index == SELECTION_INDEX;
99
        default:
100
            return false;
101
        }
102
    }
103

  
104
    @Override
105
    public void setDrawnBehavior(int index, boolean draw) {
106
        switch (index) {
107
        case EDITING_INDEX:
108
            if (draw) {
109
                mode = Mode.EDITING;
110
            } else {
111
                mode = Mode.SELECTION;
112
            }
113
            break;
114
        case SELECTION_INDEX:
115
            if (draw) {
116
                mode = Mode.SELECTION;
117
            } else {
118
                mode = Mode.EDITING;
119
            }
120
            break;
121
        default:
122
            throw new IndexOutOfBoundsException();
123
        }
124
    }
125

  
126
    @Override
127
    public int size() {
128
        return 2;
129
    }
130

  
131
    @Override
132
    public Image getImageCursor() {
133
        switch (mode) {
134
        default:
135
        case EDITING:
136
            return this.editing.getImageCursor();
137
        case SELECTION:
138
            return this.selection.getImageCursor();
139
        }
140
    }
141

  
142
    @Override
143
    public void mouseClicked(MouseEvent e) throws BehaviorException {
144
        switch (mode) {
145
        default:
146
        case EDITING:
147
            this.editing.mouseClicked(e);
148
            break;
149
        case SELECTION:
150
            this.selection.mouseClicked(e);
151
        }
152
    }
153

  
154
    @Override
155
    public void mouseDragged(MouseEvent e) throws BehaviorException {
156
        switch (mode) {
157
        default:
158
        case EDITING:
159
            this.editing.mouseDragged(e);
160
            break;
161
        case SELECTION:
162
            this.selection.mouseDragged(e);
163
        }
164
    }
165

  
166
    @Override
167
    public void mouseEntered(MouseEvent e) throws BehaviorException {
168
        switch (mode) {
169
        default:
170
        case EDITING:
171
            this.editing.mouseEntered(e);
172
            break;
173
        case SELECTION:
174
            this.selection.mouseEntered(e);
175
        }
176
    }
177

  
178
    @Override
179
    public void mouseExited(MouseEvent e) throws BehaviorException {
180
        switch (mode) {
181
        default:
182
        case EDITING:
183
            this.editing.mouseExited(e);
184
            break;
185
        case SELECTION:
186
            this.selection.mouseExited(e);
187
        }
188
    }
189

  
190
    @Override
191
    public void mouseMoved(MouseEvent e) throws BehaviorException {
192
        switch (mode) {
193
        default:
194
        case EDITING:
195
            this.editing.mouseMoved(e);
196
            break;
197
        case SELECTION:
198
            this.selection.mouseMoved(e);
199
        }
200
    }
201

  
202
    @Override
203
    public void mousePressed(MouseEvent e) throws BehaviorException {
204
        switch (mode) {
205
        default:
206
        case EDITING:
207
            this.editing.mousePressed(e);
208
            break;
209
        case SELECTION:
210
            this.selection.mousePressed(e);
211
        }
212
    }
213

  
214
    @Override
215
    public void mouseReleased(MouseEvent e) throws BehaviorException {
216
        switch (mode) {
217
        default:
218
        case EDITING:
219
            this.editing.mouseReleased(e);
220
            break;
221
        case SELECTION:
222
            this.selection.mouseReleased(e);
223
        }
224
    }
225

  
226
    @Override
227
    public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException {
228
        switch (mode) {
229
        default:
230
        case EDITING:
231
            this.editing.mouseWheelMoved(e);
232
            break;
233
        case SELECTION:
234
            this.selection.mouseWheelMoved(e);
235
        }
236
    }
237

  
238

  
239
    public void paintComponent(MapControlDrawer renderer, boolean clean) {
240
        if(clean){
241
            clean(renderer);
242
        }
243
        paintComponent(renderer);
244
    }
245

  
246
    @Override
247
    public void paintComponent(MapControlDrawer renderer) {
248
        switch (mode) {
249
        default:
250
        case EDITING:
251
            this.editing.paintComponent(renderer);
252
            break;
253
        case SELECTION:
254
            this.selection.paintComponent(renderer);
255
        }
256
    }
257

  
258
    @Override
259
    public void setListener(ToolListener listener) {
260
        if (listener != null) {
261
            throw new UnsupportedOperationException(
262
                "CompoundBehavior does not have listeners");
263
        }
264
    }
265

  
266
    @Override
267
    public ToolListener getListener() {
268
        return null;
269
    }
270

  
271
    @Override
272
    public void setMapControl(MapControl mc) {
273
        this.editing.setMapControl(mc);
274

  
275
        if (this.selection == null) {
276
            if (mc != null) {
277
                PointSelectionListener psl = new PointSelectionListener(mc);
278
                this.selection =
279
                    new CompoundBehavior(
280
                        new Behavior[] { new PointBehavior(psl) });
281
                this.selection.setMapControl(mc);
282
            }
283
        } else {
284
            this.selection.setMapControl(mc);
285
        }
286
    }
287

  
288
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.170/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/contextmenu/DefaultDynamicEditingPointPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2014 gvSIG Association
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
/* gvSIG. Desktop Geographic Information System.
26
 *
27
 * Copyright ? 2007-2014 gvSIG Association
28
 *
29
 * This program is free software; you can redistribute it and/or
30
 * modify it under the terms of the GNU General Public License
31
 * as published by the Free Software Foundation; either version 2
32
 * of the License, or (at your option) any later version.
33
 *
34
 * This program is distributed in the hope that it will be useful,
35
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
36
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
 * GNU General Public License for more details.
38
 *
39
 * You should have received a copy of the GNU General Public License
40
 * along with this program; if not, write to the Free Software
41
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
42
 * MA  02110-1301, USA.
43
 *
44
 * For any additional information, do not hesitate to contact us
45
 * at info AT gvsig.com, or visit our website www.gvsig.com.
46
 */
47
package org.gvsig.vectorediting.swing.impl.contextmenu;
48

  
49
import java.awt.event.ActionEvent;
50
import java.awt.event.ItemEvent;
51
import java.util.Objects;
52
import javax.swing.DefaultComboBoxModel;
53
import javax.swing.JComponent;
54
import org.apache.commons.lang3.StringUtils;
55
import org.apache.commons.lang3.tuple.Pair;
56
import org.gvsig.expressionevaluator.swing.CalculatorController;
57
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator;
58
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager;
59
import org.gvsig.fmap.dal.DataTypes;
60
import org.gvsig.fmap.geom.Geometry;
61

  
62
import org.gvsig.fmap.geom.primitive.Point;
63
import org.gvsig.fmap.geom.type.GeometryType;
64
import org.gvsig.temporarystorage.TemporaryStorageGroup;
65
import org.gvsig.temporarystorage.TemporaryStorageLocator;
66
import org.gvsig.tools.swing.api.ListElement;
67
import org.gvsig.tools.swing.api.ToolsSwingLocator;
68
import org.gvsig.tools.swing.api.ToolsSwingManager;
69
import org.gvsig.vectorediting.lib.api.exceptions.ParsePointException;
70
import org.gvsig.vectorediting.swing.api.EditingContext;
71
import org.gvsig.vectorediting.swing.api.JPointPanel;
72
/**
73
 * @author fdiaz
74
 *
75
 */
76
public class DefaultDynamicEditingPointPanel 
77
        extends DynamicEditingPointPanelView 
78
        implements JPointPanel
79
    {
80

  
81
    /**
82
     *
83
     */
84
    private static final long serialVersionUID = 2398169399771503091L;
85
    private final Point defaultPoint;
86
    private final CalculatorController pickers[];
87
    private CalculatorController pickerX;
88
    private CalculatorController pickerY;
89
    private CalculatorController pickerZ;
90
    private CalculatorController pickerM;
91
    private final GeometryType geomType;
92
    private final EditingContext editingContext;
93

  
94
    /**
95
     * @param editingContext
96
     * @param geomType
97
     * @param point
98
     */
99
    public DefaultDynamicEditingPointPanel(EditingContext editingContext, Point point)  {
100
        super();
101
        this.editingContext = editingContext;
102
        this.geomType = this.editingContext.getGeometryType();
103
        this.defaultPoint = point;
104
        this.pickers = new CalculatorController[this.geomType.getDimension()];
105
        this.initComponents();
106
    }
107

  
108
    private void initComponents() {
109
        ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
110
        ExpressionEvaluatorSwingManager evaluatorManager = ExpressionEvaluatorSwingLocator.getManager();
111

  
112
        toolsSwingManager.translate(this.rdbEnterTheCoordinatesManually);
113
        toolsSwingManager.translate(this.rdbUseAPointPreviouslyCaptured);
114

  
115
        toolsSwingManager.addClearButton(this.txtX);
116
        toolsSwingManager.addClearButton(this.txtY);
117
        toolsSwingManager.addClearButton(this.txtZ);
118
        toolsSwingManager.addClearButton(this.txtM);
119

  
120
        toolsSwingManager.setDefaultPopupMenu(this.txtX);
121
        toolsSwingManager.setDefaultPopupMenu(this.txtY);
122
        toolsSwingManager.setDefaultPopupMenu(this.txtZ);
123
        toolsSwingManager.setDefaultPopupMenu(this.txtM);
124

  
125
        this.pickerX = evaluatorManager.createCalculatorController(
126
                this.txtX, DataTypes.DOUBLE
127
        );
128
        this.pickerY = evaluatorManager.createCalculatorController(
129
                this.txtY, DataTypes.DOUBLE
130
        );
131
        this.pickerZ = evaluatorManager.createCalculatorController(
132
                this.txtZ, DataTypes.DOUBLE
133
        );
134
        this.pickerM = evaluatorManager.createCalculatorController(
135
                this.txtM, DataTypes.DOUBLE
136
        );
137
        this.pickers[0] = this.pickerX;
138
        this.pickers[1] = this.pickerY;
139
        if( this.geomType.hasZ() && this.geomType.hasM() ) {
140
            this.pickers[2] = this.pickerZ;
141
            this.pickers[3] = this.pickerM;                
142
        } else if( this.geomType.hasZ() ) {
143
            this.pickers[2] = this.pickerZ;
144
        } else if( this.geomType.hasM() ) {
145
            this.pickers[2] = this.pickerM;
146
        }
147
        
148
        addHierarchyChanged();
149
        
150
        TemporaryStorageGroup points = TemporaryStorageLocator.getTemporaryStorageManager()
151
                .create("Points",Point.class);
152
        
153
        DefaultComboBoxModel model = new DefaultComboBoxModel();
154
        model.addElement(new ListElement("", null));
155
        for (Pair<String, Object> pair : points.asList()) {
156
            model.addElement(new ListElement(pair.getKey(), (Point)(pair.getValue())));
157
        }
158
        this.cboCapturedPoints.setModel(model);
159
        this.cboCapturedPoints.addItemListener((ItemEvent e) -> {
160
            if( e.getStateChange()==ItemEvent.SELECTED ) {
161
                setPoint(((ListElement<Point>)e.getItem()).getValue());
162
            }
163
        });
164
        this.rdbEnterTheCoordinatesManually.addActionListener((ActionEvent e) -> {
165
            updateEnabledState();
166
        });
167
        this.rdbUseAPointPreviouslyCaptured.addActionListener((ActionEvent e) -> {
168
            updateEnabledState();
169
        });
170
        this.rdbEnterTheCoordinatesManually.setSelected(true);
171
        this.updateEnabledState();
172
    }
173
    
174
    private void updateEnabledState() {
175
        
176
        if( this.rdbEnterTheCoordinatesManually.isSelected()) {
177
            this.cboCapturedPoints.setEnabled(false);
178
            
179
            this.txtX.setEnabled(true);
180
            this.txtY.setEnabled(true);
181
            this.txtZ.setEnabled(false);
182
            this.txtM.setEnabled(false);
183

  
184
            this.lblX.setEnabled(true);
185
            this.lblY.setEnabled(true);
186
            this.lblZ.setEnabled(false);
187
            this.lblM.setEnabled(false);
188
            if( geomType.hasZ() && geomType.hasM() ) {
189
                this.txtZ.setEnabled(true);
190
                this.lblZ.setEnabled(true);
191
                this.txtM.setEnabled(true);
192
                this.lblM.setEnabled(true);
193
            } else if( geomType.hasZ() ) {
194
                this.txtZ.setEnabled(true);
195
                this.lblZ.setEnabled(true);
196
            } else if( geomType.hasM() ) {
197
                this.txtM.setEnabled(true);
198
                this.lblM.setEnabled(true);
199
            }
200
        }
201
        if( this.rdbUseAPointPreviouslyCaptured.isSelected()) {
202
            this.cboCapturedPoints.setEnabled(true);
203
            
204
            this.txtX.setEnabled(false);
205
            this.txtY.setEnabled(false);
206
            this.txtZ.setEnabled(false);
207
            this.txtM.setEnabled(false);
208

  
209
            this.lblX.setEnabled(false);
210
            this.lblY.setEnabled(false);
211
            this.lblZ.setEnabled(false);
212
            this.lblM.setEnabled(false);
213
        }
214
    }
215

  
216
    @Override
217
    public void setPoint(Point point) {
218
        if( point == null ) {
219
            this.pickerX.set(null);
220
            this.pickerY.set(null);
221
            this.pickerZ.set(null);
222
            this.pickerM.set(null);
223
            return;
224
        }
225
        this.pickerX.set( point.getX() );
226
        this.pickerY.set( point.getY() );
227
        GeometryType theGeomType = point.getGeometryType();
228
        if( theGeomType.hasZ() ) {
229
            this.pickerZ.set(point.getCoordinateAt(Geometry.DIMENSIONS.Z));
230
        } 
231
        if( theGeomType.hasM() ) {
232
            this.pickerM.set(point.getCoordinateAt(point.getDimension()-1));
233
        }
234
    }
235
    
236
    @Override
237
    public Point getPoint() {
238
        int dimension = this.geomType.getDimension();
239
        StringBuilder buffer = new StringBuilder();
240
        for (int i = 0; i < dimension; i++) {
241
            String value = this.getValue(i);
242
            buffer.append(value);
243
            if (i < dimension - 1) {
244
                buffer.append(",");
245
            }
246
        }
247
        try {
248
            Point p = this.editingContext.parsePoint(buffer.toString());
249
            return p;
250
        } catch (ParsePointException ex) {
251
            return null;
252
        }
253
    }
254
    
255
    private void addHierarchyChanged() {
256
        this.txtX.addHierarchyListener(new DefaultHierarchyListener());
257
    }
258

  
259
    /**
260
     * @return this as JComponent
261
     */
262
    @Override
263
    public JComponent asJComponent() {
264
        return this;
265
    }
266

  
267
    /**
268
     * @param i
269
     * @return String value of coordinate i
270
     */
271
    public String getValue(int i) {
272
        return Objects.toString(this.pickers[i].get(),"");
273
    }
274

  
275
    /**
276
     * @param i
277
     * @param value
278
     */
279
    public void setValue(int i, String value) {
280
        if( StringUtils.isBlank(value) ) {
281
            this.pickers[i].set(null);
282
            return;
283
        } 
284
        this.pickers[i].coerceAndSet(value);
285
    }
286
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.170/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/contextmenu/EditingContextMenuView.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2014 gvSIG Association
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.vectorediting.swing.impl.contextmenu;
26

  
27
import javax.swing.JPopupMenu;
28

  
29
/**
30
 * @author llmarques
31
 *
32
 */
33
public class EditingContextMenuView extends JPopupMenu {
34

  
35
    private static final long serialVersionUID = 3514644532820732815L;
36

  
37
    /**
38
     *
39
     */
40
    public EditingContextMenuView() {
41
        super();
42
    }
43
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.170/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/contextmenu/EditingPointPanelView.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2014 gvSIG Association
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.vectorediting.swing.impl.contextmenu;
26

  
27
import java.awt.Component;
28
import java.awt.GridBagConstraints;
29
import java.awt.GridBagLayout;
30
import java.awt.Insets;
31

  
32
import javax.swing.JLabel;
33
import javax.swing.JPanel;
34
import javax.swing.JTextField;
35

  
36
/**
37
 * @author llmarques
38
 *
39
 */
40
public class EditingPointPanelView extends JPanel {
41

  
42
    private static final long serialVersionUID = 941157096517987833L;
43

  
44
    private JTextField yTextfield;
45

  
46
    private JLabel yLabel;
47

  
48
    private JTextField xTextField;
49

  
50
    private JLabel xLabel;
51

  
52
    public EditingPointPanelView() {
53
        super();
54

  
55
        initialize();
56

  
57
//        addHierarchyChanged();
58
    }
59

  
60
//    /**
61
//     * Adds an hierarchy listener to value text field. The purpose of this is
62
//     * request focus when texfield ancestor gains focus.
63
//     */
64
//    private void addHierarchyChanged() {
65
//        getXTextField().addHierarchyListener(new DefaultHierarchyListener());
66
//    }
67

  
68
    private void initialize() {
69
        setLayout(new GridBagLayout());
70

  
71
        GridBagConstraints constrains = new GridBagConstraints();
72
        constrains.gridx = GridBagConstraints.RELATIVE;
73
        constrains.gridy = 1;
74
        constrains.weightx = 0;
75
        constrains.weighty = 0;
76
        constrains.insets = new Insets(5, 5, 5, 5);
77
        constrains.anchor = GridBagConstraints.WEST;
78

  
79
        add(getXLabel(), constrains);
80

  
81
        constrains = new GridBagConstraints();
82
        constrains.gridx = GridBagConstraints.RELATIVE;
83
        constrains.gridy = 1;
84
        constrains.weightx = 1;
85
        constrains.weighty = 0;
86
        constrains.fill = GridBagConstraints.HORIZONTAL;
87
        constrains.insets = new Insets(5, 5, 5, 5);
88
        constrains.anchor = GridBagConstraints.EAST;
89

  
90
        add(getXTextField(), constrains);
91

  
92
        constrains = new GridBagConstraints();
93
        constrains.gridx = GridBagConstraints.RELATIVE;
94
        constrains.gridy = 2;
95
        constrains.weightx = 0;
96
        constrains.weighty = 0;
97
        constrains.insets = new Insets(5, 5, 5, 5);
98
        constrains.anchor = GridBagConstraints.WEST;
99

  
100
        add(getYLabel(), constrains);
101

  
102
        constrains = new GridBagConstraints();
103
        constrains.gridx = GridBagConstraints.RELATIVE;
104
        constrains.gridy = 2;
105
        constrains.weightx = 1;
106
        constrains.weighty = 0;
107
        constrains.fill = GridBagConstraints.HORIZONTAL;
108
        constrains.insets = new Insets(5, 5, 5, 5);
109
        constrains.anchor = GridBagConstraints.EAST;
110

  
111
        add(getYTextField(), constrains);
112

  
113
    }
114

  
115
    protected JTextField getYTextField() {
116
        if (yTextfield == null) {
117
            yTextfield = new JTextField();
118
        }
119
        return yTextfield;
120
    }
121

  
122
    private JLabel getYLabel() {
123
        if (yLabel == null) {
124
            yLabel = new JLabel("Y");
125
        }
126
        return yLabel;
127
    }
128

  
129
    protected JTextField getXTextField() {
130
        if (xTextField == null) {
131
            xTextField = new JTextField();
132
        }
133
        return xTextField;
134
    }
135

  
136
    private Component getXLabel() {
137
        if (xLabel == null) {
138
            xLabel = new JLabel("X");
139
        }
140
        return xLabel;
141
    }
142

  
143
}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff