Revision 4274

View differences:

org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.258/org.gvsig.vectorediting.swing/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<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">
3

  
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.vectorediting.swing</artifactId>
6
	<packaging>pom</packaging>
7
	<name>org.gvsig.vectorediting.swing</name>
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.vectorediting</artifactId>
11
		<version>1.0.258</version>
12
	</parent>
13

  
14

  
15
	<modules>
16
		<module>org.gvsig.vectorediting.swing.api</module>
17
		<module>org.gvsig.vectorediting.swing.impl</module>
18
	</modules>
19
</project>
20

  
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.258/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/console/DefaultEditingConsole.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2015 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.console;
26

  
27
import java.awt.event.ActionEvent;
28
import java.util.List;
29

  
30
import javax.swing.AbstractAction;
31
import javax.swing.Action;
32
import javax.swing.JPopupMenu;
33
import javax.swing.JTextArea;
34
import javax.swing.KeyStroke;
35
import javax.swing.event.AncestorEvent;
36
import javax.swing.event.AncestorListener;
37
import javax.swing.text.JTextComponent;
38
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator;
39
import org.gvsig.expressionevaluator.swing.JExpressionBuilder;
40
import org.gvsig.tools.ToolsLocator;
41
import org.gvsig.tools.i18n.I18nManager;
42
import org.gvsig.tools.swing.api.ToolsSwingLocator;
43
import org.gvsig.tools.swing.api.windowmanager.Dialog;
44
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
45
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2;
46
import org.gvsig.utils.console.JConsole;
47

  
48
import org.gvsig.utils.console.ResponseListener;
49
import org.gvsig.utils.console.ResponseListenerSupport;
50
import org.gvsig.vectorediting.swing.api.EditingContext;
51
import org.gvsig.vectorediting.swing.api.EditingSwingLocator;
52
import org.gvsig.vectorediting.swing.api.console.EditingConsole;
53

  
54
/**
55
 * Default implementation of EditingConsole
56
 *
57
 * @author llmarques
58
 */
59
public class DefaultEditingConsole extends DefaultEditingConsoleView implements
60
    EditingConsole {
61

  
62
    private static final long serialVersionUID = -1068129558465010049L;
63

  
64
    private ResponseListenerSupport responseListenerSupport;
65
    private int startingCaretPosition = 0;
66

  
67
    public DefaultEditingConsole(ResponseListener listener) {
68
        super();
69

  
70
        // Add ancestor listener to request focus when an ancestor becomes
71
        // visible
72
        addAncestorListenerToSetCaretPosition();
73

  
74
        this.responseListenerSupport = new ResponseListenerSupport();
75
        this.responseListenerSupport.addResponseListener(listener);
76

  
77
        getTextArea().setNavigationFilter(
78
            new DefaultEditingNavigationFilter(startingCaretPosition));
79

  
80
        addKeyBindings();
81
        
82
        ToolsSwingLocator.getToolsSwingManager().setDefaultPopupMenu(getTextArea());
83
    }
84
    
85
    public DefaultEditingConsole(List<ResponseListener> listeners) {
86
        super();
87

  
88
        // Add ancestor listener to request focus when an ancestor becomes
89
        // visible
90
        addAncestorListenerToSetCaretPosition();
91

  
92
        this.responseListenerSupport = new ResponseListenerSupport();
93
        for (ResponseListener responseListener : listeners) {
94
            this.responseListenerSupport.addResponseListener(responseListener);
95
        }
96

  
97
        // Add navigation filter to control caret position
98
        getTextArea().setNavigationFilter(
99
            new DefaultEditingNavigationFilter(startingCaretPosition));
100

  
101
        addKeyBindings();
102
        ToolsSwingLocator.getToolsSwingManager().setDefaultPopupMenu(getTextArea());
103
    }
104

  
105
    @Override
106
    public JPopupMenu getComponentPopupMenu() {
107
        return this.getTextArea().getComponentPopupMenu();
108
    }
109

  
110
    private void addAncestorListenerToSetCaretPosition() {
111
        this.addAncestorListener(new AncestorListener() {
112

  
113
            public void ancestorRemoved(AncestorEvent event) {
114
            }
115

  
116
            public void ancestorMoved(AncestorEvent event) {
117
            }
118

  
119
            public void ancestorAdded(AncestorEvent event) {
120
                getTextArea().requestFocusInWindow();
121
                getTextArea().setCaretPosition(startingCaretPosition);
122
            }
123
        });
124
    }
125

  
126
    private void addKeyBindings() {
127

  
128
        // Enter binding
129
        getTextArea().getInputMap().put(KeyStroke.getKeyStroke("ENTER"),
130
            "enterAction");
131
        getTextArea().getActionMap().put("enterAction", enterAction);
132

  
133
        // Esc binding
134
        getTextArea().getInputMap().put(KeyStroke.getKeyStroke("ESCAPE"),
135
            "escAction");
136
        getTextArea().getActionMap().put("escAction", escAction);
137

  
138
        // BackSpace binding
139
        getTextArea().getInputMap().put(KeyStroke.getKeyStroke("BACK_SPACE"),
140
            "backSpaceAction");
141
        getTextArea().getActionMap().put("backSpaceAction", backSpaceAction);
142
        // Del binding
143
        getTextArea().getInputMap().put(KeyStroke.getKeyStroke("DELETE"), "none");
144
    }
145

  
146
    public String getResponseText() {
147
        return getTextArea().getText().substring(startingCaretPosition,
148
            getTextArea().getText().length());
149
    }
150

  
151
    public void addText(String text) {
152
        getTextArea().setText(getTextArea().getText() + text);
153
        getTextArea().setCaretPosition(getTextArea().getText().length());
154
        startingCaretPosition = getTextArea().getText().length();
155
        getTextArea().setNavigationFilter(
156
            new DefaultEditingNavigationFilter(startingCaretPosition));
157
        getTextArea().requestFocusInWindow();
158
    }
159

  
160
    public void addResponseText(String responseText) {
161
        getTextArea().setText(getTextArea().getText() + responseText);
162
        getTextArea().setCaretPosition(getTextArea().getText().length());
163
    }
164

  
165
    public void addResponseListener(ResponseListener listener) {
166
        this.responseListenerSupport.addResponseListener(listener);
167
    }
168

  
169
    public void removeResponseListener(ResponseListener listener) {
170
        this.responseListenerSupport.removeResponseListener(listener);
171
    }
172

  
173
    private void callResponseListener(String response) {
174
        this.responseListenerSupport.callAcceptResponse(response);
175
    }
176

  
177
    public void clear() {
178
        getTextArea().setText(null);
179
    }
180

  
181
    @SuppressWarnings("serial")
182
    private Action enterAction = new AbstractAction() {
183

  
184
        public void actionPerformed(ActionEvent e) {
185
            callResponseListener(getResponseText() + "\n");
186
        }
187
    };
188

  
189
    @SuppressWarnings("serial")
190
    private Action escAction = new AbstractAction() {
191

  
192
        public void actionPerformed(ActionEvent e) {
193
            callResponseListener(null);
194
        }
195
    };
196

  
197
    @SuppressWarnings("serial")
198
    private Action backSpaceAction = new AbstractAction() {
199

  
200
        public void actionPerformed(ActionEvent e) {
201
            if (getTextArea().getCaretPosition() > startingCaretPosition) {
202
                StringBuilder stb = new StringBuilder(getTextArea().getText());
203
                stb.deleteCharAt(getTextArea().getText().length() - 1);
204
                getTextArea().setText(stb.toString());
205
            }
206
        }
207
    };
208

  
209
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.258/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/console/DefaultEditingNavigationFilter.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2015 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.console;
26

  
27
import javax.swing.text.NavigationFilter;
28
import javax.swing.text.Position.Bias;
29

  
30
/**
31
 * Default implementation of Navigation filter. This implementation doesn't let
32
 * caret to move behind of a determinate position.
33
 * 
34
 * @author llmarques
35
 *
36
 */
37
public class DefaultEditingNavigationFilter extends NavigationFilter {
38

  
39
    private int startCaretPosition;
40

  
41
    public DefaultEditingNavigationFilter(int theStartPosition) {
42
        startCaretPosition = theStartPosition;
43
    }
44

  
45
    @Override
46
    public void setDot(FilterBypass fb, int dot, Bias bias) {
47
        if (dot > startCaretPosition) {
48
            fb.setDot(dot, bias);
49
        } else {
50
            fb.setDot(startCaretPosition, bias);
51
        }
52
    }
53

  
54
    @Override
55
    public void moveDot(FilterBypass fb, int dot, Bias bias) {
56
        if (dot > startCaretPosition) {
57
            fb.moveDot(dot, bias);
58
        } else {
59
            fb.moveDot(startCaretPosition, bias);
60
        }
61
    }
62
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.258/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/console/DefaultEditingConsoleView.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2015 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.console;
26

  
27
import java.awt.BorderLayout;
28
import java.awt.Dimension;
29
import java.awt.Font;
30

  
31
import javax.swing.JPanel;
32
import javax.swing.JScrollPane;
33
import javax.swing.JTextArea;
34

  
35
/**
36
 * Default view implementation of EditingConsole
37
 * 
38
 * @author llmarques
39
 */
40
public class DefaultEditingConsoleView extends JPanel {
41

  
42
    private static final long serialVersionUID = -843733609032093530L;
43

  
44
    private JTextArea textArea;
45

  
46
    public DefaultEditingConsoleView() {
47
        this.textArea = new JTextArea();
48
        this.textArea.setLineWrap(true);
49
        this.textArea.setWrapStyleWord(true);
50
        this.textArea.setFont(new Font("Monospaced", Font.PLAIN, 14));
51

  
52
        JScrollPane scroll = new JScrollPane(textArea);
53
        scroll
54
            .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
55

  
56
        initialize(scroll);
57
    }
58

  
59
    private void initialize(JScrollPane scroll) {
60
        this.setLayout(new BorderLayout());
61
        this.setSize(300, 150);
62
        this.setPreferredSize(new Dimension(300, 150));
63
        this.add(scroll, java.awt.BorderLayout.CENTER);
64
    }
65

  
66
    protected JTextArea getTextArea() {
67
        return textArea;
68
    }
69

  
70
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.258/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.258/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.258/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.258/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.euclidean.EuclideanLine2D;
37
import org.gvsig.euclidean.EuclideanManager;
38
import org.gvsig.fmap.geom.Geometry;
39
import org.gvsig.fmap.geom.GeometryLocator;
40
import org.gvsig.fmap.geom.GeometryUtils;
41
import org.gvsig.fmap.geom.aggregate.MultiPoint;
42
import org.gvsig.fmap.geom.primitive.Point;
43
import org.gvsig.fmap.mapcontext.ViewPort;
44
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
45
import org.gvsig.fmap.mapcontext.rendering.symbols.ITextSymbol;
46
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
47
import org.gvsig.fmap.mapcontrol.MapControlLocator;
48
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
49
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
50
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
51
import org.gvsig.tools.ToolsLocator;
52
import org.gvsig.tools.exception.BaseException;
53
import org.gvsig.tools.i18n.I18nManager;
54
import org.gvsig.tools.util.ToolsUtilLocator;
55
import org.gvsig.vectorediting.lib.api.DrawingStatus;
56
import org.gvsig.vectorediting.lib.api.DrawingStatus.Status;
57
import org.gvsig.vectorediting.lib.api.EditingService;
58
import org.gvsig.vectorediting.lib.api.EditingServiceParameter;
59
import org.gvsig.vectorediting.lib.api.EditingServiceParameter.TYPE;
60
import org.gvsig.vectorediting.lib.api.exceptions.CreateEditingBehaviorException;
61
import org.gvsig.vectorediting.lib.api.exceptions.VectorEditingException;
62
import org.gvsig.vectorediting.swing.api.EditingContext;
63
import org.gvsig.vectorediting.swing.api.EditingSwingLocator;
64
import org.gvsig.vectorediting.swing.api.EditingSwingManager;
65
import org.gvsig.vectorediting.swing.api.contextmenu.EditingContextMenu;
66
import org.slf4j.Logger;
67
import org.slf4j.LoggerFactory;
68

  
69
public class DefaultEditingBehavior extends Behavior {
70

  
71
    private static final Logger logger = LoggerFactory
72
        .getLogger(DefaultEditingBehavior.class);
73

  
74
    private DefaultEditingContext editingContext;
75

  
76
    private Point adjustedPoint;
77

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

  
92
    public DefaultEditingBehavior(DefaultEditingContext editingContext)
93
        throws CreateEditingBehaviorException {
94

  
95
        if (editingContext.getMapControl() != null) {
96
            this.editingContext = editingContext;
97
            setMapControl(editingContext.getMapControl());
98
        }
99
    }
100

  
101
    @Override
102
    public ToolListener getListener() {
103
        return new ToolListener() {
104

  
105
            @Override
106
            public boolean cancelDrawing() {
107
                return false;
108
            }
109

  
110
            @Override
111
            public Image getImageCursor() {
112
                return imageCursor;
113
            }
114
        };
115
    }
116

  
117
    @Override
118
    public void mouseClicked(MouseEvent e) {
119
        ViewPort vp = editingContext.getMapControl().getViewPort();
120
        EditingServiceParameter currentParam = editingContext.getCurrentParam();
121
        EditingService activeService = editingContext.getActiveService();
122

  
123
        if ((activeService != null) && (currentParam != null)) {
124

  
125
            if (SwingUtilities.isLeftMouseButton(e)) {
126

  
127
                Set<TYPE> typesOfParam = currentParam.getTypes();
128

  
129
                if (typesOfParam.contains(TYPE.LIST_POSITIONS)) {
130
                    if (e.getClickCount() == 2) {
131
                        editingContext.finishService();
132
                        return;
133
                    }
134
                }
135

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

  
153
                try {
154
                    editingContext.setValue(currentParam, ortoPoint(point), true);
155
                } catch (VectorEditingException ex) {
156
                    I18nManager i18nManager = ToolsLocator.getI18nManager();
157
                    editingContext.showConsoleMessage(i18nManager
158
                        .getTranslation("invalid_option"));
159
                }
160
            } else if (SwingUtilities.isRightMouseButton(e)) {
161

  
162
                EditingSwingManager swingManager =
163
                    EditingSwingLocator.getSwingManager();
164

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

  
170
                    contextMenu.show(getMapControl(), e.getX(), e.getY());
171
            }
172
        }
173
    }
174
    
175
    private Point ortoPoint(Point point){
176
        if(editingContext.getDrawMode() == EditingContext.DRAWMODE_NORMAL){
177
            return point;
178
        }
179
        Point refPoint = (Point) editingContext.getContextSymbolTable().value("$p");
180
        if(refPoint == null){
181
            return point;
182
        }
183
        EuclideanManager euclideanManager = ToolsUtilLocator.getEuclideanManager();
184
        EuclideanLine2D line = euclideanManager.createLine2D(refPoint.getX(), refPoint.getY(), point.getX(), point.getY());
185
        double m = line.getSlope();
186
        Point result;
187
        if(Math.abs(m)<=1){
188
            result = GeometryUtils.createPoint(point.getX(), refPoint.getY());
189
         } else {
190
            result = GeometryUtils.createPoint(refPoint.getX(), point.getY());
191
            
192
        }
193
        
194
        
195
        return result;
196
    }
197

  
198
    @Override
199
    public void mouseEntered(MouseEvent e) throws BehaviorException {
200
    }
201

  
202
    @Override
203
    public void mouseMoved(MouseEvent e) throws BehaviorException {
204
        ViewPort vp = editingContext.getMapControl().getViewPort();
205
        adjustedPoint = vp.convertToMapPoint(e.getX(), e.getY());
206
    }
207

  
208
    @Override
209
    public void mousePressed(MouseEvent e) throws BehaviorException {
210
    }
211

  
212
    @Override
213
    public void mouseReleased(MouseEvent e) throws BehaviorException {
214
    }
215

  
216
    @Override
217
    @SuppressWarnings("rawtypes")
218
    public void paintComponent(MapControlDrawer mapControlDrawer) {
219
        super.paintComponent(mapControlDrawer);
220

  
221
        if ((editingContext.getActiveService() == null)
222
            || (adjustedPoint == null)) {
223
            return;
224
        }
225

  
226
        DrawingStatus helperGeo = null;
227

  
228
        try {
229
            helperGeo =
230
                editingContext.getActiveService().getDrawingStatus(
231
                            ortoPoint(adjustedPoint));
232
        } catch (VectorEditingException e) {
233
            logger.info("An error ocurred when draw service geometries", e);
234
        }
235

  
236
        if (helperGeo != null) {
237
            for (Iterator iterator = helperGeo.getStatus().iterator(); iterator
238
                .hasNext();) {
239
                Status status = (Status) iterator.next();
240
                ISymbol symbol = status.getSymbol();
241
                if (symbol == null) {
242
                    symbol =
243
                        MapControlLocator.getMapControlManager()
244
                            .getAxisReferenceSymbol();
245
                }
246
                if (symbol instanceof ITextSymbol) {
247
                    ((ITextSymbol) symbol).setText(status.getText());
248
                }
249
                Geometry geom = status.getGeometry();
250
                if(geom != null){
251
                    if(geom.getGeometryType().isTypeOf(Geometry.TYPES.MULTIPOINT)){
252
                        MultiPoint multipoint = (MultiPoint)geom;
253
                        for (Geometry geometry : multipoint) {
254
                            editingContext.getMapControl().getMapControlDrawer()
255
                                .draw(geometry, symbol);
256
                        }
257
                    } else {
258
                        editingContext.getMapControl().getMapControlDrawer()
259
                            .draw(geom, symbol);
260
                    }
261
                }
262
            }
263
        }
264
    }
265
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.258/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.Cursor;
28
import java.awt.Image;
29
import java.awt.event.MouseEvent;
30
import java.awt.event.MouseWheelEvent;
31

  
32
import org.gvsig.fmap.mapcontrol.MapControl;
33
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
34
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
35
import org.gvsig.fmap.mapcontrol.tools.CompoundBehavior;
36
import org.gvsig.fmap.mapcontrol.tools.PointSelectionListener;
37
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
38
import org.gvsig.fmap.mapcontrol.tools.Behavior.IBehavior;
39
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseWheelBehavior;
40
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior;
41
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
42
import org.gvsig.vectorediting.swing.api.EditingContext;
43
import org.gvsig.vectorediting.swing.api.EditingSwingLocator;
44
import org.gvsig.vectorediting.swing.api.EditingSwingManager;
45

  
46
public class EditingCompoundBehavior extends CompoundBehavior {
47

  
48
    private enum Mode {
49
        EDITING, SELECTION
50
    };
51

  
52
    private Mode mode = Mode.EDITING;
53
    private IBehavior editing;
54
    private IBehavior selection;
55

  
56
    public final static int EDITING_INDEX = 0;
57
    public final static int SELECTION_INDEX = 1;
58

  
59
    public EditingCompoundBehavior(IBehavior editing) {
60
        super(new Behavior[0]);
61
        this.editing = editing;
62

  
63
        this.selection = null;
64
    }
65

  
66
    @Override
67
    public void addMapBehavior(Behavior mt, boolean draw) {
68
        if (mt instanceof MouseWheelBehavior) {
69
            return;
70
        }
71
        throw new UnsupportedOperationException();
72
    }
73

  
74
    @Override
75
    public void removeMapBehavior(Behavior mt) {
76
        throw new UnsupportedOperationException();
77
    }
78

  
79
    @Override
80
    public boolean containsBehavior(Behavior mt) {
81
        return ((mt == this.editing) || (mt == this.selection));
82
    }
83

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

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

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

  
130
    @Override
131
    public int size() {
132
        return 2;
133
    }
134

  
135
    @Override
136
    public Image getImageCursor() {
137
//        if( getEditingContext().isProcessing() ) {
138
//            return null; //Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
139
//        }
140
        switch (mode) {
141
        default:
142
        case EDITING:
143
            return this.editing.getImageCursor();
144
        case SELECTION:
145
            return this.selection.getImageCursor();
146
        }
147
    }
148
    
149
    private EditingContext getEditingContext() {
150
        EditingSwingManager swingManager = EditingSwingLocator.getSwingManager();
151
        EditingContext editingContext = swingManager.getEditingContext(this.getMapControl());
152
        return editingContext;
153
    }
154

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

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

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

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

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

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

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

  
239
    @Override
240
    public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException {
241
        switch (mode) {
242
        default:
243
        case EDITING:
244
            this.editing.mouseWheelMoved(e);
245
            break;
246
        case SELECTION:
247
            this.selection.mouseWheelMoved(e);
248
        }
249
    }
250

  
251

  
252
    public void paintComponent(MapControlDrawer renderer, boolean clean) {
253
        if(clean){
254
            clean(renderer);
255
        }
256
        paintComponent(renderer);
257
    }
258

  
259
    @Override
260
    public void paintComponent(MapControlDrawer renderer) {
261
        switch (mode) {
262
        default:
263
        case EDITING:
264
            this.editing.paintComponent(renderer);
265
            break;
266
        case SELECTION:
267
            this.selection.paintComponent(renderer);
268
        }
269
    }
270

  
271
    @Override
272
    public void setListener(ToolListener listener) {
273
        if (listener != null) {
274
            throw new UnsupportedOperationException(
275
                "CompoundBehavior does not have listeners");
276
        }
277
    }
278

  
279
    @Override
280
    public ToolListener getListener() {
281
        return null;
282
    }
283

  
284
    @Override
285
    public void setMapControl(MapControl mc) {
286
        this.editing.setMapControl(mc);
287

  
288
        if (this.selection == null) {
289
            if (mc != null) {
290
                PointSelectionListener psl = new PointSelectionListener(mc);
291
                this.selection =
292
                    new CompoundBehavior(
293
                        new Behavior[] { new PointBehavior(psl) });
294
                this.selection.setMapControl(mc);
295
            }
296
        } else {
297
            this.selection.setMapControl(mc);
298
        }
299
    }
300

  
301
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.258/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.258/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
        }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff