Revision 44124
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/test/java/org/gvsig/fmap/mapcontrol/tools/AreaListenerTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.fmap.mapcontrol.tools; |
|
25 |
|
|
26 |
import java.awt.geom.Point2D; |
|
27 |
|
|
28 |
import org.cresques.cts.IProjection; |
|
29 |
import org.gvsig.fmap.crs.CRSFactory; |
|
30 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
31 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
32 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
33 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
34 |
|
|
35 |
|
|
36 |
public class AreaListenerTest extends AbstractLibraryAutoInitTestCase { |
|
37 |
private IProjection projectionUTM = CRSFactory.getCRS("EPSG:23030"); |
|
38 |
private IProjection projectionGeo = CRSFactory.getCRS("EPSG:4230"); |
|
39 |
|
|
40 |
@Override |
|
41 |
protected void doSetUp() throws Exception { |
|
42 |
// Nothing to do |
|
43 |
} |
|
44 |
|
|
45 |
public void test1() { |
|
46 |
AreaListenerImpl areaListenerUTM=new AreaListenerImpl(newMapControlUTM()); |
|
47 |
AreaListenerImpl areaListenerGeo=new AreaListenerImpl(newMapControlGeo()); |
|
48 |
Double[] xsUTM=new Double[] {new Double(731292),new Double(731901),new Double(730138)}; |
|
49 |
Double[] ysUTM=new Double[] {new Double(4351223),new Double(4350768),new Double(4349232)}; |
|
50 |
double areaUTM=areaListenerUTM.returnCoordsArea(xsUTM,ysUTM,new Point2D.Double(730138,4349232)); |
|
51 |
Double[] xsGeo=new Double[] {new Double(-0.31888183),new Double(-0.31173131),new Double(-0.33268401)}; |
|
52 |
Double[] ysGeo=new Double[] {new Double(39.27871741),new Double(39.27464327),new Double(39.26117368)}; |
|
53 |
double areaGeo=areaListenerGeo.returnGeoCArea(xsGeo,ysGeo,new Point2D.Double(-0.33268401,39.26117368)); |
|
54 |
assertTrue("Area UTM igual a Geo",areaUTM<(areaGeo+1000)&& areaUTM>(areaGeo-1000)); |
|
55 |
} |
|
56 |
private MapControl newMapControlUTM() { |
|
57 |
ViewPort vp = new ViewPort(projectionUTM); |
|
58 |
MapControl mc=new MapControl(); |
|
59 |
mc.setMapContext(new MapContext(vp)); |
|
60 |
return mc; |
|
61 |
} |
|
62 |
private MapControl newMapControlGeo() { |
|
63 |
ViewPort vp = new ViewPort(projectionGeo); |
|
64 |
MapControl mc=new MapControl(); |
|
65 |
mc.setMapContext(new MapContext(vp)); |
|
66 |
return mc; |
|
67 |
} |
|
68 |
} |
|
0 | 69 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.fmap.mapcontrol.MapControlLibrary |
|
2 |
org.gvsig.fmap.mapcontrol.impl.DefaultMapControlLibrary |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/resources/org/gvsig/fmap/mapcontrol/i18n/text_zh.properties | ||
---|---|---|
1 |
registros_seleccionados_total=\u5df2\u9009\u5b9a\u8bb0\u5f55\u603b\u6570 |
|
0 | 2 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/resources/org/gvsig/fmap/mapcontrol/i18n/text_en.properties | ||
---|---|---|
1 |
Visible=Visible |
|
2 |
Nombre=Name |
|
3 |
Alias=Alias |
|
4 |
Calculated=Calculated |
|
5 |
|
|
6 |
Error_editar_geometria=Error while editing the geometry |
|
7 |
Geometria_no_editable_WKT=Geometry not editable on WKT format, text value too big. |
|
8 |
|
|
9 |
geometry_to_wkt_exception=Error getting the geometry value of the cell as WKT |
|
10 |
features_data_reload_exception=Error reloading the features |
|
11 |
get_feature_at_exception=Error getting the feature at row = %(rowIndex) |
|
12 |
get_row_count_exception=Error getting the total table row count |
|
13 |
set_feature_value_exception=Error setting the value of the cell at row = %(rowIndex) and column = %(columnIndex) with the value = %(value) |
|
14 |
wkt_to_geometry_exception=Error getting the geometry value of the WKT value %(wkt) |
|
15 |
table_selection_change_exception=Error while changing the selection on the list of Features |
|
16 |
|
|
17 |
registros_seleccionados_total=Total of selected records |
|
18 |
up=Up |
|
19 |
down=Down |
|
20 |
|
|
21 |
_Invalid_value=Invalid Value |
|
22 |
_Unable_to_show_value=Unable to show value |
|
23 |
_Show_as_text=Show as text |
|
24 |
|
|
25 |
_Pixels=Pixels |
|
0 | 26 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/resources/org/gvsig/fmap/mapcontrol/i18n/text_gl.properties | ||
---|---|---|
1 |
registros_seleccionados_total=Total rexistros seleccionados |
|
0 | 2 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/resources/org/gvsig/fmap/mapcontrol/i18n/text_ca.properties | ||
---|---|---|
1 |
registros_seleccionados_total=Total registres seleccionats |
|
0 | 2 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/resources/org/gvsig/fmap/mapcontrol/i18n/text_pt.properties | ||
---|---|---|
1 |
registros_seleccionados_total=Total de registos seleccionados |
|
0 | 2 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/resources/org/gvsig/fmap/mapcontrol/i18n/text_cs.properties | ||
---|---|---|
1 |
registros_seleccionados_total=Celkem zvolen\u00fdch z\u00e1znam\u016f |
|
0 | 2 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/resources/org/gvsig/fmap/mapcontrol/i18n/text_fr.properties | ||
---|---|---|
1 |
registros_seleccionados_total=Total registres s\u00e9lectionn\u00e9s |
|
0 | 2 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/resources/org/gvsig/fmap/mapcontrol/i18n/text_de.properties | ||
---|---|---|
1 |
registros_seleccionados_total=Alle ausgew\u00e4hlten register |
|
0 | 2 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/resources/org/gvsig/fmap/mapcontrol/i18n/text_eu.properties | ||
---|---|---|
1 |
registros_seleccionados_total=Hautatutako erregistroak guztira |
|
0 | 2 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/resources/org/gvsig/fmap/mapcontrol/i18n/text_it.properties | ||
---|---|---|
1 |
registros_seleccionados_total=Totale registri selezionati |
|
0 | 2 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/resources/org/gvsig/fmap/mapcontrol/i18n/text.properties | ||
---|---|---|
1 |
Visible=Visible |
|
2 |
Nombre=Nombre |
|
3 |
Alias=Alias |
|
4 |
Calculated=Calculado |
|
5 |
|
|
6 |
Error_editar_geometria=Error al editar la geometr\u00eda |
|
7 |
Geometria_no_editable_WKT=Geometr\u00eda no editable en formato WKT, valor demasiado grande. |
|
8 |
|
|
9 |
geometry_to_wkt_exception=Error al convertir la geometr\u00eda de la celda a formato WKT |
|
10 |
features_data_reload_exception=Error al recargar los fen\u00f3menos (features) |
|
11 |
get_feature_at_exception=Error al obtener el fen\u00f3meno de la fila = %(rowIndex) |
|
12 |
get_row_count_exception=Error al obtener el n\u00famero total de filas en la tabla |
|
13 |
set_feature_value_exception=Error al establecer el valor de la celda en la fila = %(rowIndex) y columna = %(columnIndex) con el valor = %(value) |
|
14 |
wkt_to_geometry_exception=Error al convertir a geometr\u00eda el valor en WKT: %(wkt) |
|
15 |
table_selection_change_exception=Error al cambiar la selecci\u00f3n en la tabla de fen\u00f3menos (features) |
|
16 |
|
|
17 |
registros_seleccionados_total=Total registros seleccionados |
|
18 |
up=Subir |
|
19 |
down=Bajar |
|
20 |
remove=Eliminar |
|
21 |
|
|
22 |
_Invalid_value=Valor no v\u00e1lido |
|
23 |
_Unable_to_show_value=No se ha podido mostrar valor |
|
24 |
_Show_as_text=Mostrar como texto |
|
25 |
|
|
26 |
_Pixels=P\u00edxeles |
|
27 |
|
|
0 | 28 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/app/gui/JComboBoxUnits.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.app.gui; |
|
25 |
|
|
26 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
27 |
import org.gvsig.i18n.Messages; |
|
28 |
import org.gvsig.utils.swing.JComboBox; |
|
29 |
|
|
30 |
|
|
31 |
/** |
|
32 |
* <p>Class representing a JComboBox with the measure units handled by the application. |
|
33 |
* It takes values from Attributes.NAMES and Attributes.CHANGE static fields. So, to |
|
34 |
* add more measure units, you must edit Attributes class and change will be automatically |
|
35 |
* reflected in the combo box.</p> |
|
36 |
* |
|
37 |
* <p>The internatiolanization of the field is automatically handled by the system</p> |
|
38 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
39 |
*/ |
|
40 |
public class JComboBoxUnits extends JComboBox { |
|
41 |
private static final long serialVersionUID = 8015263853737441433L; |
|
42 |
|
|
43 |
/** |
|
44 |
* Creates a new instance of JUnitComboBox including "pixel" units and |
|
45 |
* setting them as automatically pre-selected. |
|
46 |
*/ |
|
47 |
public JComboBoxUnits() { |
|
48 |
this(true); |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* |
|
53 |
* Creates a new instance of JUnitComboBox. If includePixel is true |
|
54 |
* then pixel units are included in the list and they are automatically |
|
55 |
* pre-selected. Otherwise, meters are preselected. |
|
56 |
* |
|
57 |
*/ |
|
58 |
public JComboBoxUnits(boolean includePixel) { |
|
59 |
super(); |
|
60 |
String[] names=MapContext.getDistanceNames(); |
|
61 |
|
|
62 |
for (int i = 0; i < names.length; i++) { |
|
63 |
super.addItem(Messages.getText(names[i])); |
|
64 |
} |
|
65 |
if (includePixel) { |
|
66 |
super.addItem(Messages.getText("_Pixels")); |
|
67 |
setSelectedItem(Messages.getText("_Pixels")); |
|
68 |
} else { |
|
69 |
setSelectedIndex(1); |
|
70 |
} |
|
71 |
setMaximumRowCount(10); |
|
72 |
} |
|
73 |
|
|
74 |
|
|
75 |
/** |
|
76 |
* Returns the conversion factor from the <b>unit selected in the combo box</b> |
|
77 |
* to <b>meters</b> or <b>0</b> if pixels have been selected as the size unit. |
|
78 |
* @return |
|
79 |
*/ |
|
80 |
public double getUnitConversionFactor() { |
|
81 |
double unitFactor; |
|
82 |
try { |
|
83 |
unitFactor = MapContext.getDistanceTrans2Meter()[getSelectedIndex()]; |
|
84 |
} catch (ArrayIndexOutOfBoundsException aioobEx) { //jijiji |
|
85 |
unitFactor = 0; // which represents size in pixel |
|
86 |
} |
|
87 |
return unitFactor; |
|
88 |
|
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* the use of this method is not allowed in this combo box. |
|
93 |
* @deprecated |
|
94 |
*/ |
|
95 |
public void addItem(Object anObject) { |
|
96 |
throw new Error("Operation not allowed"); |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* the use of this method is not allowed for this combo box. |
|
101 |
* @deprecated |
|
102 |
*/ |
|
103 |
public void removeAllItems() { |
|
104 |
throw new Error("Operation not allowed"); |
|
105 |
} |
|
106 |
|
|
107 |
public int getSelectedUnitIndex() { |
|
108 |
int i = getSelectedIndex(); |
|
109 |
if (i>MapContext.getDistanceNames().length-1) |
|
110 |
return -1; |
|
111 |
else return i; |
|
112 |
} |
|
113 |
|
|
114 |
public void setSelectedUnitIndex(int unitIndex) { |
|
115 |
if (unitIndex == -1) { |
|
116 |
setSelectedIndex(getItemCount()-1); |
|
117 |
} else { |
|
118 |
setSelectedIndex(unitIndex); |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
} |
|
0 | 125 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/IconThemeHelper.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.fmap; |
|
25 |
|
|
26 |
import java.awt.Image; |
|
27 |
|
|
28 |
import javax.swing.ImageIcon; |
|
29 |
|
|
30 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
31 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
32 |
import org.slf4j.Logger; |
|
33 |
import org.slf4j.LoggerFactory; |
|
34 |
|
|
35 |
public class IconThemeHelper { |
|
36 |
|
|
37 |
private static Logger logger = LoggerFactory.getLogger(IconThemeHelper.class); |
|
38 |
|
|
39 |
public static void registerIcon(String group, String name, Object obj) { |
|
40 |
String resourceName; |
|
41 |
ClassLoader loader; |
|
42 |
IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
|
43 |
if( group == null || group.trim().length()==0 ) { |
|
44 |
resourceName = "images/"+name+".png"; |
|
45 |
} else { |
|
46 |
resourceName = "images/"+group+"/"+name+".png"; |
|
47 |
} |
|
48 |
if( obj instanceof Class ) { |
|
49 |
loader = ((Class) obj).getClassLoader(); |
|
50 |
} else { |
|
51 |
loader = obj.getClass().getClassLoader(); |
|
52 |
} |
|
53 |
try { |
|
54 |
iconTheme.registerDefault("mapcontrol", group, name, null, loader.getResource(resourceName)); |
|
55 |
} catch( Throwable e) { |
|
56 |
logger.info(e.getMessage()); |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
public static ImageIcon getImageIcon(String iconName) { |
|
61 |
IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
|
62 |
return iconTheme.get(iconName); |
|
63 |
} |
|
64 |
|
|
65 |
public static Image getImage(String iconName) { |
|
66 |
IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
|
67 |
return iconTheme.get(iconName).getImage(); |
|
68 |
} |
|
69 |
} |
|
0 | 70 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/MapControlException.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
25 |
* |
|
26 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
27 |
* of the Valencian Government (CIT) |
|
28 |
* |
|
29 |
* This program is free software; you can redistribute it and/or |
|
30 |
* modify it under the terms of the GNU General Public License |
|
31 |
* as published by the Free Software Foundation; either version 2 |
|
32 |
* of the License, or (at your option) any later version. |
|
33 |
* |
|
34 |
* This program is distributed in the hope that it will be useful, |
|
35 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
36 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
37 |
* GNU General Public License for more details. |
|
38 |
* |
|
39 |
* You should have received a copy of the GNU General Public License |
|
40 |
* along with this program; if not, write to the Free Software |
|
41 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
42 |
* MA 02110-1301, USA. |
|
43 |
* |
|
44 |
*/ |
|
45 |
|
|
46 |
/* |
|
47 |
* AUTHORS (In addition to CIT): |
|
48 |
* 2009 {Iver T.I.} {Task} |
|
49 |
*/ |
|
50 |
|
|
51 |
package org.gvsig.fmap.mapcontrol; |
|
52 |
|
|
53 |
import org.gvsig.tools.exception.BaseException; |
|
54 |
|
|
55 |
/** |
|
56 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
57 |
*/ |
|
58 |
public class MapControlException extends BaseException { |
|
59 |
private static final long serialVersionUID = 981894833703125550L; |
|
60 |
|
|
61 |
/** |
|
62 |
* @see BaseException#BaseException(String, String, long) |
|
63 |
*/ |
|
64 |
public MapControlException(String message, String key, long code) { |
|
65 |
super(message, key, code); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* @see BaseException#BaseException(String, Throwable, String, long) |
|
70 |
*/ |
|
71 |
public MapControlException(String message, Throwable cause, String key, |
|
72 |
long code) { |
|
73 |
super(message, cause, key, code); |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
|
|
0 | 78 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/LayersTreeModel.java | ||
---|---|---|
1 |
package org.gvsig.fmap.mapcontrol; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Arrays; |
|
5 |
import java.util.Iterator; |
|
6 |
import java.util.List; |
|
7 |
import javax.swing.event.TreeModelEvent; |
|
8 |
import javax.swing.event.TreeModelListener; |
|
9 |
import javax.swing.tree.TreeModel; |
|
10 |
import javax.swing.tree.TreePath; |
|
11 |
import org.apache.commons.lang3.BooleanUtils; |
|
12 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
13 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
14 |
import org.gvsig.tools.evaluator.Evaluator; |
|
15 |
import org.gvsig.tools.evaluator.EvaluatorData; |
|
16 |
|
|
17 |
public class LayersTreeModel implements TreeModel { |
|
18 |
|
|
19 |
private final List<TreeModelListener> listeners = new ArrayList(); |
|
20 |
protected FLayers layers; |
|
21 |
private Evaluator filter; |
|
22 |
private MyEvaluatorData datafilter; |
|
23 |
|
|
24 |
private static class MyEvaluatorData implements EvaluatorData { |
|
25 |
|
|
26 |
public FLayer layer = null; |
|
27 |
|
|
28 |
@Override |
|
29 |
public Object getDataValue(String name) { |
|
30 |
if (name.equalsIgnoreCase("layer")) { |
|
31 |
return layer; |
|
32 |
} |
|
33 |
return null; |
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public Object getContextValue(String name) { |
|
38 |
if (name.equalsIgnoreCase("layer")) { |
|
39 |
return layer; |
|
40 |
} |
|
41 |
return null; |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public Iterator getDataValues() { |
|
46 |
return Arrays.asList(new FLayer[]{this.layer}).iterator(); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public Iterator getDataNames() { |
|
51 |
return Arrays.asList(new String[]{"layer"}).iterator(); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public boolean hasDataValue(String name) { |
|
56 |
if (name.equalsIgnoreCase("layer")) { |
|
57 |
return true; |
|
58 |
} |
|
59 |
return false; |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public boolean hasContextValue(String name) { |
|
64 |
if (name.equalsIgnoreCase("layer")) { |
|
65 |
return true; |
|
66 |
} |
|
67 |
return false; |
|
68 |
} |
|
69 |
|
|
70 |
} |
|
71 |
|
|
72 |
public LayersTreeModel(FLayers layers) { |
|
73 |
this.layers = layers; |
|
74 |
} |
|
75 |
|
|
76 |
public void setFilter(Evaluator filter) { |
|
77 |
this.filter = filter; |
|
78 |
this.datafilter = new MyEvaluatorData(); |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public Object getRoot() { |
|
83 |
return layers; |
|
84 |
} |
|
85 |
|
|
86 |
@Override |
|
87 |
public Object getChild(Object parent, int index) { |
|
88 |
if (!(parent instanceof FLayers)) { |
|
89 |
return null; |
|
90 |
} |
|
91 |
return ((FLayers) parent).getLayer(index); |
|
92 |
} |
|
93 |
|
|
94 |
@Override |
|
95 |
public int getChildCount(Object parent) { |
|
96 |
if (!(parent instanceof FLayers)) { |
|
97 |
return 0; |
|
98 |
} |
|
99 |
if (this.filter == null) { |
|
100 |
return ((FLayers) parent).getLayersCount(); |
|
101 |
} |
|
102 |
int count = 0; |
|
103 |
for (int i = 0; i < ((FLayers) parent).getLayersCount(); i++) { |
|
104 |
FLayer layer = ((FLayers) parent).getLayer(i); |
|
105 |
try { |
|
106 |
if (!(layer instanceof FLayers)) { |
|
107 |
this.datafilter.layer = layer; |
|
108 |
if (BooleanUtils.isTrue((Boolean) this.filter.evaluate(this.datafilter))) { |
|
109 |
count++; |
|
110 |
} |
|
111 |
} |
|
112 |
} catch (Exception ex) { |
|
113 |
// Do nothing, skyp this layer on error. |
|
114 |
} |
|
115 |
} |
|
116 |
return count; |
|
117 |
|
|
118 |
} |
|
119 |
|
|
120 |
@Override |
|
121 |
public boolean isLeaf(Object node) { |
|
122 |
return !(node instanceof FLayers); |
|
123 |
} |
|
124 |
|
|
125 |
@Override |
|
126 |
public int getIndexOfChild(Object parent, Object child) { |
|
127 |
if (this.filter == null) { |
|
128 |
for (int i = 0; i < ((FLayers) parent).getLayersCount(); i++) { |
|
129 |
FLayer layer = ((FLayers) parent).getLayer(i); |
|
130 |
if (child == layer) { |
|
131 |
return i; |
|
132 |
} |
|
133 |
} |
|
134 |
return -1; |
|
135 |
} |
|
136 |
int count = 0; |
|
137 |
for (int i = 0; i < ((FLayers) parent).getLayersCount(); i++) { |
|
138 |
FLayer layer = ((FLayers) parent).getLayer(i); |
|
139 |
try { |
|
140 |
if (!(layer instanceof FLayers)) { |
|
141 |
this.datafilter.layer = layer; |
|
142 |
if (BooleanUtils.isTrue((Boolean) this.filter.evaluate(this.datafilter))) { |
|
143 |
if (child == layer) { |
|
144 |
return count; |
|
145 |
} |
|
146 |
count++; |
|
147 |
} |
|
148 |
} |
|
149 |
} catch (Exception ex) { |
|
150 |
// Do nothing, skyp this layer on error. |
|
151 |
} |
|
152 |
} |
|
153 |
return -1; |
|
154 |
|
|
155 |
} |
|
156 |
|
|
157 |
@Override |
|
158 |
public void valueForPathChanged(TreePath path, Object value) { |
|
159 |
} |
|
160 |
|
|
161 |
@Override |
|
162 |
public void addTreeModelListener(TreeModelListener listener) { |
|
163 |
listeners.add(listener); |
|
164 |
} |
|
165 |
|
|
166 |
@Override |
|
167 |
public void removeTreeModelListener(TreeModelListener listener) { |
|
168 |
listeners.remove(listener); |
|
169 |
} |
|
170 |
|
|
171 |
public void reload() { |
|
172 |
TreeModelEvent event = new TreeModelEvent(this, new TreePath(this.layers)); |
|
173 |
Iterator<TreeModelListener> iterator = listeners.iterator(); |
|
174 |
TreeModelListener listener; |
|
175 |
while (iterator.hasNext()) { |
|
176 |
listener = iterator.next(); |
|
177 |
listener.treeStructureChanged(event); |
|
178 |
} |
|
179 |
} |
|
180 |
|
|
181 |
} |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/PrimitivesDrawer.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
25 |
* |
|
26 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
27 |
* of the Valencian Government (CIT) |
|
28 |
* |
|
29 |
* This program is free software; you can redistribute it and/or |
|
30 |
* modify it under the terms of the GNU General Public License |
|
31 |
* as published by the Free Software Foundation; either version 2 |
|
32 |
* of the License, or (at your option) any later version. |
|
33 |
* |
|
34 |
* This program is distributed in the hope that it will be useful, |
|
35 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
36 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
37 |
* GNU General Public License for more details. |
|
38 |
* |
|
39 |
* You should have received a copy of the GNU General Public License |
|
40 |
* along with this program; if not, write to the Free Software |
|
41 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
42 |
* MA 02110-1301, USA. |
|
43 |
* |
|
44 |
*/ |
|
45 |
|
|
46 |
/* |
|
47 |
* AUTHORS (In addition to CIT): |
|
48 |
* 2009 {Iver T.I.} {Task} |
|
49 |
*/ |
|
50 |
|
|
51 |
package org.gvsig.fmap.mapcontrol; |
|
52 |
|
|
53 |
import java.awt.Color; |
|
54 |
import java.awt.Graphics; |
|
55 |
|
|
56 |
/** |
|
57 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
58 |
*/ |
|
59 |
public interface PrimitivesDrawer { |
|
60 |
|
|
61 |
/** |
|
62 |
* This method is used to start a drawing process that needs to |
|
63 |
* be synchronized. |
|
64 |
* @param obj |
|
65 |
* The object that locks the resource. |
|
66 |
* @throws InterruptedException |
|
67 |
*/ |
|
68 |
public void startDrawing(Object obj) throws InterruptedException; |
|
69 |
|
|
70 |
/** |
|
71 |
* This method is used to finish a drawing process that needs to |
|
72 |
* be synchronized. |
|
73 |
* @param obj |
|
74 |
* The object that has locked the resource. |
|
75 |
*/ |
|
76 |
public void stopDrawing(Object obj); |
|
77 |
|
|
78 |
/** |
|
79 |
* This method sets the <code>Graphics</code> where the |
|
80 |
* <code>Drawer</code> has to draw all the objects. |
|
81 |
* @param graphics |
|
82 |
* The component where the new objects has to be drawn. |
|
83 |
*/ |
|
84 |
public void setGraphics(Graphics graphics); |
|
85 |
|
|
86 |
/** |
|
87 |
* Sets the color that is used to draw the objects that don't |
|
88 |
* have a symbol. |
|
89 |
* @param color |
|
90 |
* The color to use on the drawing operations. |
|
91 |
*/ |
|
92 |
public void setColor(Color color); |
|
93 |
|
|
94 |
/** |
|
95 |
* It draws a rectangle on the map using the color |
|
96 |
* specified using the {@link #setColor(Color)} method. |
|
97 |
* @param x |
|
98 |
* The minimum X coordinate. |
|
99 |
* @param y |
|
100 |
* The minimum Y coordinate. |
|
101 |
* @param width |
|
102 |
* The rectangle width. |
|
103 |
* @param height |
|
104 |
* The rectangle height. |
|
105 |
*/ |
|
106 |
public void drawRect(int x, int y, int width, int height); |
|
107 |
|
|
108 |
/** |
|
109 |
* It fills a rectangle on the map using the color |
|
110 |
* specified using the {@link #setColor(Color)} method. |
|
111 |
* @param x |
|
112 |
* The minimum X coordinate. |
|
113 |
* @param y |
|
114 |
* The minimum Y coordinate. |
|
115 |
* @param width |
|
116 |
* The rectangle width. |
|
117 |
* @param height |
|
118 |
* The rectangle height. |
|
119 |
*/ |
|
120 |
public void fillRect(int x, int y, int width, int height); |
|
121 |
|
|
122 |
public void drawOval(int i, int j, int sizePixels, int sizePixels2); |
|
123 |
|
|
124 |
public void drawLine(int x1, int y1, int x3, int y12); |
|
125 |
} |
|
0 | 126 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/MapControlLocator.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
|
|
25 |
package org.gvsig.fmap.mapcontrol; |
|
26 |
|
|
27 |
import org.gvsig.propertypage.PropertiesPageManager; |
|
28 |
import org.gvsig.tools.locator.AbstractLocator; |
|
29 |
import org.gvsig.tools.locator.Locator; |
|
30 |
import org.gvsig.tools.locator.LocatorException; |
|
31 |
import org.gvsig.tools.util.ToolsUtilLocator; |
|
32 |
|
|
33 |
/** |
|
34 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
35 |
*/ |
|
36 |
public class MapControlLocator extends AbstractLocator { |
|
37 |
private static final String LOCATOR_NAME = "MapContolLocator"; |
|
38 |
|
|
39 |
/** |
|
40 |
* MapControlManager name used by the locator to access the instance |
|
41 |
*/ |
|
42 |
public static final String MAPCONTROL_MANAGER_NAME = "MapControlManager"; |
|
43 |
private static final String MAPCONTROL_MANAGER_DESCRIPTION = "MapControlManager of gvSIG"; |
|
44 |
|
|
45 |
public static final String EDITING_NOTIFICATION_MANAGER_NAME = "EditingNotificationManager"; |
|
46 |
private static final String EDITING_NOTIFICATION_MANAGER_DESCRIPTION = "EditingNotificationManager of gvSIG"; |
|
47 |
|
|
48 |
public static final String PROPERTIES_PAGE_MANAGER_NAME = "PropertiesPageManager"; |
|
49 |
private static final String PROPERTIES_PAGE_MANAGER_DESCRIPTION = "PropertiesPage manager of gvSIG"; |
|
50 |
|
|
51 |
/** |
|
52 |
* Unique instance. |
|
53 |
*/ |
|
54 |
private static final MapControlLocator instance = new MapControlLocator(); |
|
55 |
|
|
56 |
/* (non-Javadoc) |
|
57 |
* @see org.gvsig.tools.locator.Locator#getLocatorName() |
|
58 |
*/ |
|
59 |
public String getLocatorName() { |
|
60 |
return LOCATOR_NAME; |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* Return a reference to {@link MapControlManager}. |
|
65 |
* |
|
66 |
* @return a reference to MapControlManager |
|
67 |
* @throws LocatorException |
|
68 |
* if there is no access to the class or the class cannot be |
|
69 |
* instantiated |
|
70 |
* @see Locator#get(String) |
|
71 |
*/ |
|
72 |
public static MapControlManager getMapControlManager() throws LocatorException { |
|
73 |
return (MapControlManager) getInstance().get(MAPCONTROL_MANAGER_NAME); |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Return the singleton instance. |
|
78 |
* |
|
79 |
* @return the singleton instance |
|
80 |
*/ |
|
81 |
public static MapControlLocator getInstance() { |
|
82 |
return instance; |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* Registers the Class implementing the {@link MapControlManager} interface. |
|
87 |
* |
|
88 |
* @param clazz |
|
89 |
* implementing the MapControlManager interface |
|
90 |
*/ |
|
91 |
public static void registerMapControlManager(Class clazz) { |
|
92 |
getInstance().register(MAPCONTROL_MANAGER_NAME, |
|
93 |
MAPCONTROL_MANAGER_DESCRIPTION, |
|
94 |
clazz); |
|
95 |
} |
|
96 |
|
|
97 |
public static PropertiesPageManager getPropertiesPageManager() { |
|
98 |
return ToolsUtilLocator.getPropertiesPageManager(); |
|
99 |
} |
|
100 |
|
|
101 |
} |
|
102 |
|
|
103 |
|
|
0 | 104 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/MapControlLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* |
|
25 |
* AUTHORS (In addition to CIT): |
|
26 |
* 2009 {DiSiD Technologies} {Create Library class to initialize the MapControls library} |
|
27 |
*/ |
|
28 |
package org.gvsig.fmap.mapcontrol; |
|
29 |
|
|
30 |
|
|
31 |
import org.gvsig.fmap.IconThemeHelper; |
|
32 |
import org.gvsig.fmap.mapcontext.MapContextLibrary; |
|
33 |
import org.gvsig.fmap.mapcontrol.swing.pickercontroller.impl.EnvelopePickerControllerImpl; |
|
34 |
import org.gvsig.fmap.mapcontrol.swing.pickercontroller.impl.ScalePickerControllerImpl; |
|
35 |
import org.gvsig.tools.ToolsLocator; |
|
36 |
import org.gvsig.tools.i18n.I18nManager; |
|
37 |
import org.gvsig.tools.library.AbstractLibrary; |
|
38 |
import org.gvsig.tools.library.LibraryException; |
|
39 |
|
|
40 |
/** |
|
41 |
* Initialization of the MapControls library. |
|
42 |
* |
|
43 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
|
44 |
*/ |
|
45 |
public class MapControlLibrary extends AbstractLibrary { |
|
46 |
|
|
47 |
@Override |
|
48 |
public void doRegistration() { |
|
49 |
registerAsAPI(MapControlLibrary.class); |
|
50 |
require(MapContextLibrary.class); |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
protected void doInitialize() throws LibraryException { |
|
55 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
56 |
i18nManager.addResourceFamily( |
|
57 |
"org.gvsig.fmap.mapcontrol.i18n.text", |
|
58 |
MapControlLibrary.class.getClassLoader(), |
|
59 |
MapControlLibrary.class.getClass().getName() |
|
60 |
); |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
protected void doPostInitialize() throws LibraryException { |
|
65 |
IconThemeHelper.registerIcon("cursor", "cursor-crux", this); |
|
66 |
IconThemeHelper.registerIcon("cursor", "cursor-info-by-point",this); |
|
67 |
IconThemeHelper.registerIcon("cursor", "cursor-pan", this); |
|
68 |
IconThemeHelper.registerIcon("cursor", "cursor-query-area", this); |
|
69 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-point", this); |
|
70 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-polygon", this); |
|
71 |
IconThemeHelper.registerIcon("cursor", "cursor-zoom-in", this); |
|
72 |
IconThemeHelper.registerIcon("cursor", "cursor-zoom-out", this); |
|
73 |
|
|
74 |
IconThemeHelper.registerIcon("layer", "layer-icon", this); |
|
75 |
IconThemeHelper.registerIcon("layer", "layer-icon-group", this); |
|
76 |
IconThemeHelper.registerIcon("layer", "layer-icon-vectorial", this); |
|
77 |
|
|
78 |
EnvelopePickerControllerImpl.selfRegister(); |
|
79 |
ScalePickerControllerImpl.selfRegister(); |
|
80 |
|
|
81 |
} |
|
82 |
} |
|
0 | 83 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/CompoundLayersTreeModel.java | ||
---|---|---|
1 |
package org.gvsig.fmap.mapcontrol; |
|
2 |
|
|
3 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
4 |
|
|
5 |
|
|
6 |
public class CompoundLayersTreeModel extends LayersTreeModel { |
|
7 |
|
|
8 |
public CompoundLayersTreeModel() { |
|
9 |
super(new FLayers()); |
|
10 |
} |
|
11 |
|
|
12 |
public void addLayers(FLayers layers) { |
|
13 |
this.layers.add(layers); |
|
14 |
} |
|
15 |
} |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectViewer.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* |
|
25 |
* AUTHORS (In addition to CIT): |
|
26 |
* 2009 IVER T.I. S.A. {{Task}} |
|
27 |
*/ |
|
28 |
|
|
29 |
package org.gvsig.fmap.mapcontrol.swing.dynobject; |
|
30 |
|
|
31 |
import java.awt.Color; |
|
32 |
import java.awt.GridBagConstraints; |
|
33 |
import java.awt.GridBagLayout; |
|
34 |
|
|
35 |
import javax.swing.JLabel; |
|
36 |
import javax.swing.JPanel; |
|
37 |
import javax.swing.JTextField; |
|
38 |
|
|
39 |
import org.cresques.cts.IProjection; |
|
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 |
/** |
|
47 |
* @deprecated use JDynForm |
|
48 |
* @author jjdelcerro |
|
49 |
*/ |
|
50 |
public class DynObjectViewer extends JPanel { |
|
51 |
|
|
52 |
/** |
|
53 |
* |
|
54 |
*/ |
|
55 |
private static final long serialVersionUID = -5277036770491043233L; |
|
56 |
private GridBagConstraints paramsListLabelConstraint; |
|
57 |
private GridBagConstraints paramsListValueConstraint; |
|
58 |
private GridBagConstraints paramsListFillConstraint; |
|
59 |
|
|
60 |
public DynObjectViewer() { |
|
61 |
super(); |
|
62 |
this.intialize(); |
|
63 |
} |
|
64 |
|
|
65 |
private void intialize() { |
|
66 |
this.setLayout(new GridBagLayout()); |
|
67 |
|
|
68 |
paramsListLabelConstraint = new GridBagConstraints(); |
|
69 |
paramsListValueConstraint = new GridBagConstraints(); |
|
70 |
paramsListFillConstraint = new GridBagConstraints(); |
|
71 |
|
|
72 |
paramsListLabelConstraint.ipadx = 3; |
|
73 |
paramsListLabelConstraint.ipady = 3; |
|
74 |
paramsListLabelConstraint.anchor = GridBagConstraints.FIRST_LINE_START; |
|
75 |
paramsListLabelConstraint.gridwidth = GridBagConstraints.RELATIVE; |
|
76 |
paramsListLabelConstraint.fill = GridBagConstraints.HORIZONTAL; |
|
77 |
paramsListLabelConstraint.weightx = 0.5; |
|
78 |
|
|
79 |
paramsListValueConstraint.ipadx = 3; |
|
80 |
paramsListValueConstraint.ipady = 3; |
|
81 |
paramsListValueConstraint.anchor = GridBagConstraints.FIRST_LINE_END; |
|
82 |
paramsListValueConstraint.gridwidth = GridBagConstraints.REMAINDER; |
|
83 |
paramsListValueConstraint.fill = GridBagConstraints.HORIZONTAL; |
|
84 |
paramsListValueConstraint.weightx = 0.5; |
|
85 |
|
|
86 |
paramsListFillConstraint.ipadx = 3; |
|
87 |
paramsListFillConstraint.ipady = 3; |
|
88 |
paramsListFillConstraint.anchor = GridBagConstraints.FIRST_LINE_END; |
|
89 |
paramsListFillConstraint.gridwidth = GridBagConstraints.REMAINDER; |
|
90 |
paramsListFillConstraint.fill = GridBagConstraints.BOTH; |
|
91 |
paramsListFillConstraint.weightx = 1; |
|
92 |
paramsListFillConstraint.weighty = 1; |
|
93 |
} |
|
94 |
|
|
95 |
private String getLocalizedText(String txt) { |
|
96 |
try { |
|
97 |
return Messages.getText(txt); |
|
98 |
} catch (Exception e) { |
|
99 |
return txt; |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
public void load(DynObject dynObj) { |
|
104 |
this.removeAll(); |
|
105 |
|
|
106 |
if (dynObj == null) { |
|
107 |
this.doLayout(); |
|
108 |
return; |
|
109 |
} |
|
110 |
DynClass dynClass = dynObj.getDynClass(); |
|
111 |
|
|
112 |
JTextField label; |
|
113 |
JTextField text; |
|
114 |
Object value; |
|
115 |
String strValue; |
|
116 |
|
|
117 |
// label = new JLabel(); |
|
118 |
// label.setText(getLocalizedText("parameter")); |
|
119 |
// label.setBackground(Color.LIGHT_GRAY); |
|
120 |
// this.add(label, paramsListLabelConstraint); |
|
121 |
|
|
122 |
text = new JTextField(); |
|
123 |
text.setText(getLocalizedText("parameter")); |
|
124 |
text.setEditable(false); |
|
125 |
text.setBackground(Color.LIGHT_GRAY); |
|
126 |
this.add(text, paramsListLabelConstraint); |
|
127 |
|
|
128 |
text = new JTextField(); |
|
129 |
text.setText(getLocalizedText("value")); |
|
130 |
text.setEditable(false); |
|
131 |
text.setBackground(Color.LIGHT_GRAY); |
|
132 |
this.add(text, paramsListValueConstraint); |
|
133 |
|
|
134 |
for (DynField field : dynClass.getDynFields()) { |
|
135 |
label = new JTextField(); |
|
136 |
label.setText(field.getDescription()); |
|
137 |
label.setEditable(false); |
|
138 |
this.add(label, paramsListLabelConstraint); |
|
139 |
|
|
140 |
strValue = ""; |
|
141 |
value = dynObj.getDynValue(field.getName()); |
|
142 |
if (value != null) { |
|
143 |
if (value instanceof String) { |
|
144 |
strValue = (String) value; |
|
145 |
} else if (value instanceof IProjection) { |
|
146 |
strValue = ((IProjection) value).getAbrev(); |
|
147 |
} else { |
|
148 |
strValue = value.toString(); |
|
149 |
} |
|
150 |
|
|
151 |
} |
|
152 |
text = new JTextField(); |
|
153 |
text.setText(strValue); |
|
154 |
text.setEditable(false); |
|
155 |
this.add(text, paramsListValueConstraint); |
|
156 |
} |
|
157 |
|
|
158 |
this.add(new JLabel(), paramsListFillConstraint); |
|
159 |
|
|
160 |
this.doLayout(); |
|
161 |
this.repaint(); |
|
162 |
|
|
163 |
} |
|
164 |
} |
|
0 | 165 |
tags/org.gvsig.desktop-2.0.240/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectEditor.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
Also available in: Unified diff