01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19: package org.apache.batik.gvt.event;
20:
21: import java.awt.Shape;
22:
23: /**
24: * An event which indicates that a selection is being made or has been made.
25: *
26: * @author <a href="mailto:bill.haneman@ireland.sun.com">Bill Haneman</a>
27: * @author <a href="mailto:tkormann@ilog.fr">Thierry Kormann</a>
28: * @version $Id: SelectionEvent.java 475477 2006-11-15 22:44:28Z cam $
29: */
30: public class SelectionEvent {
31:
32: /**
33: * The id for the "selection changing" event.
34: * (Selection process is under way)
35: */
36: public static final int SELECTION_CHANGED = 1;
37:
38: /**
39: * The id for the "selection cleared" event.
40: */
41: public static final int SELECTION_CLEARED = 3;
42:
43: /**
44: * The id for the "selection started" event.
45: */
46: public static final int SELECTION_STARTED = 4;
47:
48: /**
49: * The id for the "selection completed" event.
50: * (Selection process is complete).
51: */
52: public static final int SELECTION_DONE = 2;
53:
54: /** The shape enclosing the selection */
55: protected Shape highlightShape;
56:
57: /** The object which composes the selection */
58: protected Object selection;
59:
60: /** The event type of the current selection event */
61: protected int id;
62:
63: /**
64: * Constructs a new graphics node paint event.
65: * @param selection the selection
66: * @param id the id of this event
67: * @param highlightShape a user-space shape enclosing the selection.
68: */
69: public SelectionEvent(Object selection, int id, Shape highlightShape) {
70: this .id = id;
71: this .selection = selection;
72: this .highlightShape = highlightShape;
73: }
74:
75: /**
76: * Returns a shape in user space that encloses the current selection.
77: */
78: public Shape getHighlightShape() {
79: return highlightShape;
80: }
81:
82: /**
83: * Returns the selection associated with this event.
84: * Only guaranteed current for events of type SELECTION_DONE.
85: */
86: public Object getSelection() {
87: return selection;
88: }
89:
90: /**
91: * Returns the event's selection event type.
92: * @see org.apache.batik.gvt.event.SelectionEvent#SELECTION_CHANGED
93: * @see org.apache.batik.gvt.event.SelectionEvent#SELECTION_CLEARED
94: * @see org.apache.batik.gvt.event.SelectionEvent#SELECTION_DONE
95: */
96: public int getID() {
97: return id;
98: }
99: }
|