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

Color.interpolate sometimes generates exceptions with valid data

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: fx2.0
    • Fix Version/s: fx2.1
    • Component/s: javafx
    • Labels:

      Description

      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);
                  }
              }
          }

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: