diff --git a/single-apps/insourcing/insourcing-kochsnowflake/README.md b/single-apps/insourcing/insourcing-kochsnowflake/README.md new file mode 100644 index 00000000..8463bdda --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/README.md @@ -0,0 +1,56 @@ +# Wator + +**Wator Slogan** + +## Abstract: Wator + + +## More +* [https://en.wikipedia.org/wiki/Mandelbrot_set](https://en.wikipedia.org/wiki/Mandelbrot_set) +* [https://en.wikipedia.org/wiki/Julia_set](https://en.wikipedia.org/wiki/Julia_set) +* [https://en.wikipedia.org/wiki/Turing_machine](https://en.wikipedia.org/wiki/Turing_machine) + +## Screenshots + +### Running around the Edge of the Mandelbrot Set + +![Running around the Edge of the Mandelbrot Set](src/main/resources/img/screen01.png) + +### Running around the Edge of the Mandelbrot Set + +![Running around the Edge of the Mandelbrot Set](src/main/resources/img/screen02.png) + +### Computing the Area outside the Mandelbrot Set + +![Computing the Area outside the Mandelbrot Set](src/main/resources/img/screen03.png) + +### Clicked somewhere on the Edge of Mandelbrot Set: The Julia Set + +![Clicked somewhere on the Edge of Mandelbrot Set: The Julia Set](src/main/resources/img/julia01.png) + +### Clicked on another Point on the Edge of Mandelbrot Set: The Julia Set + +![Clicked on another Point on the Edge of Mandelbrot Set: The Julia Set](src/main/resources/img/julia02.png) + + +### Git Repository +* [https://github.com/thomaswoehlke/mandelbrot](https://github.com/thomaswoehlke/mandelbrot.git) + + +### Gradle Wrapper +* [https://docs.gradle.org/current/userguide/gradle_wrapper.html](https://docs.gradle.org/current/userguide/gradle_wrapper.html) + +### Run the Desktop Application +``` +git clone https://github.com/thomaswoehlke/mandelbrot.git +cd mandelbrot +./gradlew clean shadowJar runShadow +``` + +### Run the Applet Test +``` +git clone https://github.com/thomaswoehlke/mandelbrot.git +cd mandelbrot +TODO: xxx +``` + diff --git a/single-apps/insourcing/insourcing-kochsnowflake/pom.xml b/single-apps/insourcing/insourcing-kochsnowflake/pom.xml new file mode 100644 index 00000000..5a8e684e --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/pom.xml @@ -0,0 +1,127 @@ + + + 4.0.0 + + + org.woehlke.computer.kurzweil + insourcing + 2.2.8-SNAPSHOT + .. + + + insourcing-kochsnowflake + jar + + single-apps :: insourcing :: Koch Snowflake + kochsnowflake + + + org.woehlke.computer.kurzweil.KochSnowflakeApplication + + + + + org.apache.logging.log4j + log4j-slf4j-impl + + + org.apache.logging.log4j + log4j-api + + + org.apache.logging.log4j + log4j-jcl + + + org.apache.logging.log4j + log4j-core + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.dataformat + jackson-dataformat-properties + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + + + com.fasterxml.jackson.dataformat + jackson-dataformat-ion + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-core + + + org.apache.commons + commons-lang3 + + + org.yaml + snakeyaml + + + com.google.guava + guava + + + javax.validation + validation-api + + + + + ${project.artifactId} + clean dependency:tree install exec:java + + + org.codehaus.mojo + exec-maven-plugin + + + + java + + + + + org.woehlke.computer.kurzweil.KochSnowflakeApplication + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + org.woehlke.computer.kurzweil.KochSnowflakeApplication + + + + + + org.apache.maven.plugins + maven-release-plugin + + clean + true + + + + + + diff --git a/single-apps/insourcing/insourcing-kochsnowflake/run.cmd b/single-apps/insourcing/insourcing-kochsnowflake/run.cmd new file mode 100644 index 00000000..726b9db4 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/run.cmd @@ -0,0 +1,2 @@ +cmd /c ..\..\mvnw -e clean install site +cmd /c ..\..\mvnw diff --git a/single-apps/insourcing/insourcing-kochsnowflake/run.sh b/single-apps/insourcing/insourcing-kochsnowflake/run.sh new file mode 100755 index 00000000..5d1cd68e --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/run.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + + +function site() { + ../../../mvnw -e site site:deploy +} + +function run() { + ../../../mvnw +} + +function main() { + #site + run +} + +main diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/KochSnowflakeApplication.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/KochSnowflakeApplication.java new file mode 100644 index 00000000..f0e8f79c --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/KochSnowflakeApplication.java @@ -0,0 +1,33 @@ +package org.woehlke.computer.kurzweil; + +import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties; +import org.woehlke.computer.kurzweil.tabs.kochsnowflake.KochSnowflakeTab; + +import java.io.File; +import java.net.URL; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + */ +public class KochSnowflakeApplication { + + private KochSnowflakeApplication() { + String configFileName = "/application.yml"; + URL fileUrl = getClass().getResource(configFileName); + File configFile = new File(fileUrl.getFile()); + ComputerKurzweilProperties properties = ComputerKurzweilProperties.propertiesFactory(configFile); + KochSnowflakeTab frame = new KochSnowflakeTab(properties); + } + + /** + * Starting the Application. + * @param args CLI Parameter + */ + public static void main(String[] args) { + KochSnowflakeApplication application = new KochSnowflakeApplication(); + } +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/application/ComputerKurzweilProperties.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/application/ComputerKurzweilProperties.java new file mode 100644 index 00000000..2c2cda7f --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/application/ComputerKurzweilProperties.java @@ -0,0 +1,600 @@ +package org.woehlke.computer.kurzweil.application; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import lombok.*; +import lombok.extern.log4j.Log4j2; +import org.woehlke.computer.kurzweil.tabs.TabType; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +@Log4j2 +@ToString +@EqualsAndHashCode +@NoArgsConstructor +@AllArgsConstructor +@Valid +////@Validated +public class ComputerKurzweilProperties { + + @Valid @Getter @Setter public Allinone allinone = new Allinone(); + @Valid @Getter @Setter public Mandelbrot mandelbrot = new Mandelbrot(); + @Valid @Getter @Setter public MandelbrotZoom mandelbrotZoom = new MandelbrotZoom(); + @Valid @Getter @Setter public SimulatedEvolution simulatedevolution = new SimulatedEvolution(); + @Valid @Getter @Setter public Cca cca = new Cca(); + @Valid @Getter @Setter public WienerProcess randomwalk = new WienerProcess(); + @Valid @Getter @Setter public Dla dla = new Dla(); + @Valid @Getter @Setter public Kochsnowflake kochsnowflake = new Kochsnowflake(); + @Valid @Getter @Setter public Samegame samegame = new Samegame(); + @Valid @Getter @Setter public Sierpinskitriangle sierpinskitriangle = new Sierpinskitriangle(); + @Valid @Getter @Setter public Tetris tetris = new Tetris(); + @Valid @Getter @Setter public Turmite turmite = new Turmite(); + @Valid @Getter @Setter public Wator wator = new Wator(); + @Valid @Getter @Setter public Gameoflive gameoflive = new Gameoflive(); + + public static ComputerKurzweilProperties propertiesFactory(File conf){ + log.info("propertiesFactory"); + log.info("propertiesFactory conf: "+conf.getAbsolutePath()); + ComputerKurzweilProperties properties; + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + try { + InputStream input = new FileInputStream(conf); + properties = mapper.readValue(input, ComputerKurzweilProperties.class); + log.info(properties.toString()); + } catch (Exception e) { + e.printStackTrace(); + properties = new ComputerKurzweilProperties(); + } + log.info("propertiesFactory done"); + return properties; + } + + public static ComputerKurzweilProperties propertiesFactory(String conf, String jar){ + log.info("propertiesFactory"); + log.info("propertiesFactory conf: "+conf); + log.info("propertiesFactory jar: "+jar); + ComputerKurzweilProperties properties; + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + try { + JarFile jarFile = new JarFile(jar); + JarEntry entry = jarFile.getJarEntry(conf); + InputStream input = jarFile.getInputStream(entry); + properties = mapper.readValue(input, ComputerKurzweilProperties.class); + log.info(properties.toString()); + } catch (Exception e) { + e.printStackTrace(); + properties = new ComputerKurzweilProperties(); + } + log.info("propertiesFactory done"); + return properties; + } + + public String getSubtitle(TabType tabType){ + switch (tabType){ + case CYCLIC_CELLULAR_AUTOMATON: + return this.getCca().getView().getSubtitle(); + case DIFFUSION_LIMITED_AGGREGATION: + return this.getDla().getView().getSubtitle(); + case SIMULATED_EVOLUTION: + return this.getSimulatedevolution().getView().getSubtitle(); + case MANDELBROT_SET: + return this.getMandelbrot().getView().getSubtitle(); + case RANDOM_WALK_WIENER_PROCESS: + return this.getRandomwalk().getView().getSubtitle(); + case KOCH_SNOWFLAKE: + return this.getKochsnowflake().getView().getSubtitle(); + case SAME_GAME: + return this.getSamegame().getView().getSubtitle(); + case SIERPINSKI_TRIANGLE: + return this.getSierpinskitriangle().getView().getSubtitle(); + case TETRIS: + return this.getTetris().getView().getSubtitle(); + case TURMITE: + return this.getTurmite().getView().getSubtitle(); + case WATOR: + return this.getWator().getView().getSubtitle(); + case CONWAYS_GAME_OF_LIFE: + return this.getGameoflive().getView().getSubtitle(); + default: + return "UNDEFINED"; + } + } + + public String getTitle(TabType tabType){ + switch (tabType){ + case CYCLIC_CELLULAR_AUTOMATON: + return this.getCca().getView().getTitle(); + case DIFFUSION_LIMITED_AGGREGATION: + return this.getDla().getView().getTitle(); + case SIMULATED_EVOLUTION: + return this.getSimulatedevolution().getView().getTitle(); + case MANDELBROT_SET: + return this.getMandelbrot().getView().getTitle(); + case RANDOM_WALK_WIENER_PROCESS: + return this.getRandomwalk().getView().getTitle(); + case KOCH_SNOWFLAKE: + return this.getKochsnowflake().getView().getTitle(); + case SAME_GAME: + return this.getSamegame().getView().getTitle(); + case SIERPINSKI_TRIANGLE: + return this.getSierpinskitriangle().getView().getTitle(); + case TETRIS: + return this.getTetris().getView().getTitle(); + case TURMITE: + return this.getTurmite().getView().getTitle(); + case WATOR: + return this.getWator().getView().getTitle(); + case CONWAYS_GAME_OF_LIFE: + return this.getGameoflive().getView().getTitle(); + default: + return "UNDEFINED"; + } + } + + ////@Validated + @ToString + public static class Allinone { + + @Valid @Getter @Setter public Lattice lattice = new Lattice(); + @Valid @Getter @Setter public View view = new View(); + + ////@Validated + @ToString + public static class Lattice { + @NotNull @Getter @Setter private Integer width; + @NotNull @Getter @Setter private Integer height; + } + + ////@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + @NotBlank @Getter @Setter private String copyright; + @NotNull @Getter @Setter private Integer borderPaddingX; + @NotNull @Getter @Setter private Integer borderPaddingY; + @NotNull @Getter @Setter private Integer titleHeight; + @NotBlank @Getter @Setter private String startStopp; + @NotBlank @Getter @Setter private String start; + @NotBlank @Getter @Setter private String stop; + @NotBlank @Getter @Setter private String info; + } + } + + ////@Validated + @ToString + public static class Mandelbrot { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + ////@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + @NotBlank @Getter @Setter private String buttonsZoom; + @NotBlank @Getter @Setter private String buttonsZoomOut; + @NotBlank @Getter @Setter private String buttonsSwitch; + @NotBlank @Getter @Setter private String buttonsZoomLabel; + @NotBlank @Getter @Setter private String buttonsLabel; + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + } + } + + ////@Validated + @ToString + public static class MandelbrotZoom { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + ////@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + @NotBlank @Getter @Setter private String buttonsZoom; + @NotBlank @Getter @Setter private String buttonsZoomOut; + @NotBlank @Getter @Setter private String buttonsSwitch; + @NotBlank @Getter @Setter private String buttonsZoomLabel; + @NotBlank @Getter @Setter private String buttonsLabel; + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + } + } + + ////@Validated + @ToString + public static class SimulatedEvolution { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + @Valid @Getter @Setter public CellConf cellConf = new CellConf(); + @Valid @Getter @Setter public Population population = new Population(); + @Valid @Getter @Setter public Food food = new Food(); + @Valid @Getter @Setter public GardenOfEden gardenOfEden = new GardenOfEden(); + + ////@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer exitStatus; + @NotNull @Getter @Setter private Integer queueMaxLength; + } + + ////@Validated + @ToString + public static class CellConf { + @NotNull @Getter @Setter private Integer fatMax; + @NotNull @Getter @Setter private Integer fatHungerMax; + @NotNull @Getter @Setter private Integer fatMinimumForSex; + @NotNull @Getter @Setter private Integer fatAtBirth; + @NotNull @Getter @Setter private Integer fatPerFood; + @NotNull @Getter @Setter private Integer ageOfAdulthood; + @NotNull @Getter @Setter private Integer ageOld; + @NotNull @Getter @Setter private Integer ageMax; + } + + ////@Validated + @ToString + public static class Population { + @NotNull @Getter @Setter private Integer initialPopulation; + @NotBlank @Getter @Setter private String panelPopulationStatistics; + @NotBlank @Getter @Setter private String panelLifeCycleStatistics; + @NotBlank @Getter @Setter private String youngCellsLabel; + @NotBlank @Getter @Setter private String youngAndFatCellsLabel; + @NotBlank @Getter @Setter private String fullAgeCellsLabel; + @NotBlank @Getter @Setter private String hungryCellsLabel; + @NotBlank @Getter @Setter private String oldCellsLabel; + @NotBlank @Getter @Setter private String populationLabel; + @NotBlank @Getter @Setter private String generationOldestLabel; + @NotBlank @Getter @Setter private String generationYoungestLabel; + } + + ////@Validated + @ToString + public static class Food { + @NotNull @Getter @Setter private Integer foodPerDay; + @NotNull @Getter @Setter private Integer foodPerDayFieldColumns; + @NotBlank @Getter @Setter private String foodPerDayLabel; + @NotBlank @Getter @Setter private String foodPerDayBorderLabel; + @NotBlank @Getter @Setter private String buttonFoodPerDayIncrease; + @NotBlank @Getter @Setter private String buttonFoodPerDayDecrease; + @NotBlank @Getter @Setter private String panelFood; + } + + ////@Validated + @ToString + public static class GardenOfEden { + @NotBlank @Getter @Setter private String panelGardenOfEden; + @NotNull @Getter @Setter private Boolean gardenOfEdenEnabled; + @NotBlank @Getter @Setter private String gardenOfEdenEnabledString; + @NotBlank @Getter @Setter private String gardenOfEdenEnabledToggleButton; + @NotNull @Getter @Setter private Integer foodPerDay; + @NotNull @Getter @Setter private Integer gardenOfEdenLatticeDivisor; + @NotNull @Getter @Setter private Integer gardenOfEdenLatticeDivisorPadding; + } + } + + ////@Validated + @ToString + public static class Cca { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + } + } + + ////@Validated + @ToString + public static class WienerProcess { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + } + } + + //@Validated + @ToString + public static class Dla { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Kochsnowflake { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Samegame { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Sierpinskitriangle { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Tetris { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Turmite { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Wator { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + @NotBlank @Getter @Setter private String buttonsZoom; + @NotBlank @Getter @Setter private String buttonsZoomOut; + @NotBlank @Getter @Setter private String buttonsSwitch; + @NotBlank @Getter @Setter private String buttonsZoomLabel; + @NotBlank @Getter @Setter private String buttonsLabel; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Gameoflive{ + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public ComputerKurzweilProperties.Wator.View.Neighborhood neighborhood = new Wator.View.Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/ComplexNumber.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/ComplexNumber.java new file mode 100644 index 00000000..5e68767a --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/ComplexNumber.java @@ -0,0 +1,133 @@ +package org.woehlke.computer.kurzweil.commons.model.fractal; + +import java.util.Objects; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 18.08.15. + */ +public class ComplexNumber { + + public final static int MAX_ITERATIONS = 64; + private final static double DIVERGENCE_THRESHOLD = 4.0d; + private volatile double real; + private volatile double img; + private volatile int iterations; + private volatile boolean inMandelbrotSet; + private volatile boolean inJuliaSet; + + public ComplexNumber() { + this.real = 0.0d; + this.img = 0.0d; + this.iterations=0; + this.inMandelbrotSet=false; + this.inJuliaSet=false; + } + + public ComplexNumber(ComplexNumber complexNumber) { + this.real = complexNumber.real; + this.img = complexNumber.img; + this.iterations=complexNumber.iterations; + this.inMandelbrotSet=complexNumber.inMandelbrotSet; + this.inJuliaSet=complexNumber.inJuliaSet; + } + + public ComplexNumber(double real, double img) { + this.real = real; + this.img = img; + this.iterations=0; + this.inMandelbrotSet=false; + this.inJuliaSet=false; + } + + public double getReal() { + return real; + } + + public double getImg() { + return img; + } + + public ComplexNumber plus(ComplexNumber complexNumber){ + double newRealZ = this.real + complexNumber.real; + double newImgZ = this.img + complexNumber.img; + return new ComplexNumber(newRealZ,newImgZ); + } + + public ComplexNumber square(){ + double realZ=real; + double imgZ=img; + double newRealZ=realZ*realZ-imgZ*imgZ; + double newImgZ=2*realZ*imgZ; + return new ComplexNumber(newRealZ,newImgZ); + } + + public synchronized int computeMandelbrotSet() { + int iterationsTmp = 0; + ComplexNumber z = new ComplexNumber(); + do { + iterationsTmp++; + z = z.square().plus(this); + } while (z.isNotDivergent() && (iterationsTmp < MAX_ITERATIONS)); + this.inMandelbrotSet = z.isNotDivergent(); + this.iterations = this.inMandelbrotSet?0:iterationsTmp; + return this.iterations; + } + + public synchronized int computeJuliaSet(ComplexNumber c) { + int iterationsTmp = 0; + ComplexNumber z = new ComplexNumber(this); + do { + iterationsTmp++; + z = z.square().plus(c); + } while (z.isNotDivergent() && (iterationsTmp < MAX_ITERATIONS)); + this.inJuliaSet = z.isNotDivergent(); + this.iterations = this.inJuliaSet?0:iterationsTmp; + return this.iterations; + } + + public synchronized boolean isInMandelbrotSet() { + return inMandelbrotSet; + } + + public synchronized boolean isInJuliaSet() { + return inJuliaSet; + } + + public synchronized boolean isNotDivergent(){ + return (( real*real + img*img ) < DIVERGENCE_THRESHOLD); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ComplexNumber)) return false; + ComplexNumber that = (ComplexNumber) o; + return Double.compare(that.getReal(), getReal()) == 0 && + Double.compare(that.getImg(), getImg()) == 0 && + iterations == that.iterations && + isInMandelbrotSet() == that.isInMandelbrotSet() && + isInJuliaSet() == that.isInJuliaSet(); + } + + @Override + public int hashCode() { + return Objects.hash(getReal(), getImg(), iterations, isInMandelbrotSet(), isInJuliaSet()); + } + + @Override + public String toString() { + return "ComplexNumber{" + + "real=" + real + + ", img=" + img + + ", iterations=" + iterations + + ", inMandelbrotSet=" + inMandelbrotSet + + ", inJuliaSet=" + inJuliaSet + + '}'; + } +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/GaussianNumberPlane.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/GaussianNumberPlane.java new file mode 100644 index 00000000..0cabb985 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/GaussianNumberPlane.java @@ -0,0 +1,222 @@ +package org.woehlke.computer.kurzweil.commons.model.fractal; + +import org.woehlke.computer.kurzweil.tabs.kochsnowflake.KochSnowflakeModel; +import org.woehlke.computer.kurzweil.commons.model.turing.Point; + +import java.util.ArrayDeque; +import java.util.Deque; +//import java.util.logging.Logger; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class GaussianNumberPlane { + + public final static int YET_UNCOMPUTED = -1; + private final static double complexWorldDimensionRealX = 3.2d; + private final static double complexWorldDimensionImgY = 2.34d; + private final static double complexCenterForMandelbrotRealX = -2.2f; + private final static double complexCenterForMandelbrotImgY = -1.17f; + private final static double complexCenterForJuliaRealX = -1.6d; + private final static double complexCenterForJuliaImgY = -1.17d; + private final Point worldDimensions; + public volatile int zoomLevel; + private volatile int[][] lattice; + private volatile ComplexNumber complexNumberForJuliaSetC; + private volatile ComplexNumber complexWorldDimensions; + private volatile ComplexNumber complexCenterForMandelbrot; + private volatile ComplexNumber complexCenterForJulia; + private volatile Deque complexCenterForZoomedMandelbrot = new ArrayDeque<>(); + + private volatile ComplexNumber zoomCenter; + + + //public static Logger log = Logger.getLogger(GaussianNumberPlane.class.getName()); + + public GaussianNumberPlane(KochSnowflakeModel model) { + this.worldDimensions = model.getWorldDimensions(); + this.lattice = new int[worldDimensions.getWidth()][worldDimensions.getHeight()]; + this.complexWorldDimensions = new ComplexNumber( + complexWorldDimensionRealX, + complexWorldDimensionImgY + ); + this.complexCenterForMandelbrot = new ComplexNumber( + complexCenterForMandelbrotRealX, + complexCenterForMandelbrotImgY + ); + this.complexCenterForJulia = new ComplexNumber( + complexCenterForJuliaRealX, + complexCenterForJuliaImgY + ); + start(); + } + + public void setModeZoom() { + this.setZoomLevel(1); + this.setZoomCenter(complexCenterForMandelbrot); + } + + public synchronized void start(){ + zoomLevel = 1; + for(int y = 0;y < this.worldDimensions.getY(); y++){ + for(int x=0; x < worldDimensions.getX(); x++){ + lattice[x][y] = YET_UNCOMPUTED; + } + } + } + + public synchronized int getCellStatusFor(int x,int y){ + return (lattice[x][y])<0?0:lattice[x][y]; + } + + private synchronized ComplexNumber getComplexNumberFromLatticeCoordsForJulia(Point turingPosition) { + double realX = complexCenterForJulia.getReal() + + (complexWorldDimensions.getReal()*turingPosition.getX())/worldDimensions.getX(); + double imgY = complexCenterForJulia.getImg() + + (complexWorldDimensions.getImg()*turingPosition.getY())/worldDimensions.getY(); + return new ComplexNumber(realX,imgY); + } + + private synchronized ComplexNumber getComplexNumberFromLatticeCoordsForMandelbrot(Point turingPosition) { + double realX = ( + complexCenterForMandelbrot.getReal() + + ( complexWorldDimensions.getReal() * turingPosition.getX() ) + / worldDimensions.getX() + ); + double imgY = ( + complexCenterForMandelbrot.getImg() + + ( complexWorldDimensions.getImg() * turingPosition.getY() ) + / worldDimensions.getY() + ); + return new ComplexNumber(realX,imgY); + } + + private synchronized ComplexNumber getComplexNumberFromLatticeCoordsForZoomedMandelbrot(Point turingPosition) { + double realX = ( + ( complexCenterForMandelbrot.getReal() / this.getZoomLevel() ) + + getZoomCenter().getReal() + + ( complexWorldDimensions.getReal() * turingPosition.getX() ) + / ( worldDimensions.getX() * this.getZoomLevel() ) + ); + double imgY = ( + ( complexCenterForMandelbrot.getImg() / this.getZoomLevel() ) + + getZoomCenter().getImg() + + ( complexWorldDimensions.getImg() * turingPosition.getY() ) + / ( worldDimensions.getY() * this.getZoomLevel() ) + ); + 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); + lattice[turingPosition.getX()][turingPosition.getY()] = position.computeMandelbrotSet(); + return position.isInMandelbrotSet(); + } + + public synchronized void fillTheOutsideWithColors(){ + for(int y=0;y1){ + this.deceaseZoomLevel(); + this.setZoomCenter(complexCenterForZoomedMandelbrot.pop()); + } + //log.info("zoomCenter: " + this.getZoomCenter() + " - zoomLevel: "+ this.getZoomLevel()); + for(int y = 0; y < worldDimensions.getY(); y++){ + for(int x = 0; x < worldDimensions.getX(); x++){ + Point p = new Point(x, y); + this.isInZooomedMandelbrotSet(p); + } + } + } + + public void zoomIntoTheJuliaSetFor(Point zoomPoint) { + ComplexNumber c = this.complexNumberForJuliaSetC; + computeTheJuliaSetForC(c); + } + + public void zoomOutOfTheJuliaSet() { + } + + public synchronized int getZoomLevel() { + return zoomLevel; + } + + public synchronized void setZoomLevel(int zoomLevel) { + this.zoomLevel = zoomLevel; + } + + public synchronized int inceaseZoomLevel() { + return zoomLevel *= 2; + } + + public synchronized int deceaseZoomLevel() { + return zoomLevel /= 2; + } + + public synchronized ComplexNumber getZoomCenter() { + return zoomCenter; + } + + public synchronized void setZoomCenter(ComplexNumber zoomCenter) { + this.zoomCenter = zoomCenter; + } + +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringDirection.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringDirection.java new file mode 100644 index 00000000..bd799fa1 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringDirection.java @@ -0,0 +1,17 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 18.08.15. + */ +public enum MandelbrotTuringDirection { + UP, + RIGHT, + DOWN, + LEFT +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringMachine.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringMachine.java new file mode 100644 index 00000000..4c8f23d7 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringMachine.java @@ -0,0 +1,81 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +import org.woehlke.computer.kurzweil.tabs.kochsnowflake.KochSnowflakeModel; +import org.woehlke.computer.kurzweil.commons.model.fractal.GaussianNumberPlane; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Date: 28.08.13 + * Time: 12:39 + */ +public class MandelbrotTuringMachine { + + private volatile GaussianNumberPlane gaussianNumberPlane; + private volatile MandelbrotTuringPositions turingPositions; + private volatile MandelbrotTuringPhaseState turingPhaseState; + + public MandelbrotTuringMachine(KochSnowflakeModel model) { + this.gaussianNumberPlane = model.getGaussianNumberPlane(); + this.turingPhaseState = new MandelbrotTuringPhaseState(); + this.turingPositions = new MandelbrotTuringPositions(model.getWorldDimensions()); + start(); + } + + public void start() { + this.turingPhaseState.start(); + this.gaussianNumberPlane.start(); + this.turingPositions.start(); + } + + public synchronized boolean step() { + boolean repaint=true; + switch(turingPhaseState.getTuringTuringPhase()){ + case SEARCH_THE_SET: + stepGoToSet(); + repaint=false; + break; + case WALK_AROUND_THE_SET: + stepWalkAround(); + break; + case FILL_THE_OUTSIDE_WITH_COLOR: + fillTheOutsideWithColors(); + break; + case FINISHED: + default: + repaint=false; + break; + } + return repaint; + } + + private void stepGoToSet(){ + if(this.gaussianNumberPlane.isInMandelbrotSet(this.turingPositions.getTuringPosition())){ + this.turingPositions.markFirstSetPosition(); + this.turingPhaseState.finishSearchTheSet(); + } else { + this.turingPositions.goForward(); + } + } + + private void stepWalkAround(){ + if(gaussianNumberPlane.isInMandelbrotSet(this.turingPositions.getTuringPosition())){ + this.turingPositions.turnRight(); + } else { + this.turingPositions.turnLeft(); + } + this.turingPositions.goForward(); + if(this.turingPositions.isFinishedWalkAround()){ + this.turingPhaseState.finishWalkAround(); + } + } + + private void fillTheOutsideWithColors(){ + this.gaussianNumberPlane.fillTheOutsideWithColors(); + this.turingPhaseState.finishFillTheOutsideWithColors(); + } +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhase.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhase.java new file mode 100644 index 00000000..cff085ea --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhase.java @@ -0,0 +1,17 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 18.08.15. + */ +public enum MandelbrotTuringPhase { + SEARCH_THE_SET, + WALK_AROUND_THE_SET, + FILL_THE_OUTSIDE_WITH_COLOR, + FINISHED +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhaseState.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhaseState.java new file mode 100644 index 00000000..0fce7646 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhaseState.java @@ -0,0 +1,39 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class MandelbrotTuringPhaseState { + + private volatile MandelbrotTuringPhase turingTuringPhase; + + public MandelbrotTuringPhaseState() { + start(); + } + + public void start(){ + this.turingTuringPhase = MandelbrotTuringPhase.SEARCH_THE_SET; + } + + public void finishSearchTheSet(){ + turingTuringPhase = MandelbrotTuringPhase.WALK_AROUND_THE_SET; + } + + public void finishWalkAround() { + turingTuringPhase = MandelbrotTuringPhase.FILL_THE_OUTSIDE_WITH_COLOR; + } + + public void finishFillTheOutsideWithColors() { + turingTuringPhase = MandelbrotTuringPhase.FINISHED; + } + + public MandelbrotTuringPhase getTuringTuringPhase() { + return turingTuringPhase; + } +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPositions.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPositions.java new file mode 100644 index 00000000..889a592e --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPositions.java @@ -0,0 +1,90 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class MandelbrotTuringPositions { + + private volatile Point turingPosition; + private volatile Point worldDimensions; + private volatile Point firstSetPosition; + + private volatile MandelbrotTuringDirection turingDirection; + + private volatile int steps; + + public MandelbrotTuringPositions(Point worldDimensions) { + this.worldDimensions = worldDimensions; + start(); + } + + public void start() { + this.steps = 0; + this.turingPosition = new Point((worldDimensions.getX()-2),(worldDimensions.getY()/2+11)); + this.turingDirection = MandelbrotTuringDirection.LEFT; + } + + public synchronized void markFirstSetPosition(){ + this.firstSetPosition = turingPosition; + this.steps = 0; + } + + public synchronized Point getTuringPosition() { + return turingPosition; + } + + public synchronized void goForward() { + this.steps++; + switch (this.turingDirection){ + case UP: + this.turingPosition.moveUp(); + break; + case RIGHT: + this.turingPosition.moveRight(); + break; + case DOWN: + this.turingPosition.moveDown(); + break; + case LEFT: + this.turingPosition.moveLeft(); + break; + default: + break; + } + } + + public synchronized void turnRight() { + MandelbrotTuringDirection newTuringDirection; + switch (this.turingDirection){ + case UP: newTuringDirection = MandelbrotTuringDirection.RIGHT; break; + case RIGHT: newTuringDirection = MandelbrotTuringDirection.DOWN; break; + case DOWN: newTuringDirection = MandelbrotTuringDirection.LEFT; break; + case LEFT: newTuringDirection = MandelbrotTuringDirection.UP; break; + default: newTuringDirection = this.turingDirection; break; + } + this.turingDirection = newTuringDirection; + } + + public synchronized void turnLeft() { + MandelbrotTuringDirection newTuringDirection; + switch (this.turingDirection){ + case UP: newTuringDirection = MandelbrotTuringDirection.LEFT; break; + case RIGHT: newTuringDirection = MandelbrotTuringDirection.UP; break; + case DOWN: newTuringDirection = MandelbrotTuringDirection.RIGHT; break; + case LEFT: newTuringDirection = MandelbrotTuringDirection.DOWN; break; + default: newTuringDirection = this.turingDirection; break; + } + this.turingDirection = newTuringDirection; + } + + public synchronized boolean isFinishedWalkAround() { + return (this.turingPosition.equals(this.firstSetPosition)) && (this.steps>100); + } + +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/Point.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/Point.java new file mode 100644 index 00000000..a5da8333 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/Point.java @@ -0,0 +1,91 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +import java.util.Objects; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Date: 04.02.2006 + * Time: 23:47:05 + */ +public class Point { + + private volatile int x = 0; + private volatile int y = 0; + + public Point() { + } + + public Point(Point p) { + this.x = p.getX(); + this.y = p.getY(); + } + + public Point(int x, int y) { + this.x = x; + this.y = y; + } + + public void moveUp() { + y--; + } + + public void moveRight() { + x++; + } + + public void moveDown() { + y++; + } + + public void moveLeft() { + x--; + } + + public int getWidth(){ + return x; + } + public int getHeight() { return y; } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Point)) return false; + Point point = (Point) o; + return getX() == point.getX() && + getY() == point.getY(); + } + + @Override + public int hashCode() { + return Objects.hash(getX(), getY()); + } + + @Override + public String toString() { + return "Point{" + + "x=" + x + + ", y=" + y + + '}'; + } +} diff --git a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/ui/PanelCopyright.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java similarity index 88% rename from single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/ui/PanelCopyright.java rename to single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java index 0ff1ffac..4fae16fd 100644 --- a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/ui/PanelCopyright.java +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java @@ -1,4 +1,4 @@ -package org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.ui; +package org.woehlke.computer.kurzweil.commons.ui; import javax.swing.*; import java.awt.*; diff --git a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/ui/PanelSubtitle.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java similarity index 88% rename from single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/ui/PanelSubtitle.java rename to single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java index cb448797..fb044e95 100644 --- a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/ui/PanelSubtitle.java +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java @@ -1,4 +1,4 @@ -package org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.ui; +package org.woehlke.computer.kurzweil.commons.ui; import javax.swing.*; import java.awt.*; diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/TabType.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/TabType.java new file mode 100644 index 00000000..6473614f --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/TabType.java @@ -0,0 +1,109 @@ +package org.woehlke.computer.kurzweil.tabs; + +import lombok.Getter; + +import java.awt.event.KeyEvent; + +@Getter +public enum TabType { + + CYCLIC_CELLULAR_AUTOMATON( + KeyEvent.VK_1, + true, + "Cyclic Cellular Automaton", + "Cyclic Cellular Automaton", + "Cyclic Cellular Automaton" + ), + DIFFUSION_LIMITED_AGGREGATION( + KeyEvent.VK_2, + true, + "Diffusion Limited Aggregation", + "Fractal Random Walk due to Brownian Motion Cluster", + "Diffusion Limited Aggregation. Fractal Random Walk due to Brownian Motion Cluster" + ), + SIMULATED_EVOLUTION( + KeyEvent.VK_3, + true, + "Simulated Evolution", + "Artificial Life Simulation of Bacteria Motion depending on DNA and their Evolution", + "Artificial Life Simulation of Bacteria Motion depending on DNA and their Evolution" + ), + MANDELBROT_SET( + KeyEvent.VK_4, + true, + "Mandelbrot Set", + "Fractal Mandelbrot Set drawn by a Turing Machine", + "Fractal Mandelbrot Set drawn by a Turing Machine" + ), + RANDOM_WALK_WIENER_PROCESS( + KeyEvent.VK_5, + true, + "Random Walk", + "Brownian Motion by Fractal Random Walk", + "Random Walk. Brownian Motion by Fractal Random Walk" + ), + KOCH_SNOWFLAKE( + KeyEvent.VK_6, + false, + "Koch Snowflake", + "Fractal Koch Snowflake", + "Fractal Koch Snowflake" + ), + SAME_GAME( + KeyEvent.VK_7, + false, + "Same Game", + "Play the Same Game", + "Play the Same Game" + ), + SIERPINSKI_TRIANGLE( + KeyEvent.VK_0, + false, + "Sierpinski Triangle'", + "Fractal Sierpinski Triangle", + "Fractal Sierpinski Triangle" + ), + TETRIS( + KeyEvent.VK_8, + false, + "Tetris", + "Play Tetris", + "Play Tetris" + ), + TURMITE( + KeyEvent.VK_9, + false, + "Turmite", + "Turmites as Turing Machines with 2D Tape", + "Turmites as Turing Machines with 2D Tape" + ), + WATOR( + KeyEvent.VK_A, + false, + "WaTor", + "Population Dynamics on Planet Water Torus", + "Population Dynamics on Planet Water Torus" + ), + CONWAYS_GAME_OF_LIFE( + KeyEvent.VK_B, + false, + "Conways Game of Life", + "Conways Game of Life Cellular Automaton", + "Conways Game of Life Cellular Automaton" + ); + + private int keyEvent; + private boolean active; + private String title; + private String subTitle; + private String tooltip; + + TabType(int keyEvent, boolean active, String title, String subTitle, String tooltip){ + this.keyEvent=keyEvent; + this.active=active; + this.title=title; + this.subTitle=subTitle; + this.tooltip=tooltip; + } + +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/KochSnowflakeCanvas.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/KochSnowflakeCanvas.java new file mode 100644 index 00000000..3a3de551 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/KochSnowflakeCanvas.java @@ -0,0 +1,52 @@ +package org.woehlke.computer.kurzweil.tabs.kochsnowflake; + +import javax.swing.*; +import java.awt.*; + + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2013 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Date: 05.02.2006 + * Time: 00:51:51 + */ +public class KochSnowflakeCanvas extends JComponent { + + private volatile KochSnowflakeModel app; + private volatile Dimension preferredSize; + + public KochSnowflakeCanvas(KochSnowflakeModel app) { + this.app = app; + int width = this.app.getWorldDimensions().getWidth(); + int height = this.app.getWorldDimensions().getHeight(); + this.preferredSize = new Dimension(width, height); + this.setSize(this.preferredSize); + this.setPreferredSize(preferredSize); + } + + public void paint(Graphics g) { + this.setSize(this.preferredSize); + this.setPreferredSize(preferredSize); + super.paintComponent(g); + int red = 0; + int green = 0; + int blue = 0; + for(int y = 0; y < app.getWorldDimensions().getY(); y++){ + for(int x = 0; x < app.getWorldDimensions().getX(); x++){ + blue = (((app.getCellStatusFor(x,y))*4)%256); + Color stateColor = new Color(red, green, blue); + g.setColor(stateColor); + g.drawLine(x,y,x,y); + } + } + } + + public void update(Graphics g) { + paint(g); + } + +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/KochSnowflakeController.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/KochSnowflakeController.java new file mode 100644 index 00000000..b6d78aee --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/KochSnowflakeController.java @@ -0,0 +1,47 @@ +package org.woehlke.computer.kurzweil.tabs.kochsnowflake; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Date: 05.02.2006 + * Time: 00:36:20 + */ +public class KochSnowflakeController extends Thread implements Runnable { + + private final int THREAD_SLEEP_TIME = 1; + private volatile KochSnowflakeModel mandelbrotModel; + private volatile KochSnowflakeTab frame; + private volatile Boolean goOn; + + public KochSnowflakeController(KochSnowflakeModel model, KochSnowflakeTab frame) { + this.frame = frame; + this.mandelbrotModel = model; + goOn = Boolean.TRUE; + } + + public void run() { + boolean doIt; + do { + synchronized (goOn) { + doIt = goOn.booleanValue(); + } + if(this.mandelbrotModel.step()){ + frame.getCanvas().repaint(); + } + try { sleep(THREAD_SLEEP_TIME); } + catch (InterruptedException e) { } + } + while (doIt); + } + + public void exit() { + synchronized (goOn) { + goOn = Boolean.FALSE; + } + } + +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/KochSnowflakeModel.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/KochSnowflakeModel.java new file mode 100644 index 00000000..6c6cb8ae --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/KochSnowflakeModel.java @@ -0,0 +1,114 @@ +package org.woehlke.computer.kurzweil.tabs.kochsnowflake; + +import lombok.Getter; +import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties; +import org.woehlke.computer.kurzweil.commons.model.fractal.GaussianNumberPlane; +import org.woehlke.computer.kurzweil.commons.model.turing.Point; +import org.woehlke.computer.kurzweil.tabs.kochsnowflake.model.KochSnowflakeTabStateMachine; +import org.woehlke.computer.kurzweil.commons.model.turing.MandelbrotTuringMachine; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +@Getter +public class KochSnowflakeModel { + + private volatile GaussianNumberPlane gaussianNumberPlane; + private volatile MandelbrotTuringMachine mandelbrotTuringMachine; + private volatile KochSnowflakeTabStateMachine applicationStateMachine; + + private volatile ComputerKurzweilProperties properties; + private volatile KochSnowflakeTab frame; + + public KochSnowflakeModel(ComputerKurzweilProperties properties, KochSnowflakeTab frame) { + this.properties = properties; + this.frame = frame; + this.gaussianNumberPlane = new GaussianNumberPlane(this); + this.mandelbrotTuringMachine = new MandelbrotTuringMachine(this); + this.applicationStateMachine = new KochSnowflakeTabStateMachine(); + } + + public synchronized boolean click(Point c) { + applicationStateMachine.click(); + boolean repaint = true; + switch (applicationStateMachine.getApplicationState()) { + case MANDELBROT: + mandelbrotTuringMachine.start(); + repaint = false; + break; + //case JULIA_SET: + // gaussianNumberPlane.computeTheJuliaSetFor(c); + // break; + case MANDELBROT_ZOOM: + gaussianNumberPlane.zoomIntoTheMandelbrotSet(c); + break; + //case JULIA_SET_ZOOM: + // gaussianNumberPlane.zoomIntoTheJuliaSetFor(c); + // break; + } + return repaint; + } + + public synchronized boolean step() { + boolean repaint = false; + switch (applicationStateMachine.getApplicationState()) { + case MANDELBROT: + repaint = mandelbrotTuringMachine.step(); + break; + //case JULIA_SET: + case MANDELBROT_ZOOM: + //case JULIA_SET_ZOOM: + break; + } + return repaint; + } + + public synchronized int getCellStatusFor(int x, int y) { + return gaussianNumberPlane.getCellStatusFor(x, y); + } + + public Point getWorldDimensions() { + int width = properties.getAllinone().getLattice().getWidth(); + int height = properties.getAllinone().getLattice().getHeight(); + return new Point(width, height); + } + + public void setModeSwitch() { + this.applicationStateMachine.setModeSwitch(); + this.frame.setModeSwitch(); + } + + public void setModeZoom() { + this.gaussianNumberPlane.setModeZoom(); + this.applicationStateMachine.setModeZoom(); + this.frame.setModeZoom(); + } + + public GaussianNumberPlane getGaussianNumberPlane() { + return gaussianNumberPlane; + } + + public KochSnowflakeTab 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; + } + } +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/KochSnowflakeTab.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/KochSnowflakeTab.java new file mode 100644 index 00000000..5669e193 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/KochSnowflakeTab.java @@ -0,0 +1,147 @@ +package org.woehlke.computer.kurzweil.tabs.kochsnowflake; + +import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties; +import org.woehlke.computer.kurzweil.tabs.kochsnowflake.ui.PanelButtons; +import org.woehlke.computer.kurzweil.commons.ui.PanelCopyright; +import org.woehlke.computer.kurzweil.commons.ui.PanelSubtitle; +import org.woehlke.computer.kurzweil.commons.model.turing.Point; + +import javax.accessibility.Accessible; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.image.ImageObserver; +import java.io.Serializable; + +/** + * (C) 2006 - 2013 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * Date: 04.02.2006 + * Time: 18:47:46 + */ +public class KochSnowflakeTab extends JFrame implements ImageObserver, + MenuContainer, + Serializable, + Accessible, + WindowListener, + MouseListener { + + private volatile KochSnowflakeController mandelbrotController; + private volatile KochSnowflakeCanvas canvas; + private volatile KochSnowflakeModel mandelbrotModel; + private volatile Rectangle rectangleBounds; + private volatile Dimension dimensionSize; + + public KochSnowflakeTab(ComputerKurzweilProperties properties) { + super(properties.getWator().getView().getTitle()); + this.mandelbrotModel = new KochSnowflakeModel(properties,this); + BoxLayout layout = new BoxLayout(rootPane, BoxLayout.PAGE_AXIS); + this.canvas = new KochSnowflakeCanvas(mandelbrotModel); + this.mandelbrotController = new KochSnowflakeController(mandelbrotModel, this); + PanelButtons panelButtons = new PanelButtons(this.mandelbrotModel); + PanelSubtitle panelSubtitle = new PanelSubtitle(properties.getWator().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(); + setModeSwitch(); + this.mandelbrotController.start(); + } + + public void windowOpened(WindowEvent e) { + showMe(); + } + + public void windowClosing(WindowEvent e) { + this.mandelbrotController.exit(); + } + + public void windowClosed(WindowEvent e) { + this.mandelbrotController.exit(); + } + + public void windowIconified(WindowEvent e) {} + + public void windowDeiconified(WindowEvent e) { + showMe(); + } + + public void windowActivated(WindowEvent e) { + showMe(); + } + + public void windowDeactivated(WindowEvent e) {} + + + @Override + public void mouseClicked(MouseEvent e) { + Point c = new Point(e.getX(), e.getY()); + this.mandelbrotModel.click(c); + showMe(); + } + + @Override + public void mousePressed(MouseEvent e) {} + + @Override + public void mouseReleased(MouseEvent e) {} + + @Override + public void mouseEntered(MouseEvent e) {} + + @Override + public void mouseExited(MouseEvent e) {} + + public void showMeInit() { + pack(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + double width = this.rootPane.getWidth(); + double height = this.canvas.getHeight() + 180; + double startX = (screenSize.getWidth() - width) / 2d; + double startY = (screenSize.getHeight() - height) / 2d; + int myheight = Double.valueOf(height).intValue(); + int mywidth = Double.valueOf(width).intValue(); + int mystartX = Double.valueOf(startX).intValue(); + int mystartY = Double.valueOf(startY).intValue(); + this.rectangleBounds = new Rectangle(mystartX, mystartY, mywidth, myheight); + this.dimensionSize = new Dimension(mywidth, myheight); + this.setBounds(this.rectangleBounds); + this.setSize(this.dimensionSize); + this.setPreferredSize(this.dimensionSize); + this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + setVisible(true); + toFront(); + } + + /** + * TODO write doc. + */ + public void showMe() { + this.pack(); + this.setBounds(this.rectangleBounds); + this.setSize(this.dimensionSize); + this.setPreferredSize(this.dimensionSize); + this.setVisible(true); + this.toFront(); + } + + public void setModeSwitch() { + canvas.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + } + + public void setModeZoom() { + canvas.setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + public KochSnowflakeCanvas getCanvas() { + return canvas; + } +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/model/KochSnowflakeTabState.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/model/KochSnowflakeTabState.java new file mode 100644 index 00000000..6c440c4d --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/model/KochSnowflakeTabState.java @@ -0,0 +1,15 @@ +package org.woehlke.computer.kurzweil.tabs.kochsnowflake.model; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 23.08.15. + */ +public enum KochSnowflakeTabState { + MANDELBROT, + MANDELBROT_ZOOM +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/model/KochSnowflakeTabStateMachine.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/model/KochSnowflakeTabStateMachine.java new file mode 100644 index 00000000..0a5bd4e3 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/model/KochSnowflakeTabStateMachine.java @@ -0,0 +1,78 @@ +package org.woehlke.computer.kurzweil.tabs.kochsnowflake.model; + + +import static org.woehlke.computer.kurzweil.tabs.kochsnowflake.model.KochSnowflakeTabState.*; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class KochSnowflakeTabStateMachine { + + private volatile KochSnowflakeTabState applicationState; + + public KochSnowflakeTabStateMachine() { + this.applicationState = KochSnowflakeTabState.MANDELBROT; + } + + public void click(){ + KochSnowflakeTabState nextApplicationState = null; + switch (applicationState){ + case MANDELBROT: + nextApplicationState = MANDELBROT_ZOOM; + break; + case MANDELBROT_ZOOM: + nextApplicationState = MANDELBROT; + break; + } + this.setApplicationState(nextApplicationState); + } + + public void setModeSwitch() { + KochSnowflakeTabState 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() { + KochSnowflakeTabState 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 KochSnowflakeTabState getApplicationState() { + return applicationState; + } + + public void setApplicationState(KochSnowflakeTabState applicationState) { + this.applicationState = applicationState; + } + +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/ui/PanelButtons.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/ui/PanelButtons.java new file mode 100644 index 00000000..c3576371 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/ui/PanelButtons.java @@ -0,0 +1,69 @@ +package org.woehlke.computer.kurzweil.tabs.kochsnowflake.ui; + +import org.woehlke.computer.kurzweil.tabs.kochsnowflake.KochSnowflakeModel; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class PanelButtons extends JPanel implements ActionListener { + + //private volatile JRadioButton radioButtonsSwitch; + //private volatile JRadioButton radioButtonsZoom; + private volatile JButton zoomOut; + //private volatile ButtonGroup radioButtonsGroup; + private volatile KochSnowflakeModel model; + + public PanelButtons(KochSnowflakeModel model) { + this.model = model; + JLabel buttonsLabel = new JLabel(model.getProperties().getWator().getView().getButtonsLabel()); + /* + this.radioButtonsSwitch = new JRadioButton(model.getProperties().getMandelbrot().getView().getButtonsSwitch()); + this.radioButtonsSwitch.setMnemonic(RADIO_BUTTONS_SWITCH.ordinal()); + this.radioButtonsSwitch.setSelected(true); + this.radioButtonsSwitch.addActionListener(this); + this.radioButtonsZoom = new JRadioButton(model.getProperties().getMandelbrot().getView().getButtonsSwitch()); + this.radioButtonsZoom.setMnemonic(RADIO_BUTTONS_ZOOM.ordinal()); + this.radioButtonsZoom.addActionListener(this); + this.radioButtonsGroup = new ButtonGroup(); + this.radioButtonsGroup.add(radioButtonsSwitch); + this.radioButtonsGroup.add(radioButtonsZoom); + */ + this.zoomOut = new JButton(model.getProperties().getWator().getView().getButtonsZoomOut()); + this.zoomOut.addActionListener(this); + FlowLayout layout = new FlowLayout(); + this.setLayout(layout); + this.add(buttonsLabel); + //this.add(radioButtonsSwitch); + //this.add(radioButtonsZoom); + this.add(zoomOut); + } + + /** + * TODO write doc. + */ + @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){ + this.model.zoomOut(); + this.model.getFrame().getCanvas().repaint(); + } + } +} diff --git a/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/canvas/RradioButtons.java b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/ui/RadioButtons.java similarity index 75% rename from single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/canvas/RradioButtons.java rename to single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/ui/RadioButtons.java index b88ef3f2..e1f9d01e 100644 --- a/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/canvas/RradioButtons.java +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/java/org/woehlke/computer/kurzweil/tabs/kochsnowflake/ui/RadioButtons.java @@ -1,4 +1,4 @@ -package org.woehlke.computer.kurzweil.tabs.mandelbrot2julia.canvas; +package org.woehlke.computer.kurzweil.tabs.kochsnowflake.ui; /** * Mandelbrot Set drawn by a Turing Machine. @@ -9,7 +9,7 @@ * * Created by tw on 16.12.2019. */ -public enum RradioButtons { +public enum RadioButtons { RADIO_BUTTONS_SWITCH, RADIO_BUTTONS_ZOOM } diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/application.properties b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/application.properties new file mode 100644 index 00000000..81af6f26 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/application.properties @@ -0,0 +1,9 @@ +org.woehlke.computer.kurzweil.mandelbrot.config.title=Mandelbrot Set +org.woehlke.computer.kurzweil.mandelbrot.config.subtitle=Mandelbrot Set drawn by a Turing Machine +org.woehlke.computer.kurzweil.mandelbrot.config.copyright=(c) 2019 Thomas Woehlke +org.woehlke.computer.kurzweil.mandelbrot.config.width=800 +org.woehlke.computer.kurzweil.mandelbrot.config.height=585 +org.woehlke.computer.kurzweil.mandelbrot.config.buttons.label=Choose Mode +org.woehlke.computer.kurzweil.mandelbrot.config.buttons.switch=Mandelbrot Set <=> Julia Set +org.woehlke.computer.kurzweil.mandelbrot.config.buttons.zoom=Zoom +org.woehlke.computer.kurzweil.mandelbrot.config.buttons.zoomout=Zoom Out diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/application.yml b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/application.yml new file mode 100644 index 00000000..22e87914 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/application.yml @@ -0,0 +1,184 @@ +allinone: + lattice: + width: 800 + height: 585 + view: + title: 'Computer Kurzweil' + subtitle: 'Scientific Imfotainment' + copyright: '(c) 2020 Thomas Woehlke' + borderPaddingX: 5 + borderPaddingY: 5 + titleHeight: 60 + startStopp: 'Start / Stop' + start: 'Start' + stop: 'Stop' + info: 'Info' +mandelbrot: + view: + title: 'Mandelbrot Set' + subtitle: 'Fractal Mandelbrot Set drawn by a Turing Machine' + buttonsZoom: 'Zoom In' + buttonsZoomOut: 'Zoom Out' + buttonsSwitch: 'Mandelbrot Set <-> Julia Set' + buttonsZoomLabel: 'Zoom' + buttonsLabel: 'Choose Mouse Click Mode' + control: + threadSleepTime: 50 +simulatedevolution: + view: + title: 'Simulated Evolution' + subtitle: 'Artificial Life Simulation of Bacteria Motion depending on DNA' + control: + threadSleepTime: 100 + exitStatus: 0 + queueMaxLength: 1000 + cellConf: + fatMax: 2000 + fatHungerMax: 1000 + fatMinimumForSex: 800 + fatAtBirth: 500 + fatPerFood: 25 + ageOfAdulthood: 200 + ageOld: 800 + ageMax: 1000 + population: + initialPopulation: 20 + panelPopulationStatistics: 'Population' + panelLifeCycleStatistics: 'LifeCycle' + youngCellsLabel: 'young' + youngAndFatCellsLabel: 'young and Fat' + fullAgeCellsLabel: 'full Age' + hungryCellsLabel: 'hungry' + oldCellsLabel: 'old' + populationLabel: 'population' + generationOldestLabel: 'oldest Generation' + generationYoungestLabel: 'youngest Generation' + food: + foodPerDay: 20 + foodPerDayFieldColumns: 3 + foodPerDayLabel: 'Food per Day:' + foodPerDayBorderLabel: 'Food per Day:' + buttonFoodPerDayIncrease: '+' + buttonFoodPerDayDecrease: '-' + panelFood: 'Food' + gardenOfEden: + panelGardenOfEden: 'Garden of Eden' + gardenOfEdenEnabled: true + gardenOfEdenEnabledString: 'enabled' + gardenOfEdenEnabledToggleButton: 'Change' + foodPerDay: 80 + gardenOfEdenLatticeDivisor: 5 + gardenOfEdenLatticeDivisorPadding: 2 +cca: + view: + title: 'Cyclic Cellular Automaton' + subtitle: 'Cyclic Cellular Automaton' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 100 +randomwalk: + view: + title: 'Random Walk' + subtitle: 'Brownian Motion by Fractal Random Walk' + control: + threadSleepTime: 100 +dla: + view: + title: 'Diffusion Limited Aggregation' + subtitle: 'Fractal Random Walk due to Brownian Motion Cluster' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +kochsnowflake: + view: + title: 'Koch Snowflake' + subtitle: 'Fractal Koch Snowflake' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +samegame: + view: + title: 'Same Game' + subtitle: 'Play the Same Game' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +sierpinskitriangle: + view: + title: 'Sierpinski Triangle' + subtitle: 'Fractal Sierpinski Triangle' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +tetris: + view: + title: 'Tetris' + subtitle: 'Play Tetris' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +turmite: + view: + title: 'Turmite' + subtitle: 'Termites as Turing Machines with 2D Tape' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +wator: + view: + title: 'WaTor' + subtitle: 'Population Dynamics on Planet Water Torus' + buttonsZoom: 'Zoom In' + buttonsZoomOut: 'Zoom Out' + buttonsSwitch: 'Mandelbrot Set <-> Julia Set' + buttonsZoomLabel: 'Zoom' + buttonsLabel: 'Choose Mouse Click Mode' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +gameoflive: + view: + title: 'Conways Game of Life' + subtitle: 'Conways Game of Life Cellular Automaton' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/julia01.png b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/julia01.png new file mode 100644 index 00000000..804b50a0 Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/julia01.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/julia02.png b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/julia02.png new file mode 100644 index 00000000..ab30d135 Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/julia02.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/phasenraum_logo.gif b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/phasenraum_logo.gif new file mode 100644 index 00000000..3615d230 Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/phasenraum_logo.gif differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/screen01.png b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/screen01.png new file mode 100644 index 00000000..d4a4193c Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/screen01.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/screen02.png b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/screen02.png new file mode 100644 index 00000000..2a31ba74 Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/screen02.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/screen03.png b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/screen03.png new file mode 100644 index 00000000..a1fc854a Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/main/resources/img/screen03.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/markdown/About.md b/single-apps/insourcing/insourcing-kochsnowflake/src/site/markdown/About.md new file mode 100644 index 00000000..20b9b980 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/site/markdown/About.md @@ -0,0 +1,32 @@ +# Simulated Evolution +**Artificial Life Simulation of Bacteria Motion depending on DNA** + +## Abstract +Green food appears in a simulatedEvolutionModel with red moving cells. These cells eat the food if it is on their position. +Movement of the cells depends on random and their DNA. A fit cell moves around and eats enough to reproduce. +Reproduction is done by splitting the cell and randomly changing the DNA of the two new Cells. +If a cell doesn't eat enough, it will first stand still and after a while it dies. + + +## Run the Desktop Application +``` +git clone https://github.com/Computer-Kurzweil/simulated-evolution.git +cd simulated-evolution +mvnw +``` + +## Screenshot +### Early Screen +![Early Screen](src/main/resources/img/screen1.png) +### Later Screen +![Later Screen](src/main/resources/img/screen2.png) + + +## UML Class Model +![UML Class Model](src/main/resources/img/Class_Model.jpg) + +## Github Repository +[https://github.com/Computer-Kurzweil/simulated-evolution](https://github.com/Computer-Kurzweil/simulated-evolution) + +## Blog Article +[http://thomas-woehlke.blogspot.de/2016/01/simulated-evolution-artificial-life-and.html](http://thomas-woehlke.blogspot.de/2016/01/simulated-evolution-artificial-life-and.html) diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/Class_Model.jpg b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/Class_Model.jpg new file mode 100644 index 00000000..827d7bba Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/Class_Model.jpg differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/black.png b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/black.png new file mode 100644 index 00000000..6516a94c Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/black.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/blue.png b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/blue.png new file mode 100644 index 00000000..500b2779 Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/blue.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/dark_gray.png b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/dark_gray.png new file mode 100644 index 00000000..f25c5c9f Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/dark_gray.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/green.png b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/green.png new file mode 100644 index 00000000..a894e98c Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/green.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/light_gray.png b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/light_gray.png new file mode 100644 index 00000000..a9d04709 Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/light_gray.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/phasenraum_logo.gif b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/phasenraum_logo.gif new file mode 100644 index 00000000..3615d230 Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/phasenraum_logo.gif differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/red.png b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/red.png new file mode 100644 index 00000000..7e9a56cd Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/red.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/screen.png b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/screen.png new file mode 100644 index 00000000..fc4c797d Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/screen.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/screen1.png b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/screen1.png new file mode 100644 index 00000000..943cf1ba Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/screen1.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/screen2.png b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/screen2.png new file mode 100644 index 00000000..9ec3a2ed Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/screen2.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/yellow.png b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/yellow.png new file mode 100644 index 00000000..891de604 Binary files /dev/null and b/single-apps/insourcing/insourcing-kochsnowflake/src/site/resources/img/yellow.png differ diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/site/site.xml b/single-apps/insourcing/insourcing-kochsnowflake/src/site/site.xml new file mode 100644 index 00000000..3860ce74 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/site/site.xml @@ -0,0 +1,41 @@ + + + + org.apache.maven.skins + maven-default-skin + 1.3 + + + Simulated Evolution + /img/phasenraum_logo.gif + http://woehlke.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/ComplexNumberTest.java b/single-apps/insourcing/insourcing-kochsnowflake/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/ComplexNumberTest.java new file mode 100644 index 00000000..5d38f60c --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/ComplexNumberTest.java @@ -0,0 +1,75 @@ +package org.woehlke.computer.kurzweil.tabs.mandelbrot2julia; + + +import org.junit.jupiter.api.Test; +import org.woehlke.computer.kurzweil.commons.model.fractal.ComplexNumber; + +import java.util.logging.Logger; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * Created by tw on 24.08.15. + */ +public class ComplexNumberTest { + + public static Logger log = Logger.getLogger(ComplexNumberTest.class.getName()); + + @Test + public void computeMandelbrotTest1(){ + log.info("computeMandelbrotTest1 start"); + ComplexNumber complexNumber1 = new ComplexNumber(); + int iterations = complexNumber1.computeMandelbrotSet(); + log.info("computeMandelbrotTest1 iterations : "+ iterations); + assertTrue(complexNumber1.isInMandelbrotSet()); + assertNotEquals(ComplexNumber.MAX_ITERATIONS, iterations); + assertTrue(0 == iterations); + log.info("computeMandelbrotTest1 done"); + } + + @Test + public void computeMandelbrotTest2(){ + log.info("computeMandelbrotTest2 start"); + ComplexNumber complexNumber2 = new ComplexNumber(1.0d,1.2d); + int iterations = complexNumber2.computeMandelbrotSet(); + log.info("computeMandelbrotTest2 iterations : "+ iterations); + assertFalse(complexNumber2.isInMandelbrotSet()); + assertNotEquals(iterations, ComplexNumber.MAX_ITERATIONS); + assertTrue(iterations < ComplexNumber.MAX_ITERATIONS); + assertTrue(2 == iterations); + log.info("computeMandelbrotTest2 done"); + } + + @Test + public void computeJuliaTest1(){ + log.info("computeJuliaTest1 start"); + ComplexNumber z = new ComplexNumber(0.1d,0.2d); + ComplexNumber c = new ComplexNumber(0.2d,0.1d); + int iterations = z.computeJuliaSet(c); + log.info("computeJuliaTest1 iterations : "+ iterations); + boolean isInJuliaSet = z.isInJuliaSet(); + assertTrue(isInJuliaSet); + assertNotEquals(ComplexNumber.MAX_ITERATIONS, iterations); + assertTrue(iterations < ComplexNumber.MAX_ITERATIONS); + assertTrue(0 == iterations); + log.info("computeJuliaTest1 done"); + } + + @Test + public void computeJuliaTest2(){ + log.info("computeJuliaTest2 start"); + ComplexNumber z = new ComplexNumber(0.1d,0.2d); + ComplexNumber c = new ComplexNumber(1.0d,1.1d); + int iterations = z.computeJuliaSet(c); + log.info("computeJuliaTest2 iterations :"+ iterations); + boolean isInJuliaSet = z.isInJuliaSet(); + assertFalse(isInJuliaSet); + assertNotEquals(ComplexNumber.MAX_ITERATIONS, iterations); + assertTrue(iterations < ComplexNumber.MAX_ITERATIONS); + assertTrue(2 == iterations); + log.info("computeJuliaTest2 done"); + } +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringPositionsTest.java b/single-apps/insourcing/insourcing-kochsnowflake/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringPositionsTest.java new file mode 100644 index 00000000..37ab4392 --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringPositionsTest.java @@ -0,0 +1,46 @@ +package org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.model.turing; + + +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +public class TuringPositionsTest { + + public static Logger log = Logger.getLogger(TuringPositionsTest.class.getName()); + + @Test + public void startTest() { + log.info("startTest start"); + } + + @Test + public void markFirstSetPositionTest(){ + log.info("markFirstSetPositionTest start"); + + } + + @Test + public void goForwardTest() { + log.info("goForwardTest start"); + + } + + @Test + public void turnRightTest() { + log.info("turnRightTest start"); + + } + + @Test + public void turnLeftTest() { + log.info("turnLeftTest start"); + + } + + @Test + public void isFinishedWalkAroundTest() { + log.info("isFinishedWalkAroundTest start"); + + } +} diff --git a/single-apps/insourcing/insourcing-kochsnowflake/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringTuringPhaseStateEnumTest.java b/single-apps/insourcing/insourcing-kochsnowflake/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringTuringPhaseStateEnumTest.java new file mode 100644 index 00000000..2f2cadcc --- /dev/null +++ b/single-apps/insourcing/insourcing-kochsnowflake/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringTuringPhaseStateEnumTest.java @@ -0,0 +1,62 @@ +package org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.model.turing; + + +import org.junit.jupiter.api.Test; +import org.woehlke.computer.kurzweil.commons.model.turing.MandelbrotTuringPhaseState; + +import java.util.logging.Logger; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.woehlke.computer.kurzweil.commons.model.turing.MandelbrotTuringPhase.*; + +public class TuringTuringPhaseStateEnumTest { + + public static Logger log = Logger.getLogger(TuringPositionsTest.class.getName()); + private MandelbrotTuringPhaseState turingPhaseState = new MandelbrotTuringPhaseState(); + + @Test + public void startTest(){ + log.info("startTest start"); + turingPhaseState = new MandelbrotTuringPhaseState(); + assertEquals(turingPhaseState.getTuringTuringPhase(),SEARCH_THE_SET); + turingPhaseState.start(); + assertEquals(turingPhaseState.getTuringTuringPhase(),SEARCH_THE_SET); + log.info("startTest done"); + } + + @Test + public void finishGoToSetTest(){ + log.info("finishGoToSetTest start"); + turingPhaseState = new MandelbrotTuringPhaseState(); + turingPhaseState.start(); + assertEquals(turingPhaseState.getTuringTuringPhase(),SEARCH_THE_SET); + turingPhaseState.finishSearchTheSet(); + assertEquals(turingPhaseState.getTuringTuringPhase(),WALK_AROUND_THE_SET); + log.info("finishGoToSetTest done"); + } + + @Test + public void finishWalkAroundTest() { + log.info("finishWalkAroundTest start"); + turingPhaseState = new MandelbrotTuringPhaseState(); + turingPhaseState.start(); + turingPhaseState.finishSearchTheSet(); + assertEquals(turingPhaseState.getTuringTuringPhase(),WALK_AROUND_THE_SET); + turingPhaseState.finishWalkAround(); + assertEquals(turingPhaseState.getTuringTuringPhase(), FILL_THE_OUTSIDE_WITH_COLOR); + log.info("finishWalkAroundTest done"); + } + + @Test + public void finishFillTheOutsideWithColorsTest() { + log.info("finishFillTheOutsideWithColorsTest start"); + turingPhaseState = new MandelbrotTuringPhaseState(); + turingPhaseState.start(); + turingPhaseState.finishSearchTheSet(); + turingPhaseState.finishWalkAround(); + assertEquals(turingPhaseState.getTuringTuringPhase(), FILL_THE_OUTSIDE_WITH_COLOR); + turingPhaseState.finishFillTheOutsideWithColors(); + assertEquals(turingPhaseState.getTuringTuringPhase(), FINISHED); + log.info("finishFillTheOutsideWithColorsTest done"); + } +} diff --git a/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/canvas/PanelCopyright.java b/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java similarity index 87% rename from single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/canvas/PanelCopyright.java rename to single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java index 08cd6faf..4fae16fd 100644 --- a/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/canvas/PanelCopyright.java +++ b/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java @@ -1,4 +1,4 @@ -package org.woehlke.computer.kurzweil.tabs.mandelbrot2julia.canvas; +package org.woehlke.computer.kurzweil.commons.ui; import javax.swing.*; import java.awt.*; diff --git a/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/canvas/PanelSubtitle.java b/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java similarity index 87% rename from single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/canvas/PanelSubtitle.java rename to single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java index 2937d110..fb044e95 100644 --- a/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/canvas/PanelSubtitle.java +++ b/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java @@ -1,4 +1,4 @@ -package org.woehlke.computer.kurzweil.tabs.mandelbrot2julia.canvas; +package org.woehlke.computer.kurzweil.commons.ui; import javax.swing.*; import java.awt.*; diff --git a/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/commons/ui/RadioButtons.java b/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/commons/ui/RadioButtons.java new file mode 100644 index 00000000..548ff108 --- /dev/null +++ b/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/commons/ui/RadioButtons.java @@ -0,0 +1,15 @@ +package org.woehlke.computer.kurzweil.commons.ui; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public enum RadioButtons { + RADIO_BUTTONS_SWITCH, + RADIO_BUTTONS_ZOOM +} diff --git a/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/Mandelbrot2JuliaTab.java b/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/Mandelbrot2JuliaTab.java index 3e58fd0a..1beca023 100644 --- a/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/Mandelbrot2JuliaTab.java +++ b/single-apps/insourcing/insourcing-mandelbrot-julia/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/Mandelbrot2JuliaTab.java @@ -1,8 +1,8 @@ package org.woehlke.computer.kurzweil.tabs.mandelbrot2julia; import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties; -import org.woehlke.computer.kurzweil.tabs.mandelbrot2julia.canvas.PanelCopyright; -import org.woehlke.computer.kurzweil.tabs.mandelbrot2julia.canvas.PanelSubtitle; +import org.woehlke.computer.kurzweil.commons.ui.PanelCopyright; +import org.woehlke.computer.kurzweil.commons.ui.PanelSubtitle; import org.woehlke.computer.kurzweil.commons.model.turing.Point; import javax.accessibility.Accessible; diff --git a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java new file mode 100644 index 00000000..4fae16fd --- /dev/null +++ b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java @@ -0,0 +1,22 @@ +package org.woehlke.computer.kurzweil.commons.ui; + +import javax.swing.*; +import java.awt.*; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class PanelCopyright extends JPanel { + + public PanelCopyright(String subtitle) { + this.setLayout(new FlowLayout()); + this.add(new JLabel(subtitle)); + } + +} diff --git a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java new file mode 100644 index 00000000..fb044e95 --- /dev/null +++ b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java @@ -0,0 +1,22 @@ +package org.woehlke.computer.kurzweil.commons.ui; + +import javax.swing.*; +import java.awt.*; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class PanelSubtitle extends JPanel { + + public PanelSubtitle(String subtitle) { + this.setLayout(new FlowLayout()); + this.add(new JLabel(subtitle)); + } + +} diff --git a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/MandelbrotZoomTab.java b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/MandelbrotZoomTab.java index 32fec86b..bac3bf67 100644 --- a/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/MandelbrotZoomTab.java +++ b/single-apps/insourcing/insourcing-mandelbrot-zoom/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/MandelbrotZoomTab.java @@ -2,8 +2,8 @@ import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties; import org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.ui.PanelButtons; -import org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.ui.PanelCopyright; -import org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.ui.PanelSubtitle; +import org.woehlke.computer.kurzweil.commons.ui.PanelCopyright; +import org.woehlke.computer.kurzweil.commons.ui.PanelSubtitle; import org.woehlke.computer.kurzweil.commons.model.turing.Point; import javax.accessibility.Accessible; diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/README.md b/single-apps/insourcing/insourcing-sierpinskitriangle/README.md new file mode 100644 index 00000000..8463bdda --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/README.md @@ -0,0 +1,56 @@ +# Wator + +**Wator Slogan** + +## Abstract: Wator + + +## More +* [https://en.wikipedia.org/wiki/Mandelbrot_set](https://en.wikipedia.org/wiki/Mandelbrot_set) +* [https://en.wikipedia.org/wiki/Julia_set](https://en.wikipedia.org/wiki/Julia_set) +* [https://en.wikipedia.org/wiki/Turing_machine](https://en.wikipedia.org/wiki/Turing_machine) + +## Screenshots + +### Running around the Edge of the Mandelbrot Set + +![Running around the Edge of the Mandelbrot Set](src/main/resources/img/screen01.png) + +### Running around the Edge of the Mandelbrot Set + +![Running around the Edge of the Mandelbrot Set](src/main/resources/img/screen02.png) + +### Computing the Area outside the Mandelbrot Set + +![Computing the Area outside the Mandelbrot Set](src/main/resources/img/screen03.png) + +### Clicked somewhere on the Edge of Mandelbrot Set: The Julia Set + +![Clicked somewhere on the Edge of Mandelbrot Set: The Julia Set](src/main/resources/img/julia01.png) + +### Clicked on another Point on the Edge of Mandelbrot Set: The Julia Set + +![Clicked on another Point on the Edge of Mandelbrot Set: The Julia Set](src/main/resources/img/julia02.png) + + +### Git Repository +* [https://github.com/thomaswoehlke/mandelbrot](https://github.com/thomaswoehlke/mandelbrot.git) + + +### Gradle Wrapper +* [https://docs.gradle.org/current/userguide/gradle_wrapper.html](https://docs.gradle.org/current/userguide/gradle_wrapper.html) + +### Run the Desktop Application +``` +git clone https://github.com/thomaswoehlke/mandelbrot.git +cd mandelbrot +./gradlew clean shadowJar runShadow +``` + +### Run the Applet Test +``` +git clone https://github.com/thomaswoehlke/mandelbrot.git +cd mandelbrot +TODO: xxx +``` + diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/pom.xml b/single-apps/insourcing/insourcing-sierpinskitriangle/pom.xml new file mode 100644 index 00000000..d4efd354 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/pom.xml @@ -0,0 +1,127 @@ + + + 4.0.0 + + + org.woehlke.computer.kurzweil + insourcing + 2.2.8-SNAPSHOT + .. + + + insourcing-sierpinskitriangle + jar + + single-apps :: insourcing :: Sierpinski Triangle + sierpinskitriangle + + + org.woehlke.computer.kurzweil.SierpinskiTriangleApplication + + + + + org.apache.logging.log4j + log4j-slf4j-impl + + + org.apache.logging.log4j + log4j-api + + + org.apache.logging.log4j + log4j-jcl + + + org.apache.logging.log4j + log4j-core + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.dataformat + jackson-dataformat-properties + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + + + com.fasterxml.jackson.dataformat + jackson-dataformat-ion + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-core + + + org.apache.commons + commons-lang3 + + + org.yaml + snakeyaml + + + com.google.guava + guava + + + javax.validation + validation-api + + + + + ${project.artifactId} + clean dependency:tree install exec:java + + + org.codehaus.mojo + exec-maven-plugin + + + + java + + + + + org.woehlke.computer.kurzweil.SierpinskiTriangleApplication + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + org.woehlke.computer.kurzweil.SierpinskiTriangleApplication + + + + + + org.apache.maven.plugins + maven-release-plugin + + clean + true + + + + + + diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/run.cmd b/single-apps/insourcing/insourcing-sierpinskitriangle/run.cmd new file mode 100644 index 00000000..726b9db4 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/run.cmd @@ -0,0 +1,2 @@ +cmd /c ..\..\mvnw -e clean install site +cmd /c ..\..\mvnw diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/run.sh b/single-apps/insourcing/insourcing-sierpinskitriangle/run.sh new file mode 100755 index 00000000..5d1cd68e --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/run.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + + +function site() { + ../../../mvnw -e site site:deploy +} + +function run() { + ../../../mvnw +} + +function main() { + #site + run +} + +main diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/SierpinskiTriangleApplication.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/SierpinskiTriangleApplication.java new file mode 100644 index 00000000..cd4d1618 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/SierpinskiTriangleApplication.java @@ -0,0 +1,33 @@ +package org.woehlke.computer.kurzweil; + +import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties; +import org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.SierpinskiTriangleTab; + +import java.io.File; +import java.net.URL; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + */ +public class SierpinskiTriangleApplication { + + private SierpinskiTriangleApplication() { + String configFileName = "/application.yml"; + URL fileUrl = getClass().getResource(configFileName); + File configFile = new File(fileUrl.getFile()); + ComputerKurzweilProperties properties = ComputerKurzweilProperties.propertiesFactory(configFile); + SierpinskiTriangleTab frame = new SierpinskiTriangleTab(properties); + } + + /** + * Starting the Application. + * @param args CLI Parameter + */ + public static void main(String[] args) { + SierpinskiTriangleApplication application = new SierpinskiTriangleApplication(); + } +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/application/ComputerKurzweilProperties.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/application/ComputerKurzweilProperties.java new file mode 100644 index 00000000..2c2cda7f --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/application/ComputerKurzweilProperties.java @@ -0,0 +1,600 @@ +package org.woehlke.computer.kurzweil.application; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import lombok.*; +import lombok.extern.log4j.Log4j2; +import org.woehlke.computer.kurzweil.tabs.TabType; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +@Log4j2 +@ToString +@EqualsAndHashCode +@NoArgsConstructor +@AllArgsConstructor +@Valid +////@Validated +public class ComputerKurzweilProperties { + + @Valid @Getter @Setter public Allinone allinone = new Allinone(); + @Valid @Getter @Setter public Mandelbrot mandelbrot = new Mandelbrot(); + @Valid @Getter @Setter public MandelbrotZoom mandelbrotZoom = new MandelbrotZoom(); + @Valid @Getter @Setter public SimulatedEvolution simulatedevolution = new SimulatedEvolution(); + @Valid @Getter @Setter public Cca cca = new Cca(); + @Valid @Getter @Setter public WienerProcess randomwalk = new WienerProcess(); + @Valid @Getter @Setter public Dla dla = new Dla(); + @Valid @Getter @Setter public Kochsnowflake kochsnowflake = new Kochsnowflake(); + @Valid @Getter @Setter public Samegame samegame = new Samegame(); + @Valid @Getter @Setter public Sierpinskitriangle sierpinskitriangle = new Sierpinskitriangle(); + @Valid @Getter @Setter public Tetris tetris = new Tetris(); + @Valid @Getter @Setter public Turmite turmite = new Turmite(); + @Valid @Getter @Setter public Wator wator = new Wator(); + @Valid @Getter @Setter public Gameoflive gameoflive = new Gameoflive(); + + public static ComputerKurzweilProperties propertiesFactory(File conf){ + log.info("propertiesFactory"); + log.info("propertiesFactory conf: "+conf.getAbsolutePath()); + ComputerKurzweilProperties properties; + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + try { + InputStream input = new FileInputStream(conf); + properties = mapper.readValue(input, ComputerKurzweilProperties.class); + log.info(properties.toString()); + } catch (Exception e) { + e.printStackTrace(); + properties = new ComputerKurzweilProperties(); + } + log.info("propertiesFactory done"); + return properties; + } + + public static ComputerKurzweilProperties propertiesFactory(String conf, String jar){ + log.info("propertiesFactory"); + log.info("propertiesFactory conf: "+conf); + log.info("propertiesFactory jar: "+jar); + ComputerKurzweilProperties properties; + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + try { + JarFile jarFile = new JarFile(jar); + JarEntry entry = jarFile.getJarEntry(conf); + InputStream input = jarFile.getInputStream(entry); + properties = mapper.readValue(input, ComputerKurzweilProperties.class); + log.info(properties.toString()); + } catch (Exception e) { + e.printStackTrace(); + properties = new ComputerKurzweilProperties(); + } + log.info("propertiesFactory done"); + return properties; + } + + public String getSubtitle(TabType tabType){ + switch (tabType){ + case CYCLIC_CELLULAR_AUTOMATON: + return this.getCca().getView().getSubtitle(); + case DIFFUSION_LIMITED_AGGREGATION: + return this.getDla().getView().getSubtitle(); + case SIMULATED_EVOLUTION: + return this.getSimulatedevolution().getView().getSubtitle(); + case MANDELBROT_SET: + return this.getMandelbrot().getView().getSubtitle(); + case RANDOM_WALK_WIENER_PROCESS: + return this.getRandomwalk().getView().getSubtitle(); + case KOCH_SNOWFLAKE: + return this.getKochsnowflake().getView().getSubtitle(); + case SAME_GAME: + return this.getSamegame().getView().getSubtitle(); + case SIERPINSKI_TRIANGLE: + return this.getSierpinskitriangle().getView().getSubtitle(); + case TETRIS: + return this.getTetris().getView().getSubtitle(); + case TURMITE: + return this.getTurmite().getView().getSubtitle(); + case WATOR: + return this.getWator().getView().getSubtitle(); + case CONWAYS_GAME_OF_LIFE: + return this.getGameoflive().getView().getSubtitle(); + default: + return "UNDEFINED"; + } + } + + public String getTitle(TabType tabType){ + switch (tabType){ + case CYCLIC_CELLULAR_AUTOMATON: + return this.getCca().getView().getTitle(); + case DIFFUSION_LIMITED_AGGREGATION: + return this.getDla().getView().getTitle(); + case SIMULATED_EVOLUTION: + return this.getSimulatedevolution().getView().getTitle(); + case MANDELBROT_SET: + return this.getMandelbrot().getView().getTitle(); + case RANDOM_WALK_WIENER_PROCESS: + return this.getRandomwalk().getView().getTitle(); + case KOCH_SNOWFLAKE: + return this.getKochsnowflake().getView().getTitle(); + case SAME_GAME: + return this.getSamegame().getView().getTitle(); + case SIERPINSKI_TRIANGLE: + return this.getSierpinskitriangle().getView().getTitle(); + case TETRIS: + return this.getTetris().getView().getTitle(); + case TURMITE: + return this.getTurmite().getView().getTitle(); + case WATOR: + return this.getWator().getView().getTitle(); + case CONWAYS_GAME_OF_LIFE: + return this.getGameoflive().getView().getTitle(); + default: + return "UNDEFINED"; + } + } + + ////@Validated + @ToString + public static class Allinone { + + @Valid @Getter @Setter public Lattice lattice = new Lattice(); + @Valid @Getter @Setter public View view = new View(); + + ////@Validated + @ToString + public static class Lattice { + @NotNull @Getter @Setter private Integer width; + @NotNull @Getter @Setter private Integer height; + } + + ////@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + @NotBlank @Getter @Setter private String copyright; + @NotNull @Getter @Setter private Integer borderPaddingX; + @NotNull @Getter @Setter private Integer borderPaddingY; + @NotNull @Getter @Setter private Integer titleHeight; + @NotBlank @Getter @Setter private String startStopp; + @NotBlank @Getter @Setter private String start; + @NotBlank @Getter @Setter private String stop; + @NotBlank @Getter @Setter private String info; + } + } + + ////@Validated + @ToString + public static class Mandelbrot { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + ////@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + @NotBlank @Getter @Setter private String buttonsZoom; + @NotBlank @Getter @Setter private String buttonsZoomOut; + @NotBlank @Getter @Setter private String buttonsSwitch; + @NotBlank @Getter @Setter private String buttonsZoomLabel; + @NotBlank @Getter @Setter private String buttonsLabel; + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + } + } + + ////@Validated + @ToString + public static class MandelbrotZoom { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + ////@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + @NotBlank @Getter @Setter private String buttonsZoom; + @NotBlank @Getter @Setter private String buttonsZoomOut; + @NotBlank @Getter @Setter private String buttonsSwitch; + @NotBlank @Getter @Setter private String buttonsZoomLabel; + @NotBlank @Getter @Setter private String buttonsLabel; + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + } + } + + ////@Validated + @ToString + public static class SimulatedEvolution { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + @Valid @Getter @Setter public CellConf cellConf = new CellConf(); + @Valid @Getter @Setter public Population population = new Population(); + @Valid @Getter @Setter public Food food = new Food(); + @Valid @Getter @Setter public GardenOfEden gardenOfEden = new GardenOfEden(); + + ////@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer exitStatus; + @NotNull @Getter @Setter private Integer queueMaxLength; + } + + ////@Validated + @ToString + public static class CellConf { + @NotNull @Getter @Setter private Integer fatMax; + @NotNull @Getter @Setter private Integer fatHungerMax; + @NotNull @Getter @Setter private Integer fatMinimumForSex; + @NotNull @Getter @Setter private Integer fatAtBirth; + @NotNull @Getter @Setter private Integer fatPerFood; + @NotNull @Getter @Setter private Integer ageOfAdulthood; + @NotNull @Getter @Setter private Integer ageOld; + @NotNull @Getter @Setter private Integer ageMax; + } + + ////@Validated + @ToString + public static class Population { + @NotNull @Getter @Setter private Integer initialPopulation; + @NotBlank @Getter @Setter private String panelPopulationStatistics; + @NotBlank @Getter @Setter private String panelLifeCycleStatistics; + @NotBlank @Getter @Setter private String youngCellsLabel; + @NotBlank @Getter @Setter private String youngAndFatCellsLabel; + @NotBlank @Getter @Setter private String fullAgeCellsLabel; + @NotBlank @Getter @Setter private String hungryCellsLabel; + @NotBlank @Getter @Setter private String oldCellsLabel; + @NotBlank @Getter @Setter private String populationLabel; + @NotBlank @Getter @Setter private String generationOldestLabel; + @NotBlank @Getter @Setter private String generationYoungestLabel; + } + + ////@Validated + @ToString + public static class Food { + @NotNull @Getter @Setter private Integer foodPerDay; + @NotNull @Getter @Setter private Integer foodPerDayFieldColumns; + @NotBlank @Getter @Setter private String foodPerDayLabel; + @NotBlank @Getter @Setter private String foodPerDayBorderLabel; + @NotBlank @Getter @Setter private String buttonFoodPerDayIncrease; + @NotBlank @Getter @Setter private String buttonFoodPerDayDecrease; + @NotBlank @Getter @Setter private String panelFood; + } + + ////@Validated + @ToString + public static class GardenOfEden { + @NotBlank @Getter @Setter private String panelGardenOfEden; + @NotNull @Getter @Setter private Boolean gardenOfEdenEnabled; + @NotBlank @Getter @Setter private String gardenOfEdenEnabledString; + @NotBlank @Getter @Setter private String gardenOfEdenEnabledToggleButton; + @NotNull @Getter @Setter private Integer foodPerDay; + @NotNull @Getter @Setter private Integer gardenOfEdenLatticeDivisor; + @NotNull @Getter @Setter private Integer gardenOfEdenLatticeDivisorPadding; + } + } + + ////@Validated + @ToString + public static class Cca { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + } + } + + ////@Validated + @ToString + public static class WienerProcess { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + } + } + + //@Validated + @ToString + public static class Dla { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Kochsnowflake { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Samegame { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Sierpinskitriangle { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Tetris { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Turmite { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Wator { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + @NotBlank @Getter @Setter private String buttonsZoom; + @NotBlank @Getter @Setter private String buttonsZoomOut; + @NotBlank @Getter @Setter private String buttonsSwitch; + @NotBlank @Getter @Setter private String buttonsZoomLabel; + @NotBlank @Getter @Setter private String buttonsLabel; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Gameoflive{ + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public ComputerKurzweilProperties.Wator.View.Neighborhood neighborhood = new Wator.View.Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/ComplexNumber.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/ComplexNumber.java new file mode 100644 index 00000000..5e68767a --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/ComplexNumber.java @@ -0,0 +1,133 @@ +package org.woehlke.computer.kurzweil.commons.model.fractal; + +import java.util.Objects; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 18.08.15. + */ +public class ComplexNumber { + + public final static int MAX_ITERATIONS = 64; + private final static double DIVERGENCE_THRESHOLD = 4.0d; + private volatile double real; + private volatile double img; + private volatile int iterations; + private volatile boolean inMandelbrotSet; + private volatile boolean inJuliaSet; + + public ComplexNumber() { + this.real = 0.0d; + this.img = 0.0d; + this.iterations=0; + this.inMandelbrotSet=false; + this.inJuliaSet=false; + } + + public ComplexNumber(ComplexNumber complexNumber) { + this.real = complexNumber.real; + this.img = complexNumber.img; + this.iterations=complexNumber.iterations; + this.inMandelbrotSet=complexNumber.inMandelbrotSet; + this.inJuliaSet=complexNumber.inJuliaSet; + } + + public ComplexNumber(double real, double img) { + this.real = real; + this.img = img; + this.iterations=0; + this.inMandelbrotSet=false; + this.inJuliaSet=false; + } + + public double getReal() { + return real; + } + + public double getImg() { + return img; + } + + public ComplexNumber plus(ComplexNumber complexNumber){ + double newRealZ = this.real + complexNumber.real; + double newImgZ = this.img + complexNumber.img; + return new ComplexNumber(newRealZ,newImgZ); + } + + public ComplexNumber square(){ + double realZ=real; + double imgZ=img; + double newRealZ=realZ*realZ-imgZ*imgZ; + double newImgZ=2*realZ*imgZ; + return new ComplexNumber(newRealZ,newImgZ); + } + + public synchronized int computeMandelbrotSet() { + int iterationsTmp = 0; + ComplexNumber z = new ComplexNumber(); + do { + iterationsTmp++; + z = z.square().plus(this); + } while (z.isNotDivergent() && (iterationsTmp < MAX_ITERATIONS)); + this.inMandelbrotSet = z.isNotDivergent(); + this.iterations = this.inMandelbrotSet?0:iterationsTmp; + return this.iterations; + } + + public synchronized int computeJuliaSet(ComplexNumber c) { + int iterationsTmp = 0; + ComplexNumber z = new ComplexNumber(this); + do { + iterationsTmp++; + z = z.square().plus(c); + } while (z.isNotDivergent() && (iterationsTmp < MAX_ITERATIONS)); + this.inJuliaSet = z.isNotDivergent(); + this.iterations = this.inJuliaSet?0:iterationsTmp; + return this.iterations; + } + + public synchronized boolean isInMandelbrotSet() { + return inMandelbrotSet; + } + + public synchronized boolean isInJuliaSet() { + return inJuliaSet; + } + + public synchronized boolean isNotDivergent(){ + return (( real*real + img*img ) < DIVERGENCE_THRESHOLD); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ComplexNumber)) return false; + ComplexNumber that = (ComplexNumber) o; + return Double.compare(that.getReal(), getReal()) == 0 && + Double.compare(that.getImg(), getImg()) == 0 && + iterations == that.iterations && + isInMandelbrotSet() == that.isInMandelbrotSet() && + isInJuliaSet() == that.isInJuliaSet(); + } + + @Override + public int hashCode() { + return Objects.hash(getReal(), getImg(), iterations, isInMandelbrotSet(), isInJuliaSet()); + } + + @Override + public String toString() { + return "ComplexNumber{" + + "real=" + real + + ", img=" + img + + ", iterations=" + iterations + + ", inMandelbrotSet=" + inMandelbrotSet + + ", inJuliaSet=" + inJuliaSet + + '}'; + } +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/GaussianNumberPlane.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/GaussianNumberPlane.java new file mode 100644 index 00000000..a116cf6b --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/GaussianNumberPlane.java @@ -0,0 +1,222 @@ +package org.woehlke.computer.kurzweil.commons.model.fractal; + +import org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.SierpinskiTriangleModel; +import org.woehlke.computer.kurzweil.commons.model.turing.Point; + +import java.util.ArrayDeque; +import java.util.Deque; +//import java.util.logging.Logger; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class GaussianNumberPlane { + + public final static int YET_UNCOMPUTED = -1; + private final static double complexWorldDimensionRealX = 3.2d; + private final static double complexWorldDimensionImgY = 2.34d; + private final static double complexCenterForMandelbrotRealX = -2.2f; + private final static double complexCenterForMandelbrotImgY = -1.17f; + private final static double complexCenterForJuliaRealX = -1.6d; + private final static double complexCenterForJuliaImgY = -1.17d; + private final Point worldDimensions; + public volatile int zoomLevel; + private volatile int[][] lattice; + private volatile ComplexNumber complexNumberForJuliaSetC; + private volatile ComplexNumber complexWorldDimensions; + private volatile ComplexNumber complexCenterForMandelbrot; + private volatile ComplexNumber complexCenterForJulia; + private volatile Deque complexCenterForZoomedMandelbrot = new ArrayDeque<>(); + + private volatile ComplexNumber zoomCenter; + + + //public static Logger log = Logger.getLogger(GaussianNumberPlane.class.getName()); + + public GaussianNumberPlane(SierpinskiTriangleModel model) { + this.worldDimensions = model.getWorldDimensions(); + this.lattice = new int[worldDimensions.getWidth()][worldDimensions.getHeight()]; + this.complexWorldDimensions = new ComplexNumber( + complexWorldDimensionRealX, + complexWorldDimensionImgY + ); + this.complexCenterForMandelbrot = new ComplexNumber( + complexCenterForMandelbrotRealX, + complexCenterForMandelbrotImgY + ); + this.complexCenterForJulia = new ComplexNumber( + complexCenterForJuliaRealX, + complexCenterForJuliaImgY + ); + start(); + } + + public void setModeZoom() { + this.setZoomLevel(1); + this.setZoomCenter(complexCenterForMandelbrot); + } + + public synchronized void start(){ + zoomLevel = 1; + for(int y = 0;y < this.worldDimensions.getY(); y++){ + for(int x=0; x < worldDimensions.getX(); x++){ + lattice[x][y] = YET_UNCOMPUTED; + } + } + } + + public synchronized int getCellStatusFor(int x,int y){ + return (lattice[x][y])<0?0:lattice[x][y]; + } + + private synchronized ComplexNumber getComplexNumberFromLatticeCoordsForJulia(Point turingPosition) { + double realX = complexCenterForJulia.getReal() + + (complexWorldDimensions.getReal()*turingPosition.getX())/worldDimensions.getX(); + double imgY = complexCenterForJulia.getImg() + + (complexWorldDimensions.getImg()*turingPosition.getY())/worldDimensions.getY(); + return new ComplexNumber(realX,imgY); + } + + private synchronized ComplexNumber getComplexNumberFromLatticeCoordsForMandelbrot(Point turingPosition) { + double realX = ( + complexCenterForMandelbrot.getReal() + + ( complexWorldDimensions.getReal() * turingPosition.getX() ) + / worldDimensions.getX() + ); + double imgY = ( + complexCenterForMandelbrot.getImg() + + ( complexWorldDimensions.getImg() * turingPosition.getY() ) + / worldDimensions.getY() + ); + return new ComplexNumber(realX,imgY); + } + + private synchronized ComplexNumber getComplexNumberFromLatticeCoordsForZoomedMandelbrot(Point turingPosition) { + double realX = ( + ( complexCenterForMandelbrot.getReal() / this.getZoomLevel() ) + + getZoomCenter().getReal() + + ( complexWorldDimensions.getReal() * turingPosition.getX() ) + / ( worldDimensions.getX() * this.getZoomLevel() ) + ); + double imgY = ( + ( complexCenterForMandelbrot.getImg() / this.getZoomLevel() ) + + getZoomCenter().getImg() + + ( complexWorldDimensions.getImg() * turingPosition.getY() ) + / ( worldDimensions.getY() * this.getZoomLevel() ) + ); + 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); + lattice[turingPosition.getX()][turingPosition.getY()] = position.computeMandelbrotSet(); + return position.isInMandelbrotSet(); + } + + public synchronized void fillTheOutsideWithColors(){ + for(int y=0;y1){ + this.deceaseZoomLevel(); + this.setZoomCenter(complexCenterForZoomedMandelbrot.pop()); + } + //log.info("zoomCenter: " + this.getZoomCenter() + " - zoomLevel: "+ this.getZoomLevel()); + for(int y = 0; y < worldDimensions.getY(); y++){ + for(int x = 0; x < worldDimensions.getX(); x++){ + Point p = new Point(x, y); + this.isInZooomedMandelbrotSet(p); + } + } + } + + public void zoomIntoTheJuliaSetFor(Point zoomPoint) { + ComplexNumber c = this.complexNumberForJuliaSetC; + computeTheJuliaSetForC(c); + } + + public void zoomOutOfTheJuliaSet() { + } + + public synchronized int getZoomLevel() { + return zoomLevel; + } + + public synchronized void setZoomLevel(int zoomLevel) { + this.zoomLevel = zoomLevel; + } + + public synchronized int inceaseZoomLevel() { + return zoomLevel *= 2; + } + + public synchronized int deceaseZoomLevel() { + return zoomLevel /= 2; + } + + public synchronized ComplexNumber getZoomCenter() { + return zoomCenter; + } + + public synchronized void setZoomCenter(ComplexNumber zoomCenter) { + this.zoomCenter = zoomCenter; + } + +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringDirection.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringDirection.java new file mode 100644 index 00000000..bd799fa1 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringDirection.java @@ -0,0 +1,17 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 18.08.15. + */ +public enum MandelbrotTuringDirection { + UP, + RIGHT, + DOWN, + LEFT +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringMachine.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringMachine.java new file mode 100644 index 00000000..9584de5c --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringMachine.java @@ -0,0 +1,81 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +import org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.SierpinskiTriangleModel; +import org.woehlke.computer.kurzweil.commons.model.fractal.GaussianNumberPlane; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Date: 28.08.13 + * Time: 12:39 + */ +public class MandelbrotTuringMachine { + + private volatile GaussianNumberPlane gaussianNumberPlane; + private volatile MandelbrotTuringPositions turingPositions; + private volatile MandelbrotTuringPhaseState turingPhaseState; + + public MandelbrotTuringMachine(SierpinskiTriangleModel model) { + this.gaussianNumberPlane = model.getGaussianNumberPlane(); + this.turingPhaseState = new MandelbrotTuringPhaseState(); + this.turingPositions = new MandelbrotTuringPositions(model.getWorldDimensions()); + start(); + } + + public void start() { + this.turingPhaseState.start(); + this.gaussianNumberPlane.start(); + this.turingPositions.start(); + } + + public synchronized boolean step() { + boolean repaint=true; + switch(turingPhaseState.getTuringTuringPhase()){ + case SEARCH_THE_SET: + stepGoToSet(); + repaint=false; + break; + case WALK_AROUND_THE_SET: + stepWalkAround(); + break; + case FILL_THE_OUTSIDE_WITH_COLOR: + fillTheOutsideWithColors(); + break; + case FINISHED: + default: + repaint=false; + break; + } + return repaint; + } + + private void stepGoToSet(){ + if(this.gaussianNumberPlane.isInMandelbrotSet(this.turingPositions.getTuringPosition())){ + this.turingPositions.markFirstSetPosition(); + this.turingPhaseState.finishSearchTheSet(); + } else { + this.turingPositions.goForward(); + } + } + + private void stepWalkAround(){ + if(gaussianNumberPlane.isInMandelbrotSet(this.turingPositions.getTuringPosition())){ + this.turingPositions.turnRight(); + } else { + this.turingPositions.turnLeft(); + } + this.turingPositions.goForward(); + if(this.turingPositions.isFinishedWalkAround()){ + this.turingPhaseState.finishWalkAround(); + } + } + + private void fillTheOutsideWithColors(){ + this.gaussianNumberPlane.fillTheOutsideWithColors(); + this.turingPhaseState.finishFillTheOutsideWithColors(); + } +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhase.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhase.java new file mode 100644 index 00000000..cff085ea --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhase.java @@ -0,0 +1,17 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 18.08.15. + */ +public enum MandelbrotTuringPhase { + SEARCH_THE_SET, + WALK_AROUND_THE_SET, + FILL_THE_OUTSIDE_WITH_COLOR, + FINISHED +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhaseState.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhaseState.java new file mode 100644 index 00000000..0fce7646 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhaseState.java @@ -0,0 +1,39 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class MandelbrotTuringPhaseState { + + private volatile MandelbrotTuringPhase turingTuringPhase; + + public MandelbrotTuringPhaseState() { + start(); + } + + public void start(){ + this.turingTuringPhase = MandelbrotTuringPhase.SEARCH_THE_SET; + } + + public void finishSearchTheSet(){ + turingTuringPhase = MandelbrotTuringPhase.WALK_AROUND_THE_SET; + } + + public void finishWalkAround() { + turingTuringPhase = MandelbrotTuringPhase.FILL_THE_OUTSIDE_WITH_COLOR; + } + + public void finishFillTheOutsideWithColors() { + turingTuringPhase = MandelbrotTuringPhase.FINISHED; + } + + public MandelbrotTuringPhase getTuringTuringPhase() { + return turingTuringPhase; + } +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPositions.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPositions.java new file mode 100644 index 00000000..889a592e --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPositions.java @@ -0,0 +1,90 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class MandelbrotTuringPositions { + + private volatile Point turingPosition; + private volatile Point worldDimensions; + private volatile Point firstSetPosition; + + private volatile MandelbrotTuringDirection turingDirection; + + private volatile int steps; + + public MandelbrotTuringPositions(Point worldDimensions) { + this.worldDimensions = worldDimensions; + start(); + } + + public void start() { + this.steps = 0; + this.turingPosition = new Point((worldDimensions.getX()-2),(worldDimensions.getY()/2+11)); + this.turingDirection = MandelbrotTuringDirection.LEFT; + } + + public synchronized void markFirstSetPosition(){ + this.firstSetPosition = turingPosition; + this.steps = 0; + } + + public synchronized Point getTuringPosition() { + return turingPosition; + } + + public synchronized void goForward() { + this.steps++; + switch (this.turingDirection){ + case UP: + this.turingPosition.moveUp(); + break; + case RIGHT: + this.turingPosition.moveRight(); + break; + case DOWN: + this.turingPosition.moveDown(); + break; + case LEFT: + this.turingPosition.moveLeft(); + break; + default: + break; + } + } + + public synchronized void turnRight() { + MandelbrotTuringDirection newTuringDirection; + switch (this.turingDirection){ + case UP: newTuringDirection = MandelbrotTuringDirection.RIGHT; break; + case RIGHT: newTuringDirection = MandelbrotTuringDirection.DOWN; break; + case DOWN: newTuringDirection = MandelbrotTuringDirection.LEFT; break; + case LEFT: newTuringDirection = MandelbrotTuringDirection.UP; break; + default: newTuringDirection = this.turingDirection; break; + } + this.turingDirection = newTuringDirection; + } + + public synchronized void turnLeft() { + MandelbrotTuringDirection newTuringDirection; + switch (this.turingDirection){ + case UP: newTuringDirection = MandelbrotTuringDirection.LEFT; break; + case RIGHT: newTuringDirection = MandelbrotTuringDirection.UP; break; + case DOWN: newTuringDirection = MandelbrotTuringDirection.RIGHT; break; + case LEFT: newTuringDirection = MandelbrotTuringDirection.DOWN; break; + default: newTuringDirection = this.turingDirection; break; + } + this.turingDirection = newTuringDirection; + } + + public synchronized boolean isFinishedWalkAround() { + return (this.turingPosition.equals(this.firstSetPosition)) && (this.steps>100); + } + +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/Point.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/Point.java new file mode 100644 index 00000000..a5da8333 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/Point.java @@ -0,0 +1,91 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +import java.util.Objects; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Date: 04.02.2006 + * Time: 23:47:05 + */ +public class Point { + + private volatile int x = 0; + private volatile int y = 0; + + public Point() { + } + + public Point(Point p) { + this.x = p.getX(); + this.y = p.getY(); + } + + public Point(int x, int y) { + this.x = x; + this.y = y; + } + + public void moveUp() { + y--; + } + + public void moveRight() { + x++; + } + + public void moveDown() { + y++; + } + + public void moveLeft() { + x--; + } + + public int getWidth(){ + return x; + } + public int getHeight() { return y; } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Point)) return false; + Point point = (Point) o; + return getX() == point.getX() && + getY() == point.getY(); + } + + @Override + public int hashCode() { + return Objects.hash(getX(), getY()); + } + + @Override + public String toString() { + return "Point{" + + "x=" + x + + ", y=" + y + + '}'; + } +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java new file mode 100644 index 00000000..4fae16fd --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java @@ -0,0 +1,22 @@ +package org.woehlke.computer.kurzweil.commons.ui; + +import javax.swing.*; +import java.awt.*; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class PanelCopyright extends JPanel { + + public PanelCopyright(String subtitle) { + this.setLayout(new FlowLayout()); + this.add(new JLabel(subtitle)); + } + +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java new file mode 100644 index 00000000..fb044e95 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java @@ -0,0 +1,22 @@ +package org.woehlke.computer.kurzweil.commons.ui; + +import javax.swing.*; +import java.awt.*; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class PanelSubtitle extends JPanel { + + public PanelSubtitle(String subtitle) { + this.setLayout(new FlowLayout()); + this.add(new JLabel(subtitle)); + } + +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/TabType.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/TabType.java new file mode 100644 index 00000000..6473614f --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/TabType.java @@ -0,0 +1,109 @@ +package org.woehlke.computer.kurzweil.tabs; + +import lombok.Getter; + +import java.awt.event.KeyEvent; + +@Getter +public enum TabType { + + CYCLIC_CELLULAR_AUTOMATON( + KeyEvent.VK_1, + true, + "Cyclic Cellular Automaton", + "Cyclic Cellular Automaton", + "Cyclic Cellular Automaton" + ), + DIFFUSION_LIMITED_AGGREGATION( + KeyEvent.VK_2, + true, + "Diffusion Limited Aggregation", + "Fractal Random Walk due to Brownian Motion Cluster", + "Diffusion Limited Aggregation. Fractal Random Walk due to Brownian Motion Cluster" + ), + SIMULATED_EVOLUTION( + KeyEvent.VK_3, + true, + "Simulated Evolution", + "Artificial Life Simulation of Bacteria Motion depending on DNA and their Evolution", + "Artificial Life Simulation of Bacteria Motion depending on DNA and their Evolution" + ), + MANDELBROT_SET( + KeyEvent.VK_4, + true, + "Mandelbrot Set", + "Fractal Mandelbrot Set drawn by a Turing Machine", + "Fractal Mandelbrot Set drawn by a Turing Machine" + ), + RANDOM_WALK_WIENER_PROCESS( + KeyEvent.VK_5, + true, + "Random Walk", + "Brownian Motion by Fractal Random Walk", + "Random Walk. Brownian Motion by Fractal Random Walk" + ), + KOCH_SNOWFLAKE( + KeyEvent.VK_6, + false, + "Koch Snowflake", + "Fractal Koch Snowflake", + "Fractal Koch Snowflake" + ), + SAME_GAME( + KeyEvent.VK_7, + false, + "Same Game", + "Play the Same Game", + "Play the Same Game" + ), + SIERPINSKI_TRIANGLE( + KeyEvent.VK_0, + false, + "Sierpinski Triangle'", + "Fractal Sierpinski Triangle", + "Fractal Sierpinski Triangle" + ), + TETRIS( + KeyEvent.VK_8, + false, + "Tetris", + "Play Tetris", + "Play Tetris" + ), + TURMITE( + KeyEvent.VK_9, + false, + "Turmite", + "Turmites as Turing Machines with 2D Tape", + "Turmites as Turing Machines with 2D Tape" + ), + WATOR( + KeyEvent.VK_A, + false, + "WaTor", + "Population Dynamics on Planet Water Torus", + "Population Dynamics on Planet Water Torus" + ), + CONWAYS_GAME_OF_LIFE( + KeyEvent.VK_B, + false, + "Conways Game of Life", + "Conways Game of Life Cellular Automaton", + "Conways Game of Life Cellular Automaton" + ); + + private int keyEvent; + private boolean active; + private String title; + private String subTitle; + private String tooltip; + + TabType(int keyEvent, boolean active, String title, String subTitle, String tooltip){ + this.keyEvent=keyEvent; + this.active=active; + this.title=title; + this.subTitle=subTitle; + this.tooltip=tooltip; + } + +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/SierpinskiTriangleCanvas.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/SierpinskiTriangleCanvas.java new file mode 100644 index 00000000..3b4bdc80 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/SierpinskiTriangleCanvas.java @@ -0,0 +1,54 @@ +package org.woehlke.computer.kurzweil.tabs.sierpinskitriangle; + +import org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.SierpinskiTriangleModel; + +import javax.swing.*; +import java.awt.*; + + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2013 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Date: 05.02.2006 + * Time: 00:51:51 + */ +public class SierpinskiTriangleCanvas extends JComponent { + + private volatile SierpinskiTriangleModel app; + private volatile Dimension preferredSize; + + public SierpinskiTriangleCanvas(SierpinskiTriangleModel app) { + this.app = app; + int width = this.app.getWorldDimensions().getWidth(); + int height = this.app.getWorldDimensions().getHeight(); + this.preferredSize = new Dimension(width, height); + this.setSize(this.preferredSize); + this.setPreferredSize(preferredSize); + } + + public void paint(Graphics g) { + this.setSize(this.preferredSize); + this.setPreferredSize(preferredSize); + super.paintComponent(g); + int red = 0; + int green = 0; + int blue = 0; + for(int y = 0; y < app.getWorldDimensions().getY(); y++){ + for(int x = 0; x < app.getWorldDimensions().getX(); x++){ + blue = (((app.getCellStatusFor(x,y))*4)%256); + Color stateColor = new Color(red, green, blue); + g.setColor(stateColor); + g.drawLine(x,y,x,y); + } + } + } + + public void update(Graphics g) { + paint(g); + } + +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/SierpinskiTriangleController.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/SierpinskiTriangleController.java new file mode 100644 index 00000000..babdd5af --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/SierpinskiTriangleController.java @@ -0,0 +1,50 @@ +package org.woehlke.computer.kurzweil.tabs.sierpinskitriangle; + +import org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.SierpinskiTriangleModel; +import org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.SierpinskiTriangleTab; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Date: 05.02.2006 + * Time: 00:36:20 + */ +public class SierpinskiTriangleController extends Thread implements Runnable { + + private final int THREAD_SLEEP_TIME = 1; + private volatile SierpinskiTriangleModel mandelbrotModel; + private volatile SierpinskiTriangleTab frame; + private volatile Boolean goOn; + + public SierpinskiTriangleController(SierpinskiTriangleModel model, SierpinskiTriangleTab frame) { + this.frame = frame; + this.mandelbrotModel = model; + goOn = Boolean.TRUE; + } + + public void run() { + boolean doIt; + do { + synchronized (goOn) { + doIt = goOn.booleanValue(); + } + if(this.mandelbrotModel.step()){ + frame.getCanvas().repaint(); + } + try { sleep(THREAD_SLEEP_TIME); } + catch (InterruptedException e) { } + } + while (doIt); + } + + public void exit() { + synchronized (goOn) { + goOn = Boolean.FALSE; + } + } + +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/SierpinskiTriangleModel.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/SierpinskiTriangleModel.java new file mode 100644 index 00000000..7b8b52ec --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/SierpinskiTriangleModel.java @@ -0,0 +1,114 @@ +package org.woehlke.computer.kurzweil.tabs.sierpinskitriangle; + +import lombok.Getter; +import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties; +import org.woehlke.computer.kurzweil.commons.model.fractal.GaussianNumberPlane; +import org.woehlke.computer.kurzweil.commons.model.turing.Point; +import org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.model.SierpinskiTriangleTabStateMachine; +import org.woehlke.computer.kurzweil.commons.model.turing.MandelbrotTuringMachine; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +@Getter +public class SierpinskiTriangleModel { + + private volatile GaussianNumberPlane gaussianNumberPlane; + private volatile MandelbrotTuringMachine mandelbrotTuringMachine; + private volatile SierpinskiTriangleTabStateMachine applicationStateMachine; + + private volatile ComputerKurzweilProperties properties; + private volatile SierpinskiTriangleTab frame; + + public SierpinskiTriangleModel(ComputerKurzweilProperties properties, SierpinskiTriangleTab frame) { + this.properties = properties; + this.frame = frame; + this.gaussianNumberPlane = new GaussianNumberPlane(this); + this.mandelbrotTuringMachine = new MandelbrotTuringMachine(this); + this.applicationStateMachine = new SierpinskiTriangleTabStateMachine(); + } + + public synchronized boolean click(Point c) { + applicationStateMachine.click(); + boolean repaint = true; + switch (applicationStateMachine.getApplicationState()) { + case MANDELBROT: + mandelbrotTuringMachine.start(); + repaint = false; + break; + //case JULIA_SET: + // gaussianNumberPlane.computeTheJuliaSetFor(c); + // break; + case MANDELBROT_ZOOM: + gaussianNumberPlane.zoomIntoTheMandelbrotSet(c); + break; + //case JULIA_SET_ZOOM: + // gaussianNumberPlane.zoomIntoTheJuliaSetFor(c); + // break; + } + return repaint; + } + + public synchronized boolean step() { + boolean repaint = false; + switch (applicationStateMachine.getApplicationState()) { + case MANDELBROT: + repaint = mandelbrotTuringMachine.step(); + break; + //case JULIA_SET: + case MANDELBROT_ZOOM: + //case JULIA_SET_ZOOM: + break; + } + return repaint; + } + + public synchronized int getCellStatusFor(int x, int y) { + return gaussianNumberPlane.getCellStatusFor(x, y); + } + + public Point getWorldDimensions() { + int width = properties.getAllinone().getLattice().getWidth(); + int height = properties.getAllinone().getLattice().getHeight(); + return new Point(width, height); + } + + public void setModeSwitch() { + this.applicationStateMachine.setModeSwitch(); + this.frame.setModeSwitch(); + } + + public void setModeZoom() { + this.gaussianNumberPlane.setModeZoom(); + this.applicationStateMachine.setModeZoom(); + this.frame.setModeZoom(); + } + + public GaussianNumberPlane getGaussianNumberPlane() { + return gaussianNumberPlane; + } + + public SierpinskiTriangleTab 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; + } + } +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/SierpinskiTriangleTab.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/SierpinskiTriangleTab.java new file mode 100644 index 00000000..609889ef --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/SierpinskiTriangleTab.java @@ -0,0 +1,147 @@ +package org.woehlke.computer.kurzweil.tabs.sierpinskitriangle; + +import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties; +import org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.ui.PanelButtons; +import org.woehlke.computer.kurzweil.commons.ui.PanelCopyright; +import org.woehlke.computer.kurzweil.commons.ui.PanelSubtitle; +import org.woehlke.computer.kurzweil.commons.model.turing.Point; + +import javax.accessibility.Accessible; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.image.ImageObserver; +import java.io.Serializable; + +/** + * (C) 2006 - 2013 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * Date: 04.02.2006 + * Time: 18:47:46 + */ +public class SierpinskiTriangleTab extends JFrame implements ImageObserver, + MenuContainer, + Serializable, + Accessible, + WindowListener, + MouseListener { + + private volatile SierpinskiTriangleController mandelbrotController; + private volatile SierpinskiTriangleCanvas canvas; + private volatile SierpinskiTriangleModel mandelbrotModel; + private volatile Rectangle rectangleBounds; + private volatile Dimension dimensionSize; + + public SierpinskiTriangleTab(ComputerKurzweilProperties properties) { + super(properties.getWator().getView().getTitle()); + this.mandelbrotModel = new SierpinskiTriangleModel(properties,this); + BoxLayout layout = new BoxLayout(rootPane, BoxLayout.PAGE_AXIS); + this.canvas = new SierpinskiTriangleCanvas(mandelbrotModel); + this.mandelbrotController = new SierpinskiTriangleController(mandelbrotModel, this); + PanelButtons panelButtons = new PanelButtons(this.mandelbrotModel); + PanelSubtitle panelSubtitle = new PanelSubtitle(properties.getWator().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(); + setModeSwitch(); + this.mandelbrotController.start(); + } + + public void windowOpened(WindowEvent e) { + showMe(); + } + + public void windowClosing(WindowEvent e) { + this.mandelbrotController.exit(); + } + + public void windowClosed(WindowEvent e) { + this.mandelbrotController.exit(); + } + + public void windowIconified(WindowEvent e) {} + + public void windowDeiconified(WindowEvent e) { + showMe(); + } + + public void windowActivated(WindowEvent e) { + showMe(); + } + + public void windowDeactivated(WindowEvent e) {} + + + @Override + public void mouseClicked(MouseEvent e) { + Point c = new Point(e.getX(), e.getY()); + this.mandelbrotModel.click(c); + showMe(); + } + + @Override + public void mousePressed(MouseEvent e) {} + + @Override + public void mouseReleased(MouseEvent e) {} + + @Override + public void mouseEntered(MouseEvent e) {} + + @Override + public void mouseExited(MouseEvent e) {} + + public void showMeInit() { + pack(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + double width = this.rootPane.getWidth(); + double height = this.canvas.getHeight() + 180; + double startX = (screenSize.getWidth() - width) / 2d; + double startY = (screenSize.getHeight() - height) / 2d; + int myheight = Double.valueOf(height).intValue(); + int mywidth = Double.valueOf(width).intValue(); + int mystartX = Double.valueOf(startX).intValue(); + int mystartY = Double.valueOf(startY).intValue(); + this.rectangleBounds = new Rectangle(mystartX, mystartY, mywidth, myheight); + this.dimensionSize = new Dimension(mywidth, myheight); + this.setBounds(this.rectangleBounds); + this.setSize(this.dimensionSize); + this.setPreferredSize(this.dimensionSize); + this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + setVisible(true); + toFront(); + } + + /** + * TODO write doc. + */ + public void showMe() { + this.pack(); + this.setBounds(this.rectangleBounds); + this.setSize(this.dimensionSize); + this.setPreferredSize(this.dimensionSize); + this.setVisible(true); + this.toFront(); + } + + public void setModeSwitch() { + canvas.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + } + + public void setModeZoom() { + canvas.setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + public SierpinskiTriangleCanvas getCanvas() { + return canvas; + } +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/model/SierpinskiTriangleTabState.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/model/SierpinskiTriangleTabState.java new file mode 100644 index 00000000..22381c27 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/model/SierpinskiTriangleTabState.java @@ -0,0 +1,15 @@ +package org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.model; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 23.08.15. + */ +public enum SierpinskiTriangleTabState { + MANDELBROT, + MANDELBROT_ZOOM +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/model/SierpinskiTriangleTabStateMachine.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/model/SierpinskiTriangleTabStateMachine.java new file mode 100644 index 00000000..45e95d5f --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/model/SierpinskiTriangleTabStateMachine.java @@ -0,0 +1,80 @@ +package org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.model; + + +import org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.model.SierpinskiTriangleTabState; + +import static org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.model.SierpinskiTriangleTabState.*; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class SierpinskiTriangleTabStateMachine { + + private volatile SierpinskiTriangleTabState applicationState; + + public SierpinskiTriangleTabStateMachine() { + this.applicationState = SierpinskiTriangleTabState.MANDELBROT; + } + + public void click(){ + SierpinskiTriangleTabState nextApplicationState = null; + switch (applicationState){ + case MANDELBROT: + nextApplicationState = MANDELBROT_ZOOM; + break; + case MANDELBROT_ZOOM: + nextApplicationState = MANDELBROT; + break; + } + this.setApplicationState(nextApplicationState); + } + + public void setModeSwitch() { + SierpinskiTriangleTabState 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() { + SierpinskiTriangleTabState 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 SierpinskiTriangleTabState getApplicationState() { + return applicationState; + } + + public void setApplicationState(SierpinskiTriangleTabState applicationState) { + this.applicationState = applicationState; + } + +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/ui/PanelButtons.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/ui/PanelButtons.java new file mode 100644 index 00000000..8693cded --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/ui/PanelButtons.java @@ -0,0 +1,69 @@ +package org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.ui; + +import org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.SierpinskiTriangleModel; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class PanelButtons extends JPanel implements ActionListener { + + //private volatile JRadioButton radioButtonsSwitch; + //private volatile JRadioButton radioButtonsZoom; + private volatile JButton zoomOut; + //private volatile ButtonGroup radioButtonsGroup; + private volatile SierpinskiTriangleModel model; + + public PanelButtons(SierpinskiTriangleModel model) { + this.model = model; + JLabel buttonsLabel = new JLabel(model.getProperties().getWator().getView().getButtonsLabel()); + /* + this.radioButtonsSwitch = new JRadioButton(model.getProperties().getMandelbrot().getView().getButtonsSwitch()); + this.radioButtonsSwitch.setMnemonic(RADIO_BUTTONS_SWITCH.ordinal()); + this.radioButtonsSwitch.setSelected(true); + this.radioButtonsSwitch.addActionListener(this); + this.radioButtonsZoom = new JRadioButton(model.getProperties().getMandelbrot().getView().getButtonsSwitch()); + this.radioButtonsZoom.setMnemonic(RADIO_BUTTONS_ZOOM.ordinal()); + this.radioButtonsZoom.addActionListener(this); + this.radioButtonsGroup = new ButtonGroup(); + this.radioButtonsGroup.add(radioButtonsSwitch); + this.radioButtonsGroup.add(radioButtonsZoom); + */ + this.zoomOut = new JButton(model.getProperties().getWator().getView().getButtonsZoomOut()); + this.zoomOut.addActionListener(this); + FlowLayout layout = new FlowLayout(); + this.setLayout(layout); + this.add(buttonsLabel); + //this.add(radioButtonsSwitch); + //this.add(radioButtonsZoom); + this.add(zoomOut); + } + + /** + * TODO write doc. + */ + @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){ + this.model.zoomOut(); + this.model.getFrame().getCanvas().repaint(); + } + } +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/ui/RadioButtons.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/ui/RadioButtons.java new file mode 100644 index 00000000..20f16ccd --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/java/org/woehlke/computer/kurzweil/tabs/sierpinskitriangle/ui/RadioButtons.java @@ -0,0 +1,15 @@ +package org.woehlke.computer.kurzweil.tabs.sierpinskitriangle.ui; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public enum RadioButtons { + RADIO_BUTTONS_SWITCH, + RADIO_BUTTONS_ZOOM +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/application.properties b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/application.properties new file mode 100644 index 00000000..81af6f26 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/application.properties @@ -0,0 +1,9 @@ +org.woehlke.computer.kurzweil.mandelbrot.config.title=Mandelbrot Set +org.woehlke.computer.kurzweil.mandelbrot.config.subtitle=Mandelbrot Set drawn by a Turing Machine +org.woehlke.computer.kurzweil.mandelbrot.config.copyright=(c) 2019 Thomas Woehlke +org.woehlke.computer.kurzweil.mandelbrot.config.width=800 +org.woehlke.computer.kurzweil.mandelbrot.config.height=585 +org.woehlke.computer.kurzweil.mandelbrot.config.buttons.label=Choose Mode +org.woehlke.computer.kurzweil.mandelbrot.config.buttons.switch=Mandelbrot Set <=> Julia Set +org.woehlke.computer.kurzweil.mandelbrot.config.buttons.zoom=Zoom +org.woehlke.computer.kurzweil.mandelbrot.config.buttons.zoomout=Zoom Out diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/application.yml b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/application.yml new file mode 100644 index 00000000..22e87914 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/application.yml @@ -0,0 +1,184 @@ +allinone: + lattice: + width: 800 + height: 585 + view: + title: 'Computer Kurzweil' + subtitle: 'Scientific Imfotainment' + copyright: '(c) 2020 Thomas Woehlke' + borderPaddingX: 5 + borderPaddingY: 5 + titleHeight: 60 + startStopp: 'Start / Stop' + start: 'Start' + stop: 'Stop' + info: 'Info' +mandelbrot: + view: + title: 'Mandelbrot Set' + subtitle: 'Fractal Mandelbrot Set drawn by a Turing Machine' + buttonsZoom: 'Zoom In' + buttonsZoomOut: 'Zoom Out' + buttonsSwitch: 'Mandelbrot Set <-> Julia Set' + buttonsZoomLabel: 'Zoom' + buttonsLabel: 'Choose Mouse Click Mode' + control: + threadSleepTime: 50 +simulatedevolution: + view: + title: 'Simulated Evolution' + subtitle: 'Artificial Life Simulation of Bacteria Motion depending on DNA' + control: + threadSleepTime: 100 + exitStatus: 0 + queueMaxLength: 1000 + cellConf: + fatMax: 2000 + fatHungerMax: 1000 + fatMinimumForSex: 800 + fatAtBirth: 500 + fatPerFood: 25 + ageOfAdulthood: 200 + ageOld: 800 + ageMax: 1000 + population: + initialPopulation: 20 + panelPopulationStatistics: 'Population' + panelLifeCycleStatistics: 'LifeCycle' + youngCellsLabel: 'young' + youngAndFatCellsLabel: 'young and Fat' + fullAgeCellsLabel: 'full Age' + hungryCellsLabel: 'hungry' + oldCellsLabel: 'old' + populationLabel: 'population' + generationOldestLabel: 'oldest Generation' + generationYoungestLabel: 'youngest Generation' + food: + foodPerDay: 20 + foodPerDayFieldColumns: 3 + foodPerDayLabel: 'Food per Day:' + foodPerDayBorderLabel: 'Food per Day:' + buttonFoodPerDayIncrease: '+' + buttonFoodPerDayDecrease: '-' + panelFood: 'Food' + gardenOfEden: + panelGardenOfEden: 'Garden of Eden' + gardenOfEdenEnabled: true + gardenOfEdenEnabledString: 'enabled' + gardenOfEdenEnabledToggleButton: 'Change' + foodPerDay: 80 + gardenOfEdenLatticeDivisor: 5 + gardenOfEdenLatticeDivisorPadding: 2 +cca: + view: + title: 'Cyclic Cellular Automaton' + subtitle: 'Cyclic Cellular Automaton' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 100 +randomwalk: + view: + title: 'Random Walk' + subtitle: 'Brownian Motion by Fractal Random Walk' + control: + threadSleepTime: 100 +dla: + view: + title: 'Diffusion Limited Aggregation' + subtitle: 'Fractal Random Walk due to Brownian Motion Cluster' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +kochsnowflake: + view: + title: 'Koch Snowflake' + subtitle: 'Fractal Koch Snowflake' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +samegame: + view: + title: 'Same Game' + subtitle: 'Play the Same Game' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +sierpinskitriangle: + view: + title: 'Sierpinski Triangle' + subtitle: 'Fractal Sierpinski Triangle' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +tetris: + view: + title: 'Tetris' + subtitle: 'Play Tetris' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +turmite: + view: + title: 'Turmite' + subtitle: 'Termites as Turing Machines with 2D Tape' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +wator: + view: + title: 'WaTor' + subtitle: 'Population Dynamics on Planet Water Torus' + buttonsZoom: 'Zoom In' + buttonsZoomOut: 'Zoom Out' + buttonsSwitch: 'Mandelbrot Set <-> Julia Set' + buttonsZoomLabel: 'Zoom' + buttonsLabel: 'Choose Mouse Click Mode' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +gameoflive: + view: + title: 'Conways Game of Life' + subtitle: 'Conways Game of Life Cellular Automaton' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/julia01.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/julia01.png new file mode 100644 index 00000000..804b50a0 Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/julia01.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/julia02.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/julia02.png new file mode 100644 index 00000000..ab30d135 Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/julia02.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/phasenraum_logo.gif b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/phasenraum_logo.gif new file mode 100644 index 00000000..3615d230 Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/phasenraum_logo.gif differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/screen01.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/screen01.png new file mode 100644 index 00000000..d4a4193c Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/screen01.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/screen02.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/screen02.png new file mode 100644 index 00000000..2a31ba74 Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/screen02.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/screen03.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/screen03.png new file mode 100644 index 00000000..a1fc854a Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/main/resources/img/screen03.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/markdown/About.md b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/markdown/About.md new file mode 100644 index 00000000..20b9b980 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/markdown/About.md @@ -0,0 +1,32 @@ +# Simulated Evolution +**Artificial Life Simulation of Bacteria Motion depending on DNA** + +## Abstract +Green food appears in a simulatedEvolutionModel with red moving cells. These cells eat the food if it is on their position. +Movement of the cells depends on random and their DNA. A fit cell moves around and eats enough to reproduce. +Reproduction is done by splitting the cell and randomly changing the DNA of the two new Cells. +If a cell doesn't eat enough, it will first stand still and after a while it dies. + + +## Run the Desktop Application +``` +git clone https://github.com/Computer-Kurzweil/simulated-evolution.git +cd simulated-evolution +mvnw +``` + +## Screenshot +### Early Screen +![Early Screen](src/main/resources/img/screen1.png) +### Later Screen +![Later Screen](src/main/resources/img/screen2.png) + + +## UML Class Model +![UML Class Model](src/main/resources/img/Class_Model.jpg) + +## Github Repository +[https://github.com/Computer-Kurzweil/simulated-evolution](https://github.com/Computer-Kurzweil/simulated-evolution) + +## Blog Article +[http://thomas-woehlke.blogspot.de/2016/01/simulated-evolution-artificial-life-and.html](http://thomas-woehlke.blogspot.de/2016/01/simulated-evolution-artificial-life-and.html) diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/Class_Model.jpg b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/Class_Model.jpg new file mode 100644 index 00000000..827d7bba Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/Class_Model.jpg differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/black.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/black.png new file mode 100644 index 00000000..6516a94c Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/black.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/blue.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/blue.png new file mode 100644 index 00000000..500b2779 Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/blue.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/dark_gray.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/dark_gray.png new file mode 100644 index 00000000..f25c5c9f Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/dark_gray.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/green.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/green.png new file mode 100644 index 00000000..a894e98c Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/green.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/light_gray.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/light_gray.png new file mode 100644 index 00000000..a9d04709 Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/light_gray.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/phasenraum_logo.gif b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/phasenraum_logo.gif new file mode 100644 index 00000000..3615d230 Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/phasenraum_logo.gif differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/red.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/red.png new file mode 100644 index 00000000..7e9a56cd Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/red.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/screen.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/screen.png new file mode 100644 index 00000000..fc4c797d Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/screen.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/screen1.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/screen1.png new file mode 100644 index 00000000..943cf1ba Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/screen1.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/screen2.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/screen2.png new file mode 100644 index 00000000..9ec3a2ed Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/screen2.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/yellow.png b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/yellow.png new file mode 100644 index 00000000..891de604 Binary files /dev/null and b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/resources/img/yellow.png differ diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/site.xml b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/site.xml new file mode 100644 index 00000000..3860ce74 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/site/site.xml @@ -0,0 +1,41 @@ + + + + org.apache.maven.skins + maven-default-skin + 1.3 + + + Simulated Evolution + /img/phasenraum_logo.gif + http://woehlke.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/ComplexNumberTest.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/ComplexNumberTest.java new file mode 100644 index 00000000..5d38f60c --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/ComplexNumberTest.java @@ -0,0 +1,75 @@ +package org.woehlke.computer.kurzweil.tabs.mandelbrot2julia; + + +import org.junit.jupiter.api.Test; +import org.woehlke.computer.kurzweil.commons.model.fractal.ComplexNumber; + +import java.util.logging.Logger; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * Created by tw on 24.08.15. + */ +public class ComplexNumberTest { + + public static Logger log = Logger.getLogger(ComplexNumberTest.class.getName()); + + @Test + public void computeMandelbrotTest1(){ + log.info("computeMandelbrotTest1 start"); + ComplexNumber complexNumber1 = new ComplexNumber(); + int iterations = complexNumber1.computeMandelbrotSet(); + log.info("computeMandelbrotTest1 iterations : "+ iterations); + assertTrue(complexNumber1.isInMandelbrotSet()); + assertNotEquals(ComplexNumber.MAX_ITERATIONS, iterations); + assertTrue(0 == iterations); + log.info("computeMandelbrotTest1 done"); + } + + @Test + public void computeMandelbrotTest2(){ + log.info("computeMandelbrotTest2 start"); + ComplexNumber complexNumber2 = new ComplexNumber(1.0d,1.2d); + int iterations = complexNumber2.computeMandelbrotSet(); + log.info("computeMandelbrotTest2 iterations : "+ iterations); + assertFalse(complexNumber2.isInMandelbrotSet()); + assertNotEquals(iterations, ComplexNumber.MAX_ITERATIONS); + assertTrue(iterations < ComplexNumber.MAX_ITERATIONS); + assertTrue(2 == iterations); + log.info("computeMandelbrotTest2 done"); + } + + @Test + public void computeJuliaTest1(){ + log.info("computeJuliaTest1 start"); + ComplexNumber z = new ComplexNumber(0.1d,0.2d); + ComplexNumber c = new ComplexNumber(0.2d,0.1d); + int iterations = z.computeJuliaSet(c); + log.info("computeJuliaTest1 iterations : "+ iterations); + boolean isInJuliaSet = z.isInJuliaSet(); + assertTrue(isInJuliaSet); + assertNotEquals(ComplexNumber.MAX_ITERATIONS, iterations); + assertTrue(iterations < ComplexNumber.MAX_ITERATIONS); + assertTrue(0 == iterations); + log.info("computeJuliaTest1 done"); + } + + @Test + public void computeJuliaTest2(){ + log.info("computeJuliaTest2 start"); + ComplexNumber z = new ComplexNumber(0.1d,0.2d); + ComplexNumber c = new ComplexNumber(1.0d,1.1d); + int iterations = z.computeJuliaSet(c); + log.info("computeJuliaTest2 iterations :"+ iterations); + boolean isInJuliaSet = z.isInJuliaSet(); + assertFalse(isInJuliaSet); + assertNotEquals(ComplexNumber.MAX_ITERATIONS, iterations); + assertTrue(iterations < ComplexNumber.MAX_ITERATIONS); + assertTrue(2 == iterations); + log.info("computeJuliaTest2 done"); + } +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringPositionsTest.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringPositionsTest.java new file mode 100644 index 00000000..37ab4392 --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringPositionsTest.java @@ -0,0 +1,46 @@ +package org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.model.turing; + + +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +public class TuringPositionsTest { + + public static Logger log = Logger.getLogger(TuringPositionsTest.class.getName()); + + @Test + public void startTest() { + log.info("startTest start"); + } + + @Test + public void markFirstSetPositionTest(){ + log.info("markFirstSetPositionTest start"); + + } + + @Test + public void goForwardTest() { + log.info("goForwardTest start"); + + } + + @Test + public void turnRightTest() { + log.info("turnRightTest start"); + + } + + @Test + public void turnLeftTest() { + log.info("turnLeftTest start"); + + } + + @Test + public void isFinishedWalkAroundTest() { + log.info("isFinishedWalkAroundTest start"); + + } +} diff --git a/single-apps/insourcing/insourcing-sierpinskitriangle/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringTuringPhaseStateEnumTest.java b/single-apps/insourcing/insourcing-sierpinskitriangle/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringTuringPhaseStateEnumTest.java new file mode 100644 index 00000000..2f2cadcc --- /dev/null +++ b/single-apps/insourcing/insourcing-sierpinskitriangle/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringTuringPhaseStateEnumTest.java @@ -0,0 +1,62 @@ +package org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.model.turing; + + +import org.junit.jupiter.api.Test; +import org.woehlke.computer.kurzweil.commons.model.turing.MandelbrotTuringPhaseState; + +import java.util.logging.Logger; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.woehlke.computer.kurzweil.commons.model.turing.MandelbrotTuringPhase.*; + +public class TuringTuringPhaseStateEnumTest { + + public static Logger log = Logger.getLogger(TuringPositionsTest.class.getName()); + private MandelbrotTuringPhaseState turingPhaseState = new MandelbrotTuringPhaseState(); + + @Test + public void startTest(){ + log.info("startTest start"); + turingPhaseState = new MandelbrotTuringPhaseState(); + assertEquals(turingPhaseState.getTuringTuringPhase(),SEARCH_THE_SET); + turingPhaseState.start(); + assertEquals(turingPhaseState.getTuringTuringPhase(),SEARCH_THE_SET); + log.info("startTest done"); + } + + @Test + public void finishGoToSetTest(){ + log.info("finishGoToSetTest start"); + turingPhaseState = new MandelbrotTuringPhaseState(); + turingPhaseState.start(); + assertEquals(turingPhaseState.getTuringTuringPhase(),SEARCH_THE_SET); + turingPhaseState.finishSearchTheSet(); + assertEquals(turingPhaseState.getTuringTuringPhase(),WALK_AROUND_THE_SET); + log.info("finishGoToSetTest done"); + } + + @Test + public void finishWalkAroundTest() { + log.info("finishWalkAroundTest start"); + turingPhaseState = new MandelbrotTuringPhaseState(); + turingPhaseState.start(); + turingPhaseState.finishSearchTheSet(); + assertEquals(turingPhaseState.getTuringTuringPhase(),WALK_AROUND_THE_SET); + turingPhaseState.finishWalkAround(); + assertEquals(turingPhaseState.getTuringTuringPhase(), FILL_THE_OUTSIDE_WITH_COLOR); + log.info("finishWalkAroundTest done"); + } + + @Test + public void finishFillTheOutsideWithColorsTest() { + log.info("finishFillTheOutsideWithColorsTest start"); + turingPhaseState = new MandelbrotTuringPhaseState(); + turingPhaseState.start(); + turingPhaseState.finishSearchTheSet(); + turingPhaseState.finishWalkAround(); + assertEquals(turingPhaseState.getTuringTuringPhase(), FILL_THE_OUTSIDE_WITH_COLOR); + turingPhaseState.finishFillTheOutsideWithColors(); + assertEquals(turingPhaseState.getTuringTuringPhase(), FINISHED); + log.info("finishFillTheOutsideWithColorsTest done"); + } +} diff --git a/single-apps/insourcing/insourcing-turmite/README.md b/single-apps/insourcing/insourcing-turmite/README.md new file mode 100644 index 00000000..8463bdda --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/README.md @@ -0,0 +1,56 @@ +# Wator + +**Wator Slogan** + +## Abstract: Wator + + +## More +* [https://en.wikipedia.org/wiki/Mandelbrot_set](https://en.wikipedia.org/wiki/Mandelbrot_set) +* [https://en.wikipedia.org/wiki/Julia_set](https://en.wikipedia.org/wiki/Julia_set) +* [https://en.wikipedia.org/wiki/Turing_machine](https://en.wikipedia.org/wiki/Turing_machine) + +## Screenshots + +### Running around the Edge of the Mandelbrot Set + +![Running around the Edge of the Mandelbrot Set](src/main/resources/img/screen01.png) + +### Running around the Edge of the Mandelbrot Set + +![Running around the Edge of the Mandelbrot Set](src/main/resources/img/screen02.png) + +### Computing the Area outside the Mandelbrot Set + +![Computing the Area outside the Mandelbrot Set](src/main/resources/img/screen03.png) + +### Clicked somewhere on the Edge of Mandelbrot Set: The Julia Set + +![Clicked somewhere on the Edge of Mandelbrot Set: The Julia Set](src/main/resources/img/julia01.png) + +### Clicked on another Point on the Edge of Mandelbrot Set: The Julia Set + +![Clicked on another Point on the Edge of Mandelbrot Set: The Julia Set](src/main/resources/img/julia02.png) + + +### Git Repository +* [https://github.com/thomaswoehlke/mandelbrot](https://github.com/thomaswoehlke/mandelbrot.git) + + +### Gradle Wrapper +* [https://docs.gradle.org/current/userguide/gradle_wrapper.html](https://docs.gradle.org/current/userguide/gradle_wrapper.html) + +### Run the Desktop Application +``` +git clone https://github.com/thomaswoehlke/mandelbrot.git +cd mandelbrot +./gradlew clean shadowJar runShadow +``` + +### Run the Applet Test +``` +git clone https://github.com/thomaswoehlke/mandelbrot.git +cd mandelbrot +TODO: xxx +``` + diff --git a/single-apps/insourcing/insourcing-turmite/pom.xml b/single-apps/insourcing/insourcing-turmite/pom.xml new file mode 100644 index 00000000..6925cf8d --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/pom.xml @@ -0,0 +1,127 @@ + + + 4.0.0 + + + org.woehlke.computer.kurzweil + insourcing + 2.2.8-SNAPSHOT + .. + + + insourcing-turmite + jar + + single-apps :: insourcing :: Turmite + Turmites - Turing Ants + + + org.woehlke.computer.kurzweil.TurmiteApplication + + + + + org.apache.logging.log4j + log4j-slf4j-impl + + + org.apache.logging.log4j + log4j-api + + + org.apache.logging.log4j + log4j-jcl + + + org.apache.logging.log4j + log4j-core + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.dataformat + jackson-dataformat-properties + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + + + com.fasterxml.jackson.dataformat + jackson-dataformat-ion + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-core + + + org.apache.commons + commons-lang3 + + + org.yaml + snakeyaml + + + com.google.guava + guava + + + javax.validation + validation-api + + + + + ${project.artifactId} + clean dependency:tree install exec:java + + + org.codehaus.mojo + exec-maven-plugin + + + + java + + + + + org.woehlke.computer.kurzweil.TurmiteApplication + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + org.woehlke.computer.kurzweil.TurmiteApplication + + + + + + org.apache.maven.plugins + maven-release-plugin + + clean + true + + + + + + diff --git a/single-apps/insourcing/insourcing-turmite/run.cmd b/single-apps/insourcing/insourcing-turmite/run.cmd new file mode 100644 index 00000000..726b9db4 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/run.cmd @@ -0,0 +1,2 @@ +cmd /c ..\..\mvnw -e clean install site +cmd /c ..\..\mvnw diff --git a/single-apps/insourcing/insourcing-turmite/run.sh b/single-apps/insourcing/insourcing-turmite/run.sh new file mode 100755 index 00000000..5d1cd68e --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/run.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + + +function site() { + ../../../mvnw -e site site:deploy +} + +function run() { + ../../../mvnw +} + +function main() { + #site + run +} + +main diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/TurmiteApplication.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/TurmiteApplication.java new file mode 100644 index 00000000..1d1c6c13 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/TurmiteApplication.java @@ -0,0 +1,33 @@ +package org.woehlke.computer.kurzweil; + +import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties; +import org.woehlke.computer.kurzweil.tabs.turmite.TurmiteTab; + +import java.io.File; +import java.net.URL; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + */ +public class TurmiteApplication { + + private TurmiteApplication() { + String configFileName = "/application.yml"; + URL fileUrl = getClass().getResource(configFileName); + File configFile = new File(fileUrl.getFile()); + ComputerKurzweilProperties properties = ComputerKurzweilProperties.propertiesFactory(configFile); + TurmiteTab frame = new TurmiteTab(properties); + } + + /** + * Starting the Application. + * @param args CLI Parameter + */ + public static void main(String[] args) { + TurmiteApplication application = new TurmiteApplication(); + } +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/application/ComputerKurzweilProperties.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/application/ComputerKurzweilProperties.java new file mode 100644 index 00000000..2c2cda7f --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/application/ComputerKurzweilProperties.java @@ -0,0 +1,600 @@ +package org.woehlke.computer.kurzweil.application; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import lombok.*; +import lombok.extern.log4j.Log4j2; +import org.woehlke.computer.kurzweil.tabs.TabType; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +@Log4j2 +@ToString +@EqualsAndHashCode +@NoArgsConstructor +@AllArgsConstructor +@Valid +////@Validated +public class ComputerKurzweilProperties { + + @Valid @Getter @Setter public Allinone allinone = new Allinone(); + @Valid @Getter @Setter public Mandelbrot mandelbrot = new Mandelbrot(); + @Valid @Getter @Setter public MandelbrotZoom mandelbrotZoom = new MandelbrotZoom(); + @Valid @Getter @Setter public SimulatedEvolution simulatedevolution = new SimulatedEvolution(); + @Valid @Getter @Setter public Cca cca = new Cca(); + @Valid @Getter @Setter public WienerProcess randomwalk = new WienerProcess(); + @Valid @Getter @Setter public Dla dla = new Dla(); + @Valid @Getter @Setter public Kochsnowflake kochsnowflake = new Kochsnowflake(); + @Valid @Getter @Setter public Samegame samegame = new Samegame(); + @Valid @Getter @Setter public Sierpinskitriangle sierpinskitriangle = new Sierpinskitriangle(); + @Valid @Getter @Setter public Tetris tetris = new Tetris(); + @Valid @Getter @Setter public Turmite turmite = new Turmite(); + @Valid @Getter @Setter public Wator wator = new Wator(); + @Valid @Getter @Setter public Gameoflive gameoflive = new Gameoflive(); + + public static ComputerKurzweilProperties propertiesFactory(File conf){ + log.info("propertiesFactory"); + log.info("propertiesFactory conf: "+conf.getAbsolutePath()); + ComputerKurzweilProperties properties; + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + try { + InputStream input = new FileInputStream(conf); + properties = mapper.readValue(input, ComputerKurzweilProperties.class); + log.info(properties.toString()); + } catch (Exception e) { + e.printStackTrace(); + properties = new ComputerKurzweilProperties(); + } + log.info("propertiesFactory done"); + return properties; + } + + public static ComputerKurzweilProperties propertiesFactory(String conf, String jar){ + log.info("propertiesFactory"); + log.info("propertiesFactory conf: "+conf); + log.info("propertiesFactory jar: "+jar); + ComputerKurzweilProperties properties; + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + try { + JarFile jarFile = new JarFile(jar); + JarEntry entry = jarFile.getJarEntry(conf); + InputStream input = jarFile.getInputStream(entry); + properties = mapper.readValue(input, ComputerKurzweilProperties.class); + log.info(properties.toString()); + } catch (Exception e) { + e.printStackTrace(); + properties = new ComputerKurzweilProperties(); + } + log.info("propertiesFactory done"); + return properties; + } + + public String getSubtitle(TabType tabType){ + switch (tabType){ + case CYCLIC_CELLULAR_AUTOMATON: + return this.getCca().getView().getSubtitle(); + case DIFFUSION_LIMITED_AGGREGATION: + return this.getDla().getView().getSubtitle(); + case SIMULATED_EVOLUTION: + return this.getSimulatedevolution().getView().getSubtitle(); + case MANDELBROT_SET: + return this.getMandelbrot().getView().getSubtitle(); + case RANDOM_WALK_WIENER_PROCESS: + return this.getRandomwalk().getView().getSubtitle(); + case KOCH_SNOWFLAKE: + return this.getKochsnowflake().getView().getSubtitle(); + case SAME_GAME: + return this.getSamegame().getView().getSubtitle(); + case SIERPINSKI_TRIANGLE: + return this.getSierpinskitriangle().getView().getSubtitle(); + case TETRIS: + return this.getTetris().getView().getSubtitle(); + case TURMITE: + return this.getTurmite().getView().getSubtitle(); + case WATOR: + return this.getWator().getView().getSubtitle(); + case CONWAYS_GAME_OF_LIFE: + return this.getGameoflive().getView().getSubtitle(); + default: + return "UNDEFINED"; + } + } + + public String getTitle(TabType tabType){ + switch (tabType){ + case CYCLIC_CELLULAR_AUTOMATON: + return this.getCca().getView().getTitle(); + case DIFFUSION_LIMITED_AGGREGATION: + return this.getDla().getView().getTitle(); + case SIMULATED_EVOLUTION: + return this.getSimulatedevolution().getView().getTitle(); + case MANDELBROT_SET: + return this.getMandelbrot().getView().getTitle(); + case RANDOM_WALK_WIENER_PROCESS: + return this.getRandomwalk().getView().getTitle(); + case KOCH_SNOWFLAKE: + return this.getKochsnowflake().getView().getTitle(); + case SAME_GAME: + return this.getSamegame().getView().getTitle(); + case SIERPINSKI_TRIANGLE: + return this.getSierpinskitriangle().getView().getTitle(); + case TETRIS: + return this.getTetris().getView().getTitle(); + case TURMITE: + return this.getTurmite().getView().getTitle(); + case WATOR: + return this.getWator().getView().getTitle(); + case CONWAYS_GAME_OF_LIFE: + return this.getGameoflive().getView().getTitle(); + default: + return "UNDEFINED"; + } + } + + ////@Validated + @ToString + public static class Allinone { + + @Valid @Getter @Setter public Lattice lattice = new Lattice(); + @Valid @Getter @Setter public View view = new View(); + + ////@Validated + @ToString + public static class Lattice { + @NotNull @Getter @Setter private Integer width; + @NotNull @Getter @Setter private Integer height; + } + + ////@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + @NotBlank @Getter @Setter private String copyright; + @NotNull @Getter @Setter private Integer borderPaddingX; + @NotNull @Getter @Setter private Integer borderPaddingY; + @NotNull @Getter @Setter private Integer titleHeight; + @NotBlank @Getter @Setter private String startStopp; + @NotBlank @Getter @Setter private String start; + @NotBlank @Getter @Setter private String stop; + @NotBlank @Getter @Setter private String info; + } + } + + ////@Validated + @ToString + public static class Mandelbrot { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + ////@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + @NotBlank @Getter @Setter private String buttonsZoom; + @NotBlank @Getter @Setter private String buttonsZoomOut; + @NotBlank @Getter @Setter private String buttonsSwitch; + @NotBlank @Getter @Setter private String buttonsZoomLabel; + @NotBlank @Getter @Setter private String buttonsLabel; + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + } + } + + ////@Validated + @ToString + public static class MandelbrotZoom { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + ////@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + @NotBlank @Getter @Setter private String buttonsZoom; + @NotBlank @Getter @Setter private String buttonsZoomOut; + @NotBlank @Getter @Setter private String buttonsSwitch; + @NotBlank @Getter @Setter private String buttonsZoomLabel; + @NotBlank @Getter @Setter private String buttonsLabel; + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + } + } + + ////@Validated + @ToString + public static class SimulatedEvolution { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + @Valid @Getter @Setter public CellConf cellConf = new CellConf(); + @Valid @Getter @Setter public Population population = new Population(); + @Valid @Getter @Setter public Food food = new Food(); + @Valid @Getter @Setter public GardenOfEden gardenOfEden = new GardenOfEden(); + + ////@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer exitStatus; + @NotNull @Getter @Setter private Integer queueMaxLength; + } + + ////@Validated + @ToString + public static class CellConf { + @NotNull @Getter @Setter private Integer fatMax; + @NotNull @Getter @Setter private Integer fatHungerMax; + @NotNull @Getter @Setter private Integer fatMinimumForSex; + @NotNull @Getter @Setter private Integer fatAtBirth; + @NotNull @Getter @Setter private Integer fatPerFood; + @NotNull @Getter @Setter private Integer ageOfAdulthood; + @NotNull @Getter @Setter private Integer ageOld; + @NotNull @Getter @Setter private Integer ageMax; + } + + ////@Validated + @ToString + public static class Population { + @NotNull @Getter @Setter private Integer initialPopulation; + @NotBlank @Getter @Setter private String panelPopulationStatistics; + @NotBlank @Getter @Setter private String panelLifeCycleStatistics; + @NotBlank @Getter @Setter private String youngCellsLabel; + @NotBlank @Getter @Setter private String youngAndFatCellsLabel; + @NotBlank @Getter @Setter private String fullAgeCellsLabel; + @NotBlank @Getter @Setter private String hungryCellsLabel; + @NotBlank @Getter @Setter private String oldCellsLabel; + @NotBlank @Getter @Setter private String populationLabel; + @NotBlank @Getter @Setter private String generationOldestLabel; + @NotBlank @Getter @Setter private String generationYoungestLabel; + } + + ////@Validated + @ToString + public static class Food { + @NotNull @Getter @Setter private Integer foodPerDay; + @NotNull @Getter @Setter private Integer foodPerDayFieldColumns; + @NotBlank @Getter @Setter private String foodPerDayLabel; + @NotBlank @Getter @Setter private String foodPerDayBorderLabel; + @NotBlank @Getter @Setter private String buttonFoodPerDayIncrease; + @NotBlank @Getter @Setter private String buttonFoodPerDayDecrease; + @NotBlank @Getter @Setter private String panelFood; + } + + ////@Validated + @ToString + public static class GardenOfEden { + @NotBlank @Getter @Setter private String panelGardenOfEden; + @NotNull @Getter @Setter private Boolean gardenOfEdenEnabled; + @NotBlank @Getter @Setter private String gardenOfEdenEnabledString; + @NotBlank @Getter @Setter private String gardenOfEdenEnabledToggleButton; + @NotNull @Getter @Setter private Integer foodPerDay; + @NotNull @Getter @Setter private Integer gardenOfEdenLatticeDivisor; + @NotNull @Getter @Setter private Integer gardenOfEdenLatticeDivisorPadding; + } + } + + ////@Validated + @ToString + public static class Cca { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + } + } + + ////@Validated + @ToString + public static class WienerProcess { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + } + + ////@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + } + } + + //@Validated + @ToString + public static class Dla { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Kochsnowflake { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Samegame { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Sierpinskitriangle { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Tetris { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Turmite { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Wator { + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public Neighborhood neighborhood = new Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + @NotBlank @Getter @Setter private String buttonsZoom; + @NotBlank @Getter @Setter private String buttonsZoomOut; + @NotBlank @Getter @Setter private String buttonsSwitch; + @NotBlank @Getter @Setter private String buttonsZoomLabel; + @NotBlank @Getter @Setter private String buttonsLabel; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } + + @ToString + public static class Gameoflive{ + + @Valid @Getter @Setter public View view = new View(); + @Valid @Getter @Setter public Control control = new Control(); + + //@Validated + @ToString + public static class View { + @Valid @Getter @Setter public ComputerKurzweilProperties.Wator.View.Neighborhood neighborhood = new Wator.View.Neighborhood(); + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String subtitle; + + //@Validated + @ToString + public static class Neighborhood { + @NotBlank @Getter @Setter private String title; + @NotBlank @Getter @Setter private String typeVonNeumann; + @NotBlank @Getter @Setter private String typeMoore; + @NotBlank @Getter @Setter private String typeWoehlke; + } + } + + //@Validated + @ToString + public static class Control { + @NotNull @Getter @Setter private Integer threadSleepTime; + @NotNull @Getter @Setter private Integer numberOfParticles; + } + } +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/ComplexNumber.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/ComplexNumber.java new file mode 100644 index 00000000..5e68767a --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/ComplexNumber.java @@ -0,0 +1,133 @@ +package org.woehlke.computer.kurzweil.commons.model.fractal; + +import java.util.Objects; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 18.08.15. + */ +public class ComplexNumber { + + public final static int MAX_ITERATIONS = 64; + private final static double DIVERGENCE_THRESHOLD = 4.0d; + private volatile double real; + private volatile double img; + private volatile int iterations; + private volatile boolean inMandelbrotSet; + private volatile boolean inJuliaSet; + + public ComplexNumber() { + this.real = 0.0d; + this.img = 0.0d; + this.iterations=0; + this.inMandelbrotSet=false; + this.inJuliaSet=false; + } + + public ComplexNumber(ComplexNumber complexNumber) { + this.real = complexNumber.real; + this.img = complexNumber.img; + this.iterations=complexNumber.iterations; + this.inMandelbrotSet=complexNumber.inMandelbrotSet; + this.inJuliaSet=complexNumber.inJuliaSet; + } + + public ComplexNumber(double real, double img) { + this.real = real; + this.img = img; + this.iterations=0; + this.inMandelbrotSet=false; + this.inJuliaSet=false; + } + + public double getReal() { + return real; + } + + public double getImg() { + return img; + } + + public ComplexNumber plus(ComplexNumber complexNumber){ + double newRealZ = this.real + complexNumber.real; + double newImgZ = this.img + complexNumber.img; + return new ComplexNumber(newRealZ,newImgZ); + } + + public ComplexNumber square(){ + double realZ=real; + double imgZ=img; + double newRealZ=realZ*realZ-imgZ*imgZ; + double newImgZ=2*realZ*imgZ; + return new ComplexNumber(newRealZ,newImgZ); + } + + public synchronized int computeMandelbrotSet() { + int iterationsTmp = 0; + ComplexNumber z = new ComplexNumber(); + do { + iterationsTmp++; + z = z.square().plus(this); + } while (z.isNotDivergent() && (iterationsTmp < MAX_ITERATIONS)); + this.inMandelbrotSet = z.isNotDivergent(); + this.iterations = this.inMandelbrotSet?0:iterationsTmp; + return this.iterations; + } + + public synchronized int computeJuliaSet(ComplexNumber c) { + int iterationsTmp = 0; + ComplexNumber z = new ComplexNumber(this); + do { + iterationsTmp++; + z = z.square().plus(c); + } while (z.isNotDivergent() && (iterationsTmp < MAX_ITERATIONS)); + this.inJuliaSet = z.isNotDivergent(); + this.iterations = this.inJuliaSet?0:iterationsTmp; + return this.iterations; + } + + public synchronized boolean isInMandelbrotSet() { + return inMandelbrotSet; + } + + public synchronized boolean isInJuliaSet() { + return inJuliaSet; + } + + public synchronized boolean isNotDivergent(){ + return (( real*real + img*img ) < DIVERGENCE_THRESHOLD); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ComplexNumber)) return false; + ComplexNumber that = (ComplexNumber) o; + return Double.compare(that.getReal(), getReal()) == 0 && + Double.compare(that.getImg(), getImg()) == 0 && + iterations == that.iterations && + isInMandelbrotSet() == that.isInMandelbrotSet() && + isInJuliaSet() == that.isInJuliaSet(); + } + + @Override + public int hashCode() { + return Objects.hash(getReal(), getImg(), iterations, isInMandelbrotSet(), isInJuliaSet()); + } + + @Override + public String toString() { + return "ComplexNumber{" + + "real=" + real + + ", img=" + img + + ", iterations=" + iterations + + ", inMandelbrotSet=" + inMandelbrotSet + + ", inJuliaSet=" + inJuliaSet + + '}'; + } +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/GaussianNumberPlane.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/GaussianNumberPlane.java new file mode 100644 index 00000000..22b6ee1b --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/fractal/GaussianNumberPlane.java @@ -0,0 +1,222 @@ +package org.woehlke.computer.kurzweil.commons.model.fractal; + +import org.woehlke.computer.kurzweil.tabs.turmite.TurmiteModel; +import org.woehlke.computer.kurzweil.commons.model.turing.Point; + +import java.util.ArrayDeque; +import java.util.Deque; +//import java.util.logging.Logger; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class GaussianNumberPlane { + + public final static int YET_UNCOMPUTED = -1; + private final static double complexWorldDimensionRealX = 3.2d; + private final static double complexWorldDimensionImgY = 2.34d; + private final static double complexCenterForMandelbrotRealX = -2.2f; + private final static double complexCenterForMandelbrotImgY = -1.17f; + private final static double complexCenterForJuliaRealX = -1.6d; + private final static double complexCenterForJuliaImgY = -1.17d; + private final Point worldDimensions; + public volatile int zoomLevel; + private volatile int[][] lattice; + private volatile ComplexNumber complexNumberForJuliaSetC; + private volatile ComplexNumber complexWorldDimensions; + private volatile ComplexNumber complexCenterForMandelbrot; + private volatile ComplexNumber complexCenterForJulia; + private volatile Deque complexCenterForZoomedMandelbrot = new ArrayDeque<>(); + + private volatile ComplexNumber zoomCenter; + + + //public static Logger log = Logger.getLogger(GaussianNumberPlane.class.getName()); + + public GaussianNumberPlane(TurmiteModel model) { + this.worldDimensions = model.getWorldDimensions(); + this.lattice = new int[worldDimensions.getWidth()][worldDimensions.getHeight()]; + this.complexWorldDimensions = new ComplexNumber( + complexWorldDimensionRealX, + complexWorldDimensionImgY + ); + this.complexCenterForMandelbrot = new ComplexNumber( + complexCenterForMandelbrotRealX, + complexCenterForMandelbrotImgY + ); + this.complexCenterForJulia = new ComplexNumber( + complexCenterForJuliaRealX, + complexCenterForJuliaImgY + ); + start(); + } + + public void setModeZoom() { + this.setZoomLevel(1); + this.setZoomCenter(complexCenterForMandelbrot); + } + + public synchronized void start(){ + zoomLevel = 1; + for(int y = 0;y < this.worldDimensions.getY(); y++){ + for(int x=0; x < worldDimensions.getX(); x++){ + lattice[x][y] = YET_UNCOMPUTED; + } + } + } + + public synchronized int getCellStatusFor(int x,int y){ + return (lattice[x][y])<0?0:lattice[x][y]; + } + + private synchronized ComplexNumber getComplexNumberFromLatticeCoordsForJulia(Point turingPosition) { + double realX = complexCenterForJulia.getReal() + + (complexWorldDimensions.getReal()*turingPosition.getX())/worldDimensions.getX(); + double imgY = complexCenterForJulia.getImg() + + (complexWorldDimensions.getImg()*turingPosition.getY())/worldDimensions.getY(); + return new ComplexNumber(realX,imgY); + } + + private synchronized ComplexNumber getComplexNumberFromLatticeCoordsForMandelbrot(Point turingPosition) { + double realX = ( + complexCenterForMandelbrot.getReal() + + ( complexWorldDimensions.getReal() * turingPosition.getX() ) + / worldDimensions.getX() + ); + double imgY = ( + complexCenterForMandelbrot.getImg() + + ( complexWorldDimensions.getImg() * turingPosition.getY() ) + / worldDimensions.getY() + ); + return new ComplexNumber(realX,imgY); + } + + private synchronized ComplexNumber getComplexNumberFromLatticeCoordsForZoomedMandelbrot(Point turingPosition) { + double realX = ( + ( complexCenterForMandelbrot.getReal() / this.getZoomLevel() ) + + getZoomCenter().getReal() + + ( complexWorldDimensions.getReal() * turingPosition.getX() ) + / ( worldDimensions.getX() * this.getZoomLevel() ) + ); + double imgY = ( + ( complexCenterForMandelbrot.getImg() / this.getZoomLevel() ) + + getZoomCenter().getImg() + + ( complexWorldDimensions.getImg() * turingPosition.getY() ) + / ( worldDimensions.getY() * this.getZoomLevel() ) + ); + 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); + lattice[turingPosition.getX()][turingPosition.getY()] = position.computeMandelbrotSet(); + return position.isInMandelbrotSet(); + } + + public synchronized void fillTheOutsideWithColors(){ + for(int y=0;y1){ + this.deceaseZoomLevel(); + this.setZoomCenter(complexCenterForZoomedMandelbrot.pop()); + } + //log.info("zoomCenter: " + this.getZoomCenter() + " - zoomLevel: "+ this.getZoomLevel()); + for(int y = 0; y < worldDimensions.getY(); y++){ + for(int x = 0; x < worldDimensions.getX(); x++){ + Point p = new Point(x, y); + this.isInZooomedMandelbrotSet(p); + } + } + } + + public void zoomIntoTheJuliaSetFor(Point zoomPoint) { + ComplexNumber c = this.complexNumberForJuliaSetC; + computeTheJuliaSetForC(c); + } + + public void zoomOutOfTheJuliaSet() { + } + + public synchronized int getZoomLevel() { + return zoomLevel; + } + + public synchronized void setZoomLevel(int zoomLevel) { + this.zoomLevel = zoomLevel; + } + + public synchronized int inceaseZoomLevel() { + return zoomLevel *= 2; + } + + public synchronized int deceaseZoomLevel() { + return zoomLevel /= 2; + } + + public synchronized ComplexNumber getZoomCenter() { + return zoomCenter; + } + + public synchronized void setZoomCenter(ComplexNumber zoomCenter) { + this.zoomCenter = zoomCenter; + } + +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringDirection.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringDirection.java new file mode 100644 index 00000000..bd799fa1 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringDirection.java @@ -0,0 +1,17 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 18.08.15. + */ +public enum MandelbrotTuringDirection { + UP, + RIGHT, + DOWN, + LEFT +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringMachine.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringMachine.java new file mode 100644 index 00000000..0d2820c6 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringMachine.java @@ -0,0 +1,81 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +import org.woehlke.computer.kurzweil.tabs.turmite.TurmiteModel; +import org.woehlke.computer.kurzweil.commons.model.fractal.GaussianNumberPlane; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Date: 28.08.13 + * Time: 12:39 + */ +public class MandelbrotTuringMachine { + + private volatile GaussianNumberPlane gaussianNumberPlane; + private volatile MandelbrotTuringPositions turingPositions; + private volatile MandelbrotTuringPhaseState turingPhaseState; + + public MandelbrotTuringMachine(TurmiteModel model) { + this.gaussianNumberPlane = model.getGaussianNumberPlane(); + this.turingPhaseState = new MandelbrotTuringPhaseState(); + this.turingPositions = new MandelbrotTuringPositions(model.getWorldDimensions()); + start(); + } + + public void start() { + this.turingPhaseState.start(); + this.gaussianNumberPlane.start(); + this.turingPositions.start(); + } + + public synchronized boolean step() { + boolean repaint=true; + switch(turingPhaseState.getTuringTuringPhase()){ + case SEARCH_THE_SET: + stepGoToSet(); + repaint=false; + break; + case WALK_AROUND_THE_SET: + stepWalkAround(); + break; + case FILL_THE_OUTSIDE_WITH_COLOR: + fillTheOutsideWithColors(); + break; + case FINISHED: + default: + repaint=false; + break; + } + return repaint; + } + + private void stepGoToSet(){ + if(this.gaussianNumberPlane.isInMandelbrotSet(this.turingPositions.getTuringPosition())){ + this.turingPositions.markFirstSetPosition(); + this.turingPhaseState.finishSearchTheSet(); + } else { + this.turingPositions.goForward(); + } + } + + private void stepWalkAround(){ + if(gaussianNumberPlane.isInMandelbrotSet(this.turingPositions.getTuringPosition())){ + this.turingPositions.turnRight(); + } else { + this.turingPositions.turnLeft(); + } + this.turingPositions.goForward(); + if(this.turingPositions.isFinishedWalkAround()){ + this.turingPhaseState.finishWalkAround(); + } + } + + private void fillTheOutsideWithColors(){ + this.gaussianNumberPlane.fillTheOutsideWithColors(); + this.turingPhaseState.finishFillTheOutsideWithColors(); + } +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhase.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhase.java new file mode 100644 index 00000000..cff085ea --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhase.java @@ -0,0 +1,17 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 18.08.15. + */ +public enum MandelbrotTuringPhase { + SEARCH_THE_SET, + WALK_AROUND_THE_SET, + FILL_THE_OUTSIDE_WITH_COLOR, + FINISHED +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhaseState.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhaseState.java new file mode 100644 index 00000000..0fce7646 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPhaseState.java @@ -0,0 +1,39 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class MandelbrotTuringPhaseState { + + private volatile MandelbrotTuringPhase turingTuringPhase; + + public MandelbrotTuringPhaseState() { + start(); + } + + public void start(){ + this.turingTuringPhase = MandelbrotTuringPhase.SEARCH_THE_SET; + } + + public void finishSearchTheSet(){ + turingTuringPhase = MandelbrotTuringPhase.WALK_AROUND_THE_SET; + } + + public void finishWalkAround() { + turingTuringPhase = MandelbrotTuringPhase.FILL_THE_OUTSIDE_WITH_COLOR; + } + + public void finishFillTheOutsideWithColors() { + turingTuringPhase = MandelbrotTuringPhase.FINISHED; + } + + public MandelbrotTuringPhase getTuringTuringPhase() { + return turingTuringPhase; + } +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPositions.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPositions.java new file mode 100644 index 00000000..889a592e --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/MandelbrotTuringPositions.java @@ -0,0 +1,90 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class MandelbrotTuringPositions { + + private volatile Point turingPosition; + private volatile Point worldDimensions; + private volatile Point firstSetPosition; + + private volatile MandelbrotTuringDirection turingDirection; + + private volatile int steps; + + public MandelbrotTuringPositions(Point worldDimensions) { + this.worldDimensions = worldDimensions; + start(); + } + + public void start() { + this.steps = 0; + this.turingPosition = new Point((worldDimensions.getX()-2),(worldDimensions.getY()/2+11)); + this.turingDirection = MandelbrotTuringDirection.LEFT; + } + + public synchronized void markFirstSetPosition(){ + this.firstSetPosition = turingPosition; + this.steps = 0; + } + + public synchronized Point getTuringPosition() { + return turingPosition; + } + + public synchronized void goForward() { + this.steps++; + switch (this.turingDirection){ + case UP: + this.turingPosition.moveUp(); + break; + case RIGHT: + this.turingPosition.moveRight(); + break; + case DOWN: + this.turingPosition.moveDown(); + break; + case LEFT: + this.turingPosition.moveLeft(); + break; + default: + break; + } + } + + public synchronized void turnRight() { + MandelbrotTuringDirection newTuringDirection; + switch (this.turingDirection){ + case UP: newTuringDirection = MandelbrotTuringDirection.RIGHT; break; + case RIGHT: newTuringDirection = MandelbrotTuringDirection.DOWN; break; + case DOWN: newTuringDirection = MandelbrotTuringDirection.LEFT; break; + case LEFT: newTuringDirection = MandelbrotTuringDirection.UP; break; + default: newTuringDirection = this.turingDirection; break; + } + this.turingDirection = newTuringDirection; + } + + public synchronized void turnLeft() { + MandelbrotTuringDirection newTuringDirection; + switch (this.turingDirection){ + case UP: newTuringDirection = MandelbrotTuringDirection.LEFT; break; + case RIGHT: newTuringDirection = MandelbrotTuringDirection.UP; break; + case DOWN: newTuringDirection = MandelbrotTuringDirection.RIGHT; break; + case LEFT: newTuringDirection = MandelbrotTuringDirection.DOWN; break; + default: newTuringDirection = this.turingDirection; break; + } + this.turingDirection = newTuringDirection; + } + + public synchronized boolean isFinishedWalkAround() { + return (this.turingPosition.equals(this.firstSetPosition)) && (this.steps>100); + } + +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/Point.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/Point.java new file mode 100644 index 00000000..a5da8333 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/model/turing/Point.java @@ -0,0 +1,91 @@ +package org.woehlke.computer.kurzweil.commons.model.turing; + +import java.util.Objects; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Date: 04.02.2006 + * Time: 23:47:05 + */ +public class Point { + + private volatile int x = 0; + private volatile int y = 0; + + public Point() { + } + + public Point(Point p) { + this.x = p.getX(); + this.y = p.getY(); + } + + public Point(int x, int y) { + this.x = x; + this.y = y; + } + + public void moveUp() { + y--; + } + + public void moveRight() { + x++; + } + + public void moveDown() { + y++; + } + + public void moveLeft() { + x--; + } + + public int getWidth(){ + return x; + } + public int getHeight() { return y; } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Point)) return false; + Point point = (Point) o; + return getX() == point.getX() && + getY() == point.getY(); + } + + @Override + public int hashCode() { + return Objects.hash(getX(), getY()); + } + + @Override + public String toString() { + return "Point{" + + "x=" + x + + ", y=" + y + + '}'; + } +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelButtons.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelButtons.java new file mode 100644 index 00000000..60b8e1f5 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelButtons.java @@ -0,0 +1,69 @@ +package org.woehlke.computer.kurzweil.commons.ui; + +import org.woehlke.computer.kurzweil.tabs.turmite.TurmiteModel; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class PanelButtons extends JPanel implements ActionListener { + + //private volatile JRadioButton radioButtonsSwitch; + //private volatile JRadioButton radioButtonsZoom; + private volatile JButton zoomOut; + //private volatile ButtonGroup radioButtonsGroup; + private volatile TurmiteModel model; + + public PanelButtons(TurmiteModel model) { + this.model = model; + JLabel buttonsLabel = new JLabel(model.getProperties().getWator().getView().getButtonsLabel()); + /* + this.radioButtonsSwitch = new JRadioButton(model.getProperties().getMandelbrot().getView().getButtonsSwitch()); + this.radioButtonsSwitch.setMnemonic(RADIO_BUTTONS_SWITCH.ordinal()); + this.radioButtonsSwitch.setSelected(true); + this.radioButtonsSwitch.addActionListener(this); + this.radioButtonsZoom = new JRadioButton(model.getProperties().getMandelbrot().getView().getButtonsSwitch()); + this.radioButtonsZoom.setMnemonic(RADIO_BUTTONS_ZOOM.ordinal()); + this.radioButtonsZoom.addActionListener(this); + this.radioButtonsGroup = new ButtonGroup(); + this.radioButtonsGroup.add(radioButtonsSwitch); + this.radioButtonsGroup.add(radioButtonsZoom); + */ + this.zoomOut = new JButton(model.getProperties().getWator().getView().getButtonsZoomOut()); + this.zoomOut.addActionListener(this); + FlowLayout layout = new FlowLayout(); + this.setLayout(layout); + this.add(buttonsLabel); + //this.add(radioButtonsSwitch); + //this.add(radioButtonsZoom); + this.add(zoomOut); + } + + /** + * TODO write doc. + */ + @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){ + this.model.zoomOut(); + this.model.getFrame().getCanvas().repaint(); + } + } +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java new file mode 100644 index 00000000..4fae16fd --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelCopyright.java @@ -0,0 +1,22 @@ +package org.woehlke.computer.kurzweil.commons.ui; + +import javax.swing.*; +import java.awt.*; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class PanelCopyright extends JPanel { + + public PanelCopyright(String subtitle) { + this.setLayout(new FlowLayout()); + this.add(new JLabel(subtitle)); + } + +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java new file mode 100644 index 00000000..fb044e95 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/ui/PanelSubtitle.java @@ -0,0 +1,22 @@ +package org.woehlke.computer.kurzweil.commons.ui; + +import javax.swing.*; +import java.awt.*; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class PanelSubtitle extends JPanel { + + public PanelSubtitle(String subtitle) { + this.setLayout(new FlowLayout()); + this.add(new JLabel(subtitle)); + } + +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/ui/RadioButtons.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/ui/RadioButtons.java new file mode 100644 index 00000000..548ff108 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/commons/ui/RadioButtons.java @@ -0,0 +1,15 @@ +package org.woehlke.computer.kurzweil.commons.ui; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public enum RadioButtons { + RADIO_BUTTONS_SWITCH, + RADIO_BUTTONS_ZOOM +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/TabType.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/TabType.java new file mode 100644 index 00000000..6473614f --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/TabType.java @@ -0,0 +1,109 @@ +package org.woehlke.computer.kurzweil.tabs; + +import lombok.Getter; + +import java.awt.event.KeyEvent; + +@Getter +public enum TabType { + + CYCLIC_CELLULAR_AUTOMATON( + KeyEvent.VK_1, + true, + "Cyclic Cellular Automaton", + "Cyclic Cellular Automaton", + "Cyclic Cellular Automaton" + ), + DIFFUSION_LIMITED_AGGREGATION( + KeyEvent.VK_2, + true, + "Diffusion Limited Aggregation", + "Fractal Random Walk due to Brownian Motion Cluster", + "Diffusion Limited Aggregation. Fractal Random Walk due to Brownian Motion Cluster" + ), + SIMULATED_EVOLUTION( + KeyEvent.VK_3, + true, + "Simulated Evolution", + "Artificial Life Simulation of Bacteria Motion depending on DNA and their Evolution", + "Artificial Life Simulation of Bacteria Motion depending on DNA and their Evolution" + ), + MANDELBROT_SET( + KeyEvent.VK_4, + true, + "Mandelbrot Set", + "Fractal Mandelbrot Set drawn by a Turing Machine", + "Fractal Mandelbrot Set drawn by a Turing Machine" + ), + RANDOM_WALK_WIENER_PROCESS( + KeyEvent.VK_5, + true, + "Random Walk", + "Brownian Motion by Fractal Random Walk", + "Random Walk. Brownian Motion by Fractal Random Walk" + ), + KOCH_SNOWFLAKE( + KeyEvent.VK_6, + false, + "Koch Snowflake", + "Fractal Koch Snowflake", + "Fractal Koch Snowflake" + ), + SAME_GAME( + KeyEvent.VK_7, + false, + "Same Game", + "Play the Same Game", + "Play the Same Game" + ), + SIERPINSKI_TRIANGLE( + KeyEvent.VK_0, + false, + "Sierpinski Triangle'", + "Fractal Sierpinski Triangle", + "Fractal Sierpinski Triangle" + ), + TETRIS( + KeyEvent.VK_8, + false, + "Tetris", + "Play Tetris", + "Play Tetris" + ), + TURMITE( + KeyEvent.VK_9, + false, + "Turmite", + "Turmites as Turing Machines with 2D Tape", + "Turmites as Turing Machines with 2D Tape" + ), + WATOR( + KeyEvent.VK_A, + false, + "WaTor", + "Population Dynamics on Planet Water Torus", + "Population Dynamics on Planet Water Torus" + ), + CONWAYS_GAME_OF_LIFE( + KeyEvent.VK_B, + false, + "Conways Game of Life", + "Conways Game of Life Cellular Automaton", + "Conways Game of Life Cellular Automaton" + ); + + private int keyEvent; + private boolean active; + private String title; + private String subTitle; + private String tooltip; + + TabType(int keyEvent, boolean active, String title, String subTitle, String tooltip){ + this.keyEvent=keyEvent; + this.active=active; + this.title=title; + this.subTitle=subTitle; + this.tooltip=tooltip; + } + +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/TurmiteCanvas.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/TurmiteCanvas.java new file mode 100644 index 00000000..e79dfea3 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/TurmiteCanvas.java @@ -0,0 +1,52 @@ +package org.woehlke.computer.kurzweil.tabs.turmite; + +import javax.swing.*; +import java.awt.*; + + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2013 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Date: 05.02.2006 + * Time: 00:51:51 + */ +public class TurmiteCanvas extends JComponent { + + private volatile TurmiteModel app; + private volatile Dimension preferredSize; + + public TurmiteCanvas(TurmiteModel app) { + this.app = app; + int width = this.app.getWorldDimensions().getWidth(); + int height = this.app.getWorldDimensions().getHeight(); + this.preferredSize = new Dimension(width, height); + this.setSize(this.preferredSize); + this.setPreferredSize(preferredSize); + } + + public void paint(Graphics g) { + this.setSize(this.preferredSize); + this.setPreferredSize(preferredSize); + super.paintComponent(g); + int red = 0; + int green = 0; + int blue = 0; + for(int y = 0; y < app.getWorldDimensions().getY(); y++){ + for(int x = 0; x < app.getWorldDimensions().getX(); x++){ + blue = (((app.getCellStatusFor(x,y))*4)%256); + Color stateColor = new Color(red, green, blue); + g.setColor(stateColor); + g.drawLine(x,y,x,y); + } + } + } + + public void update(Graphics g) { + paint(g); + } + +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/TurmiteController.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/TurmiteController.java new file mode 100644 index 00000000..7b726ca5 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/TurmiteController.java @@ -0,0 +1,47 @@ +package org.woehlke.computer.kurzweil.tabs.turmite; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Date: 05.02.2006 + * Time: 00:36:20 + */ +public class TurmiteController extends Thread implements Runnable { + + private final int THREAD_SLEEP_TIME = 1; + private volatile TurmiteModel mandelbrotModel; + private volatile TurmiteTab frame; + private volatile Boolean goOn; + + public TurmiteController(TurmiteModel model, TurmiteTab frame) { + this.frame = frame; + this.mandelbrotModel = model; + goOn = Boolean.TRUE; + } + + public void run() { + boolean doIt; + do { + synchronized (goOn) { + doIt = goOn.booleanValue(); + } + if(this.mandelbrotModel.step()){ + frame.getCanvas().repaint(); + } + try { sleep(THREAD_SLEEP_TIME); } + catch (InterruptedException e) { } + } + while (doIt); + } + + public void exit() { + synchronized (goOn) { + goOn = Boolean.FALSE; + } + } + +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/TurmiteModel.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/TurmiteModel.java new file mode 100644 index 00000000..c9077cf9 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/TurmiteModel.java @@ -0,0 +1,114 @@ +package org.woehlke.computer.kurzweil.tabs.turmite; + +import lombok.Getter; +import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties; +import org.woehlke.computer.kurzweil.commons.model.fractal.GaussianNumberPlane; +import org.woehlke.computer.kurzweil.commons.model.turing.Point; +import org.woehlke.computer.kurzweil.tabs.turmite.model.TurmiteTabStateMachine; +import org.woehlke.computer.kurzweil.commons.model.turing.MandelbrotTuringMachine; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +@Getter +public class TurmiteModel { + + private volatile GaussianNumberPlane gaussianNumberPlane; + private volatile MandelbrotTuringMachine mandelbrotTuringMachine; + private volatile TurmiteTabStateMachine applicationStateMachine; + + private volatile ComputerKurzweilProperties properties; + private volatile TurmiteTab frame; + + public TurmiteModel(ComputerKurzweilProperties properties, TurmiteTab frame) { + this.properties = properties; + this.frame = frame; + this.gaussianNumberPlane = new GaussianNumberPlane(this); + this.mandelbrotTuringMachine = new MandelbrotTuringMachine(this); + this.applicationStateMachine = new TurmiteTabStateMachine(); + } + + public synchronized boolean click(Point c) { + applicationStateMachine.click(); + boolean repaint = true; + switch (applicationStateMachine.getApplicationState()) { + case MANDELBROT: + mandelbrotTuringMachine.start(); + repaint = false; + break; + //case JULIA_SET: + // gaussianNumberPlane.computeTheJuliaSetFor(c); + // break; + case MANDELBROT_ZOOM: + gaussianNumberPlane.zoomIntoTheMandelbrotSet(c); + break; + //case JULIA_SET_ZOOM: + // gaussianNumberPlane.zoomIntoTheJuliaSetFor(c); + // break; + } + return repaint; + } + + public synchronized boolean step() { + boolean repaint = false; + switch (applicationStateMachine.getApplicationState()) { + case MANDELBROT: + repaint = mandelbrotTuringMachine.step(); + break; + //case JULIA_SET: + case MANDELBROT_ZOOM: + //case JULIA_SET_ZOOM: + break; + } + return repaint; + } + + public synchronized int getCellStatusFor(int x, int y) { + return gaussianNumberPlane.getCellStatusFor(x, y); + } + + public Point getWorldDimensions() { + int width = properties.getAllinone().getLattice().getWidth(); + int height = properties.getAllinone().getLattice().getHeight(); + return new Point(width, height); + } + + public void setModeSwitch() { + this.applicationStateMachine.setModeSwitch(); + this.frame.setModeSwitch(); + } + + public void setModeZoom() { + this.gaussianNumberPlane.setModeZoom(); + this.applicationStateMachine.setModeZoom(); + this.frame.setModeZoom(); + } + + public GaussianNumberPlane getGaussianNumberPlane() { + return gaussianNumberPlane; + } + + public TurmiteTab 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; + } + } +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/TurmiteTab.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/TurmiteTab.java new file mode 100644 index 00000000..d8af0377 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/TurmiteTab.java @@ -0,0 +1,147 @@ +package org.woehlke.computer.kurzweil.tabs.turmite; + +import org.woehlke.computer.kurzweil.application.ComputerKurzweilProperties; +import org.woehlke.computer.kurzweil.commons.ui.PanelButtons; +import org.woehlke.computer.kurzweil.commons.ui.PanelCopyright; +import org.woehlke.computer.kurzweil.commons.ui.PanelSubtitle; +import org.woehlke.computer.kurzweil.commons.model.turing.Point; + +import javax.accessibility.Accessible; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.image.ImageObserver; +import java.io.Serializable; + +/** + * (C) 2006 - 2013 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * Date: 04.02.2006 + * Time: 18:47:46 + */ +public class TurmiteTab extends JFrame implements ImageObserver, + MenuContainer, + Serializable, + Accessible, + WindowListener, + MouseListener { + + private volatile TurmiteController mandelbrotController; + private volatile TurmiteCanvas canvas; + private volatile TurmiteModel mandelbrotModel; + private volatile Rectangle rectangleBounds; + private volatile Dimension dimensionSize; + + public TurmiteTab(ComputerKurzweilProperties properties) { + super(properties.getWator().getView().getTitle()); + this.mandelbrotModel = new TurmiteModel(properties,this); + BoxLayout layout = new BoxLayout(rootPane, BoxLayout.PAGE_AXIS); + this.canvas = new TurmiteCanvas(mandelbrotModel); + this.mandelbrotController = new TurmiteController(mandelbrotModel, this); + PanelButtons panelButtons = new PanelButtons(this.mandelbrotModel); + PanelSubtitle panelSubtitle = new PanelSubtitle(properties.getWator().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(); + setModeSwitch(); + this.mandelbrotController.start(); + } + + public void windowOpened(WindowEvent e) { + showMe(); + } + + public void windowClosing(WindowEvent e) { + this.mandelbrotController.exit(); + } + + public void windowClosed(WindowEvent e) { + this.mandelbrotController.exit(); + } + + public void windowIconified(WindowEvent e) {} + + public void windowDeiconified(WindowEvent e) { + showMe(); + } + + public void windowActivated(WindowEvent e) { + showMe(); + } + + public void windowDeactivated(WindowEvent e) {} + + + @Override + public void mouseClicked(MouseEvent e) { + Point c = new Point(e.getX(), e.getY()); + this.mandelbrotModel.click(c); + showMe(); + } + + @Override + public void mousePressed(MouseEvent e) {} + + @Override + public void mouseReleased(MouseEvent e) {} + + @Override + public void mouseEntered(MouseEvent e) {} + + @Override + public void mouseExited(MouseEvent e) {} + + public void showMeInit() { + pack(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + double width = this.rootPane.getWidth(); + double height = this.canvas.getHeight() + 180; + double startX = (screenSize.getWidth() - width) / 2d; + double startY = (screenSize.getHeight() - height) / 2d; + int myheight = Double.valueOf(height).intValue(); + int mywidth = Double.valueOf(width).intValue(); + int mystartX = Double.valueOf(startX).intValue(); + int mystartY = Double.valueOf(startY).intValue(); + this.rectangleBounds = new Rectangle(mystartX, mystartY, mywidth, myheight); + this.dimensionSize = new Dimension(mywidth, myheight); + this.setBounds(this.rectangleBounds); + this.setSize(this.dimensionSize); + this.setPreferredSize(this.dimensionSize); + this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + setVisible(true); + toFront(); + } + + /** + * TODO write doc. + */ + public void showMe() { + this.pack(); + this.setBounds(this.rectangleBounds); + this.setSize(this.dimensionSize); + this.setPreferredSize(this.dimensionSize); + this.setVisible(true); + this.toFront(); + } + + public void setModeSwitch() { + canvas.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + } + + public void setModeZoom() { + canvas.setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + public TurmiteCanvas getCanvas() { + return canvas; + } +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/model/TurmiteTabState.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/model/TurmiteTabState.java new file mode 100644 index 00000000..182aaca5 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/model/TurmiteTabState.java @@ -0,0 +1,15 @@ +package org.woehlke.computer.kurzweil.tabs.turmite.model; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 23.08.15. + */ +public enum TurmiteTabState { + MANDELBROT, + MANDELBROT_ZOOM +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/model/TurmiteTabStateMachine.java b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/model/TurmiteTabStateMachine.java new file mode 100644 index 00000000..d7a29764 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/java/org/woehlke/computer/kurzweil/tabs/turmite/model/TurmiteTabStateMachine.java @@ -0,0 +1,80 @@ +package org.woehlke.computer.kurzweil.tabs.turmite.model; + + +import org.woehlke.computer.kurzweil.tabs.turmite.model.TurmiteTabState; + +import static org.woehlke.computer.kurzweil.tabs.turmite.model.TurmiteTabState.*; + +/** + * Mandelbrot Set drawn by a Turing Machine. + * + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * + * Created by tw on 16.12.2019. + */ +public class TurmiteTabStateMachine { + + private volatile TurmiteTabState applicationState; + + public TurmiteTabStateMachine() { + this.applicationState = TurmiteTabState.MANDELBROT; + } + + public void click(){ + TurmiteTabState nextApplicationState = null; + switch (applicationState){ + case MANDELBROT: + nextApplicationState = MANDELBROT_ZOOM; + break; + case MANDELBROT_ZOOM: + nextApplicationState = MANDELBROT; + break; + } + this.setApplicationState(nextApplicationState); + } + + public void setModeSwitch() { + TurmiteTabState 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() { + TurmiteTabState 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 TurmiteTabState getApplicationState() { + return applicationState; + } + + public void setApplicationState(TurmiteTabState applicationState) { + this.applicationState = applicationState; + } + +} diff --git a/single-apps/insourcing/insourcing-turmite/src/main/resources/application.properties b/single-apps/insourcing/insourcing-turmite/src/main/resources/application.properties new file mode 100644 index 00000000..81af6f26 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/resources/application.properties @@ -0,0 +1,9 @@ +org.woehlke.computer.kurzweil.mandelbrot.config.title=Mandelbrot Set +org.woehlke.computer.kurzweil.mandelbrot.config.subtitle=Mandelbrot Set drawn by a Turing Machine +org.woehlke.computer.kurzweil.mandelbrot.config.copyright=(c) 2019 Thomas Woehlke +org.woehlke.computer.kurzweil.mandelbrot.config.width=800 +org.woehlke.computer.kurzweil.mandelbrot.config.height=585 +org.woehlke.computer.kurzweil.mandelbrot.config.buttons.label=Choose Mode +org.woehlke.computer.kurzweil.mandelbrot.config.buttons.switch=Mandelbrot Set <=> Julia Set +org.woehlke.computer.kurzweil.mandelbrot.config.buttons.zoom=Zoom +org.woehlke.computer.kurzweil.mandelbrot.config.buttons.zoomout=Zoom Out diff --git a/single-apps/insourcing/insourcing-turmite/src/main/resources/application.yml b/single-apps/insourcing/insourcing-turmite/src/main/resources/application.yml new file mode 100644 index 00000000..22e87914 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/main/resources/application.yml @@ -0,0 +1,184 @@ +allinone: + lattice: + width: 800 + height: 585 + view: + title: 'Computer Kurzweil' + subtitle: 'Scientific Imfotainment' + copyright: '(c) 2020 Thomas Woehlke' + borderPaddingX: 5 + borderPaddingY: 5 + titleHeight: 60 + startStopp: 'Start / Stop' + start: 'Start' + stop: 'Stop' + info: 'Info' +mandelbrot: + view: + title: 'Mandelbrot Set' + subtitle: 'Fractal Mandelbrot Set drawn by a Turing Machine' + buttonsZoom: 'Zoom In' + buttonsZoomOut: 'Zoom Out' + buttonsSwitch: 'Mandelbrot Set <-> Julia Set' + buttonsZoomLabel: 'Zoom' + buttonsLabel: 'Choose Mouse Click Mode' + control: + threadSleepTime: 50 +simulatedevolution: + view: + title: 'Simulated Evolution' + subtitle: 'Artificial Life Simulation of Bacteria Motion depending on DNA' + control: + threadSleepTime: 100 + exitStatus: 0 + queueMaxLength: 1000 + cellConf: + fatMax: 2000 + fatHungerMax: 1000 + fatMinimumForSex: 800 + fatAtBirth: 500 + fatPerFood: 25 + ageOfAdulthood: 200 + ageOld: 800 + ageMax: 1000 + population: + initialPopulation: 20 + panelPopulationStatistics: 'Population' + panelLifeCycleStatistics: 'LifeCycle' + youngCellsLabel: 'young' + youngAndFatCellsLabel: 'young and Fat' + fullAgeCellsLabel: 'full Age' + hungryCellsLabel: 'hungry' + oldCellsLabel: 'old' + populationLabel: 'population' + generationOldestLabel: 'oldest Generation' + generationYoungestLabel: 'youngest Generation' + food: + foodPerDay: 20 + foodPerDayFieldColumns: 3 + foodPerDayLabel: 'Food per Day:' + foodPerDayBorderLabel: 'Food per Day:' + buttonFoodPerDayIncrease: '+' + buttonFoodPerDayDecrease: '-' + panelFood: 'Food' + gardenOfEden: + panelGardenOfEden: 'Garden of Eden' + gardenOfEdenEnabled: true + gardenOfEdenEnabledString: 'enabled' + gardenOfEdenEnabledToggleButton: 'Change' + foodPerDay: 80 + gardenOfEdenLatticeDivisor: 5 + gardenOfEdenLatticeDivisorPadding: 2 +cca: + view: + title: 'Cyclic Cellular Automaton' + subtitle: 'Cyclic Cellular Automaton' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 100 +randomwalk: + view: + title: 'Random Walk' + subtitle: 'Brownian Motion by Fractal Random Walk' + control: + threadSleepTime: 100 +dla: + view: + title: 'Diffusion Limited Aggregation' + subtitle: 'Fractal Random Walk due to Brownian Motion Cluster' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +kochsnowflake: + view: + title: 'Koch Snowflake' + subtitle: 'Fractal Koch Snowflake' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +samegame: + view: + title: 'Same Game' + subtitle: 'Play the Same Game' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +sierpinskitriangle: + view: + title: 'Sierpinski Triangle' + subtitle: 'Fractal Sierpinski Triangle' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +tetris: + view: + title: 'Tetris' + subtitle: 'Play Tetris' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +turmite: + view: + title: 'Turmite' + subtitle: 'Termites as Turing Machines with 2D Tape' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +wator: + view: + title: 'WaTor' + subtitle: 'Population Dynamics on Planet Water Torus' + buttonsZoom: 'Zoom In' + buttonsZoomOut: 'Zoom Out' + buttonsSwitch: 'Mandelbrot Set <-> Julia Set' + buttonsZoomLabel: 'Zoom' + buttonsLabel: 'Choose Mouse Click Mode' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 +gameoflive: + view: + title: 'Conways Game of Life' + subtitle: 'Conways Game of Life Cellular Automaton' + neighborhood: + title: 'Neighborhood' + typeVonNeumann: 'Von Neumann' + typeMoore: 'Moore' + typeWoehlke: 'Woehlke' + control: + threadSleepTime: 50 + numberOfParticles: 30000 diff --git a/single-apps/insourcing/insourcing-turmite/src/main/resources/img/julia01.png b/single-apps/insourcing/insourcing-turmite/src/main/resources/img/julia01.png new file mode 100644 index 00000000..804b50a0 Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/main/resources/img/julia01.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/main/resources/img/julia02.png b/single-apps/insourcing/insourcing-turmite/src/main/resources/img/julia02.png new file mode 100644 index 00000000..ab30d135 Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/main/resources/img/julia02.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/main/resources/img/phasenraum_logo.gif b/single-apps/insourcing/insourcing-turmite/src/main/resources/img/phasenraum_logo.gif new file mode 100644 index 00000000..3615d230 Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/main/resources/img/phasenraum_logo.gif differ diff --git a/single-apps/insourcing/insourcing-turmite/src/main/resources/img/screen01.png b/single-apps/insourcing/insourcing-turmite/src/main/resources/img/screen01.png new file mode 100644 index 00000000..d4a4193c Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/main/resources/img/screen01.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/main/resources/img/screen02.png b/single-apps/insourcing/insourcing-turmite/src/main/resources/img/screen02.png new file mode 100644 index 00000000..2a31ba74 Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/main/resources/img/screen02.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/main/resources/img/screen03.png b/single-apps/insourcing/insourcing-turmite/src/main/resources/img/screen03.png new file mode 100644 index 00000000..a1fc854a Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/main/resources/img/screen03.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/site/markdown/About.md b/single-apps/insourcing/insourcing-turmite/src/site/markdown/About.md new file mode 100644 index 00000000..20b9b980 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/site/markdown/About.md @@ -0,0 +1,32 @@ +# Simulated Evolution +**Artificial Life Simulation of Bacteria Motion depending on DNA** + +## Abstract +Green food appears in a simulatedEvolutionModel with red moving cells. These cells eat the food if it is on their position. +Movement of the cells depends on random and their DNA. A fit cell moves around and eats enough to reproduce. +Reproduction is done by splitting the cell and randomly changing the DNA of the two new Cells. +If a cell doesn't eat enough, it will first stand still and after a while it dies. + + +## Run the Desktop Application +``` +git clone https://github.com/Computer-Kurzweil/simulated-evolution.git +cd simulated-evolution +mvnw +``` + +## Screenshot +### Early Screen +![Early Screen](src/main/resources/img/screen1.png) +### Later Screen +![Later Screen](src/main/resources/img/screen2.png) + + +## UML Class Model +![UML Class Model](src/main/resources/img/Class_Model.jpg) + +## Github Repository +[https://github.com/Computer-Kurzweil/simulated-evolution](https://github.com/Computer-Kurzweil/simulated-evolution) + +## Blog Article +[http://thomas-woehlke.blogspot.de/2016/01/simulated-evolution-artificial-life-and.html](http://thomas-woehlke.blogspot.de/2016/01/simulated-evolution-artificial-life-and.html) diff --git a/single-apps/insourcing/insourcing-turmite/src/site/resources/img/Class_Model.jpg b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/Class_Model.jpg new file mode 100644 index 00000000..827d7bba Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/Class_Model.jpg differ diff --git a/single-apps/insourcing/insourcing-turmite/src/site/resources/img/black.png b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/black.png new file mode 100644 index 00000000..6516a94c Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/black.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/site/resources/img/blue.png b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/blue.png new file mode 100644 index 00000000..500b2779 Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/blue.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/site/resources/img/dark_gray.png b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/dark_gray.png new file mode 100644 index 00000000..f25c5c9f Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/dark_gray.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/site/resources/img/green.png b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/green.png new file mode 100644 index 00000000..a894e98c Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/green.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/site/resources/img/light_gray.png b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/light_gray.png new file mode 100644 index 00000000..a9d04709 Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/light_gray.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/site/resources/img/phasenraum_logo.gif b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/phasenraum_logo.gif new file mode 100644 index 00000000..3615d230 Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/phasenraum_logo.gif differ diff --git a/single-apps/insourcing/insourcing-turmite/src/site/resources/img/red.png b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/red.png new file mode 100644 index 00000000..7e9a56cd Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/red.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/site/resources/img/screen.png b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/screen.png new file mode 100644 index 00000000..fc4c797d Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/screen.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/site/resources/img/screen1.png b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/screen1.png new file mode 100644 index 00000000..943cf1ba Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/screen1.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/site/resources/img/screen2.png b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/screen2.png new file mode 100644 index 00000000..9ec3a2ed Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/screen2.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/site/resources/img/yellow.png b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/yellow.png new file mode 100644 index 00000000..891de604 Binary files /dev/null and b/single-apps/insourcing/insourcing-turmite/src/site/resources/img/yellow.png differ diff --git a/single-apps/insourcing/insourcing-turmite/src/site/site.xml b/single-apps/insourcing/insourcing-turmite/src/site/site.xml new file mode 100644 index 00000000..3860ce74 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/site/site.xml @@ -0,0 +1,41 @@ + + + + org.apache.maven.skins + maven-default-skin + 1.3 + + + Simulated Evolution + /img/phasenraum_logo.gif + http://woehlke.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/single-apps/insourcing/insourcing-turmite/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/ComplexNumberTest.java b/single-apps/insourcing/insourcing-turmite/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/ComplexNumberTest.java new file mode 100644 index 00000000..5d38f60c --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrot2julia/ComplexNumberTest.java @@ -0,0 +1,75 @@ +package org.woehlke.computer.kurzweil.tabs.mandelbrot2julia; + + +import org.junit.jupiter.api.Test; +import org.woehlke.computer.kurzweil.commons.model.fractal.ComplexNumber; + +import java.util.logging.Logger; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * (C) 2006 - 2015 Thomas Woehlke. + * https://thomas-woehlke.blogspot.com/2016/01/mandelbrot-set-drawn-by-turing-machine.html + * @author Thomas Woehlke + * Created by tw on 24.08.15. + */ +public class ComplexNumberTest { + + public static Logger log = Logger.getLogger(ComplexNumberTest.class.getName()); + + @Test + public void computeMandelbrotTest1(){ + log.info("computeMandelbrotTest1 start"); + ComplexNumber complexNumber1 = new ComplexNumber(); + int iterations = complexNumber1.computeMandelbrotSet(); + log.info("computeMandelbrotTest1 iterations : "+ iterations); + assertTrue(complexNumber1.isInMandelbrotSet()); + assertNotEquals(ComplexNumber.MAX_ITERATIONS, iterations); + assertTrue(0 == iterations); + log.info("computeMandelbrotTest1 done"); + } + + @Test + public void computeMandelbrotTest2(){ + log.info("computeMandelbrotTest2 start"); + ComplexNumber complexNumber2 = new ComplexNumber(1.0d,1.2d); + int iterations = complexNumber2.computeMandelbrotSet(); + log.info("computeMandelbrotTest2 iterations : "+ iterations); + assertFalse(complexNumber2.isInMandelbrotSet()); + assertNotEquals(iterations, ComplexNumber.MAX_ITERATIONS); + assertTrue(iterations < ComplexNumber.MAX_ITERATIONS); + assertTrue(2 == iterations); + log.info("computeMandelbrotTest2 done"); + } + + @Test + public void computeJuliaTest1(){ + log.info("computeJuliaTest1 start"); + ComplexNumber z = new ComplexNumber(0.1d,0.2d); + ComplexNumber c = new ComplexNumber(0.2d,0.1d); + int iterations = z.computeJuliaSet(c); + log.info("computeJuliaTest1 iterations : "+ iterations); + boolean isInJuliaSet = z.isInJuliaSet(); + assertTrue(isInJuliaSet); + assertNotEquals(ComplexNumber.MAX_ITERATIONS, iterations); + assertTrue(iterations < ComplexNumber.MAX_ITERATIONS); + assertTrue(0 == iterations); + log.info("computeJuliaTest1 done"); + } + + @Test + public void computeJuliaTest2(){ + log.info("computeJuliaTest2 start"); + ComplexNumber z = new ComplexNumber(0.1d,0.2d); + ComplexNumber c = new ComplexNumber(1.0d,1.1d); + int iterations = z.computeJuliaSet(c); + log.info("computeJuliaTest2 iterations :"+ iterations); + boolean isInJuliaSet = z.isInJuliaSet(); + assertFalse(isInJuliaSet); + assertNotEquals(ComplexNumber.MAX_ITERATIONS, iterations); + assertTrue(iterations < ComplexNumber.MAX_ITERATIONS); + assertTrue(2 == iterations); + log.info("computeJuliaTest2 done"); + } +} diff --git a/single-apps/insourcing/insourcing-turmite/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringPositionsTest.java b/single-apps/insourcing/insourcing-turmite/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringPositionsTest.java new file mode 100644 index 00000000..37ab4392 --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringPositionsTest.java @@ -0,0 +1,46 @@ +package org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.model.turing; + + +import org.junit.jupiter.api.Test; + +import java.util.logging.Logger; + +public class TuringPositionsTest { + + public static Logger log = Logger.getLogger(TuringPositionsTest.class.getName()); + + @Test + public void startTest() { + log.info("startTest start"); + } + + @Test + public void markFirstSetPositionTest(){ + log.info("markFirstSetPositionTest start"); + + } + + @Test + public void goForwardTest() { + log.info("goForwardTest start"); + + } + + @Test + public void turnRightTest() { + log.info("turnRightTest start"); + + } + + @Test + public void turnLeftTest() { + log.info("turnLeftTest start"); + + } + + @Test + public void isFinishedWalkAroundTest() { + log.info("isFinishedWalkAroundTest start"); + + } +} diff --git a/single-apps/insourcing/insourcing-turmite/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringTuringPhaseStateEnumTest.java b/single-apps/insourcing/insourcing-turmite/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringTuringPhaseStateEnumTest.java new file mode 100644 index 00000000..2f2cadcc --- /dev/null +++ b/single-apps/insourcing/insourcing-turmite/src/test/java/org/woehlke/computer/kurzweil/tabs/mandelbrotzoom/model/turing/TuringTuringPhaseStateEnumTest.java @@ -0,0 +1,62 @@ +package org.woehlke.computer.kurzweil.tabs.mandelbrotzoom.model.turing; + + +import org.junit.jupiter.api.Test; +import org.woehlke.computer.kurzweil.commons.model.turing.MandelbrotTuringPhaseState; + +import java.util.logging.Logger; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.woehlke.computer.kurzweil.commons.model.turing.MandelbrotTuringPhase.*; + +public class TuringTuringPhaseStateEnumTest { + + public static Logger log = Logger.getLogger(TuringPositionsTest.class.getName()); + private MandelbrotTuringPhaseState turingPhaseState = new MandelbrotTuringPhaseState(); + + @Test + public void startTest(){ + log.info("startTest start"); + turingPhaseState = new MandelbrotTuringPhaseState(); + assertEquals(turingPhaseState.getTuringTuringPhase(),SEARCH_THE_SET); + turingPhaseState.start(); + assertEquals(turingPhaseState.getTuringTuringPhase(),SEARCH_THE_SET); + log.info("startTest done"); + } + + @Test + public void finishGoToSetTest(){ + log.info("finishGoToSetTest start"); + turingPhaseState = new MandelbrotTuringPhaseState(); + turingPhaseState.start(); + assertEquals(turingPhaseState.getTuringTuringPhase(),SEARCH_THE_SET); + turingPhaseState.finishSearchTheSet(); + assertEquals(turingPhaseState.getTuringTuringPhase(),WALK_AROUND_THE_SET); + log.info("finishGoToSetTest done"); + } + + @Test + public void finishWalkAroundTest() { + log.info("finishWalkAroundTest start"); + turingPhaseState = new MandelbrotTuringPhaseState(); + turingPhaseState.start(); + turingPhaseState.finishSearchTheSet(); + assertEquals(turingPhaseState.getTuringTuringPhase(),WALK_AROUND_THE_SET); + turingPhaseState.finishWalkAround(); + assertEquals(turingPhaseState.getTuringTuringPhase(), FILL_THE_OUTSIDE_WITH_COLOR); + log.info("finishWalkAroundTest done"); + } + + @Test + public void finishFillTheOutsideWithColorsTest() { + log.info("finishFillTheOutsideWithColorsTest start"); + turingPhaseState = new MandelbrotTuringPhaseState(); + turingPhaseState.start(); + turingPhaseState.finishSearchTheSet(); + turingPhaseState.finishWalkAround(); + assertEquals(turingPhaseState.getTuringTuringPhase(), FILL_THE_OUTSIDE_WITH_COLOR); + turingPhaseState.finishFillTheOutsideWithColors(); + assertEquals(turingPhaseState.getTuringTuringPhase(), FINISHED); + log.info("finishFillTheOutsideWithColorsTest done"); + } +} diff --git a/single-apps/insourcing/insourcing-wator/pom.xml b/single-apps/insourcing/insourcing-wator/pom.xml index ade683d6..d2a95579 100644 --- a/single-apps/insourcing/insourcing-wator/pom.xml +++ b/single-apps/insourcing/insourcing-wator/pom.xml @@ -12,8 +12,8 @@ insourcing-wator jar - single-apps :: insourcing :: Wator - Wator + single-apps :: insourcing :: WaTor + Water Torus - Population Dynamics org.woehlke.computer.kurzweil.WatorApplication diff --git a/single-apps/insourcing/pom.xml b/single-apps/insourcing/pom.xml index 431d00c8..870b3230 100644 --- a/single-apps/insourcing/pom.xml +++ b/single-apps/insourcing/pom.xml @@ -21,6 +21,9 @@ insourcing-simulated-evolution insourcing-mandelbrot-julia insourcing-mandelbrot-zoom + insourcing-kochsnowflake + insourcing-sierpinskitriangle + insourcing-turmite insourcing-wator