View Javadoc
1   package org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.ui;
2   
3   import org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.SierpinskiTriangleModel;
4   
5   import javax.swing.*;
6   import java.awt.*;
7   import java.awt.event.ActionEvent;
8   import java.awt.event.ActionListener;
9   
10  
11  /**
12   * Mandelbrot Set drawn by a Turing Machine.
13   *
14   * (C) 2006 - 2015 Thomas Woehlke.
15   * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html
16   * @author Thomas Woehlke
17   *
18   * Created by tw on 16.12.2019.
19   */
20  public class PanelButtons extends JPanel implements ActionListener {
21  
22      //private volatile JRadioButton radioButtonsSwitch;
23      //private volatile JRadioButton radioButtonsZoom;
24      private volatile JButton zoomOut;
25      //private volatile ButtonGroup radioButtonsGroup;
26      private volatile SierpinskiTriangleModel model;
27  
28      public PanelButtons(SierpinskiTriangleModel model) {
29          this.model = model;
30          JLabel buttonsLabel = new JLabel(model.getProperties().getWator().getView().getButtonsLabel());
31          /*
32          this.radioButtonsSwitch = new JRadioButton(model.getProperties().getMandelbrot().getView().getButtonsSwitch());
33          this.radioButtonsSwitch.setMnemonic(RADIO_BUTTONS_SWITCH.ordinal());
34          this.radioButtonsSwitch.setSelected(true);
35          this.radioButtonsSwitch.addActionListener(this);
36          this.radioButtonsZoom = new JRadioButton(model.getProperties().getMandelbrot().getView().getButtonsSwitch());
37          this.radioButtonsZoom.setMnemonic(RADIO_BUTTONS_ZOOM.ordinal());
38          this.radioButtonsZoom.addActionListener(this);
39          this.radioButtonsGroup = new ButtonGroup();
40          this.radioButtonsGroup.add(radioButtonsSwitch);
41          this.radioButtonsGroup.add(radioButtonsZoom);
42           */
43          this.zoomOut = new JButton(model.getProperties().getWator().getView().getButtonsZoomOut());
44          this.zoomOut.addActionListener(this);
45          FlowLayout layout = new FlowLayout();
46          this.setLayout(layout);
47          this.add(buttonsLabel);
48          //this.add(radioButtonsSwitch);
49          //this.add(radioButtonsZoom);
50          this.add(zoomOut);
51      }
52  
53      /**
54       * TODO write doc.
55       */
56      @Override
57      public void actionPerformed(ActionEvent ae) {
58          //if (ae.getSource() == this.radioButtonsSwitch) {
59          //    this.model.setModeSwitch();
60          //} else
61              //if(ae.getSource() == this.radioButtonsZoom) {
62             // this.model.setModeZoom();
63          //} else
64          if(ae.getSource() == this.zoomOut){
65              this.model.zoomOut();
66              this.model.getFrame().getCanvas().repaint();
67          }
68      }
69  }