Computer Science 252
 Problem Solving with Java
Spring 2015, The College of Saint Rose
SpiralLines Demo
A working demo of SpiralLines will appear below. Click inside the applet to interact with it.
SpiralLines BlueJ Project
Click here to download a BlueJ project for SpiralLines.
SpiralLines Source Code
The Java source code for SpiralLines is below. Click on a file name to download it.
import objectdraw.*;
/*
 * This program draws a "Spiral of Lines".  When the mouse is pressed
 * then dragged, a series of lines are drawn from the press point to
 * the current location.
 *
 * Jim Teresco, Siena College, CSCI 120, Spring 2011
 * Based on similar example from Williams College CS 134.
 * Updated for CSC 252, The College of Saint Rose, Fall 2013, Spring 2015
 *
 * $Id: Spirograph.java 2218 2013-10-18 14:06:39Z terescoj $
 */
public class SpiralLines extends WindowController {
    // First coordinate of a line segment
    private Location linesStart;
    /*
     * When the mouse is pressed, save the press point to be used as
     * the first endpoint of the lines drawn during dragging
     */
    public void onMousePress(Location point) {
        
        linesStart = point;
    } 
    /*
     * As the user is dragging, draw a line from
     * initial point where mouse pressed to current point.
     */
    public void onMouseDrag(Location point) {
        
        new Line(linesStart, point, canvas);
    }
}