Revision 12154
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/dialog/PropertiesRasterRegistrableDialog.java | ||
---|---|---|
26 | 26 |
import com.iver.andami.PluginServices; |
27 | 27 |
import com.iver.andami.ui.mdiManager.IWindow; |
28 | 28 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
29 |
|
|
30 | 29 |
/** |
31 |
* |
|
32 | 30 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
33 |
* |
|
34 | 31 |
*/ |
35 | 32 |
public class PropertiesRasterRegistrableDialog extends JPanel implements IWindow{ |
36 |
final private static long serialVersionUID = 0; |
|
37 |
private int sizePanelX = 500; |
|
38 |
private int sizePanelY = 310; |
|
39 |
private String title = ""; |
|
40 |
private RegistrableTabPanel registrable = null; |
|
41 |
private ButtonsPanel buttons = null; |
|
42 |
private TreeMap params = new TreeMap(); |
|
43 |
|
|
44 |
public PropertiesRasterRegistrableDialog(){ |
|
45 |
title = PluginServices.getText(this, "propiedades_raster"); |
|
46 |
registrable = new RegistrableTabPanel(sizePanelX, sizePanelY); |
|
47 |
buttons = new ButtonsPanel(sizePanelX); |
|
33 |
private static final long serialVersionUID = -2920327107654323732L; |
|
34 |
private RegistrableTabPanel registrable = null; |
|
35 |
private ButtonsPanel buttons = null; |
|
36 |
private TreeMap params = new TreeMap(); |
|
37 |
|
|
38 |
public PropertiesRasterRegistrableDialog() { |
|
39 |
registrable = new RegistrableTabPanel(); |
|
40 |
buttons = new ButtonsPanel(); |
|
48 | 41 |
new PropertiesRasterListener(this); |
49 |
init(); |
|
42 |
initialize();
|
|
50 | 43 |
} |
51 |
|
|
52 |
private void init(){
|
|
44 |
|
|
45 |
private void initialize() {
|
|
53 | 46 |
this.setLayout(new BorderLayout()); |
54 |
add(registrable, BorderLayout.CENTER);
|
|
55 |
add(buttons, BorderLayout.SOUTH);
|
|
47 |
add(registrable, BorderLayout.CENTER);
|
|
48 |
add(buttons, BorderLayout.SOUTH);
|
|
56 | 49 |
} |
57 |
|
|
50 |
|
|
58 | 51 |
/** |
59 | 52 |
* Add params to register panels. Each extension knows the name and the class to its |
60 | 53 |
* parameters. This method provide a generic way to register this. |
61 | 54 |
* @param key Parameter name |
62 | 55 |
* @param value parameter's value |
63 | 56 |
*/ |
64 |
public void setParam(String key, Object value){ |
|
57 |
public void setParam(String key, Object value) {
|
|
65 | 58 |
params.put(key, value); |
66 | 59 |
} |
67 |
|
|
60 |
|
|
68 | 61 |
/** |
69 | 62 |
* Get a parameter registered by the user of this class. Each extension knows the |
70 | 63 |
* name and the class to its parameters. This method provide a generic way to recover this. |
71 | 64 |
* @param key Parameter name |
72 | 65 |
* @return parameter's value |
73 | 66 |
*/ |
74 |
public Object getParam(String key){ |
|
67 |
public Object getParam(String key) {
|
|
75 | 68 |
return params.get(key); |
76 | 69 |
} |
77 |
|
|
70 |
|
|
78 | 71 |
/* |
79 | 72 |
* (non-Javadoc) |
80 | 73 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo() |
81 | 74 |
*/ |
82 | 75 |
public WindowInfo getWindowInfo() { |
83 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG |
|
84 |
| WindowInfo.RESIZABLE); |
|
85 |
m_viewinfo.setTitle(title); |
|
86 |
m_viewinfo.setHeight(sizePanelY); |
|
87 |
m_viewinfo.setWidth(sizePanelX); |
|
76 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE); |
|
77 |
m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_raster")); |
|
78 |
m_viewinfo.setWidth(500); |
|
79 |
m_viewinfo.setHeight(310); |
|
88 | 80 |
return m_viewinfo; |
89 |
}
|
|
90 |
|
|
81 |
} |
|
82 |
|
|
91 | 83 |
/** |
92 | 84 |
* Get buttons panel |
93 | 85 |
* @return ButtonsPanel |
94 | 86 |
*/ |
95 |
public ButtonsPanel getButtonsPanel(){ |
|
87 |
public ButtonsPanel getButtonsPanel() {
|
|
96 | 88 |
return this.buttons; |
97 | 89 |
} |
98 |
|
|
90 |
|
|
99 | 91 |
/** |
100 | 92 |
* Get registrable panel |
101 | 93 |
* @return RegistrableTabPanel |
102 | 94 |
*/ |
103 |
public RegistrableTabPanel getRegistrablePanel(){ |
|
95 |
public RegistrableTabPanel getRegistrablePanel() {
|
|
104 | 96 |
return this.registrable; |
105 | 97 |
} |
106 |
|
|
98 |
|
|
107 | 99 |
/** |
108 | 100 |
* Acciones a ejecutar cuando se cancela |
109 | 101 |
*/ |
110 |
public void close(){ |
|
111 |
try{ |
|
102 |
public void close() {
|
|
103 |
try {
|
|
112 | 104 |
PluginServices.getMDIManager().closeWindow(PropertiesRasterRegistrableDialog.this); |
113 |
}catch(ArrayIndexOutOfBoundsException e){
|
|
114 |
//Si la ventana no se puede eliminar no hacemos nada |
|
105 |
} catch (ArrayIndexOutOfBoundsException e) {
|
|
106 |
// Si la ventana no se puede eliminar no hacemos nada
|
|
115 | 107 |
} |
116 | 108 |
} |
117 |
} |
|
118 |
|
|
109 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/dialog/PropertiesRasterListener.java | ||
---|---|---|
20 | 20 |
|
21 | 21 |
import java.awt.event.ActionEvent; |
22 | 22 |
import java.awt.event.ActionListener; |
23 |
|
|
24 |
|
|
25 | 23 |
/** |
26 | 24 |
* Clase que maneja los eventos del dialogo de Propiedades. |
27 | 25 |
* |
28 | 26 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
29 | 27 |
*/ |
30 |
public class PropertiesRasterListener implements ActionListener{ |
|
28 |
public class PropertiesRasterListener implements ActionListener {
|
|
31 | 29 |
|
32 | 30 |
private PropertiesRasterRegistrableDialog dialog = null; |
33 |
|
|
31 |
|
|
34 | 32 |
public PropertiesRasterListener(PropertiesRasterRegistrableDialog dialog){ |
35 | 33 |
this.dialog = dialog; |
36 | 34 |
dialog.getButtonsPanel().getAccept().addActionListener(this); |
... | ... | |
43 | 41 |
dialog.getRegistrablePanel().acceptSelectedTab(); |
44 | 42 |
dialog.close(); |
45 | 43 |
} |
46 |
|
|
44 |
|
|
47 | 45 |
if(e.getSource().equals(dialog.getButtonsPanel().getApply())) |
48 | 46 |
dialog.getRegistrablePanel().applySelectedTab(); |
49 |
|
|
47 |
|
|
50 | 48 |
if(e.getSource().equals(dialog.getButtonsPanel().getCancel())){ |
51 | 49 |
dialog.getRegistrablePanel().cancelSelectedTab(); |
52 | 50 |
dialog.close(); |
53 | 51 |
} |
54 | 52 |
} |
55 |
} |
|
56 |
|
|
53 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/dialog/RasterPropertiesTocMenuEntry.java | ||
---|---|---|
96 | 96 |
//Asigna la capa a cada panel registrado para que puedan operar |
97 | 97 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
98 | 98 |
ExtensionPoint extensionPoint = (ExtensionPoint)extensionPoints.get("RasterSEPropertiesDialog"); |
99 |
if(extensionPoint == null) |
|
99 |
if (extensionPoint == null)
|
|
100 | 100 |
return; |
101 | 101 |
Iterator iterator = extensionPoint.keySet().iterator(); |
102 | 102 |
while (iterator.hasNext()) { |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/dialog/RegistrableTabPanel.java | ||
---|---|---|
18 | 18 |
*/ |
19 | 19 |
package org.gvsig.rastertools.properties.dialog; |
20 | 20 |
|
21 |
import java.util.Hashtable; |
|
21 | 22 |
import java.util.Iterator; |
22 | 23 |
|
23 | 24 |
import javax.swing.JPanel; |
... | ... | |
27 | 28 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
28 | 29 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
29 | 30 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
30 |
|
|
31 |
|
|
32 | 31 |
/** |
33 | 32 |
* Panel que contiene todos los paneles de los tabs del cuadro de dialogo |
34 | 33 |
* de bandas y transparencias |
35 | 34 |
* |
36 | 35 |
* @author Nacho Brodin (brodin_ign@gva.es) |
37 | 36 |
*/ |
38 |
public class RegistrableTabPanel extends DefaultTabPanel implements ChangeListener{ |
|
39 |
final private static long serialVersionUID = 0;
|
|
37 |
public class RegistrableTabPanel extends DefaultTabPanel implements ChangeListener {
|
|
38 |
final private static long serialVersionUID = 0;
|
|
40 | 39 |
|
41 |
private ExtensionPoints extensionPoints = null; |
|
42 |
private ExtensionPoint extensionPoint = null; |
|
43 |
/** |
|
44 |
* Tama?o en X del panel |
|
45 |
*/ |
|
46 |
protected int sizePanelX = 0; |
|
47 |
/** |
|
48 |
* Tama?o en Y del panel |
|
49 |
*/ |
|
50 |
protected int sizePanelY = 0; |
|
51 |
|
|
52 |
/** |
|
53 |
* Constructor. Inicializa los paneles y propiedades |
|
54 |
* @param props Propiedades |
|
55 |
*/ |
|
56 |
public RegistrableTabPanel(int sizex, int sizey) { |
|
57 |
super(sizex, sizey); |
|
40 |
private ExtensionPoints extensionPoints = null; |
|
41 |
private ExtensionPoint extensionPoint = null; |
|
42 |
|
|
43 |
static public Hashtable initialProperties = new Hashtable(); |
|
44 |
/** |
|
45 |
* Tama?o en X del panel |
|
46 |
*/ |
|
47 |
protected int sizePanelX = 0; |
|
48 |
|
|
49 |
/** |
|
50 |
* Tama?o en Y del panel |
|
51 |
*/ |
|
52 |
protected int sizePanelY = 0; |
|
53 |
|
|
54 |
/** |
|
55 |
* Constructor. Inicializa los paneles y propiedades |
|
56 |
* @param props Propiedades |
|
57 |
*/ |
|
58 |
public RegistrableTabPanel() { |
|
58 | 59 |
this.loadTabsFromExtensionPoints(); |
59 |
getTabPane().addChangeListener(this);
|
|
60 |
}
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Load register tabs inside the panel, reading these from extension points.
|
|
64 |
*/
|
|
65 |
private void loadTabsFromExtensionPoints(){
|
|
66 |
extensionPoints = ExtensionPointsSingleton.getInstance();
|
|
67 |
extensionPoint = (ExtensionPoint)extensionPoints.get("RasterSEPropertiesDialog"); |
|
68 |
if(extensionPoint == null) |
|
60 |
getTabPane().addChangeListener(this);
|
|
61 |
}
|
|
62 |
|
|
63 |
/**
|
|
64 |
* Load register tabs inside the panel, reading these from extension points.
|
|
65 |
*/
|
|
66 |
private void loadTabsFromExtensionPoints() {
|
|
67 |
extensionPoints = ExtensionPointsSingleton.getInstance();
|
|
68 |
extensionPoint = (ExtensionPoint) extensionPoints.get("RasterSEPropertiesDialog");
|
|
69 |
if (extensionPoint == null)
|
|
69 | 70 |
return; |
70 | 71 |
Iterator iterator = extensionPoint.keySet().iterator(); |
71 | 72 |
while (iterator.hasNext()) { |
72 | 73 |
try { |
73 |
String key = (String)iterator.next(); |
|
74 |
JPanel panel = (JPanel)extensionPoint.get(key); |
|
74 |
String key = (String) iterator.next();
|
|
75 |
JPanel panel = (JPanel) extensionPoint.get(key);
|
|
75 | 76 |
super.addTab(key, panel); |
76 | 77 |
} catch (ClassCastException e) { |
77 |
//No se a?ade el panel y se sigue con el siguiente |
|
78 |
// No se a?ade el panel y se sigue con el siguiente
|
|
78 | 79 |
continue; |
79 | 80 |
} |
80 | 81 |
} |
81 |
}
|
|
82 |
}
|
|
82 | 83 |
|
83 |
/**
|
|
84 |
* Obtiene el indice del tab seleccionado
|
|
85 |
* @return N?mero de tab seleccionado
|
|
86 |
*/
|
|
87 |
public int getSelectedTab(){
|
|
88 |
return super.getTab().getSelectedIndex();
|
|
89 |
}
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Ejecuta la acci?n de aceptar en el panel seleccionado
|
|
93 |
*/
|
|
94 |
public void acceptSelectedTab(){
|
|
95 |
execAction(0);
|
|
96 |
}
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Ejecuta la acci?n de aplicar en el panel seleccionado
|
|
100 |
*/
|
|
101 |
public void applySelectedTab(){
|
|
102 |
execAction(1);
|
|
103 |
}
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Ejecuta la acci?n de cancelar en el panel seleccionado
|
|
107 |
*/
|
|
108 |
public void cancelSelectedTab(){
|
|
109 |
execAction(2);
|
|
110 |
}
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Ejecuta la acci?n en el panel seleccionado que se le indica en el
|
|
114 |
* par?metro
|
|
115 |
* @param action indicador de la acci?n a realizar
|
|
116 |
*/
|
|
117 |
private void execAction(int action){
|
|
118 |
if(extensionPoint == null)
|
|
84 |
/**
|
|
85 |
* Obtiene el indice del tab seleccionado
|
|
86 |
* @return N?mero de tab seleccionado
|
|
87 |
*/
|
|
88 |
public int getSelectedTab() {
|
|
89 |
return super.getTab().getSelectedIndex();
|
|
90 |
}
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Ejecuta la acci?n de aceptar en el panel seleccionado
|
|
94 |
*/
|
|
95 |
public void acceptSelectedTab() {
|
|
96 |
execAction(0);
|
|
97 |
}
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Ejecuta la acci?n de aplicar en el panel seleccionado
|
|
101 |
*/
|
|
102 |
public void applySelectedTab() {
|
|
103 |
execAction(1);
|
|
104 |
}
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Ejecuta la acci?n de cancelar en el panel seleccionado
|
|
108 |
*/
|
|
109 |
public void cancelSelectedTab() {
|
|
110 |
execAction(2);
|
|
111 |
}
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Ejecuta la acci?n en el panel seleccionado que se le indica en el
|
|
115 |
* par?metro
|
|
116 |
* @param action indicador de la acci?n a realizar
|
|
117 |
*/
|
|
118 |
private void execAction(int action) {
|
|
119 |
if (extensionPoint == null)
|
|
119 | 120 |
return; |
120 |
if(getTab().getSelectedIndex() == -1)
|
|
121 |
return;
|
|
122 |
String title = getTab().getTitleAt(getTab().getSelectedIndex());
|
|
123 |
|
|
124 |
Iterator iterator = extensionPoint.keySet().iterator();
|
|
121 |
if (getTab().getSelectedIndex() == -1)
|
|
122 |
return;
|
|
123 |
String title = getTab().getTitleAt(getTab().getSelectedIndex());
|
|
124 |
|
|
125 |
Iterator iterator = extensionPoint.keySet().iterator();
|
|
125 | 126 |
while (iterator.hasNext()) { |
126 | 127 |
try { |
127 |
String key = (String)iterator.next(); |
|
128 |
if(key.equals(title)){ |
|
129 |
IRegistrablePanel panel = (IRegistrablePanel)extensionPoint.get(key); |
|
130 |
switch(action){ |
|
131 |
case 0: panel.accept(); break; |
|
132 |
case 1: panel.apply(); break; |
|
133 |
case 2: panel.cancel(); break; |
|
128 |
String key = (String) iterator.next(); |
|
129 |
IRegistrablePanel panel = (IRegistrablePanel) extensionPoint.get(key); |
|
130 |
if (key.equals(title)) { |
|
131 |
switch (action) { |
|
132 |
case 0: |
|
133 |
panel.accept(); |
|
134 |
break; |
|
135 |
case 1: |
|
136 |
panel.apply(); |
|
137 |
break; |
|
134 | 138 |
} |
135 | 139 |
} |
140 |
if (action == 2) |
|
141 |
panel.cancel(); |
|
136 | 142 |
} catch (ClassCastException e) { |
137 |
//No se ejecuta |
|
143 |
// No se ejecuta
|
|
138 | 144 |
continue; |
139 | 145 |
} |
140 | 146 |
} |
141 |
} |
|
142 |
|
|
143 |
/** |
|
144 |
* Asigna la visibilidad de un tab a verdadero o falso. La |
|
145 |
* selecci?n del tab se hace por el identificador. |
|
146 |
* @param tab Identificador del tab. Variable nom del mismo |
|
147 |
* @param active True o false para visible o invisible. |
|
148 |
*/ |
|
149 |
public void setTabVisible(String tab, boolean active){ |
|
150 |
|
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* Selecciona el panel indicado por index |
|
155 |
* @param index panel seleccionado |
|
156 |
*/ |
|
157 |
public void setSelectedIndex(int index) { |
|
158 |
tabbedPane.setSelectedIndex(index); |
|
159 |
} |
|
147 |
} |
|
160 | 148 |
|
161 |
/** |
|
162 |
* Propagamos el evento de cambiar de pesta?a a todos los paneles. |
|
163 |
*/ |
|
149 |
/** |
|
150 |
* Asigna la visibilidad de un tab a verdadero o falso. La |
|
151 |
* selecci?n del tab se hace por el identificador. |
|
152 |
* @param tab Identificador del tab. Variable nom del mismo |
|
153 |
* @param active True o false para visible o invisible. |
|
154 |
*/ |
|
155 |
public void setTabVisible(String tab, boolean active){ |
|
156 |
|
|
157 |
} |
|
158 |
|
|
159 |
/** |
|
160 |
* Selecciona el panel indicado por index |
|
161 |
* @param index panel seleccionado |
|
162 |
*/ |
|
163 |
public void setSelectedIndex(int index) { |
|
164 |
tabbedPane.setSelectedIndex(index); |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* Propagamos el evento de cambiar de pesta?a a todos los paneles. |
|
169 |
*/ |
|
164 | 170 |
public void stateChanged(ChangeEvent e) { |
165 |
if(extensionPoint == null)
|
|
171 |
if(extensionPoint == null)
|
|
166 | 172 |
return; |
167 |
if(getTab().getSelectedIndex() == -1)
|
|
168 |
return;
|
|
169 |
String title = getTab().getTitleAt(getTab().getSelectedIndex());
|
|
170 |
|
|
171 |
Iterator iterator = extensionPoint.keySet().iterator();
|
|
173 |
if(getTab().getSelectedIndex() == -1)
|
|
174 |
return;
|
|
175 |
String title = getTab().getTitleAt(getTab().getSelectedIndex());
|
|
176 |
|
|
177 |
Iterator iterator = extensionPoint.keySet().iterator();
|
|
172 | 178 |
while (iterator.hasNext()) { |
173 | 179 |
try { |
174 | 180 |
String key = (String)iterator.next(); |
... | ... | |
182 | 188 |
} |
183 | 189 |
} |
184 | 190 |
} |
185 |
|
|
186 |
} |
|
191 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/dialog/DefaultTabPanel.java | ||
---|---|---|
19 | 19 |
package org.gvsig.rastertools.properties.dialog; |
20 | 20 |
|
21 | 21 |
import java.awt.BorderLayout; |
22 |
import java.awt.Dimension; |
|
23 | 22 |
|
24 | 23 |
import javax.swing.JPanel; |
25 | 24 |
import javax.swing.JTabbedPane; |
26 |
|
|
27 |
|
|
28 | 25 |
/** |
29 | 26 |
* Panel del que heredaran los paneles que contengan tabs |
30 | 27 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
31 | 28 |
*/ |
32 |
public class DefaultTabPanel extends JPanel{ |
|
33 |
final private static long serialVersionUID = 0; |
|
34 |
protected JTabbedPane tabbedPane = null; |
|
35 |
|
|
36 |
/** |
|
37 |
* Tama?o en X del panel |
|
38 |
*/ |
|
39 |
protected int sizePanelX = 0; |
|
40 |
/** |
|
41 |
* Tama?o en Y del panel |
|
42 |
*/ |
|
43 |
protected int sizePanelY = 0; |
|
29 |
public class DefaultTabPanel extends JPanel { |
|
30 |
private static final long serialVersionUID = -4685720916064127154L; |
|
31 |
protected JTabbedPane tabbedPane = null; |
|
44 | 32 |
|
45 |
/** |
|
46 |
* Contructor |
|
47 |
*/ |
|
48 |
public DefaultTabPanel(int sizex, int sizey) { |
|
49 |
this.sizePanelX = sizex; |
|
50 |
this.sizePanelY = sizey; |
|
51 |
init(); |
|
52 |
} |
|
33 |
/** |
|
34 |
* Contructor |
|
35 |
*/ |
|
36 |
public DefaultTabPanel() { |
|
37 |
inititialize(); |
|
38 |
} |
|
53 | 39 |
|
54 | 40 |
|
55 |
public void init(){
|
|
56 |
this.setLayout(new BorderLayout());
|
|
57 |
this.add(getTabPane(), BorderLayout.CENTER);
|
|
58 |
}
|
|
59 |
|
|
41 |
public void inititialize() {
|
|
42 |
this.setLayout(new BorderLayout());
|
|
43 |
this.add(getTabPane(), BorderLayout.CENTER);
|
|
44 |
}
|
|
45 |
|
|
60 | 46 |
/** |
61 |
* Obtiene el Componente JTabbedPane |
|
62 |
* @return Componente JTabbedPane |
|
63 |
*/ |
|
64 |
public JTabbedPane getTabPane() { |
|
65 |
if (tabbedPane == null) { |
|
66 |
tabbedPane = new JTabbedPane(); |
|
67 |
tabbedPane.setPreferredSize(new Dimension(sizePanelX, sizePanelY)); |
|
68 |
} |
|
69 |
return tabbedPane; |
|
70 |
} |
|
47 |
* Obtiene el Componente JTabbedPane |
|
48 |
* @return Componente JTabbedPane |
|
49 |
*/ |
|
50 |
public JTabbedPane getTabPane() { |
|
51 |
if (tabbedPane == null) { |
|
52 |
tabbedPane = new JTabbedPane(); |
|
53 |
} |
|
54 |
return tabbedPane; |
|
55 |
} |
|
71 | 56 |
|
72 |
/**
|
|
73 |
* A?ade un tab al JTabbedPane
|
|
74 |
* @param title T?tulo del tab
|
|
75 |
* @param panel Panel del nuevo tab
|
|
76 |
*/
|
|
77 |
public void addTab(String title, JPanel panel) {
|
|
78 |
tabbedPane.add(title, panel);
|
|
79 |
}
|
|
57 |
/**
|
|
58 |
* A?ade un tab al JTabbedPane
|
|
59 |
* @param title T?tulo del tab
|
|
60 |
* @param panel Panel del nuevo tab
|
|
61 |
*/
|
|
62 |
public void addTab(String title, JPanel panel) {
|
|
63 |
tabbedPane.add(title, panel);
|
|
64 |
}
|
|
80 | 65 |
|
81 |
/**
|
|
82 |
* Obtiene el JTabbedPane
|
|
83 |
* @return JTabbedPane
|
|
84 |
*/
|
|
85 |
public JTabbedPane getTab() {
|
|
86 |
return tabbedPane;
|
|
87 |
}
|
|
88 |
|
|
89 |
} // @jve:decl-index=0:visual-constraint="13,18"
|
|
66 |
/**
|
|
67 |
* Obtiene el JTabbedPane
|
|
68 |
*
|
|
69 |
* @return JTabbedPane
|
|
70 |
*/
|
|
71 |
public JTabbedPane getTab() {
|
|
72 |
return tabbedPane;
|
|
73 |
} |
|
74 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/dialog/IRegistrablePanel.java | ||
---|---|---|
19 | 19 |
package org.gvsig.rastertools.properties.dialog; |
20 | 20 |
|
21 | 21 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
22 |
|
|
23 |
|
|
24 | 22 |
/** |
25 |
* Interfaz que implementan los paneles que se registran en el |
|
26 |
* cuadro de propiedades de raster. |
|
23 |
* Interfaz que implementan los paneles que se registran en el cuadro de |
|
24 |
* propiedades de raster. |
|
25 |
* |
|
27 | 26 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
28 |
* |
|
29 | 27 |
*/ |
30 |
public interface IRegistrablePanel extends IResizable{ |
|
28 |
public interface IRegistrablePanel extends IResizable {
|
|
31 | 29 |
/** |
32 | 30 |
* Asigna la capa |
33 | 31 |
* @param lyr |
34 | 32 |
*/ |
35 | 33 |
public void setLayer(FLayer lyr); |
36 |
|
|
34 |
|
|
37 | 35 |
/** |
38 | 36 |
* Acciones a ejecutar cuando se acepta |
39 | 37 |
*/ |
40 | 38 |
public void accept(); |
39 |
|
|
41 | 40 |
/** |
42 | 41 |
* Acciones a ejecutar cuando se aplica |
43 | 42 |
*/ |
44 | 43 |
public void apply(); |
44 |
|
|
45 | 45 |
/** |
46 | 46 |
* Acciones a ejecutar cuando se cancela |
47 | 47 |
*/ |
48 | 48 |
public void cancel(); |
49 |
|
|
49 | 50 |
/** |
50 | 51 |
* Acci?n al ejecutar un tab con el id especificado en el par?metro |
51 | 52 |
* @param id identificador del tab. |
52 | 53 |
*/ |
53 | 54 |
public void selectTab(String id); |
54 |
|
|
55 |
|
|
55 | 56 |
/** |
56 | 57 |
* Cadena que identifica el panel. |
57 | 58 |
* @return identificador |
58 | 59 |
*/ |
59 | 60 |
public String getID(); |
60 |
} |
|
61 |
|
|
61 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/dialog/ButtonsPanel.java | ||
---|---|---|
22 | 22 |
|
23 | 23 |
import javax.swing.JButton; |
24 | 24 |
import javax.swing.JPanel; |
25 |
|
|
26 | 25 |
/** |
27 | 26 |
* Panel con los controles de bot?n de aplicar, aceptar y cancelar. |
28 | 27 |
* |
29 | 28 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
30 |
* |
|
31 | 29 |
*/ |
32 | 30 |
public class ButtonsPanel extends JPanel { |
33 | 31 |
private static final long serialVersionUID = -5111153508681932951L; |
34 |
private JButton bAccept = null; |
|
35 |
private JButton bApply = null; |
|
36 |
private JButton bCancel = null; |
|
37 |
private int sizePanelX = 0; |
|
38 |
private int sizePanelY = 30; |
|
39 |
|
|
32 |
private JButton bAccept = null; |
|
33 |
private JButton bApply = null; |
|
34 |
private JButton bCancel = null; |
|
35 |
private int sizePanelY = 30; |
|
40 | 36 |
|
41 | 37 |
/** |
42 |
* This method initializes |
|
43 |
* |
|
38 |
* This method initializes |
|
44 | 39 |
*/ |
45 |
public ButtonsPanel(int sizex) {
|
|
40 |
public ButtonsPanel() { |
|
46 | 41 |
super(); |
47 |
this.sizePanelX = sizex; |
|
48 | 42 |
initialize(); |
49 | 43 |
} |
50 | 44 |
|
51 | 45 |
/** |
52 | 46 |
* This method initializes this |
53 |
* |
|
54 | 47 |
*/ |
55 | 48 |
private void initialize() { |
56 |
FlowLayout flowLayout = new FlowLayout();
|
|
57 |
flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
|
|
58 |
flowLayout.setHgap(2);
|
|
59 |
flowLayout.setVgap(2);
|
|
60 |
this.setLayout(flowLayout);
|
|
61 |
this.setPreferredSize(new java.awt.Dimension(sizePanelX, sizePanelY));
|
|
62 |
this.add(getAccept(), null);
|
|
63 |
this.add(getApply(), null);
|
|
64 |
this.add(getCancel(), null);
|
|
65 |
|
|
49 |
FlowLayout flowLayout = new FlowLayout();
|
|
50 |
flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
|
|
51 |
flowLayout.setHgap(2);
|
|
52 |
flowLayout.setVgap(2);
|
|
53 |
this.setLayout(flowLayout);
|
|
54 |
this.setPreferredSize(new java.awt.Dimension(0, sizePanelY));
|
|
55 |
this.add(getAccept(), null);
|
|
56 |
this.add(getApply(), null);
|
|
57 |
this.add(getCancel(), null);
|
|
58 |
|
|
66 | 59 |
} |
67 | 60 |
|
68 | 61 |
/** |
69 |
* This method initializes jButton |
|
70 |
* |
|
71 |
* @return javax.swing.JButton |
|
62 |
* This method initializes jButton |
|
63 |
* @return javax.swing.JButton |
|
72 | 64 |
*/ |
73 | 65 |
public JButton getAccept() { |
74 | 66 |
if (bAccept == null) { |
... | ... | |
79 | 71 |
} |
80 | 72 |
|
81 | 73 |
/** |
82 |
* This method initializes jButton1 |
|
83 |
* |
|
84 |
* @return javax.swing.JButton |
|
74 |
* This method initializes jButton1 |
|
75 |
* @return javax.swing.JButton |
|
85 | 76 |
*/ |
86 | 77 |
public JButton getApply() { |
87 | 78 |
if (bApply == null) { |
... | ... | |
92 | 83 |
} |
93 | 84 |
|
94 | 85 |
/** |
95 |
* This method initializes jButton2 |
|
96 |
* |
|
97 |
* @return javax.swing.JButton |
|
86 |
* This method initializes jButton2 |
|
87 |
* @return javax.swing.JButton |
|
98 | 88 |
*/ |
99 | 89 |
public JButton getCancel() { |
100 | 90 |
if (bCancel == null) { |
... | ... | |
103 | 93 |
} |
104 | 94 |
return bCancel; |
105 | 95 |
} |
106 |
|
|
107 |
} |
|
96 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/EnhancedControl.java | ||
---|---|---|
18 | 18 |
*/ |
19 | 19 |
package org.gvsig.rastertools.properties.panels; |
20 | 20 |
|
21 |
import java.awt.event.ActionEvent; |
|
22 |
import java.awt.event.ActionListener; |
|
21 | 23 |
import java.awt.event.KeyEvent; |
22 | 24 |
import java.awt.event.KeyListener; |
25 |
import java.util.ArrayList; |
|
23 | 26 |
|
27 |
import javax.swing.JCheckBox; |
|
24 | 28 |
import javax.swing.event.ChangeEvent; |
25 | 29 |
import javax.swing.event.ChangeListener; |
26 | 30 |
|
... | ... | |
35 | 39 |
import org.gvsig.raster.grid.filter.statistics.TailTrimFilter; |
36 | 40 |
import org.gvsig.raster.shared.IRasterDataset; |
37 | 41 |
import org.gvsig.raster.shared.IRasterRendering; |
42 |
import org.gvsig.rastertools.properties.dialog.RegistrableTabPanel; |
|
38 | 43 |
|
39 | 44 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
40 | 45 |
/** |
... | ... | |
55 | 60 |
* Manejador de eventos de los slider de brillo y contraste. |
56 | 61 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
57 | 62 |
*/ |
58 |
class BrightnessContrastListener implements KeyListener, ChangeListener { |
|
59 |
|
|
63 |
class BrightnessContrastListener implements KeyListener, ChangeListener, ActionListener {
|
|
64 |
JCheckBox active = null; |
|
60 | 65 |
/** |
61 | 66 |
* Constructor. Registra los listener |
62 | 67 |
* @param panel |
... | ... | |
66 | 71 |
panel.addContrastChangeListener(this); |
67 | 72 |
panel.addBrightnessKeyListener(this); |
68 | 73 |
panel.addContrastKeyListener(this); |
74 |
active = panel.getActive(); |
|
75 |
active.addActionListener(this); |
|
69 | 76 |
} |
70 | 77 |
|
71 | 78 |
public void keyPressed(KeyEvent e) { |
... | ... | |
73 | 80 |
|
74 | 81 |
public void keyReleased(KeyEvent e) { |
75 | 82 |
if (e.getKeyCode() == 10) |
76 |
apply();
|
|
83 |
onlyApply();
|
|
77 | 84 |
} |
78 | 85 |
|
79 | 86 |
public void keyTyped(KeyEvent e) { |
80 | 87 |
} |
81 | 88 |
|
82 | 89 |
public void stateChanged(ChangeEvent e) { |
83 |
if (bcPanel.getPreview().isSelected()) |
|
84 |
apply(); |
|
90 |
onlyApply(); |
|
85 | 91 |
} |
92 |
|
|
93 |
public void actionPerformed(ActionEvent e) { |
|
94 |
if (e.getSource() == active) |
|
95 |
onlyApply(); |
|
96 |
} |
|
86 | 97 |
} |
87 | 98 |
|
88 | 99 |
/** |
100 |
* Manejador de eventos del panel EnhancedWithTrim. |
|
101 |
* |
|
102 |
* @version 14/06/2007 |
|
103 |
* @author Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
104 |
*/ |
|
105 |
class EnhancedWithTrimListener implements ActionListener { |
|
106 |
JCheckBox active = null; |
|
107 |
/** |
|
108 |
* Constructor. Registra los listener |
|
109 |
* @param panel |
|
110 |
*/ |
|
111 |
public EnhancedWithTrimListener(EnhancedWithTrimPanel panel) { |
|
112 |
active = panel.getActive(); |
|
113 |
active.addActionListener(this); |
|
114 |
} |
|
115 |
|
|
116 |
public void actionPerformed(ActionEvent e) { |
|
117 |
if (e.getSource() == active) |
|
118 |
onlyApply(); |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
89 | 123 |
* Constructor |
90 | 124 |
* @param tp |
91 | 125 |
*/ |
92 | 126 |
public EnhancedControl(EnhancedPanel tp, IRasterDataset dataset, FLayer lyr, RasterFilterList rfl) { |
93 | 127 |
this.tPanel = tp; |
94 | 128 |
this.dataset = dataset; |
95 |
filterList = rfl; |
|
129 |
this.filterList = rfl;
|
|
96 | 130 |
this.lyr = lyr; |
97 |
bcPanel = tPanel.getBrightnessContrastPanel(); |
|
98 |
ePanel = tPanel.getEnhancedWithTrimPanel(); |
|
131 |
this.bcPanel = tPanel.getBrightnessContrastPanel();
|
|
132 |
this.ePanel = tPanel.getEnhancedWithTrimPanel();
|
|
99 | 133 |
new BrightnessContrastListener(bcPanel); |
134 |
new EnhancedWithTrimListener(ePanel); |
|
135 |
|
|
136 |
saveStatus(); |
|
137 |
|
|
100 | 138 |
setValuesFromFilterToPanel(); |
101 | 139 |
} |
102 | 140 |
|
... | ... | |
173 | 211 |
|
174 | 212 |
// BRILLO Y CONTRASTE |
175 | 213 |
BrightnessContrastListManager bcManager = (BrightnessContrastListManager) manager.getManagerByClass(BrightnessContrastListManager.class); |
176 |
if (bcPanel.getActive().isSelected()) { |
|
177 |
if ((int) bcPanel.getBrightnessValue() != 0) |
|
178 |
bcManager.addBrightnessFilter((int) bcPanel.getBrightnessValue(), insertionModeBrightness); |
|
179 |
else |
|
180 |
filterList.remove(BrightnessFilter.class); |
|
181 | 214 |
|
182 |
if ((int) bcPanel.getContrastValue() != 0) |
|
183 |
bcManager.addContrastFilter((int) bcPanel.getContrastValue(), insertionModeContrast); |
|
184 |
else |
|
185 |
filterList.remove(ContrastFilter.class); |
|
186 |
} |
|
215 |
if (bcPanel.getActive().isSelected() && ((int) bcPanel.getBrightnessValue() != 0)) |
|
216 |
bcManager.addBrightnessFilter((int) bcPanel.getBrightnessValue(), insertionModeBrightness); |
|
217 |
else |
|
218 |
filterList.remove(BrightnessFilter.class); |
|
187 | 219 |
|
220 |
if (bcPanel.getActive().isSelected() && ((int) bcPanel.getContrastValue() != 0)) |
|
221 |
bcManager.addContrastFilter((int) bcPanel.getContrastValue(), insertionModeContrast); |
|
222 |
else |
|
223 |
filterList.remove(ContrastFilter.class); |
|
224 |
|
|
188 | 225 |
// Redibujamos |
189 |
lyr.getMapContext().invalidate(); |
|
226 |
if (lyr != null) |
|
227 |
lyr.getMapContext().invalidate(); |
|
190 | 228 |
} |
191 | 229 |
|
192 | 230 |
/** |
... | ... | |
200 | 238 |
* Acciones a ejecutar cuando se aplica |
201 | 239 |
*/ |
202 | 240 |
public void apply() { |
241 |
onlyApply(); |
|
242 |
saveStatus(); |
|
243 |
} |
|
244 |
|
|
245 |
/** |
|
246 |
* Acciones a ejecutar cuando se aplica |
|
247 |
*/ |
|
248 |
public void onlyApply() { |
|
203 | 249 |
setValuesFromPanelToFilter(); |
204 | 250 |
} |
205 | 251 |
|
... | ... | |
207 | 253 |
* Acciones a ejecutar cuando se cancela |
208 | 254 |
*/ |
209 | 255 |
public void cancel() { |
256 |
restoreStatus(); |
|
210 | 257 |
} |
258 |
|
|
259 |
public void saveStatus() { |
|
260 |
RegistrableTabPanel.initialProperties.put("filterStatus", filterList.getStatusCloned()); |
|
261 |
} |
|
262 |
|
|
263 |
public void restoreStatus() { |
|
264 |
filterList.setStatus((ArrayList) RegistrableTabPanel.initialProperties.get("filterStatus")); |
|
265 |
|
|
266 |
if (lyr != null) |
|
267 |
lyr.getMapContext().invalidate(); |
|
268 |
} |
|
211 | 269 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/TranspByPixelListener.java | ||
---|---|---|
20 | 20 |
|
21 | 21 |
import java.awt.event.ActionEvent; |
22 | 22 |
import java.awt.event.ActionListener; |
23 |
import java.awt.event.MouseEvent; |
|
24 |
import java.awt.event.MouseListener; |
|
23 | 25 |
import java.util.ArrayList; |
24 | 26 |
|
25 | 27 |
import javax.swing.JButton; |
... | ... | |
37 | 39 |
* |
38 | 40 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
39 | 41 |
*/ |
40 |
public class TranspByPixelListener implements ActionListener, ListSelectionListener, DoubleSliderListener { |
|
42 |
public class TranspByPixelListener implements ActionListener, ListSelectionListener, DoubleSliderListener, MouseListener {
|
|
41 | 43 |
private ArrayList entries = new ArrayList(); |
42 | 44 |
private JButton addButton = null; |
43 | 45 |
private JButton removeButton = null; |
... | ... | |
76 | 78 |
panel.getPRGBInput().getTGreen().addValueChangedListener(this); |
77 | 79 |
panel.getPRGBInput().getTRed().addValueChangedListener(this); |
78 | 80 |
panel.getPRGBInput().getTAlpha().addValueChangedListener(this); |
81 |
list.addMouseListener(this); |
|
79 | 82 |
} |
80 | 83 |
|
81 | 84 |
/** |
... | ... | |
162 | 165 |
|
163 | 166 |
// Elimina elementos de la lista |
164 | 167 |
if (e.getSource() == removeButton) { |
165 |
if (itemSelected != -1) { |
|
166 |
entries.remove(itemSelected); |
|
167 |
panel.getListModel().remove(itemSelected); |
|
168 |
|
|
169 |
if (itemSelected >= entries.size()) { |
|
170 |
itemSelected = entries.size() - 1; |
|
171 |
} |
|
172 |
setValues(itemSelected); |
|
173 |
|
|
174 |
if (entries.size() == 0) |
|
175 |
removeButton.setEnabled(false); |
|
176 |
panel.callValueChanged(); |
|
177 |
} |
|
168 |
deleteSelected(); |
|
178 | 169 |
return; |
179 | 170 |
} |
180 | 171 |
|
... | ... | |
185 | 176 |
} |
186 | 177 |
} |
187 | 178 |
|
179 |
private void deleteSelected() { |
|
180 |
if (itemSelected == -1) |
|
181 |
return; |
|
182 |
|
|
183 |
entries.remove(itemSelected); |
|
184 |
panel.getListModel().remove(itemSelected); |
|
185 |
|
|
186 |
if (itemSelected >= entries.size()) { |
|
187 |
itemSelected = entries.size() - 1; |
|
188 |
} |
|
189 |
setValues(itemSelected); |
|
190 |
|
|
191 |
if (entries.size() == 0) |
|
192 |
removeButton.setEnabled(false); |
|
193 |
panel.callValueChanged(); |
|
194 |
} |
|
195 |
|
|
188 | 196 |
/** |
189 | 197 |
* Establece los valores RGBA a sus componentes segun la seleccion |
190 | 198 |
* @param item |
... | ... | |
293 | 301 |
*/ |
294 | 302 |
public void actionValueDragged(DoubleSliderEvent e) { |
295 | 303 |
} |
304 |
|
|
305 |
/* |
|
306 |
* (non-Javadoc) |
|
307 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) |
|
308 |
*/ |
|
309 |
public void mouseClicked(MouseEvent e) { |
|
310 |
if (e.getSource() == list) |
|
311 |
// Si es doble click borramos el seleccionado |
|
312 |
if (e.getClickCount() == 2) |
|
313 |
deleteSelected(); |
|
314 |
} |
|
315 |
|
|
316 |
/* |
|
317 |
* (non-Javadoc) |
|
318 |
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) |
|
319 |
*/ |
|
320 |
public void mouseEntered(MouseEvent e) { |
|
321 |
} |
|
322 |
|
|
323 |
/* |
|
324 |
* (non-Javadoc) |
|
325 |
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) |
|
326 |
*/ |
|
327 |
public void mouseExited(MouseEvent e) { |
|
328 |
} |
|
329 |
|
|
330 |
/* |
|
331 |
* (non-Javadoc) |
|
332 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) |
|
333 |
*/ |
|
334 |
public void mousePressed(MouseEvent e) { |
|
335 |
} |
|
336 |
|
|
337 |
/* |
|
338 |
* (non-Javadoc) |
|
339 |
* @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) |
|
340 |
*/ |
|
341 |
public void mouseReleased(MouseEvent e) { |
|
342 |
} |
|
296 | 343 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/TransparencyControl.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import org.gvsig.raster.grid.GridTransparency; |
25 | 25 |
import org.gvsig.raster.util.TransparencyRange; |
26 |
import org.gvsig.rastertools.properties.dialog.RegistrableTabPanel; |
|
26 | 27 |
/** |
27 | 28 |
* Clase que hace de interfaz entre los objetos que contienen la informaci?n de |
28 | 29 |
* transparencia y el panel. |
... | ... | |
30 | 31 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
31 | 32 |
*/ |
32 | 33 |
public class TransparencyControl implements TranspByPixelEventListener { |
33 |
private GridTransparency transparency = null; |
|
34 |
private TransparencyPanel tPanel = null; |
|
34 |
private GridTransparency transparency = null;
|
|
35 |
private TransparencyPanel tPanel = null;
|
|
35 | 36 |
|
36 | 37 |
/** |
37 |
* Constructor
|
|
38 |
* Construye un TransparencyControl
|
|
38 | 39 |
* @param tp |
39 | 40 |
*/ |
40 | 41 |
public TransparencyControl(TransparencyPanel tp) { |
... | ... | |
42 | 43 |
tPanel.getPTranspByPixel().addValueChangedListener(this); |
43 | 44 |
} |
44 | 45 |
|
46 |
/** |
|
47 |
* Aqui se definen los parametros iniciales para la transparencia del panel |
|
48 |
* @param t |
|
49 |
*/ |
|
45 | 50 |
public void setTransparencyObject(GridTransparency t) { |
46 | 51 |
this.transparency = t; |
52 |
|
|
53 |
saveStatus(); |
|
54 |
|
|
47 | 55 |
setValuesFromGridTransparencyToPanel(); |
48 | 56 |
} |
49 | 57 |
|
... | ... | |
105 | 113 |
} |
106 | 114 |
|
107 | 115 |
/** |
108 |
* Acciones a ejecutar cuando se acepta
|
|
116 |
* Aplica y guarda los cambios del panel
|
|
109 | 117 |
*/ |
110 |
public void accept() { |
|
118 |
public void apply() { |
|
119 |
onlyApply(); |
|
120 |
saveStatus(); |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Aplicar los cambios sin guardar su estado |
|
125 |
*/ |
|
126 |
public void onlyApply() { |
|
111 | 127 |
setValuesFromPanelToGridTransparency(); |
112 | 128 |
} |
113 | 129 |
|
114 | 130 |
/** |
115 |
* Acciones a ejecutar cuando se aplica
|
|
131 |
* Guarda el estado actual del panel
|
|
116 | 132 |
*/ |
117 |
public void apply() { |
|
133 |
private void saveStatus() { |
|
134 |
RegistrableTabPanel.initialProperties.put("opacity", new Integer(transparency.getOpacity())); |
|
135 |
RegistrableTabPanel.initialProperties.put("transparencyActive", new Boolean(transparency.isTransparencyActive())); |
|
136 |
|
|
137 |
ArrayList newArray = new ArrayList(); |
|
138 |
for (int i = 0; i < transparency.getTransparencyRange().size(); i++) { |
|
139 |
newArray.add(transparency.getTransparencyRange().get(i)); |
|
140 |
} |
|
141 |
RegistrableTabPanel.initialProperties.put("transparencyRange", newArray); |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* Deja la capa en el ?ltimo estado guardado y la refresca |
|
146 |
*/ |
|
147 |
public void restoreStatus() { |
|
148 |
transparency.setOpacity(((Integer) RegistrableTabPanel.initialProperties.get("opacity")).intValue()); |
|
149 |
transparency.setTransparencyActive(((Boolean) RegistrableTabPanel.initialProperties.get("transparencyActive")).booleanValue()); |
|
150 |
|
|
151 |
ArrayList newArray = (ArrayList) RegistrableTabPanel.initialProperties.get("transparencyRange"); |
|
152 |
transparency.clearListOfTransparencyRange(); |
|
153 |
for (int i = 0; i < newArray.size(); i++) { |
|
154 |
transparency.setTransparencyRange((TransparencyRange) newArray.get(i)); |
|
155 |
} |
|
156 |
|
|
157 |
if (tPanel.getLayer() != null) |
|
158 |
tPanel.getLayer().getMapContext().invalidate(); |
|
159 |
} |
|
160 |
|
|
161 |
/** |
|
162 |
* Acciones a ejecutar cuando se acepta |
|
163 |
*/ |
|
164 |
public void accept() { |
|
118 | 165 |
setValuesFromPanelToGridTransparency(); |
119 | 166 |
} |
120 | 167 |
|
... | ... | |
122 | 169 |
* Acciones a ejecutar cuando se cancela |
123 | 170 |
*/ |
124 | 171 |
public void cancel() { |
172 |
restoreStatus(); |
|
125 | 173 |
} |
126 | 174 |
|
127 | 175 |
/* |
... | ... | |
129 | 177 |
* @see org.gvsig.rastertools.properties.panels.TranspByPixelEventListener#actionPixelListChanged(java.util.EventObject) |
130 | 178 |
*/ |
131 | 179 |
public void actionPixelListChanged(EventObject e) { |
132 |
apply();
|
|
180 |
onlyApply();
|
|
133 | 181 |
} |
134 | 182 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/EnhancedWithTrimPanel.java | ||
---|---|---|
16 | 16 |
* along with this program; if not, write to the Free Software |
17 | 17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
18 | 18 |
*/ |
19 |
|
|
20 | 19 |
package org.gvsig.rastertools.properties.panels; |
21 | 20 |
|
22 | 21 |
import java.awt.BorderLayout; |
... | ... | |
34 | 33 |
import org.gvsig.gui.beans.slidertext.SliderTextContainer; |
35 | 34 |
|
36 | 35 |
import com.iver.andami.PluginServices; |
37 |
|
|
38 |
|
|
39 | 36 |
/** |
40 |
* Panel para los controles de brillo y contrase .
|
|
37 |
* Panel para los controles de brillo y contraste.
|
|
41 | 38 |
* |
42 | 39 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
43 | 40 |
*/ |
44 |
public class EnhancedWithTrimPanel extends JPanel implements ActionListener{ |
|
45 |
final private static long serialVersionUID = 0;
|
|
46 |
public static final int LINEAR = 0;
|
|
47 |
private TrimPanel trimPanel = null;
|
|
48 |
private SelectorPanel selectorPanel = null;
|
|
49 |
private JCheckBox active = null;
|
|
50 |
|
|
41 |
public class EnhancedWithTrimPanel extends JPanel implements ActionListener {
|
|
42 |
private static final long serialVersionUID = 9023137365069951866L;
|
|
43 |
public static final int LINEAR = 0;
|
|
44 |
private TrimPanel trimPanel = null;
|
|
45 |
private SelectorPanel selectorPanel = null;
|
|
46 |
private JCheckBox active = null;
|
|
47 |
|
|
51 | 48 |
/** |
52 | 49 |
* Panel con los controles de eliminar extremos, recorte de colas y slider |
53 | 50 |
* con el porcentaje de recorte. |
54 | 51 |
* |
55 | 52 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
56 |
* |
|
57 | 53 |
*/ |
58 |
class TrimPanel extends JPanel implements ActionListener{ |
|
59 |
final private static long serialVersionUID = 0;
|
|
60 |
private SliderTextContainer trimSlider = null;
|
|
61 |
private JCheckBox remove = null;
|
|
62 |
private JCheckBox trimCheck = null;
|
|
63 |
private JPanel pCheck = null;
|
|
64 |
|
|
54 |
class TrimPanel extends JPanel implements ActionListener {
|
|
55 |
private static final long serialVersionUID = -6435560458161006843L;
|
|
56 |
private SliderTextContainer trimSlider = null;
|
|
57 |
private JCheckBox remove = null;
|
|
58 |
private JCheckBox trimCheck = null;
|
|
59 |
private JPanel pCheck = null;
|
|
60 |
|
|
65 | 61 |
/** |
66 | 62 |
* Contructor |
67 | 63 |
*/ |
68 |
public TrimPanel(){ |
|
64 |
public TrimPanel() {
|
|
69 | 65 |
trimSlider = new SliderTextContainer(0, 100, 50); |
70 | 66 |
trimSlider.setDecimal(true); |
71 | 67 |
trimSlider.setBorder(""); |
72 | 68 |
init(); |
73 | 69 |
getTrim().addActionListener(this); |
74 | 70 |
} |
75 |
|
|
76 |
private void init(){ |
|
71 |
|
|
72 |
private void init() {
|
|
77 | 73 |
setBorder(javax.swing.BorderFactory.createTitledBorder(null, null, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
78 | 74 |
this.setLayout(new BorderLayout()); |
79 |
this.add(getPCheck(), BorderLayout.NORTH );
|
|
75 |
this.add(getPCheck(), BorderLayout.NORTH); |
|
80 | 76 |
this.add(trimSlider, BorderLayout.CENTER); |
81 | 77 |
} |
82 |
|
|
78 |
|
|
83 | 79 |
/** |
84 | 80 |
* Obtiene el control con el slider de recorte de colas |
85 | 81 |
* @return SliderTextContainer |
86 | 82 |
*/ |
87 |
public SliderTextContainer getTrimSlider(){ |
|
88 |
if(trimSlider == null) |
|
83 |
public SliderTextContainer getTrimSlider() {
|
|
84 |
if (trimSlider == null)
|
|
89 | 85 |
trimSlider = new SliderTextContainer(0, 100, 50); |
90 | 86 |
return trimSlider; |
91 | 87 |
} |
92 |
|
|
93 |
public JPanel getPCheck(){ |
|
94 |
if(pCheck == null){
|
|
88 |
|
|
89 |
public JPanel getPCheck() {
|
|
90 |
if (pCheck == null) {
|
|
95 | 91 |
pCheck = new JPanel(); |
96 | 92 |
pCheck.setLayout(new GridBagLayout()); |
97 | 93 |
GridBagConstraints gbc = new GridBagConstraints(); |
... | ... | |
100 | 96 |
gbc.gridx = 0; |
101 | 97 |
gbc.gridy = 0; |
102 | 98 |
gbc.weightx = 8; |
103 |
|
|
99 |
|
|
104 | 100 |
GridBagConstraints gbc1 = new GridBagConstraints(); |
105 | 101 |
gbc1.insets = new Insets(9, 0, 9, 0); |
106 | 102 |
gbc1.gridx = 0; |
107 | 103 |
gbc1.gridy = 1; |
108 | 104 |
gbc1.anchor = GridBagConstraints.WEST; |
109 | 105 |
gbc1.weightx = 8; |
110 |
|
|
106 |
|
|
111 | 107 |
pCheck.add(getRemove(), gbc); |
112 | 108 |
pCheck.add(getTrim(), gbc1); |
113 | 109 |
} |
114 | 110 |
return pCheck; |
115 | 111 |
} |
116 |
|
|
112 |
|
|
117 | 113 |
/** |
118 | 114 |
* Obtiene el check de eliminar extremos |
119 | 115 |
* @return |
120 | 116 |
*/ |
121 |
public JCheckBox getRemove(){ |
|
122 |
if(remove == null) |
|
117 |
public JCheckBox getRemove() {
|
|
118 |
if (remove == null)
|
|
123 | 119 |
remove = new JCheckBox(PluginServices.getText(this, "eliminar_extremos")); |
124 | 120 |
return remove; |
125 | 121 |
} |
126 |
|
|
122 |
|
|
127 | 123 |
/** |
128 | 124 |
* Obtiene el check de recorte de colas |
129 | 125 |
* @return |
130 | 126 |
*/ |
131 |
public JCheckBox getTrim(){ |
|
132 |
if(trimCheck == null) |
|
127 |
public JCheckBox getTrim() {
|
|
128 |
if (trimCheck == null)
|
|
133 | 129 |
trimCheck = new JCheckBox(PluginServices.getText(this, "recorte_colas")); |
134 | 130 |
return trimCheck; |
135 | 131 |
} |
136 |
|
|
132 |
|
|
137 | 133 |
/** |
138 | 134 |
* Activa o desactiva el control |
139 | 135 |
* @param enable true activa y false desactiva los controles del panel |
140 | 136 |
*/ |
141 |
public void setControlEnabled(boolean enabled){ |
|
142 |
if(enabled && getTrim().isSelected()) |
|
137 |
public void setControlEnabled(boolean enabled) {
|
|
138 |
if (enabled && getTrim().isSelected())
|
|
143 | 139 |
trimSlider.setControlEnabled(true); |
144 | 140 |
else |
145 | 141 |
trimSlider.setControlEnabled(false); |
146 | 142 |
remove.setEnabled(enabled); |
147 | 143 |
trimCheck.setEnabled(enabled); |
148 | 144 |
} |
149 |
|
|
145 |
|
|
150 | 146 |
/** |
151 | 147 |
* Maneja eventos de activar y desactivar el panel |
152 | 148 |
*/ |
153 | 149 |
public void actionPerformed(ActionEvent e) { |
154 |
if(e.getSource() == getTrim()) |
|
150 |
if (e.getSource() == getTrim())
|
|
155 | 151 |
trimSlider.setControlEnabled(getTrim().isSelected()); |
156 |
|
|
157 | 152 |
} |
158 | 153 |
} |
159 |
|
|
154 |
|
|
160 | 155 |
/** |
161 | 156 |
* Panel con los controles de selecci?n para el tipo de filtro |
162 | 157 |
* de realce. |
163 | 158 |
* |
164 | 159 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
165 |
* |
|
166 | 160 |
*/ |
167 |
class SelectorPanel extends JPanel{ |
|
168 |
final private static long serialVersionUID = 0;
|
|
169 |
private JRadioButton rb = null;
|
|
170 |
|
|
161 |
class SelectorPanel extends JPanel {
|
|
162 |
private static final long serialVersionUID = 9036702518290091787L;
|
|
163 |
private JRadioButton rb = null; |
|
164 |
|
|
171 | 165 |
/** |
172 | 166 |
* Constructor |
173 | 167 |
*/ |
174 |
public SelectorPanel(){ |
|
168 |
public SelectorPanel() {
|
|
175 | 169 |
setLayout(new GridLayout(1, 1)); |
176 |
//setBorder(javax.swing.BorderFactory.createTitledBorder(null, null, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
177 | 170 |
add(getLineal()); |
178 | 171 |
} |
179 |
|
|
172 |
|
|
180 | 173 |
/** |
181 | 174 |
* Obtiene el radio button de selecci?n de filtro lineal |
182 | 175 |
* @return JRadioButton |
183 | 176 |
*/ |
184 |
private JRadioButton getLineal(){ |
|
185 |
if(rb == null){
|
|
177 |
private JRadioButton getLineal() {
|
|
178 |
if (rb == null) {
|
|
186 | 179 |
rb = new JRadioButton(PluginServices.getText(this, "lineal_directo")); |
187 | 180 |
rb.setSelected(true); |
188 | 181 |
} |
189 | 182 |
return rb; |
190 | 183 |
} |
191 |
|
|
184 |
|
|
192 | 185 |
/** |
193 | 186 |
* Activa o desactiva el control |
194 | 187 |
* @param enable true activa y false desactiva los controles del panel |
195 | 188 |
*/ |
196 |
public void setControlEnabled(boolean enabled){ |
|
189 |
public void setControlEnabled(boolean enabled) {
|
|
197 | 190 |
rb.setEnabled(enabled); |
198 | 191 |
} |
199 |
|
|
200 | 192 |
} |
201 |
|
|
193 |
|
|
202 | 194 |
/** |
203 | 195 |
* Contructor |
204 | 196 |
*/ |
205 |
public EnhancedWithTrimPanel(){ |
|
197 |
public EnhancedWithTrimPanel() {
|
|
206 | 198 |
super(); |
207 | 199 |
trimPanel = new TrimPanel(); |
208 | 200 |
selectorPanel = new SelectorPanel(); |
209 | 201 |
initialize(); |
210 | 202 |
} |
211 |
|
|
203 |
|
|
212 | 204 |
private void initialize() { |
213 | 205 |
setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "realce"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
214 | 206 |
setLayout(new BorderLayout()); |
... | ... | |
217 | 209 |
add(trimPanel, BorderLayout.SOUTH); |
218 | 210 |
getActive().addActionListener(this); |
219 | 211 |
} |
220 |
|
|
212 |
|
|
221 | 213 |
/** |
222 | 214 |
* Obtiene el check de activar |
223 | 215 |
* @return |
224 | 216 |
*/ |
225 |
public JCheckBox getActive(){ |
|
226 |
if(active == null){
|
|
217 |
public JCheckBox getActive() {
|
|
218 |
if (active == null) {
|
|
227 | 219 |
active = new JCheckBox(PluginServices.getText(this, "activar")); |
228 | 220 |
active.setSelected(false); |
229 | 221 |
this.setControlEnabled(false); |
230 | 222 |
} |
231 | 223 |
return active; |
232 | 224 |
} |
233 |
|
|
225 |
|
|
234 | 226 |
/** |
235 | 227 |
* Activa o desactiva el control |
236 | 228 |
* @param enable true activa y false desactiva los controles del panel |
237 | 229 |
*/ |
238 |
public void setControlEnabled(boolean enabled){ |
|
230 |
public void setControlEnabled(boolean enabled) {
|
|
239 | 231 |
getActive().setSelected(enabled); |
240 | 232 |
trimPanel.setControlEnabled(enabled); |
241 | 233 |
selectorPanel.setControlEnabled(enabled); |
242 | 234 |
} |
243 |
|
|
235 |
|
|
244 | 236 |
/** |
245 | 237 |
* Maneja eventos de activar y desactivar el panel |
246 | 238 |
*/ |
247 | 239 |
public void actionPerformed(ActionEvent e) { |
248 |
if(e.getSource() == getActive()){
|
|
249 |
if(getActive().isSelected()) |
|
240 |
if (e.getSource() == getActive()) {
|
|
241 |
if (getActive().isSelected())
|
|
250 | 242 |
setControlEnabled(true); |
251 | 243 |
else |
252 | 244 |
setControlEnabled(false); |
253 | 245 |
} |
254 | 246 |
} |
255 |
|
|
247 |
|
|
256 | 248 |
/** |
257 | 249 |
* Obtiene el valor de selecci?n del check de eliminar extremos |
258 | 250 |
* @return boolean, true si est? seleccionado y false si no lo est?. |
259 | 251 |
*/ |
260 |
public boolean isRemoveEndsSelected(){ |
|
252 |
public boolean isRemoveEndsSelected() {
|
|
261 | 253 |
return trimPanel.getRemove().isSelected(); |
262 | 254 |
} |
263 |
|
|
255 |
|
|
264 | 256 |
/** |
265 | 257 |
* Obtiene el valor de selecci?n del check de recorte de colas. |
266 |
* @return boolean, true si est? seleccionado y false si no lo est?.
|
|
258 |
* @return boolean, true si est? seleccionado y false si no lo est?. |
|
267 | 259 |
*/ |
268 |
public boolean isTailTrimCheckSelected(){ |
|
260 |
public boolean isTailTrimCheckSelected() {
|
|
269 | 261 |
return trimPanel.getTrim().isSelected(); |
270 | 262 |
} |
271 |
|
|
263 |
|
|
272 | 264 |
/** |
273 | 265 |
* Obtiene el valor de recorte de colas seleccionado en el slider |
274 | 266 |
* @return double |
275 | 267 |
*/ |
276 |
public double getTrimValue(){ |
|
268 |
public double getTrimValue() {
|
|
277 | 269 |
return trimPanel.getTrimSlider().getValue(); |
278 | 270 |
} |
Also available in: Unified diff