svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / legend / gui / GeneralLayerPropertiesPageView.java @ 42506
History | View | Annotate | Download (9.35 KB)
1 |
package org.gvsig.app.project.documents.view.legend.gui; |
---|---|
2 |
|
3 |
import com.jeta.forms.components.border.TitledBorderLabel; |
4 |
import com.jeta.open.i18n.I18NUtils; |
5 |
import com.jgoodies.forms.layout.CellConstraints; |
6 |
import com.jgoodies.forms.layout.FormLayout; |
7 |
import java.awt.BorderLayout; |
8 |
import java.awt.Color; |
9 |
import java.awt.ComponentOrientation; |
10 |
import java.awt.Container; |
11 |
import java.awt.Dimension; |
12 |
import javax.swing.Box; |
13 |
import javax.swing.ButtonGroup; |
14 |
import javax.swing.ImageIcon; |
15 |
import javax.swing.JFrame; |
16 |
import javax.swing.JLabel; |
17 |
import javax.swing.JPanel; |
18 |
import javax.swing.JRadioButton; |
19 |
import javax.swing.JScrollPane; |
20 |
import javax.swing.JTextArea; |
21 |
import javax.swing.JTextField; |
22 |
|
23 |
|
24 |
public class GeneralLayerPropertiesPageView extends JPanel |
25 |
{ |
26 |
JLabel lblName = new JLabel(); |
27 |
TitledBorderLabel lblRangeOfScales = new TitledBorderLabel();
|
28 |
JRadioButton rdoShowAlways = new JRadioButton(); |
29 |
ButtonGroup buttongroup1 = new ButtonGroup(); |
30 |
JRadioButton rdoShowConditionedToTheScale = new JRadioButton(); |
31 |
TitledBorderLabel lblProperties = new TitledBorderLabel();
|
32 |
JTextArea txtProperties = new JTextArea(); |
33 |
JLabel lblIsLessThan = new JLabel(); |
34 |
JLabel lblIsGreaterThan = new JLabel(); |
35 |
JLabel lblFullScale = new JLabel(); |
36 |
JLabel lblMinumunScale = new JLabel(); |
37 |
JTextField txtIsLessThan = new JTextField(); |
38 |
JTextField txtIsGreaterThan = new JTextField(); |
39 |
JTextField txtName = new JTextField(); |
40 |
TitledBorderLabel lblDataSource = new TitledBorderLabel();
|
41 |
JLabel lblSourceType = new JLabel(); |
42 |
JLabel lblSource = new JLabel(); |
43 |
JTextField txtSourceType = new JTextField(); |
44 |
JTextField txtSource = new JTextField(); |
45 |
|
46 |
/**
|
47 |
* Default constructor
|
48 |
*/
|
49 |
public GeneralLayerPropertiesPageView()
|
50 |
{ |
51 |
initializePanel(); |
52 |
} |
53 |
|
54 |
/**
|
55 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
56 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
57 |
* @param cols an array of column indices in the first row where fill components should be added.
|
58 |
* @param rows an array of row indices in the first column where fill components should be added.
|
59 |
*/
|
60 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
61 |
{ |
62 |
Dimension filler = new Dimension(10,10); |
63 |
|
64 |
boolean filled_cell_11 = false; |
65 |
CellConstraints cc = new CellConstraints();
|
66 |
if ( cols.length > 0 && rows.length > 0 ) |
67 |
{ |
68 |
if ( cols[0] == 1 && rows[0] == 1 ) |
69 |
{ |
70 |
/** add a rigid area */
|
71 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
72 |
filled_cell_11 = true;
|
73 |
} |
74 |
} |
75 |
|
76 |
for( int index = 0; index < cols.length; index++ ) |
77 |
{ |
78 |
if ( cols[index] == 1 && filled_cell_11 ) |
79 |
{ |
80 |
continue;
|
81 |
} |
82 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
83 |
} |
84 |
|
85 |
for( int index = 0; index < rows.length; index++ ) |
86 |
{ |
87 |
if ( rows[index] == 1 && filled_cell_11 ) |
88 |
{ |
89 |
continue;
|
90 |
} |
91 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
92 |
} |
93 |
|
94 |
} |
95 |
|
96 |
/**
|
97 |
* Helper method to load an image file from the CLASSPATH
|
98 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
99 |
* @return an ImageIcon instance with the specified image file
|
100 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
101 |
*/
|
102 |
public ImageIcon loadImage( String imageName ) |
103 |
{ |
104 |
try
|
105 |
{ |
106 |
ClassLoader classloader = getClass().getClassLoader();
|
107 |
java.net.URL url = classloader.getResource( imageName ); |
108 |
if ( url != null ) |
109 |
{ |
110 |
ImageIcon icon = new ImageIcon( url ); |
111 |
return icon;
|
112 |
} |
113 |
} |
114 |
catch( Exception e ) |
115 |
{ |
116 |
e.printStackTrace(); |
117 |
} |
118 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
119 |
} |
120 |
|
121 |
/**
|
122 |
* Method for recalculating the component orientation for
|
123 |
* right-to-left Locales.
|
124 |
* @param orientation the component orientation to be applied
|
125 |
*/
|
126 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
127 |
{ |
128 |
// Not yet implemented...
|
129 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
130 |
super.applyComponentOrientation(orientation);
|
131 |
} |
132 |
|
133 |
public JPanel createPanel() |
134 |
{ |
135 |
JPanel jpanel1 = new JPanel(); |
136 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE"); |
137 |
CellConstraints cc = new CellConstraints();
|
138 |
jpanel1.setLayout(formlayout1); |
139 |
|
140 |
lblName.setName("lblName");
|
141 |
lblName.setText("Name:");
|
142 |
jpanel1.add(lblName,cc.xywh(2,2,2,1)); |
143 |
|
144 |
lblRangeOfScales.setName("lblRangeOfScales");
|
145 |
lblRangeOfScales.setText("Range of scales");
|
146 |
jpanel1.add(lblRangeOfScales,cc.xywh(2,5,2,1)); |
147 |
|
148 |
rdoShowAlways.setActionCommand("Show always");
|
149 |
rdoShowAlways.setName("rdoShowAlways");
|
150 |
rdoShowAlways.setText("Show always");
|
151 |
buttongroup1.add(rdoShowAlways); |
152 |
jpanel1.add(rdoShowAlways,cc.xywh(2,6,2,1)); |
153 |
|
154 |
rdoShowConditionedToTheScale.setActionCommand("Do not show the layer when the scale:");
|
155 |
rdoShowConditionedToTheScale.setName("rdoShowConditionedToTheScale");
|
156 |
rdoShowConditionedToTheScale.setText("Do not show the layer when the scale:");
|
157 |
buttongroup1.add(rdoShowConditionedToTheScale); |
158 |
jpanel1.add(rdoShowConditionedToTheScale,cc.xywh(2,8,2,1)); |
159 |
|
160 |
lblProperties.setName("lblProperties");
|
161 |
lblProperties.setText("Properties");
|
162 |
jpanel1.add(lblProperties,cc.xywh(2,14,2,1)); |
163 |
|
164 |
txtProperties.setEditable(false);
|
165 |
txtProperties.setName("txtProperties");
|
166 |
JScrollPane jscrollpane1 = new JScrollPane(); |
167 |
jscrollpane1.setViewportView(txtProperties); |
168 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
169 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
170 |
jpanel1.add(jscrollpane1,cc.xywh(2,15,2,1)); |
171 |
|
172 |
jpanel1.add(createPanel1(),cc.xywh(2,9,2,1)); |
173 |
txtName.setName("txtName");
|
174 |
jpanel1.add(txtName,cc.xywh(2,3,2,1)); |
175 |
|
176 |
lblDataSource.setName("lblDataSource");
|
177 |
lblDataSource.setText("Data source");
|
178 |
jpanel1.add(lblDataSource,cc.xywh(2,11,2,1)); |
179 |
|
180 |
jpanel1.add(createPanel2(),cc.xywh(2,12,2,1)); |
181 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }); |
182 |
return jpanel1;
|
183 |
} |
184 |
|
185 |
public JPanel createPanel1() |
186 |
{ |
187 |
JPanel jpanel1 = new JPanel(); |
188 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
189 |
CellConstraints cc = new CellConstraints();
|
190 |
jpanel1.setLayout(formlayout1); |
191 |
|
192 |
lblIsLessThan.setName("lblIsLessThan");
|
193 |
lblIsLessThan.setText("Is less than");
|
194 |
jpanel1.add(lblIsLessThan,cc.xy(2,1)); |
195 |
|
196 |
lblIsGreaterThan.setName("lblIsGreaterThan");
|
197 |
lblIsGreaterThan.setText("Is greater than");
|
198 |
jpanel1.add(lblIsGreaterThan,cc.xy(2,3)); |
199 |
|
200 |
lblFullScale.setName("lblFullScale");
|
201 |
lblFullScale.setText("(full scale)");
|
202 |
jpanel1.add(lblFullScale,cc.xy(7,1)); |
203 |
|
204 |
lblMinumunScale.setName("lblMinumunScale");
|
205 |
lblMinumunScale.setText("(minimum scale)");
|
206 |
jpanel1.add(lblMinumunScale,cc.xy(7,3)); |
207 |
|
208 |
txtIsLessThan.setName("txtIsLessThan");
|
209 |
jpanel1.add(txtIsLessThan,cc.xy(5,1)); |
210 |
|
211 |
txtIsGreaterThan.setName("txtIsGreaterThan");
|
212 |
jpanel1.add(txtIsGreaterThan,cc.xy(5,3)); |
213 |
|
214 |
JLabel jlabel1 = new JLabel(); |
215 |
jlabel1.setText("1:");
|
216 |
jpanel1.add(jlabel1,cc.xy(4,1)); |
217 |
|
218 |
JLabel jlabel2 = new JLabel(); |
219 |
jlabel2.setText("1:");
|
220 |
jpanel1.add(jlabel2,cc.xy(4,3)); |
221 |
|
222 |
addFillComponents(jpanel1,new int[]{ 1,3,6 },new int[]{ 1,2,3 }); |
223 |
return jpanel1;
|
224 |
} |
225 |
|
226 |
public JPanel createPanel2() |
227 |
{ |
228 |
JPanel jpanel1 = new JPanel(); |
229 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
230 |
CellConstraints cc = new CellConstraints();
|
231 |
jpanel1.setLayout(formlayout1); |
232 |
|
233 |
lblSourceType.setName("lblSourceType");
|
234 |
lblSourceType.setText("Source type");
|
235 |
jpanel1.add(lblSourceType,cc.xy(1,1)); |
236 |
|
237 |
lblSource.setName("lblSource");
|
238 |
lblSource.setText("Source");
|
239 |
jpanel1.add(lblSource,cc.xy(1,3)); |
240 |
|
241 |
txtSourceType.setBackground(new Color(236,233,216)); |
242 |
txtSourceType.setEditable(false);
|
243 |
txtSourceType.setName("txtSourceType");
|
244 |
jpanel1.add(txtSourceType,cc.xy(3,1)); |
245 |
|
246 |
txtSource.setBackground(new Color(236,233,216)); |
247 |
txtSource.setEditable(false);
|
248 |
txtSource.setName("txtSource");
|
249 |
jpanel1.add(txtSource,cc.xy(3,3)); |
250 |
|
251 |
addFillComponents(jpanel1,new int[]{ 2 },new int[]{ 2 }); |
252 |
return jpanel1;
|
253 |
} |
254 |
|
255 |
/**
|
256 |
* Initializer
|
257 |
*/
|
258 |
protected void initializePanel() |
259 |
{ |
260 |
setLayout(new BorderLayout()); |
261 |
add(createPanel(), BorderLayout.CENTER);
|
262 |
} |
263 |
|
264 |
|
265 |
} |