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

Print this page

        

@@ -198,12 +198,12 @@
             ** content position at the top of the viewport
             */
             double oldHeight = oldBounds.getHeight();
             double newHeight = newBounds.getHeight();
             if (oldHeight > 0 && oldHeight != newHeight) {
-                double oldPositionY = (snapPosition(snappedTopInset() - posY / (vsb.getMax() - vsb.getMin()) * (oldHeight - contentHeight)));
-                double newPositionY = (snapPosition(snappedTopInset() - posY / (vsb.getMax() - vsb.getMin()) * (newHeight - contentHeight)));
+                double oldPositionY = (snapPositionY(snappedTopInset() - posY / (vsb.getMax() - vsb.getMin()) * (oldHeight - contentHeight)));
+                double newPositionY = (snapPositionY(snappedTopInset() - posY / (vsb.getMax() - vsb.getMin()) * (newHeight - contentHeight)));
 
                 double newValueY = (oldPositionY/newPositionY)*vsb.getValue();
                 if (newValueY < 0.0) {
                     vsb.setValue(0.0);
                 }

@@ -222,12 +222,12 @@
             ** content position to the left of the viewport
             */
             double oldWidth = oldBounds.getWidth();
             double newWidth = newBounds.getWidth();
             if (oldWidth > 0 && oldWidth != newWidth) {
-                double oldPositionX = (snapPosition(snappedLeftInset() - posX / (hsb.getMax() - hsb.getMin()) * (oldWidth - contentWidth)));
-                double newPositionX = (snapPosition(snappedLeftInset() - posX / (hsb.getMax() - hsb.getMin()) * (newWidth - contentWidth)));
+                double oldPositionX = (snapPositionX(snappedLeftInset() - posX / (hsb.getMax() - hsb.getMin()) * (oldWidth - contentWidth)));
+                double newPositionX = (snapPositionX(snappedLeftInset() - posX / (hsb.getMax() - hsb.getMin()) * (newWidth - contentWidth)));
 
                 double newValueX = (oldPositionX/newPositionX)*hsb.getValue();
                 if (newValueX < 0.0) {
                     hsb.setValue(0.0);
                 }

@@ -277,12 +277,12 @@
                     scrollNode.layoutBoundsProperty().removeListener(boundsChangeListener);
                     viewContent.getChildren().remove(scrollNode);
                 }
                 scrollNode = getSkinnable().getContent();
                 if (scrollNode != null) {
-                    nodeWidth = snapSize(scrollNode.getLayoutBounds().getWidth());
-                    nodeHeight = snapSize(scrollNode.getLayoutBounds().getHeight());
+                    nodeWidth = snapSizeX(scrollNode.getLayoutBounds().getWidth());
+                    nodeHeight = snapSizeY(scrollNode.getLayoutBounds().getHeight());
                     viewContent.getChildren().setAll(scrollNode);
                     scrollNode.layoutBoundsProperty().addListener(nodeListener);
                     scrollNode.layoutBoundsProperty().addListener(boundsChangeListener);
                 }
             }

@@ -476,14 +476,14 @@
 
     @Override protected void layoutChildren(final double x, final double y,
                                             final double w, final double h) {
         final ScrollPane control = getSkinnable();
         final Insets padding = control.getPadding();
-        final double rightPadding = snapSize(padding.getRight());
-        final double leftPadding = snapSize(padding.getLeft());
-        final double topPadding = snapSize(padding.getTop());
-        final double bottomPadding = snapSize(padding.getBottom());
+        final double rightPadding = snapSizeX(padding.getRight());
+        final double leftPadding = snapSizeX(padding.getLeft());
+        final double topPadding = snapSizeY(padding.getTop());
+        final double bottomPadding = snapSizeY(padding.getBottom());
 
         vsb.setMin(control.getVmin());
         vsb.setMax(control.getVmax());
 
         //should only do this on css setup

@@ -584,22 +584,22 @@
             hsb.resizeRelocate(cx, snappedTopInset() + h - hsbHeight + (bottomPadding < 1 ? 0 : bottomPadding - 1),
                     hsbWidth, hsbHeight);
         }
         updateHorizontalSB();
 
-        viewRect.resizeRelocate(snappedLeftInset(), snappedTopInset(), snapSize(contentWidth), snapSize(contentHeight));
+        viewRect.resizeRelocate(snappedLeftInset(), snappedTopInset(), snapSizeX(contentWidth), snapSizeY(contentHeight));
         resetClip();
 
         if (vsbvis && hsbvis) {
             corner.setVisible(true);
             double cornerWidth = vsbWidth;
             double cornerHeight = hsbHeight;
-            corner.resizeRelocate(snapPosition(vsb.getLayoutX()), snapPosition(hsb.getLayoutY()), snapSize(cornerWidth), snapSize(cornerHeight));
+            corner.resizeRelocate(snapPositionX(vsb.getLayoutX()), snapPositionY(hsb.getLayoutY()), snapSizeX(cornerWidth), snapSizeY(cornerHeight));
         } else {
             corner.setVisible(false);
         }
-        control.setViewportBounds(new BoundingBox(snapPosition(viewContent.getLayoutX()), snapPosition(viewContent.getLayoutY()), snapSize(contentWidth), snapSize(contentHeight)));
+        control.setViewportBounds(new BoundingBox(snapPositionX(viewContent.getLayoutX()), snapPositionY(viewContent.getLayoutY()), snapSizeX(contentWidth), snapSizeY(contentHeight)));
     }
 
     /** {@inheritDoc} */
     @Override protected Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
         switch (attribute) {

@@ -1037,31 +1037,31 @@
         if (scrollNode != null) {
             if (scrollNode.isResizable()) {
                 ScrollPane control = getSkinnable();
                 Orientation bias = scrollNode.getContentBias();
                 if (bias == null) {
-                    nodeWidth = snapSize(boundedSize(control.isFitToWidth()? contentWidth : scrollNode.prefWidth(-1),
+                    nodeWidth = snapSizeX(boundedSize(control.isFitToWidth()? contentWidth : scrollNode.prefWidth(-1),
                                                          scrollNode.minWidth(-1),scrollNode.maxWidth(-1)));
-                    nodeHeight = snapSize(boundedSize(control.isFitToHeight()? contentHeight : scrollNode.prefHeight(-1),
+                    nodeHeight = snapSizeY(boundedSize(control.isFitToHeight()? contentHeight : scrollNode.prefHeight(-1),
                                                           scrollNode.minHeight(-1), scrollNode.maxHeight(-1)));
 
                 } else if (bias == Orientation.HORIZONTAL) {
-                    nodeWidth = snapSize(boundedSize(control.isFitToWidth()? contentWidth : scrollNode.prefWidth(-1),
+                    nodeWidth = snapSizeX(boundedSize(control.isFitToWidth()? contentWidth : scrollNode.prefWidth(-1),
                                                          scrollNode.minWidth(-1),scrollNode.maxWidth(-1)));
-                    nodeHeight = snapSize(boundedSize(control.isFitToHeight()? contentHeight : scrollNode.prefHeight(nodeWidth),
+                    nodeHeight = snapSizeY(boundedSize(control.isFitToHeight()? contentHeight : scrollNode.prefHeight(nodeWidth),
                                                           scrollNode.minHeight(nodeWidth),scrollNode.maxHeight(nodeWidth)));
 
                 } else { // bias == VERTICAL
-                    nodeHeight = snapSize(boundedSize(control.isFitToHeight()? contentHeight : scrollNode.prefHeight(-1),
+                    nodeHeight = snapSizeY(boundedSize(control.isFitToHeight()? contentHeight : scrollNode.prefHeight(-1),
                                                           scrollNode.minHeight(-1), scrollNode.maxHeight(-1)));
-                    nodeWidth = snapSize(boundedSize(control.isFitToWidth()? contentWidth : scrollNode.prefWidth(nodeHeight),
+                    nodeWidth = snapSizeX(boundedSize(control.isFitToWidth()? contentWidth : scrollNode.prefWidth(nodeHeight),
                                                          scrollNode.minWidth(nodeHeight),scrollNode.maxWidth(nodeHeight)));
                 }
 
             } else {
-                nodeWidth = snapSize(scrollNode.getLayoutBounds().getWidth());
-                nodeHeight = snapSize(scrollNode.getLayoutBounds().getHeight());
+                nodeWidth = snapSizeX(scrollNode.getLayoutBounds().getWidth());
+                nodeHeight = snapSizeY(scrollNode.getLayoutBounds().getHeight());
             }
             nodeSizeInvalid = false;
         }
     }
 

@@ -1102,21 +1102,21 @@
                    (nodeHeight > contentHeight && scrollNode.minHeight(-1) > contentHeight) : (nodeHeight > contentHeight)));
         }
     }
 
     private void computeScrollBarSize() {
-        vsbWidth = snapSize(vsb.prefWidth(-1));
+        vsbWidth = snapSizeX(vsb.prefWidth(-1));
         if (vsbWidth == 0) {
             //            println("*** WARNING ScrollPaneSkin: can't get scroll bar width, using {DEFAULT_SB_BREADTH}");
             if (Properties.IS_TOUCH_SUPPORTED) {
                 vsbWidth = DEFAULT_EMBEDDED_SB_BREADTH;
             }
             else {
                 vsbWidth = DEFAULT_SB_BREADTH;
             }
         }
-        hsbHeight = snapSize(hsb.prefHeight(-1));
+        hsbHeight = snapSizeY(hsb.prefHeight(-1));
         if (hsbHeight == 0) {
             //            println("*** WARNING ScrollPaneSkin: can't get scroll bar height, using {DEFAULT_SB_BREADTH}");
             if (Properties.IS_TOUCH_SUPPORTED) {
                 hsbHeight = DEFAULT_EMBEDDED_SB_BREADTH;
             }

@@ -1176,26 +1176,26 @@
 
     private double updatePosX() {
         final ScrollPane sp = getSkinnable();
         double x = isReverseNodeOrientation() ? (hsb.getMax() - (posX - hsb.getMin())) : posX;
         double minX = Math.min((- x / (hsb.getMax() - hsb.getMin()) * (nodeWidth - contentWidth)), 0);
-        viewContent.setLayoutX(snapPosition(minX));
+        viewContent.setLayoutX(snapPositionX(minX));
         if (!sp.hvalueProperty().isBound()) sp.setHvalue(Utils.clamp(sp.getHmin(), posX, sp.getHmax()));
         return posX;
     }
 
     private double updatePosY() {
         final ScrollPane sp = getSkinnable();
         double minY = Math.min((- posY / (vsb.getMax() - vsb.getMin()) * (nodeHeight - contentHeight)), 0);
-        viewContent.setLayoutY(snapPosition(minY));
+        viewContent.setLayoutY(snapPositionY(minY));
         if (!sp.vvalueProperty().isBound()) sp.setVvalue(Utils.clamp(sp.getVmin(), posY, sp.getVmax()));
         return posY;
     }
 
     private void resetClip() {
-        clipRect.setWidth(snapSize(contentWidth));
-        clipRect.setHeight(snapSize(contentHeight));
+        clipRect.setWidth(snapSizeX(contentWidth));
+        clipRect.setHeight(snapSizeY(contentHeight));
     }
 
     private void startSBReleasedAnimation() {
         if (sbTouchTimeline == null) {
             /*