~tapaal-contributor/tapaal/Typos-1896460

« back to all changes in this revision

Viewing changes to src/pipe/gui/SimulationControl.java

  • Committer: srba.jiri at gmail
  • Date: 2020-08-19 12:02:28 UTC
  • mfrom: (1071.2.34 untimed-timed-gui)
  • Revision ID: srba.jiri@gmail.com-20200819120228-ktxdev3ou3kuj3l0
merged in lp:~tapaal-contributor/tapaal/untimed-timed-gui adding timed/untimed lens projection

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
        
23
23
        final JSlider simulationSpeed = new JSlider();
24
24
        final JCheckBox randomSimulation = new JCheckBox("Enable automatic random simulation");
25
 
        final Timer timer = new Timer(simulationSpeed.getValue()*20, e -> CreateGui.getCurrentTab().getTransitionFireingComponent().fireSelectedTransition());
26
 
        
27
 
        private static SimulationControl instance;
 
25
    final JCheckBox randomMode = new JCheckBox("Choose next transition randomly");
 
26
    final Timer timer = new Timer(simulationSpeed.getValue()*20, e -> CreateGui.getCurrentTab().getTransitionFireingComponent().fireSelectedTransition());
 
27
    private static boolean defaultIsRandomTrasition;
 
28
    private static SimulationControl instance;
28
29
        
29
30
        public static SimulationControl getInstance(){
30
31
                if(instance == null){
62
63
                gbc.gridx = 0;
63
64
                gbc.gridy = 0;
64
65
                add(randomSimulation, gbc);
65
 
                
 
66
 
66
67
                gbc = new GridBagConstraints();
 
68
        gbc.anchor = GridBagConstraints.WEST;
 
69
        gbc.fill = GridBagConstraints.HORIZONTAL;
 
70
        gbc.weightx = 1.0;
 
71
        gbc.gridx = 0;
 
72
        gbc.gridy = 1;
 
73
        add(randomMode, gbc);
 
74
 
 
75
        setRandomTransitionMode(defaultIsRandomTrasition);
 
76
 
 
77
        gbc = new GridBagConstraints();
67
78
                gbc.anchor = GridBagConstraints.WEST;
68
79
                gbc.fill = GridBagConstraints.HORIZONTAL;
69
80
                gbc.weightx = 1.0;
70
81
                gbc.gridx = 0;
71
 
                gbc.gridy = 1;
 
82
                gbc.gridy = 2;
72
83
                add(new JLabel("Set simulation speed:"), gbc);
73
84
                
74
85
                gbc = new GridBagConstraints();
76
87
                gbc.fill = GridBagConstraints.HORIZONTAL;
77
88
                gbc.weightx = 1.0;
78
89
                gbc.gridx = 0;
79
 
                gbc.gridy = 2;
 
90
                gbc.gridy = 3;
80
91
                add(simulationSpeed, gbc);
81
92
                
82
93
                setBorder(BorderFactory.createCompoundBorder(
159
170
                dialog.setLocation(x, y);
160
171
                dialog.setVisible(true);
161
172
        }
 
173
 
 
174
    public boolean isRandomTransitionMode(){
 
175
        if(SimulationControl.getInstance().randomSimulation()){
 
176
            return true;
 
177
        } else {
 
178
            return randomMode.isSelected();
 
179
        }
 
180
    }
 
181
 
 
182
    public void setRandomTransitionMode(boolean randomTransition){
 
183
        randomMode.setSelected(randomTransition);
 
184
    }
 
185
    public static boolean isRandomTransition(){
 
186
        if(instance != null){
 
187
            return getInstance().isRandomTransitionMode();
 
188
        } else {
 
189
            return defaultIsRandomTrasition;
 
190
        }
 
191
    }
 
192
    public static void setDefaultIsRandomTransition(boolean delayEnabledTransitionIsRandomTransition) {
 
193
        defaultIsRandomTrasition = delayEnabledTransitionIsRandomTransition;
 
194
    }
162
195
}