/** * Program to create a recursive graphics which looks like parsley. * Written 11/4/99 by Kim Bruce * Modified 4/23/00 by Andrea Danyluk * Modified 30xi06 by Rhys Price Jones */ import objectdraw.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; public class LivingParsley extends WindowController{ private Location lastLocation; // Where mouse was before last mouse event private ParsleyTree plant; // Parsley object to be drawn and moved // Create the parsley public void begin() { JButton start = new JButton("start"); start.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { plant = new ParsleyTree(new Location(200,300), 150.0, Math.PI/2.0, canvas); } }); add(start, BorderLayout.SOUTH); } // Get ready to move parsley public void onMousePress( Location point) { lastLocation = point; } // Drag the parsley around public void onMouseDrag( Location point) { plant.move( point.getX()-lastLocation.getX(), point.getY()-lastLocation.getY()); lastLocation = point; } }