|
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.
|
|
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, 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
|