Class PaintAlpha
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.
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
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final double
private static boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImage
cloneImage
(BufferedImage image) Clone aBufferedImage
.private static Color
Similar toColor.darker()
.private static GradientPaint
darker
(GradientPaint paint) Create a newGradientPaint
with its colors darkened.static Paint
Create a new (if possible, darker)Paint
of the same Type.private static Paint
Create a new Gradient with its colours darkened.private static Paint
Create a new Gradient with its colours darkened.private static TexturePaint
darkerTexturePaint
(TexturePaint paint) Create a newTexturePaint
with its colors darkened.static boolean
setLegacyAlpha
(boolean legacyAlpha) Per defaultPaintAlpha
will try to honour alpha-channel information.
-
Field Details
-
FACTOR
private static final double FACTOR- See Also:
-
legacyAlpha
private static boolean legacyAlpha
-
-
Constructor Details
-
PaintAlpha
public PaintAlpha()
-
-
Method Details
-
setLegacyAlpha
public static boolean setLegacyAlpha(boolean legacyAlpha) Per defaultPaintAlpha
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.- Parameters:
legacyAlpha
- boolean- Returns:
- the previous setting
-
darker
Create a new (if possible, darker)Paint
of the same Type. If the Type is not supported, the originalPaint
is returned.- Parameters:
paint
- aPaint
implementation (e.g.Color
,GradientPaint
,TexturePaint
,..)- Returns:
- a (usually new, see above)
Paint
-
darker
Similar toColor.darker()
.The essential difference is that this method maintains the alpha-channel unchanged
- Parameters:
paint
- aColor
- Returns:
- a darker version of the
Color
-
darker
Create a newGradientPaint
with its colors darkened.- Parameters:
paint
- the gradient paint (null
not permitted).- Returns:
- a darker version of the
GradientPaint
-
darkerLinearGradientPaint
Create a new Gradient with its colours darkened.- Parameters:
paint
- aLinearGradientPaint
- Returns:
- a darker version of the
LinearGradientPaint
-
darkerRadialGradientPaint
Create a new Gradient with its colours darkened.- Parameters:
paint
- aRadialGradientPaint
- Returns:
- a darker version of the
RadialGradientPaint
-
darkerTexturePaint
Create a newTexturePaint
with its colors darkened.This entails cloning the underlying
BufferedImage
, then darkening each color-pixel individually!- Parameters:
paint
- aTexturePaint
- Returns:
- a darker version of the
TexturePaint
-
cloneImage
Clone aBufferedImage
.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.- Parameters:
image
- original BufferedImage to clone- Returns:
- a new BufferedImage reusing the original's Color Model and containing a clone of its pixels
-