Class ContourPlot.BarycentricGradientPaint

  • All Implemented Interfaces:
    java.awt.Paint, java.awt.Transparency
    Enclosing class:
    ContourPlot

    public class ContourPlot.BarycentricGradientPaint
    extends java.lang.Object
    implements java.awt.Paint
    The BarycentricGradientPaint class provides a way to fill a Shape with a triangular color gradient. Colors are specified for the vertices of a triangle and interpolated within the triangle according to barycentric coordinates. Only areas of the filled shape that are intersecting with the triangle of this paint are colored.

    This paint supports the ANTIALIASING rendering hint (RenderingHints) using a 4x multisampling approach. When enabled, the edges of the triangle will appear anti-aliased. It is recommended to disable AA when filling a triangle mesh (where triangles are adjacent), since otherwise triangle edges become visible.

    Note that it is not necessary to use a triangular Shape to render a triangle. Instead a rectangle can be used as well, since only the intersecting area will be filled.

    Author:
    hageldave
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.awt.Color color1  
      protected java.awt.Color color2  
      protected java.awt.Color color3  
      protected java.awt.geom.Point2D.Float p1  
      protected java.awt.geom.Point2D.Float p2  
      protected java.awt.geom.Point2D.Float p3  
      • Fields inherited from interface java.awt.Transparency

        BITMASK, OPAQUE, TRANSLUCENT
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.PaintContext createContext​(java.awt.image.ColorModel cm, java.awt.Rectangle deviceBounds, java.awt.geom.Rectangle2D userBounds, java.awt.geom.AffineTransform xform, java.awt.RenderingHints hints)  
      int getTransparency()  
      • Methods inherited from class java.lang.Object

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

      • p1

        protected java.awt.geom.Point2D.Float p1
      • p2

        protected java.awt.geom.Point2D.Float p2
      • p3

        protected java.awt.geom.Point2D.Float p3
      • color1

        protected java.awt.Color color1
      • color2

        protected java.awt.Color color2
      • color3

        protected java.awt.Color color3
    • Constructor Detail

      • BarycentricGradientPaint

        public BarycentricGradientPaint​(java.awt.geom.Point2D p1,
                                        java.awt.geom.Point2D p2,
                                        java.awt.geom.Point2D p3,
                                        java.awt.Color color1,
                                        java.awt.Color color2,
                                        java.awt.Color color3)
        Creates a new ContourPlot.BarycentricGradientPaint object with specified triangle vertices and vertex colors.
        Parameters:
        p1 - vertex of triangle
        p2 - vertex of triangle
        p3 - vertex of triangle
        color1 - color of vertex
        color2 - color of vertex
        color3 - color of vertex
      • BarycentricGradientPaint

        public BarycentricGradientPaint​(float[] x,
                                        float[] y,
                                        java.awt.Color color1,
                                        java.awt.Color color2,
                                        java.awt.Color color3)
        Creates a new ContourPlot.BarycentricGradientPaint object with specified triangle vertices and vertex colors.
        Parameters:
        x - x-coordinates for the triangle vertices
        y - y-coordinates for the triangle vertices
        color1 - color of vertex
        color2 - color of vertex
        color3 - color of vertex
      • BarycentricGradientPaint

        public BarycentricGradientPaint​(double x1,
                                        double y1,
                                        double x2,
                                        double y2,
                                        double x3,
                                        double y3,
                                        java.awt.Color color1,
                                        java.awt.Color color2,
                                        java.awt.Color color3)
        Creates a new ContourPlot.BarycentricGradientPaint object with specified triangle vertices and vertex colors.
        Parameters:
        x1 - x-coord of triangle vertex
        y1 - y-coord of triangle vertex
        x2 - x-coord of triangle vertex
        y2 - y-coord of triangle vertex
        x3 - x-coord of triangle vertex
        y3 - y-coord of triangle vertex
        color1 - color of vertex
        color2 - color of vertex
        color3 - color of vertex
      • BarycentricGradientPaint

        public BarycentricGradientPaint​(float x1,
                                        float y1,
                                        float x2,
                                        float y2,
                                        float x3,
                                        float y3,
                                        java.awt.Color color1,
                                        java.awt.Color color2,
                                        java.awt.Color color3)
        Creates a new ContourPlot.BarycentricGradientPaint object with specified triangle vertices and vertex colors.
        Parameters:
        x1 - x-coord of triangle vertex
        y1 - y-coord of triangle vertex
        x2 - x-coord of triangle vertex
        y2 - y-coord of triangle vertex
        x3 - x-coord of triangle vertex
        y3 - y-coord of triangle vertex
        color1 - color of vertex
        color2 - color of vertex
        color3 - color of vertex
    • Method Detail

      • getTransparency

        public int getTransparency()
        Specified by:
        getTransparency in interface java.awt.Transparency
      • createContext

        public java.awt.PaintContext createContext​(java.awt.image.ColorModel cm,
                                                   java.awt.Rectangle deviceBounds,
                                                   java.awt.geom.Rectangle2D userBounds,
                                                   java.awt.geom.AffineTransform xform,
                                                   java.awt.RenderingHints hints)
        Specified by:
        createContext in interface java.awt.Paint