Forms
Class MyCircle

java.lang.Object
  |
  +--Forms.Forms
        |
        +--Forms.MyCircle

public class MyCircle
extends Forms

This class construct a new circle.

Version:
1.0
Author:
Sebastien Baehni
See Also:
Forms

Field Summary
protected  int radius
          The radius of the circle.
protected  int xCenter
          The x coord of the center.
protected  int yCenter
          The y coord of the center.
 
Fields inherited from class Forms.Forms
rectangle
 
Constructor Summary
MyCircle(int xCenter, int yCenter, int radius)
          The constructor.
 
Method Summary
 void drawCircle(int[] pixels, int width, int height, Color color)
          This method draw a circle in a array of pixels.
 void drawCircleWithTexture(int[] pixels, int width, int height, Texture texture)
          We draw the circle with a texture.
 boolean isSelected(int x, int y)
          This method tell if the forms is selected or not with the specified point.
 void optimizeDrawing(AnimatedImage animatedImage)
          This method optimize the drawing of the circle on a animatedImage in drawing only the bounding rectangle of the circle.
 int radius()
          This method return the radius of the circle.
 void radius(int radius)
          This method assign the radius of the circle at a new value.
protected  int returnC(int var, int p, int q, int r)
          This method find the c value of the equation: (x-p)**2 + (var-q)**2 == r**2.
protected  int[] returnSolutions(int a, int b, int delta)
          This method returns the solutions of a second degree equation.
protected  int solveDelta(int a, int b, int c)
          This method solves the delta equation (bâ-4ac).
 void translate(int x, int y, int maxWidth, int maxHeight)
          Translation of the circle to a new point.
 int xCenter()
          This method return the x coordinate of the center of the circle.
 void xCenter(int xCenter)
          This method assign the x coordinate of the center to a new value.
 int yCenter()
          This method return the y coordinate of the center of the circle.
 void yCenter(int yCenter)
          This method assign the y coordinate of the center to a new value.
 
Methods inherited from class Forms.Forms
height, height, rectangle, width, width, xOrigin, xOrigin, yOrigin, yOrigin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

radius

protected int radius
The radius of the circle.

xCenter

protected int xCenter
The x coord of the center.

yCenter

protected int yCenter
The y coord of the center.
Constructor Detail

MyCircle

public MyCircle(int xCenter,
                int yCenter,
                int radius)
The constructor.
Parameters:
xCenter - The x coordinate of the center of the circle.
yCenter - The y coordinate of the center of the circle.
radius - The radius of the circle.
Method Detail

xCenter

public int xCenter()
This method return the x coordinate of the center of the circle.
Returns:
The x coordinate of the center of the circle.

xCenter

public void xCenter(int xCenter)
This method assign the x coordinate of the center to a new value.
Parameters:
xCenter - The new x coordinate for the center.

yCenter

public int yCenter()
This method return the y coordinate of the center of the circle.
Returns:
The y coordinate of the center of the circle.

yCenter

public void yCenter(int yCenter)
This method assign the y coordinate of the center to a new value.
Parameters:
yCenter - The new y coordinate for the center.

radius

public int radius()
This method return the radius of the circle.
Returns:
The radius of the circle.

radius

public void radius(int radius)
This method assign the radius of the circle at a new value.
Parameters:
radius - The new value for the radius.

drawCircle

public void drawCircle(int[] pixels,
                       int width,
                       int height,
                       Color color)
This method draw a circle in a array of pixels.
Parameters:
pixels - The array of pixels we want to draw the circle.
width - The width of the array of pixels.
height - The height of the array of pixels.
color - The color the circle is painted.

drawCircleWithTexture

public void drawCircleWithTexture(int[] pixels,
                                  int width,
                                  int height,
                                  Texture texture)
                           throws TextureError
We draw the circle with a texture.
Parameters:
pixels - The array of pixels we want to draw the circle.
width - The width of the array of pixels.
height - The height of the array of pixels.
texture - The texture for the circle.
Throws:
TextureError -  

optimizeDrawing

public void optimizeDrawing(AnimatedImage animatedImage)
This method optimize the drawing of the circle on a animatedImage in drawing only the bounding rectangle of the circle.
Parameters:
animatedImage - The animatedImage on which the circle must be drawn.

translate

public void translate(int x,
                      int y,
                      int maxWidth,
                      int maxHeight)
Translation of the circle to a new point.
Parameters:
x - The x coordinate the center of the circle must be translated.
y - The y coordinate the center of the circle must be translated.
maxWidth - The maximum width the circle must be translated. This prevent the circle from going out of the the animatedImage.
maxHeight - The maximum height the circle must be translated. This prevent the circle from going out of the the animatedImage.
Overrides:
translate in class Forms

isSelected

public boolean isSelected(int x,
                          int y)
This method tell if the forms is selected or not with the specified point.
Parameters:
x - The x coordinate of the point.
y - The y coordinate of the point.
Returns:
True if the point is in the forms false otherwise.
Overrides:
isSelected in class Forms

returnC

protected int returnC(int var,
                      int p,
                      int q,
                      int r)
This method find the c value of the equation: (x-p)**2 + (var-q)**2 == r**2.
Parameters:
var - The variable in the upper equation.
p - The x center coordinate of the circle.
q - The y center coordinate of the circle.
r - The radius of the circle.
Returns:
The C value of the equation.

solveDelta

protected int solveDelta(int a,
                         int b,
                         int c)
This method solves the delta equation (bâ-4ac).
Parameters:
a - The a in the upper equation.
b - The b in the upper equation.
c - The c in the upper equation.
Returns:
The result of the equation upper.

returnSolutions

protected int[] returnSolutions(int a,
                                int b,
                                int delta)
This method returns the solutions of a second degree equation.
Parameters:
a - The a value in a second degree equation.
b - The b value in a second degree equation.
delta - The delta value in a second degree equation. It can be found with the upper methods.
Returns:
The solutions of a second degree equation