* @return The transformed paint.
*/
public GradientPaint transform(final GradientPaint paint,
final Shape target) {
GradientPaint result = paint;
final Rectangle2D bounds = target.getBounds2D();
if (this.type.equals(GradientPaintTransformType.VERTICAL)) {
result = new GradientPaint(
(float) bounds.getCenterX(), (float) bounds.getMinY(),
paint.getColor1(), (float) bounds.getCenterX(),
(float) bounds.getMaxY(), paint.getColor2()
);
}
else if (this.type.equals(GradientPaintTransformType.HORIZONTAL)) {
result = new GradientPaint(
(float) bounds.getMinX(), (float) bounds.getCenterY(),
paint.getColor1(), (float) bounds.getMaxX(),
(float) bounds.getCenterY(), paint.getColor2()
);
}
else if (this.type.equals(GradientPaintTransformType.CENTER_HORIZONTAL))
{
result = new GradientPaint(
(float) bounds.getCenterX(), (float) bounds.getCenterY(),
paint.getColor1(), (float) bounds.getMaxX(),
(float) bounds.getCenterY(), paint.getColor2(), true
);
}
else if (this.type.equals(GradientPaintTransformType.CENTER_VERTICAL)) {
result = new GradientPaint(
(float) bounds.getCenterX(), (float) bounds.getMinY(),
paint.getColor1(), (float) bounds.getCenterX(),
(float) bounds.getCenterY(), paint.getColor2(), true
);
}