modules/controls/src/main/java/javafx/scene/control/skin/PaginationSkin.java
Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization
*** 1,7 ****
/*
! * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 21,41 ****
* 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.
*/
! package com.sun.javafx.scene.control.skin;
import javafx.beans.property.DoubleProperty;
import javafx.css.StyleableBooleanProperty;
import javafx.css.StyleableDoubleProperty;
import javafx.css.StyleableObjectProperty;
import javafx.css.CssMetaData;
! import com.sun.javafx.css.converters.BooleanConverter;
! import com.sun.javafx.css.converters.EnumConverter;
! import com.sun.javafx.css.converters.SizeConverter;
import com.sun.javafx.scene.control.behavior.PaginationBehavior;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
--- 21,42 ----
* 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.
*/
! package javafx.scene.control.skin;
+ import com.sun.javafx.scene.control.skin.Utils;
import javafx.beans.property.DoubleProperty;
import javafx.css.StyleableBooleanProperty;
import javafx.css.StyleableDoubleProperty;
import javafx.css.StyleableObjectProperty;
import javafx.css.CssMetaData;
! import javafx.css.converter.BooleanConverter;
! import javafx.css.converter.EnumConverter;
! import javafx.css.converter.SizeConverter;
import com.sun.javafx.scene.control.behavior.PaginationBehavior;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
*** 43,53 ****
import javafx.animation.*;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.value.ChangeListener;
- import javafx.beans.value.ObservableValue;
import javafx.beans.value.WritableValue;
import javafx.collections.ListChangeListener;
import javafx.css.Styleable;
import javafx.css.StyleableProperty;
import javafx.event.ActionEvent;
--- 44,53 ----
*** 69,83 ****
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;
import static com.sun.javafx.scene.control.skin.resources.ControlResources.getString;
! public class PaginationSkin extends BehaviorSkinBase<Pagination, PaginationBehavior> {
private static final Duration DURATION = new Duration(125.0);
private static final double SWIPE_THRESHOLD = 0.30;
private static final double TOUCH_THRESHOLD = 15;
private Pagination pagination;
private StackPane currentStackPane;
private StackPane nextStackPane;
private Timeline timeline;
--- 69,104 ----
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;
import static com.sun.javafx.scene.control.skin.resources.ControlResources.getString;
! /**
! * Default skin implementation for the {@link Pagination} control.
! *
! * @see Pagination
! * @since 9
! */
! public class PaginationSkin extends SkinBase<Pagination> {
!
! /***************************************************************************
! * *
! * Static fields *
! * *
! **************************************************************************/
private static final Duration DURATION = new Duration(125.0);
private static final double SWIPE_THRESHOLD = 0.30;
private static final double TOUCH_THRESHOLD = 15;
+ private static final Interpolator interpolator = Interpolator.SPLINE(0.4829, 0.5709, 0.6803, 0.9928);
+
+
+
+ /***************************************************************************
+ * *
+ * Private fields *
+ * *
+ **************************************************************************/
private Pagination pagination;
private StackPane currentStackPane;
private StackPane nextStackPane;
private Timeline timeline;
*** 89,108 ****
private int currentIndex;
private int toIndex;
private int pageCount;
private int maxPageIndicatorCount;
private boolean animate = true;
! public PaginationSkin(final Pagination pagination) {
! super(pagination, new PaginationBehavior(pagination));
// setManaged(false);
clipRect = new Rectangle();
getSkinnable().setClip(clipRect);
! this.pagination = pagination;
this.currentStackPane = new StackPane();
currentStackPane.getStyleClass().add("page");
this.nextStackPane = new StackPane();
--- 110,193 ----
private int currentIndex;
private int toIndex;
private int pageCount;
private int maxPageIndicatorCount;
+ private double startTouchPos;
+ private double lastTouchPos;
+ private long startTouchTime;
+ private long lastTouchTime;
+ private double touchVelocity;
+ private boolean touchThresholdBroken;
+ private int touchEventId = -1;
+ private boolean nextPageReached = false;
+ private boolean setInitialDirection = false;
+ private int direction;
+
+ private int currentAnimatedIndex;
+ private boolean hasPendingAnimation = false;
+
private boolean animate = true;
! private final PaginationBehavior behavior;
!
!
!
! /***************************************************************************
! * *
! * Listeners *
! * *
! **************************************************************************/
!
! private EventHandler<ActionEvent> swipeAnimationEndEventHandler = new EventHandler<ActionEvent>() {
! @Override public void handle(ActionEvent t) {
! swapPanes();
! timeline = null;
!
! if (hasPendingAnimation) {
! animateSwitchPage();
! hasPendingAnimation = false;
! }
! }
! };
!
! private EventHandler<ActionEvent> clampAnimationEndEventHandler = new EventHandler<ActionEvent>() {
! @Override public void handle(ActionEvent t) {
! currentStackPane.setTranslateX(0);
! nextStackPane.setTranslateX(0);
! nextStackPane.setVisible(false);
! timeline = null;
! }
! };
!
!
!
! /***************************************************************************
! * *
! * Constructors *
! * *
! **************************************************************************/
!
! /**
! * Creates a new PaginationSkin instance, installing the necessary child
! * nodes into the Control {@link Control#getChildren() children} list, as
! * well as the necessary input mappings for handling key, mouse, etc events.
! *
! * @param control The control that this skin should be installed onto.
! */
! public PaginationSkin(final Pagination control) {
! super(control);
!
! // install default input map for the Pagination control
! behavior = new PaginationBehavior(control);
! // control.setInputMap(behavior.getInputMap());
// setManaged(false);
clipRect = new Rectangle();
getSkinnable().setClip(clipRect);
! this.pagination = control;
this.currentStackPane = new StackPane();
currentStackPane.getStyleClass().add("page");
this.nextStackPane = new StackPane();
*** 113,162 ****
this.navigation = new NavigationControl();
getChildren().addAll(currentStackPane, nextStackPane, navigation);
! pagination.maxPageIndicatorCountProperty().addListener(o -> {
resetIndiciesAndNav();
});
! registerChangeListener(pagination.widthProperty(), "WIDTH");
! registerChangeListener(pagination.heightProperty(), "HEIGHT");
! registerChangeListener(pagination.pageCountProperty(), "PAGE_COUNT");
! registerChangeListener(pagination.pageFactoryProperty(), "PAGE_FACTORY");
initializeSwipeAndTouchHandlers();
}
! protected void resetIndiciesAndNav() {
! resetIndexes(false);
! navigation.initializePageIndicators();
! navigation.updatePageIndicators();
}
! public void selectNext() {
if (getCurrentPageIndex() < getPageCount() - 1) {
pagination.setCurrentPageIndex(getCurrentPageIndex() + 1);
}
}
! public void selectPrevious() {
if (getCurrentPageIndex() > 0) {
pagination.setCurrentPageIndex(getCurrentPageIndex() - 1);
}
}
! private double startTouchPos;
! private double lastTouchPos;
! private long startTouchTime;
! private long lastTouchTime;
! private double touchVelocity;
! private boolean touchThresholdBroken;
! private int touchEventId = -1;
! private boolean nextPageReached = false;
! private boolean setInitialDirection = false;
! private int direction;
private void initializeSwipeAndTouchHandlers() {
final Pagination control = getSkinnable();
getSkinnable().addEventHandler(TouchEvent.TOUCH_PRESSED, e -> {
--- 198,471 ----
this.navigation = new NavigationControl();
getChildren().addAll(currentStackPane, nextStackPane, navigation);
! control.maxPageIndicatorCountProperty().addListener(o -> {
resetIndiciesAndNav();
});
! registerChangeListener(control.widthProperty(), e -> clipRect.setWidth(getSkinnable().getWidth()));
! registerChangeListener(control.heightProperty(), e -> clipRect.setHeight(getSkinnable().getHeight()));
! registerChangeListener(control.pageCountProperty(), e -> resetIndiciesAndNav());
! registerChangeListener(control.pageFactoryProperty(), e -> {
! if (animate && timeline != null) {
! // If we are in the middle of a page animation.
! // Speedup and finish the animation then update the page factory.
! timeline.setRate(8);
! timeline.setOnFinished(arg0 -> {
! resetIndiciesAndNav();
! });
! return;
! }
! resetIndiciesAndNav();
! });
initializeSwipeAndTouchHandlers();
}
!
!
! /***************************************************************************
! * *
! * Properties *
! * *
! **************************************************************************/
!
! /** The size of the gap between number buttons and arrow buttons */
! private final DoubleProperty arrowButtonGap = new StyleableDoubleProperty(60.0) {
! @Override public Object getBean() {
! return PaginationSkin.this;
! }
! @Override public String getName() {
! return "arrowButtonGap";
! }
! @Override public CssMetaData<Pagination,Number> getCssMetaData() {
! return StyleableProperties.ARROW_BUTTON_GAP;
! }
! };
! private final DoubleProperty arrowButtonGapProperty() {
! return arrowButtonGap;
! }
! private final double getArrowButtonGap() {
! return arrowButtonGap.get();
! }
! private final void setArrowButtonGap(double value) {
! arrowButtonGap.set(value);
! }
!
! private BooleanProperty arrowsVisible;
! private final void setArrowsVisible(boolean value) { arrowsVisibleProperty().set(value); }
! private final boolean isArrowsVisible() { return arrowsVisible == null ? DEFAULT_ARROW_VISIBLE : arrowsVisible.get(); }
! private final BooleanProperty arrowsVisibleProperty() {
! if (arrowsVisible == null) {
! arrowsVisible = new StyleableBooleanProperty(DEFAULT_ARROW_VISIBLE) {
! @Override
! protected void invalidated() {
! getSkinnable().requestLayout();
! }
!
! @Override
! public CssMetaData<Pagination,Boolean> getCssMetaData() {
! return StyleableProperties.ARROWS_VISIBLE;
! }
!
! @Override
! public Object getBean() {
! return PaginationSkin.this;
! }
!
! @Override
! public String getName() {
! return "arrowVisible";
! }
! };
! }
! return arrowsVisible;
! }
!
! private BooleanProperty pageInformationVisible;
! private final void setPageInformationVisible(boolean value) { pageInformationVisibleProperty().set(value); }
! private final boolean isPageInformationVisible() { return pageInformationVisible == null ? DEFAULT_PAGE_INFORMATION_VISIBLE : pageInformationVisible.get(); }
! private final BooleanProperty pageInformationVisibleProperty() {
! if (pageInformationVisible == null) {
! pageInformationVisible = new StyleableBooleanProperty(DEFAULT_PAGE_INFORMATION_VISIBLE) {
! @Override
! protected void invalidated() {
! getSkinnable().requestLayout();
! }
!
! @Override
! public CssMetaData<Pagination,Boolean> getCssMetaData() {
! return StyleableProperties.PAGE_INFORMATION_VISIBLE;
! }
!
! @Override
! public Object getBean() {
! return PaginationSkin.this;
! }
!
! @Override
! public String getName() {
! return "pageInformationVisible";
! }
! };
! }
! return pageInformationVisible;
! }
!
! private ObjectProperty<Side> pageInformationAlignment;
! private final void setPageInformationAlignment(Side value) { pageInformationAlignmentProperty().set(value); }
! private final Side getPageInformationAlignment() { return pageInformationAlignment == null ? DEFAULT_PAGE_INFORMATION_ALIGNMENT : pageInformationAlignment.get(); }
! private final ObjectProperty<Side> pageInformationAlignmentProperty() {
! if (pageInformationAlignment == null) {
! pageInformationAlignment = new StyleableObjectProperty<Side>(Side.BOTTOM) {
! @Override
! protected void invalidated() {
! getSkinnable().requestLayout();
! }
!
! @Override
! public CssMetaData<Pagination,Side> getCssMetaData() {
! return StyleableProperties.PAGE_INFORMATION_ALIGNMENT;
! }
!
! @Override
! public Object getBean() {
! return PaginationSkin.this;
! }
!
! @Override
! public String getName() {
! return "pageInformationAlignment";
! }
! };
! }
! return pageInformationAlignment;
}
! private BooleanProperty tooltipVisible;
! private final void setTooltipVisible(boolean value) { tooltipVisibleProperty().set(value); }
! private final boolean isTooltipVisible() { return tooltipVisible == null ? DEFAULT_TOOLTIP_VISIBLE : tooltipVisible.get(); }
! private final BooleanProperty tooltipVisibleProperty() {
! if (tooltipVisible == null) {
! tooltipVisible = new StyleableBooleanProperty(DEFAULT_TOOLTIP_VISIBLE) {
! @Override
! protected void invalidated() {
! getSkinnable().requestLayout();
! }
!
! @Override
! public CssMetaData<Pagination,Boolean> getCssMetaData() {
! return StyleableProperties.TOOLTIP_VISIBLE;
! }
!
! @Override
! public Object getBean() {
! return PaginationSkin.this;
! }
!
! @Override
! public String getName() {
! return "tooltipVisible";
! }
! };
! }
! return tooltipVisible;
! }
!
!
!
! /***************************************************************************
! * *
! * Public API *
! * *
! **************************************************************************/
!
! /** {@inheritDoc} */
! @Override public void dispose() {
! super.dispose();
!
! if (behavior != null) {
! behavior.dispose();
! }
! }
!
! /** {@inheritDoc} */
! @Override protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
! double navigationWidth = navigation.isVisible() ? snapSize(navigation.minWidth(height)) : 0;
! return leftInset + Math.max(currentStackPane.minWidth(height), navigationWidth) + rightInset;
! }
!
! /** {@inheritDoc} */
! @Override protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
! double navigationHeight = navigation.isVisible() ? snapSize(navigation.minHeight(width)) : 0;
! return topInset + currentStackPane.minHeight(width) + navigationHeight + bottomInset;
! }
!
! /** {@inheritDoc} */
! @Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
! double navigationWidth = navigation.isVisible() ? snapSize(navigation.prefWidth(height)) : 0;
! return leftInset + Math.max(currentStackPane.prefWidth(height), navigationWidth) + rightInset;
! }
!
! /** {@inheritDoc} */
! @Override protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
! double navigationHeight = navigation.isVisible() ? snapSize(navigation.prefHeight(width)) : 0;
! return topInset + currentStackPane.prefHeight(width) + navigationHeight + bottomInset;
! }
!
! /** {@inheritDoc} */
! @Override protected void layoutChildren(final double x, final double y,
! final double w, final double h) {
! double navigationHeight = navigation.isVisible() ? snapSize(navigation.prefHeight(-1)) : 0;
! double stackPaneHeight = snapSize(h - navigationHeight);
!
! layoutInArea(currentStackPane, x, y, w, stackPaneHeight, 0, HPos.CENTER, VPos.CENTER);
! layoutInArea(nextStackPane, x, y, w, stackPaneHeight, 0, HPos.CENTER, VPos.CENTER);
! layoutInArea(navigation, x, stackPaneHeight, w, navigationHeight, 0, HPos.CENTER, VPos.CENTER);
! }
!
! /** {@inheritDoc} */
! @Override protected Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
! switch (attribute) {
! case FOCUS_ITEM: return navigation.indicatorButtons.getSelectedToggle();
! case ITEM_COUNT: return navigation.indicatorButtons.getToggles().size();
! case ITEM_AT_INDEX: {
! Integer index = (Integer)parameters[0];
! if (index == null) return null;
! return navigation.indicatorButtons.getToggles().get(index);
! }
! default: return super.queryAccessibleAttribute(attribute, parameters);
! }
! }
!
!
!
! /***************************************************************************
! * *
! * Private implementation *
! * *
! **************************************************************************/
!
! private void selectNext() {
if (getCurrentPageIndex() < getPageCount() - 1) {
pagination.setCurrentPageIndex(getCurrentPageIndex() + 1);
}
}
! private void selectPrevious() {
if (getCurrentPageIndex() > 0) {
pagination.setCurrentPageIndex(getCurrentPageIndex() - 1);
}
}
! private void resetIndiciesAndNav() {
! resetIndexes(false);
! navigation.initializePageIndicators();
! navigation.updatePageIndicators();
! }
private void initializeSwipeAndTouchHandlers() {
final Pagination control = getSkinnable();
getSkinnable().addEventHandler(TouchEvent.TOUCH_PRESSED, e -> {
*** 369,382 ****
private int getCurrentPageIndex() {
return getSkinnable().getCurrentPageIndex();
}
- private static final Interpolator interpolator = Interpolator.SPLINE(0.4829, 0.5709, 0.6803, 0.9928);
- private int currentAnimatedIndex;
- private boolean hasPendingAnimation = false;
-
private void animateSwitchPage() {
if (timeline != null) {
timeline.setRate(8);
hasPendingAnimation = true;
return;
--- 678,687 ----
*** 446,467 ****
timeline.play();
}
});
}
- private EventHandler<ActionEvent> swipeAnimationEndEventHandler = new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent t) {
- swapPanes();
- timeline = null;
-
- if (hasPendingAnimation) {
- animateSwitchPage();
- hasPendingAnimation = false;
- }
- }
- };
-
private void swapPanes() {
StackPane temp = currentStackPane;
currentStackPane = nextStackPane;
nextStackPane = temp;
--- 751,760 ----
*** 499,720 ****
timeline.getKeyFrames().setAll(k1, k2);
timeline.play();
}
}
- private EventHandler<ActionEvent> clampAnimationEndEventHandler = new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent t) {
- currentStackPane.setTranslateX(0);
- nextStackPane.setTranslateX(0);
- nextStackPane.setVisible(false);
- timeline = null;
- }
- };
-
- /** The size of the gap between number buttons and arrow buttons */
- private final DoubleProperty arrowButtonGap = new StyleableDoubleProperty(60.0) {
- @Override public Object getBean() {
- return PaginationSkin.this;
- }
- @Override public String getName() {
- return "arrowButtonGap";
- }
- @Override public CssMetaData<Pagination,Number> getCssMetaData() {
- return StyleableProperties.ARROW_BUTTON_GAP;
- }
- };
- private DoubleProperty arrowButtonGapProperty() {
- return arrowButtonGap;
- }
-
- private BooleanProperty arrowsVisible;
- public final void setArrowsVisible(boolean value) { arrowsVisibleProperty().set(value); }
- public final boolean isArrowsVisible() { return arrowsVisible == null ? DEFAULT_ARROW_VISIBLE : arrowsVisible.get(); }
- public final BooleanProperty arrowsVisibleProperty() {
- if (arrowsVisible == null) {
- arrowsVisible = new StyleableBooleanProperty(DEFAULT_ARROW_VISIBLE) {
- @Override
- protected void invalidated() {
- getSkinnable().requestLayout();
- }
-
- @Override
- public CssMetaData<Pagination,Boolean> getCssMetaData() {
- return StyleableProperties.ARROWS_VISIBLE;
- }
-
- @Override
- public Object getBean() {
- return PaginationSkin.this;
- }
-
- @Override
- public String getName() {
- return "arrowVisible";
- }
- };
- }
- return arrowsVisible;
- }
- private BooleanProperty pageInformationVisible;
- public final void setPageInformationVisible(boolean value) { pageInformationVisibleProperty().set(value); }
- public final boolean isPageInformationVisible() { return pageInformationVisible == null ? DEFAULT_PAGE_INFORMATION_VISIBLE : pageInformationVisible.get(); }
- public final BooleanProperty pageInformationVisibleProperty() {
- if (pageInformationVisible == null) {
- pageInformationVisible = new StyleableBooleanProperty(DEFAULT_PAGE_INFORMATION_VISIBLE) {
- @Override
- protected void invalidated() {
- getSkinnable().requestLayout();
- }
-
- @Override
- public CssMetaData<Pagination,Boolean> getCssMetaData() {
- return StyleableProperties.PAGE_INFORMATION_VISIBLE;
- }
! @Override
! public Object getBean() {
! return PaginationSkin.this;
! }
!
! @Override
! public String getName() {
! return "pageInformationVisible";
! }
! };
! }
! return pageInformationVisible;
! }
!
! private ObjectProperty<Side> pageInformationAlignment;
! public final void setPageInformationAlignment(Side value) { pageInformationAlignmentProperty().set(value); }
! public final Side getPageInformationAlignment() { return pageInformationAlignment == null ? DEFAULT_PAGE_INFORMATION_ALIGNMENT : pageInformationAlignment.get(); }
! public final ObjectProperty<Side> pageInformationAlignmentProperty() {
! if (pageInformationAlignment == null) {
! pageInformationAlignment = new StyleableObjectProperty<Side>(Side.BOTTOM) {
! @Override
! protected void invalidated() {
! getSkinnable().requestLayout();
! }
!
! @Override
! public CssMetaData<Pagination,Side> getCssMetaData() {
! return StyleableProperties.PAGE_INFORMATION_ALIGNMENT;
! }
!
! @Override
! public Object getBean() {
! return PaginationSkin.this;
! }
!
! @Override
! public String getName() {
! return "pageInformationAlignment";
! }
! };
! }
! return pageInformationAlignment;
! }
!
! private BooleanProperty tooltipVisible;
! public final void setTooltipVisible(boolean value) { tooltipVisibleProperty().set(value); }
! public final boolean isTooltipVisible() { return tooltipVisible == null ? DEFAULT_TOOLTIP_VISIBLE : tooltipVisible.get(); }
! public final BooleanProperty tooltipVisibleProperty() {
! if (tooltipVisible == null) {
! tooltipVisible = new StyleableBooleanProperty(DEFAULT_TOOLTIP_VISIBLE) {
! @Override
! protected void invalidated() {
! getSkinnable().requestLayout();
! }
!
! @Override
! public CssMetaData<Pagination,Boolean> getCssMetaData() {
! return StyleableProperties.TOOLTIP_VISIBLE;
! }
!
! @Override
! public Object getBean() {
! return PaginationSkin.this;
! }
!
! @Override
! public String getName() {
! return "tooltipVisible";
! }
! };
! }
! return tooltipVisible;
! }
!
! @Override protected void handleControlPropertyChanged(String p) {
! super.handleControlPropertyChanged(p);
! if ("PAGE_FACTORY".equals(p)) {
! if (animate && timeline != null) {
! // If we are in the middle of a page animation.
! // Speedup and finish the animation then update the page factory.
! timeline.setRate(8);
! timeline.setOnFinished(arg0 -> {
! resetIndiciesAndNav();
! });
! return;
! }
! resetIndiciesAndNav();
! } else if ("PAGE_COUNT".equals(p)) {
! resetIndiciesAndNav();
! } else if ("WIDTH".equals(p)) {
! clipRect.setWidth(getSkinnable().getWidth());
! } else if ("HEIGHT".equals(p)) {
! clipRect.setHeight(getSkinnable().getHeight());
! }
!
! getSkinnable().requestLayout();
! }
!
! @Override protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
! double navigationWidth = navigation.isVisible() ? snapSize(navigation.minWidth(height)) : 0;
! return leftInset + Math.max(currentStackPane.minWidth(height), navigationWidth) + rightInset;
! }
!
! @Override protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
! double navigationHeight = navigation.isVisible() ? snapSize(navigation.minHeight(width)) : 0;
! return topInset + currentStackPane.minHeight(width) + navigationHeight + bottomInset;
! }
!
! @Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
! double navigationWidth = navigation.isVisible() ? snapSize(navigation.prefWidth(height)) : 0;
! return leftInset + Math.max(currentStackPane.prefWidth(height), navigationWidth) + rightInset;
! }
!
! @Override protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
! double navigationHeight = navigation.isVisible() ? snapSize(navigation.prefHeight(width)) : 0;
! return topInset + currentStackPane.prefHeight(width) + navigationHeight + bottomInset;
! }
!
! @Override protected void layoutChildren(final double x, final double y,
! final double w, final double h) {
! double navigationHeight = navigation.isVisible() ? snapSize(navigation.prefHeight(-1)) : 0;
! double stackPaneHeight = snapSize(h - navigationHeight);
!
! layoutInArea(currentStackPane, x, y, w, stackPaneHeight, 0, HPos.CENTER, VPos.CENTER);
! layoutInArea(nextStackPane, x, y, w, stackPaneHeight, 0, HPos.CENTER, VPos.CENTER);
! layoutInArea(navigation, x, stackPaneHeight, w, navigationHeight, 0, HPos.CENTER, VPos.CENTER);
! }
!
! @Override
! protected Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
! switch (attribute) {
! case FOCUS_ITEM: return navigation.indicatorButtons.getSelectedToggle();
! case ITEM_COUNT: return navigation.indicatorButtons.getToggles().size();
! case ITEM_AT_INDEX: {
! Integer index = (Integer)parameters[0];
! if (index == null) return null;
! return navigation.indicatorButtons.getToggles().get(index);
! }
! default: return super.queryAccessibleAttribute(attribute, parameters);
! }
! }
class NavigationControl extends StackPane {
private HBox controlBox;
private Button leftArrowButton;
--- 792,808 ----
timeline.getKeyFrames().setAll(k1, k2);
timeline.play();
}
}
! /***************************************************************************
! * *
! * Support classes *
! * *
! **************************************************************************/
class NavigationControl extends StackPane {
private HBox controlBox;
private Button leftArrowButton;
*** 728,741 ****
public NavigationControl() {
getStyleClass().setAll("pagination-control");
// redirect mouse events to behavior
! addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> getBehavior().mousePressed(e));
! addEventHandler(MouseEvent.MOUSE_RELEASED, (e) -> getBehavior().mouseReleased(e));
! addEventHandler(MouseEvent.MOUSE_ENTERED, (e) -> getBehavior().mouseEntered(e));
! addEventHandler(MouseEvent.MOUSE_EXITED, (e) -> getBehavior().mouseExited(e));
controlBox = new HBox();
controlBox.getStyleClass().add("control-box");
leftArrowButton = new Button();
--- 816,826 ----
public NavigationControl() {
getStyleClass().setAll("pagination-control");
// redirect mouse events to behavior
! addEventHandler(MouseEvent.MOUSE_PRESSED, behavior::mousePressed);
controlBox = new HBox();
controlBox.getStyleClass().add("control-box");
leftArrowButton = new Button();
*** 1384,1394 ****
STYLEABLES = Collections.unmodifiableList(styleables);
}
}
/**
! * @return The CssMetaData associated with this class, which may include the
* CssMetaData of its super classes.
*/
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
return StyleableProperties.STYLEABLES;
}
--- 1469,1479 ----
STYLEABLES = Collections.unmodifiableList(styleables);
}
}
/**
! * Returns the CssMetaData associated with this class, which may include the
* CssMetaData of its super classes.
*/
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
return StyleableProperties.STYLEABLES;
}