Package wprover

Class CPoint


  • public class CPoint
    extends CClass
    CPoint class represents a point in a 2D space with x and y coordinates. It extends the CClass class and implements various methods for drawing, saving, and loading the point's properties.
    • Constructor Summary

      Constructors 
      Constructor Description
      CPoint()
      Default constructor for the CPoint class.
      CPoint​(int type, Param X, Param Y)
      Constructor for the CPoint class with specified type and coordinates.
      CPoint​(java.lang.String Name, Param X, Param Y)
      Constructor for the CPoint class with specified name and coordinates.
      CPoint​(Param X, Param Y)
      Constructor for the CPoint class with specified coordinates.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addcstoPoint​(Constraint cs)
      Adds a constraint to the point if it is not already present.
      boolean check_xy_valid​(double x, double y)
      Checks if the given x and y coordinates are valid based on the constraints.
      void draw​(java.awt.Graphics2D g2)
      Draws the point on the given graphics context.
      void draw​(java.awt.Graphics2D g2, boolean selected)
      Draws this point on the given graphics context.
      void draw_ct​(java.awt.Graphics2D g2)
      Draws the point with a custom style on the given graphics context.
      void draw_wt​(java.awt.Graphics2D g2)
      Draws the point and its text on the given graphics context.
      void drawA0​(java.awt.Graphics2D g2)
      Draws the point with a specific style on the given graphics context.
      boolean equals​(java.lang.Object obj)
      Checks if this point is equal to another object based on the name.
      Constraint getConstraint()
      Retrieves the first constraint associated with this point.
      java.lang.String getDescription()
      Returns a description of the point.
      CText getPText()
      Retrieves the text associated with this point.
      int getRadius()
      Gets the radius of the point.
      int getRadiusValue()
      Gets the radius value of the point.
      int getTx()
      Gets the x-coordinate of the point's text.
      int getTy()
      Gets the y-coordinate of the point's text.
      double getx()
      Gets the x-coordinate of this point.
      double gety()
      Gets the y-coordinate of this point.
      boolean isAFixedPoint()
      Checks if this point is a fixed point.
      boolean isAFreePoint()
      Checks if this point is a free point.
      boolean isEqual​(int x, int y)
      Checks if this point is equal to given coordinates based on their indices.
      boolean isEqual​(CPoint p)
      Checks if this point is equal to another point based on their coordinates.
      boolean isFreezed()
      Checks if this point is frozen.
      boolean isSame_Location​(double x, double y)
      Checks if the given location is the same as this point's location.
      void Load​(java.io.DataInputStream in, DrawProcess dp)
      Loads the state of this point from a data input stream.
      void Save​(java.io.DataOutputStream out)
      Saves the state of this point to a data output stream.
      void SavePS​(java.io.FileOutputStream fp, int stype)
      Saves the PostScript representation of this point to a file.
      void SavePS_Define_Point​(java.io.FileOutputStream fp)
      Saves the PostScript definition of this point to a file.
      void SavePsOringinal​(java.io.FileOutputStream fp)
      Saves the original PostScript representation of this point to a file.
      boolean select​(double x, double y)
      Selects this point if the given coordinates are within a certain distance.
      void setColor​(int c)
      Sets the color of this point.
      void setColorDefault()
      Sets the default color of the point based on its solved state.
      void setFillColor​(int index)
      Sets the fill color of this point.
      void setFreezed​(boolean r)
      Sets the frozen state of this point.
      void setInFlashing​(boolean flash)
      Sets the flashing state for this point and its associated text.
      void setRadius​(int r)
      Sets the radius of the point.
      void setXY​(double x, double y)
      Sets the x and y coordinates of this point.
      void stopFlash()
      Stops the flashing effect for this point and its associated text.
      java.lang.String toString()
      Returns the string representation of this point.
      java.lang.String TypeString()
      Returns the type of the point as a string.
      • Methods inherited from class java.lang.Object

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

      • POINT_RADIUS

        public int POINT_RADIUS
    • Constructor Detail

      • CPoint

        public CPoint()
        Default constructor for the CPoint class. Initializes the point with default values and sets the text position.
      • CPoint

        public CPoint​(int type,
                      Param X,
                      Param Y)
        Constructor for the CPoint class with specified type and coordinates.
        Parameters:
        type - the type of the point
        X - the x-coordinate parameter
        Y - the y-coordinate parameter
      • CPoint

        public CPoint​(java.lang.String Name,
                      Param X,
                      Param Y)
        Constructor for the CPoint class with specified name and coordinates.
        Parameters:
        Name - the name of the point
        X - the x-coordinate parameter
        Y - the y-coordinate parameter
      • CPoint

        public CPoint​(Param X,
                      Param Y)
        Constructor for the CPoint class with specified coordinates.
        Parameters:
        X - the x-coordinate parameter
        Y - the y-coordinate parameter
    • Method Detail

      • getConstraint

        public Constraint getConstraint()
        Retrieves the first constraint associated with this point.
        Returns:
        the first Constraint object, or null if no constraints are present
      • getPText

        public CText getPText()
        Retrieves the text associated with this point.
        Returns:
        the CText object associated with this point
      • equals

        public boolean equals​(java.lang.Object obj)
        Checks if this point is equal to another object based on the name.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object to compare with
        Returns:
        true if the names are equal, false otherwise
      • stopFlash

        public void stopFlash()
        Stops the flashing effect for this point and its associated text.
        Overrides:
        stopFlash in class CClass
      • setInFlashing

        public void setInFlashing​(boolean flash)
        Sets the flashing state for this point and its associated text.
        Overrides:
        setInFlashing in class CClass
        Parameters:
        flash - true to enable flashing, false to disable
      • isAFixedPoint

        public boolean isAFixedPoint()
        Checks if this point is a fixed point.
        Returns:
        true if both x and y coordinates are solved, false otherwise
      • isAFreePoint

        public boolean isAFreePoint()
        Checks if this point is a free point.
        Returns:
        true if both x and y coordinates are not solved, false otherwise
      • setColor

        public void setColor​(int c)
        Sets the color of this point.
        Overrides:
        setColor in class CClass
        Parameters:
        c - the color to set
      • select

        public boolean select​(double x,
                              double y)
        Selects this point if the given coordinates are within a certain distance.
        Parameters:
        x - the x-coordinate to check
        y - the y-coordinate to check
        Returns:
        true if the point is selected, false otherwise
      • draw

        public void draw​(java.awt.Graphics2D g2,
                         boolean selected)
        Draws this point on the given graphics context.
        Parameters:
        g2 - the graphics context
        selected - true if the point is selected, false otherwise
      • getRadius

        public int getRadius()
        Gets the radius of the point. If the radius is not set, it returns the default radius based on whether the application is running as an applet or a standalone application.
        Returns:
        the radius of the point
      • getRadiusValue

        public int getRadiusValue()
        Gets the radius value of the point.
        Returns:
        the radius value of the point
      • setRadius

        public void setRadius​(int r)
        Sets the radius of the point. If the given radius is less than or equal to 0, it sets the radius to the default value.
        Parameters:
        r - the new radius of the point
      • draw

        public void draw​(java.awt.Graphics2D g2)
        Draws the point on the given graphics context.
        Overrides:
        draw in class CClass
        Parameters:
        g2 - the graphics context
      • drawA0

        public void drawA0​(java.awt.Graphics2D g2)
        Draws the point with a specific style on the given graphics context.
        Parameters:
        g2 - the graphics context
      • draw_wt

        public void draw_wt​(java.awt.Graphics2D g2)
        Draws the point and its text on the given graphics context.
        Parameters:
        g2 - the graphics context
      • draw_ct

        public void draw_ct​(java.awt.Graphics2D g2)
        Draws the point with a custom style on the given graphics context.
        Parameters:
        g2 - the graphics context
      • TypeString

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

        public java.lang.String getDescription()
        Returns a description of the point.
        Specified by:
        getDescription in class CClass
        Returns:
        the description of the point
      • setColorDefault

        public void setColorDefault()
        Sets the default color of the point based on its solved state.
      • addcstoPoint

        public void addcstoPoint​(Constraint cs)
        Adds a constraint to the point if it is not already present.
        Parameters:
        cs - the constraint to add
      • check_xy_valid

        public boolean check_xy_valid​(double x,
                                      double y)
        Checks if the given x and y coordinates are valid based on the constraints.
        Parameters:
        x - the x-coordinate to check
        y - the y-coordinate to check
        Returns:
        true if the coordinates are valid, false otherwise
      • isEqual

        public boolean isEqual​(CPoint p)
        Checks if this point is equal to another point based on their coordinates.
        Parameters:
        p - the point to compare with
        Returns:
        true if the points have the same coordinates, false otherwise
      • isEqual

        public boolean isEqual​(int x,
                               int y)
        Checks if this point is equal to given coordinates based on their indices.
        Parameters:
        x - the x-coordinate index to compare
        y - the y-coordinate index to compare
        Returns:
        true if the indices match this point's indices, false otherwise
      • isSame_Location

        public boolean isSame_Location​(double x,
                                       double y)
        Checks if the given location is the same as this point's location.
        Parameters:
        x - the x-coordinate to compare
        y - the y-coordinate to compare
        Returns:
        true if the location matches this point's location, false otherwise
      • getx

        public double getx()
        Gets the x-coordinate of this point.
        Returns:
        the x-coordinate of this point
      • getTx

        public int getTx()
        Gets the x-coordinate of the point's text.
        Returns:
        the x-coordinate of the point's text
      • getTy

        public int getTy()
        Gets the y-coordinate of the point's text.
        Returns:
        the y-coordinate of the point's text
      • gety

        public double gety()
        Gets the y-coordinate of this point.
        Returns:
        the y-coordinate of this point
      • isFreezed

        public boolean isFreezed()
        Checks if this point is frozen.
        Returns:
        true if the point is frozen, false otherwise
      • setFreezed

        public void setFreezed​(boolean r)
        Sets the frozen state of this point.
        Parameters:
        r - the new frozen state
      • setXY

        public void setXY​(double x,
                          double y)
        Sets the x and y coordinates of this point.
        Parameters:
        x - the new x-coordinate
        y - the new y-coordinate
      • setFillColor

        public void setFillColor​(int index)
        Sets the fill color of this point.
        Parameters:
        index - the color index to set
      • toString

        public java.lang.String toString()
        Returns the string representation of this point.
        Overrides:
        toString in class CClass
        Returns:
        the name of this point
      • SavePS_Define_Point

        public void SavePS_Define_Point​(java.io.FileOutputStream fp)
                                 throws java.io.IOException
        Saves the PostScript definition of this point to a file.
        Parameters:
        fp - the file output stream to write to
        Throws:
        java.io.IOException - if an I/O error occurs
      • SavePS

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

        public void SavePsOringinal​(java.io.FileOutputStream fp)
                             throws java.io.IOException
        Saves the original PostScript representation of this point to a file.
        Parameters:
        fp - the file output stream to write to
        Throws:
        java.io.IOException - if an I/O error occurs
      • Save

        public void Save​(java.io.DataOutputStream out)
                  throws java.io.IOException
        Saves the state of this point to a data output stream.
        Overrides:
        Save in class CClass
        Parameters:
        out - the data output stream to write to
        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 state of this point from a data input stream.
        Overrides:
        Load in class CClass
        Parameters:
        in - the data input stream to read from
        dp - the draw process to use for loading
        Throws:
        java.io.IOException - if an I/O error occurs