3261N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A default L&F implementation of ScrollPaneUI. 0N/A * @author Hans Muller 0N/A * PropertyChangeListener installed on the vertical scrollbar. 0N/A * PropertyChangeListener installed on the horizontal scrollbar. 0N/A * State flag that shows whether setValue() was called from a user program 0N/A * before the value of "extent" was set in right-to-left component 0N/A * @return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE) 0N/A "ScrollPane.background",
0N/A "ScrollPane.foreground",
0N/A "ScrollPane.actionMap");
0N/A "ScrollPane.ancestorInputMap");
0N/A "ScrollPane.ancestorInputMap.RightToLeft")) ==
null)) {
0N/A /* Use a particular formula to calculate "value" 0N/A * until effective x coordinate is calculated. 0N/A /* After "extent" is set, turn setValueCalled flag off. 0N/A /* The following line can't handle a small value of 0N/A * viewPosition.x like Integer.MIN_VALUE correctly 0N/A * because (max - extent - viewPositoiin.x) causes 0N/A * an overflow. As a result, value becomes zero. 0N/A * (e.g. setViewPosition(Integer.MAX_VALUE, ...) 0N/A * in a user program causes a overflow. 0N/A * Its expected value is (max - extent).) 0N/A * However, this seems a trivial bug and adding a 0N/A * fix makes this often-called method slow, so I'll 0N/A * leave it until someone claims. 0N/A * Returns the baseline. 0N/A * @throws NullPointerException {@inheritDoc} 0N/A * @throws IllegalArgumentException {@inheritDoc} 0N/A * @see javax.swing.JComponent#getBaseline(int, int) 0N/A // Header is always given it's preferred size. 0N/A * Returns an enum indicating how the baseline of the component 0N/A * changes as the size changes. 0N/A * @throws NullPointerException {@inheritDoc} 0N/A * @see javax.swing.JComponent#getBaseline(int, int) 0N/A // Baseline is either from the header, in which case it's always 0N/A // the same size and therefor can be created as CONSTANT_ASCENT. 0N/A // If the header doesn't have a baseline than the baseline will only 0N/A // be valid if it's BaselineResizeBehavior is 0N/A // CONSTANT_ASCENT, so, return CONSTANT_ASCENT. 0N/A * Listener for viewport events. 0N/A // NOTE: This class exists only for backward compatability. All 0N/A // its functionality has been moved into Handler. If you need to add 0N/A // new functionality add it to the Handler, but make sure this 0N/A // class calls into the Handler. 0N/A * Horizontal scrollbar listener. 0N/A // NOTE: This class exists only for backward compatability. All 0N/A // its functionality has been moved into Handler. If you need to add 0N/A // new functionality add it to the Handler, but make sure this 0N/A // class calls into the Handler. 0N/A * Returns a <code>PropertyChangeListener</code> that will be installed 0N/A * on the horizontal <code>JScrollBar</code>. 0N/A * Vertical scrollbar listener. 0N/A // NOTE: This class exists only for backward compatability. All 0N/A // its functionality has been moved into Handler. If you need to add 0N/A // new functionality add it to the Handler, but make sure this 0N/A // class calls into the Handler. 0N/A * Returns a <code>PropertyChangeListener</code> that will be installed 0N/A * on the vertical <code>JScrollBar</code>. 0N/A * MouseWheelHandler is an inner class which implements the 0N/A * MouseWheelListener interface. MouseWheelHandler responds to 0N/A * MouseWheelEvents by scrolling the JScrollPane appropriately. 0N/A * If the scroll pane's 0N/A * <code>isWheelScrollingEnabled</code> 0N/A * method returns false, no scrolling occurs. 0N/A * @see javax.swing.JScrollPane#isWheelScrollingEnabled 0N/A * @see #createMouseWheelListener 0N/A * @see java.awt.event.MouseWheelListener 0N/A * @see java.awt.event.MouseWheelEvent 0N/A // NOTE: This class exists only for backward compatability. All 0N/A // its functionality has been moved into Handler. If you need to add 0N/A // new functionality add it to the Handler, but make sure this 0N/A // class calls into the Handler. 0N/A * Called when the mouse wheel is rotated while over a 0N/A * @param e MouseWheelEvent to be handled 0N/A * Creates an instance of MouseWheelListener, which is added to the 0N/A * JScrollPane by installUI(). The returned MouseWheelListener is used 0N/A * to handle mouse wheel-driven scrolling. 0N/A * @return MouseWheelListener which implements wheel-driven scrolling 0N/A * @see MouseWheelHandler 0N/A // NOTE: This class exists only for backward compatability. All 0N/A // its functionality has been moved into Handler. If you need to add 0N/A // new functionality add it to the Handler, but make sure this 0N/A // class calls into the Handler. 0N/A * Creates an instance of PropertyChangeListener that's added to 0N/A * the JScrollPane by installUI(). Subclasses can override this method 0N/A * to return a custom PropertyChangeListener, e.g. 0N/A * class MyScrollPaneUI extends BasicScrollPaneUI { 0N/A * protected PropertyChangeListener <b>createPropertyChangeListener</b>() { 0N/A * return new MyPropertyChangeListener(); 0N/A * public class MyPropertyChangeListener extends PropertyChangeListener { 0N/A * public void propertyChange(PropertyChangeEvent e) { 0N/A * if (e.getPropertyName().equals("viewport")) { 0N/A * // do some extra work when the viewport changes 0N/A * super.propertyChange(e); 0N/A * @see java.beans.PropertyChangeListener 0N/A // MouseWheelListener 0N/A // find which scrollbar to scroll, or return if none 0N/A // When the scrolling speed is set to maximum, it's possible 0N/A // for a single wheel click to scroll by more units than 0N/A // will fit in the visible area. This makes it 0N/A // Component with the wheel. To make for more accurate 0N/A // low-speed scrolling, we limit scrolling to the block 0N/A // increment if the wheel was only rotated one click. 0N/A // Check if we should use the visibleRect trick 0N/A "JScrollBar.fastWheelScrolling");
0N/A // 5078454: Under maximum acceleration, we may scroll 0N/A // by many 100s of units in ~1 second. 0N/A // BasicScrollBarUI.scrollByUnits() can bog down the EDT 0N/A // with repaints in this situation. However, the 0N/A // Scrollable interface allows us to pass in an 0N/A // arbitrary visibleRect. This allows us to accurately 0N/A // calculate the total scroll amount, and then update 0N/A // the GUI once. This technique provides much faster 0N/A // accelerated wheel scrolling. 0N/A // Modify the visible rect for the next unit, and 0N/A // check to see if we're at the end already. 0N/A else {
// (direction > 0 0N/A assert false :
"Non-sensical ComponentOrientation / scroll direction";
0N/A // Set the final view position on the ScrollBar 0N/A // rightToLeft scrollbars are oriented with 0N/A // minValue on the right and maxValue on the 0N/A // Viewport's view is not a Scrollable, or fast wheel 0N/A // scrolling is not enabled. 0N/A // ChangeListener: This is added to the vieport, and hsb/vsb models. 0N/A /* Set new X coordinate based on "value". 0N/A /* If setValue() was called before "extent" was fixed, 0N/A * turn setValueCalled flag on. 0N/A /* When a pane without a horizontal scroll bar was 0N/A * reduced and the bar appeared, the viewport should 0N/A * show the right side of the view. 0N/A // PropertyChangeListener: This is installed on both the JScrollPane 0N/A // Listens for changes in the model property and reinstalls the 0N/A // PropertyChangeListener for the horizontal and vertical scrollbars.