modules/javafx.controls/src/main/java/javafx/scene/control/SkinBase.java
Print this page
@@ -484,37 +484,122 @@
protected double snappedRightInset() {
return control.snappedRightInset();
}
/**
- * If this region's snapToPixel property is true, returns a value rounded
- * to the nearest pixel, else returns the same value.
+ * If this region's snapToPixel property is false, this method returns the
+ * same value, else it tries to return a value rounded to the nearest
+ * pixel, but since there is no indication if the value is a vertical
+ * or horizontal measurement then it may be snapped to the wrong pixel
+ * size metric on screens with different horizontal and vertical scales.
* @param value the space value to be snapped
* @return value rounded to nearest pixel
+ * @deprecated replaced by {@code snapSpaceX()} and {@code snapSpaceY()}
*/
protected double snapSpace(double value) {
- return control.isSnapToPixel() ? Math.round(value) : value;
+ return control.snapSpaceX(value);
}
/**
- * If this region's snapToPixel property is true, returns a value ceiled
- * to the nearest pixel, else returns the same value.
+ * If this region's snapToPixel property is true, returns a value rounded
+ * to the nearest pixel in the horizontal direction, else returns the
+ * same value.
+ * @param value the space value to be snapped
+ * @return value rounded to nearest pixel
+ * @since 9
+ */
+ protected double snapSpaceX(double value) {
+ return control.snapSpaceX(value);
+ }
+
+ /**
+ * If this region's snapToPixel property is true, returns a value rounded
+ * to the nearest pixel in the vertical direction, else returns the
+ * same value.
+ * @param value the space value to be snapped
+ * @return value rounded to nearest pixel
+ * @since 9
+ */
+ protected double snapSpaceY(double value) {
+ return control.snapSpaceY(value);
+ }
+
+ /**
+ /**
+ * If this region's snapToPixel property is false, this method returns the
+ * same value, else it tries to return a value ceiled to the nearest
+ * pixel, but since there is no indication if the value is a vertical
+ * or horizontal measurement then it may be snapped to the wrong pixel
+ * size metric on screens with different horizontal and vertical scales.
* @param value the size value to be snapped
* @return value ceiled to nearest pixel
+ * @deprecated replaced by {@code snapSizeX()} and {@code snapSizeY()}
*/
protected double snapSize(double value) {
- return control.isSnapToPixel() ? Math.ceil(value) : value;
+ return control.snapSizeX(value);
}
/**
- * If this region's snapToPixel property is true, returns a value rounded
- * to the nearest pixel, else returns the same value.
+ * If this region's snapToPixel property is true, returns a value ceiled
+ * to the nearest pixel in the horizontal direction, else returns the
+ * same value.
+ * @param value the size value to be snapped
+ * @return value ceiled to nearest pixel
+ * @since 9
+ */
+ protected double snapSizeX(double value) {
+ return control.snapSizeX(value);
+ }
+
+ /**
+ * If this region's snapToPixel property is true, returns a value ceiled
+ * to the nearest pixel in the vertical direction, else returns the
+ * same value.
+ * @param value the size value to be snapped
+ * @return value ceiled to nearest pixel
+ * @since 9
+ */
+ protected double snapSizeY(double value) {
+ return control.snapSizeY(value);
+ }
+
+ /**
+ * If this region's snapToPixel property is false, this method returns the
+ * same value, else it tries to return a value rounded to the nearest
+ * pixel, but since there is no indication if the value is a vertical
+ * or horizontal measurement then it may be snapped to the wrong pixel
+ * size metric on screens with different horizontal and vertical scales.
* @param value the position value to be snapped
* @return value rounded to nearest pixel
+ * @deprecated replaced by {@code snapPositionX()} and {@code snapPositionY()}
*/
protected double snapPosition(double value) {
- return control.isSnapToPixel() ? Math.round(value) : value;
+ return control.snapPositionX(value);
+ }
+
+ /**
+ * If this region's snapToPixel property is true, returns a value rounded
+ * to the nearest pixel in the horizontal direction, else returns the
+ * same value.
+ * @param value the position value to be snapped
+ * @return value rounded to nearest pixel
+ * @since 9
+ */
+ protected double snapPositionX(double value) {
+ return control.snapPositionX(value);
+ }
+
+ /**
+ * If this region's snapToPixel property is true, returns a value rounded
+ * to the nearest pixel in the vertical direction, else returns the
+ * same value.
+ * @param value the position value to be snapped
+ * @return value rounded to nearest pixel
+ * @since 9
+ */
+ protected double snapPositionY(double value) {
+ return control.snapPositionY(value);
}
/**
* Utility method which positions the child within an area of this
* skin defined by {@code areaX}, {@code areaY}, {@code areaWidth} x {@code areaHeight},