From 85751141b5705dba503b507ab34cc4ee734a9e6a Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Thu, 4 Jun 2015 22:33:05 +0200
Subject: Started own version
---
Week15 Mandelbrot/build.xml | 73 -
Week15 Mandelbrot/manifest.mf | 3 -
Week15 Mandelbrot/nbproject/build-impl.xml | 1413 --------------------
Week15 Mandelbrot/nbproject/genfiles.properties | 8 -
Week15 Mandelbrot/nbproject/project.properties | 71 -
Week15 Mandelbrot/nbproject/project.xml | 15 -
.../src/com/camilstaps/mandelbrot/DrawView.java | 168 +++
.../com/camilstaps/mandelbrot/FractalModel.java | 67 +
.../mandelbrot/MandelbrotController.java | 18 +
.../camilstaps/mandelbrot/MandelbrotFractal.java | 96 ++
.../camilstaps/mandelbrot/MandelbrotWindow.java | 39 +
.../src/com/camilstaps/mandelbrot/ZoomFrame.java | 67 +
Week15 Mandelbrot/src/mandelbrot/Area.java | 27 -
.../src/mandelbrot/AreaController.java | 22 -
Week15 Mandelbrot/src/mandelbrot/AreaSelector.java | 41 -
Week15 Mandelbrot/src/mandelbrot/ColorChooser.java | 36 -
Week15 Mandelbrot/src/mandelbrot/Grid.java | 16 -
Week15 Mandelbrot/src/mandelbrot/GridFiller.java | 59 -
Week15 Mandelbrot/src/mandelbrot/GridView.java | 63 -
Week15 Mandelbrot/src/mandelbrot/MainWindow.java | 33 -
Week15 Mandelbrot/src/mandelbrot/Mandelbrot.java | 34 -
Week15 Mandelbrot/src/mandelbrot/RGBColors.java | 82 --
Week15 Mandelbrot/src/mandelbrot/Stopper.java | 14 -
23 files changed, 455 insertions(+), 2010 deletions(-)
delete mode 100644 Week15 Mandelbrot/build.xml
delete mode 100644 Week15 Mandelbrot/manifest.mf
delete mode 100644 Week15 Mandelbrot/nbproject/build-impl.xml
delete mode 100644 Week15 Mandelbrot/nbproject/genfiles.properties
delete mode 100644 Week15 Mandelbrot/nbproject/project.properties
delete mode 100644 Week15 Mandelbrot/nbproject/project.xml
create mode 100644 Week15 Mandelbrot/src/com/camilstaps/mandelbrot/DrawView.java
create mode 100644 Week15 Mandelbrot/src/com/camilstaps/mandelbrot/FractalModel.java
create mode 100644 Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotController.java
create mode 100644 Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java
create mode 100644 Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotWindow.java
create mode 100644 Week15 Mandelbrot/src/com/camilstaps/mandelbrot/ZoomFrame.java
delete mode 100644 Week15 Mandelbrot/src/mandelbrot/Area.java
delete mode 100644 Week15 Mandelbrot/src/mandelbrot/AreaController.java
delete mode 100644 Week15 Mandelbrot/src/mandelbrot/AreaSelector.java
delete mode 100644 Week15 Mandelbrot/src/mandelbrot/ColorChooser.java
delete mode 100644 Week15 Mandelbrot/src/mandelbrot/Grid.java
delete mode 100644 Week15 Mandelbrot/src/mandelbrot/GridFiller.java
delete mode 100644 Week15 Mandelbrot/src/mandelbrot/GridView.java
delete mode 100644 Week15 Mandelbrot/src/mandelbrot/MainWindow.java
delete mode 100644 Week15 Mandelbrot/src/mandelbrot/Mandelbrot.java
delete mode 100644 Week15 Mandelbrot/src/mandelbrot/RGBColors.java
delete mode 100644 Week15 Mandelbrot/src/mandelbrot/Stopper.java
(limited to 'Week15 Mandelbrot')
diff --git a/Week15 Mandelbrot/build.xml b/Week15 Mandelbrot/build.xml
deleted file mode 100644
index c5a2ca3..0000000
--- a/Week15 Mandelbrot/build.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- Builds, tests, and runs the project Week15 Mandelbrot.
-
-
-
diff --git a/Week15 Mandelbrot/manifest.mf b/Week15 Mandelbrot/manifest.mf
deleted file mode 100644
index 1574df4..0000000
--- a/Week15 Mandelbrot/manifest.mf
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-X-COMMENT: Main-Class will be added automatically by build
-
diff --git a/Week15 Mandelbrot/nbproject/build-impl.xml b/Week15 Mandelbrot/nbproject/build-impl.xml
deleted file mode 100644
index fa82428..0000000
--- a/Week15 Mandelbrot/nbproject/build-impl.xml
+++ /dev/null
@@ -1,1413 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-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-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set profile.class
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
- Must select some files in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
- Must select one file in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Week15 Mandelbrot/nbproject/genfiles.properties b/Week15 Mandelbrot/nbproject/genfiles.properties
deleted file mode 100644
index 50b0aed..0000000
--- a/Week15 Mandelbrot/nbproject/genfiles.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=b07ebbd6
-build.xml.script.CRC32=7abc5264
-build.xml.stylesheet.CRC32=8064a381@1.75.2.48
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=b07ebbd6
-nbproject/build-impl.xml.script.CRC32=73fd3cc1
-nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week15 Mandelbrot/nbproject/project.properties b/Week15 Mandelbrot/nbproject/project.properties
deleted file mode 100644
index a69efe3..0000000
--- a/Week15 Mandelbrot/nbproject/project.properties
+++ /dev/null
@@ -1,71 +0,0 @@
-annotation.processing.enabled=true
-annotation.processing.enabled.in.editor=false
-annotation.processing.processor.options=
-annotation.processing.processors.list=
-annotation.processing.run.all.processors=true
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-build.generated.sources.dir=${build.dir}/generated-sources
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-# Uncomment to specify the preferred debugger connection transport:
-#debug.transport=dt_socket
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/Week15_Mandelbrot.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-excludes=
-includes=**
-jar.compress=false
-javac.classpath=
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.processorpath=\
- ${javac.classpath}
-javac.source=1.6
-javac.target=1.6
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-javac.test.processorpath=\
- ${javac.test.classpath}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=${source.encoding}
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-main.class=mandelbrot.Mandelbrot
-manifest.file=manifest.mf
-meta.inf.dir=${src.dir}/META-INF
-mkdist.disabled=false
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-source.encoding=UTF-8
-src.dir=src
-test.src.dir=test
diff --git a/Week15 Mandelbrot/nbproject/project.xml b/Week15 Mandelbrot/nbproject/project.xml
deleted file mode 100644
index 013727d..0000000
--- a/Week15 Mandelbrot/nbproject/project.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Week15 Mandelbrot
-
-
-
-
-
-
-
-
-
diff --git a/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/DrawView.java b/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/DrawView.java
new file mode 100644
index 0000000..16500f5
--- /dev/null
+++ b/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/DrawView.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2015 Camil Staps
+ */
+package com.camilstaps.mandelbrot;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import java.awt.image.WritableRaster;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Observable;
+import java.util.Observer;
+import javax.swing.JPanel;
+import javax.swing.SwingWorker;
+
+/**
+ *
+ * @author camilstaps
+ */
+public class DrawView extends JPanel implements Observer {
+
+ private final FractalModel fractalModel;
+
+ private final BufferedImage image;
+ private final WritableRaster raster;
+ private final int width, height;
+ private static final int DEFAULT_WIDTH = 500, DEFAULT_HEIGHT = 500;
+
+ private int pixelCounter;
+ private static final int COUNTER_MAX = 1000;
+
+ private static final int REPETITIONS_MAX = 150;
+
+ public DrawView(FractalModel fractalModel) {
+ this.fractalModel = fractalModel;
+ fractalModel.addObserver(this);
+
+ width = DEFAULT_WIDTH;
+ height = DEFAULT_HEIGHT;
+
+ image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+ raster = image.getRaster();
+
+ setPreferredSize(new Dimension(width, height));
+
+ update(fractalModel, null);
+ }
+
+ @Override
+ public int getWidth() {
+ return width;
+ }
+
+ @Override
+ public int getHeight() {
+ return height;
+ }
+
+ @Override
+ public void update(Observable o, Object o1) {
+ Updater task = new Updater();
+ task.execute();
+ }
+
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ g.drawImage(image, 0, 0, null);
+ }
+
+ public void setPixel(int x, int y, int[] rgb) {
+ raster.setPixel(x, y, rgb);
+ pixelCounter++;
+ if (pixelCounter > COUNTER_MAX) {
+ pixelCounter = 0;
+ repaint();
+ }
+ }
+
+ protected double getRealX(int pixel_x) {
+ return ((double) pixel_x * (fractalModel.getEndX() - fractalModel.getStartX()) / width) + fractalModel.getStartX();
+ }
+
+ protected double getRealY(int pixel_y) {
+ return ((double) pixel_y * (fractalModel.getEndY() - fractalModel.getStartY()) / height) + fractalModel.getStartY();
+ }
+
+ protected class Updater extends SwingWorker