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