/**
 * Program to create a recursive graphics which looks like broccoli.
 * Written 11/4/99 by Kim Bruce
 */

import objectdraw.*;

public class LivingBroccoli extends WindowController{

    private Location lastLocation;  // Where mouse was before last mouse event
    private BroccoliBranch plant;       // Broccoli object to be drawn and moved
    private boolean dragging = false;
        
  /**
   * Create the broccoli
   */
  public void begin() {
        plant = new BroccoliBranch(new Location(200,350), 80.0, Math.PI/2.0,canvas);
  }

    // Get ready to move broccoli
    public void onMousePress( Location point) {
        if (plant.contains(point)) {
            lastLocation = point;
            dragging=true;
        }
    }
    
    // Drag the broccoli around
    public void onMouseDrag( Location point) {
        if (dragging) {
            plant.move( point.getX()-lastLocation.getX(), point.getY()-lastLocation.getY());
            lastLocation = point;
        }
    }
    
    public void onMouseRelease(Location pt) {
        dragging=false;
    }

}
