Class Highway
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHighway(int start, int end, int position, boolean type) Constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic HighwaycreateHorizontal(int x, int y, int length) Static factory method creting horizontalHighwayusing point and length.static HighwaycreateVertical(int x, int y, int length) Static factory method creting vertivalHighwayusing point and length.booleanintgetEnd()Gets the end position.org.eclipse.draw2d.geometry.PointgetIntersection(Highway other) Gets the intersection point.intGets theyposition in case horizontal orxotherwiseintgetStart()Gets the start position.org.eclipse.draw2d.geometry.PointGets the start pointinthashCode()booleanWhether is horisontal highway?booleanisIntersect(Highway other) Checks, whether has crossing withotherhighway.booleanWhether is vertical highwaytoString()
-
Constructor Details
-
Highway
protected Highway(int start, int end, int position, boolean type) Constructor- Parameters:
start- the start position.xin case horizontal oryotherwiseend- the end position.xin case horizontal oryotherwiseposition- theyposition in case horizontal orxotherwisetype-true- horizontal,falsevertical
-
-
Method Details
-
createHorizontal
Static factory method creting horizontalHighwayusing point and length. UseInteger.MIN_VALUEandInteger.MAX_VALUEfoor creating unlimited end.Examples:
createHorizontal(-100, 100, 200):
line segment [point(-100, 100), point(100, 100)]
createHorizontal(Integer.MIN_VALUE, 100, 200-Integer.MIN_VALUE):
line segment [point(-INFINITY, 200), point(100, 200)]
createHorizontal(-200, 100, Integer.MAX_VALUE-(-200)):
line segment [point(-200, 100), point(INFINITY, 200)]
- Parameters:
x- - x coordinate of the pointy- - y coordinate of the pointlength- - length- Returns:
- horizontal
Highway
-
createVertical
Static factory method creting vertivalHighwayusing point and length. UseInteger.MIN_VALUEandInteger.MAX_VALUEfoor creating unlimited end.Examples:
createVertical(-100, 100, 200):
line segment [point(-100, 100), point(-100, 300)]
createVertical(100, Integer.MIN_VALUE, 200-Integer.MIN_VALUE):
line segment [point(100, -INFINITY), point(100, 200)]
createVertical(-200, -100, Integer.MAX_VALUE-(-100)):
line segment [point(-200, -100), point(-200, INFINITY)]
- Parameters:
x- - x coordinate of the pointy- - y coordinate of the pointlength- - length- Returns:
- horizontal
Highway
-
getStart
public int getStart()Gets the start position.xin case horizontal oryotherwise- Returns:
- the start position.
xin case horizontal oryotherwise
-
getEnd
public int getEnd()Gets the end position.xin case horizontal oryotherwise- Returns:
- the end position.
xin case horizontal oryotherwise
-
getPosition
public int getPosition()Gets theyposition in case horizontal orxotherwise- Returns:
- the
yposition in case horizontal orxotherwise
-
isHorizontal
public boolean isHorizontal()Whether is horisontal highway?- Returns:
- whether is horisontal highway?
-
isVertical
public boolean isVertical()Whether is vertical highway- Returns:
- whether is vertical highway
-
getStartPoint
public org.eclipse.draw2d.geometry.Point getStartPoint()Gets the start point- Returns:
- the start point
-
isIntersect
Checks, whether has crossing withotherhighway.- Returns:
- the start point
-
getIntersection
Gets the intersection point.NOTE: Invalid in case highways has not intersection. Call
isIntersect(Highway)before.- Parameters:
other- other hightway- Returns:
- the intersection point
-
hashCode
public int hashCode() -
equals
-
toString
-