This application demonstrates advantages of parallel execution done using Java Parallel API.
This JavaFX application renders an image using Mandelbrot set (wikipedia link) for any particular range of complex values.
Given a complex number the algorithm calculates an integer value which is then mapped to a color. Real part of a complex value is mapped to horizontal axis of the screen. Imaginary part of a complex value is mapped to a vertical axis of the screen.
MandelbrotSetTask.call()
method contains code which is equivalent
to the following when running in parallel mode:
IntStream.range(0, height).parallel().forEach((int y) -> { for (int x = 0; x < width; x++) { // calculate (x, y) pixel color } });
java -jar MandelbrotSet.jar -min <minReal>,<minImaginary> -max <maxReal>,<maxImaginary> -windowSize <width>x<height>
-min <minReal>,<minImaginary>
specifies left top corner of the fractal complex number area-max <maxReal>,<maxImaginary>
specifies right bottom corner of the fractal complex number area-windowSize <width>x<height>
specifies initial window size in pixelsHere is an example produced by typing "I" inside the app:
Use the following parameters to get to the same position -min -2.4807381162845332,-1.3061943784663503 -max 0.9781413692299719,1.2879652356695286 -windowSize 800.0x600.0;