package jdraw.framework;

import java.io.File;
import java.util.*;

/**
 * The class DrawModel represents the model of a drawing, i.e.
 * all figures stored in a graphic. Every draw view refers to a 
 * model.
 *
 * @see DrawView
 *
 * @author  Dominik Gruntz
 * @version 2.0, 26.04.01
 */
public interface DrawModel {
	
	/**
	 * Adds a new figure to the draw model.
	 * @param f figure to be added to draw model.
	 */
	public void addFigure(Figure f);
	
	/**
	 * Removes a given figure from the draw model.
	 * @param f figure to be removed from draw model.
	 */
	public void removeFigure(Figure f);
	
	/**
	 * Returns an iterator which can be used to iterate over
	 * all figures of a draw model.
	 * @return iterator to iterate over the draw model
	 */
	public Iterator getFigures();
		
	/**
	 * Adds the specified model listener to receive model events from 
	 * this draw model. If listener is null, no exception is thrown and no 
	 * action is performed.
	 * @param listener the draw model listener.
	 * @see DrawModelListener
	 */
	public void addModelChangeListener(DrawModelListener listener);


	/**
	 * Removes the specified model listener so that it no longer receives
	 * model events from this draw model. This method performs no function, 
	 * nor does it throw an exception, if the listener specified by the 
	 * argument was not previously added to this figure. 
	 * If listener is null, no exception is thrown and no action is performed.
	 * @param listener the draw model listener.
	 * @see DrawModelListener
	 */
	public void removeModelChangeListener(DrawModelListener listener);
	
	/**
	 * Saves all figures to file
	 * @param f File where figures should be written to
	 */
	public void saveFigures(File f);
	
	/**
	 * Loads figures from file
	 * @param f File where figures should be loaded from
	 */
	public void loadFigures(File f);
}
