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

Nimbus L&F: NimbusLookAndFeel.getDerivedColor() not always returns color2 for 1.0 midPoint

XMLWordPrintable

    • b64
    • generic
    • generic
    • Verified

        The spec for javax.swing.plaf.nimbus.NimbusLookAndFeel.getDerivedColor(Color color1, Color color2, float midPoint) says:

             * @param midPoint The offset between color 1 and color 2, a value of 0.0 is
             * color 1 and 1.0 is color 2;

        Exact second color is not always returned for 1.0 offset value.

        Please see the following code sample:

        ------------------------------------------------------------------------------------
        import java.awt.*;

        public class Test {
            public static void main(String[] args) {
                class MyNibusLAF extends javax.swing.plaf.nimbus.NimbusLookAndFeel {
                    public Color callGetDerivedColor(Color c1, Color c2, float midPoint) {
                        return getDerivedColor(c1, c2, midPoint);
                    }
                }
                Color secondColor = Color.BLACK;
                Color returnedColor = new MyNibusLAF().callGetDerivedColor(Color.WHITE, secondColor, 1.f);
                System.out.println("returnedColor = " + returnedColor);
                System.out.println("secondColor = " + secondColor);
            }
        }
        ------------------------------------------------------------------------------------

        Output will look:

        returnedColor = javax.swing.plaf.ColorUIResource[r=1,g=1,b=1]
        secondColor = java.awt.Color[r=0,g=0,b=0]


        Color RGB components are not as expected.

              peterz Peter Zhelezniakov
              dbessono Dmitry Bessonov
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: