1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * 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 */ 21package java.awt.event; 22 23import java.awt.AWTEvent; 24import java.awt.Adjustable; 25 26/** 27 * This class is not supported in Android 1.0. It is merely provided to maintain 28 * interface compatibility with desktop Java implementations. 29 * 30 * @since Android 1.0 31 */ 32public class AdjustmentEvent extends AWTEvent { 33 34 private static final long serialVersionUID = 5700290645205279921L; 35 36 public static final int ADJUSTMENT_FIRST = 601; 37 38 public static final int ADJUSTMENT_LAST = 601; 39 40 public static final int ADJUSTMENT_VALUE_CHANGED = 601; 41 42 public static final int UNIT_INCREMENT = 1; 43 44 public static final int UNIT_DECREMENT = 2; 45 46 public static final int BLOCK_DECREMENT = 3; 47 48 public static final int BLOCK_INCREMENT = 4; 49 50 public static final int TRACK = 5; 51 52 private int type; 53 private int value; 54 private boolean isAdjusting; 55 56 public AdjustmentEvent(Adjustable source, int id, int type, int value) { 57 this(source, id, type, value, false); 58 } 59 60 public AdjustmentEvent(Adjustable source, int id, int type, int value, 61 boolean isAdjusting) { 62 super(source, id); 63 this.type = type; 64 this.value = value; 65 this.isAdjusting = isAdjusting; 66 } 67 68 public int getValue() { 69 return value; 70 } 71 72 public int getAdjustmentType() { 73 return type; 74 } 75 76 public boolean getValueIsAdjusting() { 77 return isAdjusting; 78 } 79 80 public Adjustable getAdjustable() { 81 return (Adjustable) source; 82 } 83 84 @Override 85 public String paramString() { 86 /* The format is based on 1.5 release behavior 87 * which can be revealed by the following code: 88 * 89 * AdjustmentEvent e = new AdjustmentEvent(new Scrollbar(), 90 * AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, 91 * AdjustmentEvent.UNIT_INCREMENT, 1); 92 * System.out.println(e); 93 */ 94 95 String idString = (id == ADJUSTMENT_VALUE_CHANGED ? 96 "ADJUSTMENT_VALUE_CHANGED" : "unknown type"); //$NON-NLS-1$ //$NON-NLS-2$ 97 String adjType = null; 98 99 switch (type) { 100 case UNIT_INCREMENT: 101 adjType = "UNIT_INCREMENT"; //$NON-NLS-1$ 102 break; 103 case UNIT_DECREMENT: 104 adjType = "UNIT_DECREMENT"; //$NON-NLS-1$ 105 break; 106 case BLOCK_INCREMENT: 107 adjType = "BLOCK_INCREMENT"; //$NON-NLS-1$ 108 break; 109 case BLOCK_DECREMENT: 110 adjType = "BLOCK_DECREMENT"; //$NON-NLS-1$ 111 break; 112 case TRACK: 113 adjType = "TRACK"; //$NON-NLS-1$ 114 break; 115 default: 116 adjType = "unknown type"; //$NON-NLS-1$ 117 } 118 119 return (idString + ",adjType=" + adjType + ",value=" + value + //$NON-NLS-1$ //$NON-NLS-2$ 120 ",isAdjusting=" + isAdjusting); //$NON-NLS-1$ 121 } 122 123} 124