Package 

Class PolygonHelper


  • 
    public class PolygonHelper
    
                        

    Helper to make it easier to draw polygon on view

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public class PolygonHelper.Edge

      Represents edge of polygon with near and far pointsas well as intersecting lines from other edges

      pointA handle pointBO========[0]=========O| ^ edgeLine ^ || ||lineA | lineB| || |O====================OpointFarA pointFarB

      public class PolygonHelper.Line

      Representation of line

      Calculates line by two pointsand finds intersection points with other linesGeneral line formula isa * x + b * y + c = 0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int rotation
    • Method Summary

      Modifier and Type Method Description
      void setRotation(int degrees) Set rotation in degrees for polygon
      static boolean checkPolygonSize(List<Point> polygon)
      void setImageSize(int width, int height) Set scaled image size that will be drawn on screen
      void setLayout(int left, int top, int right, int bottom) Sets layout of surface inside parent to compensate differencesbetween viewport and preview sizes and draw polygon correctly
      void polygonToLinePoints(List<PointF> polygon, Array<float> points) Calculates lines points from polygon multiplying 0..1 values by view dimensionsand applying rotation matrix.
      void polygonToPoints(List<PointF> polygon, Array<float> points) Calculates points from polygon multiplying 0..1 values by view dimensionsand applying rotation matrix.
      void getDrawingPolygon(List<PointF> polygon, List<PointF> drawingPolygon) Processes original polygon with coordinates 0..
      void getPolygonFromDrawingPolygon(List<PointF> drawingPolygon, List<PointF> polygon) Processes drawing polygon coordinatesto polygon with coordinates 0..
      List<Line2D> scaleLines(List<Line2D> lines) Performs scaling from 0..
      • Methods inherited from class java.lang.Object

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

      • setRotation

         void setRotation(int degrees)

        Set rotation in degrees for polygon

        Parameters:
        degrees - usually camera rotation angle is used here
      • setImageSize

         void setImageSize(int width, int height)

        Set scaled image size that will be drawn on screen

      • setLayout

         void setLayout(int left, int top, int right, int bottom)

        Sets layout of surface inside parent to compensate differencesbetween viewport and preview sizes and draw polygon correctly

      • polygonToLinePoints

         void polygonToLinePoints(List<PointF> polygon, Array<float> points)

        Calculates lines points from polygon multiplying 0..1 values by view dimensionsand applying rotation matrix.Usually used on preview as it has camera rotation

      • polygonToPoints

         void polygonToPoints(List<PointF> polygon, Array<float> points)

        Calculates points from polygon multiplying 0..1 values by view dimensionsand applying rotation matrix.Usually used on preview as it has camera rotation

      • getDrawingPolygon

         void getDrawingPolygon(List<PointF> polygon, List<PointF> drawingPolygon)

        Processes original polygon with coordinates 0..1to drawing polygon by multiplying them by view dimensions

      • scaleLines

         List<Line2D> scaleLines(List<Line2D> lines)

        Performs scaling from 0..1 values to image pixel values