Statistics
| Revision:

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 @ 717

History | View | Annotate | Download (25.5 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.BorderFactory;
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.IFFrame;
50
import org.gvsig.app.project.documents.layout.fframes.gui.numberFormat.DecimalFormatDialog;
51
import org.gvsig.app.project.documents.layout.fframes.gui.numberFormat.DecimalFormatPanel;
52
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
53
import org.gvsig.app.project.documents.view.legend.gui.PanelEditSymbol;
54
import org.gvsig.fmap.geom.Geometry;
55
import org.gvsig.fmap.geom.primitive.Envelope;
56
import org.gvsig.fmap.mapcontext.MapContext;
57
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
58
import org.gvsig.gui.awt.text.RotatedTextUtils;
59
import org.gvsig.gui.beans.AcceptCancelPanel;
60
import org.gvsig.gui.beans.numberTextField.NumberTextField;
61
import org.gvsig.gui.beans.simplecombobox.SimpleComboBox;
62
import org.gvsig.gui.beans.swing.JNumberSpinner;
63
import org.gvsig.i18n.Messages;
64
import org.gvsig.math.intervals.IntervalUtils;
65

    
66
public class FFrameGridDialog extends AbstractFFrameDialog implements
67
IFFrameDialog {
68

    
69
    private static final long serialVersionUID = 1L;
70
    private JPanel pnlMain = null;
71
    private JTextField txtIntervalX = null;
72
    private JPanel pnlIntervalGroup = null;
73
    private JTextField txtIntervalY = null;
74
    private JLabel lblUnitsX = null;
75
    private JLabel lblUnitsY = null;
76
    private JPanel jPanel8 = null;
77
    private JPanel jPanel9 = null;
78
    private JRadioButton rbPoints = null;
79
    private JRadioButton rbLines = null;
80
    private JButton bSymbol = null;
81
    private JPanel pnlLabelGroup = null;
82
    private JPanel pnlFont = null;
83
    private JButton jButton = null;
84
    private ColorChooserPanel colorChooserPanel = null;
85

    
86
    private FFrameGrid fframegrid;
87
//    private FFrameView fframeview;
88
    private AcceptCancelPanel accept;
89
    private FFrameGrid newFFrameGrid;
90
    // private Color textcolor;
91
    private ISymbol symbol;
92
    private Font m_font;
93
    private ButtonGroup bg = new ButtonGroup();
94
        private NumberTextField tfNumDivHoriz = null;
95
        private NumberTextField tfNumDivVert = null;
96
        private JRadioButton rbHorizDiv = null;
97
        private JRadioButton rbVertDiv = null;
98
        private JPanel pnlDistance = null;
99
        private JRadioButton rbDistance = null;
100
        private JButton btnNumberFormat = null;
101
        private JNumberSpinner nfRotationHoriz = null;
102
        private JNumberSpinner nfRotationVert = null;
103
        private ButtonGroup btGrpInterval = null;
104
        private static final Insets defaultInsets = new Insets(4, 4, 4, 4);
105
        private DecimalFormat format = new DecimalFormat();
106
        private SimpleComboBox cbLblAnchor=null;
107
    private MapContext mapContext;
108
    private double frameRotation;
109

    
110
    public FFrameGridDialog(LayoutPanel layout, FFrameGrid fframe) {
111
        super(layout, fframe);
112
        this.fframegrid = fframe;
113
        initialize();
114
    }
115

    
116
    /**
117
     * This method initializes this
118
     *
119
     * @return void
120
     */
121
    private void initialize() {
122
        this.setLayout(new BorderLayout());
123
        this.add(getPnlMain(), java.awt.BorderLayout.CENTER);
124
        this.add(getAcceptCancelPanel(), java.awt.BorderLayout.SOUTH);
125
    }
126

    
127
    /**
128
     * This method initializes jPanel1
129
     *
130
     * @return javax.swing.JPanel
131
     */
132
    private JPanel getPnlMain() {
133
        if (pnlMain == null) {
134
            pnlMain = new JPanel(new GridBagLayout());
135
            GridBagConstraints c = new GridBagConstraints();
136
            c.insets = defaultInsets;
137
            c.fill = GridBagConstraints.HORIZONTAL;
138
            c.anchor = GridBagConstraints.FIRST_LINE_START;
139
            c.gridx = 0;
140
            int row = 0;
141
            c.gridy = row++;
142
            c.gridwidth = 1;
143
            pnlMain.add(getPnlIntervalGroup(), c);
144
            c.gridx = 1;
145
            c.fill = GridBagConstraints.NONE;
146
            pnlMain.add(getPnlSymbologyGroup(), c);
147

    
148
            c.gridy = row++;
149
            c.gridx = 0;
150
            c.gridwidth = 2;
151
            c.fill = GridBagConstraints.HORIZONTAL;
152
            pnlMain.add(getPnlLabelGroup(), c);
153

    
154
        }
155
        return pnlMain;
156
    }
157

    
158
    /**
159
     * This method initializes txtIntervalX
160
     *
161
     * @return javax.swing.JTextField
162
     */
163
    private JTextField getTxtIntervalX() {
164
        if (txtIntervalX == null) {
165
            txtIntervalX = new JTextField(10);
166
            txtIntervalX.setText(String.valueOf(fframegrid.getIntervalX()));
167
            txtIntervalX.setName("txtIntervalX");
168
        }
169
        return txtIntervalX;
170
    }
171

    
172
    /**
173
     * This method initializes jPanel6
174
     *
175
     * @return javax.swing.JPanel
176
     */
177
    private JPanel getPnlIntervalGroup() {
178
        if (pnlIntervalGroup == null) {
179
            pnlIntervalGroup = new JPanel(new GridBagLayout());
180
            pnlIntervalGroup.setBorder(BorderFactory.createTitledBorder(Messages.getText( "Interval")));
181
            GridBagConstraints c = new GridBagConstraints();
182

    
183
            c.anchor = GridBagConstraints.FIRST_LINE_START;
184
            c.gridx = 0;
185
            c.insets = defaultInsets;
186
            int row = 0;
187
            c.gridy = row++;
188
            c.gridwidth = 2;
189
            pnlIntervalGroup.add(getRbDistance(), c);
190
            c.gridx = 0;
191
            c.gridwidth = 2;
192
            c.gridy = row++;
193
            c.insets = new Insets(defaultInsets.top, 25, defaultInsets.bottom, defaultInsets.right);
194
            pnlIntervalGroup.add(getPnlDistance(), c);
195

    
196
            c.gridx = 0;
197
            c.gridy = row++;
198
            c.insets = defaultInsets;
199
            c.gridwidth = 1;
200
            pnlIntervalGroup.add(getRbHorizDiv(), c);
201
            c.gridx = 1;
202
            pnlIntervalGroup.add(getTfNumDivHoriz(), c);
203

    
204
            c.gridy = row++;
205
            c.gridx = 0;
206
            pnlIntervalGroup.add(getRbVertDiv(), c);
207
            c.gridx = 1;
208
            pnlIntervalGroup.add(getTfNumDivVert(), c);
209
            getBtnGrpInterval().add(getRbDistance());
210
            getBtnGrpInterval().add(getRbVertDiv());
211
            getBtnGrpInterval().add(getRbHorizDiv());
212
        }
213
        return pnlIntervalGroup;
214
    }
215

    
216
    private JRadioButton getRbHorizDiv() {
217
            if (rbHorizDiv==null) {
218
                    rbHorizDiv = new JRadioButton(Messages.getText("Number_of_horizontal_divisions"));
219
                    rbHorizDiv.setSelected(fframegrid.getUseNumDivisions()==FFrameGrid.NUM_DIVISIONS_HORIZ_MODE);
220
            }
221
            return rbHorizDiv;
222
    }
223

    
224
    private JRadioButton getRbVertDiv() {
225
            if (rbVertDiv==null) {
226
                    rbVertDiv = new JRadioButton(Messages.getText("Number_of_vertical_divisions"));
227
                    rbVertDiv.setSelected(fframegrid.getUseNumDivisions()==FFrameGrid.NUM_DIVISIONS_VERT_MODE);
228
            }
229
            return rbVertDiv;
230
    }
231

    
232
    private JRadioButton getRbDistance() {
233
            if (rbDistance==null) {
234
                    rbDistance = new JRadioButton(Messages.getText("Distance"));
235
                    rbDistance.setSelected(fframegrid.getUseNumDivisions()==FFrameGrid.FIXED_DISTANCE_MODE);
236
            }
237
            return rbDistance;
238
    }
239

    
240
    private JPanel getPnlDistance() {
241
            if (pnlDistance==null) {
242
                    pnlDistance = new JPanel(new GridBagLayout());
243
                    GridBagConstraints c = new GridBagConstraints();
244

    
245
                    int row = 0;
246
                    c.insets = new Insets(0, 0, 4, 4);
247
                    c.gridy = row++;
248
            c.gridx = 0;
249
            c.anchor = GridBagConstraints.LINE_START;
250
            JLabel labelX = new JLabel("x");
251
                    pnlDistance.add(labelX, c);
252
                    c.gridx = 1;
253
                    c.insets = defaultInsets;
254
                    pnlDistance.add(getTxtIntervalX(), c);
255
                    lblUnitsX = new JLabel();
256
                    c.insets = new Insets(0, 4, 4, 0);
257
                    c.gridx = 2;
258
                    pnlDistance.add(lblUnitsX, c);
259

    
260
                    c.insets = new Insets(4, 0, 0, 4);
261
                    c.gridy = row++;
262
            c.gridx = 0;
263
            JLabel labelY = new JLabel("y");
264
                    pnlDistance.add(labelY, c);
265
            c.insets = defaultInsets;
266
                    c.gridx = 1;
267
                    pnlDistance.add(getTxtIntervalY(), c);
268
                    lblUnitsY = new JLabel();
269
                    c.gridx = 2;
270
                    c.insets = new Insets(4, 4, 0, 0);
271
                    pnlDistance.add(lblUnitsY, c);
272

    
273
            }
274
            return pnlDistance;
275
    }
276

    
277
    private ButtonGroup getBtnGrpInterval() {
278
            if (btGrpInterval==null) {
279
                    btGrpInterval = new ButtonGroup();
280
            }
281
            return btGrpInterval;
282
    }
283

    
284
    private NumberTextField getTfNumDivHoriz() {
285
            if (tfNumDivHoriz==null) {
286
                    tfNumDivHoriz = new NumberTextField(3);
287
                    tfNumDivHoriz.addFocusListener(new FocusListener() {
288
                                public void focusLost(FocusEvent e) {
289
                                        if (getRbHorizDiv().isSelected()) {
290
                                                calculateDistance(1, tfNumDivHoriz.getIntValue());
291
                                        }
292
                                }
293
                                public void focusGained(FocusEvent e) {}
294
                        });
295
                    tfNumDivHoriz.setValue(new Integer(fframegrid.getNumDivisionsHoriz()));
296
            }
297
            return tfNumDivHoriz;
298
    }
299
    protected void calculateDistance(int axis, int numDivisions) {
300
            if (mapContext.getViewPort().getAdjustedEnvelope()!=null) {
301
                    Envelope env = mapContext.getViewPort().getAdjustedEnvelope();
302
                    double interval = IntervalUtils.roundIntervalDivision(env.getLength(axis), numDivisions);
303
                    getTxtIntervalX().setText(String.valueOf(interval));
304
                    getTxtIntervalY().setText(String.valueOf(interval));
305
            }
306
    }
307

    
308
    private NumberTextField getTfNumDivVert() {
309
            if (tfNumDivVert==null) {
310
                    tfNumDivVert = new NumberTextField(3);
311
                    tfNumDivVert.addFocusListener(new FocusListener() {
312
                                public void focusLost(FocusEvent e) {
313
                                        if (getRbVertDiv().isSelected()) {
314
                                                calculateDistance(0, tfNumDivVert.getIntValue());
315
                                        }
316
                                }
317
                                public void focusGained(FocusEvent e) {}
318
                        });
319
                    tfNumDivVert.setValue(new Integer(fframegrid.getNumDivisionsVert()));
320
            }
321
            return tfNumDivVert;
322
    }
323

    
324
    /**
325
     * This method initializes txtIntervalY
326
     *
327
     * @return javax.swing.JTextField
328
     */
329
    private JTextField getTxtIntervalY() {
330
        if (txtIntervalY == null) {
331
            txtIntervalY = new JTextField(10);
332
            txtIntervalY.setText(String.valueOf(fframegrid.getIntervalY()));
333
        }
334
        return txtIntervalY;
335
    }
336

    
337
    /**
338
     * This method initializes jPanel8
339
     *
340
     * @return javax.swing.JPanel
341
     */
342
    private JPanel getPnlSymbologyGroup() {
343
        if (jPanel8 == null) {
344
            jPanel8 = new JPanel(new GridBagLayout());
345
            GridBagConstraints c = new GridBagConstraints();
346

    
347
            jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(
348
                                    Messages.getText("Simbologia")));
349
            c.anchor = GridBagConstraints.FIRST_LINE_START;
350
            c.gridy = 0;
351
            c.gridx = 0;
352
            jPanel8.add(getJPanel9(), c);
353
            c.anchor = GridBagConstraints.FIRST_LINE_END;
354
            c.gridy = 1;
355
            jPanel8.add(getBSymbol(), c);
356
        }
357
        return jPanel8;
358
    }
359

    
360
    /**
361
     * This method initializes jPanel9
362
     *
363
     * @return javax.swing.JPanel
364
     */
365
    private JPanel getJPanel9() {
366
        if (jPanel9 == null) {
367
            jPanel9 = new JPanel(new GridBagLayout());
368
            GridBagConstraints c = new GridBagConstraints();
369
            c.gridx = 0;
370
            c.gridy = 0;
371
            c.anchor = GridBagConstraints.FIRST_LINE_START;
372

    
373
            c.insets = new Insets(0, 0, 0, 8);
374
            jPanel9.add(getRbPoints(), c);
375
            c.insets = new Insets(0, 0, 0, 0);
376
            c.gridx = 1;
377
            jPanel9.add(getRbLines(), c);
378
        }
379
        return jPanel9;
380
    }
381

    
382
    /**
383
     * This method initializes rbPoints
384
     *
385
     * @return javax.swing.JRadioButton
386
     */
387
    private JRadioButton getRbPoints() {
388
        if (rbPoints == null) {
389
            rbPoints = new JRadioButton();
390
            bg.add(rbPoints);
391
            rbPoints.setSelected(!fframegrid.isLine());
392
            rbPoints.setText(PluginServices.getText(this, "points"));
393
        }
394
        return rbPoints;
395
    }
396

    
397
    /**
398
     * This method initializes rbLines
399
     *
400
     * @return javax.swing.JRadioButton
401
     */
402
    private JRadioButton getRbLines() {
403
        if (rbLines == null) {
404
            rbLines = new JRadioButton();
405
            bg.add(rbLines);
406
            rbLines.setSelected(fframegrid.isLine());
407
            rbLines.setText(PluginServices.getText(this, "lines"));
408
        }
409
        return rbLines;
410
    }
411

    
412
    /**
413
     * This method initializes bSymbol
414
     *
415
     * @return javax.swing.JButton
416
     */
417
    private JButton getBSymbol() {
418
        if (bSymbol == null) {
419
            bSymbol = new JButton();
420
            bSymbol.setText(PluginServices.getText(this, "symbol"));
421
            bSymbol.addActionListener(new java.awt.event.ActionListener() {
422

    
423
                public void actionPerformed(java.awt.event.ActionEvent e) {
424
                    PanelEditSymbol pes = new PanelEditSymbol();
425
                    if (getRbLines().isSelected()) {
426
                        pes.setSymbol(fframegrid.getSymbolLine());
427
                        pes.setShapeType(Geometry.TYPES.CURVE);
428
                    } else {
429
                        pes.setSymbol(fframegrid.getSymbolPoint());
430
                        pes.setShapeType(Geometry.TYPES.POINT);
431
                    }
432
                    PluginServices.getMDIManager().addWindow(pes);
433
                    symbol = pes.getSymbol();
434
                }
435
            });
436
        }
437
        return bSymbol;
438
    }
439

    
440
    /**
441
     * This method initializes jPanel10
442
     *
443
     * @return javax.swing.JPanel
444
     */
445
    private JPanel getPnlLabelGroup() {
446
        if (pnlLabelGroup == null) {
447
            pnlLabelGroup = new JPanel(new GridBagLayout());
448
            pnlLabelGroup.setBorder(BorderFactory.createTitledBorder(
449
                            Messages.getText("Label")));
450

    
451
            GridBagConstraints c = new GridBagConstraints();
452
            int row = 0;
453

    
454
            c.insets = defaultInsets;
455
            c.gridx = 0;
456
            c.gridy = row++;
457
            c.gridwidth = 1;
458
            c.anchor = GridBagConstraints.LINE_START;
459
            pnlLabelGroup.add(new JLabel(Messages.getText("Number_format")), c);
460
            c.gridx = 1;
461
            pnlLabelGroup.add(getBtnNumberFormat(), c);
462

    
463
            c.gridx = 0;
464
            c.gridy = row++;
465
            c.gridwidth = 1;
466
            pnlLabelGroup.add(new JLabel(Messages.getText("Horizontal_label_rotation")), c);
467
            c.gridx = 1;
468
            pnlLabelGroup.add(getNfRotationHoriz(), c);
469

    
470
            c.gridy = row++;
471
            c.gridx = 0;
472
            pnlLabelGroup.add(new JLabel(Messages.getText("Vertical_label_rotation")), c);
473
            c.gridx = 1;
474
            pnlLabelGroup.add(getNfRotationVert(), c);
475

    
476
            c.gridy = row++;
477
            c.gridx = 0;
478
            c.fill = GridBagConstraints.NONE;
479
            pnlLabelGroup.add(new JLabel(Messages.getText("Anchor")), c);
480
            c.gridx = 1;
481
            c.fill = GridBagConstraints.HORIZONTAL;
482
            pnlLabelGroup.add(getCbLblAnchor(), c);
483

    
484
            c.gridx = 0;
485
            c.gridy = row++;
486
            c.gridwidth = 2;
487
            pnlLabelGroup.add(getPnlFont(), c);
488
        }
489
        return pnlLabelGroup;
490
    }
491

    
492
    private SimpleComboBox getCbLblAnchor() {
493
            if (cbLblAnchor==null) {
494
                cbLblAnchor = new SimpleComboBox();
495
                cbLblAnchor.addItem(Messages.getText("Corner"), RotatedTextUtils.ANCHOR_CORNER);
496
                cbLblAnchor.addItem(Messages.getText("Center"), RotatedTextUtils.ANCHOR_CENTER);
497
                cbLblAnchor.setSelectedCode(fframegrid.getLabelAnchor());
498
            }
499
            return cbLblAnchor;
500
    }
501

    
502
    private JButton getBtnNumberFormat() {
503
            if (btnNumberFormat==null) {
504
                    btnNumberFormat = new JButton(Messages.getText("Format"));
505
                    format = fframegrid.getLabelFormat();
506
                    btnNumberFormat.addActionListener(new java.awt.event.ActionListener() {
507
                public void actionPerformed(java.awt.event.ActionEvent e) {
508
                        openDecimalFormatDialog();
509
                }
510
                    });
511
            }
512
            return btnNumberFormat;
513
    }
514

    
515
    protected void openDecimalFormatDialog() {
516
            final DecimalFormatDialog dialog = new DecimalFormatDialog(null, null);
517
            dialog.addOkButtonActionListener(new ActionListener() {
518
                        public void actionPerformed(ActionEvent e) {
519
                                applyDecimalFormatSettings(dialog.getPanel());
520
                        }
521

    
522
            });
523
            dialog.getPanel().setFormat(fframegrid.getLabelFormat());
524
            PluginServices.getMDIManager().addWindow(dialog);
525
    }
526

    
527
    protected void applyDecimalFormatSettings(DecimalFormatPanel p) {
528
            format = p.getFormat();
529
    }
530

    
531
    private JNumberSpinner getNfRotationHoriz() {
532
            if (nfRotationHoriz==null) {
533
                    nfRotationHoriz = new JNumberSpinner(0, 3, 0, 360, 1);
534
                    nfRotationHoriz.setInteger((int)fframegrid.getHorizLabelRotation());
535
            }
536
            return nfRotationHoriz;
537
    }
538

    
539
    private JNumberSpinner getNfRotationVert() {
540
            if (nfRotationVert==null) {
541
                    nfRotationVert = new JNumberSpinner(0, 3, 0, 360, 1);
542
                    nfRotationVert.setInteger((int)fframegrid.getVertLabelRotation());
543
            }
544
            return nfRotationVert;
545
    }
546

    
547
    /**
548
     * This method initializes jPanel11
549
     *
550
     * @return javax.swing.JPanel
551
     */
552
    private JPanel getPnlFont() {
553
        if (pnlFont == null) {
554
            pnlFont = new JPanel(new GridBagLayout());
555
            GridBagConstraints c = new GridBagConstraints();
556
            c.anchor = GridBagConstraints.FIRST_LINE_START;
557
            c.insets = new Insets(0, 0, 0, 4);
558
            c.gridy = 0;
559
            c.gridx = 0;
560
            pnlFont.add(new JLabel(Messages.getText("Font_type")), c);
561
            c.gridx = 1;
562
            c.insets = new Insets(0, 4, 0, 4);
563
            pnlFont.add(getJButton(), c);
564
            c.gridx = 2;
565
            c.insets = new Insets(0, 4, 0, 0);
566
            pnlFont.add(getColorChooserPanel(), c);
567
        }
568
        return pnlFont;
569
    }
570

    
571
    /**
572
     * This method initializes jButton
573
     *
574
     * @return javax.swing.JButton
575
     */
576
    private JButton getJButton() {
577
        if (jButton == null) {
578
            jButton = new JButton();
579
            jButton.setText(PluginServices.getText(this, "Font"));
580
            m_font = fframegrid.getFont();
581
            jButton.addActionListener(new java.awt.event.ActionListener() {
582

    
583
                public void actionPerformed(java.awt.event.ActionEvent e) {
584
                    Font font =
585
                        FontChooser.showDialog(PluginServices.getText(this,
586
                        "__seleccion_de_fuente"), m_font);
587
                    if (font != null)
588
                        m_font = font; // fchoser=new
589
                    // FontChooser();
590
                    // //$NON-NLS-1$
591
                }
592
            });
593
        }
594
        return jButton;
595
    }
596

    
597
    /**
598
     * This method initializes colorChooserPanel
599
     *
600
     * @return com.iver.cit.gvsig.gui.panels.ColorChooserPanel
601
     */
602
    private ColorChooserPanel getColorChooserPanel() {
603
        if (colorChooserPanel == null) {
604
            colorChooserPanel = new ColorChooserPanel();
605
            colorChooserPanel.setAlpha(255);
606
            colorChooserPanel.setColor(fframegrid.getFontColor());
607
        }
608
        return colorChooserPanel;
609
    }
610

    
611
    public IFFrame getFFrame() {
612
        return newFFrameGrid;
613
    }
614

    
615
    private AcceptCancelPanel getAcceptCancelPanel() {
616
        if (accept == null) {
617
            ActionListener okAction, cancelAction;
618
            okAction = new java.awt.event.ActionListener() {
619

    
620
                public void actionPerformed(java.awt.event.ActionEvent e) {
621
                    try {
622
                        newFFrameGrid = (FFrameGrid) fframegrid.clone();
623

    
624
                        newFFrameGrid
625
                        .setIntervalX(Double.parseDouble(getTxtIntervalX()
626
                            .getText().toString()));
627
                        newFFrameGrid
628
                        .setIntervalY(Double.parseDouble(getTxtIntervalY()
629
                            .getText().toString()));
630

    
631
                        if (getRbLines().isSelected()) {
632
                            if (symbol != null)
633
                                newFFrameGrid.setSymbolLine(symbol);
634
                        } else {
635
                            if (symbol != null)
636
                                newFFrameGrid.setSymbolPoint(symbol);
637
                        }
638

    
639
                        newFFrameGrid.setTextColor(getColorChooserPanel()
640
                            .getColor());
641
                        newFFrameGrid.setSizeFont(m_font.getSize());
642
                        newFFrameGrid.setIsLine(getRbLines().isSelected());
643
                        newFFrameGrid.setFont(m_font);
644
                        newFFrameGrid.setHorizLabelRotation(getNfRotationHoriz().getInteger());
645
                        newFFrameGrid.setVertLabelRotation(getNfRotationVert().getInteger());
646
                        newFFrameGrid.setLabelAnchor(getCbLblAnchor().getSelectedCode());
647
                        newFFrameGrid.setLabelFormat(format);
648
                        if (getRbDistance().isSelected()) {
649
                                newFFrameGrid.setUseNumDivisions(FFrameGrid.FIXED_DISTANCE_MODE);
650
                        }
651
                        else if (getRbHorizDiv().isSelected()) {
652
                                newFFrameGrid.setUseNumDivisions(FFrameGrid.NUM_DIVISIONS_HORIZ_MODE);
653
                                newFFrameGrid.setNumDivisionsHoriz(getTfNumDivHoriz().getIntValue());
654
                        }
655
                        else if (getRbVertDiv().isSelected()) {
656
                                newFFrameGrid.setUseNumDivisions(FFrameGrid.NUM_DIVISIONS_VERT_MODE);
657
                                newFFrameGrid.setNumDivisionsVert(getTfNumDivVert().getIntValue());
658
                        }
659
                    } catch (CloneNotSupportedException e1) {
660
                        LOG.error("It is not possible clonate the object", e);
661
                    }
662
                    PluginServices.getMDIManager().closeWindow(
663
                        FFrameGridDialog.this);
664
                    notifyDialogClosed();
665
                    fireActionEvent(new ActionEvent(FFrameGridDialog.this, 1, "accept"));
666
                    
667
                }
668
            };
669
            cancelAction = new java.awt.event.ActionListener() {
670

    
671
                public void actionPerformed(java.awt.event.ActionEvent e) {
672
                    newFFrameGrid = null;
673
                    PluginServices.getMDIManager().closeWindow(
674
                        FFrameGridDialog.this);
675
                    notifyDialogClosed();
676
                }
677
            };
678
            accept = new AcceptCancelPanel(okAction, cancelAction);
679
            accept.setEnabled(true);
680
            accept.setVisible(true);
681
        }
682
        return accept;
683
    }
684

    
685
    public WindowInfo getWindowInfo() {
686
        WindowInfo m_viewinfo =
687
            new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
688
        m_viewinfo.setTitle(PluginServices.getText(this, "Grid_settings"));
689
        m_viewinfo.setWidth(620);
690
        m_viewinfo.setHeight(440);
691

    
692
        return m_viewinfo;
693
    }
694

    
695
    public boolean getIsAcepted() {
696
        // TODO Auto-generated method stub
697
        return false;
698
    }
699

    
700
    public void setMapContext(MapContext mapContext) {
701
        this.mapContext = mapContext;
702
        if (mapContext != null){
703
            String mapUnitsText = Messages.getText(MapContext.getDistanceNames()[mapContext.getViewPort().getMapUnits()]);
704
            lblUnitsX.setText(mapUnitsText);
705
            lblUnitsY.setText(mapUnitsText);
706
        }
707
    }
708

    
709
    public void setFrameRotation(double frameRotation) {
710
        this.frameRotation = frameRotation;
711
    }
712

    
713
    public Object getWindowProfile() {
714
        return WindowInfo.DIALOG_PROFILE;
715
    }
716

    
717
        public void setRectangle(Rectangle2D r) {
718
                // nothing to do as this fframe takes the size from the associated fframeview
719
        }
720

    
721
} // @jve:decl-index=0:visual-constraint="10,10"