Floodfill Application
Contents
Background
In this studio, you will be using a parallel and recursive method to create an app that fills in a space with color, much like the paint bucket in MS Paint.
Setup
In order to run the visualization app you will need to setup e(fx)clipse.
Where to Start
In order to test this application, please refer to the floodfill.viz
package in the src/visualization/java
folder. More specifically, check out the FloodFillVizApp.java
class. Otherwise, the only class you will need to modify is FloodFiller.java
, which can be found int the floodfill.studio
package in the src/main/java
folder.
There is also an albeit limited test suite FloodFillTestSuite
.
The Kernel
The class is composed of two methods: floodFill and floodFillKernel. As you will be implementing FloodFill recursively and in parallel. Carefully consider where to put your asyncs and/or finishes. The entire process in the kernel is triggered from the floodFill method. This is so that the kernel can run recursively and asynchronously so the floodFill method can wrap the kernel in an all-inclusive finish.
The kernel should check if the given pixel is in bounds. If it is, it should check if the given pixel matches the targetColor (the color we wish to change). If it is, it should then replace the color with the replacementColor and asynchronously call the method again to repeat the process for the surrounding pixels. The purpose of the assignment is to understand recursion and how to make it work in parallel.
Sequential Implementation Increased Stack Size Requirement
For this project, if you decide to first build a sequential version, you will need to change your VM Arguments slightly. In addition to the normal argument that needs to be pasted in for every assignment, you need to add -Xss4m
. Altogether, it will look something like:
-javaagent:"path\to\hjlib-cooperative-0.1.14-SNAPSHOT.jar" -Xss4m
. This will increase the size of the call stack, essentially increasing the maximum depth of your recursion.