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 / ViewCapturePointPanelView.java @ 44006
History | View | Annotate | Download (7.74 KB)
1 |
package org.gvsig.app.project.documents.view.expressionevaluator; |
---|---|
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 ViewCapturePointPanelView extends JPanel |
24 |
{ |
25 |
JButton btnToggleCapture = new JButton(); |
26 |
JRadioButton rdoInsertAsWKT = new JRadioButton(); |
27 |
ButtonGroup buttongroup1 = new ButtonGroup(); |
28 |
JRadioButton rdoInsertAsWKB = new JRadioButton(); |
29 |
JRadioButton rdoInsertAsGeometry = new JRadioButton(); |
30 |
ButtonGroup buttongroup2 = new ButtonGroup(); |
31 |
JRadioButton rdoInsertAsString = new JRadioButton(); |
32 |
JTextField txtPoint = new JTextField(); |
33 |
|
34 |
/**
|
35 |
* Default constructor
|
36 |
*/
|
37 |
public ViewCapturePointPanelView()
|
38 |
{ |
39 |
initializePanel(); |
40 |
} |
41 |
|
42 |
/**
|
43 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
44 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
45 |
* @param cols an array of column indices in the first row where fill components should be added.
|
46 |
* @param rows an array of row indices in the first column where fill components should be added.
|
47 |
*/
|
48 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
49 |
{ |
50 |
Dimension filler = new Dimension(10,10); |
51 |
|
52 |
boolean filled_cell_11 = false; |
53 |
CellConstraints cc = new CellConstraints();
|
54 |
if ( cols.length > 0 && rows.length > 0 ) |
55 |
{ |
56 |
if ( cols[0] == 1 && rows[0] == 1 ) |
57 |
{ |
58 |
/** add a rigid area */
|
59 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
60 |
filled_cell_11 = true;
|
61 |
} |
62 |
} |
63 |
|
64 |
for( int index = 0; index < cols.length; index++ ) |
65 |
{ |
66 |
if ( cols[index] == 1 && filled_cell_11 ) |
67 |
{ |
68 |
continue;
|
69 |
} |
70 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
71 |
} |
72 |
|
73 |
for( int index = 0; index < rows.length; index++ ) |
74 |
{ |
75 |
if ( rows[index] == 1 && filled_cell_11 ) |
76 |
{ |
77 |
continue;
|
78 |
} |
79 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
80 |
} |
81 |
|
82 |
} |
83 |
|
84 |
/**
|
85 |
* Helper method to load an image file from the CLASSPATH
|
86 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
87 |
* @return an ImageIcon instance with the specified image file
|
88 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
89 |
*/
|
90 |
public ImageIcon loadImage( String imageName ) |
91 |
{ |
92 |
try
|
93 |
{ |
94 |
ClassLoader classloader = getClass().getClassLoader();
|
95 |
java.net.URL url = classloader.getResource( imageName ); |
96 |
if ( url != null ) |
97 |
{ |
98 |
ImageIcon icon = new ImageIcon( url ); |
99 |
return icon;
|
100 |
} |
101 |
} |
102 |
catch( Exception e ) |
103 |
{ |
104 |
e.printStackTrace(); |
105 |
} |
106 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
107 |
} |
108 |
|
109 |
/**
|
110 |
* Method for recalculating the component orientation for
|
111 |
* right-to-left Locales.
|
112 |
* @param orientation the component orientation to be applied
|
113 |
*/
|
114 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
115 |
{ |
116 |
// Not yet implemented...
|
117 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
118 |
super.applyComponentOrientation(orientation);
|
119 |
} |
120 |
|
121 |
public JPanel createPanel() |
122 |
{ |
123 |
JPanel jpanel1 = new JPanel(); |
124 |
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"); |
125 |
CellConstraints cc = new CellConstraints();
|
126 |
jpanel1.setLayout(formlayout1); |
127 |
|
128 |
JLabel jlabel1 = new JLabel(); |
129 |
jlabel1.setFont(new Font("Dialog",Font.BOLD,11)); |
130 |
jlabel1.setText("Constant Point");
|
131 |
jpanel1.add(jlabel1,cc.xywh(2,2,3,1)); |
132 |
|
133 |
JLabel jlabel2 = new JLabel(); |
134 |
jlabel2.setFont(new Font("Dialog",Font.BOLD,11)); |
135 |
jlabel2.setText("Value");
|
136 |
jpanel1.add(jlabel2,cc.xy(2,4)); |
137 |
|
138 |
JLabel jlabel3 = new JLabel(); |
139 |
jlabel3.setFont(new Font("Dialog",Font.BOLD,11)); |
140 |
jlabel3.setText("Description");
|
141 |
jpanel1.add(jlabel3,cc.xy(2,10)); |
142 |
|
143 |
JLabel jlabel4 = new JLabel(); |
144 |
jlabel4.setText("Capture a point from current view");
|
145 |
jpanel1.add(jlabel4,cc.xywh(2,11,3,1)); |
146 |
|
147 |
btnToggleCapture.setActionCommand("Toggle point capture");
|
148 |
btnToggleCapture.setName("btnToggleCapture");
|
149 |
btnToggleCapture.setText("Toggle point capture");
|
150 |
jpanel1.add(btnToggleCapture,new CellConstraints(4,8,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
151 |
|
152 |
jpanel1.add(createPanel1(),cc.xywh(2,13,3,1)); |
153 |
txtPoint.setBackground(new Color(236,233,216)); |
154 |
txtPoint.setEditable(false);
|
155 |
txtPoint.setName("txtPoint");
|
156 |
jpanel1.add(txtPoint,cc.xywh(2,6,3,1)); |
157 |
|
158 |
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 }); |
159 |
return jpanel1;
|
160 |
} |
161 |
|
162 |
public JPanel createPanel1() |
163 |
{ |
164 |
JPanel jpanel1 = new JPanel(); |
165 |
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"); |
166 |
CellConstraints cc = new CellConstraints();
|
167 |
jpanel1.setLayout(formlayout1); |
168 |
|
169 |
JLabel jlabel1 = new JLabel(); |
170 |
jlabel1.setText("Use WKT or WKB");
|
171 |
jpanel1.add(jlabel1,cc.xywh(2,1,2,1)); |
172 |
|
173 |
JLabel jlabel2 = new JLabel(); |
174 |
jlabel2.setText("Use Geometry or Text");
|
175 |
jpanel1.add(jlabel2,cc.xywh(2,6,2,1)); |
176 |
|
177 |
rdoInsertAsWKT.setActionCommand("Insert as WKT");
|
178 |
rdoInsertAsWKT.setName("rdoInsertAsWKT");
|
179 |
rdoInsertAsWKT.setOpaque(false);
|
180 |
rdoInsertAsWKT.setSelected(true);
|
181 |
rdoInsertAsWKT.setText("Insert as WKT");
|
182 |
buttongroup1.add(rdoInsertAsWKT); |
183 |
jpanel1.add(rdoInsertAsWKT,cc.xy(3,2)); |
184 |
|
185 |
rdoInsertAsWKB.setActionCommand("Insert as WKB");
|
186 |
rdoInsertAsWKB.setName("rdoInsertAsWKB");
|
187 |
rdoInsertAsWKB.setOpaque(false);
|
188 |
rdoInsertAsWKB.setText("Insert as WKB");
|
189 |
buttongroup1.add(rdoInsertAsWKB); |
190 |
jpanel1.add(rdoInsertAsWKB,cc.xy(3,4)); |
191 |
|
192 |
rdoInsertAsGeometry.setActionCommand("Insert as geometry");
|
193 |
rdoInsertAsGeometry.setName("rdoInsertAsGeometry");
|
194 |
rdoInsertAsGeometry.setOpaque(false);
|
195 |
rdoInsertAsGeometry.setSelected(true);
|
196 |
rdoInsertAsGeometry.setText("Insert as Geometry");
|
197 |
buttongroup2.add(rdoInsertAsGeometry); |
198 |
jpanel1.add(rdoInsertAsGeometry,cc.xy(3,8)); |
199 |
|
200 |
rdoInsertAsString.setActionCommand("Insert as String");
|
201 |
rdoInsertAsString.setName("rdoInsertAsString");
|
202 |
rdoInsertAsString.setOpaque(false);
|
203 |
rdoInsertAsString.setText("Insert as Text");
|
204 |
buttongroup2.add(rdoInsertAsString); |
205 |
jpanel1.add(rdoInsertAsString,cc.xy(3,10)); |
206 |
|
207 |
addFillComponents(jpanel1,new int[]{ 1,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9,10 }); |
208 |
return jpanel1;
|
209 |
} |
210 |
|
211 |
/**
|
212 |
* Initializer
|
213 |
*/
|
214 |
protected void initializePanel() |
215 |
{ |
216 |
setLayout(new BorderLayout()); |
217 |
add(createPanel(), BorderLayout.CENTER);
|
218 |
} |
219 |
|
220 |
|
221 |
} |