/*
 * @(#)PaintActionEvent.java    1.0   2 May 2006
 *
 * Copyright 2006
 * College of Computer and Information Science
 * Northeastern University
 * Boston, MA  02115
 *
 * The Java Power Tools software may be used for educational
 * purposes as long as this copyright notice is retained intact
 * at the top of all source files.
 *
 * To discuss possible commercial use of this software, 
 * contact Richard Rasala at Northeastern University, 
 * College of Computer and Information Science,
 * 617-373-2462 or rasala@ccs.neu.edu.
 *
 * The Java Power Tools software has been designed and built
 * in collaboration with Viera Proulx and Jeff Raab.
 *
 * Should this software be modified, the words "Modified from 
 * Original" must be included as a comment below this notice.
 *
 * All publication rights are retained.  This software or its 
 * documentation may not be published in any media either
 * in whole or in part without explicit permission.
 *
 * This software was created with support from Northeastern 
 * University and from NSF grant DUE-9950829.
 */

package edu.neu.ccs.gui;

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;

/**
 * <P>Class of events representing an action
 * triggered by a call to paint a component.</P>
 *
 * @author  Jeff Raab
 * @version 2.2
 * @since   2.2
 */
public class PaintActionEvent extends ActionEvent {
   
    /** 
     * The graphics context of the component that triggered 
     * this change action event. 
     */
    protected Graphics graphicsContext = null;

    /**
     * Constructs a paint action event
     * triggered by the given source object,
     * with the given graphics context.
     *
     * @param g graphics context of the component source
     * @param source the object that originated the event
     */
    public PaintActionEvent(Object source, Graphics g) {
        this(source, g, ActionEvent.ACTION_PERFORMED, null);
    }

    /**
     * Constructs a repaint action event
     * triggered by the given source object,
     * with the given graphics context, identifier and command name.
     *
     * @param g       graphics context of the component source
     * @param source  the object that originated the event
     * @param id      an integer that identifies the event
     * @param command a string that may specify a command 
     *                (possibly one of several)
     *                associated with the event
     */
    public PaintActionEvent(
        Object source, 
        Graphics g,
        int id, 
        String command) 
    {
        super(source, id, command);
        graphicsContext = g;
    }

    /**
     * Returns the graphics context of the component
     * that triggered this paint action event.
     */
    public Graphics getGraphics() {
        return graphicsContext;
    }
    
    /**
     * Returns the component source that triggered
     * this paint action event.
     *
     * @throws ClassCastException if the source object
     *      for this action event is not of type Component
     */
    public Component getComponent() {
        return (Component)getSource();
    }
}

