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: 5095630
Votes 0
Synopsis new method in AlphaComposite to derive new instances by rule or extra alpha
Category java:classes_2d
Reported Against 1.2.1
Release Fixed mustang(beta)
State 10-Fix Delivered, request for enhancement
Priority: 4-Low
Related Bugs
Submit Date 01-SEP-2004
Description
The following new methods on AlphaComposite would simplify a fair amount
of code:

	public AlphaComposite derive(float alpha);

	public AlphaComposite derive(int rule);

The first one in particular would simplify the creation of new objects from:

	AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);



	AlphaComposite ac = AlphaComposite.SrcOver.derive(0.5);

this would also simplify a fade operation where a new AlphaComposite needs
to be created with a different alpha parameter for each iteration of the
fade:

	ac = ac.derive(newfadeamount);

The latter method that derives a new instance with a new rule is probably
less useful, but is included for completeness.
Work Around
N/A
Evaluation
New methods were implemented as described in the description.

The full javadocs are as follows:

    /**
     * Returns a similar <code>AlphaComposite</code> object that uses
     * the specified compositing rule.
     * If this object already uses the specified compositing rule,
     * this object is returned.
     * @return an <code>AlphaComposite</code> object derived from
     * this object that uses the specified compositing rule.
     * @param rule the compositing rule
     * @throws IllegalArgumentException if 
     *         <code>rule</code> is not one of 
     *         the following:  {@link #CLEAR}, {@link #SRC}, {@link #DST},
     *         {@link #SRC_OVER}, {@link #DST_OVER}, {@link #SRC_IN}, 
     *         {@link #DST_IN}, {@link #SRC_OUT}, {@link #DST_OUT},
     *         {@link #SRC_ATOP}, {@link #DST_ATOP}, or {@link #XOR}
     */
    public AlphaComposite derive(int rule);

    /**
     * Returns a similar <code>AlphaComposite</code> object that uses
     * the specified alpha value.
     * If this object already has the specified alpha value,
     * this object is returned.
     * @return an <code>AlphaComposite</code> object derived from
     * this object that uses the specified alpha value.
     * @param alpha the constant alpha to be multiplied with the alpha of
     * the source. <code>alpha</code> must be a floating point number in the
     * inclusive range [0.0,&nbsp;1.0]. 
     * @throws IllegalArgumentException if 
     *         <code>alpha</code> is less than 0.0 or greater than 1.0
     */
    public AlphaComposite derive(float alpha);
  xxxxx@xxxxx   10/23/04 08:31 GMT
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang