/*
* 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.
*/
// static final Dimension roundThumbSize = new Dimension(21 + 4, 21 + 4); // +2px on both sides for focus fuzz
// static final Dimension pointingThumbSize = new Dimension(19 + 4, 22 + 4);
protected static final RecyclableSingleton<SizeDescriptor> roundThumbDescriptor = new RecyclableSingleton<SizeDescriptor>() {
protected SizeDescriptor getInstance() {
}
}
};
}
};
protected static final RecyclableSingleton<SizeDescriptor> pointingThumbDescriptor = new RecyclableSingleton<SizeDescriptor>() {
protected SizeDescriptor getInstance() {
}
}
};
}
};
static final AquaPainter<JRSUIState> trackPainter = AquaPainter.create(JRSUIStateFactory.getSliderTrack(), new NineSliceMetricsProvider() {
}
}
});
final AquaPainter<JRSUIState> thumbPainter = AquaPainter.create(JRSUIStateFactory.getSliderThumb());
protected transient boolean fIsDragging = false;
// From AppearanceManager doc
// Create PLAF
return new AquaSliderUI((JSlider)c);
}
super(b);
}
super.installUI(c);
}
return new TrackListener();
}
super.installListeners(s);
}
super.uninstallListeners(s);
}
}
// Paint Methods
// We have to override paint of BasicSliderUI because we need slight differences.
// We don't paint focus the same way - it is part of the thumb.
// We also need to repaint the whole track when the thumb moves.
final Orientation orientation = slider.getOrientation() == SwingConstants.HORIZONTAL ? Orientation.HORIZONTAL : Orientation.VERTICAL;
if (slider.getPaintTrack()) {
// This is needed for when this is used as a renderer. It is the same as BasicSliderUI.java
// and is missing from our reimplementation.
//
// <rdar://problem/3721898> JSlider in TreeCellRenderer component not painted properly.
//
if (!trackIntersectsClip) {
}
}
paintTicks(g);
}
paintLabels(g);
}
}
}
// Paints track and thumb
public void paintTrack(final Graphics g, final JComponent c, final Orientation orientation, final State state) {
// for debugging
//g.setColor(Color.green);
//g.drawRect(trackRect.x, trackRect.y, trackRect.width - 1, trackRect.height - 1);
}
// Paints thumb only
public void paintThumb(final Graphics g, final JComponent c, final Orientation orientation, final State state) {
// for debugging
//g.setColor(Color.blue);
//g.drawRect(thumbRect.x, thumbRect.y, thumbRect.width - 1, thumbRect.height - 1);
}
if (shouldUseArrowThumb()) {
}
}
}
if (fIsDragging) {
}
}
}
} else {
if (disabledTickColor == null) {
disabledTickColor = new Color(tickColor.getRed(), tickColor.getGreen(), tickColor.getBlue(), tickColor.getAlpha() / 2);
}
}
super.paintTicks(g);
}
// Layout Methods
// Used lots
protected void calculateThumbLocation() {
super.calculateThumbLocation();
if (shouldUseArrowThumb()) {
}
}
}
}
}
// Only called from calculateGeometry
protected void calculateThumbSize() {
final SizeDescriptor descriptor = shouldUseArrowThumb() ? pointingThumbDescriptor.get() : roundThumbDescriptor.get();
} else {
}
}
protected boolean shouldUseArrowThumb() {
final Object shouldPaintArrowThumbProperty = slider.getClientProperty("Slider.paintThumbArrowShape");
}
return false;
}
protected void calculateTickRect() {
// super assumes tickRect ends align with trackRect ends.
// Ours need to inset by trackBuffer
// Ours also needs to be *inside* trackRect
} else {
}
}
// Basic's preferred size doesn't allow for our focus ring, throwing off things like SwingSet2
}
}
return new ChangeListener() {
public void stateChanged(final ChangeEvent e) {
if (fIsDragging) return;
}
};
}
// This is copied almost verbatim from superclass, except we changed things to use fIsDragging
// instead of isDragging since isDragging was a private member.
protected transient int offset;
currentMouseX = -1;
currentMouseY = -1;
offset = 0;
scrollTimer.stop();
// This is the way we have to determine snap-to-ticks. It's hard to explain
// but since ChangeEvents don't give us any idea what has changed we don't
// have a way to stop the thumb bounds from being recalculated. Recalculating
// the thumb bounds moves the thumb over the current value (i.e., snapping
// to the ticks).
fIsDragging = false;
slider.setValueIsAdjusting(false);
} else {
slider.setValueIsAdjusting(false);
fIsDragging = false;
}
}
// We should recalculate geometry just before
// calculation of the thumb movement direction.
// It is important for the case, when JSlider
// is a cell editor in JTable. See 6348946.
currentMouseX = e.getX();
currentMouseY = e.getY();
if (slider.isRequestFocusEnabled()) {
}
// we don't want to move the thumb if we just clicked on the edge of the thumb
if (!firstClick || !isMouseEventInThumb) {
slider.setValueIsAdjusting(true);
switch (slider.getOrientation()) {
case SwingConstants.VERTICAL:
break;
case SwingConstants.HORIZONTAL:
break;
}
slider.setValueIsAdjusting(false);
isMouseEventInThumb = true; // since we just moved it in there
}
// Clicked in the Thumb area?
if (isMouseEventInThumb) {
switch (slider.getOrientation()) {
case SwingConstants.VERTICAL:
break;
case SwingConstants.HORIZONTAL:
break;
}
fIsDragging = true;
return;
}
fIsDragging = false;
}
if (r.y + r.height <= currentMouseY) return false;
} else {
if (r.y >= currentMouseY) return false;
}
} else {
if (r.x + r.width >= currentMouseX) return false;
} else {
if (r.x <= currentMouseX) return false;
}
}
return false;
}
return false;
}
return true;
}
/**
* of the thumb relative to the origin of the track.
*/
int thumbMiddle = 0;
currentMouseX = e.getX();
currentMouseY = e.getY();
if (!fIsDragging) return;
slider.setValueIsAdjusting(true);
switch (slider.getOrientation()) {
case SwingConstants.VERTICAL:
if (drawInverted()) {
trackBottom = vMax;
} else {
}
break;
case SwingConstants.HORIZONTAL:
if (drawInverted()) {
} else {
trackRight = hMax;
}
break;
default:
return;
}
// enable live snap-to-ticks <rdar://problem/3165310>
if (slider.getSnapToTicks()) {
}
}
}
// Super handles snap-to-ticks by recalculating the thumb rect in the TrackListener
// See setThumbLocation for why that doesn't work
int getScale() {
return scale;
}
}