svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extEditing / src / org / gvsig / editing / gui / cad / panels / matrix / MatrixProperty.java @ 39052
History | View | Annotate | Download (14.2 KB)
1 |
package org.gvsig.editing.gui.cad.panels.matrix; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Dimension; |
5 |
import java.awt.event.ActionListener; |
6 |
|
7 |
import javax.swing.ImageIcon; |
8 |
import javax.swing.JButton; |
9 |
import javax.swing.JCheckBox; |
10 |
import javax.swing.JDialog; |
11 |
import javax.swing.JLabel; |
12 |
import javax.swing.JPanel; |
13 |
import javax.swing.JTabbedPane; |
14 |
import javax.swing.JTextField; |
15 |
|
16 |
import org.gvsig.andami.IconThemeHelper; |
17 |
import org.gvsig.andami.PluginServices; |
18 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
19 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
20 |
import org.gvsig.editing.gui.cad.tools.MatrixCADTool; |
21 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
22 |
import org.gvsig.utils.DoubleUtilities; |
23 |
|
24 |
|
25 |
|
26 |
public class MatrixProperty extends JPanel implements IWindow{ |
27 |
|
28 |
private JPanel jPanel = null; |
29 |
private JTabbedPane jTabbedPane = null; // @jve:decl-index=0:visual-constraint="10,10" |
30 |
private JPanel pRectangular = null; |
31 |
private JPanel pPolar = null; |
32 |
private JPanel pNorth = null; |
33 |
private JLabel lblRows = null; |
34 |
private JTextField txtRows = null; |
35 |
private JLabel lblColumns = null; |
36 |
private JTextField txtColumns = null; |
37 |
private JPanel pCenter = null; |
38 |
private JLabel lblDistRows = null; |
39 |
private JTextField txtDistRows = null; |
40 |
private JLabel lblDistColumns = null; |
41 |
private JTextField txtDistColumns = null; |
42 |
private JLabel lblRotation = null; |
43 |
private JTextField txtRotation = null; |
44 |
private AcceptCancelPanel jPanel1;
|
45 |
private MatrixOperations operations;
|
46 |
private JPanel pNorthPolar = null; |
47 |
private JPanel pCenterPolar = null; |
48 |
private JLabel lblCenter = null; |
49 |
private JLabel lblx = null; |
50 |
private JTextField txtX = null; |
51 |
private JLabel lblY = null; |
52 |
private JTextField txtY = null; |
53 |
private JLabel lblNum = null; |
54 |
private JTextField txtNum = null; |
55 |
private JCheckBox chbRotateElements = null; |
56 |
private JButton bLagXY = null; |
57 |
private JButton bLagY = null; |
58 |
private JButton bLagX = null; |
59 |
private JButton bRotation = null; |
60 |
private MatrixCADTool matrixCADTool;
|
61 |
private static ImageIcon ilagXY = null; |
62 |
private static ImageIcon iaddpoint = null; |
63 |
|
64 |
/**
|
65 |
* This is the default constructor
|
66 |
*/
|
67 |
public MatrixProperty() {
|
68 |
super();
|
69 |
initialize(); |
70 |
|
71 |
} |
72 |
|
73 |
/**
|
74 |
* This method initializes this
|
75 |
*
|
76 |
* @return void
|
77 |
*/
|
78 |
private void initialize() { |
79 |
|
80 |
iaddpoint = IconThemeHelper.getImageIcon("layer-modify-matrix-addpoint");
|
81 |
ilagXY = IconThemeHelper.getImageIcon("layer-modify-matrix-lagxy");
|
82 |
|
83 |
this.setLayout(new BorderLayout()); |
84 |
this.setSize(369, 275); |
85 |
this.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
|
86 |
this.add(getJPanel(), java.awt.BorderLayout.EAST);
|
87 |
this.add(getJPanel1(), java.awt.BorderLayout.SOUTH);
|
88 |
|
89 |
} |
90 |
|
91 |
/**
|
92 |
* This method initializes jPanel
|
93 |
*
|
94 |
* @return javax.swing.JPanel
|
95 |
*/
|
96 |
private JPanel getJPanel() { |
97 |
if (jPanel == null) { |
98 |
jPanel = new JPanel(); |
99 |
} |
100 |
return jPanel;
|
101 |
} |
102 |
|
103 |
/**
|
104 |
* This method initializes jTabbedPane
|
105 |
*
|
106 |
* @return javax.swing.JTabbedPane
|
107 |
*/
|
108 |
private JTabbedPane getJTabbedPane() { |
109 |
if (jTabbedPane == null) { |
110 |
jTabbedPane = new JTabbedPane(); |
111 |
jTabbedPane.setSize(new java.awt.Dimension(323,235)); |
112 |
jTabbedPane.addTab(PluginServices.getText(this,"matriz_rectangular"), null, getPRectangular(), null); |
113 |
jTabbedPane.addTab(PluginServices.getText(this,"matriz_polar"), null, getPPolar(), null); |
114 |
} |
115 |
return jTabbedPane;
|
116 |
} |
117 |
|
118 |
/**
|
119 |
* This method initializes pRectangular
|
120 |
*
|
121 |
* @return javax.swing.JPanel
|
122 |
*/
|
123 |
private JPanel getPRectangular() { |
124 |
if (pRectangular == null) { |
125 |
pRectangular = new JPanel(); |
126 |
pRectangular.setLayout(new BorderLayout()); |
127 |
pRectangular.setPreferredSize(new Dimension(300,200)); |
128 |
pRectangular.add(getPNorth(), java.awt.BorderLayout.NORTH); |
129 |
pRectangular.add(getPCenter(), java.awt.BorderLayout.CENTER); |
130 |
} |
131 |
return pRectangular;
|
132 |
} |
133 |
|
134 |
/**
|
135 |
* This method initializes pPolar
|
136 |
*
|
137 |
* @return javax.swing.JPanel
|
138 |
*/
|
139 |
private JPanel getPPolar() { |
140 |
if (pPolar == null) { |
141 |
pPolar = new JPanel(); |
142 |
pPolar.setLayout(new BorderLayout()); |
143 |
pPolar.add(getPNorthPolar(), java.awt.BorderLayout.NORTH); |
144 |
pPolar.add(getPCenterPolar(), java.awt.BorderLayout.CENTER); |
145 |
} |
146 |
return pPolar;
|
147 |
} |
148 |
|
149 |
/**
|
150 |
* This method initializes pNorth
|
151 |
*
|
152 |
* @return javax.swing.JPanel
|
153 |
*/
|
154 |
private JPanel getPNorth() { |
155 |
if (pNorth == null) { |
156 |
lblColumns = new JLabel(); |
157 |
lblColumns.setText(PluginServices.getText(this,"columns")); |
158 |
lblRows = new JLabel(); |
159 |
lblRows.setText(PluginServices.getText(this,"rows")); |
160 |
pNorth = new JPanel(); |
161 |
pNorth.add(lblRows, null);
|
162 |
pNorth.add(getTxtRows(), null);
|
163 |
pNorth.add(lblColumns, null);
|
164 |
pNorth.add(getTxtColumns(), null);
|
165 |
} |
166 |
return pNorth;
|
167 |
} |
168 |
|
169 |
/**
|
170 |
* This method initializes txtRows
|
171 |
*
|
172 |
* @return javax.swing.JTextField
|
173 |
*/
|
174 |
private JTextField getTxtRows() { |
175 |
if (txtRows == null) { |
176 |
txtRows = new JTextField(); |
177 |
txtRows.setPreferredSize(new Dimension(40,20)); |
178 |
} |
179 |
return txtRows;
|
180 |
} |
181 |
|
182 |
/**
|
183 |
* This method initializes txtColumns
|
184 |
*
|
185 |
* @return javax.swing.JTextField
|
186 |
*/
|
187 |
private JTextField getTxtColumns() { |
188 |
if (txtColumns == null) { |
189 |
txtColumns = new JTextField(); |
190 |
txtColumns.setPreferredSize(new Dimension(40,20)); |
191 |
} |
192 |
return txtColumns;
|
193 |
} |
194 |
|
195 |
/**
|
196 |
* This method initializes pCenter
|
197 |
*
|
198 |
* @return javax.swing.JPanel
|
199 |
*/
|
200 |
private JPanel getPCenter() { |
201 |
if (pCenter == null) { |
202 |
lblRotation = new JLabel(); |
203 |
lblRotation.setBounds(new java.awt.Rectangle(6,73,141,22)); |
204 |
lblRotation.setText(PluginServices.getText(this,"rotation")); |
205 |
lblDistColumns = new JLabel(); |
206 |
lblDistColumns.setBounds(new java.awt.Rectangle(6,42,141,22)); |
207 |
lblDistColumns.setText(PluginServices.getText(this,"disp_columns")); |
208 |
lblDistRows = new JLabel(); |
209 |
lblDistRows.setBounds(new java.awt.Rectangle(6,10,141,22)); |
210 |
lblDistRows.setText(PluginServices.getText(this,"disp_rows")); |
211 |
pCenter = new JPanel(); |
212 |
pCenter.setPreferredSize(new Dimension(200,150)); |
213 |
pCenter.setLayout(null);
|
214 |
pCenter.add(lblDistRows, null);
|
215 |
pCenter.add(getTxtDistRows(), null);
|
216 |
pCenter.add(lblDistColumns, null);
|
217 |
pCenter.add(getTxtDistColumns(), null);
|
218 |
pCenter.add(lblRotation, null);
|
219 |
pCenter.add(getTxtRotation(), null);
|
220 |
pCenter.add(getBLagXY(), null);
|
221 |
pCenter.add(getBLagY(), null);
|
222 |
pCenter.add(getBLagX(), null);
|
223 |
pCenter.add(getBRotation(), null);
|
224 |
} |
225 |
return pCenter;
|
226 |
} |
227 |
|
228 |
/**
|
229 |
* This method initializes txtDistRows
|
230 |
*
|
231 |
* @return javax.swing.JTextField
|
232 |
*/
|
233 |
private JTextField getTxtDistRows() { |
234 |
if (txtDistRows == null) { |
235 |
txtDistRows = new JTextField(); |
236 |
txtDistRows.setBounds(new java.awt.Rectangle(153,11,75,22)); |
237 |
} |
238 |
return txtDistRows;
|
239 |
} |
240 |
|
241 |
/**
|
242 |
* This method initializes txtDistColumns
|
243 |
*
|
244 |
* @return javax.swing.JTextField
|
245 |
*/
|
246 |
private JTextField getTxtDistColumns() { |
247 |
if (txtDistColumns == null) { |
248 |
txtDistColumns = new JTextField(); |
249 |
txtDistColumns.setBounds(new java.awt.Rectangle(153,43,75,22)); |
250 |
} |
251 |
return txtDistColumns;
|
252 |
} |
253 |
|
254 |
/**
|
255 |
* This method initializes txtRotation
|
256 |
*
|
257 |
* @return javax.swing.JTextField
|
258 |
*/
|
259 |
private JTextField getTxtRotation() { |
260 |
if (txtRotation == null) { |
261 |
txtRotation = new JTextField(); |
262 |
txtRotation.setBounds(new java.awt.Rectangle(153,72,75,22)); |
263 |
} |
264 |
return txtRotation;
|
265 |
} |
266 |
|
267 |
/**
|
268 |
* This method initializes jPanel
|
269 |
*
|
270 |
* @return javax.swing.JPanel
|
271 |
*/
|
272 |
private AcceptCancelPanel getJPanel1() {
|
273 |
if (jPanel1 == null) { |
274 |
ActionListener okAction = new java.awt.event.ActionListener() { |
275 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
276 |
if (getJTabbedPane().getSelectedIndex()==0) { |
277 |
operations.setRectangular(true);
|
278 |
operations.setNumRows(Integer.parseInt(getTxtRows().getText()));
|
279 |
operations.setNumColumns(Integer.parseInt(getTxtColumns().getText()));
|
280 |
operations.setDistRows(Double.parseDouble(getTxtDistRows().getText()));
|
281 |
operations.setDistColumns(Double.parseDouble(getTxtDistColumns().getText()));
|
282 |
operations.setRotation(Double.parseDouble(getTxtRotation().getText()));
|
283 |
}else {
|
284 |
operations.setRectangular(false);
|
285 |
operations.setPositionX(Double.parseDouble(getTxtX().getText()));
|
286 |
operations.setPositionY(Double.parseDouble(getTxtY().getText()));
|
287 |
operations.setNum(Integer.parseInt(getTxtNum().getText()));
|
288 |
operations.setRotateElements(getChbRotateElements().isSelected()); |
289 |
} |
290 |
operations.setAccepted(true);
|
291 |
|
292 |
if (PluginServices.getMainFrame() == null) { |
293 |
((JDialog) (getParent().getParent().getParent()
|
294 |
.getParent())).dispose(); |
295 |
} else {
|
296 |
PluginServices.getMDIManager().closeWindow(MatrixProperty.this); |
297 |
} |
298 |
} |
299 |
}; |
300 |
ActionListener cancelAction = new java.awt.event.ActionListener() { |
301 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
302 |
operations.setAccepted(false);
|
303 |
if (PluginServices.getMainFrame() != null) { |
304 |
PluginServices.getMDIManager().closeWindow(MatrixProperty.this); |
305 |
} else {
|
306 |
((JDialog) (getParent().getParent().getParent()
|
307 |
.getParent())).dispose(); |
308 |
} |
309 |
} |
310 |
}; |
311 |
jPanel1 = new AcceptCancelPanel(okAction, cancelAction);
|
312 |
} |
313 |
return jPanel1;
|
314 |
} |
315 |
|
316 |
public WindowInfo getWindowInfo() {
|
317 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
318 |
m_viewinfo.setTitle(PluginServices.getText(this,"matrix")); |
319 |
m_viewinfo.setHeight(this.getHeight());
|
320 |
m_viewinfo.setWidth(this.getWidth());
|
321 |
return m_viewinfo;
|
322 |
} |
323 |
|
324 |
public void setMatrixCADTool(MatrixCADTool tool) { |
325 |
operations=tool.getOperations(); |
326 |
matrixCADTool=tool; |
327 |
refresh(); |
328 |
} |
329 |
|
330 |
/**
|
331 |
* This method initializes pNorthPolar
|
332 |
*
|
333 |
* @return javax.swing.JPanel
|
334 |
*/
|
335 |
private JPanel getPNorthPolar() { |
336 |
if (pNorthPolar == null) { |
337 |
lblY = new JLabel(); |
338 |
lblY.setText("Y: ");
|
339 |
lblx = new JLabel(); |
340 |
lblx.setText("X: ");
|
341 |
lblCenter = new JLabel(); |
342 |
lblCenter.setText("centro");
|
343 |
pNorthPolar = new JPanel(); |
344 |
pNorthPolar.add(lblCenter, null);
|
345 |
pNorthPolar.add(lblx, null);
|
346 |
pNorthPolar.add(getTxtX(), null);
|
347 |
pNorthPolar.add(lblY, null);
|
348 |
pNorthPolar.add(getTxtY(), null);
|
349 |
} |
350 |
return pNorthPolar;
|
351 |
} |
352 |
|
353 |
/**
|
354 |
* This method initializes pCenterPolar
|
355 |
*
|
356 |
* @return javax.swing.JPanel
|
357 |
*/
|
358 |
private JPanel getPCenterPolar() { |
359 |
if (pCenterPolar == null) { |
360 |
lblNum = new JLabel(); |
361 |
lblNum.setText("num_elementos");
|
362 |
pCenterPolar = new JPanel(); |
363 |
pCenterPolar.add(lblNum, null);
|
364 |
pCenterPolar.add(getTxtNum(), null);
|
365 |
pCenterPolar.add(getChbRotateElements(), null);
|
366 |
} |
367 |
return pCenterPolar;
|
368 |
} |
369 |
|
370 |
/**
|
371 |
* This method initializes txtX
|
372 |
*
|
373 |
* @return javax.swing.JTextField
|
374 |
*/
|
375 |
private JTextField getTxtX() { |
376 |
if (txtX == null) { |
377 |
txtX = new JTextField(); |
378 |
txtX.setPreferredSize(new java.awt.Dimension(50,20)); |
379 |
} |
380 |
return txtX;
|
381 |
} |
382 |
|
383 |
/**
|
384 |
* This method initializes txtY
|
385 |
*
|
386 |
* @return javax.swing.JTextField
|
387 |
*/
|
388 |
private JTextField getTxtY() { |
389 |
if (txtY == null) { |
390 |
txtY = new JTextField(); |
391 |
txtY.setPreferredSize(new java.awt.Dimension(50,20)); |
392 |
} |
393 |
return txtY;
|
394 |
} |
395 |
|
396 |
/**
|
397 |
* This method initializes txtNum
|
398 |
*
|
399 |
* @return javax.swing.JTextField
|
400 |
*/
|
401 |
private JTextField getTxtNum() { |
402 |
if (txtNum == null) { |
403 |
txtNum = new JTextField(); |
404 |
txtNum.setPreferredSize(new java.awt.Dimension(50,20)); |
405 |
} |
406 |
return txtNum;
|
407 |
} |
408 |
|
409 |
/**
|
410 |
* This method initializes chbRotateElements
|
411 |
*
|
412 |
* @return javax.swing.JCheckBox
|
413 |
*/
|
414 |
private JCheckBox getChbRotateElements() { |
415 |
if (chbRotateElements == null) { |
416 |
chbRotateElements = new JCheckBox(); |
417 |
chbRotateElements.setText("girar_elementos_a_medida_que_se_copian");
|
418 |
} |
419 |
return chbRotateElements;
|
420 |
} |
421 |
|
422 |
/**
|
423 |
* This method initializes bLagXY
|
424 |
*
|
425 |
* @return javax.swing.JButton
|
426 |
*/
|
427 |
public JButton getBLagXY() { |
428 |
if (bLagXY == null) { |
429 |
bLagXY = new JButton(); |
430 |
bLagXY.setBounds(new java.awt.Rectangle(232,8,30,56)); |
431 |
bLagXY.setIcon(ilagXY); |
432 |
bLagXY.addActionListener(new java.awt.event.ActionListener() {
|
433 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
434 |
operations.setAccepted(false);
|
435 |
matrixCADTool.addOption("lagXY");
|
436 |
} |
437 |
}); |
438 |
} |
439 |
return bLagXY;
|
440 |
} |
441 |
|
442 |
/**
|
443 |
* This method initializes bLagY
|
444 |
*
|
445 |
* @return javax.swing.JButton
|
446 |
*/
|
447 |
public JButton getBLagY() { |
448 |
if (bLagY == null) { |
449 |
bLagY = new JButton(); |
450 |
bLagY.setBounds(new java.awt.Rectangle(270,7,28,26)); |
451 |
bLagY.setIcon(iaddpoint); |
452 |
bLagY.addActionListener(new java.awt.event.ActionListener() {
|
453 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
454 |
operations.setAccepted(false);
|
455 |
matrixCADTool.addOption("lagY");
|
456 |
} |
457 |
}); |
458 |
} |
459 |
return bLagY;
|
460 |
} |
461 |
|
462 |
/**
|
463 |
* This method initializes bLagX
|
464 |
*
|
465 |
* @return javax.swing.JButton
|
466 |
*/
|
467 |
public JButton getBLagX() { |
468 |
if (bLagX == null) { |
469 |
bLagX = new JButton(); |
470 |
bLagX.setBounds(new java.awt.Rectangle(270,38,28,26)); |
471 |
bLagX.setIcon(iaddpoint); |
472 |
bLagX.addActionListener(new java.awt.event.ActionListener() {
|
473 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
474 |
operations.setAccepted(false);
|
475 |
matrixCADTool.addOption("lagX");
|
476 |
} |
477 |
}); |
478 |
} |
479 |
return bLagX;
|
480 |
} |
481 |
|
482 |
/**
|
483 |
* This method initializes bRotation
|
484 |
*
|
485 |
* @return javax.swing.JButton
|
486 |
*/
|
487 |
public JButton getBRotation() { |
488 |
if (bRotation == null) { |
489 |
bRotation = new JButton(); |
490 |
bRotation.setBounds(new java.awt.Rectangle(232,70,28,26)); |
491 |
bRotation.setIcon(iaddpoint); |
492 |
bRotation.addActionListener(new java.awt.event.ActionListener() {
|
493 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
494 |
operations.setAccepted(false);
|
495 |
matrixCADTool.addOption("rotation");
|
496 |
} |
497 |
}); |
498 |
} |
499 |
return bRotation;
|
500 |
} |
501 |
|
502 |
public void refresh() { |
503 |
refreshLagX(); |
504 |
refreshLagY(); |
505 |
refreshRotation(); |
506 |
getTxtColumns().setText(String.valueOf(operations.getNumColumns()));
|
507 |
getTxtRows().setText(String.valueOf(operations.getNumRows()));
|
508 |
getTxtNum().setText(String.valueOf(operations.getNum()));
|
509 |
getTxtX().setText(String.valueOf(operations.getPositionX()));
|
510 |
getTxtY().setText(String.valueOf(operations.getPositionY()));
|
511 |
} |
512 |
|
513 |
public void refreshLagX() { |
514 |
getTxtDistColumns().setText(String.valueOf(DoubleUtilities.format(operations.getDistColumns(),'.',2))); |
515 |
|
516 |
} |
517 |
|
518 |
public void refreshLagY() { |
519 |
getTxtDistRows().setText(String.valueOf(DoubleUtilities.format(operations.getDistRows(),'.',2))); |
520 |
|
521 |
} |
522 |
public void refreshRotation() { |
523 |
getTxtRotation().setText(String.valueOf(DoubleUtilities.format(operations.getRotation(),'.',2))); |
524 |
|
525 |
} |
526 |
|
527 |
public Object getWindowProfile() { |
528 |
return WindowInfo.DIALOG_PROFILE;
|
529 |
} |
530 |
|
531 |
|
532 |
} // @jve:decl-index=0:visual-constraint="10,10"
|