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
Constructors - 
Method Summary
Modifier and TypeMethodDescriptiondoublearea()Calculates the area of this circleclone()booleancontains(int x, int y) Tells if a given point is contained in the circlebooleanTells if a given circle is contained on this circle, that means that every point in the circle is contained in this one.booleanTells if a given line segment is contained in the circle, that means that both ends are contained in the circlebooleanTells if a given point is contained in the circlevoiddraw(Graphics2D g) Draws the component on the given graphicsbooleanintReturns the radius of the circlegetShape()This method should return aAreathat represents theGFillableE.inthashCode()booleanTells if this circle intersects with another onebooleanintersects(GLine line) Tells if this circle intersects with a line.
Note: This will tell if the line intersects the circle NOT the line segment!!!voidmove(int x, int y) Moves the center of this circle to the given coordinatesdoubleCalculated the perimeter of this circlevoidtraslate(int x, int y) Traslates this element on X and Yintx()Retrieves the X coordinate of the center of the circleinty()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-GCircleto copy- Throws:
 IllegalArgumentException- ifeisnull
 - 
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:
 trueif the circle is contained andfalseotherwise- Throws:
 IllegalArgumentException- ifcircleisnull
 - 
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:
 trueif the line is contained andfalseotherwise- Throws:
 IllegalArgumentException- iflineisnull
 - 
contains
Tells if a given point is contained in the circle- Parameters:
 point- the point to check- Returns:
 trueif the point is contained andfalseotherwise- Throws:
 IllegalArgumentException- ifpointisnull
 - 
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:
 trueif the point is contained andfalseotherwise
 - 
intersects
Tells if this circle intersects with another one- Parameters:
 c- The circle to check- Returns:
 trueif the circles intersect andfalseotherwise- Throws:
 IllegalArgumentException- ifcircleisnull
 - 
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:
 trueif they intersect andfalseotherwise- Throws:
 IllegalArgumentException- iflineisnull
 - 
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:GraphicEDraws the component on the given graphics - 
traslate
public void traslate(int x, int y) Description copied from class:GraphicETraslates 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:
 clonein classGFillableE
 - 
hashCode
public int hashCode()- Overrides:
 hashCodein classGFillableE
 - 
equals
- Overrides:
 equalsin classGFillableE
 - 
getShape
Description copied from class:GFillableEThis method should return aAreathat represents theGFillableE. Since this is not always possible, and the implementation ofAreaisn't always easy, it should returnnullotherwise.
InjDrawingLibs implementation we use the default shapes for this. Note that this method is only called to create clips forGraphicobjects- Specified by:
 getShapein classGFillableE- Returns:
 - Shape
 
 
 -