svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / filter / ui / FilterMainPanel.java @ 19285
History | View | Annotate | Download (5.18 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.rastertools.filter.ui; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
import java.awt.Dimension; |
23 |
|
24 |
import javax.swing.JLabel; |
25 |
import javax.swing.JPanel; |
26 |
import javax.swing.JTextField; |
27 |
|
28 |
import org.gvsig.gui.beans.treelist.TreeListContainer; |
29 |
import org.gvsig.raster.RasterLibrary; |
30 |
import org.gvsig.raster.beans.previewbase.IUserPanelInterface; |
31 |
import org.gvsig.raster.util.PropertyEvent; |
32 |
import org.gvsig.raster.util.PropertyListener; |
33 |
import org.gvsig.rastertools.filter.FilterListener; |
34 |
|
35 |
import com.iver.andami.PluginServices; |
36 |
/**
|
37 |
*
|
38 |
* @version 22/02/2008
|
39 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
40 |
*/
|
41 |
public class FilterMainPanel extends JPanel implements PropertyListener, IUserPanelInterface { |
42 |
private TreeListContainer treeListContainer = null; |
43 |
private JPanel centralPanel = null; |
44 |
private JPanel jPNameFile = null; |
45 |
private JLabel labelFilename = null; |
46 |
private JTextField filenameTextField = null; |
47 |
private FilterListener filterListener = null; |
48 |
|
49 |
public FilterMainPanel(FilterListener filterListener) {
|
50 |
this.filterListener = filterListener;
|
51 |
initialize(); |
52 |
translate(); |
53 |
} |
54 |
|
55 |
private void initialize() { |
56 |
setPreferredSize(new Dimension(390,0)); |
57 |
setLayout(new BorderLayout(5, 5)); |
58 |
add(getTreeListContainer(), BorderLayout.WEST);
|
59 |
add(getCentralPanel(), BorderLayout.CENTER);
|
60 |
} |
61 |
|
62 |
/*
|
63 |
* (non-Javadoc)
|
64 |
* @see org.gvsig.raster.beans.previewbase.IUserPanelInterface#getPanel()
|
65 |
*/
|
66 |
public JPanel getPanel() { |
67 |
return this; |
68 |
} |
69 |
|
70 |
/**
|
71 |
* Seccion donde ir?n todas las traducciones invariables del componente
|
72 |
*/
|
73 |
private void translate() { |
74 |
getLabelFilename().setText(PluginServices.getText(this, "nombre_capa") + ":"); |
75 |
} |
76 |
|
77 |
/**
|
78 |
* This method initializes jPanel
|
79 |
* @return javax.swing.JPanel
|
80 |
*/
|
81 |
public TreeListContainer getTreeListContainer() {
|
82 |
if (treeListContainer == null) { |
83 |
treeListContainer = new TreeListContainer();
|
84 |
treeListContainer.getTree().expandRow(0);
|
85 |
treeListContainer.addTreeListListener(filterListener); |
86 |
treeListContainer.addChangeSelectionListener(filterListener); |
87 |
} |
88 |
return treeListContainer;
|
89 |
} |
90 |
|
91 |
/**
|
92 |
* Obtener y generar el JPanel central que contendr? las propiedades
|
93 |
* @return
|
94 |
*/
|
95 |
public JPanel getCentralPanel() { |
96 |
if (centralPanel == null) { |
97 |
centralPanel = new JPanel(); |
98 |
centralPanel.setLayout(new BorderLayout()); |
99 |
centralPanel.add(getJPNameFile(), BorderLayout.SOUTH);
|
100 |
} |
101 |
return centralPanel;
|
102 |
} |
103 |
|
104 |
/**
|
105 |
* This method initializes filenameTextField
|
106 |
*
|
107 |
* @return javax.swing.JTextField
|
108 |
*/
|
109 |
public JTextField getFilenameTextField() { |
110 |
if (filenameTextField == null) { |
111 |
filenameTextField = new JTextField(); |
112 |
filenameTextField.setPreferredSize(new Dimension(150, filenameTextField.getPreferredSize().height)); |
113 |
RasterLibrary.addOnlyLayerNameListener(this);
|
114 |
} |
115 |
return filenameTextField;
|
116 |
} |
117 |
|
118 |
private JLabel getLabelFilename() { |
119 |
if (labelFilename == null) { |
120 |
labelFilename = new JLabel(); |
121 |
} |
122 |
return labelFilename;
|
123 |
} |
124 |
|
125 |
/**
|
126 |
* This method initializes jPNameFile
|
127 |
*
|
128 |
* @return javax.swing.JPanel
|
129 |
*/
|
130 |
private JPanel getJPNameFile() { |
131 |
if (jPNameFile == null) { |
132 |
jPNameFile = new JPanel(); |
133 |
jPNameFile.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "nombre_capa"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
134 |
jPNameFile.add(getLabelFilename()); |
135 |
jPNameFile.add(getFilenameTextField()); |
136 |
updateNewLayerText(); |
137 |
} |
138 |
return jPNameFile;
|
139 |
} |
140 |
|
141 |
/*
|
142 |
* (non-Javadoc)
|
143 |
* @see org.gvsig.raster.beans.previewbase.IUserPanelInterface#getTitle()
|
144 |
*/
|
145 |
public String getTitle() { |
146 |
return "Filtros"; |
147 |
} |
148 |
|
149 |
/**
|
150 |
* Cuando alguien ha cambiado la propiedad del nombre de la
|
151 |
* capa se actualiza autom?ticamente
|
152 |
*/
|
153 |
public void actionValueChanged(PropertyEvent e) { |
154 |
updateNewLayerText(); |
155 |
} |
156 |
|
157 |
/**
|
158 |
* Especificar el nombre de la nueva capa para el recuadro de texto asign?ndo
|
159 |
* en cada llamada un nombre consecutivo.
|
160 |
*/
|
161 |
public void updateNewLayerText() { |
162 |
getFilenameTextField().setText(RasterLibrary.getOnlyLayerName()); |
163 |
} |
164 |
|
165 |
public void setFilenameEnabled(boolean value) { |
166 |
getFilenameTextField().setEnabled(value); |
167 |
getLabelFilename().setEnabled(value); |
168 |
} |
169 |
} |