package jdraw.framework;

import java.awt.Rectangle;
import java.util.EventObject;

/**
 * An event which indicates that a draw model has changed.
 * This event is fired if new figures are added to a model or
 * if figures are removed from a model. The event is also fired
 * if one figure in a draw model changes (e.g. its size or its
 * position).
 * @see FigureListener
 *
 * @author  Dominik Gruntz
 * @version 2.0
 */

public class DrawModelEvent extends EventObject {

	/**
	 * This event indicates that a figure was added to the draw model.
	 */
	public final static int FIGURE_ADDED = 0;

	/**
	 * This event indicates that a figure was removed from the draw model.
	 */
	public final static int FIGURE_REMOVED = 1;

	/**
	 * This event indicates that a figure was changed in the draw model.
	 */
	public final static int FIGURE_CHANGED = 2;

	private Figure figure;
	private int type;
	
    /**
     * Constructs a DrawModelEvent object with the specified model.
     * @param source  model which changed
	 * @param figure  the affected figure
	 * @param type    an integer indicating the event type
	 */
    public DrawModelEvent(DrawModel source, Figure figure, int type) {
        super(source);
		this.figure = figure;
		this.type = type;
     }

    /**
     * Returns the draw model which changed.
     * @return changed model
     */
    public DrawModel getModel() {
        return (DrawModel)getSource();
    }
	
	/**
	 * Returns the figure which initiated the event.
	 * @return added, removed or changed figure (depending on event type)
	 */
	public Figure getFigure(){
		return figure;
	}
	/**
	 * Returns the event type.
	 * @return type of event
	 */
	public int getType(){
		return type;
	}
}
