001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Michael Danilov
019: * @version $Revision$
020: */package java.awt.event;
021:
022: import java.awt.AWTEvent;
023: import java.awt.Adjustable;
024:
025: public class AdjustmentEvent extends AWTEvent {
026:
027: private static final long serialVersionUID = 5700290645205279921L;
028:
029: public static final int ADJUSTMENT_FIRST = 601;
030:
031: public static final int ADJUSTMENT_LAST = 601;
032:
033: public static final int ADJUSTMENT_VALUE_CHANGED = 601;
034:
035: public static final int UNIT_INCREMENT = 1;
036:
037: public static final int UNIT_DECREMENT = 2;
038:
039: public static final int BLOCK_DECREMENT = 3;
040:
041: public static final int BLOCK_INCREMENT = 4;
042:
043: public static final int TRACK = 5;
044:
045: private int type;
046: private int value;
047: private boolean isAdjusting;
048:
049: public AdjustmentEvent(Adjustable source, int id, int type,
050: int value) {
051: this (source, id, type, value, false);
052: }
053:
054: public AdjustmentEvent(Adjustable source, int id, int type,
055: int value, boolean isAdjusting) {
056: super (source, id);
057: this .type = type;
058: this .value = value;
059: this .isAdjusting = isAdjusting;
060: }
061:
062: public int getValue() {
063: return value;
064: }
065:
066: public int getAdjustmentType() {
067: return type;
068: }
069:
070: public boolean getValueIsAdjusting() {
071: return isAdjusting;
072: }
073:
074: public Adjustable getAdjustable() {
075: return (Adjustable) source;
076: }
077:
078: @Override
079: public String paramString() {
080: /* The format is based on 1.5 release behavior
081: * which can be revealed by the following code:
082: *
083: * AdjustmentEvent e = new AdjustmentEvent(new Scrollbar(),
084: * AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
085: * AdjustmentEvent.UNIT_INCREMENT, 1);
086: * System.out.println(e);
087: */
088:
089: String idString = (id == ADJUSTMENT_VALUE_CHANGED ? "ADJUSTMENT_VALUE_CHANGED" : "unknown type"); //$NON-NLS-1$ //$NON-NLS-2$
090: String adjType = null;
091:
092: switch (type) {
093: case UNIT_INCREMENT:
094: adjType = "UNIT_INCREMENT"; //$NON-NLS-1$
095: break;
096: case UNIT_DECREMENT:
097: adjType = "UNIT_DECREMENT"; //$NON-NLS-1$
098: break;
099: case BLOCK_INCREMENT:
100: adjType = "BLOCK_INCREMENT"; //$NON-NLS-1$
101: break;
102: case BLOCK_DECREMENT:
103: adjType = "BLOCK_DECREMENT"; //$NON-NLS-1$
104: break;
105: case TRACK:
106: adjType = "TRACK"; //$NON-NLS-1$
107: break;
108: default:
109: adjType = "unknown type"; //$NON-NLS-1$
110: }
111:
112: return (idString + ",adjType=" + adjType + ",value=" + value + //$NON-NLS-1$ //$NON-NLS-2$
113: ",isAdjusting=" + isAdjusting); //$NON-NLS-1$
114: }
115:
116: }
|