import objectdraw.*;

/**
 * Interface implemented by arithmetic expressions
 * 
 * @author Russell C. Bjork 
 * @version March 20, 2008
 */
public interface Expression
{
    /** Convert this expression to a string
     * 
     *  @return the string form of this Expression
     */
    String toString();
    
    /** Evaluate this expression for a given value of the variable "X"
     * 
     *  @param x the value of x at which to evaluate this expression
     */
    double evaluate(double x);
    
    /** Take the derivative of this expression
     *
     *  @return the tree form of the derivative
     */
    Expression derivative();
    
    /** Simplify this expression
     * 
     *  @return the simplified form of the expression - or this if no
     *          simplification is possible
     */
    Expression simplify();
    
    /** Draw the tree form of this expression
     * 
     *  @param x the x coordinate of the upper left hand corner of the tree
     *  @param y the y coordinate of the upper left hand corner of the tree
     *  @param width the width of the area in which to draw the tree - the
     *         tree will be centered within this
     *  (No height is specified - the tree will start at the y coordinate
     *   specified and will be as high as needed)
     *  @param canvas the canvas on which to draw the tree.
     */
    void draw(double x, double y, double width, DrawingCanvas canvas);
    
    /** The diameter for circles used to represent tree nodes
     */
    int TREE_NODE_DIAMETER = 30;
}
