Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / properties / panels / BandSetupFileList.java @ 11180

History | View | Annotate | Download (7.07 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.gvsig.rastertools.properties.panels;
25

    
26
import java.awt.BorderLayout;
27
import java.awt.FlowLayout;
28
import java.util.Vector;
29

    
30
import javax.swing.JButton;
31
import javax.swing.JComboBox;
32
import javax.swing.JLabel;
33
import javax.swing.JList;
34
import javax.swing.JPanel;
35
import javax.swing.JScrollPane;
36

    
37
/**
38
 * Panel que contiene la lista de ficheros cargados desde donde se leen las bandas visualizadas.
39
 * Contiene controles para a?adir y eliminar los ficheros, as? como un control para seleccionar
40
 * el n?mero de bandas a visualizar.
41
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
42
 * @author Nacho Brodin (brodin_ign@gva.es)
43
 */
44
public class BandSetupFileList extends JPanel {
45
    final private static long serialVersionUID = 0;
46
    private JScrollPane jScrollPane = null;
47
    private JPanel jPanel = null;
48
    private JButton jButton2 = null;
49
    private JButton jButton3 = null;
50
    private Vector fileNames = null;
51
    private JList jList = null;
52
    private JPanel jPanel1 = null;
53
    private JComboBox jComboBox = null;
54
    private JPanel jPanel2 = null;
55
    
56
    /**
57
     * Variable accesible para la traducci?n.
58
     */
59
    public JLabel lbandasVisibles = null;
60

    
61
    /**
62
    * This is the default constructor
63
    */
64
    public BandSetupFileList() {
65
        super();
66
        initialize();
67
    }
68

    
69
    /**
70
     * This method initializes jScrollPane
71
     *
72
     * @return javax.swing.JScrollPane
73
     */
74
    private JScrollPane getJScrollPane() {
75
        if (jScrollPane == null) {
76
            jScrollPane = new JScrollPane();
77
            jScrollPane.setViewportView(getJList());
78
        }
79

    
80
        return jScrollPane;
81
    }
82

    
83
    /**
84
     * This method initializes jPanel
85
     *
86
     * @return javax.swing.JPanel
87
     */
88
    private JPanel getJPanel() {
89
        if (jPanel == null) {
90
            FlowLayout flowLayout2 = new FlowLayout();
91
            jPanel = new JPanel();
92
            jPanel.setLayout(flowLayout2);
93
            flowLayout2.setAlignment(java.awt.FlowLayout.RIGHT);
94
            jPanel.add(getJPanel1(), null);
95
        }
96

    
97
        return jPanel;
98
    }
99

    
100
    /**
101
     * This method initializes jButton2
102
     *
103
     * @return javax.swing.JButton
104
     */
105
    public JButton getJButtonAdd() {
106
        if (jButton2 == null) {
107
            jButton2 = new JButton("A?adir");
108
            jButton2.setPreferredSize(new java.awt.Dimension(80, 25));
109
        }
110

    
111
        return jButton2;
112
    }
113

    
114
    /**
115
     * This method initializes jButton3
116
     *
117
     * @return javax.swing.JButton
118
     */
119
    public JButton getJButtonRemove() {
120
        if (jButton3 == null) {
121
            jButton3 = new JButton("Eliminar");
122
            jButton3.setPreferredSize(new java.awt.Dimension(80, 25));
123
        }
124

    
125
        return jButton3;
126
    }
127

    
128
    /**
129
     * This method initializes jList
130
     *
131
     * @return javax.swing.JList
132
     */
133
    public JList getJList() {
134
        if (jList == null) {
135
            fileNames = new Vector();
136
            jList = new JList(fileNames);
137
        }
138

    
139
        return jList;
140
    }
141

    
142
    /**
143
     * This method initializes this
144
     *
145
     * @return void
146
     */
147
    private void initialize() {
148
        this.setLayout(new BorderLayout());
149
        this.setSize(300, 248);
150
        this.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
151
        this.add(getJPanel(), java.awt.BorderLayout.EAST);
152
    }
153

    
154
    /**
155
     * This method initializes jPanel1
156
     *
157
     * @return javax.swing.JPanel
158
     */
159
    private JPanel getJPanel1() {
160
        if (jPanel1 == null) {
161
            jPanel1 = new JPanel();
162
            jPanel1.setPreferredSize(new java.awt.Dimension(86, 180));
163
            jPanel1.add(getJButtonAdd(), null);
164
            jPanel1.add(getJButtonRemove(), null);
165
            jPanel1.add(getJPanel2(), null);
166
        }
167

    
168
        return jPanel1;
169
    }
170

    
171
    /**
172
     * A?ade el nombre de un fichero a la lista
173
     * @param fName
174
     */
175
    public void addFName(String fName) {
176
        fileNames.add(fName);
177
        showList();
178
    }
179

    
180
    /**
181
     * Elimina un fichero de la lista
182
     * @param fName
183
     */
184
    public void removeFName(String fName) {
185
        for (int i = 0; i < fileNames.size(); i++) {
186
            if (((String) fileNames.get(i)).endsWith(fName)) {
187
                fileNames.remove(i);
188
            }
189
        }
190

    
191
        showList();
192
    }
193

    
194
    /**
195
     * Elimina todos los ficheros de la lista
196
     */
197
    public void clear(){
198
            fileNames.clear();
199
            showList();
200
    }
201
    
202
    /**
203
     * Actualiza el contenido de la lista
204
     */
205
    private void showList(){
206
            jList = new JList(fileNames);
207
        jScrollPane.setViewportView(jList);
208
        jList.show();            
209
    }
210
    
211
    /**
212
     * Obtiene el n?mero de ficheros en la lista
213
     * @return
214
     */
215
    public int getNFiles() {
216
        return fileNames.size();
217
    }
218

    
219
    /**
220
     * Asigna al combo del n?mero de bandas la lista de ellas
221
     */
222
    public void setList(String[] list) {
223
        if (jComboBox != null) {
224
            jComboBox.removeAllItems();
225

    
226
            for (int i = 0; i < list.length; i++)
227
                jComboBox.addItem(list[i]);
228

    
229
            jComboBox.setSelectedIndex(list.length - 1);
230
        }
231
    }
232

    
233
    /**
234
     * This method initializes jComboBox
235
     *
236
     * @return javax.swing.JComboBox
237
     */
238
    public JComboBox getJComboBox() {
239
        if (jComboBox == null) {
240
            String[] list = { "1", "2", "3" };
241
            jComboBox = new JComboBox(list);
242
            jComboBox.setSelectedIndex(2);
243
            jComboBox.setPreferredSize(new java.awt.Dimension(36, 25));
244
        }
245

    
246
        return jComboBox;
247
    }
248

    
249
    /**
250
     * This method initializes jPanel2
251
     *
252
     * @return javax.swing.JPanel
253
     */
254
    private JPanel getJPanel2() {
255
        if (jPanel2 == null) {
256
            lbandasVisibles = new JLabel();
257
            jPanel2 = new JPanel();
258
            lbandasVisibles.setText("Bandas");
259
            jPanel2.add(lbandasVisibles, null);
260
            jPanel2.add(getJComboBox(), null);
261
        }
262

    
263
        return jPanel2;
264
    }
265
    
266
    public void setResize (int nWidth, int nHeight){
267
            this.jScrollPane.setSize(this.jScrollPane.getSize().width + 1, this.jScrollPane.getSize().height + 1);
268
            this.jList.setSize(this.jList.getSize().width + 1, this.jList.getSize().height + 1);
269
            this.setSize(428 + nWidth, 110 + nHeight/2);
270
    }
271
} //  @jve:decl-index=0:visual-constraint="10,10"