gvsig-raster / org.gvsig.raster.wmts / trunk / org.gvsig.raster.wmts / org.gvsig.raster.wmts.swing / org.gvsig.raster.wmts.swing.impl / src / main / java / org / gvsig / raster / wmts / swing / impl / panel / dimension / DimensionPanel.java @ 2613
History | View | Annotate | Download (4.27 KB)
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.wmts.swing.impl.panel.dimension; |
23 |
|
24 |
import java.awt.GridBagConstraints; |
25 |
import java.awt.GridBagLayout; |
26 |
import java.util.List; |
27 |
|
28 |
import javax.swing.JPanel; |
29 |
|
30 |
import org.gvsig.raster.wmts.ogc.struct.WMTSDimension; |
31 |
|
32 |
/**
|
33 |
* Dimension tab panel
|
34 |
*
|
35 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
36 |
*/
|
37 |
public class DimensionPanel extends JPanel { |
38 |
private static final long serialVersionUID = 1L; |
39 |
private DimensionComboPanel dimensionPanel = null; |
40 |
private ValuesDimensionListPanel valuesDimensionListPanel = null; |
41 |
private SelectedValuePanel selectedValuePanel = null; |
42 |
private List<WMTSDimension> dataModel = null; |
43 |
|
44 |
|
45 |
public DimensionPanel() {
|
46 |
init(); |
47 |
} |
48 |
|
49 |
public void init() { |
50 |
setLayout(new GridBagLayout()); |
51 |
|
52 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
53 |
gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
|
54 |
gridBagConstraints1.anchor = GridBagConstraints.CENTER;
|
55 |
gridBagConstraints1.gridx = 0;
|
56 |
gridBagConstraints1.gridy = 0;
|
57 |
gridBagConstraints1.weightx = 1.0;
|
58 |
gridBagConstraints1.weighty = 0.0;
|
59 |
gridBagConstraints1.insets = new java.awt.Insets(2,2,2,2); |
60 |
add(getDimensionPanel(), gridBagConstraints1); |
61 |
|
62 |
gridBagConstraints1.fill = GridBagConstraints.BOTH;
|
63 |
gridBagConstraints1.anchor = GridBagConstraints.CENTER;
|
64 |
gridBagConstraints1.gridx = 0;
|
65 |
gridBagConstraints1.gridy = 1;
|
66 |
gridBagConstraints1.weightx = 1.0;
|
67 |
gridBagConstraints1.weighty = 1.0;
|
68 |
add(getValuesDimensionListPanel(), gridBagConstraints1); |
69 |
|
70 |
gridBagConstraints1.fill = GridBagConstraints.BOTH;
|
71 |
gridBagConstraints1.gridx = 0;
|
72 |
gridBagConstraints1.gridy = 2;
|
73 |
gridBagConstraints1.weighty = 0.0;
|
74 |
add(getSelectedValuePanel(), gridBagConstraints1); |
75 |
} |
76 |
|
77 |
public void setDimensions(List<WMTSDimension> dimensions) { |
78 |
this.dataModel = dimensions;
|
79 |
getDimensionPanel().clearDimensions(); |
80 |
|
81 |
for (int i = 0; i < dimensions.size(); i++) { |
82 |
WMTSDimension dim = dimensions.get(i); |
83 |
getDimensionPanel().getDimensionList().addItem(dim.getIdentifier()); |
84 |
} |
85 |
fillDefaultValuesOfSelectedDimension(); |
86 |
} |
87 |
|
88 |
private void fillDefaultValuesOfSelectedDimension() { |
89 |
String selectedDimension = getDimensionPanel().getSelectedDimension();
|
90 |
getValuesDimensionListPanel().clearList(); |
91 |
getSelectedValuePanel().getSelectedValue().setText("");
|
92 |
|
93 |
for (int i = 0; i < dataModel.size(); i++) { |
94 |
WMTSDimension dim = dataModel.get(i); |
95 |
if(dim.getIdentifier().equals(selectedDimension)) {
|
96 |
for (int j = 0; j < dim.getValueList().size(); j++) { |
97 |
getValuesDimensionListPanel().addElement(dim.getValueList().get(j)); |
98 |
} |
99 |
} |
100 |
getSelectedValuePanel().setValue(dim.getDefaultValue()); |
101 |
} |
102 |
} |
103 |
|
104 |
public void clearGraphicComponents() { |
105 |
getDimensionPanel().getDimensionList().removeAllItems(); |
106 |
getValuesDimensionListPanel().clearList(); |
107 |
getSelectedValuePanel().getSelectedValue().setText("");
|
108 |
} |
109 |
|
110 |
public DimensionComboPanel getDimensionPanel() {
|
111 |
if(dimensionPanel == null) { |
112 |
dimensionPanel = new DimensionComboPanel();
|
113 |
} |
114 |
return dimensionPanel;
|
115 |
} |
116 |
|
117 |
public ValuesDimensionListPanel getValuesDimensionListPanel() {
|
118 |
if(valuesDimensionListPanel == null) { |
119 |
valuesDimensionListPanel = new ValuesDimensionListPanel();
|
120 |
} |
121 |
return valuesDimensionListPanel;
|
122 |
} |
123 |
|
124 |
public SelectedValuePanel getSelectedValuePanel() {
|
125 |
if (selectedValuePanel == null) { |
126 |
selectedValuePanel = new SelectedValuePanel();
|
127 |
} |
128 |
return selectedValuePanel;
|
129 |
} |
130 |
|
131 |
} |