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

Color.interpolate sometimes generates exceptions with valid data

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • fx2.1
    • fx2.0
    • javafx

      The following test case will generate a failure despite all values being in range. The problem is that sometimes float->double->int conversions implicit in the math of the interpolate function can generate values every so slightly out of range...

          @Test
          public void testOfTheWayAll() {
              List<Color> colors = new ArrayList<Color>();
              for (Field f : Color.class.getDeclaredFields()) {
                  if (Modifier.isStatic(f.getModifiers()) &&
                      f.getType() == Color.class)
                  {
                      try {
                          colors.add((Color) f.get(null));
                      } catch (IllegalArgumentException ex) {
                      } catch (IllegalAccessException ex) {
                      }
                  }
              }
              System.out.println("colors: "+colors.size());
              for (Color c1 : colors) {
                  for (Color c2 : colors) {
                      c1.interpolate(c2, 0.0);
                      c1.interpolate(c2, 0.5);
                      c1.interpolate(c2, 1.0);
                  }
              }
          }

            flar Jim Graham
            flar Jim Graham
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: