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

History | View | Annotate | Download (25.1 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.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 = 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
            pnlMain.add(getPnlLabelGroup(), c);
151

    
152
        }
153
        return pnlMain;
154
    }
155

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

    
170
    /**
171
     * This method initializes jPanel6
172
     * 
173
     * @return javax.swing.JPanel
174
     */
175
    private JPanel getPnlIntervalGroup() {
176
        if (pnlIntervalGroup == null) {
177
            pnlIntervalGroup = new JPanel(new GridBagLayout());
178
            pnlIntervalGroup.setBorder(BorderFactory.createTitledBorder(Messages.getText( "Interval")));
179
            GridBagConstraints c = new GridBagConstraints();
180
            
181
            c.anchor = GridBagConstraints.FIRST_LINE_START;
182
            c.gridx = 0;
183
            c.insets = defaultInsets;
184
            int row = 0;
185
            c.gridy = row++;
186
            c.gridwidth = 2;
187
            pnlIntervalGroup.add(getRbDistance(), c); 
188
            c.gridx = 0;
189
            c.gridwidth = 2;
190
            c.gridy = row++;
191
            c.insets = new Insets(defaultInsets.top, 25, defaultInsets.bottom, defaultInsets.right);
192
            pnlIntervalGroup.add(getPnlDistance(), c);
193
            
194
            c.gridx = 0;
195
            c.gridy = row++;
196
            c.insets = defaultInsets;
197
            c.gridwidth = 1;
198
            pnlIntervalGroup.add(getRbHorizDiv(), c);
199
            c.gridx = 1;
200
            pnlIntervalGroup.add(getTfNumDivHoriz(), c);
201
            
202
            c.gridy = row++;
203
            c.gridx = 0;
204
            pnlIntervalGroup.add(getRbVertDiv(), c);
205
            c.gridx = 1;
206
            pnlIntervalGroup.add(getTfNumDivVert(), c);
207
            
208
            getRbDistance().setSelected(true);
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
                    rbDistance.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
                    rbDistance.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(5);
296
            }
297
            return tfNumDivHoriz;
298
    }
299
    protected void calculateDistance(int axis, int numDivisions) {
300
            if (fframeview!=null &&
301
                            fframeview.getMapContext().getViewPort().getAdjustedEnvelope()!=null) {
302
                    Envelope env = fframeview.getMapContext().getViewPort().getAdjustedEnvelope();
303
                    double interval = IntervalUtils.roundIntervalDivision(env.getLength(axis), numDivisions);
304
                    getTxtIntervalX().setText(String.valueOf(interval));
305
                    getTxtIntervalY().setText(String.valueOf(interval));
306
            }
307
    }
308
    
309
    private NumberTextField getTfNumDivVert() {
310
            if (tfNumDivVert==null) {
311
                    tfNumDivVert = new NumberTextField(3);
312
                    tfNumDivVert.addFocusListener(new FocusListener() {
313
                                public void focusLost(FocusEvent e) {
314
                                        if (getRbVertDiv().isSelected()) {
315
                                                calculateDistance(0, tfNumDivVert.getIntValue());
316
                                        }
317
                                }
318
                                public void focusGained(FocusEvent e) {}
319
                        });
320
                    tfNumDivVert.setValue(5);
321
            }
322
            return tfNumDivVert;
323
    }
324

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

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

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

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

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

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

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

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

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

    
441
    /**
442
     * This method initializes jPanel10
443
     * 
444
     * @return javax.swing.JPanel
445
     */
446
    private JPanel getPnlLabelGroup() {
447
        if (pnlLabelGroup == null) {
448
            pnlLabelGroup = new JPanel(new GridBagLayout());
449
            pnlLabelGroup.setBorder(BorderFactory.createTitledBorder(
450
                            Messages.getText("Label")));
451
            
452
            GridBagConstraints c = new GridBagConstraints();
453
            int row = 0;
454
            
455
            c.insets = defaultInsets;
456
            c.gridx = 0;
457
            c.gridy = row++;
458
            c.gridwidth = 1;
459
            c.anchor = GridBagConstraints.LINE_START;
460
            pnlLabelGroup.add(new JLabel(Messages.getText("Number_format")), c);
461
            c.gridx = 1;
462
            pnlLabelGroup.add(getBtnNumberFormat(), c);
463
            
464
            c.gridx = 0;
465
            c.gridy = row++;
466
            c.gridwidth = 1;
467
            pnlLabelGroup.add(new JLabel(Messages.getText("Horizontal_label_rotation")), c);
468
            c.gridx = 1;
469
            pnlLabelGroup.add(getNfRotationHoriz(), c);
470
            
471
            c.gridy = row++;
472
            c.gridx = 0;
473
            pnlLabelGroup.add(new JLabel(Messages.getText("Vertical_label_rotation")), c);
474
            c.gridx = 1;
475
            pnlLabelGroup.add(getNfRotationVert(), c);
476
            
477
            c.gridx = 0;
478
            c.gridy = row++;
479
            c.gridwidth = 2;
480
            pnlLabelGroup.add(getPnlFont(), c);
481
        }
482
        return pnlLabelGroup;
483
    }
484
    
485
    private JButton getBtnNumberFormat() {
486
            if (btnNumberFormat==null) {
487
                    btnNumberFormat = new JButton(Messages.getText("Format"));
488
                    btnNumberFormat.addActionListener(new java.awt.event.ActionListener() {
489
                public void actionPerformed(java.awt.event.ActionEvent e) {
490
                        openDecimalFormatDialog();
491
                }
492
                    });
493
            }
494
            return btnNumberFormat;
495
    }
496
    
497
    protected void openDecimalFormatDialog() {
498
            final DecimalFormatDialog dialog = new DecimalFormatDialog(null, null);
499
            dialog.addOkButtonActionListener(new ActionListener() {
500
                        public void actionPerformed(ActionEvent e) {
501
                                applyDecimalFormatSettings(dialog.getPanel());
502
                        }
503
                    
504
            });
505
            dialog.getPanel().setFormat(fframegrid.getLabelFormat());
506
            PluginServices.getMDIManager().addWindow(dialog);
507
    }
508
    
509
    protected void applyDecimalFormatSettings(DecimalFormatPanel p) {
510
            format = p.getFormat();
511
    }
512
    
513
    private JIncrementalNumberField getNfRotationHoriz() {
514
            if (nfRotationHoriz==null) {
515
                        Cleaner cleaner = ValidatingTextField.NUMBER_CLEANER;
516
                        Validator validator = ValidatingTextField.INTEGER_VALIDATOR;
517
                    nfRotationHoriz = new JIncrementalNumberField("rotationH", 3, validator, cleaner, 0.0d, 360.0d, 1.0);
518
                    nfRotationHoriz.setInteger((int)fframegrid.getHorizLabelRotation());
519
            }
520
            return nfRotationHoriz;
521
    }
522
    
523
    private JIncrementalNumberField getNfRotationVert() {
524
            if (nfRotationVert==null) {
525
                        Cleaner cleaner = ValidatingTextField.NUMBER_CLEANER;
526
                        Validator validator = ValidatingTextField.INTEGER_VALIDATOR;
527
                    nfRotationVert  = new JIncrementalNumberField("rotationV", 3, validator, cleaner, 0.0d, 360.0d, 1.0);
528
                    nfRotationVert.setInteger((int)fframegrid.getVertLabelRotation());
529
            }
530
            return nfRotationVert;
531
    }
532

    
533
    /**
534
     * This method initializes jPanel11
535
     * 
536
     * @return javax.swing.JPanel
537
     */
538
    private JPanel getPnlFont() {
539
        if (pnlFont == null) {
540
            pnlFont = new JPanel(new GridBagLayout());
541
            GridBagConstraints c = new GridBagConstraints();
542
            c.anchor = GridBagConstraints.FIRST_LINE_START;
543
            c.insets = new Insets(0, 0, 0, 4);
544
            c.gridy = 0;
545
            c.gridx = 0;
546
            pnlFont.add(new JLabel(Messages.getText("Font_type")), c);
547
            c.gridx = 1;
548
            c.insets = new Insets(0, 4, 0, 4);
549
            pnlFont.add(getJButton(), c);
550
            c.gridx = 2;
551
            c.insets = new Insets(0, 4, 0, 0);
552
            pnlFont.add(getColorChooserPanel(), c);
553
        }
554
        return pnlFont;
555
    }
556

    
557
    /**
558
     * This method initializes jButton
559
     * 
560
     * @return javax.swing.JButton
561
     */
562
    private JButton getJButton() {
563
        if (jButton == null) {
564
            jButton = new JButton();
565
            jButton.setText(PluginServices.getText(this, "Font"));
566
            m_font = fframegrid.getFont();
567
            jButton.addActionListener(new java.awt.event.ActionListener() {
568

    
569
                public void actionPerformed(java.awt.event.ActionEvent e) {
570
                    Font font =
571
                        FontChooser.showDialog(PluginServices.getText(this,
572
                        "__seleccion_de_fuente"), m_font);
573
                    if (font != null)
574
                        m_font = font; // fchoser=new
575
                    // FontChooser();
576
                    // //$NON-NLS-1$
577
                }
578
            });
579
        }
580
        return jButton;
581
    }
582

    
583
    /**
584
     * This method initializes colorChooserPanel
585
     * 
586
     * @return com.iver.cit.gvsig.gui.panels.ColorChooserPanel
587
     */
588
    private ColorChooserPanel getColorChooserPanel() {
589
        if (colorChooserPanel == null) {
590
            colorChooserPanel = new ColorChooserPanel();
591
            colorChooserPanel.setAlpha(255);
592
            colorChooserPanel.setColor(fframegrid.getFontColor());
593
        }
594
        return colorChooserPanel;
595
    }
596

    
597
    public IFFrame getFFrame() {
598
        return newFFrameGrid;
599
    }
600

    
601
    private AcceptCancelPanel getAcceptCancelPanel() {
602
        if (accept == null) {
603
            ActionListener okAction, cancelAction;
604
            okAction = new java.awt.event.ActionListener() {
605

    
606
                public void actionPerformed(java.awt.event.ActionEvent e) {
607
                    try {
608
                        newFFrameGrid = (FFrameGrid) fframegrid.clone();
609
                        newFFrameGrid.setFFrameDependence(fframeview);
610
                        
611
                        newFFrameGrid
612
                        .setIntervalX(Double.parseDouble(getTxtIntervalX()
613
                            .getText().toString()));
614
                        newFFrameGrid
615
                        .setIntervalY(Double.parseDouble(getTxtIntervalY()
616
                            .getText().toString()));
617

    
618
                        if (getRbLines().isSelected()) {
619
                            if (symbol != null)
620
                                newFFrameGrid.setSymbolLine(symbol);
621
                        } else {
622
                            if (symbol != null)
623
                                newFFrameGrid.setSymbolPoint(symbol);
624
                        }
625

    
626
                        newFFrameGrid.setTextColor(getColorChooserPanel()
627
                            .getColor());
628
                        newFFrameGrid.setSizeFont(m_font.getSize());
629
                        newFFrameGrid.setIsLine(getRbLines().isSelected());
630
                        newFFrameGrid.setFont(m_font);
631
                        newFFrameGrid.setRotation(fframeview.getRotation());
632
                        newFFrameGrid.setHorizLabelRotation(getNfRotationHoriz().getInteger());
633
                        newFFrameGrid.setVertLabelRotation(getNfRotationVert().getInteger());
634
                        newFFrameGrid.setLabelFormat(format);
635
                        if (getRbDistance().isSelected()) {
636
                                newFFrameGrid.setUseNumDivisions(FFrameGrid.FIXED_DISTANCE_MODE); 
637
                        }
638
                        else if (getRbHorizDiv().isSelected()) {
639
                                newFFrameGrid.setUseNumDivisions(FFrameGrid.NUM_DIVISIONS_HORIZ_MODE);
640
                        }
641
                        else if (getRbVertDiv().isSelected()) {
642
                                newFFrameGrid.setUseNumDivisions(FFrameGrid.NUM_DIVISIONS_VERT_MODE);
643
                        }
644
                    } catch (CloneNotSupportedException e1) {
645
                        LOG.error("It is not possible clonate the object", e);
646
                    }
647
                    PluginServices.getMDIManager().closeWindow(
648
                        FFrameGridDialog.this);
649
                    notifyDialogClosed();
650
                }
651
            };
652
            cancelAction = new java.awt.event.ActionListener() {
653

    
654
                public void actionPerformed(java.awt.event.ActionEvent e) {
655
                    newFFrameGrid = null;
656
                    PluginServices.getMDIManager().closeWindow(
657
                        FFrameGridDialog.this);
658
                    notifyDialogClosed();
659
                }
660
            };
661
            accept = new AcceptCancelPanel(okAction, cancelAction);
662
            accept.setEnabled(true);
663
            accept.setVisible(true);
664
        }
665
        return accept;
666
    }
667

    
668
    public WindowInfo getWindowInfo() {
669
        WindowInfo m_viewinfo =
670
            new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
671
        m_viewinfo.setTitle(PluginServices.getText(this, "Grid_settings"));
672
        m_viewinfo.setWidth(480);
673
        m_viewinfo.setHeight(400);
674

    
675
        return m_viewinfo;
676
    }
677

    
678
    public boolean getIsAcepted() {
679
        // TODO Auto-generated method stub
680
        return false;
681
    }
682

    
683
    public void setFFrameView(FFrameView fview) {
684
        fframeview = fview;
685
        //Set the label
686
        if (fframeview.getMapContext() != null){
687
            lblUnitsX.setText(Messages.getText(MapContext.getDistanceNames()[
688
                   fframeview.getMapContext().getViewPort().getMapUnits()]));
689
            lblUnitsY.setText(Messages.getText(MapContext.getDistanceNames()[
690
                   fframeview.getMapContext().getViewPort().getMapUnits()]));
691
        }
692
    }
693

    
694
    public Object getWindowProfile() {
695
        return WindowInfo.DIALOG_PROFILE;
696
    }
697

    
698
        public void setRectangle(Rectangle2D r) {
699
                // nothing to do as this fframe takes the size from the associated fframeview
700
        }
701

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