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

No focus point adjustment for RadialGradientPaint

XMLWordPrintable

    • 2d
    • b142
    • generic
    • generic
    • Verified

      The specs for java.awt.RadialGradientPaint says:
      =================================================
      "Specifying a focus point outside of the circle's radius will result in the focus being set to the intersection point of the focus-center line and the perimeter of the circle."
      =================================================

      However the following sample shows it does not happen in case of RI.
      =================================================
              float cx = 0.0f;
              float cy = 0.0f;
              float radius = 10.0f;
              float fx = 20.f;
              float fy = 0.0f;

              Point2D expectedFocus = new Point2D.Float(10.0f, 0.0f);

              RadialGradientPaint gp = new RadialGradientPaint(cx, cy, radius, fx, fy,
                      new float[] { 0.0f, 0.5f, 1.0f},
                      new Color[] { Color.RED, Color.GREEN, Color.BLUE },
                      CycleMethod.NO_CYCLE);
              Point2D actualFocus = gp.getFocusPoint();

              if ( ! expectedFocus.equals(actualFocus)) {
                  System.out.println("FAIL. Expected focus point: " + expectedFocus
                          + "\nActual focus point: " + actualFocus);
              }
      =================================================

      The output produced:
      =================================================
      FAIL. Expected focus point: Point2D.Float[10.0, 0.0]
      Actual focus point: Point2D.Double[20.0, 0.0]
      =================================================

      The sample source attached.

            flar Jim Graham
            ashusher Alexander Shusherov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: