Package wprover

Class CAngle


  • public class CAngle
    extends CClass
    Class representing an angle in a geometric construction.
    • Constructor Detail

      • CAngle

        public CAngle()
        Constructor for CAngle.
      • CAngle

        public CAngle​(CLine l1,
                      CLine l2,
                      CPoint p1,
                      CPoint p2,
                      CPoint p3,
                      CPoint p4)
        Constructs a CAngle object with specified lines and points.
        Parameters:
        l1 - The first line.
        l2 - The second line.
        p1 - The first point.
        p2 - The second point.
        p3 - The third point.
        p4 - The fourth point.
      • CAngle

        public CAngle​(CLine l1,
                      CLine l2,
                      CPoint p1,
                      CPoint p2)
        Constructs a CAngle object.
        Parameters:
        l1 - the first line
        l2 - the second line
        p1 - the first point
        p2 - the second point
    • Method Detail

      • setValue1

        public void setValue1​(int c)
        Set the value for the angle.
        Parameters:
        c - The value to set.
      • getTextType

        public int getTextType()
        Get the type of text to display for the angle.
        Returns:
        The type of text.
      • setTextType

        public void setTextType​(int n)
        Set the type of text to display for the angle.
        Parameters:
        n - The type of text to set.
      • getValue1

        public int getValue1()
        Get the value of the angle.
        Returns:
        The value of the angle.
      • setAngleType

        public void setAngleType​(int n)
        Set the type of the angle.
        Parameters:
        n - The type of the angle to set.
      • getAngleType

        public int getAngleType()
        Get the type of the angle.
        Returns:
        The type of the angle.
      • isSame

        public boolean isSame​(CPoint p1,
                              CPoint p2,
                              CPoint p3,
                              CPoint p4)
        Check if two angles are the same.
        Parameters:
        p1 - Point 1 of angle 1.
        p2 - Point 2 of angle 1.
        p3 - Point 1 of angle 2.
        p4 - Point 2 of angle 2.
        Returns:
        True if the angles are the same, false otherwise.
      • setAngleText

        public void setAngleText​(java.lang.String s)
        Sets the text of the angle.
        Parameters:
        s - The text to set.
      • getAngleName

        public java.lang.String getAngleName()
        Gets the name of the angle based on its defining points and lines.
        Returns:
        The name of the angle.
      • setRadius

        public void setRadius​(int v)
        Sets the radius of the angle.
        Parameters:
        v - the radius value
      • getRadius

        public int getRadius()
        Gets the radius of the angle.
        Returns:
        the radius value
      • getText

        public CText getText()
        Gets the text associated with the angle.
        Returns:
        the CText object representing the text
      • getxForString

        public double getxForString()
        Gets the x-coordinate for the angle's string representation.
        Returns:
        the x-coordinate
      • getyForString

        public double getyForString()
        Gets the y-coordinate for the angle's string representation.
        Returns:
        the y-coordinate
      • TypeString

        public java.lang.String TypeString()
        Gets the type string of the angle.
        Specified by:
        TypeString in class CClass
        Returns:
        the type string
      • getDescription

        public java.lang.String getDescription()
        Gets the description of the angle.
        Specified by:
        getDescription in class CClass
        Returns:
        the description string
      • getVertex

        public CPoint getVertex()
        Gets the vertex point of the angle.
        Returns:
        the vertex point
      • canEqual

        public static CPoint canEqual​(CAngle ag1,
                                      CAngle ag2)
        Checks if two angles can be considered equal based on their common points and lines.
        Parameters:
        ag1 - the first angle
        ag2 - the second angle
        Returns:
        the common point, or null if they are not equal
      • select

        public boolean select​(double x,
                              double y)
        Selects the angle if the given coordinates are within the angle's range.
        Parameters:
        x - the x-coordinate
        y - the y-coordinate
        Returns:
        true if the angle is selected, false otherwise
      • move

        public void move​(double dx,
                         double dy)
        Moves the angle by adjusting its radius based on the given coordinates.
        Parameters:
        dx - the x-coordinate
        dy - the y-coordinate
      • draw

        public void draw​(java.awt.Graphics2D g2)
        Draws the angle using the given Graphics2D object.
        Overrides:
        draw in class CClass
        Parameters:
        g2 - the Graphics2D object
      • drawauxLine1

        public void drawauxLine1​(double x,
                                 double y,
                                 CPoint p,
                                 CPoint p1,
                                 CPoint p2,
                                 java.awt.Graphics2D g2)
        Draws an auxiliary line from a point to the perimeter of the angle.
        Parameters:
        x - the x-coordinate
        y - the y-coordinate
        p - the first point
        p1 - the second point
        p2 - the third point
        g2 - the Graphics2D object
      • drawauxLine

        public void drawauxLine​(double x,
                                double y,
                                java.awt.Graphics2D g2)
        Draws an auxiliary line for the angle.
        Parameters:
        x - the x-coordinate
        y - the y-coordinate
        g2 - the Graphics2D object
      • setShowType

        public void setShowType​(int n)
        Sets the show type of the angle.
        Parameters:
        n - the show type
      • draw

        public void draw​(java.awt.Graphics2D g2,
                         boolean isSelected)
        Draws the angle with the option to highlight if selected.
        Parameters:
        g2 - the Graphics2D object
        isSelected - true if the angle is selected, false otherwise
      • roundValue

        public float roundValue​(double r)
        Rounds the given value to one decimal place.
        Parameters:
        r - the value to round
        Returns:
        the rounded value
      • SavePS

        public void SavePS​(java.io.FileOutputStream fp,
                           int stype)
                    throws java.io.IOException
        Saves the angle to a PostScript file.
        Specified by:
        SavePS in class CClass
        Parameters:
        fp - the file output stream
        stype - the show type
        Throws:
        java.io.IOException - if an I/O error occurs
      • round

        public float round​(float r)
        Rounds the given angle to be within the range of -180 to 180 degrees.
        Parameters:
        r - the angle to round
        Returns:
        the rounded angle
      • get3pAngle

        public static double get3pAngle​(double x1,
                                        double y1,
                                        double x2,
                                        double y2,
                                        double x3,
                                        double y3)
        Calculates the angle between three points.
        Parameters:
        x1 - the x-coordinate of the first point
        y1 - the y-coordinate of the first point
        x2 - the x-coordinate of the second point
        y2 - the y-coordinate of the second point
        x3 - the x-coordinate of the third point
        y3 - the y-coordinate of the third point
        Returns:
        the angle in radians
      • get4pAngle

        public static double get4pAngle​(double x1,
                                        double y1,
                                        double x2,
                                        double y2,
                                        double x3,
                                        double y3,
                                        double x4,
                                        double y4)
        Calculates the angle between four points.
        Parameters:
        x1 - the x-coordinate of the first point
        y1 - the y-coordinate of the first point
        x2 - the x-coordinate of the second point
        y2 - the y-coordinate of the second point
        x3 - the x-coordinate of the third point
        y3 - the y-coordinate of the third point
        x4 - the x-coordinate of the fourth point
        y4 - the y-coordinate of the fourth point
        Returns:
        the angle in radians
      • getAngleValue

        public static double getAngleValue​(CPoint pa,
                                           CPoint pb,
                                           CPoint pc)
        Calculates the angle value between three points.
        Parameters:
        pa - the first point
        pb - the second point
        pc - the third point
        Returns:
        the angle value in radians
      • getAngleValue

        public static double getAngleValue​(CPoint p1,
                                           CPoint p2,
                                           CPoint p3,
                                           CPoint p4)
        Calculates the angle value between four points.
        Parameters:
        p1 - the first point
        p2 - the second point
        p3 - the third point
        p4 - the fourth point
        Returns:
        the angle value in radians
      • Save

        public void Save​(java.io.DataOutputStream out)
                  throws java.io.IOException
        Saves the angle data to an output stream.
        Overrides:
        Save in class CClass
        Parameters:
        out - the data output stream
        Throws:
        java.io.IOException - if an I/O error occurs
      • Load

        public void Load​(java.io.DataInputStream in,
                         DrawProcess dp)
                  throws java.io.IOException
        Loads the angle data from an input stream.
        Overrides:
        Load in class CClass
        Parameters:
        in - the data input stream
        dp - the draw process
        Throws:
        java.io.IOException - if an I/O error occurs