1 package org.woehlke.computer.kurzweil.application;
2
3 import lombok.Getter;
4 import lombok.extern.log4j.Log4j2;
5
6 import javax.swing.*;
7 import java.awt.event.KeyEvent;
8
9 @Log4j2
10 @Getter
11 public class ComputerKurzweilMenuBar extends JMenuBar {
12
13 private final ComputerKurzweilContext ctx;
14
15 public ComputerKurzweilMenuBar(ComputerKurzweilContext ctx) {
16 this.ctx = ctx;
17 ComputerKurzweilProperties p = this.ctx.getProperties();
18 cyclicCellularAutomatonMenuItemLabel = p.getCca().getView().getTitle();
19 randomWalkMenuItemLabel = p.getRandomwalk().getView().getTitle();
20 diffusionLimitedAggregationMenuItemLabel = p.getDla().getView().getTitle();
21 mandelbrotMenuItemLabel = p.getMandelbrot().getView().getTitle();
22 simulatedEvolutionMenuItemLabel = p.getSimulatedevolution().getView().getTitle();
23 cyclicCellularAutomatonTooltip = p.getCca().getView().getSubtitle();
24 randomWalkTooltip = p.getRandomwalk().getView().getSubtitle();
25 diffusionLimitedAggregationTooltip = p.getDla().getView().getSubtitle();
26 mandelbrotTooltip = p.getMandelbrot().getView().getSubtitle();
27 simulatedEvolutionTooltip = p.getSimulatedevolution().getView().getSubtitle();
28 fileMenu = new JMenu(fileMenuLabel);
29 exitMenuItem = new JMenuItem(exitCmd, null);
30 exitMenuItem.setMnemonic(KeyEvent.VK_E);
31 exitMenuItem.setToolTipText(exitTooltip);
32 exitMenuItem.addActionListener((event) -> System.exit(0));
33 fileMenu.add(exitMenuItem);
34 fileMenu.setMnemonic(KeyEvent.VK_F);
35 startMenu = new JMenu(startMenuLabel);
36 cyclicCellularAutomatonMenuItem = new JMenuItem(startCmd+cyclicCellularAutomatonMenuItemLabel, null);
37 randomWalkMenuItem = new JMenuItem(startCmd+randomWalkMenuItemLabel, null);
38 diffusionLimitedAggregationMenuItem = new JMenuItem(startCmd+diffusionLimitedAggregationMenuItemLabel, null);
39 mandelbrotMenuItem = new JMenuItem(startCmd+mandelbrotMenuItemLabel, null);
40 simulatedEvolutionMenuItem = new JMenuItem(startCmd+simulatedEvolutionMenuItemLabel, null);
41 cyclicCellularAutomatonMenuItem.setMnemonic(KeyEvent.VK_1);
42 cyclicCellularAutomatonMenuItem.setToolTipText(cyclicCellularAutomatonTooltip);
43 cyclicCellularAutomatonMenuItem.addActionListener((event) -> cyclicCellularAutomatonStart());
44 randomWalkMenuItem.setMnemonic(KeyEvent.VK_2);
45 randomWalkMenuItem.setToolTipText(randomWalkTooltip);
46 randomWalkMenuItem.addActionListener((event) -> randomWalkStart());
47 diffusionLimitedAggregationMenuItem.setMnemonic(KeyEvent.VK_3);
48 diffusionLimitedAggregationMenuItem.setToolTipText(diffusionLimitedAggregationTooltip);
49 diffusionLimitedAggregationMenuItem.addActionListener((event) -> diffusionLimitedAggregationStart());
50 mandelbrotMenuItem.setMnemonic(KeyEvent.VK_4);
51 mandelbrotMenuItem.setToolTipText(mandelbrotTooltip);
52 mandelbrotMenuItem.addActionListener((event) -> mandelbrotStart());
53 simulatedEvolutionMenuItem.setMnemonic(KeyEvent.VK_5);
54 simulatedEvolutionMenuItem.setToolTipText(simulatedEvolutionTooltip);
55 simulatedEvolutionMenuItem.addActionListener((event) -> simulatedEvolutionStart());
56 startMenu.add(cyclicCellularAutomatonMenuItem);
57 startMenu.add(randomWalkMenuItem);
58 startMenu.add(diffusionLimitedAggregationMenuItem);
59 startMenu.add(mandelbrotMenuItem);
60 startMenu.add(simulatedEvolutionMenuItem);
61 startMenu.setMnemonic(KeyEvent.VK_S);
62 this.add(fileMenu);
63 this.add(startMenu);
64 }
65
66
67 private void cyclicCellularAutomatonStart(){
68
69 }
70
71 private void randomWalkStart(){
72
73 }
74
75 private void diffusionLimitedAggregationStart(){
76
77 }
78
79 private void mandelbrotStart(){
80
81 }
82
83 private void simulatedEvolutionStart(){
84
85 }
86
87 private final JMenu fileMenu;
88 private final JMenu startMenu;
89
90 private final String cyclicCellularAutomatonMenuItemLabel;
91 private final String randomWalkMenuItemLabel;
92 private final String diffusionLimitedAggregationMenuItemLabel;
93 private final String mandelbrotMenuItemLabel;
94 private final String simulatedEvolutionMenuItemLabel;
95
96 private final String cyclicCellularAutomatonTooltip;
97 private final String randomWalkTooltip;
98 private final String diffusionLimitedAggregationTooltip;
99 private final String mandelbrotTooltip;
100 private final String simulatedEvolutionTooltip;
101
102 private final JMenuItem cyclicCellularAutomatonMenuItem;
103 private final JMenuItem randomWalkMenuItem;
104 private final JMenuItem diffusionLimitedAggregationMenuItem;
105 private final JMenuItem mandelbrotMenuItem;
106 private final JMenuItem simulatedEvolutionMenuItem;
107
108 private final String startCmd = "Start ";
109 private final String fileMenuLabel = "File";
110 private final String startMenuLabel = "Start";
111
112 private final String exitCmd = "Exit";
113 private final String exitTooltip = "Exit application";
114
115 private final JMenuItem exitMenuItem;
116 }