Class Line


  • class Line
    extends java.lang.Object
    This class describes a rasterized line. This was done as part of GSoC2014, Tilman Hausherr is the mentor.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private float[] color0  
      private float[] color1  
      protected java.util.Set<java.awt.Point> linePoints  
      private java.awt.Point point0  
      private java.awt.Point point1  
    • Constructor Summary

      Constructors 
      Constructor Description
      Line​(java.awt.Point p0, java.awt.Point p1, float[] c0, float[] c1)
      Constructor of class Line.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected float[] calcColor​(java.awt.Point p)
      Calculate the color of a point on a rasterized line by linear interpolation.
      private java.util.Set<java.awt.Point> calcLine​(int x0, int y0, int x1, int y1)
      Calculate the points of a line with Bresenham's line algorithm Bresenham's line algorithm
      • Methods inherited from class java.lang.Object

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

      • point0

        private final java.awt.Point point0
      • point1

        private final java.awt.Point point1
      • color0

        private final float[] color0
      • color1

        private final float[] color1
      • linePoints

        protected final java.util.Set<java.awt.Point> linePoints
    • Constructor Detail

      • Line

        Line​(java.awt.Point p0,
             java.awt.Point p1,
             float[] c0,
             float[] c1)
        Constructor of class Line.
        Parameters:
        p0 - one end of a line
        p1 - the other end of the line
        c0 - color of point p0
        c1 - color of point p1
    • Method Detail

      • calcLine

        private java.util.Set<java.awt.Point> calcLine​(int x0,
                                                       int y0,
                                                       int x1,
                                                       int y1)
        Calculate the points of a line with Bresenham's line algorithm Bresenham's line algorithm
        Parameters:
        x0 - coordinate
        y0 - coordinate
        x1 - coordinate
        y1 - coordinate
        Returns:
        all the points on the rasterized line from (x0, y0) to (x1, y1)
      • calcColor

        protected float[] calcColor​(java.awt.Point p)
        Calculate the color of a point on a rasterized line by linear interpolation.
        Parameters:
        p - target point, p should always be contained in linePoints
        Returns:
        color