01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Michael Danilov
19: * @version $Revision$
20: */package java.awt.event;
21:
22: import java.awt.Component;
23:
24: public class MouseWheelEvent extends MouseEvent {
25:
26: private static final long serialVersionUID = -9187413581993563929L;
27:
28: public static final int WHEEL_UNIT_SCROLL = 0;
29:
30: public static final int WHEEL_BLOCK_SCROLL = 1;
31:
32: private int wheelRotation;
33: private int scrollAmount;
34: private int scrollType;
35:
36: public MouseWheelEvent(Component source, int id, long when,
37: int modifiers, int x, int y, int clickCount,
38: boolean popupTrigger, int scrollType, int scrollAmount,
39: int wheelRotation) {
40: super (source, id, when, modifiers, x, y, clickCount,
41: popupTrigger);
42:
43: this .scrollType = scrollType;
44: this .scrollAmount = scrollAmount;
45: this .wheelRotation = wheelRotation;
46: }
47:
48: public int getScrollAmount() {
49: return scrollAmount;
50: }
51:
52: public int getScrollType() {
53: return scrollType;
54: }
55:
56: public int getWheelRotation() {
57: return wheelRotation;
58: }
59:
60: public int getUnitsToScroll() {
61: return (scrollAmount * wheelRotation);
62: }
63:
64: @Override
65: public String paramString() {
66: /* The format is based on 1.5 release behavior
67: * which can be revealed by the following code:
68: *
69: * MouseWheelEvent e = new MouseWheelEvent(new Component(){},
70: * MouseWheelEvent.MOUSE_WHEEL, 0,
71: * MouseEvent.BUTTON1_DOWN_MASK|MouseEvent.CTRL_DOWN_MASK,
72: * 10, 20, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL,
73: * 1, 3);
74: * System.out.println(e);
75: */
76:
77: String paramString = super .paramString();
78: String typeString = null;
79:
80: switch (scrollType) {
81: case WHEEL_UNIT_SCROLL:
82: typeString = "WHEEL_UNIT_SCROLL"; //$NON-NLS-1$
83: break;
84: case WHEEL_BLOCK_SCROLL:
85: typeString = "WHEEL_BLOCK_SCROLL"; //$NON-NLS-1$
86: break;
87: default:
88: typeString = "unknown type"; //$NON-NLS-1$
89: }
90:
91: paramString += ",scrollType=" + typeString + //$NON-NLS-1$
92: ",scrollAmount=" + scrollAmount + //$NON-NLS-1$
93: ",wheelRotation=" + wheelRotation; //$NON-NLS-1$
94:
95: return paramString;
96: }
97:
98: }
|