Package org.gephi.graph.api
Class Rect2D
- java.lang.Object
-
- org.gephi.graph.api.Rect2D
-
public class Rect2D extends Object
Represents a 2D axis-aligned immutable rectangle.- Author:
- Eduardo Ramos
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float[]center()Return the rectangle's center, as an array where the first element is the x coordinate and the second element is the y coordinate.booleancontains(float minX, float minY, float maxX, float maxY)Returns true if this rectangle contains the given rectangle.booleancontains(Rect2D rect)Returns true if this rectangle contains the given rectangle.booleanequals(Object obj)inthashCode()floatheight()Return the rectangle's height.booleanintersects(float minX, float minY, float maxX, float maxY)Returns true if this rectangle intersects the given rectangle.booleanintersects(Rect2D rect)Returns true if this rectangle intersects the given rectangle.floatradius()Return the rectangle's radius.StringtoString()floatwidth()Return the rectangle's width.
-
-
-
Constructor Detail
-
Rect2D
public Rect2D(Rect2D source)
Create a newRect2Das a copy of the givensource.- Parameters:
source- theRect2Dto copy from
-
Rect2D
public Rect2D(float minX, float minY, float maxX, float maxY)Create a newRect2Dwith the given minimum and maximum corner coordinates.- Parameters:
minX- the x coordinate of the minimum cornerminY- the y coordinate of the minimum cornermaxX- the x coordinate of the maximum cornermaxY- the y coordinate of the maximum corner
-
-
Method Detail
-
width
public float width()
Return the rectangle's width.- Returns:
- the rectangle's width
-
height
public float height()
Return the rectangle's height.- Returns:
- the rectangle's height
-
center
public float[] center()
Return the rectangle's center, as an array where the first element is the x coordinate and the second element is the y coordinate.- Returns:
- the rectangle's center
-
radius
public float radius()
Return the rectangle's radius.- Returns:
- the rectangle's radius
-
contains
public boolean contains(Rect2D rect)
Returns true if this rectangle contains the given rectangle.- Parameters:
rect- the rectangle to check- Returns:
- true if this rectangle contains, false otherwise
-
intersects
public boolean intersects(Rect2D rect)
Returns true if this rectangle intersects the given rectangle.- Parameters:
rect- the rectangle to check- Returns:
- true if this rectangle intersects, false otherwise
-
contains
public boolean contains(float minX, float minY, float maxX, float maxY)Returns true if this rectangle contains the given rectangle.- Parameters:
minX- the x coordinate of the minimum cornerminY- the y coordinate of the minimum cornermaxX- the x coordinate of the maximum cornermaxY- the y coordinate of the maximum corner- Returns:
- true if this rectangle contains, false otherwise
-
intersects
public boolean intersects(float minX, float minY, float maxX, float maxY)Returns true if this rectangle intersects the given rectangle.- Parameters:
minX- the x coordinate of the minimum cornerminY- the y coordinate of the minimum cornermaxX- the x coordinate of the maximum cornermaxY- the y coordinate of the maximum corner- Returns:
- true if this rectangle intersects, false otherwise
-
-