svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / fframes / gui / dialogs / FFrameGridDialog.java @ 279
History | View | Annotate | Download (24.7 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.app.project.documents.layout.fframes.gui.dialogs; |
23 |
|
24 |
import java.awt.BorderLayout; |
25 |
import java.awt.Font; |
26 |
import java.awt.GridBagConstraints; |
27 |
import java.awt.GridBagLayout; |
28 |
import java.awt.Insets; |
29 |
import java.awt.event.ActionEvent; |
30 |
import java.awt.event.ActionListener; |
31 |
import java.awt.event.FocusEvent; |
32 |
import java.awt.event.FocusListener; |
33 |
import java.awt.geom.Rectangle2D; |
34 |
import java.text.DecimalFormat; |
35 |
|
36 |
import javax.swing.BoxLayout; |
37 |
import javax.swing.ButtonGroup; |
38 |
import javax.swing.JButton; |
39 |
import javax.swing.JLabel; |
40 |
import javax.swing.JPanel; |
41 |
import javax.swing.JRadioButton; |
42 |
import javax.swing.JTextField; |
43 |
|
44 |
import org.gvsig.andami.PluginServices; |
45 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
46 |
import org.gvsig.app.gui.panels.ColorChooserPanel; |
47 |
import org.gvsig.app.gui.utils.FontChooser; |
48 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGrid; |
49 |
import org.gvsig.app.project.documents.layout.fframes.FFrameView; |
50 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
51 |
import org.gvsig.app.project.documents.layout.fframes.gui.numberFormat.DecimalFormatDialog; |
52 |
import org.gvsig.app.project.documents.layout.fframes.gui.numberFormat.DecimalFormatPanel; |
53 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
54 |
import org.gvsig.app.project.documents.view.legend.gui.PanelEditSymbol; |
55 |
import org.gvsig.fmap.geom.Geometry; |
56 |
import org.gvsig.fmap.geom.primitive.Envelope; |
57 |
import org.gvsig.fmap.mapcontext.MapContext; |
58 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
59 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
60 |
import org.gvsig.gui.beans.numberTextField.NumberTextField; |
61 |
import org.gvsig.gui.beans.swing.JIncrementalNumberField; |
62 |
import org.gvsig.gui.beans.swing.ValidatingTextField; |
63 |
import org.gvsig.gui.beans.swing.ValidatingTextField.Cleaner; |
64 |
import org.gvsig.gui.beans.swing.ValidatingTextField.Validator; |
65 |
import org.gvsig.i18n.Messages; |
66 |
import org.gvsig.math.intervals.IntervalUtils; |
67 |
|
68 |
public class FFrameGridDialog extends AbstractFFrameDialog implements |
69 |
IFFrameDialog { |
70 |
|
71 |
private static final long serialVersionUID = 1L; |
72 |
private JPanel pnlMain = null; |
73 |
private JTextField txtIntervalX = null; |
74 |
private JPanel pnlIntervalGroup = null; |
75 |
private JTextField txtIntervalY = null; |
76 |
private JLabel lblUnitsX = null; |
77 |
private JLabel lblUnitsY = null; |
78 |
private JPanel jPanel8 = null; |
79 |
private JPanel jPanel9 = null; |
80 |
private JRadioButton rbPoints = null; |
81 |
private JRadioButton rbLines = null; |
82 |
private JButton bSymbol = null; |
83 |
private JPanel pnlLabelGroup = null; |
84 |
private JPanel pnlFont = null; |
85 |
private JButton jButton = null; |
86 |
private ColorChooserPanel colorChooserPanel = null; |
87 |
|
88 |
private FFrameGrid fframegrid;
|
89 |
private FFrameView fframeview;
|
90 |
private AcceptCancelPanel accept;
|
91 |
private FFrameGrid newFFrameGrid;
|
92 |
// private Color textcolor;
|
93 |
private ISymbol symbol;
|
94 |
private Font m_font; |
95 |
private ButtonGroup bg = new ButtonGroup(); |
96 |
private NumberTextField tfNumDivHoriz = null; |
97 |
private NumberTextField tfNumDivVert = null; |
98 |
private JRadioButton rbHorizDiv = null; |
99 |
private JRadioButton rbVertDiv = null; |
100 |
private JPanel pnlDistance = null; |
101 |
private JRadioButton rbDistance = null; |
102 |
private JButton btnNumberFormat = null; |
103 |
private JIncrementalNumberField nfRotationHoriz = null; |
104 |
private ButtonGroup btGrpInterval = null; |
105 |
private static final Insets defaultInsets = new Insets(4, 4, 4, 4); |
106 |
private DecimalFormat format = new DecimalFormat(); |
107 |
private JIncrementalNumberField nfRotationVert = null; |
108 |
|
109 |
public FFrameGridDialog(LayoutPanel layout, FFrameGrid fframe) {
|
110 |
super(layout, fframe);
|
111 |
this.fframegrid = fframe;
|
112 |
initialize(); |
113 |
} |
114 |
|
115 |
/**
|
116 |
* This method initializes this
|
117 |
*
|
118 |
* @return void
|
119 |
*/
|
120 |
private void initialize() { |
121 |
this.setLayout(new BorderLayout()); |
122 |
this.add(getPnlMain(), java.awt.BorderLayout.CENTER);
|
123 |
this.add(getAcceptCancelPanel(), java.awt.BorderLayout.SOUTH);
|
124 |
} |
125 |
|
126 |
/**
|
127 |
* This method initializes jPanel1
|
128 |
*
|
129 |
* @return javax.swing.JPanel
|
130 |
*/
|
131 |
private JPanel getPnlMain() { |
132 |
if (pnlMain == null) { |
133 |
pnlMain = new JPanel(new GridBagLayout()); |
134 |
GridBagConstraints c = new GridBagConstraints(); |
135 |
c.insets = new Insets(4, 4, 4, 4); |
136 |
c.fill = GridBagConstraints.HORIZONTAL;
|
137 |
c.anchor = GridBagConstraints.FIRST_LINE_START;
|
138 |
c.gridx = 0;
|
139 |
int row = 0; |
140 |
c.gridy = row++; |
141 |
pnlMain.add(getPnlIntervalGroup(), c); |
142 |
c.gridy = row++; |
143 |
pnlMain.add(getPnlLabelGroup(), c); |
144 |
c.gridy = row++; |
145 |
c.fill = GridBagConstraints.NONE;
|
146 |
pnlMain.add(getPnlSymbologyGroup(), c); |
147 |
|
148 |
} |
149 |
return pnlMain;
|
150 |
} |
151 |
|
152 |
/**
|
153 |
* This method initializes txtIntervalX
|
154 |
*
|
155 |
* @return javax.swing.JTextField
|
156 |
*/
|
157 |
private JTextField getTxtIntervalX() { |
158 |
if (txtIntervalX == null) { |
159 |
txtIntervalX = new JTextField(10); |
160 |
txtIntervalX.setText(String.valueOf(fframegrid.getIntervalX()));
|
161 |
txtIntervalX.setName("txtIntervalX");
|
162 |
} |
163 |
return txtIntervalX;
|
164 |
} |
165 |
|
166 |
/**
|
167 |
* This method initializes jPanel6
|
168 |
*
|
169 |
* @return javax.swing.JPanel
|
170 |
*/
|
171 |
private JPanel getPnlIntervalGroup() { |
172 |
if (pnlIntervalGroup == null) { |
173 |
pnlIntervalGroup = new JPanel(new GridBagLayout()); |
174 |
pnlIntervalGroup.setBorder(javax.swing.BorderFactory.createTitledBorder( |
175 |
null, PluginServices.getText(this, "Interval"), |
176 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
177 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
178 |
GridBagConstraints c = new GridBagConstraints(); |
179 |
c.anchor = GridBagConstraints.FIRST_LINE_START;
|
180 |
c.gridx = 0;
|
181 |
c.insets = defaultInsets; |
182 |
int row = 0; |
183 |
c.gridy = row++; |
184 |
c.gridwidth = 1;
|
185 |
pnlIntervalGroup.add(getRbDistance(), c); |
186 |
c.gridx = 1;
|
187 |
c.gridwidth = 2;
|
188 |
pnlIntervalGroup.add(getPnlDistance(), c); |
189 |
|
190 |
c.gridx = 0;
|
191 |
c.gridy = row++; |
192 |
c.gridwidth = 2;
|
193 |
pnlIntervalGroup.add(getRbHorizDiv(), c); |
194 |
c.gridx = 2;
|
195 |
c.gridwidth = 1;
|
196 |
pnlIntervalGroup.add(getTfNumDivHoriz(), c); |
197 |
|
198 |
c.gridy = row++; |
199 |
c.gridx = 0;
|
200 |
c.gridwidth = 2;
|
201 |
pnlIntervalGroup.add(getRbVertDiv(), c); |
202 |
c.gridx = 2;
|
203 |
c.gridwidth = 1;
|
204 |
pnlIntervalGroup.add(getTfNumDivVert(), c); |
205 |
|
206 |
getRbDistance().setSelected(true);
|
207 |
getBtnGrpInterval().add(getRbDistance()); |
208 |
getBtnGrpInterval().add(getRbVertDiv()); |
209 |
getBtnGrpInterval().add(getRbHorizDiv()); |
210 |
} |
211 |
return pnlIntervalGroup;
|
212 |
} |
213 |
|
214 |
private JRadioButton getRbHorizDiv() { |
215 |
if (rbHorizDiv==null) { |
216 |
rbHorizDiv = new JRadioButton(Messages.getText("Number_of_horizontal_divisions")); |
217 |
rbDistance.setSelected(fframegrid.getUseNumDivisions()==FFrameGrid.NUM_DIVISIONS_HORIZ_MODE); |
218 |
} |
219 |
return rbHorizDiv;
|
220 |
} |
221 |
|
222 |
private JRadioButton getRbVertDiv() { |
223 |
if (rbVertDiv==null) { |
224 |
rbVertDiv = new JRadioButton(Messages.getText("Number_of_vertical_divisions")); |
225 |
rbDistance.setSelected(fframegrid.getUseNumDivisions()==FFrameGrid.NUM_DIVISIONS_VERT_MODE); |
226 |
} |
227 |
return rbVertDiv;
|
228 |
} |
229 |
|
230 |
private JRadioButton getRbDistance() { |
231 |
if (rbDistance==null) { |
232 |
rbDistance = new JRadioButton(Messages.getText("Distance")); |
233 |
rbDistance.setSelected(fframegrid.getUseNumDivisions()==FFrameGrid.FIXED_DISTANCE_MODE); |
234 |
} |
235 |
return rbDistance;
|
236 |
} |
237 |
|
238 |
private JPanel getPnlDistance() { |
239 |
if (pnlDistance==null) { |
240 |
pnlDistance = new JPanel(new GridBagLayout()); |
241 |
GridBagConstraints c = new GridBagConstraints(); |
242 |
|
243 |
int row = 0; |
244 |
c.insets = new Insets(0, 4, 4, 4); |
245 |
c.gridy = row++; |
246 |
c.gridx = 0;
|
247 |
c.anchor = GridBagConstraints.LINE_START;
|
248 |
JLabel labelX = new JLabel("x"); |
249 |
pnlDistance.add(labelX, c); |
250 |
c.gridx = 1;
|
251 |
pnlDistance.add(getTxtIntervalX(), c); |
252 |
lblUnitsX = new JLabel(); |
253 |
c.gridx = 2;
|
254 |
pnlDistance.add(lblUnitsX, c); |
255 |
|
256 |
c.insets = defaultInsets; |
257 |
c.gridy = row++; |
258 |
c.gridx = 0;
|
259 |
JLabel labelY = new JLabel("y"); |
260 |
pnlDistance.add(labelY, c); |
261 |
c.gridx = 1;
|
262 |
pnlDistance.add(getTxtIntervalY(), c); |
263 |
lblUnitsY = new JLabel(); |
264 |
c.gridx = 2;
|
265 |
pnlDistance.add(lblUnitsY, c); |
266 |
|
267 |
} |
268 |
return pnlDistance;
|
269 |
} |
270 |
|
271 |
private ButtonGroup getBtnGrpInterval() { |
272 |
if (btGrpInterval==null) { |
273 |
btGrpInterval = new ButtonGroup(); |
274 |
} |
275 |
return btGrpInterval;
|
276 |
} |
277 |
|
278 |
private NumberTextField getTfNumDivHoriz() {
|
279 |
if (tfNumDivHoriz==null) { |
280 |
tfNumDivHoriz = new NumberTextField(3); |
281 |
tfNumDivHoriz.addFocusListener(new FocusListener() { |
282 |
public void focusLost(FocusEvent e) { |
283 |
if (getRbHorizDiv().isSelected()) {
|
284 |
calculateDistance(1, tfNumDivHoriz.getIntValue());
|
285 |
} |
286 |
} |
287 |
public void focusGained(FocusEvent e) {} |
288 |
}); |
289 |
tfNumDivHoriz.setValue(5);
|
290 |
} |
291 |
return tfNumDivHoriz;
|
292 |
} |
293 |
protected void calculateDistance(int axis, int numDivisions) { |
294 |
if (fframeview!=null && |
295 |
fframeview.getMapContext().getViewPort().getAdjustedEnvelope()!=null) {
|
296 |
Envelope env = fframeview.getMapContext().getViewPort().getAdjustedEnvelope(); |
297 |
double interval = IntervalUtils.roundIntervalDivision(env.getLength(axis), numDivisions);
|
298 |
getTxtIntervalX().setText(String.valueOf(interval));
|
299 |
getTxtIntervalY().setText(String.valueOf(interval));
|
300 |
} |
301 |
} |
302 |
|
303 |
private NumberTextField getTfNumDivVert() {
|
304 |
if (tfNumDivVert==null) { |
305 |
tfNumDivVert = new NumberTextField(3); |
306 |
tfNumDivVert.addFocusListener(new FocusListener() { |
307 |
public void focusLost(FocusEvent e) { |
308 |
if (getRbVertDiv().isSelected()) {
|
309 |
calculateDistance(0, tfNumDivVert.getIntValue());
|
310 |
} |
311 |
} |
312 |
public void focusGained(FocusEvent e) {} |
313 |
}); |
314 |
tfNumDivVert.setValue(5);
|
315 |
} |
316 |
return tfNumDivVert;
|
317 |
} |
318 |
|
319 |
/**
|
320 |
* This method initializes txtIntervalY
|
321 |
*
|
322 |
* @return javax.swing.JTextField
|
323 |
*/
|
324 |
private JTextField getTxtIntervalY() { |
325 |
if (txtIntervalY == null) { |
326 |
txtIntervalY = new JTextField(10); |
327 |
txtIntervalY.setText(String.valueOf(fframegrid.getIntervalY()));
|
328 |
} |
329 |
return txtIntervalY;
|
330 |
} |
331 |
|
332 |
/**
|
333 |
* This method initializes jPanel8
|
334 |
*
|
335 |
* @return javax.swing.JPanel
|
336 |
*/
|
337 |
private JPanel getPnlSymbologyGroup() { |
338 |
if (jPanel8 == null) { |
339 |
jPanel8 = new JPanel(); |
340 |
jPanel8.setLayout(new BoxLayout(getPnlSymbologyGroup(), BoxLayout.Y_AXIS)); |
341 |
jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder( |
342 |
null, PluginServices.getText(this, "Simbologia"), |
343 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
344 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
345 |
jPanel8.add(getJPanel9(), null);
|
346 |
jPanel8.add(getBSymbol(), null);
|
347 |
} |
348 |
return jPanel8;
|
349 |
} |
350 |
|
351 |
/**
|
352 |
* This method initializes jPanel9
|
353 |
*
|
354 |
* @return javax.swing.JPanel
|
355 |
*/
|
356 |
private JPanel getJPanel9() { |
357 |
if (jPanel9 == null) { |
358 |
jPanel9 = new JPanel(); |
359 |
jPanel9.add(getRbPoints(), null);
|
360 |
jPanel9.add(getRbLines(), null);
|
361 |
} |
362 |
return jPanel9;
|
363 |
} |
364 |
|
365 |
/**
|
366 |
* This method initializes rbPoints
|
367 |
*
|
368 |
* @return javax.swing.JRadioButton
|
369 |
*/
|
370 |
private JRadioButton getRbPoints() { |
371 |
if (rbPoints == null) { |
372 |
rbPoints = new JRadioButton(); |
373 |
bg.add(rbPoints); |
374 |
rbPoints.setSelected(!fframegrid.isLine()); |
375 |
rbPoints.setText(PluginServices.getText(this, "points")); |
376 |
} |
377 |
return rbPoints;
|
378 |
} |
379 |
|
380 |
/**
|
381 |
* This method initializes rbLines
|
382 |
*
|
383 |
* @return javax.swing.JRadioButton
|
384 |
*/
|
385 |
private JRadioButton getRbLines() { |
386 |
if (rbLines == null) { |
387 |
rbLines = new JRadioButton(); |
388 |
bg.add(rbLines); |
389 |
rbLines.setSelected(fframegrid.isLine()); |
390 |
rbLines.setText(PluginServices.getText(this, "lines")); |
391 |
} |
392 |
return rbLines;
|
393 |
} |
394 |
|
395 |
/**
|
396 |
* This method initializes bSymbol
|
397 |
*
|
398 |
* @return javax.swing.JButton
|
399 |
*/
|
400 |
private JButton getBSymbol() { |
401 |
if (bSymbol == null) { |
402 |
bSymbol = new JButton(); |
403 |
bSymbol.setText(PluginServices.getText(this, "symbol")); |
404 |
bSymbol.addActionListener(new java.awt.event.ActionListener() {
|
405 |
|
406 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
407 |
PanelEditSymbol pes = new PanelEditSymbol();
|
408 |
if (getRbLines().isSelected()) {
|
409 |
pes.setSymbol(fframegrid.getSymbolLine()); |
410 |
pes.setShapeType(Geometry.TYPES.CURVE); |
411 |
} else {
|
412 |
pes.setSymbol(fframegrid.getSymbolPoint()); |
413 |
pes.setShapeType(Geometry.TYPES.POINT); |
414 |
} |
415 |
PluginServices.getMDIManager().addWindow(pes); |
416 |
symbol = pes.getSymbol(); |
417 |
// FPanelLegendDefault pld=new FPanelLegendDefault();
|
418 |
// pld.setFSymbol(fframegrid.getSymbolLine());
|
419 |
|
420 |
} |
421 |
}); |
422 |
} |
423 |
return bSymbol;
|
424 |
} |
425 |
|
426 |
/**
|
427 |
* This method initializes jPanel10
|
428 |
*
|
429 |
* @return javax.swing.JPanel
|
430 |
*/
|
431 |
private JPanel getPnlLabelGroup() { |
432 |
if (pnlLabelGroup == null) { |
433 |
pnlLabelGroup = new JPanel(new GridBagLayout()); |
434 |
pnlLabelGroup.setBorder(javax.swing.BorderFactory.createTitledBorder( |
435 |
null, PluginServices.getText(this, "Label"), |
436 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
437 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
438 |
|
439 |
GridBagConstraints c = new GridBagConstraints(); |
440 |
int row = 0; |
441 |
|
442 |
c.insets = defaultInsets; |
443 |
c.gridx = 0;
|
444 |
c.gridy = row++; |
445 |
c.gridwidth = 1;
|
446 |
c.anchor = GridBagConstraints.LINE_START;
|
447 |
pnlLabelGroup.add(new JLabel(Messages.getText("Number_format")), c); |
448 |
c.gridx = 1;
|
449 |
pnlLabelGroup.add(getBtnNumberFormat(), c); |
450 |
|
451 |
c.gridx = 0;
|
452 |
c.gridy = row++; |
453 |
c.gridwidth = 1;
|
454 |
pnlLabelGroup.add(new JLabel(Messages.getText("Horizontal_label_rotation")), c); |
455 |
c.gridx = 1;
|
456 |
pnlLabelGroup.add(getNfRotationHoriz(), c); |
457 |
|
458 |
c.gridy = row++; |
459 |
c.gridx = 0;
|
460 |
pnlLabelGroup.add(new JLabel(Messages.getText("Vertical_label_rotation")), c); |
461 |
c.gridx = 1;
|
462 |
pnlLabelGroup.add(getNfRotationVert(), c); |
463 |
|
464 |
c.insets = new Insets(4, 0, 4, 4); |
465 |
c.gridx = 0;
|
466 |
c.gridy = row++; |
467 |
c.gridwidth = 2;
|
468 |
pnlLabelGroup.add(getPnlFont(), c); |
469 |
} |
470 |
return pnlLabelGroup;
|
471 |
} |
472 |
|
473 |
private JButton getBtnNumberFormat() { |
474 |
if (btnNumberFormat==null) { |
475 |
btnNumberFormat = new JButton(Messages.getText("Format")); |
476 |
btnNumberFormat.addActionListener(new java.awt.event.ActionListener() {
|
477 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
478 |
openDecimalFormatDialog(); |
479 |
} |
480 |
}); |
481 |
} |
482 |
return btnNumberFormat;
|
483 |
} |
484 |
|
485 |
protected void openDecimalFormatDialog() { |
486 |
final DecimalFormatDialog dialog = new DecimalFormatDialog(null, null); |
487 |
dialog.addOkButtonActionListener(new ActionListener() { |
488 |
public void actionPerformed(ActionEvent e) { |
489 |
applyDecimalFormatSettings(dialog.getPanel()); |
490 |
} |
491 |
|
492 |
}); |
493 |
dialog.getPanel().setFormat(fframegrid.getLabelFormat()); |
494 |
PluginServices.getMDIManager().addWindow(dialog); |
495 |
} |
496 |
|
497 |
protected void applyDecimalFormatSettings(DecimalFormatPanel p) { |
498 |
format = p.getFormat(); |
499 |
} |
500 |
|
501 |
private JIncrementalNumberField getNfRotationHoriz() {
|
502 |
if (nfRotationHoriz==null) { |
503 |
Cleaner cleaner = ValidatingTextField.NUMBER_CLEANER; |
504 |
Validator validator = ValidatingTextField.INTEGER_VALIDATOR;
|
505 |
nfRotationHoriz = new JIncrementalNumberField("rotationH", 3, validator, cleaner, 0.0d, 360.0d, 1.0); |
506 |
nfRotationHoriz.setInteger((int)fframegrid.getHorizLabelRotation());
|
507 |
} |
508 |
return nfRotationHoriz;
|
509 |
} |
510 |
|
511 |
private JIncrementalNumberField getNfRotationVert() {
|
512 |
if (nfRotationVert==null) { |
513 |
Cleaner cleaner = ValidatingTextField.NUMBER_CLEANER; |
514 |
Validator validator = ValidatingTextField.INTEGER_VALIDATOR;
|
515 |
nfRotationVert = new JIncrementalNumberField("rotationV", 3, validator, cleaner, 0.0d, 360.0d, 1.0); |
516 |
nfRotationVert.setInteger((int)fframegrid.getVertLabelRotation());
|
517 |
} |
518 |
return nfRotationVert;
|
519 |
} |
520 |
|
521 |
/**
|
522 |
* This method initializes jPanel11
|
523 |
*
|
524 |
* @return javax.swing.JPanel
|
525 |
*/
|
526 |
private JPanel getPnlFont() { |
527 |
if (pnlFont == null) { |
528 |
pnlFont = new JPanel(); |
529 |
pnlFont.add(new JLabel(Messages.getText("Font_type")), null); |
530 |
pnlFont.add(getJButton(), null);
|
531 |
pnlFont.add(getColorChooserPanel(), null);
|
532 |
} |
533 |
return pnlFont;
|
534 |
} |
535 |
|
536 |
/**
|
537 |
* This method initializes jButton
|
538 |
*
|
539 |
* @return javax.swing.JButton
|
540 |
*/
|
541 |
private JButton getJButton() { |
542 |
if (jButton == null) { |
543 |
jButton = new JButton(); |
544 |
jButton.setText(PluginServices.getText(this, "Font")); |
545 |
m_font = fframegrid.getFont(); |
546 |
jButton.addActionListener(new java.awt.event.ActionListener() {
|
547 |
|
548 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
549 |
Font font =
|
550 |
FontChooser.showDialog(PluginServices.getText(this,
|
551 |
"__seleccion_de_fuente"), m_font);
|
552 |
if (font != null) |
553 |
m_font = font; // fchoser=new
|
554 |
// FontChooser();
|
555 |
// //$NON-NLS-1$
|
556 |
} |
557 |
}); |
558 |
} |
559 |
return jButton;
|
560 |
} |
561 |
|
562 |
/**
|
563 |
* This method initializes colorChooserPanel
|
564 |
*
|
565 |
* @return com.iver.cit.gvsig.gui.panels.ColorChooserPanel
|
566 |
*/
|
567 |
private ColorChooserPanel getColorChooserPanel() {
|
568 |
if (colorChooserPanel == null) { |
569 |
colorChooserPanel = new ColorChooserPanel();
|
570 |
colorChooserPanel.setAlpha(255);
|
571 |
colorChooserPanel.setColor(fframegrid.getFontColor()); |
572 |
} |
573 |
return colorChooserPanel;
|
574 |
} |
575 |
|
576 |
public IFFrame getFFrame() {
|
577 |
return newFFrameGrid;
|
578 |
} |
579 |
|
580 |
private AcceptCancelPanel getAcceptCancelPanel() {
|
581 |
if (accept == null) { |
582 |
ActionListener okAction, cancelAction;
|
583 |
okAction = new java.awt.event.ActionListener() {
|
584 |
|
585 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
586 |
try {
|
587 |
newFFrameGrid = (FFrameGrid) fframegrid.clone(); |
588 |
newFFrameGrid.setFFrameDependence(fframeview); |
589 |
// FIXME: use the new properties here
|
590 |
|
591 |
newFFrameGrid |
592 |
.setIntervalX(Double.parseDouble(getTxtIntervalX()
|
593 |
.getText().toString())); |
594 |
newFFrameGrid |
595 |
.setIntervalY(Double.parseDouble(getTxtIntervalY()
|
596 |
.getText().toString())); |
597 |
|
598 |
if (getRbLines().isSelected()) {
|
599 |
if (symbol != null) |
600 |
newFFrameGrid.setSymbolLine(symbol); |
601 |
} else {
|
602 |
if (symbol != null) |
603 |
newFFrameGrid.setSymbolPoint(symbol); |
604 |
} |
605 |
|
606 |
newFFrameGrid.setTextColor(getColorChooserPanel() |
607 |
.getColor()); |
608 |
newFFrameGrid.setSizeFont(m_font.getSize()); |
609 |
newFFrameGrid.setIsLine(getRbLines().isSelected()); |
610 |
newFFrameGrid.setFont(m_font); |
611 |
newFFrameGrid.setRotation(fframeview.getRotation()); |
612 |
newFFrameGrid.setHorizLabelRotation(getNfRotationHoriz().getInteger()); |
613 |
newFFrameGrid.setVertLabelRotation(getNfRotationVert().getInteger()); |
614 |
newFFrameGrid.setLabelFormat(format); |
615 |
if (getRbDistance().isSelected()) {
|
616 |
newFFrameGrid.setUseNumDivisions(FFrameGrid.FIXED_DISTANCE_MODE); |
617 |
} |
618 |
else if (getRbHorizDiv().isSelected()) { |
619 |
newFFrameGrid.setUseNumDivisions(FFrameGrid.NUM_DIVISIONS_HORIZ_MODE); |
620 |
} |
621 |
else if (getRbVertDiv().isSelected()) { |
622 |
newFFrameGrid.setUseNumDivisions(FFrameGrid.NUM_DIVISIONS_VERT_MODE); |
623 |
} |
624 |
} catch (CloneNotSupportedException e1) { |
625 |
LOG.error("It is not possible clonate the object", e);
|
626 |
} |
627 |
PluginServices.getMDIManager().closeWindow( |
628 |
FFrameGridDialog.this); |
629 |
notifyDialogClosed(); |
630 |
} |
631 |
}; |
632 |
cancelAction = new java.awt.event.ActionListener() {
|
633 |
|
634 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
635 |
newFFrameGrid = null;
|
636 |
PluginServices.getMDIManager().closeWindow( |
637 |
FFrameGridDialog.this); |
638 |
notifyDialogClosed(); |
639 |
} |
640 |
}; |
641 |
accept = new AcceptCancelPanel(okAction, cancelAction);
|
642 |
accept.setEnabled(true);
|
643 |
accept.setVisible(true);
|
644 |
} |
645 |
return accept;
|
646 |
} |
647 |
|
648 |
public WindowInfo getWindowInfo() {
|
649 |
WindowInfo m_viewinfo = |
650 |
new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
|
651 |
m_viewinfo.setTitle(PluginServices.getText(this, "Grid_settings")); |
652 |
m_viewinfo.setWidth(450);
|
653 |
m_viewinfo.setHeight(420);
|
654 |
|
655 |
return m_viewinfo;
|
656 |
} |
657 |
|
658 |
public boolean getIsAcepted() { |
659 |
// TODO Auto-generated method stub
|
660 |
return false; |
661 |
} |
662 |
|
663 |
public void setFFrameView(FFrameView fview) { |
664 |
fframeview = fview; |
665 |
//Set the label
|
666 |
if (fframeview.getMapContext() != null){ |
667 |
lblUnitsX.setText(Messages.getText(MapContext.getDistanceNames()[ |
668 |
fframeview.getMapContext().getViewPort().getMapUnits()])); |
669 |
lblUnitsY.setText(Messages.getText(MapContext.getDistanceNames()[ |
670 |
fframeview.getMapContext().getViewPort().getMapUnits()])); |
671 |
} |
672 |
} |
673 |
|
674 |
public Object getWindowProfile() { |
675 |
return WindowInfo.DIALOG_PROFILE;
|
676 |
} |
677 |
|
678 |
public void setRectangle(Rectangle2D r) { |
679 |
// nothing to do as this fframe takes the size from the associated fframeview
|
680 |
} |
681 |
|
682 |
} // @jve:decl-index=0:visual-constraint="10,10"
|