~ubuntu-branches/ubuntu/precise/scilab/precise

« back to all changes in this revision

Viewing changes to modules/xcos/src/java/org/scilab/modules/xcos/actions/ViewGridAction.java

  • Committer: Bazaar Package Importer
  • Author(s): Sylvestre Ledru
  • Date: 2010-04-16 15:57:24 UTC
  • mfrom: (1.1.9 upstream) (4.4.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100416155724-lx1sdku0oidl0ffn
Tags: 5.2.2-1
* New upstream release
* better-feedback-on-lib-error.diff, full_support.diff, renesas-sh.diff,
  s390javadetection.diff, sparc64.diff, test_run_permission.diff,
  z_cpudetection.diff removed (applied upstream)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
package org.scilab.modules.xcos.actions;
15
15
 
16
16
import java.awt.event.ActionEvent;
 
17
import java.beans.PropertyChangeEvent;
 
18
import java.beans.PropertyChangeListener;
17
19
 
18
20
import org.scilab.modules.graph.ScilabGraph;
19
21
import org.scilab.modules.graph.actions.base.DefaultAction;
25
27
 * Grid visibility management
26
28
 */
27
29
public final class ViewGridAction extends DefaultAction {
 
30
        /** Name of the action */
28
31
        public static final String NAME = XcosMessages.GRID;
 
32
        /** Icon name of the action */
29
33
        public static final String SMALL_ICON = "";
 
34
        /** Mnemonic key of the action */
30
35
        public static final int MNEMONIC_KEY = 0;
 
36
        /** Accelerator key for the action */
31
37
        public static final int ACCELERATOR_KEY = 0;
32
38
        
33
39
        /**
44
50
         * @return the menu
45
51
         */
46
52
        public static CheckBoxMenuItem createCheckBoxMenu(ScilabGraph scilabGraph) {
47
 
                CheckBoxMenuItem  menu = createCheckBoxMenu(scilabGraph, ViewGridAction.class);
 
53
                final CheckBoxMenuItem  menu = 
 
54
                        createCheckBoxMenu(scilabGraph, ViewGridAction.class);
48
55
                menu.setChecked(true);
 
56
                
 
57
                scilabGraph.addPropertyChangeListener("gridEnabled", new PropertyChangeListener() {
 
58
                        public void propertyChange(PropertyChangeEvent evt) {
 
59
                                XcosDiagram graph = (XcosDiagram) evt.getSource();
 
60
                                
 
61
                                menu.setChecked(graph.isGridEnabled());
 
62
                                graph.getAsComponent().setGridVisible(graph.isGridEnabled());
 
63
                                graph.getAsComponent().repaint();
 
64
                        }
 
65
                });
 
66
                
49
67
                return  menu;
50
68
        }
51
69
        
55
73
         */
56
74
        @Override
57
75
        public void actionPerformed(ActionEvent e) {
58
 
                ((XcosDiagram) getGraph(null)).setGridVisible(!((XcosDiagram) getGraph(null)).getAsComponent().isGridVisible());
 
76
                ((ScilabGraph) getGraph(e)).setGridEnabled(!((XcosDiagram) getGraph(e)).isGridEnabled());
59
77
        }
60
78
}