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

Print this page




1692      * pixel, but since there is no indication if the value is a vertical
1693      * or horizontal measurement then it may be snapped to the wrong pixel
1694      * size metric on screens with different horizontal and vertical scales.
1695      * @param value the space value to be snapped
1696      * @return value rounded to nearest pixel
1697      * @deprecated replaced by {@code snapSpaceX()} and {@code snapSpaceY()}
1698      */
1699     @Deprecated
1700     protected double snapSpace(double value) {
1701         return snapSpaceX(value, isSnapToPixel());
1702     }
1703 
1704     /**
1705      * If this region's snapToPixel property is true, returns a value rounded
1706      * to the nearest pixel in the horizontal direction, else returns the
1707      * same value.
1708      * @param value the space value to be snapped
1709      * @return value rounded to nearest pixel
1710      * @since 9
1711      */
1712     protected double snapSpaceX(double value) {
1713         return snapSpaceX(value, isSnapToPixel());
1714     }
1715 
1716     /**
1717      * If this region's snapToPixel property is true, returns a value rounded
1718      * to the nearest pixel in the vertical direction, else returns the
1719      * same value.
1720      * @param value the space value to be snapped
1721      * @return value rounded to nearest pixel
1722      * @since 9
1723      */
1724     protected double snapSpaceY(double value) {
1725         return snapSpaceY(value, isSnapToPixel());
1726     }
1727 
1728     /**
1729      * If this region's snapToPixel property is false, this method returns the
1730      * same value, else it tries to return a value ceiled to the nearest
1731      * pixel, but since there is no indication if the value is a vertical
1732      * or horizontal measurement then it may be snapped to the wrong pixel
1733      * size metric on screens with different horizontal and vertical scales.
1734      * @param value the size value to be snapped
1735      * @return value ceiled to nearest pixel
1736      * @deprecated replaced by {@code snapSizeX()} and {@code snapSizeY()}
1737      */
1738     @Deprecated
1739     protected double snapSize(double value) {
1740         return snapSizeX(value, isSnapToPixel());
1741     }
1742 
1743     /**
1744      * If this region's snapToPixel property is true, returns a value ceiled
1745      * to the nearest pixel in the horizontal direction, else returns the
1746      * same value.
1747      * @param value the size value to be snapped
1748      * @return value ceiled to nearest pixel
1749      * @since 9
1750      */
1751     protected double snapSizeX(double value) {
1752         return snapSizeX(value, isSnapToPixel());
1753     }
1754 
1755     /**
1756      * If this region's snapToPixel property is true, returns a value ceiled
1757      * to the nearest pixel in the vertical direction, else returns the
1758      * same value.
1759      * @param value the size value to be snapped
1760      * @return value ceiled to nearest pixel
1761      * @since 9
1762      */
1763     protected double snapSizeY(double value) {
1764         return snapSizeY(value, isSnapToPixel());
1765     }
1766 
1767     /**
1768      * If this region's snapToPixel property is false, this method returns the
1769      * same value, else it tries to return a value rounded to the nearest
1770      * pixel, but since there is no indication if the value is a vertical
1771      * or horizontal measurement then it may be snapped to the wrong pixel
1772      * size metric on screens with different horizontal and vertical scales.
1773      * @param value the position value to be snapped
1774      * @return value rounded to nearest pixel
1775      * @deprecated replaced by {@code snapPositionX()} and {@code snapPositionY()}
1776      */
1777     @Deprecated
1778     protected double snapPosition(double value) {
1779         return snapPositionX(value, isSnapToPixel());
1780     }
1781 
1782     /**
1783      * If this region's snapToPixel property is true, returns a value rounded
1784      * to the nearest pixel in the horizontal direction, else returns the
1785      * same value.
1786      * @param value the position value to be snapped
1787      * @return value rounded to nearest pixel
1788      * @since 9
1789      */
1790     protected double snapPositionX(double value) {
1791         return snapPositionX(value, isSnapToPixel());
1792     }
1793 
1794     /**
1795      * If this region's snapToPixel property is true, returns a value rounded
1796      * to the nearest pixel in the vertical direction, else returns the
1797      * same value.
1798      * @param value the position value to be snapped
1799      * @return value rounded to nearest pixel
1800      * @since 9
1801      */
1802     protected double snapPositionY(double value) {
1803         return snapPositionY(value, isSnapToPixel());
1804     }
1805 
1806     double snapPortionX(double value) {
1807         return snapPortionX(value, isSnapToPixel());
1808     }
1809     double snapPortionY(double value) {
1810         return snapPortionY(value, isSnapToPixel());
1811     }
1812 
1813 
1814     /**
1815      * Utility method to get the top inset which includes padding and border
1816      * inset. Then snapped to whole pixels if isSnapToPixel() is true.
1817      *
1818      * @since JavaFX 8.0
1819      * @return Rounded up insets top
1820      */
1821     public final double snappedTopInset() {
1822         return snappedTopInset;




1692      * pixel, but since there is no indication if the value is a vertical
1693      * or horizontal measurement then it may be snapped to the wrong pixel
1694      * size metric on screens with different horizontal and vertical scales.
1695      * @param value the space value to be snapped
1696      * @return value rounded to nearest pixel
1697      * @deprecated replaced by {@code snapSpaceX()} and {@code snapSpaceY()}
1698      */
1699     @Deprecated
1700     protected double snapSpace(double value) {
1701         return snapSpaceX(value, isSnapToPixel());
1702     }
1703 
1704     /**
1705      * If this region's snapToPixel property is true, returns a value rounded
1706      * to the nearest pixel in the horizontal direction, else returns the
1707      * same value.
1708      * @param value the space value to be snapped
1709      * @return value rounded to nearest pixel
1710      * @since 9
1711      */
1712     public double snapSpaceX(double value) {
1713         return snapSpaceX(value, isSnapToPixel());
1714     }
1715 
1716     /**
1717      * If this region's snapToPixel property is true, returns a value rounded
1718      * to the nearest pixel in the vertical direction, else returns the
1719      * same value.
1720      * @param value the space value to be snapped
1721      * @return value rounded to nearest pixel
1722      * @since 9
1723      */
1724     public double snapSpaceY(double value) {
1725         return snapSpaceY(value, isSnapToPixel());
1726     }
1727 
1728     /**
1729      * If this region's snapToPixel property is false, this method returns the
1730      * same value, else it tries to return a value ceiled to the nearest
1731      * pixel, but since there is no indication if the value is a vertical
1732      * or horizontal measurement then it may be snapped to the wrong pixel
1733      * size metric on screens with different horizontal and vertical scales.
1734      * @param value the size value to be snapped
1735      * @return value ceiled to nearest pixel
1736      * @deprecated replaced by {@code snapSizeX()} and {@code snapSizeY()}
1737      */
1738     @Deprecated
1739     protected double snapSize(double value) {
1740         return snapSizeX(value, isSnapToPixel());
1741     }
1742 
1743     /**
1744      * If this region's snapToPixel property is true, returns a value ceiled
1745      * to the nearest pixel in the horizontal direction, else returns the
1746      * same value.
1747      * @param value the size value to be snapped
1748      * @return value ceiled to nearest pixel
1749      * @since 9
1750      */
1751     public double snapSizeX(double value) {
1752         return snapSizeX(value, isSnapToPixel());
1753     }
1754 
1755     /**
1756      * If this region's snapToPixel property is true, returns a value ceiled
1757      * to the nearest pixel in the vertical direction, else returns the
1758      * same value.
1759      * @param value the size value to be snapped
1760      * @return value ceiled to nearest pixel
1761      * @since 9
1762      */
1763     public double snapSizeY(double value) {
1764         return snapSizeY(value, isSnapToPixel());
1765     }
1766 
1767     /**
1768      * If this region's snapToPixel property is false, this method returns the
1769      * same value, else it tries to return a value rounded to the nearest
1770      * pixel, but since there is no indication if the value is a vertical
1771      * or horizontal measurement then it may be snapped to the wrong pixel
1772      * size metric on screens with different horizontal and vertical scales.
1773      * @param value the position value to be snapped
1774      * @return value rounded to nearest pixel
1775      * @deprecated replaced by {@code snapPositionX()} and {@code snapPositionY()}
1776      */
1777     @Deprecated
1778     protected double snapPosition(double value) {
1779         return snapPositionX(value, isSnapToPixel());
1780     }
1781 
1782     /**
1783      * If this region's snapToPixel property is true, returns a value rounded
1784      * to the nearest pixel in the horizontal direction, else returns the
1785      * same value.
1786      * @param value the position value to be snapped
1787      * @return value rounded to nearest pixel
1788      * @since 9
1789      */
1790     public double snapPositionX(double value) {
1791         return snapPositionX(value, isSnapToPixel());
1792     }
1793 
1794     /**
1795      * If this region's snapToPixel property is true, returns a value rounded
1796      * to the nearest pixel in the vertical direction, else returns the
1797      * same value.
1798      * @param value the position value to be snapped
1799      * @return value rounded to nearest pixel
1800      * @since 9
1801      */
1802     public double snapPositionY(double value) {
1803         return snapPositionY(value, isSnapToPixel());
1804     }
1805 
1806     double snapPortionX(double value) {
1807         return snapPortionX(value, isSnapToPixel());
1808     }
1809     double snapPortionY(double value) {
1810         return snapPortionY(value, isSnapToPixel());
1811     }
1812 
1813 
1814     /**
1815      * Utility method to get the top inset which includes padding and border
1816      * inset. Then snapped to whole pixels if isSnapToPixel() is true.
1817      *
1818      * @since JavaFX 8.0
1819      * @return Rounded up insets top
1820      */
1821     public final double snappedTopInset() {
1822         return snappedTopInset;