// Copyright (c) 1995, 1996 Regents of the University of California.
// All rights reserved.
//
// This software was developed by the Arcadia project
// at the University of California, Irvine.
//
// Redistribution and use in source and binary forms are permitted
// provided that the above copyright notice and this paragraph are
// duplicated in all such forms and that any documentation,
// advertising materials, and other materials related to such
// distribution and use acknowledge that the software was developed
// by the University of California, Irvine.  The name of the
// University may not be used to endorse or promote products derived
// from this software without specific prior written permission.
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
// WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

// File: ModeCreate.java
// Classes: ModeCreate
// Original Author: Jason Robbins
// $Id: ModeCreate.java,v 1.2 2000/09/19 21:08:33 dougo Exp $

// Modified by : Kedar Patankar

package edu.neu.ccs.demeter.tools.apstudio.graphedit;

import java.awt.Graphics;
import java.awt.event.MouseEvent;

public abstract class ModeCreate extends Mode {

  /** original mouse down event coordinates */
//  protected int anchorX, anchorY;

  /** This holds the DiagramElement to be added to the parent Editor. */
  protected DiagramElement newItem;

  public ModeCreate(Document par) { super(par); }
  
  public void mouseDrag(MouseEvent e)
  {
	  parent.damaged(newItem);
	  creationDrag(e.getX(),e.getY());
	  parent.damaged(newItem);
  }

  /** Update the new item to reflect the new mouse position. By
   * default let the new item set its size, subclasses may override.
   *
   * @see ModeCreateFigLine#creationDrag */
  protected void creationDrag(int x, int y) {
    ((FigBentLine)newItem).createDrag(x, y); 
  }

  /** Draw this mode by drawing the new item. This is the only
   * feedback that the user will get since the new item is not
   * officially added to the Editor's document yet. */

  public void draw(Graphics g) {
    if (null != newItem) newItem.draw(g);
  }

 /** Construct a new DiagramElement to be added to the
  * Editor. Typically, subclasses will make a new instance of some Fig
  * based on the given mouse down event and the state of the parent
  * Editor (specifically, its default graphical attributes). */
  public abstract DiagramElement createNewItem(MouseEvent e);

} /* end class ModeCreate */

