changeset 5231:48e93b84056d

RT-32848: Add CENTER constant to BackgroundPosition Reviewed-by: snorthov
author rbair
date Wed, 02 Oct 2013 13:37:53 -0700
parents 04dfdd1ed7be
children 043bd9ac4de2
files modules/graphics/src/main/java/javafx/scene/layout/BackgroundPosition.java modules/graphics/src/test/java/javafx/scene/layout/BackgroundPositionTest.java
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/javafx/scene/layout/BackgroundPosition.java	Wed Oct 02 15:26:04 2013 -0400
+++ b/modules/graphics/src/main/java/javafx/scene/layout/BackgroundPosition.java	Wed Oct 02 13:37:53 2013 -0700
@@ -59,6 +59,12 @@
     // As per the CSS 3 Spec (3.6), 0% 0% is the default
 
     /**
+     * A BackgroundPosition which will center a BackgroundImage.
+     */
+    public static final BackgroundPosition CENTER = new BackgroundPosition(
+            Side.LEFT, .5, true, Side.TOP, .5, true);
+
+    /**
      * The side along the horizontal axis to which the BackgroundImage is
      * anchored. This will only be LEFT or RIGHT and never null.
      */
--- a/modules/graphics/src/test/java/javafx/scene/layout/BackgroundPositionTest.java	Wed Oct 02 15:26:04 2013 -0400
+++ b/modules/graphics/src/test/java/javafx/scene/layout/BackgroundPositionTest.java	Wed Oct 02 13:37:53 2013 -0700
@@ -156,4 +156,13 @@
         BackgroundPosition pos = new BackgroundPosition(Side.LEFT, 0, true, Side.TOP, 0, true);
         assertEquals(BackgroundPosition.DEFAULT.hashCode(), pos.hashCode());
     }
+
+    @Test public void CENTER() {
+        assertEquals(Side.LEFT, BackgroundPosition.CENTER.getHorizontalSide());
+        assertEquals(.5, BackgroundPosition.CENTER.getHorizontalPosition(), 0);
+        assertTrue(BackgroundPosition.CENTER.isHorizontalAsPercentage());
+        assertEquals(Side.TOP, BackgroundPosition.CENTER.getVerticalSide());
+        assertEquals(.5, BackgroundPosition.CENTER.getVerticalPosition(), 0);
+        assertTrue(BackgroundPosition.CENTER.isVerticalAsPercentage());
+    }
 }