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 30659f6 commit 3309f40
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ public synchronized boolean click(Point c) {
case JULIA_SET:
gaussianNumberPlane.computeTheJuliaSetFor(c);
break;
case MANDELBROT_ZOOM:
gaussianNumberPlane.zoomIntoTheMandelbrotSet(c);
break;
case JULIA_SET_ZOOM:
gaussianNumberPlane.zoomIntoTheJuliaSetFor(c);
break;
}
return repaint;
}
Expand All @@ -62,8 +56,6 @@ public synchronized boolean step() {
repaint = mandelbrotTuringMachine.step();
break;
case JULIA_SET:
case MANDELBROT_ZOOM:
case JULIA_SET_ZOOM:
break;
}
return repaint;
Expand All @@ -80,16 +72,10 @@ public Point getWorldDimensions() {
}

public void setModeSwitch() {
this.applicationStateMachine.setModeSwitch();
//this.applicationStateMachine.setModeSwitch();
this.frame.setModeSwitch();
}

public void setModeZoom() {
this.gaussianNumberPlane.setModeZoom();
this.applicationStateMachine.setModeZoom();
this.frame.setModeZoom();
}

public GaussianNumberPlane getGaussianNumberPlane() {
return gaussianNumberPlane;
}
Expand All @@ -98,17 +84,4 @@ public MandelbrotTab getFrame() {
return frame;
}

public void zoomOut() {
switch (applicationStateMachine.getApplicationState()) {
case MANDELBROT:
case JULIA_SET:
break;
case MANDELBROT_ZOOM:
gaussianNumberPlane.zoomOutOfTheMandelbrotSet();
break;
case JULIA_SET_ZOOM:
gaussianNumberPlane.zoomOutOfTheJuliaSet();
break;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.woehlke.computer.kurzweil.tabs.mandelbrot;

import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties;
import org.woehlke.computer.kurzweil.tabs.mandelbrot.canvas.PanelButtons;
import org.woehlke.computer.kurzweil.tabs.mandelbrot.canvas.PanelCopyright;
import org.woehlke.computer.kurzweil.tabs.mandelbrot.canvas.PanelSubtitle;
import org.woehlke.computer.kurzweil.tabs.mandelbrot.model.turing.Point;
Expand Down Expand Up @@ -39,16 +38,13 @@ public MandelbrotTab(ComputerKurzweilProperties properties) {
BoxLayout layout = new BoxLayout(rootPane, BoxLayout.PAGE_AXIS);
this.canvas = new MandelbrotCanvas(mandelbrotModel);
this.mandelbrotController = new MandelbrotController(mandelbrotModel, this);
PanelButtons panelButtons = new PanelButtons(this.mandelbrotModel);
PanelSubtitle panelSubtitle = new PanelSubtitle(properties.getMandelbrot().getView().getSubtitle());
PanelCopyright panelCopyright = new PanelCopyright(properties.getAllinone().getView().getCopyright());
JSeparator separator = new JSeparator();
rootPane.setLayout(layout);
rootPane.add(panelSubtitle);
rootPane.add(canvas);
rootPane.add(panelCopyright);
rootPane.add(separator);
rootPane.add(panelButtons);
addWindowListener(this);
this.canvas.addMouseListener( this);
showMeInit();
Expand Down Expand Up @@ -104,7 +100,7 @@ public void showMeInit() {
pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
double width = this.rootPane.getWidth();
double height = this.canvas.getHeight() + 180;
double height = this.canvas.getHeight() + 90;
double startX = (screenSize.getWidth() - width) / 2d;
double startY = (screenSize.getHeight() - height) / 2d;
int myheight = Double.valueOf(height).intValue();
Expand Down Expand Up @@ -137,10 +133,11 @@ public void setModeSwitch() {
canvas.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
}

/*
public void setModeZoom() {
canvas.setCursor(new Cursor(Cursor.HAND_CURSOR));
}

*/
public MandelbrotCanvas getCanvas() {
return canvas;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class GaussianNumberPlane {

private volatile ComplexNumber zoomCenter;


//public static Logger log = Logger.getLogger(GaussianNumberPlane.class.getName());

public GaussianNumberPlane(MandelbrotModel model) {
Expand All @@ -64,10 +63,12 @@ public GaussianNumberPlane(MandelbrotModel model) {
start();
}

/*
public void setModeZoom() {
this.setZoomLevel(1);
this.setZoomCenter(complexCenterForMandelbrot);
}
*/

public synchronized void start(){
zoomLevel = 1;
Expand Down Expand Up @@ -120,11 +121,13 @@ private synchronized ComplexNumber getComplexNumberFromLatticeCoordsForZoomedMan
return new ComplexNumber(realX,imgY);
}

/*
public synchronized boolean isInZooomedMandelbrotSet(Point turingPosition) {
ComplexNumber position = this.getComplexNumberFromLatticeCoordsForZoomedMandelbrot(turingPosition);
lattice[turingPosition.getX()][turingPosition.getY()] = position.computeMandelbrotSet();
return position.isInMandelbrotSet();
}
*/

public synchronized boolean isInMandelbrotSet(Point turingPosition) {
ComplexNumber position = this.getComplexNumberFromLatticeCoordsForMandelbrot(turingPosition);
Expand Down Expand Up @@ -158,6 +161,7 @@ public synchronized void computeTheJuliaSetFor(Point pointFromMandelbrotSet) {
computeTheJuliaSetForC(c);
}

/*
public void zoomIntoTheMandelbrotSet(Point zoomPoint) {
//log.info("zoomIntoTheMandelbrotSet: "+ zoomPoint +" - old: "+this.getZoomCenter());
this.inceaseZoomLevel();
Expand Down Expand Up @@ -201,19 +205,20 @@ public void zoomIntoTheJuliaSetFor(Point zoomPoint) {
public void zoomOutOfTheJuliaSet() {
}

*/
public synchronized int getZoomLevel() {
return zoomLevel;
}

/*
public synchronized int inceaseZoomLevel() {
return zoomLevel *= 2;
}
public synchronized int deceaseZoomLevel() {
return zoomLevel /= 2;
}

*/
public synchronized void setZoomLevel(int zoomLevel) {
this.zoomLevel = zoomLevel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@
*/
public enum ApplicationState {
MANDELBROT,
JULIA_SET,
MANDELBROT_ZOOM,
JULIA_SET_ZOOM
JULIA_SET
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.woehlke.computer.kurzweil.tabs.mandelbrot.model.state;

import static org.woehlke.computer.kurzweil.tabs.mandelbrot.model.state.ApplicationState.*;
import static org.woehlke.computer.kurzweil.tabs.mandelbrot.model.state.ApplicationState.JULIA_SET_ZOOM;

/**
* Mandelbrot Set drawn by a Turing Machine.
Expand Down Expand Up @@ -29,47 +28,21 @@ public void click(){
case JULIA_SET:
nextApplicationState = MANDELBROT;
break;
case MANDELBROT_ZOOM:
nextApplicationState = MANDELBROT_ZOOM;
break;
case JULIA_SET_ZOOM:
nextApplicationState = JULIA_SET_ZOOM;
break;
}
this.setApplicationState(nextApplicationState);
}

/*
public void setModeSwitch() {
ApplicationState nextApplicationState = this.applicationState;
switch (applicationState){
case MANDELBROT:
case JULIA_SET:
break;
case MANDELBROT_ZOOM:
nextApplicationState = MANDELBROT;
break;
case JULIA_SET_ZOOM:
nextApplicationState = JULIA_SET;
break;
}
this.setApplicationState(nextApplicationState);
}

public void setModeZoom() {
ApplicationState nextApplicationState = this.applicationState;
switch (applicationState){
case MANDELBROT:
nextApplicationState = MANDELBROT_ZOOM;
break;
case JULIA_SET:
nextApplicationState = JULIA_SET_ZOOM;
break;
case MANDELBROT_ZOOM:
case JULIA_SET_ZOOM:
break;
}
this.setApplicationState(nextApplicationState);
}
*/

public ApplicationState getApplicationState() {
return applicationState;
Expand Down

0 comments on commit 3309f40

Please sign in to comment.