San Jose State University | CS 151 - OO Design

Homework 7

Make a copy of the ch08/graphed2 directory in the book code into a directory hw7 in your repo. Add a DiamondNode class. Diamonds have a black outline and and blank interior. (Diamonds don't have a color.) In the draw method, generate four Line2D.Double objects and draw them. Edges should attach at one of the four corner points of a diamond. Hint: Compute dx and dy as with the circle node, and note that the lines dx = dy and dx = -dy bisect the plane into four areas that tell you which connection point to use.

DiamondNode

Provide two edge types HVEdge and VHEdge like in Violet that consist of a horizontal line followed by a vertical line, or a vertical line followed by a horizontal line. Make them extend LineEdge so you inherit the lineStyle property.

Update the SimpleGraph class so that the SimpleGraphEditor can edit graphs consisting of black and white circles and diamonds and straight edges, HV edges, and VH edges.