View Javadoc
1   package org.woehlke.computer.kurzweil.mandelbrot.zoom.view.labels;
2   
3   import org.woehlke.computer.kurzweil.mandelbrot.zoom.config.ComputerKurzweilProperties;
4   import org.woehlke.computer.kurzweil.mandelbrot.zoom.model.ApplicationModel;
5   import org.woehlke.computer.kurzweil.mandelbrot.zoom.view.MandelbrotZoomFrame;
6   
7   import javax.swing.*;
8   import java.awt.*;
9   import java.awt.event.ActionEvent;
10  import java.awt.event.ActionListener;
11  
12  public class PanelButtons extends JPanel implements ActionListener {
13  
14      final static long serialVersionUID = 242L;
15  
16      private volatile JLabel copyright;
17      private volatile JButton zoomOut;
18      private final MandelbrotZoomFrame tab;
19      private final ApplicationModel model;
20  
21      public PanelButtons(ApplicationModel model, MandelbrotZoomFrame tab, ComputerKurzweilProperties config ) {
22          this.tab = tab;
23          this.model = model;
24          this.copyright = new JLabel(config.getMandelbrotZoom().getView().getCopyright());
25          this.zoomOut = new JButton(config.getMandelbrotZoom().getView().getButtonsZoomOut());
26          int hgap = 16;
27          int vgap = 2;
28          this.copyright.setLayout(new FlowLayout( FlowLayout.RIGHT, hgap, vgap));
29          this.zoomOut.setLayout(new FlowLayout( FlowLayout.LEFT, hgap, vgap));
30          this.setLayout(new FlowLayout( FlowLayout.CENTER, hgap, vgap));
31          this.add(this.copyright);
32          this.add(this.zoomOut);
33          this.zoomOut.addActionListener(this);
34      }
35  
36      /**
37       * TODO write doc.
38       */
39      @Override
40      public void actionPerformed(ActionEvent ae) {
41          if(ae.getSource() == this.zoomOut){
42              this.model.zoomOut();
43              this.tab.getCanvas().repaint();
44              this.tab.repaint();
45          }
46      }
47  }