net.sf.latexdraw.glib.models.interfaces
Interface ILine

All Known Implementing Classes:
LLine

public interface ILine

Defines an interface that classes defining a line should implement.

This file is part of LaTeXDraw.
Copyright (c) 2005-2012 Arnaud BLOUIN

LaTeXDraw is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
LaTeXDraw is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

07/02/2009

Since:
3.0
Version:
3.0
Author:
Arnaud BLOUIN

Method Summary
 IPoint[] findPoints(double x, double y, double distance)
          Gets the points which are on the line and at the distance "distance" of the point "p" of the line.
 IPoint[] findPoints(IPoint p, double distance)
          Gets the points which are on the line and at the distance "distance" of the point "p" of the line.
 IPoint[] findPoints(java.awt.geom.Point2D p, double distance)
          Gets the points which are on the line and at the distance "distance" of the point "p" of the line.
 double getA()
           
 double getB()
           
 IPoint getBottomRightPoint()
           
 IPoint getIntersection(ILine l)
           
 IPoint getIntersectionSegment(ILine l)
           
 double getLineAngle()
          Computes the angle of the line.
 IPoint getMiddlePt()
           
 ILine getPerpendicularLine(IPoint pt)
          Creates the line which is perpendicular to the current line at the point pt.
 IPoint getPoint1()
           
 IPoint getPoint2()
           
 IPoint getTopLeftPoint()
           
 double getX1()
           
 double getX2()
           
 double getXWithEquation(double y)
          Gets the X-coordinate thanks to the equation of the line and the Y-coordinate of the point.
 double getY1()
           
 double getY2()
           
 double getYWithEquation(double x)
          Gets the Y-coordinate thanks to the equation of the line and the X-coordinate of the point.
 boolean isDot()
           
 boolean isHorizontalLine()
           
 boolean isVerticalLine()
           
 void setLine(double x1, double y1, double x2, double y2)
          Sets the position of the line.
 void setP1(double x, double y)
          Sets the coordinates of the first point.
 void setP1(IPoint pt)
          Sets the first point.
 void setP2(double x, double y)
          Sets the coordinates of the second point.
 void setP2(IPoint pt)
          Sets the second point.
 void setX1(double x1)
          Sets the x coordinate of the first point.
 void setX2(double x2)
          Sets the x coordinate of the second point.
 void setY1(double y1)
          Sets the y coordinate of the first point.
 void setY2(double y2)
          Sets the y coordinate of the second point.
 void updateAandB()
          Update the y-intercept b and slope a.
 

Method Detail

getLineAngle

double getLineAngle()
Computes the angle of the line.

Returns:
The angle of the line.
Since:
3.0

getX1

double getX1()
Returns:
The x coordinate of the first point.
Since:
3.0

getX2

double getX2()
Returns:
The x coordinate of the second point.
Since:
3.0

getY1

double getY1()
Returns:
The y coordinate of the first point.
Since:
3.0

getY2

double getY2()
Returns:
The y coordinate of the second point.
Since:
3.0

getPoint1

IPoint getPoint1()
Returns:
The first point.
Since:
3.0

getPoint2

IPoint getPoint2()
Returns:
The second point.
Since:
3.0

isVerticalLine

boolean isVerticalLine()
Returns:
True if the line is vertical.
Since:
3.0

isHorizontalLine

boolean isHorizontalLine()
Returns:
True if the line is horizontal.
Since:
3.0

isDot

boolean isDot()
Returns:
True if the two points of the line are equals meaning this is not a line but a 'dot'.
Since:
3.0

setLine

void setLine(double x1,
             double y1,
             double x2,
             double y2)
Sets the position of the line. Do nothing if one of the given parameter is not valid.

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.
Since:
3.0

setX1

void setX1(double x1)
Sets the x coordinate of the first point.

Parameters:
x1 - The new x coordinate of the first point.
Since:
3.0

setX2

void setX2(double x2)
Sets the x coordinate of the second point.

Parameters:
x2 - The new x coordinate of the second point.
Since:
3.0

setY1

void setY1(double y1)
Sets the y coordinate of the first point.

Parameters:
y1 - The new y coordinate of the first point.
Since:
3.0

setY2

void setY2(double y2)
Sets the y coordinate of the second point.

Parameters:
y2 - The new y coordinate of the second point.
Since:
3.0

setP1

void setP1(IPoint pt)
Sets the first point.

Parameters:
pt - The new first point.
Since:
3.0

setP2

void setP2(IPoint pt)
Sets the second point.

Parameters:
pt - The new second point.
Since:
3.0

setP1

void setP1(double x,
           double y)
Sets the coordinates of the first point.

Parameters:
x - The new x coordinate of the first point.
y - The new y coordinate of the first point.
Since:
3.0

setP2

void setP2(double x,
           double y)
Sets the coordinates of the second point.

Parameters:
x - The new x coordinate of the second point.
y - The new y coordinate of the second point.
Since:
3.0

getA

double getA()
Returns:
the a parameter of the line.

getB

double getB()
Returns:
the b parameter of the line.

getTopLeftPoint

IPoint getTopLeftPoint()
Returns:
The top left point of the line (may be not a point on the line).

getBottomRightPoint

IPoint getBottomRightPoint()
Returns:
The bottom right point of the line (may be not a point on the line).

getPerpendicularLine

ILine getPerpendicularLine(IPoint pt)
Creates the line which is perpendicular to the current line at the point pt.

Parameters:
pt - The point of crossing between the two lines.
Returns:
The perpendicular line.

getIntersection

IPoint getIntersection(ILine l)
Parameters:
l - The second lines
Returns:
The intersection between two lines. Null if the given is not valid or if both lines are parallels or both lines are identical.

getMiddlePt

IPoint getMiddlePt()
Returns:
The middle point of the line.

getIntersectionSegment

IPoint getIntersectionSegment(ILine l)
Parameters:
l - The second line.
Returns:
The point of the intersection between of the two segments.

findPoints

IPoint[] findPoints(double x,
                    double y,
                    double distance)
Gets the points which are on the line and at the distance "distance" of the point "p" of the line.

Parameters:
x - The x-coordinate of the point of reference.
y - The y-coordinate of the point of reference.
distance - The distance between p and the points we must find.
Returns:
The found points or null if a problem occurs.

findPoints

IPoint[] findPoints(IPoint p,
                    double distance)
Gets the points which are on the line and at the distance "distance" of the point "p" of the line.

Parameters:
p - The point of reference.
distance - The distance between p and the points we must find.
Returns:
The found points or null if a problem occurs.

findPoints

IPoint[] findPoints(java.awt.geom.Point2D p,
                    double distance)
Gets the points which are on the line and at the distance "distance" of the point "p" of the line.

Parameters:
p - The point of reference.
distance - The distance between p and the points we must find.
Returns:
The found points or null if a problem occurs.

getYWithEquation

double getYWithEquation(double x)
Gets the Y-coordinate thanks to the equation of the line and the X-coordinate of the point. The line must not by vertical.

Parameters:
x - The X-coordinate of the point.
Returns:
The Y-coordinate of the point or NaN if the line is vertical or if the two points of the line are equal, or if the given x is not valid.

getXWithEquation

double getXWithEquation(double y)
Gets the X-coordinate thanks to the equation of the line and the Y-coordinate of the point. The line must not by horizontal.

Parameters:
y - The Y-coordinate of the point.
Returns:
The X-coordinate of the point or NaN if the line is horizontal or if the two points of the line are equal, or if the given y is not valid.

updateAandB

void updateAandB()
Update the y-intercept b and slope a.