svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / extension / geometriespalette / GeometriesPalettePanelView.java @ 47621
History | View | Annotate | Download (8.21 KB)
1 |
package org.gvsig.app.extension.geometriespalette; |
---|---|
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.JComboBox; |
14 |
import javax.swing.JFrame; |
15 |
import javax.swing.JLabel; |
16 |
import javax.swing.JList; |
17 |
import javax.swing.JPanel; |
18 |
import javax.swing.JScrollPane; |
19 |
import javax.swing.JSpinner; |
20 |
import javax.swing.JTabbedPane; |
21 |
import javax.swing.JTextField; |
22 |
import javax.swing.border.EmptyBorder; |
23 |
|
24 |
|
25 |
public class GeometriesPalettePanelView extends JPanel |
26 |
{ |
27 |
JTabbedPane jtabbedpane1 = new JTabbedPane(); |
28 |
JList lstData = new JList(); |
29 |
JSpinner spnSize = new JSpinner(); |
30 |
JTextField txtDataFilter = new JTextField(); |
31 |
JButton btnDataFilter = new JButton(); |
32 |
JComboBox cboLabel = new JComboBox(); |
33 |
JLabel lblEtiqueta = new JLabel(); |
34 |
JComboBox cboColor = new JComboBox(); |
35 |
JLabel lblColor = new JLabel(); |
36 |
JLabel lblFilter = new JLabel(); |
37 |
JButton btnFilter = new JButton(); |
38 |
JTextField txtFilter = new JTextField(); |
39 |
|
40 |
/**
|
41 |
* Default constructor
|
42 |
*/
|
43 |
public GeometriesPalettePanelView()
|
44 |
{ |
45 |
initializePanel(); |
46 |
} |
47 |
|
48 |
/**
|
49 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
50 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
51 |
* @param cols an array of column indices in the first row where fill components should be added.
|
52 |
* @param rows an array of row indices in the first column where fill components should be added.
|
53 |
*/
|
54 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
55 |
{ |
56 |
Dimension filler = new Dimension(10,10); |
57 |
|
58 |
boolean filled_cell_11 = false; |
59 |
CellConstraints cc = new CellConstraints();
|
60 |
if ( cols.length > 0 && rows.length > 0 ) |
61 |
{ |
62 |
if ( cols[0] == 1 && rows[0] == 1 ) |
63 |
{ |
64 |
/** add a rigid area */
|
65 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
66 |
filled_cell_11 = true;
|
67 |
} |
68 |
} |
69 |
|
70 |
for( int index = 0; index < cols.length; index++ ) |
71 |
{ |
72 |
if ( cols[index] == 1 && filled_cell_11 ) |
73 |
{ |
74 |
continue;
|
75 |
} |
76 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
77 |
} |
78 |
|
79 |
for( int index = 0; index < rows.length; index++ ) |
80 |
{ |
81 |
if ( rows[index] == 1 && filled_cell_11 ) |
82 |
{ |
83 |
continue;
|
84 |
} |
85 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
86 |
} |
87 |
|
88 |
} |
89 |
|
90 |
/**
|
91 |
* Helper method to load an image file from the CLASSPATH
|
92 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
93 |
* @return an ImageIcon instance with the specified image file
|
94 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
95 |
*/
|
96 |
public ImageIcon loadImage( String imageName ) |
97 |
{ |
98 |
try
|
99 |
{ |
100 |
ClassLoader classloader = getClass().getClassLoader();
|
101 |
java.net.URL url = classloader.getResource( imageName ); |
102 |
if ( url != null ) |
103 |
{ |
104 |
ImageIcon icon = new ImageIcon( url ); |
105 |
return icon;
|
106 |
} |
107 |
} |
108 |
catch( Exception e ) |
109 |
{ |
110 |
e.printStackTrace(); |
111 |
} |
112 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
113 |
} |
114 |
|
115 |
/**
|
116 |
* Method for recalculating the component orientation for
|
117 |
* right-to-left Locales.
|
118 |
* @param orientation the component orientation to be applied
|
119 |
*/
|
120 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
121 |
{ |
122 |
// Not yet implemented...
|
123 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
124 |
super.applyComponentOrientation(orientation);
|
125 |
} |
126 |
|
127 |
public JPanel createPanel() |
128 |
{ |
129 |
JPanel jpanel1 = new JPanel(); |
130 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE"); |
131 |
CellConstraints cc = new CellConstraints();
|
132 |
jpanel1.setLayout(formlayout1); |
133 |
|
134 |
jtabbedpane1.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
|
135 |
jtabbedpane1.setTabPlacement(JTabbedPane.BOTTOM);
|
136 |
jtabbedpane1.addTab("Elements",null,createPanel1()); |
137 |
jtabbedpane1.addTab("Config",null,createPanel3()); |
138 |
jpanel1.add(jtabbedpane1,cc.xy(2,2)); |
139 |
|
140 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 }); |
141 |
return jpanel1;
|
142 |
} |
143 |
|
144 |
public JPanel createPanel1() |
145 |
{ |
146 |
JPanel jpanel1 = new JPanel(); |
147 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE"); |
148 |
CellConstraints cc = new CellConstraints();
|
149 |
jpanel1.setLayout(formlayout1); |
150 |
|
151 |
lstData.setName("lstData");
|
152 |
JScrollPane jscrollpane1 = new JScrollPane(); |
153 |
jscrollpane1.setViewportView(lstData); |
154 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
155 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
156 |
jpanel1.add(jscrollpane1,cc.xy(1,3)); |
157 |
|
158 |
spnSize.setName("spnSize");
|
159 |
jpanel1.add(spnSize,cc.xy(1,5)); |
160 |
|
161 |
jpanel1.add(createPanel2(),cc.xy(1,1)); |
162 |
addFillComponents(jpanel1,new int[]{ 1 },new int[]{ 1,2,4 }); |
163 |
return jpanel1;
|
164 |
} |
165 |
|
166 |
public JPanel createPanel2() |
167 |
{ |
168 |
JPanel jpanel1 = new JPanel(); |
169 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
170 |
CellConstraints cc = new CellConstraints();
|
171 |
jpanel1.setLayout(formlayout1); |
172 |
|
173 |
txtDataFilter.setName("txtDataFilter");
|
174 |
jpanel1.add(txtDataFilter,cc.xy(1,1)); |
175 |
|
176 |
btnDataFilter.setActionCommand("...");
|
177 |
btnDataFilter.setName("btnDataFilter");
|
178 |
btnDataFilter.setText("...");
|
179 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
180 |
btnDataFilter.setBorder(emptyborder1); |
181 |
jpanel1.add(btnDataFilter,cc.xy(3,1)); |
182 |
|
183 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
184 |
return jpanel1;
|
185 |
} |
186 |
|
187 |
public JPanel createPanel3() |
188 |
{ |
189 |
JPanel jpanel1 = new JPanel(); |
190 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
191 |
CellConstraints cc = new CellConstraints();
|
192 |
jpanel1.setLayout(formlayout1); |
193 |
|
194 |
cboLabel.setName("cboLabel");
|
195 |
jpanel1.add(cboLabel,cc.xy(2,4)); |
196 |
|
197 |
lblEtiqueta.setName("lblEtiqueta");
|
198 |
lblEtiqueta.setText("Label");
|
199 |
jpanel1.add(lblEtiqueta,cc.xy(2,2)); |
200 |
|
201 |
cboColor.setName("cboColor");
|
202 |
jpanel1.add(cboColor,cc.xy(2,8)); |
203 |
|
204 |
lblColor.setName("lblColor");
|
205 |
lblColor.setText("Color");
|
206 |
jpanel1.add(lblColor,cc.xy(2,6)); |
207 |
|
208 |
lblFilter.setName("lblFilter");
|
209 |
lblFilter.setText("Filtro");
|
210 |
jpanel1.add(lblFilter,cc.xy(2,10)); |
211 |
|
212 |
jpanel1.add(createPanel4(),cc.xy(2,12)); |
213 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }); |
214 |
return jpanel1;
|
215 |
} |
216 |
|
217 |
public JPanel createPanel4() |
218 |
{ |
219 |
JPanel jpanel1 = new JPanel(); |
220 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
221 |
CellConstraints cc = new CellConstraints();
|
222 |
jpanel1.setLayout(formlayout1); |
223 |
|
224 |
btnFilter.setActionCommand("...");
|
225 |
btnFilter.setName("btnFilter");
|
226 |
btnFilter.setText("...");
|
227 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
228 |
btnFilter.setBorder(emptyborder1); |
229 |
jpanel1.add(btnFilter,cc.xy(3,1)); |
230 |
|
231 |
txtFilter.setName("txtFilter");
|
232 |
jpanel1.add(txtFilter,cc.xy(1,1)); |
233 |
|
234 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
235 |
return jpanel1;
|
236 |
} |
237 |
|
238 |
/**
|
239 |
* Initializer
|
240 |
*/
|
241 |
protected void initializePanel() |
242 |
{ |
243 |
setLayout(new BorderLayout()); |
244 |
add(createPanel(), BorderLayout.CENTER);
|
245 |
} |
246 |
|
247 |
|
248 |
} |