jdk/src/share/classes/java/awt/event/PaintEvent.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 440 a3dac373f62d
child 5506 202f599c92aa
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 440
diff changeset
     2
 * Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt.event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * The component-level paint event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * This event is a special type which is used to ensure that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * paint/update method calls are serialized along with the other
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * events delivered from the event queue.  This event is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * designed to be used with the Event Listener model; programs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * should continue to override paint/update methods in order
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * render themselves properly.
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    39
 * <p>
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    40
 * An unspecified behavior will be caused if the {@code id} parameter
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    41
 * of any particular {@code PaintEvent} instance is not
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    42
 * in the range from {@code PAINT_FIRST} to {@code PAINT_LAST}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @author Amy Fowler
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @since 1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
public class PaintEvent extends ComponentEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * Marks the first integer id for the range of paint event ids.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    public static final int PAINT_FIRST         = 800;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * Marks the last integer id for the range of paint event ids.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    public static final int PAINT_LAST          = 801;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * The paint event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public static final int PAINT = PAINT_FIRST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * The update event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    public static final int UPDATE = PAINT_FIRST + 1; //801
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * This is the rectangle that represents the area on the source
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * component that requires a repaint.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * This rectangle should be non null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @see java.awt.Rectangle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @see #setUpdateRect(Rectangle)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @see #getUpdateRect()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    Rectangle updateRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    private static final long serialVersionUID = 1267492026433337593L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Constructs a <code>PaintEvent</code> object with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * source component and type.
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    89
     * <p> This method throws an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * <code>IllegalArgumentException</code> if <code>source</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    93
     * @param source     The object where the event originated
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    94
     * @param id           The integer that identifies the event type.
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    95
     *                     For information on allowable values, see
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    96
     *                     the class description for {@link PaintEvent}
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    97
     * @param updateRect The rectangle area which needs to be repainted
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @throws IllegalArgumentException if <code>source</code> is null
440
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
    99
     * @see #getSource()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   100
     * @see #getID()
a3dac373f62d 6520716: event classes lack info about parameters
dav
parents: 2
diff changeset
   101
     * @see #getUpdateRect()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    public PaintEvent(Component source, int id, Rectangle updateRect) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        super(source, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        this.updateRect = updateRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * Returns the rectangle representing the area which needs to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * repainted in response to this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public Rectangle getUpdateRect() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        return updateRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Sets the rectangle representing the area which needs to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * repainted in response to this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @param updateRect the rectangle area which needs to be repainted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    public void setUpdateRect(Rectangle updateRect) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        this.updateRect = updateRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        String typeStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        switch(id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
          case PAINT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
              typeStr = "PAINT";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
          case UPDATE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
              typeStr = "UPDATE";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
              typeStr = "unknown type";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        return typeStr + ",updateRect="+(updateRect != null ? updateRect.toString() : "null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
}