Difference between revisions of "Floodfill Application"

From CSE231 Wiki
Jump to navigation Jump to search
Line 12: Line 12:
  
 
=Setup=
 
=Setup=
In order to run the visualization app you will need to [http://www.cse.wustl.edu/~cosgroved/courses/cse231/s17/setup/JavaFX.html setup e(fx)clipse].
+
In order to run the visualization app you will need to [https://classes.engineering.wustl.edu/cse231/core/index.php?title=Eclipse_Tips#JavaFX_Setup  setup e(fx)clipse]].
  
 
=Mistakes to Avoid=
 
=Mistakes to Avoid=

Revision as of 08:43, 1 February 2018

Motivation

Floodfill is an problem that is well solved recursively. Further, we will harken back to this studio later in the semester when we discuss determinism.

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.

References

https://en.wikipedia.org/wiki/Flood_fill

Video

https://wustl.app.box.com/s/d800l5t04y2dthi4q3t4pddph9ms1d8p

Setup

In order to run the visualization app you will need to setup e(fx)clipse].

Mistakes to Avoid

Attention niels epting.svg Warning: Do NOT use == to compare Colors. Use Objects.equals(a,b)

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. This will increase the size of the call stack, essentially increasing the maximum depth of your recursion.

Code To Use

MutablePixels

Code To Implement

class: FloodFiller.java Java.png
methods: floodFillKernel
package: floodfill.studio
source folder: student/src/main/java


method: floodFillKernel Parallel.svg (parallel implementation required)

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.

Testing Your Solution

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.

Visualization

Correctness

class: MergeSortTestSuite.java Junit.png
package: sort.studio.merge
source folder: testing/src/test/java