Package wprover
Class CLine
- java.lang.Object
-
- wprover.CClass
-
- wprover.CLine
-
public class CLine extends CClass
Represents a geometric line with various properties and methods.
-
-
Constructor Summary
Constructors Constructor Description CLine(int type)Constructs a CLine with a specified type.CLine(java.lang.String name, CPoint A, CPoint B)Constructs a CLine with a name and two points.CLine(CPoint A, int type)Constructs a CLine with a specified point and type.CLine(CPoint A, CPoint B)Constructs a CLine with two points.CLine(CPoint A, CPoint B, int Type)Constructs a CLine with two points and a specified type.CLine(CPoint A, CPoint B, java.lang.String color)Constructs a CLine with two points and a specified color.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddApoint(CPoint a)Adds a point to the line.voidaddconstraint(Constraint cs)Adds a constraint to the line.static CPoint[]commonPoint(CLine ln, Circle c)Finds the common points between a line and a circle.static CPointcommonPoint(CLine line0, CLine line1)Finds the common point between two lines.booleancontainPT(CPoint p)Checks if the line contains the specified point.booleancontainPTs(CPoint p1, CPoint p2)Checks if the line contains the specified points.doubledistance(double x, double y)Calculates the distance from a point to this line.static doubledistanceToPoint(double x1, double y1, double k, double x, double y)Calculates the distance from a point to a line given the slope.static doubledistanceToPoint(CLine ln, double x, double y)Calculates the distance from a point to a line.voiddraw(java.awt.Graphics2D g2)Draws the line on the given graphics context.voiddraw(java.awt.Graphics2D g2, boolean selected)Draws the line on the given graphics context.static voiddrawABLine(CLine line, java.awt.Graphics2D g2)Draws an ABLine.static voiddrawALine(CLine line, java.awt.Graphics2D g2)Draws an ALine.static voiddrawBLine(CLine line, java.awt.Graphics2D g2)Draws a BLine.static voiddrawCCLine(CLine line, java.awt.Graphics2D g2)Draws a CCLine.static voiddrawLLine(CLine line, java.awt.Graphics2D g2)Draws an LLine.static voiddrawPLine(CLine line, java.awt.Graphics2D g2)Draws a PLine.static voiddrawPParaLine(CLine line, CPoint pt, java.awt.Graphics2D g2)Draws a parallel line to the given line through the specified point.static voiddrawSLine(CLine line, java.awt.Graphics2D g2)Draws an SLine.static voiddrawTCLine(CLine line, java.awt.Graphics2D g2)Draws a TCLine.static voiddrawTLine(CLine line, java.awt.Graphics2D g2)Draws a TLine.static voiddrawTPerpLine(CLine line, CPoint pt, java.awt.Graphics2D g2)Draws a perpendicular line to the given line through the specified point.static voiddrawXLine(double x0, double y0, double k, java.awt.Graphics2D g2)Draws a line given a point and a slope.CPointget_Lpt1(CPoint px)Returns the point on the line with the smallest x-index that is not the given point.CPointget_Lptv(CPoint px, double x, double y)Returns the point on the line that forms a vector with the given point and coordinates.static doublegetALineK(CLine ln1, CLine ln2, CLine ln3)Calculates the slope (k) for a line defined by three other lines.static doublegetALineK(CPoint p1, CPoint p2, CPoint p3, CPoint p4, CPoint p5, CPoint p6)Calculates the slope (k) for a line defined by six points.java.lang.StringgetAllPointName()Returns the names of all points on the line.CPointgetAPointBut(CPoint t)Returns a point on the line that is not the given point.Constraintgetcons(int i)Returns the constraint at the specified index.ConstraintgetconsByType(int t)Returns the first constraint of the specified type.java.lang.StringgetDescription()Returns the description of the line.java.lang.StringgetDiscription()Returns the description of the line.intgetExtent()Returns the extent of the line.CPointgetfirstPoint()Returns the first point on the line.doublegetK()Calculates the slope (k) of the line.CPoint[]getMaxMinPoint()Returns the maximum and minimum points of the line.CPoint[]getMaxMinPoint(boolean ckv)Returns the maximum and minimum points of the line, optionally considering visibility.CPointgetMaxXPoint()Returns the point on the line with the maximum x-coordinate.CPointgetPoint(int n)Returns the point at the specified index.intgetPtsSize()Returns the number of points in the line.CPointgetSecondPoint(CPoint t)Returns the second point on the line that is not the given point.java.lang.StringgetSimpleName()Returns the simple name of the line.CPoint[]getTowSideOfLine()Returns the two points on the line with the smallest and largest x-index.booleaninside(double x, double y)Checks if a point is inside the line segment.booleaninside(double x, double y, double eps)Checks if a point is inside the line segment within a given tolerance.static double[]Intersect(CLine line0, CLine line1)Calculates the intersection point of two lines.static double[]Intersect(CPoint p1, CPoint p2, CPoint p3, CPoint p4)Calculates the intersection point of two line segments.booleanisEqual(CPoint A, CPoint B)Checks if two points are equal.booleanisHorizonal()Checks if the line is horizontal.static booleanisPerp(CLine line0, CLine line1)Checks if two lines are perpendicular.booleanisTwoEndFreePoints()Checks if the line has two free points at its ends.booleanisVertical()Checks if the line is vertical.static booleanisVerticalSlop(double r)Checks if a slope is considered vertical.voidLoad(java.io.DataInputStream in, DrawProcess dp)Loads the line from a data input stream.static booleanmouse_on_line(double x, double y, double x1, double y1, double x2, double y2)Checks if the mouse is on the line.booleannearline(double x, double y)Checks if a point is near the line.voidpointonline(CPoint pt)Sets the location of the given point to be on this line.booleanpointOnLine(CPoint p)Checks if a point is on the line.booleanpointonMiddle(CPoint pt)Checks if the given point is on the middle of the line.booleansameLine(CLine line2)Checks if this line is the same as another line.booleansameLine(CPoint A, CPoint B)Checks if two points are on the same line.voidSave(java.io.DataOutputStream out)Saves the line to a data output stream.voidSavePS(java.io.FileOutputStream fp, int stype)Saves the line to a PostScript file.booleanselect(double x, double y)Selects the line if a point is near it.voidsetExtent(int n)Sets the extent of the line.java.lang.StringTypeString()Returns the type of the line as a string.-
Methods inherited from class wprover.CClass
copy, get_type, getColor, getColorIndex, getname, getPSLineString, hasNameSet, isdraw, saveSuper, saveSuperColor, setAttr, setAttrAux, setColor, setDash, setInFlashing, setWidth, stopFlash, toString, visible
-
-
-
-
Field Detail
-
LLine
public static final int LLine
- See Also:
- Constant Field Values
-
PLine
public static final int PLine
- See Also:
- Constant Field Values
-
TLine
public static final int TLine
- See Also:
- Constant Field Values
-
BLine
public static final int BLine
- See Also:
- Constant Field Values
-
CCLine
public static final int CCLine
- See Also:
- Constant Field Values
-
NTALine
public static final int NTALine
- See Also:
- Constant Field Values
-
ALine
public static final int ALine
- See Also:
- Constant Field Values
-
SALine
public static final int SALine
- See Also:
- Constant Field Values
-
ABLine
public static final int ABLine
- See Also:
- Constant Field Values
-
TCLine
public static final int TCLine
- See Also:
- Constant Field Values
-
ET_NORMAL
public static final int ET_NORMAL
- See Also:
- Constant Field Values
-
ET_EXTENSION
public static final int ET_EXTENSION
- See Also:
- Constant Field Values
-
ET_ENDLESS
public static final int ET_ENDLESS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CLine
public CLine(int type)
Constructs a CLine with a specified type.- Parameters:
type- the type of the line
-
CLine
public CLine(CPoint A, int type)
Constructs a CLine with a specified point and type.- Parameters:
A- the pointtype- the type of the line
-
CLine
public CLine(CPoint A, CPoint B, int Type)
Constructs a CLine with two points and a specified type.- Parameters:
A- the first pointB- the second pointType- the type of the line
-
CLine
public CLine(CPoint A, CPoint B)
Constructs a CLine with two points.- Parameters:
A- the first pointB- the second point
-
CLine
public CLine(CPoint A, CPoint B, java.lang.String color)
Constructs a CLine with two points and a specified color.- Parameters:
A- the first pointB- the second pointcolor- the color of the line
-
-
Method Detail
-
draw
public void draw(java.awt.Graphics2D g2, boolean selected)Draws the line on the given graphics context.- Parameters:
g2- the graphics contextselected- whether the line is selected
-
draw
public void draw(java.awt.Graphics2D g2)
Draws the line on the given graphics context.
-
TypeString
public java.lang.String TypeString()
Returns the type of the line as a string.- Specified by:
TypeStringin classCClass- Returns:
- the type of the line
-
getSimpleName
public java.lang.String getSimpleName()
Returns the simple name of the line.- Returns:
- the simple name of the line
-
getDescription
public java.lang.String getDescription()
Returns the description of the line.- Specified by:
getDescriptionin classCClass- Returns:
- the description of the line
-
setExtent
public void setExtent(int n)
Sets the extent of the line.- Parameters:
n- the extent to set
-
getExtent
public int getExtent()
Returns the extent of the line.- Returns:
- the extent of the line
-
drawALine
public static void drawALine(CLine line, java.awt.Graphics2D g2)
Draws an ALine.- Parameters:
line- the line to drawg2- the graphics context
-
drawABLine
public static void drawABLine(CLine line, java.awt.Graphics2D g2)
Draws an ABLine.- Parameters:
line- the line to drawg2- the graphics context
-
drawTCLine
public static void drawTCLine(CLine line, java.awt.Graphics2D g2)
Draws a TCLine.- Parameters:
line- the line to drawg2- the graphics context
-
drawBLine
public static void drawBLine(CLine line, java.awt.Graphics2D g2)
Draws a BLine.- Parameters:
line- the line to drawg2- the graphics context
-
drawCCLine
public static void drawCCLine(CLine line, java.awt.Graphics2D g2)
Draws a CCLine.- Parameters:
line- the line to drawg2- the graphics context
-
drawSLine
public static void drawSLine(CLine line, java.awt.Graphics2D g2)
Draws an SLine.- Parameters:
line- the line to drawg2- the graphics context
-
drawXLine
public static void drawXLine(double x0, double y0, double k, java.awt.Graphics2D g2)Draws a line given a point and a slope.- Parameters:
x0- the x-coordinate of the pointy0- the y-coordinate of the pointk- the slope of the lineg2- the graphics context
-
drawTLine
public static void drawTLine(CLine line, java.awt.Graphics2D g2)
Draws a TLine.- Parameters:
line- the line to drawg2- the graphics context
-
drawPLine
public static void drawPLine(CLine line, java.awt.Graphics2D g2)
Draws a PLine.- Parameters:
line- the line to drawg2- the graphics context
-
drawLLine
public static void drawLLine(CLine line, java.awt.Graphics2D g2)
Draws an LLine.- Parameters:
line- the line to drawg2- the graphics context
-
drawPParaLine
public static void drawPParaLine(CLine line, CPoint pt, java.awt.Graphics2D g2)
Draws a parallel line to the given line through the specified point.- Parameters:
line- the line to which the parallel line is drawnpt- the point through which the parallel line passesg2- the graphics context
-
drawTPerpLine
public static void drawTPerpLine(CLine line, CPoint pt, java.awt.Graphics2D g2)
Draws a perpendicular line to the given line through the specified point.- Parameters:
line- the line to which the perpendicular line is drawnpt- the point through which the perpendicular line passesg2- the graphics context
-
getAllPointName
public java.lang.String getAllPointName()
Returns the names of all points on the line.- Returns:
- a string containing the names of all points on the line
-
getSecondPoint
public CPoint getSecondPoint(CPoint t)
Returns the second point on the line that is not the given point.- Parameters:
t- the point to exclude- Returns:
- the second point on the line, or null if there is no such point
-
getfirstPoint
public CPoint getfirstPoint()
Returns the first point on the line.- Returns:
- the first point on the line, or null if there is no such point
-
getAPointBut
public CPoint getAPointBut(CPoint t)
Returns a point on the line that is not the given point.- Parameters:
t- the point to exclude- Returns:
- a point on the line that is not the given point, or null if there is no such point
-
getMaxXPoint
public CPoint getMaxXPoint()
Returns the point on the line with the maximum x-coordinate.- Returns:
- the point on the line with the maximum x-coordinate, or null if there is no such point
-
isTwoEndFreePoints
public boolean isTwoEndFreePoints()
Checks if the line has two free points at its ends.- Returns:
- true if the line has two free points at its ends, false otherwise
-
get_Lpt1
public CPoint get_Lpt1(CPoint px)
Returns the point on the line with the smallest x-index that is not the given point.- Parameters:
px- the point to exclude- Returns:
- the point on the line with the smallest x-index that is not the given point, or null if there is no such point
-
get_Lptv
public CPoint get_Lptv(CPoint px, double x, double y)
Returns the point on the line that forms a vector with the given point and coordinates.- Parameters:
px- the point to excludex- the x-coordinate of the vectory- the y-coordinate of the vector- Returns:
- the point on the line that forms a vector with the given point and coordinates, or null if there is no such point
-
getTowSideOfLine
public CPoint[] getTowSideOfLine()
Returns the two points on the line with the smallest and largest x-index.- Returns:
- an array containing the two points on the line with the smallest and largest x-index, or null if there are not enough points
-
getDiscription
public java.lang.String getDiscription()
Returns the description of the line.- Returns:
- the description of the line
-
getMaxMinPoint
public CPoint[] getMaxMinPoint()
Returns the maximum and minimum points of the line.- Returns:
- an array containing the maximum and minimum points, or null if there are less than 2 points
-
getMaxMinPoint
public CPoint[] getMaxMinPoint(boolean ckv)
Returns the maximum and minimum points of the line, optionally considering visibility.- Parameters:
ckv- whether to consider visibility of points- Returns:
- an array containing the maximum and minimum points, or null if there are less than 2 points
-
getcons
public Constraint getcons(int i)
Returns the constraint at the specified index.- Parameters:
i- the index of the constraint- Returns:
- the constraint at the specified index, or null if the index is out of bounds
-
getconsByType
public Constraint getconsByType(int t)
Returns the first constraint of the specified type.- Parameters:
t- the type of the constraint- Returns:
- the first constraint of the specified type, or null if no such constraint exists
-
containPTs
public boolean containPTs(CPoint p1, CPoint p2)
Checks if the line contains the specified points.- Parameters:
p1- the first pointp2- the second point- Returns:
- true if the line contains both points, false otherwise
-
containPT
public boolean containPT(CPoint p)
Checks if the line contains the specified point.- Parameters:
p- the point- Returns:
- true if the line contains the point, false otherwise
-
getPtsSize
public int getPtsSize()
Returns the number of points in the line.- Returns:
- the number of points in the line
-
getPoint
public CPoint getPoint(int n)
Returns the point at the specified index.- Parameters:
n- the index of the point- Returns:
- the point at the specified index, or null if the index is out of bounds
-
isVertical
public boolean isVertical()
Checks if the line is vertical.- Returns:
- true if the line is vertical, false otherwise
-
isHorizonal
public boolean isHorizonal()
Checks if the line is horizontal.- Returns:
- true if the line is horizontal, false otherwise
-
getK
public double getK()
Calculates the slope (k) of the line.- Returns:
- the slope of the line
-
getALineK
public static double getALineK(CLine ln1, CLine ln2, CLine ln3)
Calculates the slope (k) for a line defined by three other lines.- Parameters:
ln1- the first lineln2- the second lineln3- the third line- Returns:
- the calculated slope
-
getALineK
public static double getALineK(CPoint p1, CPoint p2, CPoint p3, CPoint p4, CPoint p5, CPoint p6)
Calculates the slope (k) for a line defined by six points.- Parameters:
p1- the first pointp2- the second pointp3- the third pointp4- the fourth pointp5- the fifth pointp6- the sixth point- Returns:
- the calculated slope
-
addApoint
public void addApoint(CPoint a)
Adds a point to the line.- Parameters:
a- the point to add
-
addconstraint
public void addconstraint(Constraint cs)
Adds a constraint to the line.- Parameters:
cs- the constraint to add
-
sameLine
public boolean sameLine(CPoint A, CPoint B)
Checks if two points are on the same line.- Parameters:
A- the first pointB- the second point- Returns:
- true if both points are on the same line, false otherwise
-
pointOnLine
public boolean pointOnLine(CPoint p)
Checks if a point is on the line.- Parameters:
p- the point to check- Returns:
- true if the point is on the line, false otherwise
-
isEqual
public boolean isEqual(CPoint A, CPoint B)
Checks if two points are equal.- Parameters:
A- the first pointB- the second point- Returns:
- true if both points are equal, false otherwise
-
mouse_on_line
public static boolean mouse_on_line(double x, double y, double x1, double y1, double x2, double y2)Checks if the mouse is on the line.- Parameters:
x- the x-coordinate of the mousey- the y-coordinate of the mousex1- the x-coordinate of the first point of the liney1- the y-coordinate of the first point of the linex2- the x-coordinate of the second point of the liney2- the y-coordinate of the second point of the line- Returns:
- true if the mouse is on the line, false otherwise
-
distanceToPoint
public static double distanceToPoint(CLine ln, double x, double y)
Calculates the distance from a point to a line.- Parameters:
ln- the linex- the x-coordinate of the pointy- the y-coordinate of the point- Returns:
- the distance from the point to the line
-
distanceToPoint
public static double distanceToPoint(double x1, double y1, double k, double x, double y)Calculates the distance from a point to a line given the slope.- Parameters:
x1- the x-coordinate of the first point of the liney1- the y-coordinate of the first point of the linek- the slope of the linex- the x-coordinate of the pointy- the y-coordinate of the point- Returns:
- the distance from the point to the line
-
inside
public boolean inside(double x, double y)Checks if a point is inside the line segment.- Parameters:
x- the x-coordinate of the pointy- the y-coordinate of the point- Returns:
- true if the point is inside the line segment, false otherwise
-
inside
public boolean inside(double x, double y, double eps)Checks if a point is inside the line segment within a given tolerance.- Parameters:
x- the x-coordinate of the pointy- the y-coordinate of the pointeps- the tolerance- Returns:
- true if the point is inside the line segment within the tolerance, false otherwise
-
nearline
public boolean nearline(double x, double y)Checks if a point is near the line.- Parameters:
x- the x-coordinate of the pointy- the y-coordinate of the point- Returns:
- true if the point is near the line, false otherwise
-
select
public boolean select(double x, double y)Selects the line if a point is near it.- Parameters:
x- the x-coordinate of the pointy- the y-coordinate of the point- Returns:
- true if the line is selected, false otherwise
-
distance
public double distance(double x, double y)Calculates the distance from a point to this line.- Parameters:
x- the x-coordinate of the pointy- the y-coordinate of the point- Returns:
- the distance from the point to this line
-
pointonMiddle
public boolean pointonMiddle(CPoint pt)
Checks if the given point is on the middle of the line.- Parameters:
pt- the point to check- Returns:
- true if the point is on the middle of the line, false otherwise
-
pointonline
public void pointonline(CPoint pt)
Sets the location of the given point to be on this line.- Parameters:
pt- the point to set on the line
-
commonPoint
public static CPoint[] commonPoint(CLine ln, Circle c)
Finds the common points between a line and a circle.- Parameters:
ln- the linec- the circle- Returns:
- an array of common points between the line and the circle
-
commonPoint
public static CPoint commonPoint(CLine line0, CLine line1)
Finds the common point between two lines.- Parameters:
line0- the first lineline1- the second line- Returns:
- the common point between the two lines, or null if there is no common point
-
sameLine
public boolean sameLine(CLine line2)
Checks if this line is the same as another line.- Parameters:
line2- the other line to compare- Returns:
- true if the lines are the same, false otherwise
-
Intersect
public static double[] Intersect(CPoint p1, CPoint p2, CPoint p3, CPoint p4)
Calculates the intersection point of two line segments.- Parameters:
p1- the first point of the first line segmentp2- the second point of the first line segmentp3- the first point of the second line segmentp4- the second point of the second line segment- Returns:
- an array containing the x and y coordinates of the intersection point, or null if there is no intersection
-
isVerticalSlop
public static boolean isVerticalSlop(double r)
Checks if a slope is considered vertical.- Parameters:
r- the slope to check- Returns:
- true if the slope is vertical, false otherwise
-
isPerp
public static boolean isPerp(CLine line0, CLine line1)
Checks if two lines are perpendicular.- Parameters:
line0- the first lineline1- the second line- Returns:
- true if the lines are perpendicular, false otherwise
-
Intersect
public static double[] Intersect(CLine line0, CLine line1)
Calculates the intersection point of two lines.- Parameters:
line0- the first lineline1- the second line- Returns:
- an array containing the x and y coordinates of the intersection point, or null if there is no intersection
-
SavePS
public void SavePS(java.io.FileOutputStream fp, int stype) throws java.io.IOExceptionSaves the line to a PostScript file.
-
Save
public void Save(java.io.DataOutputStream out) throws java.io.IOExceptionSaves the line to a data output stream.
-
Load
public void Load(java.io.DataInputStream in, DrawProcess dp) throws java.io.IOExceptionLoads the line from a data input stream.
-
-