001    /*
002     * SmartCanvas.java
003     * Part of the Scribble problem set.
004     *
005     * Developed for "Rethinking CS101", a project of Lynn Andrea Stein's AP Group.
006     * For more information, see http://www.ai.mit.edu/projects/cs101, the
007     * CS101 homepage or email las@ai.mit.edu.
008     *
009     * Copyright (C) 1998 Massachusetts Institute of Technology.
010     * Please do not redistribute without obtaining permission.
011     */
012    
013    package scribble;
014    
015    import java.awt.*;
016    
017    /**
018     * GUI component corresponding to the drawing space.  As implemented,
019     * it doesn't do anything when you click on it, ie., it has no
020     * facility for handling mouse events.
021     *
022     * <P>Copyright (c) 1998 Massachusetts Institute of Technology
023     *
024     * @author Lynn Andrea Stein, las@ai.mit.edu
025     * @author Todd C. Parnell, tparnell@ai.mit.edu
026     * @version $Id: SmartCanvas.java,v 1.1.1.1 2002/06/05 21:56:35 root Exp $
027     */
028    public class SmartCanvas extends Canvas {
029      /** holds and paints the lines */
030      protected ScribbleData repository;
031    
032      private static final int PREFERRED_WIDTH = 300,
033        PREFERRED_HEIGHT = 200;
034    
035      /**
036       * Creates a new SmartCanvas.
037       */
038      public SmartCanvas() {
039        this (new ScribbleData());
040      }
041    
042      /**
043       * Creates a new SmartCanvas with associated ScribbleData. 
044       */
045      public SmartCanvas(ScribbleData repository) {
046        this.repository = repository;
047        this.repository.setGUI(this);
048        this.setSize(SmartCanvas.PREFERRED_WIDTH,
049                     SmartCanvas.PREFERRED_HEIGHT);
050      }
051    
052      /** Paints all Lines onto g. */
053      public void paint (Graphics g) {
054        this.repository.paintLines(g);
055      }
056    }
057    
058    /*
059     * $Log: SmartCanvas.java,v $
060     * Revision 1.1.1.1  2002/06/05 21:56:35  root
061     * CS101 comes to Olin finally.
062     *
063     * Revision 1.1  2000/05/06 22:30:58  mharder
064     * Moved to scribble subdirectory.
065     *
066     * Revision 1.4  1998/07/24 16:44:53  tparnell
067     * Placate new javadoc behavior
068     *
069     * Revision 1.3  1998/07/21 19:06:14  tparnell
070     * added more javadoc
071     *
072     * Revision 1.2  1998/07/20 18:55:33  tparnell
073     * Added javadoc and logging.  Minor code mods for greater consistency
074     * between files.
075     *
076     */
077    
078    
079    
080    
081    
082    
083    
084    
085    
086    
087    
088    
089    
090    
091