Skip to content

Commit

Permalink
Issue #48 Split Mandelbrot-Tab into Mandelbrot-Julia and Mandelbrot-Zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaswoehlke committed Oct 11, 2020
1 parent bef8254 commit 29a8487
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@
*/
public enum MandelbrotZoomTabState {
MANDELBROT,
JULIA_SET,
MANDELBROT_ZOOM,
JULIA_SET_ZOOM
MANDELBROT_ZOOM
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -26,23 +25,18 @@ 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);
}

public void setModeSwitch() {
MandelbrotZoomTabState nextApplicationState = this.applicationState;
/*
switch (applicationState){
case MANDELBROT:
case JULIA_SET:
Expand All @@ -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;
Expand All @@ -70,6 +66,7 @@ public void setModeZoom() {
case JULIA_SET_ZOOM:
break;
}
*/
this.setApplicationState(nextApplicationState);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}

Expand All @@ -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();
}
Expand Down

0 comments on commit 29a8487

Please sign in to comment.