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

History | View | Annotate | Download (25.6 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.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.awt.text.RotatedTextUtils;
60
import org.gvsig.gui.beans.AcceptCancelPanel;
61
import org.gvsig.gui.beans.numberTextField.NumberTextField;
62
import org.gvsig.gui.beans.simplecombobox.SimpleComboBox;
63
import org.gvsig.gui.beans.swing.JNumberSpinner;
64
import org.gvsig.i18n.Messages;
65
import org.gvsig.math.intervals.IntervalUtils;
66

    
67
public class FFrameGridDialog extends AbstractFFrameDialog implements
68
IFFrameDialog {
69

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

    
87
    private FFrameGrid fframegrid;
88
    private FFrameView fframeview;
89
    private AcceptCancelPanel accept;
90
    private FFrameGrid newFFrameGrid;
91
    // private Color textcolor;
92
    private ISymbol symbol;
93
    private Font m_font;
94
    private ButtonGroup bg = new ButtonGroup();
95
        private NumberTextField tfNumDivHoriz = null;
96
        private NumberTextField tfNumDivVert = null;
97
        private JRadioButton rbHorizDiv = null;
98
        private JRadioButton rbVertDiv = null;
99
        private JPanel pnlDistance = null;
100
        private JRadioButton rbDistance = null;
101
        private JButton btnNumberFormat = null;
102
        private JNumberSpinner nfRotationHoriz = null; 
103
        private JNumberSpinner nfRotationVert = 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 SimpleComboBox cbLblAnchor=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 = defaultInsets;
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
            c.gridwidth = 1;
142
            pnlMain.add(getPnlIntervalGroup(), c);
143
            c.gridx = 1;
144
            c.fill = GridBagConstraints.NONE;
145
            pnlMain.add(getPnlSymbologyGroup(), c);
146
            
147
            c.gridy = row++;
148
            c.gridx = 0;
149
            c.gridwidth = 2;
150
            c.fill = GridBagConstraints.HORIZONTAL;
151
            pnlMain.add(getPnlLabelGroup(), c);
152

    
153
        }
154
        return pnlMain;
155
    }
156

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

    
171
    /**
172
     * This method initializes jPanel6
173
     * 
174
     * @return javax.swing.JPanel
175
     */
176
    private JPanel getPnlIntervalGroup() {
177
        if (pnlIntervalGroup == null) {
178
            pnlIntervalGroup = new JPanel(new GridBagLayout());
179
            pnlIntervalGroup.setBorder(BorderFactory.createTitledBorder(Messages.getText( "Interval")));
180
            GridBagConstraints c = new GridBagConstraints();
181
            
182
            c.anchor = GridBagConstraints.FIRST_LINE_START;
183
            c.gridx = 0;
184
            c.insets = defaultInsets;
185
            int row = 0;
186
            c.gridy = row++;
187
            c.gridwidth = 2;
188
            pnlIntervalGroup.add(getRbDistance(), c); 
189
            c.gridx = 0;
190
            c.gridwidth = 2;
191
            c.gridy = row++;
192
            c.insets = new Insets(defaultInsets.top, 25, defaultInsets.bottom, defaultInsets.right);
193
            pnlIntervalGroup.add(getPnlDistance(), c);
194
            
195
            c.gridx = 0;
196
            c.gridy = row++;
197
            c.insets = defaultInsets;
198
            c.gridwidth = 1;
199
            pnlIntervalGroup.add(getRbHorizDiv(), c);
200
            c.gridx = 1;
201
            pnlIntervalGroup.add(getTfNumDivHoriz(), c);
202
            
203
            c.gridy = row++;
204
            c.gridx = 0;
205
            pnlIntervalGroup.add(getRbVertDiv(), c);
206
            c.gridx = 1;
207
            pnlIntervalGroup.add(getTfNumDivVert(), c);
208
            
209
            getRbDistance().setSelected(true);
210
            getBtnGrpInterval().add(getRbDistance());
211
            getBtnGrpInterval().add(getRbVertDiv());
212
            getBtnGrpInterval().add(getRbHorizDiv());
213
        }
214
        return pnlIntervalGroup;
215
    }
216
    
217
    private JRadioButton getRbHorizDiv() {
218
            if (rbHorizDiv==null) {
219
                    rbHorizDiv = new JRadioButton(Messages.getText("Number_of_horizontal_divisions"));
220
                    rbDistance.setSelected(fframegrid.getUseNumDivisions()==FFrameGrid.NUM_DIVISIONS_HORIZ_MODE);
221
            }
222
            return rbHorizDiv;
223
    }
224
    
225
    private JRadioButton getRbVertDiv() {
226
            if (rbVertDiv==null) {
227
                    rbVertDiv = new JRadioButton(Messages.getText("Number_of_vertical_divisions"));
228
                    rbDistance.setSelected(fframegrid.getUseNumDivisions()==FFrameGrid.NUM_DIVISIONS_VERT_MODE);
229
            }
230
            return rbVertDiv;
231
    }
232
    
233
    private JRadioButton getRbDistance() {
234
            if (rbDistance==null) {
235
                    rbDistance = new JRadioButton(Messages.getText("Distance"));
236
                    rbDistance.setSelected(fframegrid.getUseNumDivisions()==FFrameGrid.FIXED_DISTANCE_MODE);
237
            }
238
            return rbDistance;
239
    }
240
    
241
    private JPanel getPnlDistance() {
242
            if (pnlDistance==null) {
243
                    pnlDistance = new JPanel(new GridBagLayout());
244
                    GridBagConstraints c = new GridBagConstraints();
245
                    
246
                    int row = 0;
247
                    c.insets = new Insets(0, 0, 4, 4);
248
                    c.gridy = row++;
249
            c.gridx = 0;
250
            c.anchor = GridBagConstraints.LINE_START;
251
            JLabel labelX = new JLabel("x");
252
                    pnlDistance.add(labelX, c);
253
                    c.gridx = 1;
254
                    c.insets = defaultInsets;
255
                    pnlDistance.add(getTxtIntervalX(), c);
256
                    lblUnitsX = new JLabel();
257
                    c.insets = new Insets(0, 4, 4, 0);
258
                    c.gridx = 2;
259
                    pnlDistance.add(lblUnitsX, c);
260
                    
261
                    c.insets = new Insets(4, 0, 0, 4);
262
                    c.gridy = row++;
263
            c.gridx = 0;
264
            JLabel labelY = new JLabel("y");
265
                    pnlDistance.add(labelY, c);
266
            c.insets = defaultInsets;
267
                    c.gridx = 1;
268
                    pnlDistance.add(getTxtIntervalY(), c);
269
                    lblUnitsY = new JLabel();
270
                    c.gridx = 2;
271
                    c.insets = new Insets(4, 4, 0, 0);
272
                    pnlDistance.add(lblUnitsY, c);
273
                    
274
            }
275
            return pnlDistance;
276
    }
277
    
278
    private ButtonGroup getBtnGrpInterval() {
279
            if (btGrpInterval==null) {
280
                    btGrpInterval = new ButtonGroup();
281
            }
282
            return btGrpInterval;
283
    }
284
    
285
    private NumberTextField getTfNumDivHoriz() {
286
            if (tfNumDivHoriz==null) {
287
                    tfNumDivHoriz = new NumberTextField(3);
288
                    tfNumDivHoriz.addFocusListener(new FocusListener() {
289
                                public void focusLost(FocusEvent e) {
290
                                        if (getRbHorizDiv().isSelected()) {
291
                                                calculateDistance(1, tfNumDivHoriz.getIntValue());
292
                                        }
293
                                }
294
                                public void focusGained(FocusEvent e) {}
295
                        });
296
                    tfNumDivHoriz.setValue(5);
297
            }
298
            return tfNumDivHoriz;
299
    }
300
    protected void calculateDistance(int axis, int numDivisions) {
301
            if (fframeview!=null &&
302
                            fframeview.getMapContext().getViewPort().getAdjustedEnvelope()!=null) {
303
                    Envelope env = fframeview.getMapContext().getViewPort().getAdjustedEnvelope();
304
                    double interval = IntervalUtils.roundIntervalDivision(env.getLength(axis), numDivisions);
305
                    getTxtIntervalX().setText(String.valueOf(interval));
306
                    getTxtIntervalY().setText(String.valueOf(interval));
307
            }
308
    }
309
    
310
    private NumberTextField getTfNumDivVert() {
311
            if (tfNumDivVert==null) {
312
                    tfNumDivVert = new NumberTextField(3);
313
                    tfNumDivVert.addFocusListener(new FocusListener() {
314
                                public void focusLost(FocusEvent e) {
315
                                        if (getRbVertDiv().isSelected()) {
316
                                                calculateDistance(0, tfNumDivVert.getIntValue());
317
                                        }
318
                                }
319
                                public void focusGained(FocusEvent e) {}
320
                        });
321
                    tfNumDivVert.setValue(5);
322
            }
323
            return tfNumDivVert;
324
    }
325

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

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

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

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

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

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

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

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

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

    
442
    /**
443
     * This method initializes jPanel10
444
     * 
445
     * @return javax.swing.JPanel
446
     */
447
    private JPanel getPnlLabelGroup() {
448
        if (pnlLabelGroup == null) {
449
            pnlLabelGroup = new JPanel(new GridBagLayout());
450
            pnlLabelGroup.setBorder(BorderFactory.createTitledBorder(
451
                            Messages.getText("Label")));
452
            
453
            GridBagConstraints c = new GridBagConstraints();
454
            int row = 0;
455
            
456
            c.insets = defaultInsets;
457
            c.gridx = 0;
458
            c.gridy = row++;
459
            c.gridwidth = 1;
460
            c.anchor = GridBagConstraints.LINE_START;
461
            pnlLabelGroup.add(new JLabel(Messages.getText("Number_format")), c);
462
            c.gridx = 1;
463
            pnlLabelGroup.add(getBtnNumberFormat(), c);
464
            
465
            c.gridx = 0;
466
            c.gridy = row++;
467
            c.gridwidth = 1;
468
            pnlLabelGroup.add(new JLabel(Messages.getText("Horizontal_label_rotation")), c);
469
            c.gridx = 1;
470
            pnlLabelGroup.add(getNfRotationHoriz(), c);
471
            
472
            c.gridy = row++;
473
            c.gridx = 0;
474
            pnlLabelGroup.add(new JLabel(Messages.getText("Vertical_label_rotation")), c);
475
            c.gridx = 1;
476
            pnlLabelGroup.add(getNfRotationVert(), c);
477
            
478
            c.gridy = row++;
479
            c.gridx = 0;
480
            c.fill = GridBagConstraints.NONE;
481
            pnlLabelGroup.add(new JLabel(Messages.getText("Anchor")), c);
482
            c.gridx = 1;
483
            c.fill = GridBagConstraints.HORIZONTAL;
484
            pnlLabelGroup.add(getCbLblAnchor(), c);
485
            
486
            c.gridx = 0;
487
            c.gridy = row++;
488
            c.gridwidth = 2;
489
            pnlLabelGroup.add(getPnlFont(), c);
490
        }
491
        return pnlLabelGroup;
492
    }
493
    
494
    private SimpleComboBox getCbLblAnchor() {
495
            if (cbLblAnchor==null) {
496
                cbLblAnchor = new SimpleComboBox();
497
                cbLblAnchor.addItem(Messages.getText("Corner"), RotatedTextUtils.ANCHOR_CORNER);
498
                cbLblAnchor.addItem(Messages.getText("Center"), RotatedTextUtils.ANCHOR_CENTER);
499
                cbLblAnchor.setSelectedCode(fframegrid.getLabelAnchor());
500
            }
501
            return cbLblAnchor;
502
    }
503
    
504
    private JButton getBtnNumberFormat() {
505
            if (btnNumberFormat==null) {
506
                    btnNumberFormat = new JButton(Messages.getText("Format"));
507
                    format = fframegrid.getLabelFormat();
508
                    btnNumberFormat.addActionListener(new java.awt.event.ActionListener() {
509
                public void actionPerformed(java.awt.event.ActionEvent e) {
510
                        openDecimalFormatDialog();
511
                }
512
                    });
513
            }
514
            return btnNumberFormat;
515
    }
516
    
517
    protected void openDecimalFormatDialog() {
518
            final DecimalFormatDialog dialog = new DecimalFormatDialog(null, null);
519
            dialog.addOkButtonActionListener(new ActionListener() {
520
                        public void actionPerformed(ActionEvent e) {
521
                                applyDecimalFormatSettings(dialog.getPanel());
522
                        }
523
                    
524
            });
525
            dialog.getPanel().setFormat(fframegrid.getLabelFormat());
526
            PluginServices.getMDIManager().addWindow(dialog);
527
    }
528
    
529
    protected void applyDecimalFormatSettings(DecimalFormatPanel p) {
530
            format = p.getFormat();
531
    }
532
    
533
    private JNumberSpinner getNfRotationHoriz() {
534
            if (nfRotationHoriz==null) {
535
                    nfRotationHoriz = new JNumberSpinner(0, 3, 0, 360, 1);
536
                    nfRotationHoriz.setInteger((int)fframegrid.getHorizLabelRotation());
537
            }
538
            return nfRotationHoriz;
539
    }
540
    
541
    private JNumberSpinner getNfRotationVert() {
542
            if (nfRotationVert==null) {
543
                    nfRotationVert = new JNumberSpinner(0, 3, 0, 360, 1);
544
                    nfRotationVert.setInteger((int)fframegrid.getVertLabelRotation());
545
            }
546
            return nfRotationVert;
547
    }
548

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

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

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

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

    
613
    public IFFrame getFFrame() {
614
        return newFFrameGrid;
615
    }
616

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

    
622
                public void actionPerformed(java.awt.event.ActionEvent e) {
623
                    try {
624
                        newFFrameGrid = (FFrameGrid) fframegrid.clone();
625
                        newFFrameGrid.setFFrameDependence(fframeview);
626
                        
627
                        newFFrameGrid
628
                        .setIntervalX(Double.parseDouble(getTxtIntervalX()
629
                            .getText().toString()));
630
                        newFFrameGrid
631
                        .setIntervalY(Double.parseDouble(getTxtIntervalY()
632
                            .getText().toString()));
633

    
634
                        if (getRbLines().isSelected()) {
635
                            if (symbol != null)
636
                                newFFrameGrid.setSymbolLine(symbol);
637
                        } else {
638
                            if (symbol != null)
639
                                newFFrameGrid.setSymbolPoint(symbol);
640
                        }
641

    
642
                        newFFrameGrid.setTextColor(getColorChooserPanel()
643
                            .getColor());
644
                        newFFrameGrid.setSizeFont(m_font.getSize());
645
                        newFFrameGrid.setIsLine(getRbLines().isSelected());
646
                        newFFrameGrid.setFont(m_font);
647
                        newFFrameGrid.setRotation(fframeview.getRotation());
648
                        newFFrameGrid.setHorizLabelRotation(getNfRotationHoriz().getInteger());
649
                        newFFrameGrid.setVertLabelRotation(getNfRotationVert().getInteger());
650
                        newFFrameGrid.setLabelAnchor(getCbLblAnchor().getSelectedCode());
651
                        newFFrameGrid.setLabelFormat(format);
652
                        if (getRbDistance().isSelected()) {
653
                                newFFrameGrid.setUseNumDivisions(FFrameGrid.FIXED_DISTANCE_MODE); 
654
                        }
655
                        else if (getRbHorizDiv().isSelected()) {
656
                                newFFrameGrid.setUseNumDivisions(FFrameGrid.NUM_DIVISIONS_HORIZ_MODE);
657
                        }
658
                        else if (getRbVertDiv().isSelected()) {
659
                                newFFrameGrid.setUseNumDivisions(FFrameGrid.NUM_DIVISIONS_VERT_MODE);
660
                        }
661
                    } catch (CloneNotSupportedException e1) {
662
                        LOG.error("It is not possible clonate the object", e);
663
                    }
664
                    PluginServices.getMDIManager().closeWindow(
665
                        FFrameGridDialog.this);
666
                    notifyDialogClosed();
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 setFFrameView(FFrameView fview) {
701
        fframeview = fview;
702
        //Set the label
703
        if (fframeview.getMapContext() != null){
704
            lblUnitsX.setText(Messages.getText(MapContext.getDistanceNames()[
705
                   fframeview.getMapContext().getViewPort().getMapUnits()]));
706
            lblUnitsY.setText(Messages.getText(MapContext.getDistanceNames()[
707
                   fframeview.getMapContext().getViewPort().getMapUnits()]));
708
        }
709
    }
710

    
711
    public Object getWindowProfile() {
712
        return WindowInfo.DIALOG_PROFILE;
713
    }
714

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

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