Details
-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
7
-
generic
-
generic
Description
Specification for method
decodeColor(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;
In fact midPoint value of 1.0 doesn't always lead to returning second color.
Please see the following code sample:
-------------------------------------
import javax.swing.*;
import java.awt.*;
public class Test {
public static void main(String[] args) {
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 callDecodeColor() {
Color color = decodeColor(Color.BLUE, Color.BLACK, 1.f);
if ( !Color.BLACK.equals(color)) {
throw new RuntimeException("Expected " + Color.BLACK + ", returned " + color);
}
}
}
new MyARP().callDecodeColor();
}
}
-------------------------------------
The output will be
Exception in thread "main" java.lang.RuntimeException: Expected java.awt.Color[r=0,g=0,b=0], returned java.awt.Color[r=0,g=0,b=1]
at Test$1MyARP.callDecodeColor(Test.java:15)
at Test.main(Test.java:19)
decodeColor(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;
In fact midPoint value of 1.0 doesn't always lead to returning second color.
Please see the following code sample:
-------------------------------------
import javax.swing.*;
import java.awt.*;
public class Test {
public static void main(String[] args) {
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 callDecodeColor() {
Color color = decodeColor(Color.BLUE, Color.BLACK, 1.f);
if ( !Color.BLACK.equals(color)) {
throw new RuntimeException("Expected " + Color.BLACK + ", returned " + color);
}
}
}
new MyARP().callDecodeColor();
}
}
-------------------------------------
The output will be
Exception in thread "main" java.lang.RuntimeException: Expected java.awt.Color[r=0,g=0,b=0], returned java.awt.Color[r=0,g=0,b=1]
at Test$1MyARP.callDecodeColor(Test.java:15)
at Test.main(Test.java:19)
Attachments
Issue Links
- duplicates
-
JDK-6849805 Nimbus L&F: NimbusLookAndFeel.getDerivedColor() not always returns color2 for 1.0 midPoint
- Closed