public class PaintAlpha
extends java.lang.Object
Paint
The intention is to honour the alpha-channel in the process.
PaintAlpha was originally conceived to improve the
rendering of 3D Shapes with transparent colours and to allow
invisible bars by making them completely transparent.
In, for example
StackedBarRenderer3D,
bars are rendered with 6 faces. The front face is rendered with
the Paint requested. The other 5 faces are rendered
darker to achieve the 3D effect.
Previously Color.darker() was used for this,
which always returns an opaque colour.
Additionally there are methods to control the behaviour and
in particular a cloneImage(..)
method which is needed to darken objects of type TexturePaint.
| Modifier and Type | Field and Description |
|---|---|
private static double |
FACTOR
Multiplier for the
darker Methods.(taken from Color.FACTOR) |
private static boolean |
legacyAlpha |
| Constructor and Description |
|---|
PaintAlpha() |
| Modifier and Type | Method and Description |
|---|---|
static java.awt.image.BufferedImage |
cloneImage(java.awt.image.BufferedImage image)
Clone a
BufferedImage. |
private static java.awt.Color |
darker(java.awt.Color paint)
Similar to
Color.darker(). |
private static java.awt.GradientPaint |
darker(java.awt.GradientPaint paint)
Create a new
GradientPaint with its colors darkened. |
static java.awt.Paint |
darker(java.awt.Paint paint)
Create a new (if possible, darker)
Paint of the same Type. |
private static java.awt.Paint |
darkerLinearGradientPaint(java.awt.LinearGradientPaint paint)
Create a new Gradient with its colours darkened.
|
private static java.awt.Paint |
darkerRadialGradientPaint(java.awt.RadialGradientPaint paint)
Create a new Gradient with its colours darkened.
|
private static java.awt.TexturePaint |
darkerTexturePaint(java.awt.TexturePaint paint)
Create a new
TexturePaint with its colors darkened. |
static boolean |
setLegacyAlpha(boolean legacyAlpha)
Per default
PaintAlpha will try to honour alpha-channel
information. |
private static final double FACTOR
darker Methods.Color.FACTOR)private static boolean legacyAlpha
public static boolean setLegacyAlpha(boolean legacyAlpha)
PaintAlpha will try to honour alpha-channel
information. In the past this was not the case.
If you wish legacy functionality for your application you can request
this here.legacyAlpha - booleanpublic static java.awt.Paint darker(java.awt.Paint paint)
Paint of the same Type.
If the Type is not supported, the original Paint is returned.
paint - a Paint implementation
(e.g. Color, GradientPaint, TexturePaint,..)
Paintprivate static java.awt.Color darker(java.awt.Color paint)
Color.darker().
The essential difference is that this method
maintains the alpha-channel unchanged
paint - a ColorColorprivate static java.awt.GradientPaint darker(java.awt.GradientPaint paint)
GradientPaint with its colors darkened.paint - the gradient paint (null not permitted).GradientPaintprivate static java.awt.Paint darkerLinearGradientPaint(java.awt.LinearGradientPaint paint)
paint - a LinearGradientPaintLinearGradientPaintprivate static java.awt.Paint darkerRadialGradientPaint(java.awt.RadialGradientPaint paint)
paint - a RadialGradientPaintRadialGradientPaintprivate static java.awt.TexturePaint darkerTexturePaint(java.awt.TexturePaint paint)
TexturePaint with its colors darkened.
This entails cloning the underlying BufferedImage,
then darkening each color-pixel individually!
paint - a TexturePaintTexturePaintpublic static java.awt.image.BufferedImage cloneImage(java.awt.image.BufferedImage image)
BufferedImage.
Note: when constructing the clone, the original Color Model Object is
reused.
That keeps things simple and should not be a problem, as all
known Color Models
(IndexColorModel,
DirectColorModel,
ComponentColorModel) are
immutable.
image - original BufferedImage to clone