Revision 477

View differences:

org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.9/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.api/src/main/java/org/gvsig/vectorediting/swing/api/EditingSwingManager.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.api;
26

  
27
import java.awt.Component;
28
import java.util.List;
29

  
30
import org.gvsig.fmap.mapcontrol.MapControl;
31
import org.gvsig.tools.service.Manager;
32
import org.gvsig.utils.console.ResponseListener;
33
import org.gvsig.vectorediting.lib.api.EditingServiceParameter;
34
import org.gvsig.vectorediting.swing.api.console.EditingConsole;
35
import org.gvsig.vectorediting.swing.api.contextmenu.AcceptValueListener;
36
import org.gvsig.vectorediting.swing.api.contextmenu.EditingContextMenu;
37

  
38
/**
39
 * @author gvSIG team.
40
 */
41
public interface EditingSwingManager extends Manager {
42

  
43
    /**
44
     * @param mapControl
45
     * @return
46
     */
47
    EditingContext getEditingContext(MapControl mapControl);
48

  
49
    /**
50
     *
51
     * @param mapControl
52
     */
53
    public void registerEditingContext(MapControl mapControl);
54

  
55
    /**
56
     *
57
     * @param layerName
58
     * @return
59
     */
60
    int showPanelExportOrDiscard(MapControl parent, String layerName);
61

  
62
    /**
63
     *
64
     * @param layerName
65
     * @return
66
     */
67
    int showPanelSaveOrDiscard(MapControl parent, String layerName);
68

  
69
    /**
70
     * Gets an instance of current parameter contextual menu. To show it, invoke
71
     * {@link EditingContextMenu#show(java.awt.Component, int, int)}.
72
     *
73
     * @param parent
74
     *            of contextual menu
75
     * @param parameter
76
     *            to build contextual menu according to it types.
77
     * @return contextual menu of parameter
78
     */
79
    EditingContextMenu getContextualMenu(Component parent,
80
        AcceptValueListener listener, EditingServiceParameter parameter);
81

  
82
    /**
83
     * Gets and instance of {@link EditingConsole}.
84
     * The response listener will receive the response typed
85
     * by user when ENTER key is pressed.
86
     * 
87
     * @param listener
88
     *            Object that will received the response
89
     * @return An instance of {@link EditingConsole}
90
     */
91
    EditingConsole getEditingConsole(ResponseListener listener);
92

  
93
    /**
94
     * Gets and instance of {@link EditingConsole}.
95
     * Response listener list will receive the response
96
     * typed by user when ENTER key is pressed.
97
     * 
98
     * @param listener
99
     *            Object that will received the response
100
     * @return An instance of {@link EditingConsole}
101
     */
102
    EditingConsole getEditingConsole(List<ResponseListener> liteners);
103
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.9/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.api/src/main/java/org/gvsig/vectorediting/swing/api/EditingContext.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.api;
26

  
27
import java.lang.ref.WeakReference;
28

  
29
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
30
import org.gvsig.fmap.mapcontrol.MapControl;
31
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
32
import org.gvsig.tools.observer.Observable;
33

  
34
public interface EditingContext extends Observable {
35

  
36
    static final int CANCEL = 0;
37
    static final int DISCARD_CHANGES = 1;
38
    static final int EXPORT_LAYER = 2;
39
    static final int SAVE_CHANGES = 3;
40
    static final String DEFAULT_TOOL = "default_tool";
41

  
42
    static final String CHANGE_SELECTED_TOOL_NOTIFICATION = "EditingContext.changeSelectedTool";
43
    static final String REFRESH_TOOLS_NOTIFICATION = "EditingContext.refreshTools";
44
    /**
45
     * Activates service as of name and {@link MapControl}
46
     *
47
     * @param name
48
     *            of service
49
     * @param mapControl
50
     *            of
51
     */
52
    public void activateService(String name);
53

  
54
    /**
55
     * Begins edition of a layer with the {@link MapControl} received as
56
     * parameter.
57
     *
58
     * @param layer
59
     *            to begin edition
60
     * @param mapControl
61
     *            necessary to add listeners, console... See
62
     *            {@link EditingBehavior}.
63
     */
64
    public void beginEdition(FLyrVect layer, Behavior[] additionalBehaviors);
65

  
66
    /**
67
     * Ends edition of a layer with the {@link MapControl} received as
68
     * parameter.
69
     *
70
     * @param layer
71
     *            to end edition
72
     * @param mapControl
73
     *            necessary to delete observers, stop drawing, obtain
74
     *            {@link EditingBehavior}...
75
     */
76
    public void endEdition(FLyrVect layer);
77

  
78
    /**
79
     * Gets mapControl object. It is referenced by {@link WeakReference}.
80
     *
81
     * @return
82
     */
83
    public MapControl getMapControl();
84

  
85
    /**
86
     *
87
     * @param name
88
     * @return
89
     */
90
    public boolean isServiceCompatible(String name);
91

  
92
    /**
93
     * Updates the weak reference at editing context.
94
     *
95
     * @param mapControl
96
     */
97
    public void setMapControl(MapControl mapControl);
98

  
99

  
100
    public Behavior[] getDefaultBehaviors();
101

  
102
    public void setDefaultBehaviors(Behavior[] defaultBehaviors);
103
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.9/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.api/src/main/java/org/gvsig/vectorediting/swing/api/contextmenu/EditingContextMenu.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.api.contextmenu;
26

  
27
import java.awt.Component;
28

  
29
/**
30
 * @author llmarques
31
 *
32
 */
33
public interface EditingContextMenu {
34

  
35
    public void show(Component mapControl, int x, int y);
36

  
37
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.9/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.api/src/main/java/org/gvsig/vectorediting/swing/api/contextmenu/AcceptValueListener.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.api.contextmenu;
48

  
49
/**
50
 * @author llmarques
51
 *
52
 */
53
public interface AcceptValueListener {
54

  
55
    public void acceptValue(Object value);
56

  
57
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.9/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.api/src/main/java/org/gvsig/vectorediting/swing/api/EditingSwingLocator.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.api;
26

  
27
import org.gvsig.tools.locator.BaseLocator;
28
import org.gvsig.tools.locator.Locator;
29
import org.gvsig.tools.locator.LocatorException;
30

  
31
public class EditingSwingLocator extends BaseLocator {
32

  
33
    private static final String LOCATOR_NAME = "EditingSwingLocator";
34

  
35
    public static final String MANAGER_NAME = "VectorEditingSwing.manager";
36

  
37
    private static final String MANAGER_DESCRIPTION =
38
        "Editing Swing Manager of gvSIG";
39

  
40
    private static final EditingSwingLocator instance =
41
        new EditingSwingLocator();
42

  
43
    private EditingSwingLocator() {
44

  
45
    }
46

  
47
    /**
48
     * Return the singleton instance.
49
     *
50
     * @return the singleton instance
51
     */
52
    public static EditingSwingLocator getInstance() {
53
        return instance;
54
    }
55

  
56
    @Override
57
    public String getLocatorName() {
58
        return LOCATOR_NAME;
59
    }
60

  
61
    /**
62
     * Return a reference to EditingSwingManager.
63
     *
64
     * @return a reference to EditingSwingManager
65
     * @throws LocatorException
66
     *             if there is no access to the class or the class
67
     *             cannot be instantiated
68
     * @see Locator#get(String)
69
     */
70
    public static EditingSwingManager getSwingManager() throws LocatorException {
71
        return (EditingSwingManager) getInstance().get(MANAGER_NAME);
72
    }
73

  
74
    /**
75
     * Registers the Class implementing the EditingSwingLocator interface.
76
     *
77
     * @param clazz
78
     *            implementing the EeditingSwingManager interface
79
     */
80
    public static void registerManager(Class clazz) {
81
        getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
82
    }
83

  
84
    public static void registerDefaultManager(Class clazz) {
85
        getInstance().registerDefault(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
86
    }
87

  
88
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.9/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.api/src/main/java/org/gvsig/vectorediting/swing/api/EditingSwingLibrary.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.api;
26

  
27
import org.gvsig.fmap.dal.DALLibrary;
28
import org.gvsig.fmap.geom.GeometryLibrary;
29
import org.gvsig.tools.library.AbstractLibrary;
30
import org.gvsig.tools.library.LibraryException;
31
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
32

  
33
public class EditingSwingLibrary extends AbstractLibrary {
34

  
35
    @Override
36
    public void doRegistration() {
37
        registerAsAPI(EditingSwingLibrary.class);
38
        require(DALLibrary.class);
39
        require(GeometryLibrary.class);
40
    }
41

  
42
    @Override
43
    protected void doInitialize() throws LibraryException {
44
        // TODO Auto-generated method stub
45

  
46
    }
47

  
48
    @Override
49
    protected void doPostInitialize() throws LibraryException {
50
        EditingSwingManager manager = EditingSwingLocator.getSwingManager();
51
        if (manager == null) {
52
            throw new ReferenceNotRegisteredException(
53
                EditingSwingLocator.MANAGER_NAME,
54
                EditingSwingLocator.getInstance());
55
        }
56

  
57
    }
58

  
59
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.9/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.api/src/main/java/org/gvsig/vectorediting/swing/api/console/EditingConsole.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.api.console;
26

  
27
import org.gvsig.utils.console.ResponseListener;
28

  
29

  
30
/**
31
 * 
32
 * @author llmarques
33
 *
34
 */
35
public interface EditingConsole {
36
    
37
    /**
38
     * Gets response text typed by user
39
     * 
40
     * @return
41
     */
42
    public String getResponseText();
43
    
44
    /**
45
     * Clears console
46
     */
47
    public void clear();
48
    
49
    /**
50
     * Adds text to console
51
     * 
52
     * @param text
53
     */
54
    public void addText(String text);
55
    
56
    /**
57
     * Add text that is taken like text typed by user
58
     * 
59
     * @param responseText
60
     */
61
    public void addResponseText(String responseText);
62
    
63
    /**
64
     * Adds the listener
65
     * 
66
     * @param listener
67
     */
68
    public void addResponseListener(ResponseListener listener);
69
    
70
    /**
71
     * Removes the listener
72
     * 
73
     * @param listener
74
     */
75
    public void removeResponseListener(ResponseListener listener);
76
    
77
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.9/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.vectorediting.swing.api.EditingSwingLibrary
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.9/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.api/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/maven-v4_0_0.xsd">
3
	<modelVersion>4.0.0</modelVersion>
4
	<artifactId>org.gvsig.vectorediting.swing.api</artifactId>
5
	<packaging>jar</packaging>
6
	<name>org.gvsig.vectorediting.swing.api</name>
7
	<parent>
8
		<groupId>org.gvsig</groupId>
9
		<artifactId>org.gvsig.vectorediting.swing</artifactId>
10
		<version>1.0.9</version>
11
	</parent>
12
	<build>
13
		<plugins>
14
			<plugin>
15
				<groupId>org.apache.maven.plugins</groupId>
16
				<artifactId>maven-jar-plugin</artifactId>
17
				<configuration>
18
				</configuration>
19
				<executions>
20
					<!-- Generates a jar file only with the test classes -->
21
					<execution>
22
						<goals>
23
							<goal>test-jar</goal>
24
						</goals>
25
					</execution>
26
				</executions>
27
			</plugin>
28
		</plugins>
29
	</build>
30
	<dependencies>
31
		<dependency>
32
			<groupId>org.gvsig</groupId>
33
			<artifactId>org.gvsig.vectorediting.lib.api</artifactId>
34
		</dependency>
35
	</dependencies>
36
</project>
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.9/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.9</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.9/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.9/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.9/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.9/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.9/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

  
36
import javax.swing.SwingUtilities;
37

  
38
import org.slf4j.Logger;
39
import org.slf4j.LoggerFactory;
40

  
41
import org.gvsig.fmap.geom.Geometry;
42
import org.gvsig.fmap.geom.GeometryLocator;
43
import org.gvsig.fmap.geom.primitive.Point;
44
import org.gvsig.fmap.mapcontext.ViewPort;
45
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
46
import org.gvsig.fmap.mapcontext.rendering.symbols.ITextSymbol;
47
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
48
import org.gvsig.fmap.mapcontrol.MapControlLocator;
49
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
50
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
51
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
52
import org.gvsig.tools.ToolsLocator;
53
import org.gvsig.tools.exception.BaseException;
54
import org.gvsig.tools.i18n.I18nManager;
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.EditingSwingLocator;
63
import org.gvsig.vectorediting.swing.api.EditingSwingManager;
64
import org.gvsig.vectorediting.swing.api.contextmenu.AcceptValueListener;
65
import org.gvsig.vectorediting.swing.api.contextmenu.EditingContextMenu;
66

  
67
public class DefaultEditingBehavior extends Behavior {
68

  
69
    private static final Logger logger = LoggerFactory
70
        .getLogger(DefaultEditingBehavior.class);
71

  
72
    private DefaultEditingContext editingContext;
73

  
74
    private Point adjustedPoint;
75

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

  
90
    public DefaultEditingBehavior(DefaultEditingContext editingContext)
91
        throws CreateEditingBehaviorException {
92

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

  
99
    @Override
100
    public ToolListener getListener() {
101
        return new ToolListener() {
102

  
103
            public boolean cancelDrawing() {
104
                return false;
105
            }
106

  
107
            public Image getImageCursor() {
108
                return imageCursor;
109
            }
110
        };
111
    }
112

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

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

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

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

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

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

  
149
                try {
150
                    editingContext.getActiveService().setValue(point);
151
                } catch (VectorEditingException ex) {
152
                    I18nManager i18nManager = ToolsLocator.getI18nManager();
153
                    editingContext.showConsoleMessage(i18nManager
154
                        .getTranslation("invalid_option"));
155
                }
156

  
157
                editingContext.getNextParameter();
158

  
159
            } else if (SwingUtilities.isRightMouseButton(e)) {
160

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

  
164
                EditingContextMenu contextMenu =
165
                    swingManager.getContextualMenu(getMapControl(),
166
                        new AcceptValueListener() {
167

  
168
                            public void acceptValue(Object value) {
169
                                editingContext.textEntered((String) value);
170

  
171
                            }
172
                        }, currentParam);
173

  
174
                contextMenu.show(getMapControl(), e.getX(), e.getY());
175
            }
176
        }
177
    }
178

  
179
    @Override
180
    public void mouseEntered(MouseEvent e) throws BehaviorException {
181
    }
182

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

  
189
    @Override
190
    public void mousePressed(MouseEvent e) throws BehaviorException {
191
    }
192

  
193
    @Override
194
    public void mouseReleased(MouseEvent e) throws BehaviorException {
195
    }
196

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

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

  
207
        DrawingStatus helperGeo = null;
208

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

  
217
        if (helperGeo != null) {
218
            for (Iterator iterator = helperGeo.getStatus().iterator(); iterator
219
                .hasNext();) {
220
                Status status = (Status) iterator.next();
221
                ISymbol symbol = status.getSymbol();
222
                if (symbol == null) {
223
                    symbol =
224
                        MapControlLocator.getMapControlManager()
225
                            .getAxisReferenceSymbol();
226
                }
227
                if (symbol instanceof ITextSymbol) {
228
                    ((ITextSymbol) symbol).setText(status.getText());
229
                }
230
                editingContext.getMapControl().getMapControlDrawer()
231
                    .draw(status.getGeometry(), symbol);
232
            }
233
        }
234
    }
235
}
org.gvsig.vectorediting/tags/org.gvsig.vectorediting-1.0.9/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.9/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/contextmenu/DefaultEditingValuePanel.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.JComponent;
28

  
29
public class DefaultEditingValuePanel extends EditingValuePanelView {
30

  
31
    private static final long serialVersionUID = -2429230493027567705L;
32

  
33
    public JComponent asJComponent() {
34
        return this;
35
    }
36

  
37
    public String getValue() {
38
        return getValueTextField().getText();
39
    }
40

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

Also available in: Unified diff