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