Chase the Mouse (Over a Terrain)

The code given above, when completed and compiled with the given jar files, should create a window in which one can draw a terrain.

Clicking in the window (and optionally dragging the mouse) changes the color of one or more "pixels" from one terrain type to the next. Gray indicates normal terrain; green indicates the presence of trees, through which passage is more difficult; blue indicates the presence of water, which is even harder to get through than trees (but not impossible); and black represents an impassible terrain.

Upon clicking the button at the bottom of the window and maneuvering the mouse inside the main body of the window, a "bad guy" (represented by a red dot) will begin to chase the mouse, avoiding harder terrains as possible.

Appealing to Dijkstra's algorithm, complete the class given so that the program functions as described above. Then, improve upon this by modifying your code so that the A* algorithm is used instead.