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 / expressionevaluator / viewcapturerectangle / ViewCaptureRectanglePanelView.java @ 44190
History | View | Annotate | Download (8.28 KB)
1 |
package org.gvsig.app.project.documents.view.expressionevaluator.viewcapturerectangle; |
---|---|
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.Color; |
8 |
import java.awt.ComponentOrientation; |
9 |
import java.awt.Container; |
10 |
import java.awt.Dimension; |
11 |
import java.awt.Font; |
12 |
import javax.swing.Box; |
13 |
import javax.swing.ButtonGroup; |
14 |
import javax.swing.ImageIcon; |
15 |
import javax.swing.JButton; |
16 |
import javax.swing.JFrame; |
17 |
import javax.swing.JLabel; |
18 |
import javax.swing.JPanel; |
19 |
import javax.swing.JRadioButton; |
20 |
import javax.swing.JTextField; |
21 |
|
22 |
|
23 |
public class ViewCaptureRectanglePanelView extends JPanel |
24 |
{ |
25 |
JLabel lblConstantRectangle = new JLabel(); |
26 |
JTextField txtBox = new JTextField(); |
27 |
JLabel lblValue = new JLabel(); |
28 |
JButton btnToggleCapture = new JButton(); |
29 |
JLabel lblDescription = new JLabel(); |
30 |
JLabel lblCaptureAPointFromCurrentView = new JLabel(); |
31 |
JLabel lblUseWktOrWkb = new JLabel(); |
32 |
JRadioButton rdoInsertAsWKT = new JRadioButton(); |
33 |
ButtonGroup buttongroup1 = new ButtonGroup(); |
34 |
JRadioButton rdoInsertAsWKB = new JRadioButton(); |
35 |
JLabel lblUseGeometryOrText = new JLabel(); |
36 |
JRadioButton rdoInsertAsGeometry = new JRadioButton(); |
37 |
ButtonGroup buttongroup2 = new ButtonGroup(); |
38 |
JRadioButton rdoInsertAsString = new JRadioButton(); |
39 |
|
40 |
/**
|
41 |
* Default constructor
|
42 |
*/
|
43 |
public ViewCaptureRectanglePanelView()
|
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:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
131 |
CellConstraints cc = new CellConstraints();
|
132 |
jpanel1.setLayout(formlayout1); |
133 |
|
134 |
lblConstantRectangle.setFont(new Font("Dialog",Font.BOLD,11)); |
135 |
lblConstantRectangle.setName("lblConstantRectangle");
|
136 |
lblConstantRectangle.setText("_Constant_Rectangle");
|
137 |
jpanel1.add(lblConstantRectangle,cc.xywh(2,2,3,1)); |
138 |
|
139 |
txtBox.setBackground(new Color(236,233,216)); |
140 |
txtBox.setEditable(false);
|
141 |
txtBox.setName("txtBox");
|
142 |
jpanel1.add(txtBox,cc.xywh(2,6,3,1)); |
143 |
|
144 |
lblValue.setFont(new Font("Dialog",Font.BOLD,11)); |
145 |
lblValue.setName("lblValue");
|
146 |
lblValue.setText("_Value");
|
147 |
jpanel1.add(lblValue,cc.xy(2,4)); |
148 |
|
149 |
btnToggleCapture.setActionCommand("Toggle point capture");
|
150 |
btnToggleCapture.setName("btnToggleCapture");
|
151 |
btnToggleCapture.setText("_Start_capture");
|
152 |
jpanel1.add(btnToggleCapture,new CellConstraints(4,8,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
153 |
|
154 |
lblDescription.setFont(new Font("Dialog",Font.BOLD,11)); |
155 |
lblDescription.setName("lblDescription");
|
156 |
lblDescription.setText("_Description");
|
157 |
jpanel1.add(lblDescription,cc.xy(2,10)); |
158 |
|
159 |
lblCaptureAPointFromCurrentView.setName("lblCaptureAPointFromCurrentView");
|
160 |
lblCaptureAPointFromCurrentView.setText("_Capture_a_point_from_current_view");
|
161 |
jpanel1.add(lblCaptureAPointFromCurrentView,cc.xywh(2,11,3,1)); |
162 |
|
163 |
jpanel1.add(createPanel1(),cc.xywh(2,13,3,1)); |
164 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14 }); |
165 |
return jpanel1;
|
166 |
} |
167 |
|
168 |
public JPanel createPanel1() |
169 |
{ |
170 |
JPanel jpanel1 = new JPanel(); |
171 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:8DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE","CENTER:DEFAULT: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,CENTER:DEFAULT:NONE"); |
172 |
CellConstraints cc = new CellConstraints();
|
173 |
jpanel1.setLayout(formlayout1); |
174 |
|
175 |
lblUseWktOrWkb.setName("lblUseWktOrWkb");
|
176 |
lblUseWktOrWkb.setText("_Use_WKT_or_WKB");
|
177 |
jpanel1.add(lblUseWktOrWkb,cc.xywh(2,1,2,1)); |
178 |
|
179 |
rdoInsertAsWKT.setActionCommand("Insert as WKT");
|
180 |
rdoInsertAsWKT.setName("rdoInsertAsWKT");
|
181 |
rdoInsertAsWKT.setOpaque(false);
|
182 |
rdoInsertAsWKT.setText("_Insert_as_WKT");
|
183 |
buttongroup1.add(rdoInsertAsWKT); |
184 |
jpanel1.add(rdoInsertAsWKT,cc.xy(3,2)); |
185 |
|
186 |
rdoInsertAsWKB.setActionCommand("Insert as WKB");
|
187 |
rdoInsertAsWKB.setName("rdoInsertAsWKB");
|
188 |
rdoInsertAsWKB.setOpaque(false);
|
189 |
rdoInsertAsWKB.setSelected(true);
|
190 |
rdoInsertAsWKB.setText("_Insert_as_WKB");
|
191 |
buttongroup1.add(rdoInsertAsWKB); |
192 |
jpanel1.add(rdoInsertAsWKB,cc.xy(3,4)); |
193 |
|
194 |
lblUseGeometryOrText.setName("lblUseGeometryOrText");
|
195 |
lblUseGeometryOrText.setText("_Use_Geometry_or_Text");
|
196 |
jpanel1.add(lblUseGeometryOrText,cc.xywh(2,6,2,1)); |
197 |
|
198 |
rdoInsertAsGeometry.setActionCommand("Insert as geometry");
|
199 |
rdoInsertAsGeometry.setName("rdoInsertAsGeometry");
|
200 |
rdoInsertAsGeometry.setOpaque(false);
|
201 |
rdoInsertAsGeometry.setSelected(true);
|
202 |
rdoInsertAsGeometry.setText("_Insert_as_Geometry");
|
203 |
buttongroup2.add(rdoInsertAsGeometry); |
204 |
jpanel1.add(rdoInsertAsGeometry,cc.xy(3,8)); |
205 |
|
206 |
rdoInsertAsString.setActionCommand("Insert as String");
|
207 |
rdoInsertAsString.setName("rdoInsertAsString");
|
208 |
rdoInsertAsString.setOpaque(false);
|
209 |
rdoInsertAsString.setText("_Insert_as_Text");
|
210 |
buttongroup2.add(rdoInsertAsString); |
211 |
jpanel1.add(rdoInsertAsString,cc.xy(3,10)); |
212 |
|
213 |
addFillComponents(jpanel1,new int[]{ 1,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9,10 }); |
214 |
return jpanel1;
|
215 |
} |
216 |
|
217 |
/**
|
218 |
* Initializer
|
219 |
*/
|
220 |
protected void initializePanel() |
221 |
{ |
222 |
setLayout(new BorderLayout()); |
223 |
add(createPanel(), BorderLayout.CENTER);
|
224 |
} |
225 |
|
226 |
|
227 |
} |