469 * Utility method to get the left inset which includes padding and border 470 * inset. Then snapped to whole pixels if getSkinnable().isSnapToPixel() is true. 471 * 472 * @return Rounded up insets left 473 */ 474 protected double snappedLeftInset() { 475 return control.snappedLeftInset(); 476 } 477 478 /** 479 * Utility method to get the right inset which includes padding and border 480 * inset. Then snapped to whole pixels if getSkinnable().isSnapToPixel() is true. 481 * 482 * @return Rounded up insets right 483 */ 484 protected double snappedRightInset() { 485 return control.snappedRightInset(); 486 } 487 488 /** 489 * If this region's snapToPixel property is true, returns a value rounded 490 * to the nearest pixel, else returns the same value. 491 * @param value the space value to be snapped 492 * @return value rounded to nearest pixel 493 */ 494 protected double snapSpace(double value) { 495 return control.isSnapToPixel() ? Math.round(value) : value; 496 } 497 498 /** 499 * If this region's snapToPixel property is true, returns a value ceiled 500 * to the nearest pixel, else returns the same value. 501 * @param value the size value to be snapped 502 * @return value ceiled to nearest pixel 503 */ 504 protected double snapSize(double value) { 505 return control.isSnapToPixel() ? Math.ceil(value) : value; 506 } 507 508 /** 509 * If this region's snapToPixel property is true, returns a value rounded 510 * to the nearest pixel, else returns the same value. 511 * @param value the position value to be snapped 512 * @return value rounded to nearest pixel 513 */ 514 protected double snapPosition(double value) { 515 return control.isSnapToPixel() ? Math.round(value) : value; 516 } 517 518 /** 519 * Utility method which positions the child within an area of this 520 * skin defined by {@code areaX}, {@code areaY}, {@code areaWidth} x {@code areaHeight}, 521 * with a baseline offset relative to that area. 522 * <p> 523 * This function does <i>not</i> resize the node and uses the node's layout bounds 524 * width and height to determine how it should be positioned within the area. 525 * <p> 526 * If the vertical alignment is {@code VPos.BASELINE} then it 527 * will position the node so that its own baseline aligns with the passed in 528 * {@code baselineOffset}, otherwise the baseline parameter is ignored. 529 * <p> 530 * If {@code snapToPixel} is {@code true} for this skin, then the x/y position 531 * values will be rounded to their nearest pixel boundaries. 532 * 533 * @param child the child being positioned within this skin 534 * @param areaX the horizontal offset of the layout area relative to this skin 535 * @param areaY the vertical offset of the layout area relative to this skin | 469 * Utility method to get the left inset which includes padding and border 470 * inset. Then snapped to whole pixels if getSkinnable().isSnapToPixel() is true. 471 * 472 * @return Rounded up insets left 473 */ 474 protected double snappedLeftInset() { 475 return control.snappedLeftInset(); 476 } 477 478 /** 479 * Utility method to get the right inset which includes padding and border 480 * inset. Then snapped to whole pixels if getSkinnable().isSnapToPixel() is true. 481 * 482 * @return Rounded up insets right 483 */ 484 protected double snappedRightInset() { 485 return control.snappedRightInset(); 486 } 487 488 /** 489 * If {@code getSkinnable().isSnapToPixel()} is false, this method 490 * returns the same value, else it tries to return a value rounded to 491 * the nearest pixel, but since there is no indication if the value is 492 * a vertical or horizontal measurement then it may be snapped to the 493 * wrong pixel size metric on screens with different horizontal and 494 * vertical scales. 495 * @param value the space value to be snapped 496 * @return value rounded to nearest pixel 497 * @deprecated replaced by {@code snapSpaceX()} and {@code snapSpaceY()} 498 */ 499 @Deprecated 500 protected double snapSpace(double value) { 501 return control.snapSpaceX(value); 502 } 503 504 /** 505 * If {@code getSkinnable().isSnapToPixel()} is true, returns a 506 * value rounded to the nearest pixel in the horizontal direction, else 507 * returns the same value. 508 * @param value the space value to be snapped 509 * @return value rounded to nearest pixel 510 * @since 9 511 */ 512 protected double snapSpaceX(double value) { 513 return control.snapSpaceX(value); 514 } 515 516 /** 517 * If {@code getSkinnable().isSnapToPixel()} is true, returns a 518 * value rounded to the nearest pixel in the vertical direction, else 519 * returns the same value. 520 * @param value the space value to be snapped 521 * @return value rounded to nearest pixel 522 * @since 9 523 */ 524 protected double snapSpaceY(double value) { 525 return control.snapSpaceY(value); 526 } 527 528 /** 529 * If {@code getSkinnable().isSnapToPixel()} is false, this method 530 * returns the same value, else it tries to return a value ceiled to 531 * the nearest pixel, but since there is no indication if the value is 532 * a vertical or horizontal measurement then it may be snapped to the 533 * wrong pixel size metric on screens with different horizontal and 534 * vertical scales. 535 * @param value the size value to be snapped 536 * @return value ceiled to nearest pixel 537 * @deprecated replaced by {@code snapSizeX()} and {@code snapSizeY()} 538 */ 539 @Deprecated 540 protected double snapSize(double value) { 541 return control.snapSizeX(value); 542 } 543 544 /** 545 * If {@code getSkinnable().isSnapToPixel()} is true, returns a 546 * value ceiled to the nearest pixel in the horizontal direction, else 547 * returns the same value. 548 * @param value the size value to be snapped 549 * @return value ceiled to nearest pixel 550 * @since 9 551 */ 552 protected double snapSizeX(double value) { 553 return control.snapSizeX(value); 554 } 555 556 /** 557 * If {@code getSkinnable().isSnapToPixel()} is true, returns a 558 * value ceiled to the nearest pixel in the vertical direction, else 559 * returns the same value. 560 * @param value the size value to be snapped 561 * @return value ceiled to nearest pixel 562 * @since 9 563 */ 564 protected double snapSizeY(double value) { 565 return control.snapSizeY(value); 566 } 567 568 /** 569 * If {@code getSkinnable().isSnapToPixel()} is false, this method 570 * returns the same value, else it tries to return a value rounded to 571 * the nearest pixel, but since there is no indication if the value is 572 * a vertical or horizontal measurement then it may be snapped to the 573 * wrong pixel size metric on screens with different horizontal and 574 * vertical scales. 575 * @param value the position value to be snapped 576 * @return value rounded to nearest pixel 577 * @deprecated replaced by {@code snapPositionX()} and {@code snapPositionY()} 578 */ 579 @Deprecated 580 protected double snapPosition(double value) { 581 return control.snapPositionX(value); 582 } 583 584 /** 585 * If {@code getSkinnable().isSnapToPixel()} is true, returns a 586 * value rounded to the nearest pixel in the horizontal direction, else 587 * returns the same value. 588 * @param value the position value to be snapped 589 * @return value rounded to nearest pixel 590 * @since 9 591 */ 592 protected double snapPositionX(double value) { 593 return control.snapPositionX(value); 594 } 595 596 /** 597 * If {@code getSkinnable().isSnapToPixel()} is true, returns a 598 * value rounded to the nearest pixel in the vertical direction, else 599 * returns the same value. 600 * @param value the position value to be snapped 601 * @return value rounded to nearest pixel 602 * @since 9 603 */ 604 protected double snapPositionY(double value) { 605 return control.snapPositionY(value); 606 } 607 608 /** 609 * Utility method which positions the child within an area of this 610 * skin defined by {@code areaX}, {@code areaY}, {@code areaWidth} x {@code areaHeight}, 611 * with a baseline offset relative to that area. 612 * <p> 613 * This function does <i>not</i> resize the node and uses the node's layout bounds 614 * width and height to determine how it should be positioned within the area. 615 * <p> 616 * If the vertical alignment is {@code VPos.BASELINE} then it 617 * will position the node so that its own baseline aligns with the passed in 618 * {@code baselineOffset}, otherwise the baseline parameter is ignored. 619 * <p> 620 * If {@code snapToPixel} is {@code true} for this skin, then the x/y position 621 * values will be rounded to their nearest pixel boundaries. 622 * 623 * @param child the child being positioned within this skin 624 * @param areaX the horizontal offset of the layout area relative to this skin 625 * @param areaY the vertical offset of the layout area relative to this skin |