Revision 37457

View differences:

tags/v2_0_0_Build_2042/libraries/libFMap_controls/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
5
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
6
                      
7
	<modelVersion>4.0.0</modelVersion>
8
	<groupId>org.gvsig</groupId>
9
	<artifactId>org.gvsig.fmap.control</artifactId>
10
	<packaging>jar</packaging>
11
	<version>2.0-SNAPSHOT</version>
12
	<name>libFMap_controls</name>
13
	<url>http://gvsig.org</url>
14
	<parent>
15
		<groupId>org.gvsig</groupId>
16
		<artifactId>gvsig-base-library-pom</artifactId>
17
		<version>2.0-SNAPSHOT</version>
18
	</parent>	
19
	<distributionManagement>
20
		<site>
21
			<id>gvsig-repository</id>
22
			<url>${site-repository}/</url>
23
		</site>
24
	</distributionManagement>
25

  
26
	<properties>
27
		<build-dir>${basedir}/../build</build-dir>
28
        <eclipse.project.name>libFMap_controls</eclipse.project.name>
29
	</properties>
30
	<dependencies>
31
        <dependency>
32
            <groupId>org.gvsig</groupId>
33
            <artifactId>org.gvsig.tools.lib</artifactId>
34
            <scope>compile</scope>
35
        </dependency>
36
        <dependency>
37
            <groupId>org.gvsig</groupId>
38
            <artifactId>org.gvsig.tools.swing.api</artifactId>
39
            <scope>compile</scope>
40
        </dependency>
41
        <dependency>
42
            <groupId>org.gvsig</groupId>
43
            <artifactId>org.gvsig.tools.swing.impl</artifactId>
44
            <scope>runtime</scope>
45
        </dependency>
46
        <dependency>
47
            <groupId>org.gvsig</groupId>
48
            <artifactId>org.gvsig.tools.swing.spi</artifactId>
49
            <scope>runtime</scope>
50
        </dependency>
51
        <dependency>
52
            <groupId>org.gvsig</groupId>
53
            <artifactId>org.gvsig.tools.swing.serv.field</artifactId>
54
            <scope>runtime</scope>
55
        </dependency>
56
        <dependency>
57
            <groupId>org.gvsig</groupId>
58
            <artifactId>org.gvsig.tools.swing.serv.jform</artifactId>
59
            <scope>runtime</scope>
60
        </dependency>
61
        <dependency>
62
            <groupId>org.gvsig</groupId>
63
            <artifactId>org.gvsig.tools.swing.serv.jlist</artifactId>
64
            <scope>runtime</scope>
65
        </dependency>
66
		<dependency>
67
			<groupId>org.gvsig</groupId>
68
			<artifactId>org.gvsig.utils</artifactId>
69
            <scope>compile</scope>
70
		</dependency>
71
		<dependency>
72
			<groupId>org.gvsig</groupId>
73
			<artifactId>org.gvsig.fmap.dal</artifactId>
74
            <scope>compile</scope>
75
		</dependency>
76
        <dependency>
77
            <groupId>org.gvsig</groupId>
78
            <artifactId>org.gvsig.fmap.geometry</artifactId>
79
            <scope>compile</scope>
80
        </dependency>        
81
        <dependency>
82
            <groupId>org.gvsig</groupId>
83
            <artifactId>org.gvsig.fmap.geometry</artifactId>
84
            <classifier>operation</classifier>
85
            <scope>compile</scope>
86
        </dependency>
87
        <dependency>
88
            <groupId>org.gvsig</groupId>
89
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
90
            <scope>compile</scope>
91
        </dependency>        
92
        <dependency>
93
            <groupId>org.gvsig</groupId>
94
            <artifactId>org.gvsig.projection</artifactId>
95
            <scope>compile</scope>
96
        </dependency>
97
		<dependency>
98
    		<!-- TODO: remove -->
99
			<groupId>org.gvsig</groupId>
100
			<artifactId>org.gvsig.fmap.dal</artifactId>
101
			<classifier>impl</classifier>
102
            <scope>compile</scope>
103
		</dependency>
104
		<dependency>
105
			<groupId>org.gvsig</groupId>
106
			<artifactId>org.gvsig.fmap.mapcontext</artifactId>
107
            <scope>compile</scope>
108
		</dependency>
109
		<dependency>
110
			<groupId>org.gvsig</groupId>
111
			<artifactId>org.gvsig.fmap.mapcontext</artifactId>
112
			<classifier>operation</classifier>
113
            <scope>compile</scope>
114
		</dependency>
115
		<dependency>
116
			<groupId>org.gvsig</groupId>
117
			<artifactId>org.gvsig.tools.lib</artifactId>
118
			<type>test-jar</type>
119
			<scope>test</scope>
120
		</dependency>
121
        <dependency>
122
            <groupId>org.gvsig</groupId>
123
            <artifactId>org.gvsig.i18n</artifactId>
124
            <scope>compile</scope>
125
        </dependency>
126
        <dependency>
127
            <groupId>org.slf4j</groupId>
128
            <artifactId>slf4j-api</artifactId>
129
            <scope>compile</scope>
130
        </dependency>
131
        <dependency>
132
            <groupId>com.vividsolutions</groupId>
133
            <artifactId>jts</artifactId>
134
            <scope>compile</scope>
135
        </dependency>
136
        <dependency>
137
            <groupId>org.gvsig</groupId>
138
            <artifactId>org.gvsig.tools.swing.api</artifactId>
139
            <scope>compile</scope>
140
        </dependency>
141
		<!-- TODO: uncomment when mapcontexts tests work again 
142
		<dependency>
143
			<groupId>org.gvsig</groupId>
144
			<artifactId>org.gvsig.fmap.mapcontext</artifactId>
145
            <type>test-jar</type>
146
			<scope>test</scope>
147
		</dependency>
148
		 -->
149
	    <dependency>
150
            <groupId>org.gvsig</groupId>
151
            <artifactId>org.gvsig.timesupport.lib.api</artifactId>
152
            <scope>compile</scope>
153
        </dependency>
154
	</dependencies>
155
	<build>
156
		<sourceDirectory>src</sourceDirectory>
157
		<testSourceDirectory>src-test</testSourceDirectory>
158
		<resources>
159
			<resource>
160
				<filtering>false</filtering>
161
				<directory>${basedir}/resources</directory>
162
			</resource>
163
		</resources>
164

  
165
		<!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION -->
166
		<plugins>
167
			<plugin>
168
				<groupId>org.apache.maven.plugins</groupId>
169
				<artifactId>maven-surefire-plugin</artifactId>
170
				<configuration>
171
					<skipTests>true</skipTests>
172
				</configuration>
173
			</plugin>
174
      		<plugin>
175
				<groupId>org.apache.maven.plugins</groupId>
176
				<artifactId>maven-compiler-plugin</artifactId>
177
				<configuration>
178
					<testExcludes>
179
						<exclude>**</exclude>
180
					</testExcludes>
181
				</configuration>
182
			</plugin>		
183
		</plugins>
184
	</build>
185
</project>
tags/v2_0_0_Build_2042/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_de.properties
1
registros_seleccionados_total=Alle ausgew\u00e4hlten register
tags/v2_0_0_Build_2042/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_eu.properties
1
registros_seleccionados_total=Hautatutako erregistroak guztira
tags/v2_0_0_Build_2042/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_it.properties
1
registros_seleccionados_total=Totale registri selezionati
tags/v2_0_0_Build_2042/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text.properties
1
Visible=Visible
2
Nombre=Nombre
3
Alias=Alias
4

  
5
Error_editar_geometria=Error al editar la geometr?a
6
Geometria_no_editable_WKT=Geometr?a no editable en formato WKT, valor demasiado grande.
7

  
8
geometry_to_wkt_exception=Error al convertir la geometr?a de la celda a formato WKT
9
features_data_reload_exception=Error al recargar los fen?menos (features)
10
get_feature_at_exception=Error al obtener el fen?meno de la fila = %(rowIndex)
11
get_row_count_exception=Error al obtener el n?mero total de filas en la tabla
12
set_feature_value_exception=Error al establecer el valor de la celda en la fila = %(rowIndex) y columna = %(columnIndex) con el valor = %(value)
13
wkt_to_geometry_exception=Error al convertir a geometr?a el valor en WKT: %(wkt)
14
table_selection_change_exception=Error al cambiar la selecci?n en la tabla de fen?menos (features)
15

  
16
registros_seleccionados_total=Total registros seleccionados
tags/v2_0_0_Build_2042/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_zh.properties
1
registros_seleccionados_total=\u5df2\u9009\u5b9a\u8bb0\u5f55\u603b\u6570
tags/v2_0_0_Build_2042/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_en.properties
1
Visible=Visible
2
Nombre=Name
3
Alias=Alias
4

  
5
Error_editar_geometria=Error while editing the geometry
6
Geometria_no_editable_WKT=Geometry not editable on WKT format, text value too big.
7

  
8
geometry_to_wkt_exception=Error getting the geometry value of the cell as WKT
9
features_data_reload_exception=Error reloading the features
10
get_feature_at_exception=Error getting the feature at row = %(rowIndex)
11
get_row_count_exception=Error getting the total table row count
12
set_feature_value_exception=Error setting the value of the cell at row = %(rowIndex) and column = %(columnIndex) with the value = %(value)
13
wkt_to_geometry_exception=Error getting the geometry value of the WKT value %(wkt)
14
table_selection_change_exception=Error while changing the selection on the list of Features
15

  
16
registros_seleccionados_total=Total of selected records
tags/v2_0_0_Build_2042/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_gl.properties
1
registros_seleccionados_total=Total rexistros seleccionados
tags/v2_0_0_Build_2042/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_ca.properties
1
registros_seleccionados_total=Total registres seleccionats
tags/v2_0_0_Build_2042/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_pt.properties
1
registros_seleccionados_total=Total de registos seleccionados
tags/v2_0_0_Build_2042/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_cs.properties
1
registros_seleccionados_total=Celkem zvolen\u00fdch z\u00e1znam\u016f
tags/v2_0_0_Build_2042/libraries/libFMap_controls/resources/org/gvsig/fmap/mapcontrol/i18n/text_fr.properties
1
registros_seleccionados_total=Total registres s\u00e9lectionn\u00e9s
tags/v2_0_0_Build_2042/libraries/libFMap_controls/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.mapcontrol.MapControlLibrary
2
org.gvsig.fmap.mapcontrol.impl.DefaultMapControlLibrary
tags/v2_0_0_Build_2042/libraries/libFMap_controls/src-test/org/gvsig/fmap/mapcontrol/tools/AreaListenerTest.java
1
package org.gvsig.fmap.mapcontrol.tools;
2

  
3
import java.awt.geom.Point2D;
4

  
5
import org.cresques.cts.IProjection;
6
import org.gvsig.fmap.crs.CRSFactory;
7
import org.gvsig.fmap.mapcontext.MapContext;
8
import org.gvsig.fmap.mapcontext.ViewPort;
9
import org.gvsig.fmap.mapcontrol.MapControl;
10
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
11

  
12

  
13
public class AreaListenerTest extends AbstractLibraryAutoInitTestCase {
14
	private IProjection projectionUTM = CRSFactory.getCRS("EPSG:23030");
15
	private IProjection projectionGeo = CRSFactory.getCRS("EPSG:4230");
16
		
17
	@Override
18
	protected void doSetUp() throws Exception {
19
		// Nothing to do	
20
	}
21

  
22
	public void test1() {
23
		AreaListenerImpl areaListenerUTM=new AreaListenerImpl(newMapControlUTM());
24
		AreaListenerImpl areaListenerGeo=new AreaListenerImpl(newMapControlGeo());
25
		Double[] xsUTM=new Double[] {new Double(731292),new Double(731901),new Double(730138)};
26
		Double[] ysUTM=new Double[] {new Double(4351223),new Double(4350768),new Double(4349232)};
27
		double areaUTM=areaListenerUTM.returnCoordsArea(xsUTM,ysUTM,new Point2D.Double(730138,4349232));
28
		Double[] xsGeo=new Double[] {new Double(-0.31888183),new Double(-0.31173131),new Double(-0.33268401)};
29
		Double[] ysGeo=new Double[] {new Double(39.27871741),new Double(39.27464327),new Double(39.26117368)};
30
		double areaGeo=areaListenerGeo.returnGeoCArea(xsGeo,ysGeo,new Point2D.Double(-0.33268401,39.26117368));
31
		assertTrue("Area UTM igual a Geo",areaUTM<(areaGeo+1000)&& areaUTM>(areaGeo-1000));
32
	}
33
	private MapControl newMapControlUTM() {
34
		ViewPort vp = new ViewPort(projectionUTM);
35
		MapControl mc=new MapControl();
36
		mc.setMapContext(new MapContext(vp));
37
		return mc;
38
	}
39
	private MapControl newMapControlGeo() {
40
		ViewPort vp = new ViewPort(projectionGeo);
41
		MapControl mc=new MapControl();
42
		mc.setMapContext(new MapContext(vp));
43
		return mc;
44
	}
45
}
tags/v2_0_0_Build_2042/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/LayersDynObjectSetComponent.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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
 */
22
package org.gvsig.fmap.mapcontrol.swing.dynobject;
23

  
24
import org.gvsig.tools.dispose.Disposable;
25
import org.gvsig.tools.swing.api.Component;
26

  
27
/**
28
 * Interface for components to show information of a list of layers.
29
 * 
30
 * @author gvSIG Team
31
 * @version $Id$
32
 */
33
public interface LayersDynObjectSetComponent extends Component, Disposable {
34

  
35

  
36
}
tags/v2_0_0_Build_2042/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/impl/LayersDynObjectSetComponentModel.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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
 */
22
package org.gvsig.fmap.mapcontrol.swing.dynobject.impl;
23

  
24
import java.util.Iterator;
25
import java.util.Map;
26
import java.util.Set;
27

  
28
import javax.swing.AbstractListModel;
29

  
30
import org.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent;
31
import org.gvsig.tools.dispose.Disposable;
32
import org.gvsig.tools.dynobject.DynObjectSet;
33

  
34
/**
35
 * Model for a {@link LayersDynObjectSetComponent}.
36
 * 
37
 * @author gvSIG Team
38
 * @version $Id$
39
 */
40
public class LayersDynObjectSetComponentModel extends AbstractListModel
41
    implements Disposable {
42

  
43
    private static final long serialVersionUID = -7978388308830573063L;
44

  
45
    private final Map<String, DynObjectSet> layerName2InfoByPoint;
46
    private final String[] layerNames;
47

  
48
    public LayersDynObjectSetComponentModel(
49
        Map<String, DynObjectSet> layerName2InfoByPoint) {
50
        this.layerName2InfoByPoint = layerName2InfoByPoint;
51
        Set<String> keyset = layerName2InfoByPoint.keySet();
52
        layerNames = keyset.toArray(new String[keyset.size()]);
53
    }
54

  
55
    public String[] getLayerNames() {
56
        Set<String> keyset = layerName2InfoByPoint.keySet();
57
        return keyset.toArray(new String[keyset.size()]);
58
    }
59

  
60
    public DynObjectSet getLayerInfoByPoint(String layerName) {
61
        return layerName2InfoByPoint.get(layerName);
62
    }
63

  
64
    public int getSize() {
65
        return layerName2InfoByPoint.size();
66
    }
67

  
68
    public Object getElementAt(int index) {
69
        return layerNames[index];
70
    }
71

  
72
    public void dispose() {
73
        for (Iterator<DynObjectSet> iterator =
74
            layerName2InfoByPoint.values().iterator(); iterator.hasNext();) {
75
            iterator.next().dispose();
76
        }
77
        layerName2InfoByPoint.clear();
78
    }
79
}
tags/v2_0_0_Build_2042/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/impl/DefaultLayersDynObjectSetComponent.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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
 */
22
package org.gvsig.fmap.mapcontrol.swing.dynobject.impl;
23

  
24
import java.awt.BorderLayout;
25
import java.util.Map;
26

  
27
import javax.swing.JComponent;
28
import javax.swing.JList;
29
import javax.swing.JPanel;
30
import javax.swing.ListSelectionModel;
31
import javax.swing.event.ListSelectionEvent;
32
import javax.swing.event.ListSelectionListener;
33

  
34
import org.slf4j.Logger;
35
import org.slf4j.LoggerFactory;
36

  
37
import org.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent;
38
import org.gvsig.tools.dynobject.DynObjectSet;
39
import org.gvsig.tools.exception.BaseException;
40
import org.gvsig.tools.swing.api.ToolsSwingLocator;
41
import org.gvsig.tools.swing.api.dynobject.set.JDynObjectSetComponent;
42

  
43
/**
44
 * @author gvSIG Team
45
 * @version $Id$
46
 * 
47
 */
48
public class DefaultLayersDynObjectSetComponent extends JPanel implements
49
    LayersDynObjectSetComponent, ListSelectionListener {
50

  
51
    private static final long serialVersionUID = 5864674721657215264L;
52

  
53
    private static final Logger LOG = LoggerFactory
54
        .getLogger(DefaultLayersDynObjectSetComponent.class);
55

  
56
    private final LayersDynObjectSetComponentModel model;
57

  
58
    private JDynObjectSetComponent component;
59

  
60
    private JList layersList;
61

  
62
    private final boolean writable;
63

  
64
    /**
65
     * Creates a new {@link DefaultLayersDynObjectSetComponent} with the given
66
     * information for a list of layers.
67
     */
68
    public DefaultLayersDynObjectSetComponent(
69
        Map<String, DynObjectSet> layerName2InfoByPoint) {
70
        this(layerName2InfoByPoint, true);
71
    }
72

  
73
    /**
74
     * @param isDoubleBuffered
75
     */
76
    public DefaultLayersDynObjectSetComponent(
77
        Map<String, DynObjectSet> layerName2InfoByPoint,
78
 boolean writable) {
79
        super(new BorderLayout());
80
        this.writable = writable;
81
        model = new LayersDynObjectSetComponentModel(layerName2InfoByPoint);
82
        initializeUI();
83
    }
84

  
85
    private void initializeUI() {
86
        addLayerList();
87
    }
88

  
89
    private void addLayerList() {
90
        layersList = new JList(model);
91
        layersList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
92
        layersList.setLayoutOrientation(JList.VERTICAL);
93
        // list.setVisibleRowCount(20);
94
        layersList.addListSelectionListener(this);
95

  
96
        add(layersList, BorderLayout.WEST);
97

  
98
        layersList.setSelectedIndex(0);
99
    }
100

  
101
    public void valueChanged(ListSelectionEvent e) {
102
        if (!e.getValueIsAdjusting()) {
103
            String layerName = (String) layersList.getSelectedValue();
104
            setCurrentLayerInfoByPoint(layerName);
105
        }
106
    }
107

  
108
    private void setCurrentLayerInfoByPoint(String layerName) {
109
        JDynObjectSetComponent newComponent = null;
110

  
111
        DynObjectSet dynObjectSet = model.getLayerInfoByPoint(layerName);
112
        try {
113
            newComponent =
114
                ToolsSwingLocator.getDynObjectSwingManager()
115
                    .createJDynObjectSetComponent(dynObjectSet, writable);
116
        } catch (BaseException e) {
117
            LOG.error("Error creating the JDynObjectSetComponent for "
118
                + "the DynObjectSet: " + dynObjectSet, e);
119
        }
120

  
121
        if (newComponent != null) {
122
            removeCurrentDynObjectSetComponent();
123
            component = newComponent;
124
            add(component.asJComponent(), BorderLayout.CENTER);
125
            revalidate();
126
            repaint();
127
        }
128
    }
129

  
130
    public JComponent asJComponent() {
131
        return this;
132
    }
133

  
134
    public void dispose() {
135
        removeCurrentDynObjectSetComponent();
136
        model.dispose();
137
    }
138

  
139
    private void removeCurrentDynObjectSetComponent() {
140
        if (component != null) {
141
            remove(component.asJComponent());
142
            component.dispose();
143
        }
144
    }
145

  
146
}
tags/v2_0_0_Build_2042/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectViewer.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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
 */
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I. S.A.   {{Task}}
26
*/
27

  
28
package org.gvsig.fmap.mapcontrol.swing.dynobject;
29

  
30
import java.awt.Color;
31
import java.awt.GridBagConstraints;
32
import java.awt.GridBagLayout;
33

  
34
import javax.swing.JLabel;
35
import javax.swing.JPanel;
36
import javax.swing.JTextField;
37

  
38
import org.cresques.cts.IProjection;
39

  
40
import org.gvsig.i18n.Messages;
41
import org.gvsig.tools.dynobject.DynClass;
42
import org.gvsig.tools.dynobject.DynField;
43
import org.gvsig.tools.dynobject.DynObject;
44

  
45

  
46
public class DynObjectViewer extends JPanel {
47

  
48
	/**
49
	 *
50
	 */
51
	private static final long serialVersionUID = -5277036770491043233L;
52
	private GridBagConstraints paramsListLabelConstraint;
53
	private GridBagConstraints paramsListValueConstraint;
54
	private GridBagConstraints paramsListFillConstraint;
55

  
56
	public DynObjectViewer() {
57
		super();
58
		this.intialize();
59
	}
60

  
61
	private void intialize() {
62
		this.setLayout(new GridBagLayout());
63

  
64
		paramsListLabelConstraint = new GridBagConstraints();
65
		paramsListValueConstraint = new GridBagConstraints();
66
		paramsListFillConstraint = new GridBagConstraints();
67

  
68
		paramsListLabelConstraint.ipadx = 3;
69
		paramsListLabelConstraint.ipady = 3;
70
		paramsListLabelConstraint.anchor = GridBagConstraints.FIRST_LINE_START;
71
		paramsListLabelConstraint.gridwidth = GridBagConstraints.RELATIVE;
72
		paramsListLabelConstraint.fill = GridBagConstraints.HORIZONTAL;
73

  
74
		paramsListValueConstraint.ipadx = 3;
75
		paramsListValueConstraint.ipady = 3;
76
		paramsListValueConstraint.anchor = GridBagConstraints.FIRST_LINE_END;
77
		paramsListValueConstraint.gridwidth = GridBagConstraints.REMAINDER;
78
		paramsListValueConstraint.fill = GridBagConstraints.HORIZONTAL;
79
		paramsListValueConstraint.weightx = 1;
80

  
81
		paramsListFillConstraint.ipadx = 3;
82
		paramsListFillConstraint.ipady = 3;
83
		paramsListFillConstraint.anchor = GridBagConstraints.FIRST_LINE_END;
84
		paramsListFillConstraint.gridwidth = GridBagConstraints.REMAINDER;
85
		paramsListFillConstraint.fill = GridBagConstraints.BOTH;
86
		paramsListFillConstraint.weightx = 1;
87
		paramsListFillConstraint.weighty = 1;
88
	}
89

  
90
	private String getLocalizedText(String txt) {
91
		try {
92
			return Messages.getText(txt);
93
		} catch (Exception e) {
94
			return txt;
95
		}
96
	}
97

  
98
	public void load(DynObject dynObj) {
99
		this.removeAll();
100

  
101
		if (dynObj == null) {
102
			this.doLayout();
103
			return;
104
		}
105
		DynClass dynClass = dynObj.getDynClass();
106

  
107
		JTextField label;
108
		JTextField text;
109
		Object value;
110
		String strValue;
111

  
112
		//		label = new JLabel();
113
		//		label.setText(getLocalizedText("parameter"));
114
		//		label.setBackground(Color.LIGHT_GRAY);
115
		//		this.add(label, paramsListLabelConstraint);
116

  
117
		text = new JTextField();
118
		text.setText(getLocalizedText("parameter"));
119
		text.setEditable(false);
120
		text.setBackground(Color.LIGHT_GRAY);
121
		this.add(text, paramsListLabelConstraint);
122

  
123
		text = new JTextField();
124
		text.setText(getLocalizedText("value"));
125
		text.setEditable(false);
126
		text.setBackground(Color.LIGHT_GRAY);
127
		this.add(text, paramsListValueConstraint);
128

  
129
		for (DynField field : dynClass.getDynFields()) {
130
			label = new JTextField();
131
			label.setText(field.getDescription());
132
			label.setEditable(false);
133
			this.add(label, paramsListLabelConstraint);
134

  
135
			strValue = "";
136
			value = dynObj.getDynValue(field.getName());
137
			if (value != null) {
138
				if (value instanceof String) {
139
					strValue = (String) value;
140
				} else if (value instanceof IProjection) {
141
					strValue = ((IProjection) value).getAbrev();
142
				} else {
143
					strValue = value.toString();
144
				}
145

  
146
			}
147
			text = new JTextField();
148
			text.setText(strValue);
149
			text.setEditable(false);
150
			this.add(text, paramsListValueConstraint);
151
		}
152

  
153
		this.add(new JLabel(), paramsListFillConstraint);
154

  
155
		this.doLayout();
156
		this.repaint();
157

  
158
	}
159
}
0 160

  
tags/v2_0_0_Build_2042/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectEditor.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 IVER T.I. S.A.   {{Task}}
26
 */
27

  
28
/**
29
 *
30
 */
31
package org.gvsig.fmap.mapcontrol.swing.dynobject;
32

  
33
import java.awt.BorderLayout;
34
import java.awt.Component;
35
import java.awt.GridBagConstraints;
36
import java.awt.GridBagLayout;
37
import java.awt.Insets;
38
import java.awt.event.ActionEvent;
39
import java.awt.event.ActionListener;
40

  
41
import javax.swing.JButton;
42
import javax.swing.JLabel;
43
import javax.swing.JPanel;
44

  
45
import org.slf4j.Logger;
46
import org.slf4j.LoggerFactory;
47

  
48
import org.gvsig.i18n.Messages;
49
import org.gvsig.tools.dynobject.DynObject;
50
import org.gvsig.tools.service.ServiceException;
51
import org.gvsig.tools.swing.api.ToolsSwingLocator;
52
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent;
53
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
54

  
55
/**
56
 * Editor for a store parameters.
57
 * 
58
 * @author gvSIG Team
59
 * @version $Id$
60
 */
61
public class DynObjectEditor extends JPanel implements ActionListener {
62

  
63
    private static final long serialVersionUID = 23898787077741411L;
64

  
65
    private static final Logger LOG = LoggerFactory
66
        .getLogger(DynObjectEditor.class);
67
    
68
    private static final WindowManager WINDOW_MANAGER =
69
        ToolsSwingLocator.getWindowManager();
70
    
71
    private String title;
72

  
73
    private JButton botAcept;
74
    private JButton botCancel;
75
    private JButton botRestoreDefaults;
76
    private JPanel panButtons;
77

  
78
    private boolean modal;
79

  
80
    private JDynObjectComponent component;
81

  
82
    public DynObjectEditor(DynObject parameters) throws ServiceException {
83
        component =
84
            ToolsSwingLocator.getDynObjectSwingManager()
85
                .createJDynObjectComponent(parameters, true);
86
        this.setLayout(new BorderLayout());
87
        this.add(component.asJComponent(), BorderLayout.CENTER);
88
        this.add(getButtonsPanel(), BorderLayout.SOUTH);
89
    }
90

  
91
    private JPanel getButtonsPanel() {
92
        if (this.panButtons == null) {
93
            this.panButtons = new JPanel();
94
            this.panButtons.setLayout(new GridBagLayout());
95
            GridBagConstraints constr = new GridBagConstraints();
96
            constr.anchor = GridBagConstraints.LAST_LINE_END;
97
            constr.fill = GridBagConstraints.HORIZONTAL;
98
            constr.weightx = 1;
99
            constr.weighty = 0;
100
            this.panButtons.add(new JLabel(), constr);
101

  
102
            constr = this.getDefaultParametersConstraints();
103
            constr.fill = GridBagConstraints.NONE;
104
            constr.weightx = 0;
105
            constr.weighty = 0;
106

  
107
            this.panButtons.add(this.getAcceptButton(), constr);
108
            this.panButtons.add(this.getCancelButton(), constr);
109
            this.panButtons.add(this.getRestoreDefaults(), constr);
110
        }
111
        return this.panButtons;
112
    }
113

  
114
    private GridBagConstraints getDefaultParametersConstraints() {
115
        GridBagConstraints constr = new GridBagConstraints();
116
        constr.insets = new Insets(2, 2, 2, 2);
117
        constr.ipadx = 2;
118
        constr.ipady = 2;
119
        constr.anchor = GridBagConstraints.PAGE_START;
120
        return constr;
121

  
122
    }
123

  
124
    private JButton getRestoreDefaults() {
125
        if (this.botRestoreDefaults == null) {
126
            this.botRestoreDefaults =
127
                ToolsSwingLocator.getUsabilitySwingManager().createJButton(
128
                    Messages.getText("restoreDefaults"));
129
            this.botRestoreDefaults.addActionListener(this);
130
        }
131
        return this.botRestoreDefaults;
132
    }
133

  
134
    private JButton getCancelButton() {
135
        if (this.botCancel == null) {
136
            this.botCancel =
137
                ToolsSwingLocator.getUsabilitySwingManager().createJButton(
138
                    Messages.getText("cancel"));
139
            this.botCancel.addActionListener(this);
140
        }
141
        return this.botCancel;
142
    }
143

  
144
    private JButton getAcceptButton() {
145
        if (this.botAcept == null) {
146
            this.botAcept =
147
                ToolsSwingLocator.getUsabilitySwingManager().createJButton(
148
                    Messages.getText("accept"));
149
            this.botAcept.addActionListener(this);
150
        }
151
        return this.botAcept;
152
    }
153

  
154
    public void actionPerformed(ActionEvent e) {
155
        Component source = (Component) e.getSource();
156
        if (source == this.botAcept) {
157
            this.component.saveStatus();
158
            this.closeWindow();
159

  
160
        } else
161
            if (source == this.botCancel) {
162
                // TODO Close windows
163
                this.closeWindow();
164
            } else
165
                if (source == this.botRestoreDefaults) {
166
                    // TODO: implement
167
                    // this.component.restore();
168

  
169
                }
170
    }
171

  
172
    protected void closeWindow() {
173
        LOG.debug("Closing window, values edited: ", component.getDynObject());
174
        this.setVisible(false);       
175
    }
176

  
177
    public void editObject(boolean modal) {
178
        this.modal = modal;
179
        
180
        WINDOW_MANAGER.showWindow(this, 
181
            Messages.getText("explorer_parameters"), 
182
            WindowManager.MODE.DIALOG);
183
    }
184

  
185
    public String getTitle() {
186
        return title;
187
    }
188

  
189
    public void setTitle(String title) {
190
        this.title = title;
191
    }
192
  
193
    public DynObject getParameters() {
194
        return component.getDynObject();
195
    }
196
}
0 197

  
tags/v2_0_0_Build_2042/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.fmap.mapcontrol;
29

  
30
import java.util.Map;
31
import java.util.prefs.Preferences;
32

  
33
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
34
import org.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent;
35
import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapper;
36
import org.gvsig.tools.dynobject.DynObject;
37
import org.gvsig.tools.dynobject.DynObjectSet;
38

  
39
/**
40
 * <p>
41
 * This class is the manager of the MapControl library. It is used to
42
 * manage all the properties related with the drawing of objects 
43
 * in a map, including default symbols used to draw objects
44
 * in a map, the tolerance used by the selection or edition tools...
45
 * </p>
46
 * <p>
47
 * It also holds the implementations of the {@link MapControlDrawer}'s, 
48
 * that is the responsible to draw graphical objects in a map.
49
 * </p> 
50
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
51
 */
52
public interface MapControlManager {
53

  
54
	public MapControl createJMapControlPanel() throws MapControlCreationException;
55
		
56
	/**
57
	 * Register a <code>MapControlDrawer</code> by name.
58
	 * @param name
59
	 * Name of the <code>MapControlDrawer</code>.
60
	 * @param mapControolDrawerClass
61
	 * Class used to draw graphical objects on a map.
62
	 */
63
	public void registerMapControlDrawer(String name, Class mapControolDrawerClass);
64
	
65
	/**
66
	 * Creates a <code>MapControlDrawer</code> from a name.
67
	 * @param name
68
	 * Name of the <code>MapControlDrawer</code>.
69
	 * @return
70
	 * A <code>MapControlDrawer</code>.
71
	 * @throws MapControlCreationException
72
	 */
73
	public MapControlDrawer createMapControlDrawer(String name) throws MapControlCreationException;
74
	
75
	/**
76
	 * It registers the default implementation for the <code>MapControlDrawer</code>.
77
	 * @param mapControlDrawerClass
78
	 * A <code>MapControlDrawer</code>. 
79
	 */
80
	public void registerDefaultMapControlDrawer(Class mapControlDrawerClass);
81
	
82
	/**
83
	 * It returns the default implementation for the <code>MapControlDrawer</code>.
84
	 * @return
85
	 * The default <code>MapControlDrawer</code>.
86
	 * @throws MapControlCreationException
87
	 */
88
	public MapControlDrawer createDefaultMapControlDrawer() throws MapControlCreationException;
89
	
90
	/**
91
	 * Returns a snapper in a concrete position;
92
	 * @param index
93
	 * Snapper position.
94
	 * @return
95
	 * A snapper. 
96
	 */
97
	public ISnapper getSnapperAt(int index);
98
	
99
	/**
100
	 * Returns the number of registered snappers.
101
	 * @return
102
	 * The number of registered snappers.
103
	 */
104
	public int getSnapperCount();
105
	
106
	/**
107
	 * Add a snapper.
108
	 * @param snapper
109
	 */
110
	public void registerSnapper(String name, Class snapperClass);
111
	
112
	
113
	public Preferences getEditionPreferences();
114
	
115
	/**
116
	 * Tolerance (in pixels) that has to be used by the tools
117
	 * that use snapping.
118
	 * @return
119
	 * The distance in pixels.
120
	 */
121
	public int getTolerance();
122
	
123
	/**
124
	 * Sets the tolerance (in pixels) that has to be used by the
125
	 * tools that use snapping.
126
	 * @param tolerance
127
	 * The tolerance to apply
128
	 */
129
	public void setTolerance(int tolerance);
130
	
131
	/**
132
	 * Sets the symbol that has to be used to draw a geometry when
133
	 * it is selected.
134
	 * @param selectionSymbol
135
	 * The symbol to apply.
136
	 * @deprecated the symbol for edition is the selection symbol
137
	 */
138
	public void setSelectionSymbol(ISymbol selectionSymbol);
139
	
140
	/**
141
	 * Gets the symbol used to draw the selected geometries.
142
	 * @return
143
	 * The symbol used to draw the selected geometries.
144
	 * @deprecated the symbol for edition is the selection symbol
145
	 */
146
	public ISymbol getSelectionSymbol();
147
	
148
	/**
149
	 * Sets the symbol that has to be used to draw a geometry that
150
	 * represent the axis of a geometry.
151
	 * @param axisReferencesSymbol
152
	 * The symbol to apply.
153
	 */
154
	public void setAxisReferenceSymbol(ISymbol axisReferencesSymbol);
155
	
156
	/**
157
	 * Gets the symbol used to draw the axis of a geometry.
158
	 * @return
159
	 * The symbol used to draw the axis of a geometry.
160
	 */
161
	public ISymbol getAxisReferenceSymbol();
162
	
163
	/**
164
	 * Sets the symbol that has to be used to draw a geometry when
165
	 * it is selected.
166
	 * @param geometrySelectionSymbol
167
	 * The symbol to apply.
168
	 */
169
	public void setGeometrySelectionSymbol(ISymbol geometrySelectionSymbol);
170
	
171
	/**
172
	 * Gets the symbol used to draw the selected geometries.
173
	 * @return
174
	 * The symbol used to draw the selected geometries.
175
	 */
176
	public ISymbol getGeometrySelectionSymbol();
177
	
178
	/**
179
	 * Sets the symbol that has to be used to draw the handlers.
180
	 * @param handlerSymbol
181
	 * The symbol to apply.
182
	 */
183
	public void setHandlerSymbol(ISymbol handlerSymbol);
184
	
185
	/**
186
	 * Gets the symbol used to draw the handlers.
187
	 * @return
188
	 * The symbol used to draw the handlers.
189
	 */
190
	public ISymbol getHandlerSymbol();
191

  
192
    /**
193
     * Creates a readonly component to view information of a set of layers. The
194
     * information must be provided as a set of {@link DynObject}s, through a
195
     * {@link DynObjectSet}.
196
     * 
197
     * @param layerName2InfoByPoint
198
     *            the map of {@link DynObjectSet} for each layer.
199
     * @return the component to view the information
200
     */
201
    public LayersDynObjectSetComponent createLayersDynObjectSetComponent(
202
        Map<String, DynObjectSet> layerName2InfoByPoint);
203

  
204
    /**
205
     * Creates a component to view information of a set of layers. The
206
     * information must be provided as a set of {@link DynObject}s, through a
207
     * {@link DynObjectSet}.
208
     * 
209
     * @param layerName2InfoByPoint
210
     *            the map of {@link DynObjectSet} for each layer.
211
     * @param writable
212
     *            if the DynObjects loaded must be able to be edited
213
     * @return the component to view the information
214
     */
215
    public LayersDynObjectSetComponent createLayersDynObjectSetComponent(
216
        Map<String, DynObjectSet> layerName2InfoByPoint, boolean writable);
217
}
218

  
0 219

  
tags/v2_0_0_Build_2042/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControlException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.fmap.mapcontrol;
29

  
30
import org.gvsig.tools.exception.BaseException;
31

  
32
/**
33
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
34
 */
35
public class MapControlException extends BaseException {
36
	private static final long serialVersionUID = 981894833703125550L;
37

  
38
	/**
39
     * @see BaseException#BaseException(String, String, long)
40
     */
41
    public MapControlException(String message, String key, long code) {
42
        super(message, key, code);
43
    }
44

  
45
    /**
46
     * @see BaseException#BaseException(String, Throwable, String, long)
47
     */
48
    public MapControlException(String message, Throwable cause, String key,
49
            long code) {
50
        super(message, cause, key, code);
51
    }
52
}
53

  
54

  
0 55

  
tags/v2_0_0_Build_2042/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControl.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff