/** * CircularStroke.java * * @author Sunny Kim (skim@gettysburg.edu) * * represents a circular stroke with location, color, outline/filled * is used in DrawApp */ import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; public class SquareStroke extends Stroke { public SquareStroke(int x, int y, int r, boolean f) { // can call any parent or your own constructor // but it has to be the first statement super(x, y, r, f); // this(x, y, r, f, canvas.randomColor()); } public SquareStroke(int x, int y, int r, boolean f, Color c) { super(x, y, r, f, c); } /** * Draws on the cprivateanvas this circular stroke */ // private parent variables may still be accessible through accessor methods public void draw(GraphicsContext gc) { if (filled == true) { gc.setFill(color); gc.fillRect(ulx, uly, width, height); } else { gc.setStroke(color); gc.strokeRect(ulx, uly, width, height); } } }