Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8314534

Region.snapInnerSpace*()

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • javafx
    • None
    • source
    • minimal
    • Hide
      This change adds a new method to a non-final public class.
      This might cause a source incompatibility in the case when child class declares a method with the same signature.
      Show
      This change adds a new method to a non-final public class. This might cause a source incompatibility in the case when child class declares a method with the same signature.
    • Java API
    • JDK

      Summary

      Adding Region.snapInnerSpaceX() and Region.snapInnerSpaceY() with the semantics of floor() operation to complement existing snapPositionX/Y and snapPortionX/Y methods.

      Problem

      Some layout calculations need the snapped coordinates not to exceed some available space, such as width of the table header. There are existing snapPortionX/Y methods with the required semantics, but they are not public.

      Solution

      The solution is to add two new public methods.

      Specification

      javafx.graphics/src/main/java/javafx/scene/layout/Region.java

      +    /**
      +     * If this region's snapToPixel property is true, then the value is either floored (positive values) or
      +     * ceiled (negative values) with a scale. When the absolute value of the given value
      +     * multiplied by the current scale is less than 10^15, then this method guarantees that:
      +     *
      +     * <pre>snapInnerSpaceX(snapInnerSpaceX(value)) == snapInnerSpaceX(value)</pre>
      +     *
      +     * The limit is about 10^15 because double values will no longer be able to represent
      +     * larger integers with exact precision beyond this limit.
      +     *
      +     * @since 22
      +     * @param value The value that needs to be snapped
      +     * @return value either as passed, or floored or ceiled with scale, based on snapToPixel property
      +     */
      +    public double snapInnerSpaceX(double value) {
      +        return snapPortionX(value, isSnapToPixel());
      +    }
      +
      +    /**
      +     * If this region's snapToPixel property is true, then the value is either floored (positive values) or
      +     * ceiled (negative values) with a scale. When the absolute value of the given value
      +     * multiplied by the current scale is less than 10^15, then this method guarantees that:
      +     *
      +     * <pre>snapInnerSpaceY(snapInnerSpaceY(value)) == snapInnerSpaceY(value)</pre>
      +     *
      +     * The limit is about 10^15 because double values will no longer be able to represent
      +     * larger integers with exact precision beyond this limit.
      +     *
      +     * @since 22
      +     * @param value The value that needs to be snapped
      +     * @return value either as passed, or floored or ceiled with scale, based on snapToPixel property
      +     */
      +    public double snapInnerSpaceY(double value) {
      +        return snapPortionY(value, isSnapToPixel());
      +    }

            angorya Andy Goryachev
            angorya Andy Goryachev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: