Class DirectionalGradientPaintTransformer

  • All Implemented Interfaces:
    GradientPaintTransformer

    public class DirectionalGradientPaintTransformer
    extends java.lang.Object
    implements GradientPaintTransformer
    Transforms a GradientPaint to range over the width of a target shape. The orientation of the resulting GradientPaint depend on the coordinates of the original paint:
    • If the original paint starts at 0,0 and ends at a point 0, y != 0, the resulting paint will have a vertical orientation.
    • If the original paint starts at 0,0 and ends at a point x !=0, 0, the resulting paint will have a horizontal orientation.
    • If the original paint starts at 0,0 and ends at a point x != 0, y != 0, the resulting paint will have a diagonal orientation from the upper left to the lower right edge. Lines of equal color will have a 45 ∞ angle, pointing upwards from left to right.
    • If the original paint starts at a point x != 0, y != 0, the resulting paint will have a diagonal orientation from the lower left to the upper right edge. Lines of equal color will have a 45 ∞ angle, pointing downwards from left to right.

    In all cases, the cyclic flag of the original paint will be taken into account.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.GradientPaint transform​(java.awt.GradientPaint paint, java.awt.Shape target)
      Transforms a GradientPaint instance to fit some target shape.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DirectionalGradientPaintTransformer

        public DirectionalGradientPaintTransformer()
        Default constructor.
    • Method Detail

      • transform

        public java.awt.GradientPaint transform​(java.awt.GradientPaint paint,
                                                java.awt.Shape target)
        Transforms a GradientPaint instance to fit some target shape.
        Specified by:
        transform in interface GradientPaintTransformer
        Parameters:
        paint - the original paint (not null).
        target - the reference area (not null).
        Returns:
        A transformed paint.