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

Nimbus L&F: AbstractRegionPainter.decodeGradient(...) should specify IAEs

    Details

      Description

      Different (unspecified) IAEs could be thrown from method AbstractRegionPainter.decodeGradient():

          java.lang.IllegalArgumentException: Colors and fractions must have equal size
          java.lang.IllegalArgumentException: Fraction values must be in the range 0 to 1: ...
          java.lang.IllegalArgumentException: Keyframe fractions must be increasing: ...
          java.lang.IllegalArgumentException: Start point cannot equalendpoint

      They should be specified.
      Please see the following code sample which illustrates four exceptions listed above.

      ------------------------------------------------------------------------------------
      import javax.swing.*;
      import java.awt.*;
      import static java.awt.Color.*;

      public class Test {

          public static void main(String[] args) {
              MyARP arp = new MyARP();
              // uncomment any of calls below to see different types of IAEs
      // arp.callDecodeGradient(0.1f, 0.4f, 0.2f, 0.8f, new float[]{0.1f, 0.6f}, new Color[]{BLACK, MAGENTA, BLUE});
      // arp.callDecodeGradient(0.1f, 0.4f, 0.2f, 0.8f, new float[]{12.1f, 0.6f}, new Color[]{BLACK, BLUE});
      // arp.callDecodeGradient(0.1f, 0.4f, 0.2f, 0.8f, new float[]{.3f, 0.2f}, new Color[]{BLACK, BLUE});
      // arp.callDecodeGradient(100.f, Float.MAX_VALUE, 100.f, Float.MAX_VALUE, new float[]{.1f, 0.2f}, new Color[]{BLACK, BLUE});
          }

          static class MyARP extends javax.swing.plaf.nimbus.AbstractRegionPainter {
              protected PaintContext getPaintContext() { return null; }
              protected void doPaint(Graphics2D g, JComponent c,
                                     int width, int height,
                                     Object[] extendedCacheKeys) { }
              void callDecodeGradient(float x1, float y1, float x2, float y2,
                                             float[] midpoints, java.awt.Color[] colors) {
                  decodeGradient(x1, y1, x2, y2, midpoints, colors);
              }
          }
      }
      ------------------------------------------------------------------------------------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                peterz Peter Zhelezniakov (Inactive)
                Reporter:
                dbessono Dmitry Bessonov
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: