Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6849805
Votes 0
Synopsis Nimbus L&F: NimbusLookAndFeel.getDerivedColor() not always returns color2 for 1.0 midPoint
Category java:classes_swing
Reported Against b59
Release Fixed 7(b64)
State 10-Fix Delivered, Verified, bug
Priority: 2-High
Related Bugs 6849396
Submit Date 10-JUN-2009
Description
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.
Posted Date : 2009-06-10 13:12:13.0
Work Around
N/A
Evaluation
I believe this is caused by wrong rounding mode. Conversion to (int) rounds towards zero, whereas we should be rounding towards negative infinity. Math.round() does exactly what we need here.
Posted Date : 2009-06-26 08:27:42.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang