Revision 4361
org.gvsig.raster/tags/org.gvsig.raster-2.2.27/org.gvsig.raster.app/org.gvsig.raster.app.common/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<!-- |
|
2 |
|
|
3 |
gvSIG. Desktop Geographic Information System. |
|
4 |
|
|
5 |
Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
|
8 |
modify it under the terms of the GNU General Public License |
|
9 |
as published by the Free Software Foundation; either version 3 |
|
10 |
of the License, or (at your option) any later version. |
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful, |
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
GNU General Public License for more details. |
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
|
18 |
along with this program; if not, write to the Free Software |
|
19 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
MA 02110-1301, USA. |
|
21 |
|
|
22 |
For any additional information, do not hesitate to contact us |
|
23 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
|
|
25 |
--> |
|
26 |
<assembly> |
|
27 |
<id>gvsig-plugin-package</id> |
|
28 |
<formats> |
|
29 |
<format>zip</format> |
|
30 |
</formats> |
|
31 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
32 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
33 |
<files> |
|
34 |
<file> |
|
35 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
36 |
<outputDirectory>lib</outputDirectory> |
|
37 |
</file> |
|
38 |
<file> |
|
39 |
<source>target/package.info</source> |
|
40 |
</file> |
|
41 |
</files> |
|
42 |
|
|
43 |
<fileSets> |
|
44 |
<fileSet> |
|
45 |
<directory>src/main/resources-plugin</directory> |
|
46 |
<outputDirectory>.</outputDirectory> |
|
47 |
</fileSet> |
|
48 |
</fileSets> |
|
49 |
|
|
50 |
|
|
51 |
<dependencySets> |
|
52 |
<dependencySet> |
|
53 |
<useProjectArtifact>false</useProjectArtifact> |
|
54 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
55 |
<outputDirectory>lib</outputDirectory> |
|
56 |
<includes> |
|
57 |
<include>org.gvsig:org.gvsig.raster.swing.api:jar</include> |
|
58 |
<include>org.gvsig:org.gvsig.raster.swing.impl:jar</include> |
|
59 |
<include>org.gvsig:org.gvsig.raster.cache.lib.api:jar</include> |
|
60 |
<include>org.gvsig:org.gvsig.raster.cache.lib.impl:jar</include> |
|
61 |
<include>org.gvsig:org.gvsig.raster.lib.api:jar</include> |
|
62 |
<include>org.gvsig:org.gvsig.raster.lib.impl:jar</include> |
|
63 |
<include>org.gvsig:org.gvsig.raster.algorithm:jar</include> |
|
64 |
<include>org.gvsig:org.gvsig.raster.fmap:jar</include> |
|
65 |
<!-- <include>org.gvsig:org.gvsig.timesupport.lib.api:jar</include> |
|
66 |
<include>org.gvsig:org.gvsig.timesupport.lib.impl:jar</include>--> |
|
67 |
<include>org.joda:joda-time:jar</include> |
|
68 |
</includes> |
|
69 |
</dependencySet> |
|
70 |
</dependencySets> |
|
71 |
|
|
72 |
</assembly> |
|
73 |
|
|
74 |
|
org.gvsig.raster/tags/org.gvsig.raster-2.2.27/org.gvsig.raster.app/org.gvsig.raster.app.common/src/main/java/org/gvsig/raster/mainplugin/RasterMainPluginExtension.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.raster.mainplugin; |
|
23 |
|
|
24 |
import org.gvsig.andami.IconThemeHelper; |
|
25 |
import org.gvsig.andami.plugins.Extension; |
|
26 |
import org.gvsig.i18n.Messages; |
|
27 |
import org.gvsig.raster.mainplugin.properties.RasterPropertiesTocMenuEntry; |
|
28 |
import org.gvsig.tools.ToolsLocator; |
|
29 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
30 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
31 |
|
|
32 |
|
|
33 |
/** |
|
34 |
* Main plugin for raster |
|
35 |
* |
|
36 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
37 |
*/ |
|
38 |
public class RasterMainPluginExtension extends Extension { |
|
39 |
|
|
40 |
public void initialize() { |
|
41 |
Messages.addResourceFamily("org.gvsig.raster.mainplugin.i18n.text", |
|
42 |
RasterMainPluginExtension.class.getClassLoader(), |
|
43 |
RasterMainPluginExtension.class.getClass().getName()); |
|
44 |
|
|
45 |
IconThemeHelper.registerIcon(null, "map-ok-ico", this); |
|
46 |
IconThemeHelper.registerIcon("action", "layer-properties-raster", this); |
|
47 |
|
|
48 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
49 |
ExtensionPoint point = null; |
|
50 |
|
|
51 |
//Registro punto de extensi?n del cuadro de propiedades |
|
52 |
if (!extensionPoints.has("RasterSEPropertiesDialog")) { |
|
53 |
point = extensionPoints.add("RasterSEPropertiesDialog"); |
|
54 |
point.setDescription("Raster Properties registrable panels (register instances of javax.swing.JPanel)"); |
|
55 |
} |
|
56 |
|
|
57 |
//Entradas del men? del toc de raster |
|
58 |
if (!extensionPoints.has("View_TocActions")) { |
|
59 |
point = extensionPoints.add("View_TocActions"); |
|
60 |
} |
|
61 |
point = extensionPoints.get("View_TocActions"); |
|
62 |
point.append("RasterSEProperties", "Raster Properties", RasterPropertiesTocMenuEntry.getSingleton()); |
|
63 |
|
|
64 |
//A?ade las propiedades de raster a la barra de herramientas. Si nadie registra paneles estar? vacio |
|
65 |
//cuando se abra |
|
66 |
|
|
67 |
point = extensionPoints.add("GenericToolBarMenu"); |
|
68 |
point.append("RasterProperties", "", RasterPropertiesTocMenuEntry.getSingleton()); |
|
69 |
} |
|
70 |
|
|
71 |
public void execute(String actionCommand) { |
|
72 |
|
|
73 |
} |
|
74 |
|
|
75 |
public boolean isEnabled() { |
|
76 |
return false; |
|
77 |
} |
|
78 |
|
|
79 |
public boolean isVisible() { |
|
80 |
return false; |
|
81 |
} |
|
82 |
|
|
83 |
} |
org.gvsig.raster/tags/org.gvsig.raster-2.2.27/org.gvsig.raster.app/org.gvsig.raster.app.common/src/main/java/org/gvsig/raster/mainplugin/toolbar/ButtonItems.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.raster.mainplugin.toolbar; |
|
23 |
|
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.List; |
|
26 |
|
|
27 |
import javax.swing.JButton; |
|
28 |
|
|
29 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
30 |
import org.gvsig.gui.beans.controls.combobutton.ComboButton; |
|
31 |
/** |
|
32 |
* Clase para gestionar y ordenar los items de un ComboButton |
|
33 |
* |
|
34 |
* @version 13/02/2008 |
|
35 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
36 |
*/ |
|
37 |
public class ButtonItems { |
|
38 |
private ComboButton comboButton = null; |
|
39 |
private FLayer[] layers = null; |
|
40 |
private List<IGenericToolBarMenuItem> arrayList = new ArrayList<IGenericToolBarMenuItem>(); |
|
41 |
private List<String> arrayKeys = new ArrayList<String>(); |
|
42 |
|
|
43 |
public ButtonItems(ComboButton comboButton, FLayer[] layers) { |
|
44 |
this.comboButton = comboButton; |
|
45 |
this.layers = layers; |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* A?ade un item al ComboButton |
|
50 |
* @param menuItem |
|
51 |
* @param key |
|
52 |
*/ |
|
53 |
public void addButton(IGenericToolBarMenuItem menuItem, String key) { |
|
54 |
int pos = 0; |
|
55 |
boolean find = false; |
|
56 |
for (int i = 0; i < arrayList.size(); i++) { |
|
57 |
pos = i; |
|
58 |
IGenericToolBarMenuItem aux = (IGenericToolBarMenuItem) arrayList.get(i); |
|
59 |
if (aux.getGroupOrder() > menuItem.getGroupOrder()) { |
|
60 |
find = true; |
|
61 |
break; |
|
62 |
} |
|
63 |
if (aux.getGroupOrder() == menuItem.getGroupOrder()) { |
|
64 |
if (aux.getOrder() > menuItem.getOrder()) { |
|
65 |
find = true; |
|
66 |
break; |
|
67 |
} |
|
68 |
} |
|
69 |
} |
|
70 |
if (!find) |
|
71 |
pos = arrayList.size(); |
|
72 |
arrayList.add(pos, menuItem); |
|
73 |
arrayKeys.add(pos, key); |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Refresca los items del ComboButton |
|
78 |
*/ |
|
79 |
public void refresh() { |
|
80 |
String actionCommand = comboButton.getActionCommand(); |
|
81 |
comboButton.clearButtons(); |
|
82 |
int group = -1; |
|
83 |
for (int i = 0; i < arrayList.size(); i++) { |
|
84 |
IGenericToolBarMenuItem aux = (IGenericToolBarMenuItem) arrayList.get(i); |
|
85 |
|
|
86 |
if ((group != -1) && (group != aux.getGroupOrder())) |
|
87 |
comboButton.addSeparator(); |
|
88 |
|
|
89 |
JButton button2 = new JButton(aux.getText(), aux.getIcon()); |
|
90 |
|
|
91 |
if (!aux.isVisible(null, layers)) |
|
92 |
button2.setEnabled(false); |
|
93 |
|
|
94 |
if (!aux.isEnabled(null, layers)) |
|
95 |
button2.setEnabled(false); |
|
96 |
|
|
97 |
button2.setActionCommand((String) arrayKeys.get(i)); |
|
98 |
comboButton.addButton(button2); |
|
99 |
group = aux.getGroupOrder(); |
|
100 |
} |
|
101 |
comboButton.setSelectedItem(actionCommand); |
|
102 |
} |
|
103 |
} |
org.gvsig.raster/tags/org.gvsig.raster-2.2.27/org.gvsig.raster.app/org.gvsig.raster.app.common/src/main/java/org/gvsig/raster/mainplugin/toolbar/GenericToolBarPanel.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.raster.mainplugin.toolbar; |
|
23 |
|
|
24 |
import java.awt.Insets; |
|
25 |
import java.awt.event.ActionEvent; |
|
26 |
import java.awt.event.ActionListener; |
|
27 |
import java.awt.event.ItemEvent; |
|
28 |
import java.awt.event.ItemListener; |
|
29 |
import java.awt.event.MouseEvent; |
|
30 |
import java.awt.event.MouseListener; |
|
31 |
import java.util.ArrayList; |
|
32 |
import java.util.Iterator; |
|
33 |
import java.util.List; |
|
34 |
|
|
35 |
import javax.swing.JButton; |
|
36 |
import javax.swing.JToolBar; |
|
37 |
|
|
38 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
39 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
40 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.DefaultComboBoxConfigurableLookUpModel; |
|
41 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.JComboBoxConfigurableLookUp; |
|
42 |
import org.gvsig.gui.beans.controls.IControl; |
|
43 |
import org.gvsig.gui.beans.controls.combobutton.ComboButton; |
|
44 |
import org.gvsig.gui.beans.controls.combobutton.ComboButtonEvent; |
|
45 |
import org.gvsig.gui.beans.controls.combobutton.ComboButtonListener; |
|
46 |
import org.gvsig.tools.ToolsLocator; |
|
47 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
48 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
49 |
/** |
|
50 |
* Componente que contiene los objetos visuales de la barra de herramientas |
|
51 |
* generica |
|
52 |
* |
|
53 |
* @author BorSanZa - Borja S?nchez Zamorano |
|
54 |
*/ |
|
55 |
public class GenericToolBarPanel extends JToolBar implements ComboButtonListener, ActionListener, MouseListener, ItemListener, IControl { |
|
56 |
private static final long serialVersionUID = -4382962282970490523L; |
|
57 |
private JComboBoxConfigurableLookUp jCBCLU = null; |
|
58 |
private ComboButton buttonGroup = new ComboButton(); |
|
59 |
private ComboButton buttonMenu = new ComboButton(); |
|
60 |
private FLayers lastLayers = null; |
|
61 |
|
|
62 |
public GenericToolBarPanel() { |
|
63 |
super("GenericToolBarPanel"); |
|
64 |
initialize(); |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* Especifica que las capas de la vista han cambiado. |
|
69 |
* @param layers |
|
70 |
*/ |
|
71 |
public void setLayers(FLayers layers) { |
|
72 |
lastLayers = layers; |
|
73 |
|
|
74 |
getComboBoxConfigurableLookUp().setBlockPopupHided(true); |
|
75 |
getComboBoxConfigurableLookUp().removeAllItems(); |
|
76 |
|
|
77 |
if(layers != null) { |
|
78 |
List<FLayer> lyrs = getLayerList(layers, null); |
|
79 |
for (int i = 0; i < lyrs.size(); i++) |
|
80 |
getComboBoxConfigurableLookUp().addItem(((FLayer)lyrs.get(i)).getName()); |
|
81 |
|
|
82 |
if (layers.getActives().length > 0) |
|
83 |
getComboBoxConfigurableLookUp().setSelectedItem(layers.getActives()[0].getName()); |
|
84 |
else if (layers.getLayersCount() > 0) |
|
85 |
getComboBoxConfigurableLookUp().setSelectedItem(layers.getLayer(0).getName()); |
|
86 |
} |
|
87 |
reloadSubMenu(); |
|
88 |
getComboBoxConfigurableLookUp().setBlockPopupHided(false); |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* Devuelve un combo de busqueda de items. |
|
93 |
* @return |
|
94 |
*/ |
|
95 |
private JComboBoxConfigurableLookUp getComboBoxConfigurableLookUp() { |
|
96 |
if (jCBCLU == null) { |
|
97 |
jCBCLU = new JComboBoxConfigurableLookUp(); |
|
98 |
jCBCLU.setOnlyOneColorOnText(true); |
|
99 |
jCBCLU.setPrototypeDisplayValue(" "); |
|
100 |
if (jCBCLU.getModel() instanceof DefaultComboBoxConfigurableLookUpModel) { |
|
101 |
((DefaultComboBoxConfigurableLookUpModel) jCBCLU.getModel()).setShowAllItemsInListBox(false); |
|
102 |
((DefaultComboBoxConfigurableLookUpModel) jCBCLU.getModel()).setLookUpAgent(new BinarySearch()); |
|
103 |
((DefaultComboBoxConfigurableLookUpModel) jCBCLU.getModel()).setCaseSensitive(false); |
|
104 |
jCBCLU.setToForceSelectAnItem(true); |
|
105 |
jCBCLU.setDisplayAllItemsWithArrowButton(true); |
|
106 |
} |
|
107 |
jCBCLU.addActionListener(this); |
|
108 |
} |
|
109 |
return jCBCLU; |
|
110 |
} |
|
111 |
|
|
112 |
private void initialize() { |
|
113 |
buttonGroup.addComboButtonClickedListener(this); |
|
114 |
buttonGroup.setName("Menu principal"); |
|
115 |
buttonGroup.setMargin(new Insets(0, 0, 0, 0)); |
|
116 |
buttonGroup.setAlwaysMenuOnClick(true); |
|
117 |
reloadMenuGroup(); |
|
118 |
add(buttonGroup); |
|
119 |
|
|
120 |
buttonMenu.addComboButtonClickedListener(this); |
|
121 |
buttonMenu.setName("Submenus"); |
|
122 |
buttonMenu.addMouseListener(this); |
|
123 |
buttonMenu.setMargin(new Insets(0, 0, 0, 0)); |
|
124 |
reloadMenuGroup(); |
|
125 |
add(buttonMenu); |
|
126 |
|
|
127 |
add(getComboBoxConfigurableLookUp()); |
|
128 |
this.setRollover(true); |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* Recarga los items del menu global dejando seleccionado el item que habia |
|
133 |
* previamente, en caso de que exista |
|
134 |
*/ |
|
135 |
public void reloadMenuGroup() { |
|
136 |
FLayer[] layers = new FLayer[] { getLayerSelected() }; |
|
137 |
ButtonItems buttonItems = new ButtonItems(buttonGroup, layers); |
|
138 |
|
|
139 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
140 |
ExtensionPoint point = extensionPoints.get("GenericToolBarGroup"); |
|
141 |
Iterator<?> iterator = point.iterator(); |
|
142 |
while (iterator.hasNext()) { |
|
143 |
ExtensionPoint.Extension extension = (ExtensionPoint.Extension) iterator.next(); |
|
144 |
Object object; |
|
145 |
try { |
|
146 |
object = extension.create(); |
|
147 |
} catch (Exception e) { |
|
148 |
throw new RuntimeException(e); |
|
149 |
} |
|
150 |
if (object instanceof IGenericToolBarMenuItem) |
|
151 |
buttonItems.addButton((IGenericToolBarMenuItem) object, extension.getName()); |
|
152 |
} |
|
153 |
buttonItems.refresh(); |
|
154 |
reloadSubMenu(); |
|
155 |
} |
|
156 |
|
|
157 |
/** |
|
158 |
* Recarga los items del submenu dejando seleccionado el item que habia |
|
159 |
* previamente, en caso de que exista |
|
160 |
*/ |
|
161 |
public void reloadSubMenu() { |
|
162 |
FLayer[] layers = new FLayer[] { getLayerSelected() }; |
|
163 |
ButtonItems buttonItems = new ButtonItems(buttonMenu, layers); |
|
164 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
165 |
ExtensionPoint point = extensionPoints.add("GenericToolBarMenu"); |
|
166 |
Iterator<?> iterator = point.iterator(); |
|
167 |
while (iterator.hasNext()) { |
|
168 |
ExtensionPoint.Extension entry = (ExtensionPoint.Extension) iterator.next(); |
|
169 |
Object object; |
|
170 |
try { |
|
171 |
object = entry.create(); |
|
172 |
} catch (Exception e) { |
|
173 |
throw new RuntimeException(e); |
|
174 |
} |
|
175 |
if (object instanceof IGenericToolBarMenuItem) { |
|
176 |
IGenericToolBarMenuItem item = (IGenericToolBarMenuItem) object; |
|
177 |
if (!buttonGroup.getActionCommand().equals(item.getGroup())) |
|
178 |
continue; |
|
179 |
buttonItems.addButton(item, entry.getName()); |
|
180 |
} |
|
181 |
} |
|
182 |
buttonItems.refresh(); |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* Devuelve el layer seleccionado en el combobox |
|
187 |
* @return |
|
188 |
*/ |
|
189 |
public FLayer getLayerSelected() { |
|
190 |
if (lastLayers == null) |
|
191 |
return null; |
|
192 |
List<FLayer> lyrs = getLayerList(lastLayers, null); |
|
193 |
for (int i = 0; i < lyrs.size(); i++) |
|
194 |
if (((FLayer)lyrs.get(i)).getName().equals(getComboBoxConfigurableLookUp().getEditor().getItem())) |
|
195 |
return (FLayer)lyrs.get(i); |
|
196 |
return null; |
|
197 |
} |
|
198 |
|
|
199 |
public static List<FLayer> getLayerList(FLayers srcLyrs, List<FLayer> destLyrs) { |
|
200 |
if(srcLyrs == null) |
|
201 |
return null; |
|
202 |
if(destLyrs == null) |
|
203 |
destLyrs = new ArrayList<FLayer>(); |
|
204 |
for (int i = 0; i < srcLyrs.getLayersCount(); i++) { |
|
205 |
if(srcLyrs.getLayer(i) instanceof FLayers) |
|
206 |
destLyrs = getLayerList((FLayers)srcLyrs.getLayer(i), destLyrs); |
|
207 |
else |
|
208 |
destLyrs.add(srcLyrs.getLayer(i)); |
|
209 |
} |
|
210 |
return destLyrs; |
|
211 |
} |
|
212 |
|
|
213 |
public void actionPerformed(ActionEvent e) { |
|
214 |
if (e.getSource() == getComboBoxConfigurableLookUp()) { |
|
215 |
// selectLayerInTOC(lastLayers, (String) getComboBoxConfigurableLookUp().getSelectedItem()); |
|
216 |
} |
|
217 |
} |
|
218 |
|
|
219 |
public void actionComboButtonClicked(ComboButtonEvent e) { |
|
220 |
if (e.getSource() == buttonGroup) { |
|
221 |
reloadSubMenu(); |
|
222 |
return; |
|
223 |
} |
|
224 |
if (e.getSource() == buttonMenu) { |
|
225 |
ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager(); |
|
226 |
ExtensionPoint point=extensionPoints.add("GenericToolBarMenu"); |
|
227 |
Iterator<?> iterator = point.iterator(); |
|
228 |
while (iterator.hasNext()) { |
|
229 |
ExtensionPoint.Extension entry = (ExtensionPoint.Extension) iterator |
|
230 |
.next(); |
|
231 |
if (!entry.getName().equals( |
|
232 |
((JButton) e.getSource()).getActionCommand())) |
|
233 |
continue; |
|
234 |
Object object; |
|
235 |
try { |
|
236 |
object = entry.create(); |
|
237 |
} catch (Exception e1) { |
|
238 |
// TODO Auto-generated catch block |
|
239 |
throw new RuntimeException(e1); |
|
240 |
} |
|
241 |
if (object instanceof IGenericToolBarMenuItem) { |
|
242 |
IGenericToolBarMenuItem item = (IGenericToolBarMenuItem) object; |
|
243 |
|
|
244 |
FLayer[] layers = new FLayer[] { getLayerSelected() }; |
|
245 |
if (!item.isVisible(null, layers)) |
|
246 |
continue; |
|
247 |
if (!item.isEnabled(null, layers)) |
|
248 |
continue; |
|
249 |
|
|
250 |
if (getLayerSelected() != null) { |
|
251 |
item.execute(null, new FLayer[] { getLayerSelected() }); |
|
252 |
} else |
|
253 |
item.execute(null, null); |
|
254 |
reloadSubMenu(); |
|
255 |
return; |
|
256 |
} |
|
257 |
} |
|
258 |
return; |
|
259 |
} |
|
260 |
} |
|
261 |
|
|
262 |
/** |
|
263 |
* Selecciona una capa en el TOC |
|
264 |
* @param layers |
|
265 |
* @param nameLayer |
|
266 |
*/ |
|
267 |
// private void selectLayerInTOC(FLayers layers, String nameLayer) { |
|
268 |
// if (layers == null) |
|
269 |
// return; |
|
270 |
// for (int i = 0; i < layers.getLayersCount(); i++) { |
|
271 |
// if (layers.getLayer(i) instanceof FLayers) { |
|
272 |
// selectLayerInTOC((FLayers) layers.getLayer(i), nameLayer); |
|
273 |
// } else { |
|
274 |
// if (layers.getLayer(i) instanceof FLayer) { |
|
275 |
// FLayer layer = ((FLayer) layers.getLayer(i)); |
|
276 |
// if (layer.getName().equals(nameLayer) && !layer.isActive()) { |
|
277 |
// layer.setActive(true); |
|
278 |
// } |
|
279 |
// } |
|
280 |
// } |
|
281 |
// } |
|
282 |
// } |
|
283 |
|
|
284 |
/** |
|
285 |
* Recargo el menu cada vez que entra el raton en el boton, para ahorrar tiempo en |
|
286 |
* la visualizacion del mismo |
|
287 |
*/ |
|
288 |
public void mouseEntered(MouseEvent e) { |
|
289 |
this.reloadSubMenu(); |
|
290 |
} |
|
291 |
|
|
292 |
public void itemStateChanged(ItemEvent e) { |
|
293 |
// if (e.getStateChange() != ItemEvent.SELECTED) |
|
294 |
// return; |
|
295 |
// |
|
296 |
// FLayer layer = getLayerSelected(); |
|
297 |
// |
|
298 |
// if (layer == null) |
|
299 |
// return; |
|
300 |
// |
|
301 |
// FLayers layers = lastLayers; |
|
302 |
// for(int i = 0; i < layers.getLayersCount(); i++) |
|
303 |
// layers.getLayer(i).setActive(false); |
|
304 |
// |
|
305 |
// layer.setActive(true); |
|
306 |
// View view = (View) PluginServices.getMDIManager().getActiveWindow(); |
|
307 |
// JScrollBar verticalBar = view.getTOC().getJScrollPane().getVerticalScrollBar(); |
|
308 |
// double widthPerEntry = verticalBar.getMaximum() / layer.getMapContext().getLayers().getLayersCount(); |
|
309 |
// verticalBar.setValue((int)widthPerEntry * (layer.getMapContext().getLayers().getLayersCount() - pos - 1)); |
|
310 |
} |
|
311 |
|
|
312 |
public void mouseClicked(MouseEvent e) {} |
|
313 |
public void mouseExited(MouseEvent e) {} |
|
314 |
public void mousePressed(MouseEvent e) {} |
|
315 |
public void mouseReleased(MouseEvent e) {} |
|
316 |
|
|
317 |
public void addActionListener(ActionListener listener) { |
|
318 |
|
|
319 |
} |
|
320 |
|
|
321 |
public Object getValue() { |
|
322 |
return null; |
|
323 |
} |
|
324 |
|
|
325 |
public void removeActionListener(ActionListener listener) { |
|
326 |
|
|
327 |
} |
|
328 |
|
|
329 |
public Object setValue(Object value) { |
|
330 |
return null; |
|
331 |
} |
|
332 |
|
|
333 |
} |
org.gvsig.raster/tags/org.gvsig.raster-2.2.27/org.gvsig.raster.app/org.gvsig.raster.app.common/src/main/java/org/gvsig/raster/mainplugin/toolbar/GenericToolBarMenuItem.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.raster.mainplugin.toolbar; |
|
23 |
|
|
24 |
import java.util.Map; |
|
25 |
|
|
26 |
import javax.swing.Icon; |
|
27 |
|
|
28 |
import org.gvsig.andami.IconThemeHelper; |
|
29 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
|
30 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
31 |
import org.gvsig.tools.extensionpoint.ExtensionBuilder; |
|
32 |
|
|
33 |
/** |
|
34 |
* Clase que implementa un IGenericToolBarMenuItem para evitar tener que crear |
|
35 |
* clases para items de menu sencillas |
|
36 |
* |
|
37 |
* @version 06/02/2008 |
|
38 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
39 |
*/ |
|
40 |
public class GenericToolBarMenuItem implements IGenericToolBarMenuItem, ExtensionBuilder { |
|
41 |
private String text = ""; |
|
42 |
private int order = 0; |
|
43 |
private int groupOrder = 0; |
|
44 |
private Icon icon = null; |
|
45 |
private String group = ""; |
|
46 |
|
|
47 |
public GenericToolBarMenuItem(String text, Icon icon) { |
|
48 |
this(text, icon, "", 0); |
|
49 |
} |
|
50 |
|
|
51 |
public GenericToolBarMenuItem(String text) { |
|
52 |
this(text, IconThemeHelper.getImageIcon("blank-icon"), "", 0); |
|
53 |
} |
|
54 |
|
|
55 |
public GenericToolBarMenuItem(String text, Icon icon, String group, int order) { |
|
56 |
this.text = text; |
|
57 |
this.order = order; |
|
58 |
this.icon = icon; |
|
59 |
this.group = group; |
|
60 |
} |
|
61 |
|
|
62 |
public GenericToolBarMenuItem(String text, Icon icon, String group) { |
|
63 |
this(text, icon, group, 0); |
|
64 |
} |
|
65 |
|
|
66 |
public GenericToolBarMenuItem(String text, Icon icon, int order) { |
|
67 |
this(text, icon, "", 0); |
|
68 |
} |
|
69 |
|
|
70 |
public String getGroup() { |
|
71 |
return group; |
|
72 |
} |
|
73 |
|
|
74 |
public int getOrder() { |
|
75 |
return order; |
|
76 |
} |
|
77 |
|
|
78 |
public String getText() { |
|
79 |
return text; |
|
80 |
} |
|
81 |
|
|
82 |
public Icon getIcon() { |
|
83 |
return icon; |
|
84 |
} |
|
85 |
|
|
86 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
|
87 |
return true; |
|
88 |
} |
|
89 |
|
|
90 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
|
91 |
return true; |
|
92 |
} |
|
93 |
|
|
94 |
public int getGroupOrder() { |
|
95 |
return groupOrder; |
|
96 |
} |
|
97 |
|
|
98 |
public void execute(ITocItem item, FLayer[] selectedItems) {} |
|
99 |
|
|
100 |
public Object create() { |
|
101 |
return this; |
|
102 |
} |
|
103 |
|
|
104 |
public Object create(Object[] args) { |
|
105 |
return this; |
|
106 |
} |
|
107 |
|
|
108 |
@SuppressWarnings("rawtypes") |
|
109 |
public Object create(Map args) { |
|
110 |
return this; |
|
111 |
} |
|
112 |
|
|
113 |
public boolean isEnableEvents() { |
|
114 |
return true; |
|
115 |
} |
|
116 |
} |
org.gvsig.raster/tags/org.gvsig.raster-2.2.27/org.gvsig.raster.app/org.gvsig.raster.app.common/src/main/java/org/gvsig/raster/mainplugin/toolbar/BinarySearch.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.raster.mainplugin.toolbar; |
|
23 |
|
|
24 |
import java.util.Arrays; |
|
25 |
import java.util.List; |
|
26 |
import java.util.Vector; |
|
27 |
import org.apache.commons.lang3.StringUtils; |
|
28 |
|
|
29 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.ILookUp; |
|
30 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.JComboBoxConfigurableLookUp; |
|
31 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.StringComparator; |
|
32 |
/** |
|
33 |
* Clase para reimplementar una nueva busqueda para el componente |
|
34 |
* {@link JComboBoxConfigurableLookUp} |
|
35 |
* |
|
36 |
* @version 13/02/2008 |
|
37 |
* @author BorSanZa - Borja S?nchez Zamorano |
|
38 |
*/ |
|
39 |
public class BinarySearch implements ILookUp { |
|
40 |
public List<Object> doLookUpConsideringCaseSensitive(String text, Vector<Object> sortOrderedItems, StringComparator comp) { |
|
41 |
Vector<Object> list = new Vector<Object>(); |
|
42 |
for (int i = 0; i < sortOrderedItems.size(); i++) { |
|
43 |
Object cur_o = sortOrderedItems.get(i); |
|
44 |
if( cur_o!=null ) { |
|
45 |
String cur_s = cur_o.toString(); |
|
46 |
if( StringUtils.isEmpty(text) ) { |
|
47 |
list.add(cur_o); |
|
48 |
} else { |
|
49 |
if (cur_s.indexOf(text) != -1) { |
|
50 |
list.add(cur_o); |
|
51 |
} |
|
52 |
} |
|
53 |
} |
|
54 |
} |
|
55 |
return Arrays.asList(list.toArray()); |
|
56 |
} |
|
57 |
|
|
58 |
public List<Object> doLookUpIgnoringCaseSensitive(String text, Vector<Object> sortOrderedItems, StringComparator comp) { |
|
59 |
Vector<Object> list = new Vector<Object>(); |
|
60 |
for (int i = 0; i < sortOrderedItems.size(); i++) { |
|
61 |
Object cur_o = sortOrderedItems.get(i); |
|
62 |
if( cur_o!=null ) { |
|
63 |
String cur_s = cur_o.toString(); |
|
64 |
if( StringUtils.isEmpty(text) ) { |
|
65 |
list.add(cur_o); |
|
66 |
} else { |
|
67 |
if (cur_s.toLowerCase().indexOf(text.toLowerCase()) != -1) { |
|
68 |
list.add(cur_o); |
|
69 |
} |
|
70 |
} |
|
71 |
} |
|
72 |
} |
|
73 |
return Arrays.asList(list.toArray()); |
|
74 |
} |
|
75 |
} |
org.gvsig.raster/tags/org.gvsig.raster-2.2.27/org.gvsig.raster.app/org.gvsig.raster.app.common/src/main/java/org/gvsig/raster/mainplugin/toolbar/IGenericToolBarMenuItem.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.raster.mainplugin.toolbar; |
|
23 |
|
|
24 |
import javax.swing.Icon; |
|
25 |
|
|
26 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
|
27 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
28 |
|
|
29 |
/** |
|
30 |
* Interfaz que debe implementar quien quiera aparecer en la barra de |
|
31 |
* herramientas gen?rica. |
|
32 |
* |
|
33 |
* @version 06/02/2008 |
|
34 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
35 |
*/ |
|
36 |
public interface IGenericToolBarMenuItem { |
|
37 |
/** |
|
38 |
* Devuelve el nombre del grupo al que pertenece el item de menu |
|
39 |
* @return |
|
40 |
*/ |
|
41 |
public String getGroup(); |
|
42 |
|
|
43 |
/** |
|
44 |
* Devuelve el orden en el que aparecer? en el men? |
|
45 |
* @return |
|
46 |
*/ |
|
47 |
public int getOrder(); |
|
48 |
|
|
49 |
/** |
|
50 |
* Devuelve el orden en el que aparecer? en el men? |
|
51 |
* @return |
|
52 |
*/ |
|
53 |
public int getGroupOrder(); |
|
54 |
|
|
55 |
/** |
|
56 |
* Devuelve el texto que se ver? en el men? |
|
57 |
* @return |
|
58 |
*/ |
|
59 |
public String getText(); |
|
60 |
|
|
61 |
/** |
|
62 |
* Devuelve el icono del item del menu |
|
63 |
* @return |
|
64 |
*/ |
|
65 |
public Icon getIcon(); |
|
66 |
|
|
67 |
/** |
|
68 |
* Dice si es visible el item de menu para dicha entrada |
|
69 |
* @param item |
|
70 |
* @param selectedItems |
|
71 |
* @return |
|
72 |
*/ |
|
73 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems); |
|
74 |
|
|
75 |
/** |
|
76 |
* Dice si el item actual esta habilitado |
|
77 |
* @param item |
|
78 |
* @param selectedItems |
|
79 |
* @return |
|
80 |
*/ |
|
81 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems); |
|
82 |
|
|
83 |
/** |
|
84 |
* Metodo que sera invocado cuando el item del menu sea presionado |
|
85 |
* @param item |
|
86 |
* @param selectedItems |
|
87 |
*/ |
|
88 |
public void execute(ITocItem item, FLayer[] selectedItems); |
|
89 |
} |
org.gvsig.raster/tags/org.gvsig.raster-2.2.27/org.gvsig.raster.app/org.gvsig.raster.app.common/src/main/java/org/gvsig/raster/mainplugin/RasterMainPluginUtils.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.raster.mainplugin; |
|
23 |
|
|
24 |
import java.awt.Component; |
|
25 |
import java.awt.Dimension; |
|
26 |
import java.awt.Point; |
|
27 |
import java.io.File; |
|
28 |
import java.util.ArrayList; |
|
29 |
|
|
30 |
import javax.swing.JOptionPane; |
|
31 |
|
|
32 |
import org.gvsig.andami.PluginServices; |
|
33 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
34 |
import org.gvsig.app.project.Project; |
|
35 |
import org.gvsig.app.project.ProjectManager; |
|
36 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
37 |
import org.gvsig.fmap.dal.DALLocator; |
|
38 |
import org.gvsig.fmap.dal.DataManager; |
|
39 |
import org.gvsig.fmap.dal.DataStore; |
|
40 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
41 |
import org.gvsig.fmap.dal.coverage.datastruct.Param; |
|
42 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
|
43 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
44 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices; |
|
45 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
46 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
47 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
48 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
49 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
50 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
51 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
52 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
53 |
import org.gvsig.gui.beans.propertiespanel.PropertiesComponent; |
|
54 |
import org.gvsig.gui.beans.propertiespanel.PropertyStruct; |
|
55 |
import org.gvsig.i18n.Messages; |
|
56 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
57 |
import org.gvsig.raster.util.RasterNotLoadException; |
|
58 |
|
|
59 |
/** |
|
60 |
* Herramientas de uso general y que son dependientes de gvSIG, FMap o de |
|
61 |
* libUIComponents. En caso de no serlo existe una clase independiente de |
|
62 |
* cualquier proyecto dentro de libRaster para este tipo de funciones. |
|
63 |
* |
|
64 |
* @version 31/05/2007 |
|
65 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
66 |
*/ |
|
67 |
public class RasterMainPluginUtils { |
|
68 |
|
|
69 |
/** |
|
70 |
* Obtiene la lista de capas del TOC y devuelve las raster. Si hay capas agrupadas lo tiene en cuenta y mira |
|
71 |
* dentro de la agrupaci?n. |
|
72 |
* @param srcLyrs FLayers de la vista |
|
73 |
* @param destLyrs Lista de capas |
|
74 |
* @return ArrayList con la lista de capas raster agrupadas o no. El orden en que aparecen |
|
75 |
* en la lista es de abajo a arriba las que aparecen en el TOC. |
|
76 |
*/ |
|
77 |
public static ArrayList<FLayer> getRasterLayerList(FLayers srcLyrs, ArrayList<FLayer> destLyrs) { |
|
78 |
if(destLyrs == null) |
|
79 |
destLyrs = new ArrayList<FLayer>(); |
|
80 |
for (int i = 0; i < srcLyrs.getLayersCount(); i++) { |
|
81 |
if(srcLyrs.getLayer(i) instanceof DefaultFLyrRaster) |
|
82 |
destLyrs.add(srcLyrs.getLayer(i)); |
|
83 |
if(srcLyrs.getLayer(i) instanceof FLayers) |
|
84 |
destLyrs = getLayerList((FLayers)srcLyrs.getLayer(i), destLyrs); |
|
85 |
} |
|
86 |
return destLyrs; |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Obtiene la lista de capas del TOC y devuelve las raster. Si hay capas agrupadas lo tiene en cuenta y mira |
|
91 |
* dentro de la agrupaci?n. |
|
92 |
* @param srcLyrs FLayers de la vista |
|
93 |
* @param destLyrs Lista de capas |
|
94 |
* @return ArrayList con la lista de capas raster agrupadas o no. El orden en que aparecen |
|
95 |
* en la lista es de abajo a arriba las que aparecen en el TOC. |
|
96 |
*/ |
|
97 |
public static ArrayList<FLayer> getLayerList(FLayers srcLyrs, ArrayList<FLayer> destLyrs) { |
|
98 |
if(srcLyrs == null) |
|
99 |
return null; |
|
100 |
if(destLyrs == null) |
|
101 |
destLyrs = new ArrayList<FLayer>(); |
|
102 |
for (int i = 0; i < srcLyrs.getLayersCount(); i++) { |
|
103 |
if(srcLyrs.getLayer(i) instanceof FLayers) |
|
104 |
destLyrs = getLayerList((FLayers)srcLyrs.getLayer(i), destLyrs); |
|
105 |
else |
|
106 |
destLyrs.add(srcLyrs.getLayer(i)); |
|
107 |
} |
|
108 |
return destLyrs; |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* Obtiene el nombre de la vista donde est? cargada la capa que se pasa por par?metro |
|
113 |
* @param layer Capa cargada en una vista |
|
114 |
* @return Nombre de la vista donde est? cargada la capa. |
|
115 |
*/ |
|
116 |
public static String getView(FLayer layer) { |
|
117 |
// Project p = ((ProjectExtension) PluginServices.getExtension(ProjectExtension.class)).getProject(); |
|
118 |
Project p = ProjectManager.getInstance().getCurrentProject(); |
|
119 |
return p.getViewName(layer); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* A?ade una ventana al gestor de ventanas |
|
124 |
* @param window |
|
125 |
*/ |
|
126 |
public static void addWindow(IWindow window) { |
|
127 |
PluginServices.getMDIManager().addWindow(window); |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* Elimina una ventana al gestor de ventanas |
|
132 |
* @param window |
|
133 |
*/ |
|
134 |
public static void closeWindow(IWindow window) { |
|
135 |
PluginServices.getMDIManager().closeWindow(window); |
|
136 |
} |
|
137 |
|
|
138 |
/** |
|
139 |
* Selecciona los controles del panel de propiedades a partir de los par?mtros |
|
140 |
* obtenidos del driver. Este m?todo realiza una transformaci?n entre Params |
|
141 |
* obtenido del driver de escritura y los par?metros del panel de propiedades. |
|
142 |
* @param panel Panel de propiedades |
|
143 |
* @param params Par?metros del driver |
|
144 |
* @param notTakeIntoAccount Nombre de par?metros que no hay que tener en cuenta. Si es null se tienen en cuenta todos. |
|
145 |
*/ |
|
146 |
public static void loadPropertiesFromWriterParams(PropertiesComponent pComp, Params params, String[] notTakeIntoAccount) { |
|
147 |
for (int i = 0; i < params.getNumParams(); i++) { |
|
148 |
Param p = params.getParam(i); |
|
149 |
String name = Messages.getText(p.getId()); |
|
150 |
String key = p.getId(); |
|
151 |
|
|
152 |
//Miramos si el par?metro coincide con alguno en la lista de parametros que no hay que |
|
153 |
//tener en cuenta. Si es as? no lo a?adimos |
|
154 |
if(notTakeIntoAccount != null && notTakeIntoAccount.length > 0) { |
|
155 |
boolean jump = false; |
|
156 |
for (int j = 0; j < notTakeIntoAccount.length; j++) { |
|
157 |
if (key.equals(notTakeIntoAccount[j])) |
|
158 |
jump = true; |
|
159 |
} |
|
160 |
if(jump) |
|
161 |
continue; |
|
162 |
} |
|
163 |
|
|
164 |
Object[] types = null; |
|
165 |
int selectedValue = 0; |
|
166 |
|
|
167 |
switch (p.getType()) { |
|
168 |
case Params.CHECK: |
|
169 |
pComp.addValue(name, key, p.getDefaultValue(), types); |
|
170 |
break; |
|
171 |
case Params.CHOICE: |
|
172 |
ArrayList<String> list = new ArrayList<String>(); |
|
173 |
for (int j = 0; j < p.getList().length; j++) { |
|
174 |
list.add(p.getList()[j]); |
|
175 |
if (p.getDefaultValue() instanceof Integer) |
|
176 |
if (((Integer) p.getDefaultValue()).intValue() == j) |
|
177 |
selectedValue = j; |
|
178 |
} |
|
179 |
types = new Object[] { new Integer(PropertiesComponent.TYPE_COMBO), list }; |
|
180 |
pComp.addValue(name, key, new Integer(selectedValue), types); |
|
181 |
break; |
|
182 |
case Params.SLIDER: |
|
183 |
types = new Object[] { new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(p.getList()[0]), new Integer(p.getList()[1]) }; |
|
184 |
pComp.addValue(name, key, p.getDefaultValue(), types); |
|
185 |
break; |
|
186 |
default: |
|
187 |
pComp.addValue(Messages.getText(((Param)params.getParam(i)).getId()), params.getParam(i).getId(), params.getParam(i).getDefaultValue(), null); |
|
188 |
break; |
|
189 |
} |
|
190 |
} |
|
191 |
} |
|
192 |
|
|
193 |
/** |
|
194 |
* Carga los par?metros del escritor WriterParams con los valores obtenidos |
|
195 |
* de la ventana de propiedades. |
|
196 |
*/ |
|
197 |
@SuppressWarnings("unchecked") |
|
198 |
public static void loadWriterParamsFromPropertiesPanel(PropertiesComponent pComp, Params params) { |
|
199 |
ArrayList<PropertyStruct> values = pComp.getValues(); |
|
200 |
for (int iParam = 0; iParam < params.getNumParams(); iParam++) { |
|
201 |
Param p = params.getParam(iParam); |
|
202 |
for (int iValue = 0; iValue < values.size(); iValue++) { |
|
203 |
PropertyStruct prop = values.get(iValue); |
|
204 |
if (p.getId().compareTo(prop.getKey()) == 0) { |
|
205 |
switch (p.getType()) { |
|
206 |
case Params.CHECK: |
|
207 |
p.setDefaultValue((Boolean) prop.getNewValue()); |
|
208 |
break; |
|
209 |
case Params.CHOICE: |
|
210 |
p.setDefaultValue(((Integer) prop.getNewValue()));//p.list[((Integer) prop.getNewValue()).intValue()]; |
|
211 |
break; |
|
212 |
case Params.SLIDER: |
|
213 |
try { |
|
214 |
p.setDefaultValue((Integer)prop.getNewValue()); |
|
215 |
} catch (NumberFormatException e) {} |
|
216 |
} |
|
217 |
break; |
|
218 |
} |
|
219 |
} |
|
220 |
} |
|
221 |
} |
|
222 |
|
|
223 |
/** |
|
224 |
* Funci?n que devuelve true si se tiene permiso de escritura en la ruta |
|
225 |
* indicada en el par?metro path y false si no los tiene. |
|
226 |
* @param path Ruta a comprobar los permisosv |
|
227 |
* @param pluginObject si es distinto de null se obtiene un mensaje de |
|
228 |
* advertencia y sirve como par?metro para getText de la traducci?n. |
|
229 |
* Si es null no se mostrar? ventana de advertencia |
|
230 |
* @return true si se tiene permiso de escritura en la ruta indicada en el |
|
231 |
* par?metro path y false si no los tiene. |
|
232 |
*/ |
|
233 |
public static boolean canWrite(String path, Object pluginObject) { |
|
234 |
File f = new File(path); |
|
235 |
if(f.exists() && f.canWrite()) |
|
236 |
return true; |
|
237 |
else { |
|
238 |
if(pluginObject != null) |
|
239 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
|
240 |
PluginServices.getText(pluginObject, "error_escritura")); |
|
241 |
return false; |
|
242 |
} |
|
243 |
} |
|
244 |
|
|
245 |
/** |
|
246 |
* Carga una capa raster en una vista de gvSIG. |
|
247 |
* @param viewName Nombre de la vista donde ha de cargarse. Si vale null se cargar? en la |
|
248 |
* primera vista que encuentre que est? activa. Si no hay ninguna saltar? una excepci?n. |
|
249 |
* @param fileName Nombre del fichero a cargar. No debe ser nulo nunca. |
|
250 |
* @param layerName Nombre de la capa. Si es null se asignar? el nombre del |
|
251 |
* fichero sin extensi?n. |
|
252 |
* @throws RasterNotLoadException Excepci?n que se lanza cuando no se ha podido cargar la capa |
|
253 |
* por alg?n motivo. |
|
254 |
*/ |
|
255 |
@SuppressWarnings("deprecation") |
|
256 |
public static FLayer loadLayer(String viewName, String fileName, String layerName) throws RasterNotLoadException { |
|
257 |
if(fileName == null) |
|
258 |
return null; |
|
259 |
|
|
260 |
//Seleccionamos la vista de gvSIG |
|
261 |
AbstractViewPanel theView = null; |
|
262 |
try { |
|
263 |
IWindow[] allViews = PluginServices.getMDIManager().getAllWindows(); |
|
264 |
if(viewName != null) { |
|
265 |
for (int i = 0; i < allViews.length; i++) { |
|
266 |
if (allViews[i] instanceof AbstractViewPanel |
|
267 |
&& (((AbstractViewPanel) allViews[i]).getDocument().getName().equals(viewName) || |
|
268 |
PluginServices.getMDIManager().getWindowInfo((AbstractViewPanel) allViews[i]).getTitle().equals(viewName))) |
|
269 |
theView = (AbstractViewPanel) allViews[i]; |
|
270 |
} |
|
271 |
} else { |
|
272 |
IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
|
273 |
for (int i = 0; i < allViews.length; i++) { |
|
274 |
if (allViews[i] instanceof AbstractViewPanel && ((AbstractViewPanel)allViews[i]) == activeWindow) //En la primera vista activa |
|
275 |
theView = (AbstractViewPanel) allViews[i]; |
|
276 |
} |
|
277 |
if(theView == null) { |
|
278 |
for (int i = 0; i < allViews.length; i++) { |
|
279 |
if (allViews[i] instanceof AbstractViewPanel) //En la primera vista |
|
280 |
theView = (AbstractViewPanel) allViews[i]; |
|
281 |
} |
|
282 |
} |
|
283 |
} |
|
284 |
|
|
285 |
if (theView == null) |
|
286 |
throw new RasterNotLoadException("Imposible cargar la capa."); |
|
287 |
} catch (ClassCastException ex) { |
|
288 |
throw new RasterNotLoadException("No se puede hacer un casting de esa IWindow a View."); |
|
289 |
} |
|
290 |
|
|
291 |
theView.getMapControl().getMapContext().beginAtomicEvent(); |
|
292 |
|
|
293 |
DefaultFLyrRaster lyr = null; |
|
294 |
try { |
|
295 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices(); |
|
296 |
RasterDataParameters storeParameters = provServ.createNotTiledParameters(fileName); |
|
297 |
storeParameters.setSRS(theView.getProjection()); |
|
298 |
|
|
299 |
MapContextManager mcm = MapContextLocator.getMapContextManager(); |
|
300 |
DataManager dataManager = DALLocator.getDataManager(); |
|
301 |
DataStore dataStore = null; |
|
302 |
try { |
|
303 |
dataStore = dataManager.createStore(storeParameters); |
|
304 |
} catch (ValidateDataParametersException e) { |
|
305 |
throw new RasterNotLoadException("Error al cargar la capa."); |
|
306 |
} catch (InitializeException e) { |
|
307 |
throw new RasterNotLoadException("Error al cargar la capa."); |
|
308 |
} catch (ProviderNotRegisteredException e) { |
|
309 |
throw new RasterNotLoadException("Error al cargar la capa."); |
|
310 |
} |
|
311 |
|
|
312 |
lyr = new DefaultFLyrRaster(); |
|
313 |
|
|
314 |
if(layerName == null) { |
|
315 |
int endIndex = fileName.lastIndexOf("."); |
|
316 |
if (endIndex < 0) |
|
317 |
endIndex = fileName.length(); |
|
318 |
|
|
319 |
layerName = fileName.substring(fileName.lastIndexOf(File.separator) + 1, endIndex); |
|
320 |
} |
|
321 |
|
|
322 |
lyr = (DefaultFLyrRaster) mcm.createLayer(layerName, dataStore); |
|
323 |
|
|
324 |
} catch (LoadLayerException e) { |
|
325 |
throw new RasterNotLoadException("Error al cargar la capa."); |
|
326 |
} catch (InitializeException e) { |
|
327 |
throw new RasterNotLoadException("Error creating parameters."); |
|
328 |
} catch (ProviderNotRegisteredException e) { |
|
329 |
throw new RasterNotLoadException("Error creating parameters."); |
|
330 |
} |
|
331 |
theView.getMapControl().getMapContext().getLayers().addLayer(lyr); |
|
332 |
theView.getMapControl().getMapContext().invalidate(); |
|
333 |
theView.getMapControl().getMapContext().endAtomicEvent(); |
|
334 |
return lyr; |
|
335 |
} |
|
336 |
|
|
337 |
/** |
|
338 |
* Carga una capa raster en una vista de gvSIG. |
|
339 |
* @param viewName Nombre de la vista donde ha de cargarse. Si vale null se cargar? en la |
|
340 |
* primera vista que encuentre que est? activa. Si no hay ninguna saltar? una excepci?n. |
|
341 |
* @param fileName Nombre del fichero a cargar. No debe ser nulo nunca. |
|
342 |
* @param layerName Nombre de la capa. Si es null se asignar? el nombre del |
|
343 |
* fichero sin extensi?n. |
|
344 |
* @throws RasterNotLoadException Excepci?n que se lanza cuando no se ha podido cargar la capa |
|
345 |
* por alg?n motivo. |
|
346 |
*/ |
|
347 |
public static FLayer loadLayer(String viewName, FLayer lyr) throws RasterNotLoadException { |
|
348 |
if(lyr == null) |
|
349 |
return null; |
|
350 |
|
|
351 |
//Seleccionamos la vista de gvSIG |
|
352 |
AbstractViewPanel theView = null; |
|
353 |
try { |
|
354 |
IWindow[] allViews = PluginServices.getMDIManager().getAllWindows(); |
|
355 |
if(viewName != null) { |
|
356 |
for (int i = 0; i < allViews.length; i++) { |
|
357 |
if (allViews[i] instanceof AbstractViewPanel |
|
358 |
&& PluginServices.getMDIManager().getWindowInfo((AbstractViewPanel) allViews[i]).getTitle().equals(viewName)) |
|
359 |
theView = (AbstractViewPanel) allViews[i]; |
|
360 |
} |
|
361 |
} else { |
|
362 |
IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
|
363 |
for (int i = 0; i < allViews.length; i++) { |
|
364 |
if (allViews[i] instanceof AbstractViewPanel && ((AbstractViewPanel)allViews[i]) == activeWindow) //En la primera vista activa |
|
365 |
theView = (AbstractViewPanel) allViews[i]; |
|
366 |
} |
|
367 |
if(theView == null) { |
|
368 |
for (int i = 0; i < allViews.length; i++) { |
|
369 |
if (allViews[i] instanceof AbstractViewPanel) //En la primera vista |
|
370 |
theView = (AbstractViewPanel) allViews[i]; |
|
371 |
} |
|
372 |
} |
|
373 |
} |
|
374 |
|
|
375 |
if (theView == null) |
|
376 |
throw new RasterNotLoadException("Imposible cargar la capa."); |
|
377 |
} catch (ClassCastException ex) { |
|
378 |
throw new RasterNotLoadException("No se puede hacer un casting de esa IWindow a View."); |
|
379 |
} |
|
380 |
|
|
381 |
theView.getMapControl().getMapContext().beginAtomicEvent(); |
|
382 |
theView.getMapControl().getMapContext().getLayers().addLayer(lyr); |
|
383 |
theView.getMapControl().getMapContext().invalidate(); |
|
384 |
theView.getMapControl().getMapContext().endAtomicEvent(); |
|
385 |
return lyr; |
|
386 |
} |
|
387 |
|
|
388 |
/** |
|
389 |
* Calculo de las coordenadas de una ventana IWindow para que quede centrada sobre el |
|
390 |
* MainFrame. Estas coordenadas solo valen para un IWindow ya que andami mete las ventanas |
|
391 |
* con coordenadas relativas a su ventanta principal. |
|
392 |
* @param widthWindow Ancho de la ventana a a?adir |
|
393 |
* @param heightWindow Alto de la ventana a a?adir |
|
394 |
* @return Array con el ancho y el alto |
|
395 |
*/ |
|
396 |
public static Point iwindowPosition(int widthWindow, int heightWindow) { |
|
397 |
int posWindowX = 0; |
|
398 |
int posWindowY = 0; |
|
399 |
Dimension dim = null; |
|
400 |
Point pos = null; |
|
401 |
if(PluginServices.getMainFrame() instanceof Component) { |
|
402 |
dim = ((Component)PluginServices.getMainFrame()).getSize(); |
|
403 |
pos = ((Component)PluginServices.getMainFrame()).getLocation(); |
|
404 |
if(dim != null && pos != null) { |
|
405 |
posWindowX = ((dim.width >> 1) - (widthWindow >> 1)); |
|
406 |
posWindowY = ((dim.height >> 1) - (heightWindow >> 1) - 70); |
|
407 |
return new Point(posWindowX, posWindowY); |
|
408 |
} |
|
409 |
} |
|
410 |
return null; |
|
411 |
} |
|
412 |
} |
org.gvsig.raster/tags/org.gvsig.raster-2.2.27/org.gvsig.raster.app/org.gvsig.raster.app.common/src/main/java/org/gvsig/raster/mainplugin/config/Configuration.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.raster.mainplugin.config; |
|
23 |
|
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.HashMap; |
|
26 |
import java.util.Iterator; |
|
27 |
|
|
28 |
import org.gvsig.andami.PluginServices; |
|
29 |
import org.gvsig.raster.fmap.layers.IConfiguration; |
|
30 |
import org.gvsig.utils.XMLEntity; |
|
31 |
|
|
32 |
/** |
|
33 |
* La clase <code>Configuration</code> sirve para poder leer y escribir valores en el entorno |
|
34 |
* de raster a nivel de configuraci?n. Para leer o escribir hay que usar los |
|
35 |
* metodos getValue y setValue, estos metodos lanzan eventos en el caso de |
|
36 |
* cambiar el valor que habia establecido. Forma de uso:<p> |
|
37 |
* |
|
38 |
* En la lectura es recomendable pasar un valor por defecto en el get, para que |
|
39 |
* si no existe o si existe pero no corresponde el tipo de datos devolvera el |
|
40 |
* valor por defecto<p> |
|
41 |
* |
|
42 |
* <code>Boolean valor = Configuration.getValue("valorBooleano", Boolean.valueOf(true));</code><p> |
|
43 |
* |
|
44 |
* <code>Configuration.setValue("valorBooleano", Boolean.valueOf(false));</code><p> |
|
45 |
* |
|
46 |
* Solo se pueden usar los siguientes tipos de datos:<br> |
|
47 |
* - <b>Boolean</b>, <b>Double</b>, <b>Float</b>, <b>Integer</b>, <b>Long</b> |
|
48 |
* y <b>String</b>.<p> |
|
49 |
* |
|
50 |
* Otra funcionalidad que tiene, es que puedes agregar un manejador de eventos |
|
51 |
* para controlar los cambios de las variables y actuar en consecuencia si cambia |
|
52 |
* la que deseas. |
|
53 |
* |
|
54 |
* @version 07/12/2007 |
|
55 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
56 |
*/ |
|
57 |
public class Configuration implements IConfiguration { |
|
58 |
static private Configuration singleton = new Configuration(); |
|
59 |
private ArrayList<ConfigurationListener> |
|
60 |
actionCommandListeners = new ArrayList<ConfigurationListener>(); |
|
61 |
private XMLEntity xml = null; |
|
62 |
private HashMap<String, Object> |
|
63 |
hashMap = new HashMap<String, Object>(); |
|
64 |
|
|
65 |
/** |
|
66 |
* Constructor privado. Nos aseguramos de que nadie pueda crear una instancia |
|
67 |
* desde fuera, la configuraci?n es ?nica para todos. |
|
68 |
*/ |
|
69 |
private Configuration() { |
|
70 |
try { |
|
71 |
PluginServices ps = PluginServices.getPluginServices("org.gvsig.raster.mainplugin"); |
|
72 |
xml = ps.getPersistentXML(); |
|
73 |
} catch (NullPointerException e) { |
|
74 |
//No est? inicializado Configuration |
|
75 |
xml = new XMLEntity(); |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Devuelve un valor Boolean para el key especificado |
|
81 |
* @param key |
|
82 |
* @param defaultValue |
|
83 |
* @return |
|
84 |
*/ |
|
85 |
static public Boolean getValue(String key, Boolean defaultValue) { |
|
86 |
singleton.saveDefaultValue(key, defaultValue); |
|
87 |
try { |
|
88 |
return Boolean.valueOf(getXMLEntity().getStringProperty(key)); |
|
89 |
} catch (Exception e) { |
|
90 |
} |
|
91 |
try { |
|
92 |
getXMLEntity().putProperty(key, defaultValue.booleanValue()); |
|
93 |
} catch(NullPointerException e) { |
|
94 |
//No est? inicializada la configuraci?n. Devuelve el default |
|
95 |
} |
|
96 |
return defaultValue; |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* Devuelve un valor Double para el key especificado |
|
101 |
* @param key |
|
102 |
* @param defaultValue |
|
103 |
* @return |
|
104 |
*/ |
|
105 |
static public Double getValue(String key, Double defaultValue) { |
|
106 |
singleton.saveDefaultValue(key, defaultValue); |
|
107 |
try { |
|
108 |
return Double.valueOf(getXMLEntity().getStringProperty(key)); |
|
109 |
} catch (Exception e) { |
|
110 |
} |
|
111 |
getXMLEntity().putProperty(key, defaultValue.doubleValue()); |
|
112 |
return defaultValue; |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* Devuelve un valor Float para el key especificado |
|
117 |
* @param key |
|
118 |
* @param defaultValue |
|
119 |
* @return |
|
120 |
*/ |
|
121 |
static public Float getValue(String key, Float defaultValue) { |
|
122 |
singleton.saveDefaultValue(key, defaultValue); |
|
123 |
try { |
|
124 |
return Float.valueOf(getXMLEntity().getStringProperty(key)); |
|
125 |
} catch (Exception e) { |
|
126 |
} |
|
127 |
getXMLEntity().putProperty(key, defaultValue.floatValue()); |
|
128 |
return defaultValue; |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* Devuelve un valor Integer para el key especificado |
|
133 |
* @param key |
|
134 |
* @param defaultValue |
|
135 |
* @return |
|
136 |
*/ |
|
137 |
static public Integer getValue(String key, Integer defaultValue) { |
|
138 |
singleton.saveDefaultValue(key, defaultValue); |
|
139 |
try { |
|
140 |
return Integer.valueOf(getXMLEntity().getStringProperty(key)); |
|
141 |
} catch (Exception e) { |
|
142 |
} |
|
143 |
getXMLEntity().putProperty(key, defaultValue.intValue()); |
|
144 |
return defaultValue; |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* Devuelve un valor Long para el key especificado |
|
149 |
* @param key |
|
150 |
* @param defaultValue |
|
151 |
* @return |
|
152 |
*/ |
|
153 |
static public Long getValue(String key, Long defaultValue) { |
|
154 |
singleton.saveDefaultValue(key, defaultValue); |
|
155 |
try { |
|
156 |
return Long.valueOf(getXMLEntity().getStringProperty(key)); |
|
157 |
} catch (Exception e) { |
|
158 |
} |
|
159 |
getXMLEntity().putProperty(key, defaultValue.longValue()); |
|
160 |
return defaultValue; |
|
161 |
} |
|
162 |
|
|
163 |
/** |
|
164 |
* Devuelve un valor String para el key especificado |
Also available in: Unified diff