svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.library / org.gvsig.raster / org.gvsig.raster.swing / org.gvsig.raster.swing.buffer / org.gvsig.raster.swing.buffer.impl / src / main / java / org / gvsig / raster / swing / buffer / impl / histogram / HistogramPanelView.java @ 43803
History | View | Annotate | Download (7.65 KB)
1 |
package org.gvsig.raster.swing.buffer.impl.histogram; |
---|---|
2 |
|
3 |
import com.jeta.open.i18n.I18NUtils; |
4 |
import com.jgoodies.forms.layout.CellConstraints; |
5 |
import com.jgoodies.forms.layout.FormLayout; |
6 |
import java.awt.BorderLayout; |
7 |
import java.awt.ComponentOrientation; |
8 |
import java.awt.Container; |
9 |
import java.awt.Dimension; |
10 |
import javax.swing.Box; |
11 |
import javax.swing.ImageIcon; |
12 |
import javax.swing.JButton; |
13 |
import javax.swing.JCheckBox; |
14 |
import javax.swing.JComboBox; |
15 |
import javax.swing.JFrame; |
16 |
import javax.swing.JLabel; |
17 |
import javax.swing.JPanel; |
18 |
import javax.swing.JScrollPane; |
19 |
import javax.swing.JTable; |
20 |
|
21 |
|
22 |
public class HistogramPanelView extends JPanel |
23 |
{ |
24 |
JPanel pnlHistogram = new JPanel(); |
25 |
JLabel lblSource = new JLabel(); |
26 |
JLabel lblType = new JLabel(); |
27 |
JComboBox cmbSource = new JComboBox(); |
28 |
JComboBox cmbType = new JComboBox(); |
29 |
JButton btnAllBands = new JButton(); |
30 |
JButton btnClearBands = new JButton(); |
31 |
JLabel lblBands = new JLabel(); |
32 |
JTable tblBands = new JTable(); |
33 |
JTable tblStatistics = new JTable(); |
34 |
JCheckBox chkShowStatistics = new JCheckBox(); |
35 |
JCheckBox chkRemoveTails = new JCheckBox(); |
36 |
JButton btnExportTable = new JButton(); |
37 |
|
38 |
/**
|
39 |
* Default constructor
|
40 |
*/
|
41 |
public HistogramPanelView()
|
42 |
{ |
43 |
initializePanel(); |
44 |
} |
45 |
|
46 |
/**
|
47 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
48 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
49 |
* @param cols an array of column indices in the first row where fill components should be added.
|
50 |
* @param rows an array of row indices in the first column where fill components should be added.
|
51 |
*/
|
52 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
53 |
{ |
54 |
Dimension filler = new Dimension(10,10); |
55 |
|
56 |
boolean filled_cell_11 = false; |
57 |
CellConstraints cc = new CellConstraints();
|
58 |
if ( cols.length > 0 && rows.length > 0 ) |
59 |
{ |
60 |
if ( cols[0] == 1 && rows[0] == 1 ) |
61 |
{ |
62 |
/** add a rigid area */
|
63 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
64 |
filled_cell_11 = true;
|
65 |
} |
66 |
} |
67 |
|
68 |
for( int index = 0; index < cols.length; index++ ) |
69 |
{ |
70 |
if ( cols[index] == 1 && filled_cell_11 ) |
71 |
{ |
72 |
continue;
|
73 |
} |
74 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
75 |
} |
76 |
|
77 |
for( int index = 0; index < rows.length; index++ ) |
78 |
{ |
79 |
if ( rows[index] == 1 && filled_cell_11 ) |
80 |
{ |
81 |
continue;
|
82 |
} |
83 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
84 |
} |
85 |
|
86 |
} |
87 |
|
88 |
/**
|
89 |
* Helper method to load an image file from the CLASSPATH
|
90 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
91 |
* @return an ImageIcon instance with the specified image file
|
92 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
93 |
*/
|
94 |
public ImageIcon loadImage( String imageName ) |
95 |
{ |
96 |
try
|
97 |
{ |
98 |
ClassLoader classloader = getClass().getClassLoader();
|
99 |
java.net.URL url = classloader.getResource( imageName ); |
100 |
if ( url != null ) |
101 |
{ |
102 |
ImageIcon icon = new ImageIcon( url ); |
103 |
return icon;
|
104 |
} |
105 |
} |
106 |
catch( Exception e ) |
107 |
{ |
108 |
e.printStackTrace(); |
109 |
} |
110 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
111 |
} |
112 |
|
113 |
/**
|
114 |
* Method for recalculating the component orientation for
|
115 |
* right-to-left Locales.
|
116 |
* @param orientation the component orientation to be applied
|
117 |
*/
|
118 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
119 |
{ |
120 |
// Not yet implemented...
|
121 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
122 |
super.applyComponentOrientation(orientation);
|
123 |
} |
124 |
|
125 |
public JPanel createPanel() |
126 |
{ |
127 |
JPanel jpanel1 = new JPanel(); |
128 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
129 |
CellConstraints cc = new CellConstraints();
|
130 |
jpanel1.setLayout(formlayout1); |
131 |
|
132 |
pnlHistogram.setName("pnlHistogram");
|
133 |
jpanel1.add(pnlHistogram,cc.xywh(2,10,8,1)); |
134 |
|
135 |
lblSource.setName("lblSource");
|
136 |
lblSource.setText("_source");
|
137 |
lblSource.setToolTipText("_source");
|
138 |
jpanel1.add(lblSource,cc.xy(2,2)); |
139 |
|
140 |
lblType.setName("lblType");
|
141 |
lblType.setText("_type");
|
142 |
lblType.setToolTipText("_type");
|
143 |
jpanel1.add(lblType,cc.xy(2,4)); |
144 |
|
145 |
cmbSource.setName("cmbSource");
|
146 |
jpanel1.add(cmbSource,cc.xy(4,2)); |
147 |
|
148 |
cmbType.setName("cmbType");
|
149 |
jpanel1.add(cmbType,cc.xy(4,4)); |
150 |
|
151 |
btnAllBands.setActionCommand("_all_bands");
|
152 |
btnAllBands.setName("btnAllBands");
|
153 |
btnAllBands.setText("_all_bands");
|
154 |
btnAllBands.setToolTipText("_select_all_bands");
|
155 |
jpanel1.add(btnAllBands,cc.xy(4,6)); |
156 |
|
157 |
btnClearBands.setActionCommand("_clear_bands");
|
158 |
btnClearBands.setName("btnClearBands");
|
159 |
btnClearBands.setText("_clear_bands");
|
160 |
btnClearBands.setToolTipText("_unselected_all_bands");
|
161 |
jpanel1.add(btnClearBands,cc.xy(4,8)); |
162 |
|
163 |
lblBands.setName("lblBands");
|
164 |
lblBands.setText("_bands");
|
165 |
lblBands.setToolTipText("_bands");
|
166 |
jpanel1.add(lblBands,new CellConstraints(6,2,4,1,CellConstraints.CENTER,CellConstraints.DEFAULT)); |
167 |
|
168 |
tblBands.setName("tblBands");
|
169 |
tblBands.setRowSelectionAllowed(false);
|
170 |
JScrollPane jscrollpane1 = new JScrollPane(); |
171 |
jscrollpane1.setViewportView(tblBands); |
172 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
173 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
174 |
jpanel1.add(jscrollpane1,cc.xywh(6,4,4,5)); |
175 |
|
176 |
tblStatistics.setAutoscrolls(false);
|
177 |
tblStatistics.setName("tblStatistics");
|
178 |
tblStatistics.setRowSelectionAllowed(false);
|
179 |
JScrollPane jscrollpane2 = new JScrollPane(); |
180 |
jscrollpane2.setViewportView(tblStatistics); |
181 |
jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
182 |
jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
183 |
jpanel1.add(jscrollpane2,cc.xywh(2,12,5,5)); |
184 |
|
185 |
chkShowStatistics.setActionCommand("RGB");
|
186 |
chkShowStatistics.setName("chkShowStatistics");
|
187 |
chkShowStatistics.setSelected(true);
|
188 |
chkShowStatistics.setText("_show_statistics");
|
189 |
chkShowStatistics.setToolTipText("_show_statistics ");
|
190 |
jpanel1.add(chkShowStatistics,cc.xy(8,16)); |
191 |
|
192 |
chkRemoveTails.setActionCommand("_remove_tails");
|
193 |
chkRemoveTails.setName("chkRemoveTails");
|
194 |
chkRemoveTails.setText("_remove_tails");
|
195 |
chkRemoveTails.setToolTipText("_remove_tails");
|
196 |
jpanel1.add(chkRemoveTails,cc.xy(8,14)); |
197 |
|
198 |
btnExportTable.setActionCommand("_export_table");
|
199 |
btnExportTable.setName("btnExportTable");
|
200 |
btnExportTable.setText("_export_table");
|
201 |
btnExportTable.setToolTipText("_export_table");
|
202 |
jpanel1.add(btnExportTable,cc.xy(8,12)); |
203 |
|
204 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9,10 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 }); |
205 |
return jpanel1;
|
206 |
} |
207 |
|
208 |
/**
|
209 |
* Initializer
|
210 |
*/
|
211 |
protected void initializePanel() |
212 |
{ |
213 |
setLayout(new BorderLayout()); |
214 |
add(createPanel(), BorderLayout.CENTER);
|
215 |
} |
216 |
|
217 |
|
218 |
} |