~ubuntu-branches/debian/squeeze/latexdraw/squeeze

« back to all changes in this revision

Viewing changes to latexDraw/ui/dialog/ParametersAxeFrame.java

  • Committer: Bazaar Package Importer
  • Author(s): Stuart Prescott
  • Date: 2009-05-03 23:49:35 UTC
  • Revision ID: james.westby@ubuntu.com-20090503234935-cls7n48x018g0vk2
Tags: upstream-2.0.2+1
ImportĀ upstreamĀ versionĀ 2.0.2+1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package latexDraw.ui.dialog;
 
2
 
 
3
import java.awt.*;
 
4
import java.awt.event.ActionEvent;
 
5
 
 
6
import javax.swing.*;
 
7
import javax.swing.border.CompoundBorder;
 
8
import javax.swing.border.EmptyBorder;
 
9
import javax.swing.border.TitledBorder;
 
10
import javax.swing.event.ChangeEvent;
 
11
 
 
12
import latexDraw.figures.Axe;
 
13
import latexDraw.figures.Figure;
 
14
import latexDraw.figures.GridShape;
 
15
import latexDraw.lang.LaTeXDrawLang;
 
16
import latexDraw.psTricks.PSTricksConstants;
 
17
import latexDraw.ui.DrawPanel;
 
18
 
 
19
 
 
20
/** 
 
21
 * This class defines the frame allowing to modify axes.<br>
 
22
 *<br>
 
23
 * This file is part of LaTeXDraw.<br>
 
24
 * Copyright (c) 2005-2008 Arnaud BLOUIN<br>
 
25
 *<br>
 
26
 *  LaTeXDraw is free software; you can redistribute it and/or modify
 
27
 *  it under the terms of the GNU General Public License as published by
 
28
 *  the Free Software Foundation; either version 2 of the License, or
 
29
 *  any later version.<br>
 
30
 *<br>
 
31
 *  LaTeXDraw is distributed without any warranty; without even the 
 
32
 *  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 
33
 *  PURPOSE. See the GNU General Public License for more details.<br>
 
34
 *<br>
 
35
 * 08/17/06<br>
 
36
 * @author Arnaud BLOUIN<br>
 
37
 * @since 1.8<br>
 
38
 * @version 2.0.0<br>
 
39
 */
 
40
public class ParametersAxeFrame extends AbstractGridShapeFrame
 
41
{
 
42
        private static final long serialVersionUID = 1L;
 
43
 
 
44
        protected JCheckBox drawXLabel;
 
45
        
 
46
        protected JCheckBox drawYLabel;
 
47
 
 
48
        protected JCheckBox drawXTicks;
 
49
        
 
50
        protected JCheckBox drawYTicks;
 
51
        
 
52
        protected JCheckBox defineLabelDistCB;
 
53
        
 
54
        protected JComboBox axeShapeChoice;
 
55
 
 
56
        protected JComboBox ticksShapeChoice;
 
57
        
 
58
        protected JSpinner ticksSizeField;
 
59
        
 
60
        protected JSpinner labelXDistField;
 
61
        
 
62
        protected JSpinner labelYDistField;
 
63
        
 
64
        /** Allows to change the increment of the X labels. */
 
65
        protected JSpinner labelXIncrement;
 
66
        
 
67
        /** Allows to change the increment of the Y labels. */
 
68
        protected JSpinner labelYIncrement;
 
69
        
 
70
        /** Allows to change the origin of the X labels. */
 
71
        protected JSpinner labelXOrigin;
 
72
        
 
73
        /** Allows to change the origin of the Y labels. */
 
74
        protected JSpinner labelYOrigin;
 
75
        
 
76
        protected JCheckBox showOriginCB;
 
77
        
 
78
        public static final String LABEL_DRAW_X_LABELS = "dispXLab";//$NON-NLS-1$
 
79
        
 
80
        public static final String LABEL_DEF_LABELS_DIST = "defDist";//$NON-NLS-1$
 
81
 
 
82
        public static final String LABEL_DRAW_Y_LABELS = "dispYLab";//$NON-NLS-1$
 
83
 
 
84
        public static final String LABEL_DRAW_X_TICKS = "dispXTicks";//$NON-NLS-1$
 
85
        
 
86
        public static final String LABEL_DRAW_Y_TICKS = "dispYTicks";//$NON-NLS-1$
 
87
        
 
88
        public static final String LABEL_Y_LABEL_DIST = "xLabSep";//$NON-NLS-1$
 
89
        
 
90
        public static final String LABEL_X_LABEL_DIST = "yLabSep";//$NON-NLS-1$
 
91
        
 
92
        public static final String LABEL_TICKS_SIZE_FIELD = "ticksSizeField";//$NON-NLS-1$
 
93
        
 
94
        public static final String LABEL_LABEL_X_INCR = "labXInc";//$NON-NLS-1$
 
95
 
 
96
        public static final String LABEL_LABEL_Y_INCR = "labYInc";//$NON-NLS-1$
 
97
 
 
98
        public static final String LABEL_LABEL_X_ORIG = "labXOrig";//$NON-NLS-1$
 
99
        
 
100
        public static final String LABEL_LABEL_Y_ORIG = "labYOrig";//$NON-NLS-1$
 
101
        
 
102
        public static final String LABEL_SHOW_ORIGIN = "showOrig";//$NON-NLS-1$
 
103
        
 
104
        
 
105
        
 
106
        
 
107
        public ParametersAxeFrame(Frame parent, DrawPanel d, boolean attachToMainFrame)
 
108
        {
 
109
                super(parent, d, attachToMainFrame);
 
110
 
 
111
                try
 
112
                {
 
113
                        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
 
114
                        JTabbedPane tabbedPane = new JTabbedPane();
 
115
                        JPanel pButton  = createButtonsPanel(this);
 
116
                        JPanel pGeneral = new JPanel();
 
117
                        JPanel pAxes    = new JPanel();
 
118
                JPanel pOther = new JPanel(new FlowLayout(FlowLayout.LEFT));
 
119
                pAxes.setLayout(new BoxLayout(pAxes, BoxLayout.Y_AXIS));
 
120
                JPanel positionP = createPositionPanel(false);
 
121
                
 
122
                        pGeneral.setLayout(new BoxLayout(pGeneral, BoxLayout.Y_AXIS));
 
123
                pGeneral.add(positionP);
 
124
                pGeneral.add(createBordersPanel(false));
 
125
                pGeneral.add(pOther);
 
126
 
 
127
                pOther.add(new JLabel(LaTeXDrawLang.getString1_8("ParametersAxeFrame.0"))); //$NON-NLS-1$
 
128
                
 
129
                axeShapeChoice = Axe.createAxeStyleChoice();
 
130
                axeShapeChoice.addActionListener(this);
 
131
                pOther.add(axeShapeChoice);
 
132
                
 
133
                showOriginCB = new JCheckBox(LaTeXDrawLang.getString1_8("ParametersAxeFrame.1"), true); //$NON-NLS-1$
 
134
                showOriginCB.setActionCommand(LABEL_SHOW_ORIGIN);
 
135
                showOriginCB.setName(LABEL_SHOW_ORIGIN);
 
136
                showOriginCB.addActionListener(this);
 
137
                pOther.add(showOriginCB);
 
138
                
 
139
                String axesS = LaTeXDrawLang.getString1_8("ParametersAxeFrame.2"); //$NON-NLS-1$
 
140
                pOther.setBorder(new CompoundBorder(new TitledBorder(null, axesS,
 
141
                                          TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
 
142
                
 
143
                pAxes.add(createLabelsPanel());
 
144
                pAxes.add(createTicksPanel());
 
145
                
 
146
                tabbedPane.addTab(TITLE_TABBED_PANE_GENERAL, pGeneral);
 
147
                tabbedPane.addTab(axesS, pAxes);
 
148
                tabbedPane.addTab(NAME_TABBEDPANE_ARROW, createArrowPanel(true, false));
 
149
                BoxLayout bl = new BoxLayout(getContentPane(), BoxLayout.Y_AXIS);
 
150
                getContentPane().setLayout(bl);
 
151
                getContentPane().add(glimpsePanelZoom);
 
152
                getContentPane().add(tabbedPane);
 
153
                        getContentPane().add(pButton);
 
154
                        pack();
 
155
                        setLocation(dim.width/2-getWidth()/2, dim.height/2-getHeight()/2);
 
156
                        setVisible(false);
 
157
 
 
158
                }catch(Exception e)
 
159
                {
 
160
                        e.printStackTrace(); 
 
161
                        ExceptionFrameDialog.showExceptionDialog(e);
 
162
                }
 
163
        }
 
164
 
 
165
        
 
166
        
 
167
        
 
168
        protected JPanel createLabelsPanel()
 
169
        {
 
170
                JPanel pLabels = new JPanel(new GridBagLayout());
 
171
                GridBagConstraints constraint = new GridBagConstraints();
 
172
                
 
173
        constraint.gridx = 0;
 
174
        constraint.gridy = 0;
 
175
        constraint.gridwidth = 1;
 
176
        constraint.gridheight = 1;
 
177
        constraint.weightx = 0.1;
 
178
        constraint.weighty = 0.1;
 
179
        constraint.fill = GridBagConstraints.NONE;
 
180
        constraint.anchor = GridBagConstraints.WEST;
 
181
        
 
182
        drawXLabel = new JCheckBox(LaTeXDrawLang.getString1_8("ParametersAxeFrame.3"), true); //$NON-NLS-1$
 
183
        drawXLabel.setActionCommand(LABEL_DRAW_X_LABELS);
 
184
        drawXLabel.setName(LABEL_DRAW_X_LABELS);
 
185
        drawXLabel.addActionListener(this);
 
186
        constraint.gridx=0;
 
187
        pLabels.add(drawXLabel, constraint);
 
188
 
 
189
        drawYLabel = new JCheckBox(LaTeXDrawLang.getString1_8("ParametersAxeFrame.4"), true); //$NON-NLS-1$
 
190
        drawYLabel.setActionCommand(LABEL_DRAW_Y_LABELS);
 
191
        drawYLabel.setName(LABEL_DRAW_Y_LABELS);
 
192
        drawYLabel.addActionListener(this);
 
193
        constraint.gridx+=2;
 
194
        pLabels.add(drawYLabel, constraint);
 
195
        
 
196
        constraint.gridx = 0;   constraint.gridy++;
 
197
        constraint.gridwidth=2;
 
198
        invertXLabelsCB = new JCheckBox(LABEL_ISXLABEL);
 
199
        invertXLabelsCB.setText(LABEL_ISXLABEL);
 
200
        invertXLabelsCB.setSelected(GridShape.DEFAULT_ISYLABELWEST);
 
201
        invertXLabelsCB.setActionCommand(LABEL_ISXLABEL);
 
202
        invertXLabelsCB.addActionListener(this);
 
203
        pLabels.add(invertXLabelsCB, constraint);
 
204
        
 
205
        constraint.gridx+=2;
 
206
        invertYLabelsCB = new JCheckBox(LABEL_ISYLABEL);
 
207
        invertYLabelsCB.setText(LABEL_ISYLABEL);
 
208
        invertYLabelsCB.setSelected(GridShape.DEFAULT_ISXLABELSOUTH);
 
209
        invertYLabelsCB.addActionListener(this);
 
210
        invertYLabelsCB.setActionCommand(LABEL_ISYLABEL);
 
211
        pLabels.add(invertYLabelsCB, constraint);
 
212
        
 
213
        constraint.gridx=0;
 
214
        constraint.gridy++;
 
215
        defineLabelDistCB = new JCheckBox(LABEL_DEF_LABELS_DIST);
 
216
        defineLabelDistCB.setText(LaTeXDrawLang.getString1_8("ParametersAxeFrame.5")); //$NON-NLS-1$
 
217
        defineLabelDistCB.setSelected(false);
 
218
        defineLabelDistCB.addActionListener(this);
 
219
        defineLabelDistCB.setActionCommand(LABEL_DEF_LABELS_DIST);
 
220
        pLabels.add(defineLabelDistCB, constraint);
 
221
 
 
222
        constraint.gridwidth=1;
 
223
        constraint.gridx=0;
 
224
        constraint.gridy++;
 
225
        pLabels.add(new JLabel(LaTeXDrawLang.getString1_8("ParametersAxeFrame.6")), constraint); //$NON-NLS-1$
 
226
        
 
227
        SpinnerModel model = new SpinnerNumberModel(0.01,0.01,1000,0.05);
 
228
        labelXDistField = new JSpinner(model);
 
229
        labelXDistField.setEditor(new JSpinner.NumberEditor(labelXDistField, "0.00"));//$NON-NLS-1$
 
230
        labelXDistField.addChangeListener(this);
 
231
        labelXDistField.setName(LABEL_X_LABEL_DIST);
 
232
        labelXDistField.setEnabled(false);
 
233
        constraint.gridx++;
 
234
        pLabels.add(labelXDistField, constraint);
 
235
 
 
236
        constraint.gridx++;
 
237
        pLabels.add(new JLabel(LaTeXDrawLang.getString1_8("ParametersAxeFrame.7")), constraint); //$NON-NLS-1$
 
238
        
 
239
        model = new SpinnerNumberModel(0.01,0.01,1000,0.05);
 
240
        labelYDistField = new JSpinner(model);
 
241
        labelYDistField.setEditor(new JSpinner.NumberEditor(labelYDistField, "0.00"));//$NON-NLS-1$
 
242
        labelYDistField.addChangeListener(this);
 
243
        labelYDistField.setEnabled(false);
 
244
        labelYDistField.setName(LABEL_Y_LABEL_DIST);
 
245
        constraint.gridx++;
 
246
        pLabels.add(labelYDistField, constraint);
 
247
        
 
248
        constraint.gridx=0;
 
249
        constraint.gridy++;
 
250
        pLabels.add(new JLabel(LaTeXDrawLang.getString1_8("ParametersAxeFrame.8")), constraint); //$NON-NLS-1$
 
251
        
 
252
        model = new SpinnerNumberModel(0.0001,0.0001,1000,1);
 
253
        labelXIncrement = new JSpinner(model);
 
254
        labelXIncrement.setEditor(new JSpinner.NumberEditor(labelXIncrement, "0.000"));//$NON-NLS-1$
 
255
        labelXIncrement.addChangeListener(this);
 
256
        labelXIncrement.setName(LABEL_LABEL_X_INCR);
 
257
        constraint.gridx++;
 
258
        pLabels.add(labelXIncrement, constraint);
 
259
        
 
260
        constraint.gridx++;
 
261
        pLabels.add(new JLabel(LaTeXDrawLang.getString1_8("ParametersAxeFrame.9")), constraint); //$NON-NLS-1$
 
262
        
 
263
        model = new SpinnerNumberModel(0.0001,0.0001,1000,1);
 
264
        labelYIncrement = new JSpinner(model);
 
265
        labelYIncrement.setEditor(new JSpinner.NumberEditor(labelYIncrement, "0.000"));//$NON-NLS-1$
 
266
        labelYIncrement.addChangeListener(this);
 
267
        labelYIncrement.setName(LABEL_LABEL_Y_INCR);
 
268
        constraint.gridx++;
 
269
        pLabels.add(labelYIncrement, constraint);
 
270
        
 
271
        constraint.gridx=0;
 
272
        constraint.gridy++;
 
273
        pLabels.add(new JLabel(LaTeXDrawLang.getString1_8("ParametersAxeFrame.10")), constraint); //$NON-NLS-1$
 
274
        
 
275
        model = new SpinnerNumberModel(1,-1000,1000,1);
 
276
        labelXOrigin = new JSpinner(model);
 
277
        labelXOrigin.setEditor(new JSpinner.NumberEditor(labelXOrigin, "0"));//$NON-NLS-1$
 
278
        labelXOrigin.addChangeListener(this);
 
279
        labelXOrigin.setName(LABEL_LABEL_X_ORIG);
 
280
        constraint.gridx++;
 
281
        pLabels.add(labelXOrigin, constraint);
 
282
        
 
283
        constraint.gridx++;
 
284
        pLabels.add(new JLabel(LaTeXDrawLang.getString1_8("ParametersAxeFrame.11")), constraint); //$NON-NLS-1$
 
285
        
 
286
        model = new SpinnerNumberModel(1,-1000,1000,1);
 
287
        labelYOrigin = new JSpinner(model);
 
288
        labelYOrigin.setEditor(new JSpinner.NumberEditor(labelYOrigin, "0"));//$NON-NLS-1$
 
289
        labelYOrigin.addChangeListener(this);
 
290
        labelYOrigin.setName(LABEL_LABEL_Y_ORIG);
 
291
        constraint.gridx++;
 
292
        pLabels.add(labelYOrigin, constraint);
 
293
        
 
294
        pLabels.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getString1_8("ParametersAxeFrame.12"), //$NON-NLS-1$
 
295
                                  TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
 
296
        
 
297
        return pLabels;
 
298
        }
 
299
        
 
300
        
 
301
        
 
302
        protected JPanel createTicksPanel()
 
303
        {
 
304
                JPanel pTicks = new JPanel(new GridBagLayout());
 
305
                GridBagConstraints constraint = new GridBagConstraints();
 
306
                
 
307
        constraint.gridx = 0;
 
308
        constraint.gridy = 0;
 
309
        constraint.gridwidth = 1;
 
310
        constraint.gridheight = 1;
 
311
        constraint.weightx = 0.1;
 
312
        constraint.weighty = 0.1;
 
313
        constraint.fill = GridBagConstraints.NONE;
 
314
        constraint.anchor = GridBagConstraints.WEST;
 
315
 
 
316
        pTicks.add(new JLabel(LaTeXDrawLang.getString1_8("ParametersAxeFrame.13")), constraint); //$NON-NLS-1$
 
317
        
 
318
        SpinnerModel model = new SpinnerNumberModel(1,1,1000,0.5);
 
319
        ticksSizeField = new JSpinner(model);
 
320
        ticksSizeField.setEditor(new JSpinner.NumberEditor(ticksSizeField, "0.00"));//$NON-NLS-1$
 
321
        ticksSizeField.addChangeListener(this);
 
322
        ticksSizeField.setName(LABEL_TICKS_SIZE_FIELD);
 
323
        constraint.gridx++;
 
324
        pTicks.add(ticksSizeField, constraint);
 
325
        
 
326
        constraint.gridx++;
 
327
        pTicks.add(new JLabel(LaTeXDrawLang.getString1_8("ParametersAxeFrame.14")), constraint); //$NON-NLS-1$
 
328
        
 
329
        ticksShapeChoice = Axe.createTicksStyleChoice();
 
330
        ticksShapeChoice.addActionListener(this);
 
331
        constraint.gridx++;
 
332
        pTicks.add(ticksShapeChoice, constraint);
 
333
        
 
334
        drawXTicks = new JCheckBox(LaTeXDrawLang.getString1_8("ParametersAxeFrame.15"), true); //$NON-NLS-1$
 
335
        drawXTicks.setActionCommand(LABEL_DRAW_X_TICKS);
 
336
        drawXTicks.setName(LABEL_DRAW_X_TICKS);
 
337
        drawXTicks.addActionListener(this);
 
338
        constraint.gridx=0;     constraint.gridy++;
 
339
        pTicks.add(drawXTicks, constraint);
 
340
 
 
341
        drawYTicks = new JCheckBox(LaTeXDrawLang.getString1_8("ParametersAxeFrame.16"), true); //$NON-NLS-1$
 
342
        drawYTicks.setActionCommand(LABEL_DRAW_Y_TICKS);
 
343
        drawYTicks.setName(LABEL_DRAW_Y_TICKS);
 
344
        drawYTicks.addActionListener(this);
 
345
        constraint.gridx+=1;
 
346
        pTicks.add(drawYTicks, constraint);
 
347
 
 
348
                
 
349
                pTicks.setBorder(new CompoundBorder(new TitledBorder(null, LaTeXDrawLang.getString1_8("ParametersAxeFrame.17"), //$NON-NLS-1$
 
350
                                  TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(0,0,0,0)));
 
351
                
 
352
                return pTicks;
 
353
        }
 
354
        
 
355
        
 
356
        
 
357
        @Override
 
358
        public void setVisible(boolean visible, Figure selected, boolean deleteOnCancel, boolean isFramedBox) 
 
359
        {
 
360
                try
 
361
                {
 
362
                        if(!(selected instanceof Axe))
 
363
                                throw new ClassCastException();
 
364
 
 
365
                        super.setVisible(visible, selected, deleteOnCancel, isFramedBox);
 
366
                }
 
367
                catch(Exception ex)
 
368
                {
 
369
                        ex.printStackTrace(); 
 
370
                        ExceptionFrameDialog.showExceptionDialog(ex);
 
371
                }       
 
372
        }
 
373
 
 
374
        
 
375
 
 
376
        
 
377
        @Override
 
378
        public void setFigureFrameField()
 
379
        {
 
380
                super.setFigureFrameField();
 
381
                
 
382
                Axe a = (Axe)figure;
 
383
                int labelsDisplayed = a.getLabelsDisplayed();
 
384
                int ticksDisplayed      = a.getTicksDisplayed();
 
385
                
 
386
                if(labelsDisplayed==Axe.LABELS_DISPLAYED_ALL_VALUE || labelsDisplayed==Axe.LABELS_DISPLAYED_X_VALUE)
 
387
                        drawXLabel.setSelected(true);
 
388
                
 
389
                if(labelsDisplayed==Axe.LABELS_DISPLAYED_ALL_VALUE || labelsDisplayed==Axe.LABELS_DISPLAYED_Y_VALUE)
 
390
                        drawYLabel.setSelected(true);
 
391
 
 
392
                if(ticksDisplayed==Axe.LABELS_DISPLAYED_ALL_VALUE || ticksDisplayed==Axe.LABELS_DISPLAYED_X_VALUE)
 
393
                        drawXTicks.setSelected(true);
 
394
                
 
395
                if(ticksDisplayed==Axe.LABELS_DISPLAYED_ALL_VALUE || ticksDisplayed==Axe.LABELS_DISPLAYED_Y_VALUE)
 
396
                        drawYTicks.setSelected(true);
 
397
                
 
398
                String style = a.getAxesStyleToken();
 
399
                
 
400
                if(style.equals(PSTricksConstants.TOKEN_AXES_STYLE_AXES))
 
401
                        axeShapeChoice.setSelectedItem(Axe.LABEL_STYLE_AXE);
 
402
                else
 
403
                        if(style.equals(PSTricksConstants.TOKEN_AXES_STYLE_FRAME))
 
404
                                axeShapeChoice.setSelectedItem(Axe.LABEL_STYLE_FRAME);
 
405
                        else 
 
406
                                if(style.equals(PSTricksConstants.TOKEN_AXES_STYLE_NONE))
 
407
                                        axeShapeChoice.setSelectedItem(Axe.LABEL_STYLE_NONE);
 
408
        
 
409
                style = a.getTicksStyleToken();
 
410
                
 
411
                if(style.equals(PSTricksConstants.TOKEN_TICKS_STYLE_FULL))
 
412
                        ticksShapeChoice.setSelectedItem(Axe.LABEL_STYLE_TICKS_FULL);
 
413
                else
 
414
                        if(style.equals(PSTricksConstants.TOKEN_TICKS_STYLE_BOTTOM))
 
415
                                ticksShapeChoice.setSelectedItem(Axe.LABEL_STYLE_TICKS_BOTTOM);
 
416
                        else 
 
417
                                if(style.equals(PSTricksConstants.TOKEN_TICKS_STYLE_TOP))
 
418
                                        ticksShapeChoice.setSelectedItem(Axe.LABEL_STYLE_TICKS_TOP);
 
419
                
 
420
                ticksSizeField.setValue(a.getTicksSize());
 
421
                boolean ok = a.getDistLabelsX()!=0 || a.getDistLabelsY()!=0;
 
422
                
 
423
                defineLabelDistCB.setSelected(ok);
 
424
                labelXDistField.setEnabled(ok);
 
425
                labelYDistField.setEnabled(ok);
 
426
                labelXDistField.removeChangeListener(this);
 
427
                labelYDistField.removeChangeListener(this);
 
428
                labelXDistField.setValue(a.getDistLabelsX()==0 ? a.getIncrement().x : a.getDistLabelsX());
 
429
                labelYDistField.setValue(a.getDistLabelsY()==0 ? a.getIncrement().y : a.getDistLabelsY());
 
430
                labelXDistField.addChangeListener(this);
 
431
                labelYDistField.addChangeListener(this);
 
432
                labelXIncrement.setValue(a.getIncrement().x);
 
433
                labelYIncrement.setValue(a.getIncrement().y);
 
434
                labelXOrigin.setValue((int)a.getOrigin().x);
 
435
                labelYOrigin.setValue((int)a.getOrigin().y);
 
436
                showOriginCB.setSelected(a.isShowOrigin());
 
437
                
 
438
                glimpsePanel.repaint();
 
439
        }
 
440
        
 
441
 
 
442
        
 
443
        
 
444
        @Override
 
445
        public void setDefaultsValues()
 
446
        {
 
447
                super.setDefaultsValues();
 
448
                
 
449
                drawXLabel.setSelected(true);
 
450
                drawYLabel.setSelected(true);
 
451
                drawXTicks.setSelected(true);
 
452
                drawYTicks.setSelected(true);
 
453
                Axe axe = (Axe)glimpsePanel.glimpseFigure;
 
454
                
 
455
                axe.setLabelsDisplayed(Axe.LABELS_DISPLAYED_ALL_VALUE);
 
456
                axeShapeChoice.setSelectedIndex(0);
 
457
                ticksShapeChoice.setSelectedIndex(0);
 
458
                ticksSizeField.setValue(PSTricksConstants.DEFAULT_TICKS_SIZE);
 
459
                defineLabelDistCB.setSelected(false);
 
460
                labelXDistField.setEnabled(false);
 
461
                labelYDistField.setEnabled(false);
 
462
                axe.setDistLabelsX(0);
 
463
                axe.setDistLabelsY(0);
 
464
                axe.setIncrementX(PSTricksConstants.DEFAULT_DX);
 
465
                axe.setIncrementY(PSTricksConstants.DEFAULT_DY);
 
466
                axe.setOriginX(PSTricksConstants.DEFAULT_OX);
 
467
                axe.setOriginY(PSTricksConstants.DEFAULT_OY);
 
468
                axe.setShowOrigin(PSTricksConstants.DEFAULT_SHOW_ORIGIN);
 
469
                axe.updateBorders();
 
470
                
 
471
                glimpsePanel.repaint();
 
472
        }
 
473
        
 
474
        
 
475
        
 
476
        
 
477
        @Override
 
478
        public void saveParameters()
 
479
        {
 
480
                super.saveParameters();
 
481
                
 
482
                Axe a = (Axe)figure;
 
483
                double xVal = Float.valueOf(labelXDistField.getValue().toString()).doubleValue();
 
484
                double yVal = Float.valueOf(labelYDistField.getValue().toString()).doubleValue();
 
485
 
 
486
                if(drawXLabel.isSelected())
 
487
                        if(drawYLabel.isSelected())
 
488
                                a.setLabelsDisplayed(Axe.LABELS_DISPLAYED_ALL_VALUE);
 
489
                        else a.setLabelsDisplayed(Axe.LABELS_DISPLAYED_X_VALUE);
 
490
                else 
 
491
                        if(drawYLabel.isSelected())
 
492
                                a.setLabelsDisplayed(Axe.LABELS_DISPLAYED_Y_VALUE);
 
493
                        else a.setLabelsDisplayed(Axe.LABELS_DISPLAYED_NON_VALUE);
 
494
 
 
495
                if(drawXTicks.isSelected())
 
496
                        if(drawYTicks.isSelected())
 
497
                                a.setTicksDisplayed(Axe.LABELS_DISPLAYED_ALL_VALUE);
 
498
                        else a.setTicksDisplayed(Axe.LABELS_DISPLAYED_X_VALUE);
 
499
                else 
 
500
                        if(drawYTicks.isSelected())
 
501
                                a.setTicksDisplayed(Axe.LABELS_DISPLAYED_Y_VALUE);
 
502
                        else a.setTicksDisplayed(Axe.LABELS_DISPLAYED_NON_VALUE);
 
503
                
 
504
                String selected = axeShapeChoice.getSelectedItem().toString();
 
505
                
 
506
                if(selected.equals(Axe.LABEL_STYLE_AXE))
 
507
                        a.setAxesStyle(Axe.AXES_STYLE_AXES_VALUE);
 
508
                else
 
509
                        if(selected.equals(Axe.LABEL_STYLE_FRAME))
 
510
                                a.setAxesStyle(Axe.AXES_STYLE_FRAME_VALUE);
 
511
                        else 
 
512
                                if(selected.equals(Axe.LABEL_STYLE_NONE))
 
513
                                        a.setAxesStyle(Axe.AXES_STYLE_NONE_VALUE);
 
514
                
 
515
                selected = ticksShapeChoice.getSelectedItem().toString();
 
516
                
 
517
                if(selected.equals(Axe.LABEL_STYLE_TICKS_FULL))
 
518
                        a.setTicksStyle(Axe.TICKS_STYLE_FULL_VALUE);
 
519
                else
 
520
                        if(selected.equals(Axe.LABEL_STYLE_TICKS_TOP))
 
521
                                a.setTicksStyle(Axe.TICKS_STYLE_TOP_VALUE);
 
522
                        else 
 
523
                                if(selected.equals(Axe.LABEL_STYLE_TICKS_BOTTOM))
 
524
                                        a.setTicksStyle(Axe.TICKS_STYLE_BOTTOM_VALUE);
 
525
                
 
526
                a.setTicksSize(Float.valueOf(ticksSizeField.getValue().toString()).doubleValue());
 
527
                a.setDistLabelsX(defineLabelDistCB.isSelected() ? xVal : 0);
 
528
                a.setDistLabelsY(defineLabelDistCB.isSelected() ? yVal : 0);
 
529
                a.setIncrementX(Float.valueOf(labelXIncrement.getValue().toString()).doubleValue());
 
530
                a.setIncrementY(Float.valueOf(labelYIncrement.getValue().toString()).doubleValue());
 
531
                a.setOriginX(Float.valueOf(labelXOrigin.getValue().toString()).intValue());
 
532
                a.setOriginY(Float.valueOf(labelYOrigin.getValue().toString()).intValue());
 
533
                a.setShowOrigin(showOriginCB.isSelected());
 
534
                a.updateBorders();
 
535
                
 
536
                drawPanel.getFrameParent().setExportAsMenu(true);
 
537
                drawPanel.getDraw().updateBorders();
 
538
                drawPanel.updateDraw(true);
 
539
        }
 
540
        
 
541
        
 
542
        
 
543
        
 
544
        @Override
 
545
        public void actionPerformed(ActionEvent e) 
 
546
        {
 
547
                try
 
548
                {
 
549
                        Object o = e.getSource();
 
550
                        Axe a = (Axe)glimpsePanel.getGlimpseFigure();
 
551
                        
 
552
                        if(o instanceof JCheckBox)
 
553
                        {
 
554
                                String label = ((JCheckBox)o).getActionCommand();
 
555
                                
 
556
                                if(label.equals(LABEL_SHOW_ORIGIN))
 
557
                                {
 
558
                                        setModified(true);
 
559
                                        a.setShowOrigin(showOriginCB.isSelected());
 
560
                                        glimpsePanel.repaint();
 
561
                                        
 
562
                                        return ;
 
563
                                }
 
564
                                
 
565
                                if(label.equals(LABEL_DEF_LABELS_DIST))
 
566
                                {
 
567
                                        double xVal = Float.valueOf(labelXDistField.getValue().toString()).doubleValue();
 
568
                                        double yVal = Float.valueOf(labelYDistField.getValue().toString()).doubleValue();
 
569
                                        boolean isSelected = defineLabelDistCB.isSelected();
 
570
                                        
 
571
                                        setModified(true);
 
572
                                        labelXDistField.setEnabled(isSelected);
 
573
                                        labelYDistField.setEnabled(isSelected);
 
574
                                        a.setDistLabelsX(isSelected ? xVal : 0);
 
575
                                        a.setDistLabelsY(isSelected ? yVal : 0);
 
576
                                        a.updateBorders();
 
577
                                        glimpsePanel.repaint();
 
578
                                        
 
579
                                        return ;
 
580
                                }
 
581
                                
 
582
                                if(label.equals(LABEL_DRAW_X_LABELS) || label.equals(LABEL_DRAW_Y_LABELS))
 
583
                                {
 
584
                                        if(drawXLabel.isSelected())
 
585
                                                if(drawYLabel.isSelected())
 
586
                                                        a.setLabelsDisplayed(Axe.LABELS_DISPLAYED_ALL_VALUE);
 
587
                                                else a.setLabelsDisplayed(Axe.LABELS_DISPLAYED_X_VALUE);
 
588
                                        else 
 
589
                                                if(drawYLabel.isSelected())
 
590
                                                        a.setLabelsDisplayed(Axe.LABELS_DISPLAYED_Y_VALUE);
 
591
                                                else a.setLabelsDisplayed(Axe.LABELS_DISPLAYED_NON_VALUE);
 
592
                                        
 
593
                                        setModified(true);
 
594
                                        glimpsePanel.repaint();
 
595
                                        return ;
 
596
                                }
 
597
                                
 
598
                                if(label.equals(LABEL_DRAW_X_TICKS) || label.equals(LABEL_DRAW_Y_TICKS))
 
599
                                {
 
600
                                        if(drawXTicks.isSelected())
 
601
                                                if(drawYTicks.isSelected())
 
602
                                                        a.setTicksDisplayed(Axe.LABELS_DISPLAYED_ALL_VALUE);
 
603
                                                else a.setTicksDisplayed(Axe.LABELS_DISPLAYED_X_VALUE);
 
604
                                        else 
 
605
                                                if(drawYTicks.isSelected())
 
606
                                                        a.setTicksDisplayed(Axe.LABELS_DISPLAYED_Y_VALUE);
 
607
                                                else a.setTicksDisplayed(Axe.LABELS_DISPLAYED_NON_VALUE);
 
608
                                        
 
609
                                        setModified(true);
 
610
                                        glimpsePanel.repaint();
 
611
                                        return ;
 
612
                                }
 
613
                        }
 
614
                        
 
615
                        if(o instanceof JComboBox)
 
616
                        {
 
617
                                String label = ((JComboBox)o).getActionCommand();
 
618
                                
 
619
                                if(label.equals(Axe.ACTION_CMD_AXE_STYLE_CHOICE))
 
620
                                {
 
621
                                        String selected = axeShapeChoice.getSelectedItem().toString();
 
622
                                        
 
623
                                        if(selected.equals(Axe.LABEL_STYLE_AXE))
 
624
                                                a.setAxesStyle(Axe.AXES_STYLE_AXES_VALUE);
 
625
                                        else
 
626
                                                if(selected.equals(Axe.LABEL_STYLE_FRAME))
 
627
                                                        a.setAxesStyle(Axe.AXES_STYLE_FRAME_VALUE);
 
628
                                                else 
 
629
                                                        if(selected.equals(Axe.LABEL_STYLE_NONE))
 
630
                                                                a.setAxesStyle(Axe.AXES_STYLE_NONE_VALUE);
 
631
                                        
 
632
                                        setModified(true);
 
633
                                        boolean ok = selected.equals(Axe.LABEL_STYLE_AXE);
 
634
                                        arrow1Choice.setEnabled(ok);
 
635
                                        arrow2Choice.setEnabled(ok);
 
636
                                        glimpsePanel.repaint();
 
637
                                        return ;
 
638
                                }
 
639
                                
 
640
                                if(label.equals(Axe.ACTION_CMD_TICKS_STYLE_CHOICE))
 
641
                                {
 
642
                                        String selected = ticksShapeChoice.getSelectedItem().toString();
 
643
                        
 
644
                                        if(selected.equals(Axe.LABEL_STYLE_TICKS_FULL))
 
645
                                                a.setTicksStyle(Axe.TICKS_STYLE_FULL_VALUE);
 
646
                                        else
 
647
                                                if(selected.equals(Axe.LABEL_STYLE_TICKS_TOP))
 
648
                                                        a.setTicksStyle(Axe.TICKS_STYLE_TOP_VALUE);
 
649
                                                else 
 
650
                                                        if(selected.equals(Axe.LABEL_STYLE_TICKS_BOTTOM))
 
651
                                                                a.setTicksStyle(Axe.TICKS_STYLE_BOTTOM_VALUE);
 
652
                                        
 
653
                                        setModified(true);
 
654
                                        glimpsePanel.repaint();
 
655
                                        return ;
 
656
                                }
 
657
                                
 
658
                                return ;
 
659
                        }
 
660
                }
 
661
                catch(Exception ex)
 
662
                {
 
663
                        ex.printStackTrace(); 
 
664
                        ExceptionFrameDialog.showExceptionDialog(ex);
 
665
                }
 
666
                
 
667
                super.actionPerformed(e);
 
668
        }
 
669
 
 
670
        
 
671
        
 
672
        @Override
 
673
        public void stateChanged(ChangeEvent e) 
 
674
        {
 
675
                try
 
676
                {
 
677
                        Object o = e.getSource();
 
678
                        Axe a = (Axe)glimpsePanel.getGlimpseFigure();
 
679
                        
 
680
                        if(o instanceof JSpinner)
 
681
                        {
 
682
                                String name = ((JSpinner)o).getName();
 
683
                                
 
684
                                if(name.equals(LABEL_TICKS_SIZE_FIELD))
 
685
                                {
 
686
                                        setModified(true);
 
687
                                        a.setTicksSize(Float.valueOf(ticksSizeField.getValue().toString()).doubleValue());
 
688
                                        a.updateBorders();
 
689
                                        glimpsePanel.repaint();
 
690
                                        return ;
 
691
                                }
 
692
                                
 
693
                                if(name.equals(LABEL_LABEL_X_INCR))
 
694
                                {
 
695
                                        setModified(true);
 
696
                                        a.setIncrementX(Float.valueOf(labelXIncrement.getValue().toString()).doubleValue());
 
697
                                        glimpsePanel.repaint();
 
698
                                        return ;
 
699
                                }
 
700
 
 
701
                                if(name.equals(LABEL_LABEL_Y_INCR))
 
702
                                {
 
703
                                        setModified(true);
 
704
                                        a.setIncrementY(Float.valueOf(labelYIncrement.getValue().toString()).doubleValue());
 
705
                                        glimpsePanel.repaint();
 
706
                                        return ;
 
707
                                }
 
708
                                
 
709
                                if(name.equals(LABEL_LABEL_X_ORIG))
 
710
                                {
 
711
                                        setModified(true);
 
712
                                        a.setOriginX(Float.valueOf(labelXOrigin.getValue().toString()).intValue());
 
713
                                        glimpsePanel.repaint();
 
714
                                        return ;
 
715
                                }
 
716
                                
 
717
                                if(name.equals(LABEL_LABEL_Y_ORIG))
 
718
                                {
 
719
                                        setModified(true);
 
720
                                        a.setOriginY(Float.valueOf(labelYOrigin.getValue().toString()).intValue());
 
721
                                        glimpsePanel.repaint();
 
722
                                        return ;
 
723
                                }
 
724
 
 
725
                                if(name.equals(LABEL_X_LABEL_DIST))
 
726
                                {
 
727
                                        setModified(true);
 
728
                                        a.setDistLabelsX(Float.valueOf(labelXDistField.getValue().toString()).doubleValue());
 
729
                                        a.updateBorders();
 
730
                                        glimpsePanel.repaint();
 
731
                                        return ;
 
732
                                }
 
733
                                
 
734
                                if(name.equals(LABEL_Y_LABEL_DIST))
 
735
                                {
 
736
                                        setModified(true);
 
737
                                        a.setDistLabelsY(Float.valueOf(labelYDistField.getValue().toString()).doubleValue());
 
738
                                        a.updateBorders();
 
739
                                        glimpsePanel.repaint();
 
740
                                        return ;
 
741
                                }
 
742
                        }
 
743
                }
 
744
                catch(Exception ex)
 
745
                {
 
746
                        ex.printStackTrace(); 
 
747
                        ExceptionFrameDialog.showExceptionDialog(ex);
 
748
                }
 
749
                
 
750
                super.stateChanged(e);
 
751
        }
 
752
}