Class ColorMatchers


  • public class ColorMatchers
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ColorMatchers()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String getColorText​(javafx.scene.paint.Color color)  
      static org.hamcrest.Matcher<javafx.scene.paint.Color> hasClosestNamedColor​(java.lang.String namedColor)
      Creates a matcher that matches all Colors that have the given named color String as their closest JavaFX named color.
      static org.hamcrest.Matcher<javafx.scene.paint.Color> hasClosestNamedColor​(javafx.scene.paint.Color namedColor)
      Creates a matcher that matches all Colors that are exactly equal to the given JavaFX named Color.
      static org.hamcrest.Matcher<javafx.scene.paint.Color> isColor​(java.lang.String namedColor)
      Creates a matcher that matches all Colors that are exactly equal to the given JavaFX named color String.
      static org.hamcrest.Matcher<javafx.scene.paint.Color> isColor​(javafx.scene.paint.Color color)
      Creates a matcher that matches all Colors that are exactly equal to the given color.
      static org.hamcrest.Matcher<javafx.scene.paint.Color> isColor​(javafx.scene.paint.Color color, ColorMatcher colorMatcher)
      Creates a matcher that matches all Colors that match the given color with respect to the given colorMatcher.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ColorMatchers

        public ColorMatchers()
    • Method Detail

      • isColor

        public static org.hamcrest.Matcher<javafx.scene.paint.Color> isColor​(javafx.scene.paint.Color color)
        Creates a matcher that matches all Colors that are exactly equal to the given color.
      • isColor

        public static org.hamcrest.Matcher<javafx.scene.paint.Color> isColor​(javafx.scene.paint.Color color,
                                                                             ColorMatcher colorMatcher)
        Creates a matcher that matches all Colors that match the given color with respect to the given colorMatcher.

        For example, to match colors using a custom matcher that considers two colors equal if they have the same red components:

        
         assertThat(Color.rgb(0.3, 0.2, 0.1), ColorMatchers.isColor(Color.rgb(0.3, 0.8, 0.7),
              (c1, c2) -> c1.getRed() == c2.getRed()));
         
      • isColor

        public static org.hamcrest.Matcher<javafx.scene.paint.Color> isColor​(java.lang.String namedColor)
        Creates a matcher that matches all Colors that are exactly equal to the given JavaFX named color String. The namedColor is not case sensitive.
        Throws:
        java.lang.AssertionError - if the given named color String is not a JavaFX named color
        See Also:
        JavaFX Named Colors
      • hasClosestNamedColor

        public static org.hamcrest.Matcher<javafx.scene.paint.Color> hasClosestNamedColor​(javafx.scene.paint.Color namedColor)
        Creates a matcher that matches all Colors that are exactly equal to the given JavaFX named Color.
        Throws:
        java.lang.AssertionError - if the given named Color is not a JavaFX named color
        See Also:
        JavaFX Named Colors
      • hasClosestNamedColor

        public static org.hamcrest.Matcher<javafx.scene.paint.Color> hasClosestNamedColor​(java.lang.String namedColor)
        Creates a matcher that matches all Colors that have the given named color String as their closest JavaFX named color. The namedColor is not case sensitive.
        Throws:
        java.lang.AssertionError - if the given named color String is not a JavaFX named color
        See Also:
        JavaFX Named Colors
      • getColorText

        private static java.lang.String getColorText​(javafx.scene.paint.Color color)