Package wprover

Class CText


  • public class CText
    extends CClass
    CText is a class that represents a text object in a graphical application. It extends the CClass class and provides methods to manipulate and display text.
    • Constructor Summary

      Constructors 
      Constructor Description
      CText()
      Default constructor for the CText class.
      CText​(int x, int y, java.lang.String s)
      Constructor for the CText class.
      CText​(CClass f, double dx, double dy, int type)
      Constructor for the CText class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void drag​(double dx, double dy)
      Drags the text object by the given offsets (dx, dy).
      void drag​(double x0, double y0, double dx, double dy)
      Drags the text object from the given starting point (x0, y0) by the given offsets (dx, dy).
      void draw​(java.awt.Graphics2D g2)
      Draws the text object using the provided Graphics2D context.
      void draw​(java.awt.Graphics2D g2, boolean select)
      Draws the text object with a selection highlight using the provided Graphics2D context.
      boolean equals​(java.lang.Object obj)
      Checks if this CText object is equal to another object.
      java.lang.String getDescription()
      Retrieves a description of this text object.
      java.awt.Font getFont()
      Retrieves the font of this CText object.
      int getFontSize()
      Retrieves the font size of this CText object.
      java.awt.Point getLocation()
      Retrieves the location of the text as a Point object.
      java.lang.String getString()
      Retrieves the string content of this CText object.
      int getSX()
      Retrieves the x-coordinate for drawing the text.
      int getSY()
      Retrieves the y-coordinate for drawing the text.
      java.lang.String getText()
      Retrieves the text content of this CText object.
      java.awt.Dimension getTextDimension()
      Retrieves the dimensions of the text as a Dimension object.
      int getType()
      Retrieves the type of this CText object.
      java.lang.String getValueText()
      Retrieves the value text of this CText object.
      int getX()
      Retrieves the x-coordinate of the text.
      int getY()
      Retrieves the y-coordinate of the text.
      boolean inRect​(double x0, double y0, double x1, double y1)
      Checks if the given rectangle defined by (x0, y0) and (x1, y1) intersects with this text object.
      boolean isdraw()
      Checks if the text should be drawn based on its visibility and the visibility of its parent.
      void Load​(java.io.DataInputStream in, DrawProcess dp)
      Loads the text object from the specified data input stream.
      void move​(double dx, double dy)
      Moves the text object by the specified offsets.
      void Save​(java.io.DataOutputStream out)
      Saves the text object to the specified data output stream.
      void SavePS​(java.io.FileOutputStream fp, int stype)
      Saves the text object as a PostScript file.
      boolean select​(double x1, double y1)
      Checks if the given point (x1, y1) is within the bounds of this text object.
      void setBold()
      Sets the font to bold.
      void setFont​(java.awt.Font f)
      Sets the font of this CText object.
      void setFontSize​(int n)
      Sets the font size of this CText object.
      void setPlain()
      Sets the font to plain.
      void setText​(java.lang.String s)
      Sets the text content of this CText object based on its type.
      void setText1​(java.lang.String s)
      Sets the text content of this CText object.
      void setTextType​(int t)
      Sets the text type and parses the text value.
      void setXY​(int x, int y)
      Sets the x and y coordinates of this CText object.
      java.lang.String TypeString()
      Retrieves a string representation of the type of this text object.
      • Methods inherited from class java.lang.Object

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

      • CText

        public CText()
        Default constructor for the CText class. Initializes the text object with default values.
      • CText

        public CText​(CClass f,
                     double dx,
                     double dy,
                     int type)
        Constructor for the CText class. Initializes the text object with the specified parent, coordinates, and type.
        Parameters:
        f - the parent CClass object
        dx - the x-coordinate offset
        dy - the y-coordinate offset
        type - the type of the text
      • CText

        public CText​(int x,
                     int y,
                     java.lang.String s)
        Constructor for the CText class. Initializes the text object with the specified coordinates and string.
        Parameters:
        x - the x-coordinate of the text
        y - the y-coordinate of the text
        s - the string content of the text
    • Method Detail

      • getFont

        public java.awt.Font getFont()
        Retrieves the font of this CText object.
        Returns:
        the font
      • setTextType

        public void setTextType​(int t)
        Sets the text type and parses the text value.
        Parameters:
        t - the text type to set
      • getFontSize

        public int getFontSize()
        Retrieves the font size of this CText object.
        Returns:
        the font size
      • setBold

        public void setBold()
        Sets the font to bold.
      • setPlain

        public void setPlain()
        Sets the font to plain.
      • setFont

        public void setFont​(java.awt.Font f)
        Sets the font of this CText object.
        Parameters:
        f - the font to set
      • setFontSize

        public void setFontSize​(int n)
        Sets the font size of this CText object.
        Parameters:
        n - the font size to set
      • setXY

        public void setXY​(int x,
                          int y)
        Sets the x and y coordinates of this CText object.
        Parameters:
        x - the x-coordinate to set
        y - the y-coordinate to set
      • move

        public void move​(double dx,
                         double dy)
        Moves the text object by the specified offsets.
        Parameters:
        dx - the x-offset to move by
        dy - the y-offset to move by
      • equals

        public boolean equals​(java.lang.Object obj)
        Checks if this CText object is equal to another object.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object to compare with
        Returns:
        true if the objects are equal, false otherwise
      • getText

        public java.lang.String getText()
        Retrieves the text content of this CText object.
        Returns:
        the text content
      • setText1

        public void setText1​(java.lang.String s)
        Sets the text content of this CText object.
        Parameters:
        s - the text content to set
      • setText

        public void setText​(java.lang.String s)
        Sets the text content of this CText object based on its type.
        Parameters:
        s - the text content to set
      • getString

        public java.lang.String getString()
        Retrieves the string content of this CText object.
        Returns:
        the string content
      • getTextDimension

        public java.awt.Dimension getTextDimension()
        Retrieves the dimensions of the text as a Dimension object.
        Returns:
        the dimensions of the text
      • getX

        public int getX()
        Retrieves the x-coordinate of the text.
        Returns:
        the x-coordinate
      • getY

        public int getY()
        Retrieves the y-coordinate of the text.
        Returns:
        the y-coordinate
      • getLocation

        public java.awt.Point getLocation()
        Retrieves the location of the text as a Point object.
        Returns:
        the location of the text
      • getType

        public int getType()
        Retrieves the type of this CText object.
        Returns:
        the type of the text
      • isdraw

        public boolean isdraw()
        Checks if the text should be drawn based on its visibility and the visibility of its parent.
        Overrides:
        isdraw in class CClass
        Returns:
        true if the text should be drawn, false otherwise
      • getSX

        public int getSX()
        Retrieves the x-coordinate for drawing the text.
        Returns:
        the x-coordinate for drawing
      • getSY

        public int getSY()
        Retrieves the y-coordinate for drawing the text.
        Returns:
        the y-coordinate for drawing
      • getValueText

        public java.lang.String getValueText()
        Retrieves the value text of this CText object.
        Returns:
        the value text
      • draw

        public void draw​(java.awt.Graphics2D g2)
        Draws the text object using the provided Graphics2D context.
        Overrides:
        draw in class CClass
        Parameters:
        g2 - the Graphics2D context
      • draw

        public void draw​(java.awt.Graphics2D g2,
                         boolean select)
        Draws the text object with a selection highlight using the provided Graphics2D context.
        Parameters:
        g2 - the Graphics2D context
        select - true if the text object is selected, false otherwise
      • TypeString

        public java.lang.String TypeString()
        Retrieves a string representation of the type of this text object.
        Specified by:
        TypeString in class CClass
        Returns:
        the type string
      • getDescription

        public java.lang.String getDescription()
        Retrieves a description of this text object.
        Specified by:
        getDescription in class CClass
        Returns:
        the description
      • inRect

        public boolean inRect​(double x0,
                              double y0,
                              double x1,
                              double y1)
        Checks if the given rectangle defined by (x0, y0) and (x1, y1) intersects with this text object.
        Parameters:
        x0 - the x-coordinate of the first corner of the rectangle
        y0 - the y-coordinate of the first corner of the rectangle
        x1 - the x-coordinate of the opposite corner of the rectangle
        y1 - the y-coordinate of the opposite corner of the rectangle
        Returns:
        true if the rectangle intersects with this text object, false otherwise
      • select

        public boolean select​(double x1,
                              double y1)
        Checks if the given point (x1, y1) is within the bounds of this text object.
        Parameters:
        x1 - the x-coordinate of the point
        y1 - the y-coordinate of the point
        Returns:
        true if the point is within the bounds, false otherwise
      • drag

        public void drag​(double dx,
                         double dy)
        Drags the text object by the given offsets (dx, dy).
        Parameters:
        dx - the x-offset to drag by
        dy - the y-offset to drag by
      • drag

        public void drag​(double x0,
                         double y0,
                         double dx,
                         double dy)
        Drags the text object from the given starting point (x0, y0) by the given offsets (dx, dy).
        Parameters:
        x0 - the starting x-coordinate
        y0 - the starting y-coordinate
        dx - the x-offset to drag by
        dy - the y-offset to drag by
      • SavePS

        public void SavePS​(java.io.FileOutputStream fp,
                           int stype)
                    throws java.io.IOException
        Saves the text object as a PostScript file.
        Specified by:
        SavePS in class CClass
        Parameters:
        fp - the file output stream to write to
        stype - the style type (0 for color, 1 for gray, 2 for black & white)
        Throws:
        java.io.IOException - if an I/O error occurs
      • Save

        public void Save​(java.io.DataOutputStream out)
                  throws java.io.IOException
        Saves the text object to the specified 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 text object from the specified data input stream.
        Overrides:
        Load in class CClass
        Parameters:
        in - the data input stream to read from
        dp - the draw process
        Throws:
        java.io.IOException - if an I/O error occurs