Revision 38672
tags/v2_0_0_Build_2050/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_2050/libraries/libFMap_controls/src/org/gvsig/app/gui/JComboBoxUnits.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.app.gui; |
|
42 |
|
|
43 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
44 |
import org.gvsig.i18n.Messages; |
|
45 |
import org.gvsig.utils.swing.JComboBox; |
|
46 |
|
|
47 |
|
|
48 |
/** |
|
49 |
* <p>Class representing a JComboBox with the measure units handled by the application. |
|
50 |
* It takes values from Attributes.NAMES and Attributes.CHANGE static fields. So, to |
|
51 |
* add more measure units, you must edit Attributes class and change will be automatically |
|
52 |
* reflected in the combo box.</p> |
|
53 |
* |
|
54 |
* <p>The internatiolanization of the field is automatically handled by the system</p> |
|
55 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
56 |
*/ |
|
57 |
public class JComboBoxUnits extends JComboBox { |
|
58 |
private static final long serialVersionUID = 8015263853737441433L; |
|
59 |
|
|
60 |
/** |
|
61 |
* Creates a new instance of JUnitComboBox including "pixel" units and |
|
62 |
* setting them as automatically pre-selected. |
|
63 |
*/ |
|
64 |
public JComboBoxUnits() { |
|
65 |
this(true); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* |
|
70 |
* Creates a new instance of JUnitComboBox. If includePixel is true |
|
71 |
* then pixel units are included in the list and they are automatically |
|
72 |
* pre-selected. Otherwise, meters are preselected. |
|
73 |
* |
|
74 |
*/ |
|
75 |
public JComboBoxUnits(boolean includePixel) { |
|
76 |
super(); |
|
77 |
String[] names=MapContext.getDistanceNames(); |
|
78 |
|
|
79 |
for (int i = 0; i < names.length; i++) { |
|
80 |
super.addItem(Messages.getText(names[i])); |
|
81 |
} |
|
82 |
if (includePixel) { |
|
83 |
super.addItem(Messages.getText("pixels")); |
|
84 |
setSelectedItem(Messages.getText("pixels")); |
|
85 |
} else { |
|
86 |
setSelectedIndex(1); |
|
87 |
} |
|
88 |
setMaximumRowCount(10); |
|
89 |
} |
|
90 |
|
|
91 |
|
|
92 |
/** |
|
93 |
* Returns the conversion factor from the <b>unit selected in the combo box</b> |
|
94 |
* to <b>meters</b> or <b>0</b> if pixels have been selected as the size unit. |
|
95 |
* @return |
|
96 |
*/ |
|
97 |
public double getUnitConversionFactor() { |
|
98 |
double unitFactor; |
|
99 |
try { |
|
100 |
unitFactor = MapContext.getDistanceTrans2Meter()[getSelectedIndex()]; |
|
101 |
} catch (ArrayIndexOutOfBoundsException aioobEx) { //jijiji |
|
102 |
unitFactor = 0; // which represents size in pixel |
|
103 |
} |
|
104 |
return unitFactor; |
|
105 |
|
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* the use of this method is not allowed in this combo box. |
|
110 |
* @deprecated |
|
111 |
*/ |
|
112 |
public void addItem(Object anObject) { |
|
113 |
throw new Error("Operation not allowed"); |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* the use of this method is not allowed for this combo box. |
|
118 |
* @deprecated |
|
119 |
*/ |
|
120 |
public void removeAllItems() { |
|
121 |
throw new Error("Operation not allowed"); |
|
122 |
} |
|
123 |
|
|
124 |
public int getSelectedUnitIndex() { |
|
125 |
int i = getSelectedIndex(); |
|
126 |
if (i>MapContext.getDistanceNames().length-1) |
|
127 |
return -1; |
|
128 |
else return i; |
|
129 |
} |
|
130 |
|
|
131 |
public void setSelectedUnitIndex(int unitIndex) { |
|
132 |
if (unitIndex == -1) { |
|
133 |
setSelectedIndex(getItemCount()-1); |
|
134 |
} else { |
|
135 |
setSelectedIndex(unitIndex); |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
} |
tags/v2_0_0_Build_2050/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynfield/factory/GeometryDynFieldComponentFactory.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2012 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.fmap.mapcontrol.swing.dynfield.factory; |
|
24 |
|
|
25 |
import org.gvsig.fmap.geom.DataTypes; |
|
26 |
import org.gvsig.fmap.geom.Geometry; |
|
27 |
import org.gvsig.fmap.mapcontrol.swing.dynfield.GeometryDynFieldComponent; |
|
28 |
import org.gvsig.tools.dynobject.DynField; |
|
29 |
import org.gvsig.tools.service.ServiceException; |
|
30 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
|
31 |
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField; |
|
32 |
import org.gvsig.tools.swing.spi.AbstractJDynFieldComponentFactory; |
|
33 |
|
|
34 |
|
|
35 |
/** |
|
36 |
* This factory will create a swing component to represent |
|
37 |
* a {@link Geometry} object (for example when opening |
|
38 |
* a info by point dialog) |
|
39 |
* |
|
40 |
* @author jldominguez |
|
41 |
* |
|
42 |
*/ |
|
43 |
public class GeometryDynFieldComponentFactory extends |
|
44 |
AbstractJDynFieldComponentFactory { |
|
45 |
|
|
46 |
public JDynFieldComponent createJDynFieldComponent(DynField child, |
|
47 |
ValueField dynObject, boolean writable) throws ServiceException { |
|
48 |
|
|
49 |
return new GeometryDynFieldComponent(child, dynObject, writable); |
|
50 |
} |
|
51 |
|
|
52 |
public String getFactoryDescription() { |
|
53 |
// TODO Auto-generated method stub |
|
54 |
return null; |
|
55 |
} |
|
56 |
|
|
57 |
public String getFactorySubType() { |
|
58 |
// TODO Auto-generated method stub |
|
59 |
return null; |
|
60 |
} |
|
61 |
|
|
62 |
public Integer getFactoryType() { |
|
63 |
return DataTypes.GEOMETRY; |
|
64 |
} |
|
65 |
|
|
66 |
} |
tags/v2_0_0_Build_2050/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynfield/GeometryDynFieldComponent.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2012 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.fmap.mapcontrol.swing.dynfield; |
|
24 |
|
|
25 |
import java.awt.event.ActionEvent; |
|
26 |
import java.awt.event.ActionListener; |
|
27 |
|
|
28 |
import javax.swing.BoxLayout; |
|
29 |
import javax.swing.JCheckBox; |
|
30 |
import javax.swing.JComponent; |
|
31 |
import javax.swing.JPanel; |
|
32 |
import javax.swing.JTextField; |
|
33 |
|
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
37 |
import org.gvsig.fmap.geom.Geometry; |
|
38 |
import org.gvsig.i18n.Messages; |
|
39 |
import org.gvsig.tools.dynobject.DynField; |
|
40 |
import org.gvsig.tools.service.ServiceException; |
|
41 |
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField; |
|
42 |
import org.gvsig.tools.swing.spi.AbstractJDynFieldComponent; |
|
43 |
|
|
44 |
|
|
45 |
/** |
|
46 |
* |
|
47 |
* This class provides a swing component |
|
48 |
* to represent {@link Geometry} objects in dialogs/forms |
|
49 |
* |
|
50 |
* |
|
51 |
* @author jldominguez |
|
52 |
* |
|
53 |
*/ |
|
54 |
public class GeometryDynFieldComponent extends |
|
55 |
AbstractJDynFieldComponent implements ActionListener { |
|
56 |
|
|
57 |
private static Logger logger = |
|
58 |
LoggerFactory.getLogger(GeometryDynFieldComponent.class); |
|
59 |
|
|
60 |
private JCheckBox wktCheckBox = null; |
|
61 |
private JTextField txtField = null; |
|
62 |
private JPanel panel = null; |
|
63 |
|
|
64 |
public GeometryDynFieldComponent( |
|
65 |
DynField definition, |
|
66 |
ValueField value, |
|
67 |
boolean writeable) throws ServiceException { |
|
68 |
|
|
69 |
super(definition, value, false /* cannot edit geometry. writeable*/); |
|
70 |
init(); |
|
71 |
} |
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
public void setEnabled(boolean isEnabled) { |
|
78 |
} |
|
79 |
|
|
80 |
public void requestFocus() { |
|
81 |
} |
|
82 |
|
|
83 |
public JComponent asJComponent() { |
|
84 |
return panel; |
|
85 |
} |
|
86 |
|
|
87 |
public Object getValue() { |
|
88 |
return this.getFieldValue(); |
|
89 |
} |
|
90 |
|
|
91 |
protected void setJDynFieldComponentListeners() { |
|
92 |
} |
|
93 |
|
|
94 |
protected void afterUI() { |
|
95 |
} |
|
96 |
|
|
97 |
protected void initData() { |
|
98 |
} |
|
99 |
|
|
100 |
private String getValueText(boolean wkt) { |
|
101 |
Object val = this.getFieldValue(); |
|
102 |
String txt = null; |
|
103 |
|
|
104 |
if (val == null || (!(val instanceof Geometry))) { |
|
105 |
txt = "[" + Messages.getText("_Invalid_value") + "]"; |
|
106 |
} else { |
|
107 |
Geometry geom = (Geometry) val; |
|
108 |
if (wkt) { |
|
109 |
try { |
|
110 |
txt = geom.convertToWKT(); |
|
111 |
} catch (Exception e) { |
|
112 |
logger.info("Error while getting WKT: " + e.getMessage(), e); |
|
113 |
txt = "[" + Messages.getText("_Unable_to_show_value") + "]"; |
|
114 |
} |
|
115 |
} else { |
|
116 |
txt = geom.getGeometryType().getName(); |
|
117 |
} |
|
118 |
} |
|
119 |
return txt; |
|
120 |
} |
|
121 |
|
|
122 |
protected void initUI() { |
|
123 |
|
|
124 |
wktCheckBox = |
|
125 |
new JCheckBox(Messages.getText("_Show_as_text") + " "); |
|
126 |
wktCheckBox.setSelected(false); |
|
127 |
wktCheckBox.addActionListener(this); |
|
128 |
txtField = new JTextField(); |
|
129 |
// txtField.setEditable(false); |
|
130 |
txtField.setText(this.getValueText(wktCheckBox.isSelected())); |
|
131 |
txtField.setHorizontalAlignment(JTextField.LEFT); |
|
132 |
|
|
133 |
panel = new JPanel(); // new GridBagLayout()); |
|
134 |
panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS)); |
|
135 |
|
|
136 |
/* |
|
137 |
GridBagConstraints constr = new GridBagConstraints(); |
|
138 |
constr.insets = new Insets(3, 3, 3, 3); |
|
139 |
constr.gridx = 0; |
|
140 |
constr.gridy = 0; |
|
141 |
constr.fill = GridBagConstraints.NONE; |
|
142 |
*/ |
|
143 |
|
|
144 |
panel.add(wktCheckBox); // , constr); |
|
145 |
/* |
|
146 |
constr.gridx = 1; |
|
147 |
constr.fill = GridBagConstraints.HORIZONTAL; |
|
148 |
*/ |
|
149 |
panel.add(txtField); // , constr); |
|
150 |
} |
|
151 |
|
|
152 |
protected void setNonNullValue(Object value) { |
|
153 |
} |
|
154 |
|
|
155 |
protected void setNullValue() { |
|
156 |
} |
|
157 |
|
|
158 |
protected void setReadOnly() { |
|
159 |
} |
|
160 |
|
|
161 |
|
|
162 |
public void actionPerformed(ActionEvent e) { |
|
163 |
// update txt field when check box state changes |
|
164 |
if (txtField != null && wktCheckBox != null) { |
|
165 |
txtField.setText(this.getValueText(wktCheckBox.isSelected())); |
|
166 |
txtField.setHorizontalAlignment(JTextField.LEFT); |
|
167 |
} |
|
168 |
} |
|
169 |
|
|
170 |
} |
tags/v2_0_0_Build_2050/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, boolean showDefaultsButton) |
|
83 |
throws ServiceException { |
|
84 |
component = |
|
85 |
ToolsSwingLocator.getDynObjectSwingManager() |
|
86 |
.createJDynObjectComponent(parameters, true); |
|
87 |
this.setLayout(new BorderLayout()); |
|
88 |
this.add(component.asJComponent(), BorderLayout.CENTER); |
|
89 |
this.add(getButtonsPanel(showDefaultsButton), BorderLayout.SOUTH); |
|
90 |
} |
|
91 |
|
|
92 |
public DynObjectEditor(DynObject parameters) throws ServiceException { |
|
93 |
this(parameters, false); |
|
94 |
} |
|
95 |
|
|
96 |
|
|
97 |
private JPanel getButtonsPanel(boolean add_defaults_button) { |
|
98 |
if (this.panButtons == null) { |
|
99 |
this.panButtons = new JPanel(); |
|
100 |
this.panButtons.setLayout(new GridBagLayout()); |
|
101 |
GridBagConstraints constr = new GridBagConstraints(); |
|
102 |
constr.anchor = GridBagConstraints.LAST_LINE_END; |
|
103 |
constr.fill = GridBagConstraints.HORIZONTAL; |
|
104 |
constr.weightx = 1; |
|
105 |
constr.weighty = 0; |
|
106 |
this.panButtons.add(new JLabel(), constr); |
|
107 |
|
|
108 |
constr = this.getDefaultParametersConstraints(); |
|
109 |
constr.fill = GridBagConstraints.NONE; |
|
110 |
constr.weightx = 0; |
|
111 |
constr.weighty = 0; |
|
112 |
|
|
113 |
this.panButtons.add(this.getAcceptButton(), constr); |
|
114 |
this.panButtons.add(this.getCancelButton(), constr); |
|
115 |
if (add_defaults_button) { |
|
116 |
this.panButtons.add(this.getRestoreDefaults(), constr); |
|
117 |
} |
|
118 |
} |
|
119 |
return this.panButtons; |
|
120 |
} |
|
121 |
|
|
122 |
private GridBagConstraints getDefaultParametersConstraints() { |
|
123 |
GridBagConstraints constr = new GridBagConstraints(); |
|
124 |
constr.insets = new Insets(2, 2, 2, 2); |
|
125 |
constr.ipadx = 2; |
|
126 |
constr.ipady = 2; |
|
127 |
constr.anchor = GridBagConstraints.PAGE_START; |
|
128 |
return constr; |
|
129 |
|
|
130 |
} |
|
131 |
|
|
132 |
private JButton getRestoreDefaults() { |
|
133 |
if (this.botRestoreDefaults == null) { |
|
134 |
this.botRestoreDefaults = |
|
135 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton( |
|
136 |
Messages.getText("restoreDefaults")); |
|
137 |
this.botRestoreDefaults.addActionListener(this); |
|
138 |
} |
|
139 |
return this.botRestoreDefaults; |
|
140 |
} |
|
141 |
|
|
142 |
private JButton getCancelButton() { |
|
143 |
if (this.botCancel == null) { |
|
144 |
this.botCancel = |
|
145 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton( |
|
146 |
Messages.getText("cancel")); |
|
147 |
this.botCancel.addActionListener(this); |
|
148 |
} |
|
149 |
return this.botCancel; |
|
150 |
} |
|
151 |
|
|
152 |
private JButton getAcceptButton() { |
|
153 |
if (this.botAcept == null) { |
|
154 |
this.botAcept = |
|
155 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton( |
|
156 |
Messages.getText("accept")); |
|
157 |
this.botAcept.addActionListener(this); |
|
158 |
} |
|
159 |
return this.botAcept; |
|
160 |
} |
|
161 |
|
|
162 |
public void actionPerformed(ActionEvent e) { |
|
163 |
Component source = (Component) e.getSource(); |
|
164 |
if (source == this.botAcept) { |
|
165 |
this.component.saveStatus(); |
|
166 |
this.closeWindow(); |
|
167 |
|
|
168 |
} else |
|
169 |
if (source == this.botCancel) { |
|
170 |
// TODO Close windows |
|
171 |
this.closeWindow(); |
|
172 |
} else |
|
173 |
if (source == this.botRestoreDefaults) { |
|
174 |
// TODO: implement |
|
175 |
// this.component.restore(); |
|
176 |
|
|
177 |
} |
|
178 |
} |
|
179 |
|
|
180 |
protected void closeWindow() { |
|
181 |
LOG.debug("Closing window, values edited: ", component.getDynObject()); |
|
182 |
this.setVisible(false); |
|
183 |
} |
|
184 |
|
|
185 |
public void editObject(boolean modal) { |
|
186 |
this.modal = modal; |
|
187 |
|
|
188 |
WINDOW_MANAGER.showWindow(this, |
|
189 |
Messages.getText("explorer_parameters"), |
|
190 |
WindowManager.MODE.DIALOG); |
|
191 |
} |
|
192 |
|
|
193 |
public String getTitle() { |
|
194 |
return title; |
|
195 |
} |
|
196 |
|
|
197 |
public void setTitle(String title) { |
|
198 |
this.title = title; |
|
199 |
} |
|
200 |
|
|
201 |
public DynObject getParameters() { |
|
202 |
return component.getDynObject(); |
|
203 |
} |
|
204 |
} |
|
0 | 205 |
tags/v2_0_0_Build_2050/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_2050/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_2050/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.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent; |
|
35 |
import org.gvsig.tools.dynobject.DynObjectSet; |
|
36 |
import org.gvsig.tools.exception.BaseException; |
|
37 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
38 |
import org.gvsig.tools.swing.api.dynobject.set.JDynObjectSetComponent; |
|
39 |
import org.slf4j.Logger; |
|
40 |
import org.slf4j.LoggerFactory; |
|
41 |
|
|
42 |
/** |
|
43 |
* @author gvSIG Team |
|
44 |
* @version $Id$ |
|
45 |
* |
|
46 |
*/ |
|
47 |
public class DefaultLayersDynObjectSetComponent extends JPanel implements |
|
48 |
LayersDynObjectSetComponent, ListSelectionListener { |
|
49 |
|
|
50 |
private static final long serialVersionUID = 5864674721657215264L; |
|
51 |
|
|
52 |
private static final Logger LOG = LoggerFactory |
|
53 |
.getLogger(DefaultLayersDynObjectSetComponent.class); |
|
54 |
|
|
55 |
private final LayersDynObjectSetComponentModel model; |
|
56 |
|
|
57 |
private JDynObjectSetComponent component; |
|
58 |
|
|
59 |
private JList layersList; |
|
60 |
|
|
61 |
private final boolean writable; |
|
62 |
|
|
63 |
/** |
|
64 |
* Creates a new {@link DefaultLayersDynObjectSetComponent} with the given |
|
65 |
* information for a list of layers. |
|
66 |
*/ |
|
67 |
public DefaultLayersDynObjectSetComponent( |
|
68 |
Map<String, DynObjectSet> layerName2InfoByPoint) { |
|
69 |
this(layerName2InfoByPoint, true); |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* @param isDoubleBuffered |
|
74 |
*/ |
|
75 |
public DefaultLayersDynObjectSetComponent( |
|
76 |
Map<String, DynObjectSet> layerName2InfoByPoint, |
|
77 |
boolean writable) { |
|
78 |
super(new BorderLayout()); |
|
79 |
this.writable = writable; |
|
80 |
model = new LayersDynObjectSetComponentModel(layerName2InfoByPoint); |
|
81 |
initializeUI(); |
|
82 |
} |
|
83 |
|
|
84 |
private void initializeUI() { |
|
85 |
addLayerList(); |
|
86 |
} |
|
87 |
|
|
88 |
private void addLayerList() { |
|
89 |
layersList = new JList(model); |
|
90 |
layersList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
91 |
layersList.setLayoutOrientation(JList.VERTICAL); |
|
92 |
// list.setVisibleRowCount(20); |
|
93 |
layersList.addListSelectionListener(this); |
|
94 |
|
|
95 |
add(layersList, BorderLayout.WEST); |
|
96 |
|
|
97 |
layersList.setSelectedIndex(0); |
|
98 |
} |
|
99 |
|
|
100 |
public void valueChanged(ListSelectionEvent e) { |
|
101 |
if (!e.getValueIsAdjusting()) { |
|
102 |
String layerName = (String) layersList.getSelectedValue(); |
|
103 |
setCurrentLayerInfoByPoint(layerName); |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 |
private void setCurrentLayerInfoByPoint(String layerName) { |
|
108 |
JDynObjectSetComponent newComponent = null; |
|
109 |
|
|
110 |
DynObjectSet dynObjectSet = model.getLayerInfoByPoint(layerName); |
|
111 |
try { |
|
112 |
newComponent = |
|
113 |
ToolsSwingLocator.getDynObjectSwingManager() |
|
114 |
.createJDynObjectSetComponent(dynObjectSet, writable); |
|
115 |
} catch (BaseException e) { |
|
116 |
LOG.error("Error creating the JDynObjectSetComponent for " |
|
117 |
+ "the DynObjectSet: " + dynObjectSet, e); |
|
118 |
} |
|
119 |
|
|
120 |
if (newComponent != null) { |
|
121 |
removeCurrentDynObjectSetComponent(); |
|
122 |
component = newComponent; |
|
123 |
add(component.asJComponent(), BorderLayout.CENTER); |
|
124 |
revalidate(); |
|
125 |
repaint(); |
|
126 |
} |
|
127 |
} |
|
128 |
|
|
129 |
public JComponent asJComponent() { |
|
130 |
return this; |
|
131 |
} |
|
132 |
|
|
133 |
public void dispose() { |
|
134 |
removeCurrentDynObjectSetComponent(); |
|
135 |
model.dispose(); |
|
136 |
} |
|
137 |
|
|
138 |
private void removeCurrentDynObjectSetComponent() { |
|
139 |
if (component != null) { |
|
140 |
remove(component.asJComponent()); |
|
141 |
component.dispose(); |
|
142 |
} |
|
143 |
} |
|
144 |
|
|
145 |
} |
tags/v2_0_0_Build_2050/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 |
import org.gvsig.i18n.Messages; |
|
40 |
import org.gvsig.tools.dynobject.DynClass; |
|
41 |
import org.gvsig.tools.dynobject.DynField; |
|
42 |
import org.gvsig.tools.dynobject.DynObject; |
|
43 |
|
|
44 |
|
|
45 |
public class DynObjectViewer extends JPanel { |
|
46 |
|
|
47 |
/** |
|
48 |
* |
|
49 |
*/ |
|
50 |
private static final long serialVersionUID = -5277036770491043233L; |
|
51 |
private GridBagConstraints paramsListLabelConstraint; |
|
52 |
private GridBagConstraints paramsListValueConstraint; |
|
53 |
private GridBagConstraints paramsListFillConstraint; |
|
54 |
|
|
55 |
public DynObjectViewer() { |
|
56 |
super(); |
|
57 |
this.intialize(); |
|
58 |
} |
|
59 |
|
|
60 |
private void intialize() { |
|
61 |
this.setLayout(new GridBagLayout()); |
|
62 |
|
|
63 |
paramsListLabelConstraint = new GridBagConstraints(); |
|
64 |
paramsListValueConstraint = new GridBagConstraints(); |
|
65 |
paramsListFillConstraint = new GridBagConstraints(); |
|
66 |
|
|
67 |
paramsListLabelConstraint.ipadx = 3; |
|
68 |
paramsListLabelConstraint.ipady = 3; |
|
69 |
paramsListLabelConstraint.anchor = GridBagConstraints.FIRST_LINE_START; |
|
70 |
paramsListLabelConstraint.gridwidth = GridBagConstraints.RELATIVE; |
|
71 |
paramsListLabelConstraint.fill = GridBagConstraints.HORIZONTAL; |
|
72 |
paramsListLabelConstraint.weightx = 0.5; |
|
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 = 0.5; |
|
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_2050/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_2050/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_2050/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 |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.fmap.mapcontrol; |
|
42 |
|
|
43 |
import java.awt.Color; |
|
44 |
import java.awt.Cursor; |
|
45 |
import java.awt.Dimension; |
|
46 |
import java.awt.Graphics; |
|
47 |
import java.awt.Graphics2D; |
|
48 |
import java.awt.Image; |
|
49 |
import java.awt.Point; |
|
50 |
import java.awt.Toolkit; |
|
51 |
import java.awt.event.ActionEvent; |
|
52 |
import java.awt.event.ActionListener; |
|
53 |
import java.awt.event.ComponentEvent; |
|
54 |
import java.awt.event.ComponentListener; |
|
55 |
import java.awt.event.MouseEvent; |
|
56 |
import java.awt.event.MouseListener; |
|
57 |
import java.awt.event.MouseMotionListener; |
|
58 |
import java.awt.event.MouseWheelEvent; |
|
59 |
import java.awt.event.MouseWheelListener; |
|
60 |
import java.awt.geom.Point2D; |
|
61 |
import java.awt.image.BufferedImage; |
|
62 |
import java.awt.image.MemoryImageSource; |
|
63 |
import java.util.ArrayList; |
|
64 |
import java.util.Comparator; |
|
65 |
import java.util.HashMap; |
|
66 |
import java.util.List; |
|
67 |
import java.util.Set; |
|
68 |
import java.util.TreeMap; |
|
69 |
import java.util.prefs.Preferences; |
|
70 |
|
|
71 |
import javax.swing.JComponent; |
|
72 |
import javax.swing.SwingUtilities; |
|
73 |
import javax.swing.Timer; |
|
74 |
|
|
75 |
import org.cresques.cts.IProjection; |
|
76 |
import org.slf4j.Logger; |
|
77 |
import org.slf4j.LoggerFactory; |
|
78 |
|
|
79 |
import org.gvsig.fmap.crs.CRSFactory; |
|
80 |
import org.gvsig.fmap.dal.DataStoreNotification; |
|
81 |
import org.gvsig.fmap.dal.feature.FeatureStoreNotification; |
|
82 |
import org.gvsig.fmap.geom.Geometry; |
|
83 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
84 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
85 |
import org.gvsig.fmap.geom.GeometryManager; |
|
86 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
87 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
88 |
import org.gvsig.fmap.geom.util.Converter; |
|
89 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
90 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
91 |
import org.gvsig.fmap.mapcontext.events.AtomicEvent; |
|
92 |
import org.gvsig.fmap.mapcontext.events.listeners.AtomicEventListener; |
|
93 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
94 |
import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent; |
|
95 |
import org.gvsig.fmap.mapcontext.layers.LayerEvent; |
|
96 |
import org.gvsig.fmap.mapcontext.layers.SpatialCache; |
|
97 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
98 |
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer; |
|
99 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
100 |
import org.gvsig.fmap.mapcontrol.tools.CompoundBehavior; |
Also available in: Unified diff