/*
* Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* o Neither the name of Substance Kirill Grouchnikov nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.jvnet.substance;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.GeneralPath;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.EnumSet;
import java.util.Set;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicScrollBarUI;
import org.jvnet.lafwidget.animation.*;
import org.jvnet.lafwidget.layout.TransitionLayout;
import org.jvnet.substance.api.*;
import org.jvnet.substance.api.SubstanceConstants.ScrollPaneButtonPolicyKind;
import org.jvnet.substance.api.SubstanceConstants.Side;
import org.jvnet.substance.painter.border.SimplisticSoftBorderPainter;
import org.jvnet.substance.painter.border.SubstanceBorderPainter;
import org.jvnet.substance.painter.gradient.SimplisticGradientPainter;
import org.jvnet.substance.painter.gradient.SubstanceGradientPainter;
import org.jvnet.substance.painter.utils.SubstanceFillBackgroundDelegate;
import org.jvnet.substance.shaper.ClassicButtonShaper;
import org.jvnet.substance.shaper.SubstanceButtonShaper;
import org.jvnet.substance.utils.*;
import org.jvnet.substance.utils.icon.ArrowButtonTransitionAwareIcon;
import org.jvnet.substance.utils.scroll.SubstanceScrollButton;
/**
* UI for scroll bars in <b>Substance </b> look and feel.
*
* @author Kirill Grouchnikov
*/
public class SubstanceScrollBarUI extends BasicScrollBarUI implements Trackable {
/**
* The second decrease button. Is shown under
* {@link SubstanceConstants.ScrollPaneButtonPolicyKind#ADJACENT},
* {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE} and
* {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE_BOTH}
* modes.
*
* @since version 3.1
*/
protected JButton mySecondDecreaseButton;
/**
* The second increase button. Is shown only under
* {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE_BOTH} mode.
*
* @since version 3.1
*/
protected JButton mySecondIncreaseButton;
/**
* Surrogate button model for tracking the thumb transitions.
*/
private ButtonModel thumbModel;
/**
* Stores computed images for vertical thumbs.
*/
private static LazyResettableHashMap<BufferedImage> thumbVerticalMap = new LazyResettableHashMap<BufferedImage>(
"SubstanceScrollBarUI.thumbVertical");
/**
* Stores computed images for horizontal thumbs.
*/
private static LazyResettableHashMap<BufferedImage> thumbHorizontalMap = new LazyResettableHashMap<BufferedImage>(
"SubstanceScrollBarUI.thumbHorizontal");
/**
* Stores computed images for full vertical tracks under
* {@link DefaultControlBackgroundComposite}.
*/
private static LazyResettableHashMap<BufferedImage> trackFullVerticalMap = new LazyResettableHashMap<BufferedImage>(
"SubstanceScrollBarUI.trackFullVertical");
/**
* Stores computed images for full horizontal tracks under
* {@link DefaultControlBackgroundComposite}.
*/
private static LazyResettableHashMap<BufferedImage> trackFullHorizontalMap = new LazyResettableHashMap<BufferedImage>(
"SubstanceScrollBarUI.trackFullHorizontal");
/**
* Mouse listener on the associated scroll bar.
*/
private MouseListener substanceMouseListener;
/**
* Listener for thumb fade animations.
*/
private RolloverControlListener substanceThumbRolloverListener;
/**
* Listener for fade animations.
*/
protected FadeStateListener substanceFadeStateListener;
/**
* Property change listener.
*
*/
private PropertyChangeListener substancePropertyListener;
/**
* Scroll bar width.
*/
protected int scrollBarWidth;
/**
* Cache of images for horizontal tracks.
*/
private static LazyResettableHashMap<BufferedImage> trackHorizontalMap = new LazyResettableHashMap<BufferedImage>(
"SubstanceScrollBarUI.trackHorizontal");
/**
* Cache of images for vertical tracks.
*/
private static LazyResettableHashMap<BufferedImage> trackVerticalMap = new LazyResettableHashMap<BufferedImage>(
"SubstanceScrollBarUI.trackVertical");
/**
* Listener on adjustments made to the scrollbar model - this is for the
* overlay mode (see {@link SubstanceLookAndFeel#OVERLAY_PROPERTY} and
* repaiting both scrollbars with the viewport.
*
* @since version 3.2
*/
protected AdjustmentListener substanceAdjustmentListener;
/**
* Surrogate model to sync between rollover effects of scroll buttons and
* scroll track / scroll thumb.
*
* @since version 3.2
*/
protected CompositeButtonModel compositeScrollTrackModel;
/**
* Surrogate model to sync between rollover effects of scroll buttons and
* scroll track / scroll thumb.
*
* @since version 3.2
*/
protected CompositeButtonModel compositeButtonsModel;
/*
* (non-Javadoc)
*
* @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent)
*/
public static ComponentUI createUI(JComponent comp) {
SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp);
return new SubstanceScrollBarUI(comp);
}
/**
* Simple constructor.
*
* @param b
* Associated component.
*/
protected SubstanceScrollBarUI(JComponent b) {
super();
this.thumbModel = new DefaultButtonModel();
this.thumbModel.setArmed(false);
this.thumbModel.setSelected(false);
this.thumbModel.setPressed(false);
this.thumbModel.setRollover(false);
b.setOpaque(false);
}
/**
* Creates a decrease button.
*
* @param orientation
* Button orientation.
* @param isRegular
* if <code>true</code>, the regular (upper / left) decrease
* button is created, if <code>false</code>, the additional
* (lower / right) decrease button is created for
* {@link SubstanceConstants.ScrollPaneButtonPolicyKind#ADJACENT}
* ,
* {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE}
* and
* {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE_BOTH}
* kinds.
* @return Decrease button.
*/
protected JButton createGeneralDecreaseButton(final int orientation,
boolean
- 1
- 2
- 3
- 4
- 5
前往页