Class Quadrilateral

  • All Implemented Interfaces:
    android.os.Parcelable

    public class Quadrilateral
    extends java.lang.Object
    implements android.os.Parcelable
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface android.os.Parcelable

        android.os.Parcelable.ClassLoaderCreator<T extends java.lang.Object>, android.os.Parcelable.Creator<T extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static android.os.Parcelable.Creator<Quadrilateral> CREATOR  
      • Fields inherited from interface android.os.Parcelable

        CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Quadrilateral clone()  
      int describeContents()  
      int getColor()  
      Point getLowerLeft()
      Returns the point nearest to (0, height) coordinate
      Point getLowerRight()
      Returns the point nearest to (width, height) coordinate
      Quadrilateral getSortedQuad()
      Returns the Quadrilateral which has same corners as original, but it guarantees that upper left point is the point nearest to (0,0) coordinate.
      Point getUpperLeft()
      Returns the point nearest to (0, 0) coordinate.
      Point getUpperRight()
      Returns the point nearest to (width, 0) coordinate
      boolean isDefaultQuad()  
      boolean isEmpty()
      Returns true if quadrilateral is empty, i.e.
      boolean matchesMargins​(int top, int bottom, int left, int right, int hostActivityOrientation)  
      void mirror​(int canvasWidth, int canvasHeight, int hostActivityOrientation)
      Mirrors the quadrangle so that it can be properly drawn on mirrored camera preview
      void setColor​(int color)  
      void setIsDefaultQuad​(boolean defaultQuad)  
      void setMargins​(int top, int bottom, int left, int right, int hostActivityOrientation)  
      void setPoints​(Point uleft, Point uright, Point lleft, Point lright)  
      void toFloatArray​(float[] arr)
      Converts this quadrilateral to array of float points.
      java.lang.String toString()  
      void writeToParcel​(android.os.Parcel dest, int flags)  
      • Methods inherited from class java.lang.Object

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

      • CREATOR

        @NonNull
        public static final android.os.Parcelable.Creator<Quadrilateral> CREATOR
    • Constructor Detail

      • Quadrilateral

        public Quadrilateral​(int top,
                             int bottom,
                             int left,
                             int right,
                             int hostActivityOrientation)
      • Quadrilateral

        public Quadrilateral()
      • Quadrilateral

        public Quadrilateral​(@NonNull
                             Point uleft,
                             @NonNull
                             Point uright,
                             @NonNull
                             Point lleft,
                             @NonNull
                             Point lright)
      • Quadrilateral

        public Quadrilateral​(@Size(8L) @NonNull
                             float[] points)
        Constructor from float array. The points are represented as pairs (x,y) in clockwise order: upper left, upper right, lower right, lower left
        Parameters:
        points - float pairs representing quadrilateral points
      • Quadrilateral

        protected Quadrilateral​(@NonNull
                                android.os.Parcel in)
    • Method Detail

      • setMargins

        public void setMargins​(int top,
                               int bottom,
                               int left,
                               int right,
                               int hostActivityOrientation)
      • matchesMargins

        public boolean matchesMargins​(int top,
                                      int bottom,
                                      int left,
                                      int right,
                                      int hostActivityOrientation)
      • isEmpty

        public boolean isEmpty()
        Returns true if quadrilateral is empty, i.e. all 4 points have coordinates (0,0).
        Returns:
        true if quadrilateral is empty, i.e. all 4 points have coordinates (0,0).
      • toFloatArray

        public void toFloatArray​(@NonNull @Size(8L)
                                 float[] arr)
        Converts this quadrilateral to array of float points. The points are represented as pairs (x,y) in clockwise order: upper left, upper right, lower right, lower left
      • setPoints

        public void setPoints​(@NonNull
                              Point uleft,
                              @NonNull
                              Point uright,
                              @NonNull
                              Point lleft,
                              @NonNull
                              Point lright)
      • toString

        @NonNull
        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • mirror

        public void mirror​(int canvasWidth,
                           int canvasHeight,
                           int hostActivityOrientation)
        Mirrors the quadrangle so that it can be properly drawn on mirrored camera preview
        Parameters:
        canvasWidth - width of canvas
        canvasHeight - height of canvas
      • getSortedQuad

        @NonNull
        public Quadrilateral getSortedQuad()
        Returns the Quadrilateral which has same corners as original, but it guarantees that upper left point is the point nearest to (0,0) coordinate.
        Returns:
        sorted Quadrilateral
      • getUpperLeft

        @NonNull
        public Point getUpperLeft()
        Returns the point nearest to (0, 0) coordinate.
        Returns:
        the point nearest to (0, 0) coordinate.
      • getUpperRight

        @NonNull
        public Point getUpperRight()
        Returns the point nearest to (width, 0) coordinate
        Returns:
        the point nearest to (width, 0) coordinate
      • getLowerLeft

        @NonNull
        public Point getLowerLeft()
        Returns the point nearest to (0, height) coordinate
        Returns:
        the point nearest to (height, 0) coordinate
      • getLowerRight

        @NonNull
        public Point getLowerRight()
        Returns the point nearest to (width, height) coordinate
        Returns:
        the point nearest to (width, height) coordinate
      • getColor

        public int getColor()
      • setColor

        public void setColor​(int color)
      • isDefaultQuad

        public boolean isDefaultQuad()
      • setIsDefaultQuad

        public void setIsDefaultQuad​(boolean defaultQuad)
      • clone

        @NonNull
        public Quadrilateral clone()
        Overrides:
        clone in class java.lang.Object
      • describeContents

        public int describeContents()
        Specified by:
        describeContents in interface android.os.Parcelable
      • writeToParcel

        public void writeToParcel​(@NonNull
                                  android.os.Parcel dest,
                                  int flags)
        Specified by:
        writeToParcel in interface android.os.Parcelable