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