A java program to explore fractals
This week, I unearthed a project that should never have been unearthed.
The context of the project
I produced this monstrosity in my second year of university the project was here to test the java skills we acquired during the semester coupled with a bit of maths (complex numbers).
The rules as I remember them were as follows:
- Create a java program implementing the MVC design pattern
- It should be able to accurately display 3 different types of fractals
- The graphical library used should be either javaFX or Swing
- There was a strong incentive that if we didn’t test our code our marks would greatly suffer
- They also threatened that if any plagiarized code was found we would be publicly shamed, and our marks halved
We had the choice of the graphical library, javaFX is more recent and globally more used than swing which was already deprecated when I developed this ‘fractal explorer’. Nonetheless, I chose Swing because I liked the challenge, and those who used javaFX had to provide the added functionality to make a projection of the fractal on a 3D sphere, meh, much more work for not much more results.
I did this project in duo with Romain Champlon, I don’t remember very well how we shared the work.
Processing fractals in java is a terrible idea performance and precision wise. We had no formation on the subject of fractals, nor how they were built.
We had to figure out everything by ourselves after basic formation on the MVC pattern and complex numbers.
The final project
I remember struggling a lot implementing the first fractal and being the sole programmer to have chosen Swing as graphical library, all my friends focused on performance, some of them even held contest over who could run the fastest render of the mandelbrot fractal.
JavaFX is actually a lot nicer to use and much nicer to see but in my stubbornness I kept going with ugly old-ass swing.
Here is the result :
As you can see It’s not pretty. When I unearthed the project I worked on it a bit to see what I could improve with my experience with web MVC pattern. I realized that I could have made things much simpler on how I handled the interface.
I could have done so much more but once the project reached a certain size, I made things so tightly coupled that it became a nightmare to implement anything new or come back on old things leading to a burnout and a general disinterest in the project…
Of the three fractals I chose were Mandelbrot as seen on the picture above, Newton’s as seen on the next picture :
I don’t remember having so big black zone on the rendition when I published the final version of the project to my teachers, it seems like there is a bug somewhere. This one require a lot more efforts to implement than the mandelbrot set.
The last one I decided to implement was Pythagoras' fractal :
This one was pretty easy and fun to implement, without any complex number involved, not that it matters anyway.
What I did to make it work
I installed the Java JDK 16 and simply opened the project in Intellij Idea and that’s it !
Swing comes bundled in the JDK (Java Development Kit) and little to no configuration is necessary to make it run.
The full project is accessible here.