JDK-6296064 : Add new Paint classes for multi-stop gradients
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0,6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS:
    generic,solaris_2,windows_2000,windows_xp generic,solaris_2,windows_2000,windows_xp
  • CPU: generic,unknown,x86
  • Submitted: 2005-07-12
  • Updated: 2017-05-16
  • Resolved: 2006-04-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
6 b81Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Java2D should provide direct support for multi-color linear and radial gradients.  A "reflect" mode should be available in addition to the calmping and cyclic modes currently provided.  Although gradients beyond those supplied in Java2D can be implemented in software as custom Paint objects, they can only be fully accelerated if they are made a part of the core API.

Gradients are part of SVG, including SVG Tiny 1.2, as well as other drawing formats and APIs including PostScript Level 3 and OpenVG.

SVG gradients provide the following:

A color ramp with multiple (offset,r,g,b,a) "stops"
A "pad mode" -- clamp, repeat, or reflect
For linear gradients, (x0,y0) and (x1,y1) endpoints
For radial gadients, a center (cx,cy), radius r, and focal point (fx,fy)

I can supply formulas for evaluation the gradient function at an arbitrary point.

###@###.### 2005-07-12 22:17:38 GMT

EVALUATION We have added two new concrete Paint implementations for Mustang: - LinearGradientPaint is a more flexible version of the existing GradientPaint class that allows for multi-stop gradients involving two or more colors. - RadialGradientPaint is similarly flexible, except instead of interpolating the colors in a linear fashion, the colors radiate out from a center point (imagine ripples expanding from a drop of water). We are also including a non-user-extendable parent class, MultipleGradientPaint, which contains shared API and implementation. It also contains two public enums, CycleMethod and ColorSpaceType, which are used to control the behavior of LinearGradientPaint and RadialGradientPaint. The new API should be familiar to developers who have worked with the multi-stop gradient classes in the Apache Batik project. Those Batik classes were developed years ago by Java 2D engineers at Sun and donated to the Batik project. The classes being integrated into the JDK for Mustang are based on the original sources from 2000, except with a ton of code and javadoc cleanup. We have done some work to make the constructors in LGP and RGP a bit more symmetric, so there are a few constructors in the new JDK classes that weren't in the Batik classes, and vice versa. The new JDK classes are lacking a number of performance enhancements made to the Batik code over the years, but we plan to include some optimizations of our own in the near future. Also, we're working on accelerating these operations in hardware via OpenGL much as we did for GradientPaint and TexturePaint, except most likely we will need to use fragment shaders for these more complex paints. Along with the new classes, we updated the GradAnim pane in Java2Demo to demonstrate the new LGP and RGP paint options. In addition, we added some new options to J2DBench to help folks measure performance of these new classes.

EVALUATION Application user interfaces on most desktop computers now feature extensive use of multiple stop gradients. XP and OSX use them in a lot of places and Vista will use even more. If Swing applications are to compete with native apps then they need multi-stop gradients too.