From 29a84874408f0ab28475caf1627931ce3a18b8f4 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Sun, 11 Oct 2020 12:42:40 +0200 Subject: [PATCH] Issue #48 Split Mandelbrot-Tab into Mandelbrot-Julia and Mandelbrot-Zoom --- .../mandelbrotzoom/MandelbrotZoomModel.java | 24 +++++++++---------- .../model/MandelbrotZoomTabState.java | 4 +--- .../model/MandelbrotZoomTabStateMachine.java | 15 +++++------- .../tabs/mandelbrotzoom/ui/PanelButtons.java | 24 +++++++++++-------- 4 files changed, 33 insertions(+), 34 deletions(-) diff --git a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/MandelbrotZoomModel.java b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/MandelbrotZoomModel.java index 35d48dcf..45f154f7 100644 --- a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/MandelbrotZoomModel.java +++ b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/MandelbrotZoomModel.java @@ -42,15 +42,15 @@ public synchronized boolean click(Point c) { mandelbrotTuringMachine.start(); repaint = false; break; - case JULIA_SET: - gaussianNumberPlane.computeTheJuliaSetFor(c); - break; + //case JULIA_SET: + // gaussianNumberPlane.computeTheJuliaSetFor(c); + // break; case MANDELBROT_ZOOM: gaussianNumberPlane.zoomIntoTheMandelbrotSet(c); break; - case JULIA_SET_ZOOM: - gaussianNumberPlane.zoomIntoTheJuliaSetFor(c); - break; + //case JULIA_SET_ZOOM: + // gaussianNumberPlane.zoomIntoTheJuliaSetFor(c); + // break; } return repaint; } @@ -61,9 +61,9 @@ public synchronized boolean step() { case MANDELBROT: repaint = mandelbrotTuringMachine.step(); break; - case JULIA_SET: + //case JULIA_SET: case MANDELBROT_ZOOM: - case JULIA_SET_ZOOM: + //case JULIA_SET_ZOOM: break; } return repaint; @@ -101,14 +101,14 @@ public MandelbrotZoomTab getFrame() { public void zoomOut() { switch (applicationStateMachine.getApplicationState()) { case MANDELBROT: - case JULIA_SET: + //case JULIA_SET: break; case MANDELBROT_ZOOM: gaussianNumberPlane.zoomOutOfTheMandelbrotSet(); break; - case JULIA_SET_ZOOM: - gaussianNumberPlane.zoomOutOfTheJuliaSet(); - break; + //case JULIA_SET_ZOOM: + // gaussianNumberPlane.zoomOutOfTheJuliaSet(); + // break; } } } diff --git a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/MandelbrotZoomTabState.java b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/MandelbrotZoomTabState.java index b69daf12..e14d2c16 100644 --- a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/MandelbrotZoomTabState.java +++ b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/MandelbrotZoomTabState.java @@ -11,7 +11,5 @@ */ public enum MandelbrotZoomTabState { MANDELBROT, - JULIA_SET, - MANDELBROT_ZOOM, - JULIA_SET_ZOOM + MANDELBROT_ZOOM } diff --git a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/MandelbrotZoomTabStateMachine.java b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/MandelbrotZoomTabStateMachine.java index 6262e1b2..4441d53c 100644 --- a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/MandelbrotZoomTabStateMachine.java +++ b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/MandelbrotZoomTabStateMachine.java @@ -3,7 +3,6 @@ import org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.model.MandelbrotZoomTabState; import static org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.model.MandelbrotZoomTabState.*; -import static org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.model.MandelbrotZoomTabState.JULIA_SET_ZOOM; /** * Mandelbrot Set drawn by a Turing Machine. @@ -26,16 +25,10 @@ public void click(){ MandelbrotZoomTabState nextApplicationState = null; switch (applicationState){ case MANDELBROT: - nextApplicationState = JULIA_SET; - break; - case JULIA_SET: - nextApplicationState = MANDELBROT; - break; - case MANDELBROT_ZOOM: nextApplicationState = MANDELBROT_ZOOM; break; - case JULIA_SET_ZOOM: - nextApplicationState = JULIA_SET_ZOOM; + case MANDELBROT_ZOOM: + nextApplicationState = MANDELBROT; break; } this.setApplicationState(nextApplicationState); @@ -43,6 +36,7 @@ public void click(){ public void setModeSwitch() { MandelbrotZoomTabState nextApplicationState = this.applicationState; + /* switch (applicationState){ case MANDELBROT: case JULIA_SET: @@ -54,11 +48,13 @@ public void setModeSwitch() { nextApplicationState = JULIA_SET; break; } + */ this.setApplicationState(nextApplicationState); } public void setModeZoom() { MandelbrotZoomTabState nextApplicationState = this.applicationState; + /* switch (applicationState){ case MANDELBROT: nextApplicationState = MANDELBROT_ZOOM; @@ -70,6 +66,7 @@ public void setModeZoom() { case JULIA_SET_ZOOM: break; } + */ this.setApplicationState(nextApplicationState); } diff --git a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/ui/PanelButtons.java b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/ui/PanelButtons.java index 0c93373a..40f0b485 100644 --- a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/ui/PanelButtons.java +++ b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/ui/PanelButtons.java @@ -22,15 +22,16 @@ */ public class PanelButtons extends JPanel implements ActionListener { - private volatile JRadioButton radioButtonsSwitch; - private volatile JRadioButton radioButtonsZoom; + //private volatile JRadioButton radioButtonsSwitch; + //private volatile JRadioButton radioButtonsZoom; private volatile JButton zoomOut; - private volatile ButtonGroup radioButtonsGroup; + //private volatile ButtonGroup radioButtonsGroup; private volatile MandelbrotZoomModel model; public PanelButtons(MandelbrotZoomModel model) { this.model = model; JLabel buttonsLabel = new JLabel(model.getProperties().getMandelbrot().getView().getButtonsLabel()); + /* this.radioButtonsSwitch = new JRadioButton(model.getProperties().getMandelbrot().getView().getButtonsSwitch()); this.radioButtonsSwitch.setMnemonic(RADIO_BUTTONS_SWITCH.ordinal()); this.radioButtonsSwitch.setSelected(true); @@ -41,13 +42,14 @@ public PanelButtons(MandelbrotZoomModel model) { this.radioButtonsGroup = new ButtonGroup(); this.radioButtonsGroup.add(radioButtonsSwitch); this.radioButtonsGroup.add(radioButtonsZoom); + */ this.zoomOut = new JButton(model.getProperties().getMandelbrot().getView().getButtonsZoomOut()); this.zoomOut.addActionListener(this); FlowLayout layout = new FlowLayout(); this.setLayout(layout); this.add(buttonsLabel); - this.add(radioButtonsSwitch); - this.add(radioButtonsZoom); + //this.add(radioButtonsSwitch); + //this.add(radioButtonsZoom); this.add(zoomOut); } @@ -56,11 +58,13 @@ public PanelButtons(MandelbrotZoomModel model) { */ @Override public void actionPerformed(ActionEvent ae) { - if (ae.getSource() == this.radioButtonsSwitch) { - this.model.setModeSwitch(); - } else if(ae.getSource() == this.radioButtonsZoom) { - this.model.setModeZoom(); - } else if(ae.getSource() == this.zoomOut){ + //if (ae.getSource() == this.radioButtonsSwitch) { + // this.model.setModeSwitch(); + //} else + //if(ae.getSource() == this.radioButtonsZoom) { + // this.model.setModeZoom(); + //} else + if(ae.getSource() == this.zoomOut){ this.model.zoomOut(); this.model.getFrame().getCanvas().repaint(); }