modules/javafx.controls/src/main/java/javafx/scene/control/skin/PaginationSkin.java

Print this page




 375 
 376 
 377 
 378     /***************************************************************************
 379      *                                                                         *
 380      * Public API                                                              *
 381      *                                                                         *
 382      **************************************************************************/
 383 
 384     /** {@inheritDoc} */
 385     @Override public void dispose() {
 386         super.dispose();
 387 
 388         if (behavior != null) {
 389             behavior.dispose();
 390         }
 391     }
 392 
 393     /** {@inheritDoc} */
 394     @Override protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
 395         double navigationWidth = navigation.isVisible() ? snapSize(navigation.minWidth(height)) : 0;
 396         return leftInset + Math.max(currentStackPane.minWidth(height), navigationWidth) + rightInset;
 397     }
 398 
 399     /** {@inheritDoc} */
 400     @Override protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
 401         double navigationHeight = navigation.isVisible() ? snapSize(navigation.minHeight(width)) : 0;
 402         return topInset + currentStackPane.minHeight(width) + navigationHeight + bottomInset;
 403     }
 404 
 405     /** {@inheritDoc} */
 406     @Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
 407         double navigationWidth = navigation.isVisible() ? snapSize(navigation.prefWidth(height)) : 0;
 408         return leftInset + Math.max(currentStackPane.prefWidth(height), navigationWidth) + rightInset;
 409     }
 410 
 411     /** {@inheritDoc} */
 412     @Override protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
 413         double navigationHeight = navigation.isVisible() ? snapSize(navigation.prefHeight(width)) : 0;
 414         return topInset + currentStackPane.prefHeight(width) + navigationHeight + bottomInset;
 415     }
 416 
 417     /** {@inheritDoc} */
 418     @Override protected void layoutChildren(final double x, final double y,
 419                                             final double w, final double h) {
 420         double navigationHeight = navigation.isVisible() ? snapSize(navigation.prefHeight(-1)) : 0;
 421         double stackPaneHeight = snapSize(h - navigationHeight);
 422 
 423         layoutInArea(currentStackPane, x, y, w, stackPaneHeight, 0, HPos.CENTER, VPos.CENTER);
 424         layoutInArea(nextStackPane, x, y, w, stackPaneHeight, 0, HPos.CENTER, VPos.CENTER);
 425         layoutInArea(navigation, x, stackPaneHeight, w, navigationHeight, 0, HPos.CENTER, VPos.CENTER);
 426     }
 427 
 428     /** {@inheritDoc} */
 429     @Override protected Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
 430         switch (attribute) {
 431             case FOCUS_ITEM: return navigation.indicatorButtons.getSelectedToggle();
 432             case ITEM_COUNT: return navigation.indicatorButtons.getToggles().size();
 433             case ITEM_AT_INDEX: {
 434                 Integer index = (Integer)parameters[0];
 435                 if (index == null) return null;
 436                 return navigation.indicatorButtons.getToggles().get(index);
 437             }
 438             default: return super.queryAccessibleAttribute(attribute, parameters);
 439         }
 440     }
 441 




 375 
 376 
 377 
 378     /***************************************************************************
 379      *                                                                         *
 380      * Public API                                                              *
 381      *                                                                         *
 382      **************************************************************************/
 383 
 384     /** {@inheritDoc} */
 385     @Override public void dispose() {
 386         super.dispose();
 387 
 388         if (behavior != null) {
 389             behavior.dispose();
 390         }
 391     }
 392 
 393     /** {@inheritDoc} */
 394     @Override protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
 395         double navigationWidth = navigation.isVisible() ? snapSizeX(navigation.minWidth(height)) : 0;
 396         return leftInset + Math.max(currentStackPane.minWidth(height), navigationWidth) + rightInset;
 397     }
 398 
 399     /** {@inheritDoc} */
 400     @Override protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
 401         double navigationHeight = navigation.isVisible() ? snapSizeY(navigation.minHeight(width)) : 0;
 402         return topInset + currentStackPane.minHeight(width) + navigationHeight + bottomInset;
 403     }
 404 
 405     /** {@inheritDoc} */
 406     @Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
 407         double navigationWidth = navigation.isVisible() ? snapSizeX(navigation.prefWidth(height)) : 0;
 408         return leftInset + Math.max(currentStackPane.prefWidth(height), navigationWidth) + rightInset;
 409     }
 410 
 411     /** {@inheritDoc} */
 412     @Override protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
 413         double navigationHeight = navigation.isVisible() ? snapSizeY(navigation.prefHeight(width)) : 0;
 414         return topInset + currentStackPane.prefHeight(width) + navigationHeight + bottomInset;
 415     }
 416 
 417     /** {@inheritDoc} */
 418     @Override protected void layoutChildren(final double x, final double y,
 419                                             final double w, final double h) {
 420         double navigationHeight = navigation.isVisible() ? snapSizeY(navigation.prefHeight(-1)) : 0;
 421         double stackPaneHeight = snapSizeY(h - navigationHeight);
 422 
 423         layoutInArea(currentStackPane, x, y, w, stackPaneHeight, 0, HPos.CENTER, VPos.CENTER);
 424         layoutInArea(nextStackPane, x, y, w, stackPaneHeight, 0, HPos.CENTER, VPos.CENTER);
 425         layoutInArea(navigation, x, stackPaneHeight, w, navigationHeight, 0, HPos.CENTER, VPos.CENTER);
 426     }
 427 
 428     /** {@inheritDoc} */
 429     @Override protected Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
 430         switch (attribute) {
 431             case FOCUS_ITEM: return navigation.indicatorButtons.getSelectedToggle();
 432             case ITEM_COUNT: return navigation.indicatorButtons.getToggles().size();
 433             case ITEM_AT_INDEX: {
 434                 Integer index = (Integer)parameters[0];
 435                 if (index == null) return null;
 436                 return navigation.indicatorButtons.getToggles().get(index);
 437             }
 438             default: return super.queryAccessibleAttribute(attribute, parameters);
 439         }
 440     }
 441