Package com.dkt.graphics.elements
Class GCircle
java.lang.Object
com.dkt.graphics.elements.GraphicE
com.dkt.graphics.elements.GFillableE
com.dkt.graphics.elements.GCircle
- All Implemented Interfaces:
Cloneable
- Author:
- Federico Vera <[email protected]>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
area()
Calculates the area of this circleclone()
boolean
contains
(int x, int y) Tells if a given point is contained in the circleboolean
Tells if a given circle is contained on this circle, that means that every point in the circle is contained in this one.boolean
Tells if a given line segment is contained in the circle, that means that both ends are contained in the circleboolean
Tells if a given point is contained in the circlevoid
draw
(Graphics2D g) Draws the component on the given graphicsboolean
int
Returns the radius of the circlegetShape()
This method should return aArea
that represents theGFillableE
.int
hashCode()
boolean
Tells if this circle intersects with another oneboolean
intersects
(GLine line) Tells if this circle intersects with a line.
Note: This will tell if the line intersects the circle NOT the line segment!!!void
move
(int x, int y) Moves the center of this circle to the given coordinatesdouble
Calculated the perimeter of this circlevoid
traslate
(int x, int y) Traslates this element on X and Yint
x()
Retrieves the X coordinate of the center of the circleint
y()
Retrieves the Y coordinate of the center of the circleMethods inherited from class com.dkt.graphics.elements.GFillableE
fill, getFillPaint, setFill, setFillPaint
-
Constructor Details
-
GCircle
Copy constructor- Parameters:
e
-GCircle
to copy- Throws:
IllegalArgumentException
- ife
isnull
-
GCircle
public GCircle(int x, int y, int r) - Parameters:
x
- X coordinate of the centery
- Y coordinate of the centerr
- radius
-
-
Method Details
-
x
public int x()Retrieves the X coordinate of the center of the circle- Returns:
- x coordinate of the center
-
y
public int y()Retrieves the Y coordinate of the center of the circle- Returns:
- y coordinate of the center
-
getRadius
public int getRadius()Returns the radius of the circle- Returns:
- radius
-
contains
Tells if a given circle is contained on this circle, that means that every point in the circle is contained in this one.- Parameters:
c
- the line to check- Returns:
true
if the circle is contained andfalse
otherwise- Throws:
IllegalArgumentException
- ifcircle
isnull
-
contains
Tells if a given line segment is contained in the circle, that means that both ends are contained in the circle- Parameters:
line
- the line to check- Returns:
true
if the line is contained andfalse
otherwise- Throws:
IllegalArgumentException
- ifline
isnull
-
contains
Tells if a given point is contained in the circle- Parameters:
point
- the point to check- Returns:
true
if the point is contained andfalse
otherwise- Throws:
IllegalArgumentException
- ifpoint
isnull
-
contains
public boolean contains(int x, int y) Tells if a given point is contained in the circle- Parameters:
x
- x coordinate of the pointy
- y coordinate of the point- Returns:
true
if the point is contained andfalse
otherwise
-
intersects
Tells if this circle intersects with another one- Parameters:
c
- The circle to check- Returns:
true
if the circles intersect andfalse
otherwise- Throws:
IllegalArgumentException
- ifcircle
isnull
-
intersects
Tells if this circle intersects with a line.
Note: This will tell if the line intersects the circle NOT the line segment!!!- Parameters:
line
- The line to check- Returns:
true
if they intersect andfalse
otherwise- Throws:
IllegalArgumentException
- ifline
isnull
-
area
public double area()Calculates the area of this circle- Returns:
- area
-
perimeter
public double perimeter()Calculated the perimeter of this circle- Returns:
- perimeter
-
draw
Description copied from class:GraphicE
Draws the component on the given graphics -
traslate
public void traslate(int x, int y) Description copied from class:GraphicE
Traslates this element on X and Y -
move
public void move(int x, int y) Moves the center of this circle to the given coordinates- Parameters:
x
- new x coordinatey
- new y coordinate
-
clone
- Specified by:
clone
in classGFillableE
-
hashCode
public int hashCode()- Overrides:
hashCode
in classGFillableE
-
equals
- Overrides:
equals
in classGFillableE
-
getShape
Description copied from class:GFillableE
This method should return aArea
that represents theGFillableE
. Since this is not always possible, and the implementation ofArea
isn't always easy, it should returnnull
otherwise.
InjDrawingLib
s implementation we use the default shapes for this. Note that this method is only called to create clips forGraphic
objects- Specified by:
getShape
in classGFillableE
- Returns:
- Shape
-