Package wprover
Class CPoint
- java.lang.Object
-
- wprover.CClass
-
- wprover.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 voidaddcstoPoint(Constraint cs)Adds a constraint to the point if it is not already present.booleancheck_xy_valid(double x, double y)Checks if the given x and y coordinates are valid based on the constraints.voiddraw(java.awt.Graphics2D g2)Draws the point on the given graphics context.voiddraw(java.awt.Graphics2D g2, boolean selected)Draws this point on the given graphics context.voiddraw_ct(java.awt.Graphics2D g2)Draws the point with a custom style on the given graphics context.voiddraw_wt(java.awt.Graphics2D g2)Draws the point and its text on the given graphics context.voiddrawA0(java.awt.Graphics2D g2)Draws the point with a specific style on the given graphics context.booleanequals(java.lang.Object obj)Checks if this point is equal to another object based on the name.ConstraintgetConstraint()Retrieves the first constraint associated with this point.java.lang.StringgetDescription()Returns a description of the point.CTextgetPText()Retrieves the text associated with this point.intgetRadius()Gets the radius of the point.intgetRadiusValue()Gets the radius value of the point.intgetTx()Gets the x-coordinate of the point's text.intgetTy()Gets the y-coordinate of the point's text.doublegetx()Gets the x-coordinate of this point.doublegety()Gets the y-coordinate of this point.booleanisAFixedPoint()Checks if this point is a fixed point.booleanisAFreePoint()Checks if this point is a free point.booleanisEqual(int x, int y)Checks if this point is equal to given coordinates based on their indices.booleanisEqual(CPoint p)Checks if this point is equal to another point based on their coordinates.booleanisFreezed()Checks if this point is frozen.booleanisSame_Location(double x, double y)Checks if the given location is the same as this point's location.voidLoad(java.io.DataInputStream in, DrawProcess dp)Loads the state of this point from a data input stream.voidSave(java.io.DataOutputStream out)Saves the state of this point to a data output stream.voidSavePS(java.io.FileOutputStream fp, int stype)Saves the PostScript representation of this point to a file.voidSavePS_Define_Point(java.io.FileOutputStream fp)Saves the PostScript definition of this point to a file.voidSavePsOringinal(java.io.FileOutputStream fp)Saves the original PostScript representation of this point to a file.booleanselect(double x, double y)Selects this point if the given coordinates are within a certain distance.voidsetColor(int c)Sets the color of this point.voidsetColorDefault()Sets the default color of the point based on its solved state.voidsetFillColor(int index)Sets the fill color of this point.voidsetFreezed(boolean r)Sets the frozen state of this point.voidsetInFlashing(boolean flash)Sets the flashing state for this point and its associated text.voidsetRadius(int r)Sets the radius of the point.voidsetXY(double x, double y)Sets the x and y coordinates of this point.voidstopFlash()Stops the flashing effect for this point and its associated text.java.lang.StringtoString()Returns the string representation of this point.java.lang.StringTypeString()Returns the type of the point as a string.-
Methods inherited from class wprover.CClass
copy, get_type, getColor, getColorIndex, getname, getPSLineString, hasNameSet, isdraw, saveSuper, saveSuperColor, setAttr, setAttrAux, setDash, setWidth, visible
-
-
-
-
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 pointX- the x-coordinate parameterY- 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 pointX- the x-coordinate parameterY- 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:
equalsin classjava.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.
-
setInFlashing
public void setInFlashing(boolean flash)
Sets the flashing state for this point and its associated text.- Overrides:
setInFlashingin classCClass- 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.
-
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 checky- 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 contextselected- 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.
-
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:
TypeStringin classCClass- Returns:
- the type of the point
-
getDescription
public java.lang.String getDescription()
Returns a description of the point.- Specified by:
getDescriptionin classCClass- 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 checky- 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 comparey- 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 comparey- 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-coordinatey- 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.
-
SavePS_Define_Point
public void SavePS_Define_Point(java.io.FileOutputStream fp) throws java.io.IOExceptionSaves 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.IOExceptionSaves the PostScript representation of this point to a file.
-
SavePsOringinal
public void SavePsOringinal(java.io.FileOutputStream fp) throws java.io.IOExceptionSaves 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.IOExceptionSaves the state of this point to a data output stream.
-
Load
public void Load(java.io.DataInputStream in, DrawProcess dp) throws java.io.IOExceptionLoads the state of this point from a data input stream.
-
-