Class ellipseTool

java.lang.Object
  extended by ellipseTool
All Implemented Interfaces:
ourTool

public class ellipseTool
extends java.lang.Object
implements ourTool

This is a class for the ellipse tool which is located at row 8 column 1 of the drawing icon. It allows us to draw an ellipse in 3 ways, a left color border with white background, a left color border with left background or a left color border with right color background. It also allows us to draw the ellipse horizontally or vertically according to the mouse button clicked. It should work with all operating systems and hardware. There are no variances and no security constraints.


Field Summary
private  java.awt.image.BufferedImage backupImage
          This is used to store the back up image that we want and then, we are going to modify this as we continue the drawing of the ellipse.
private  java.awt.image.BufferedImage curImage
          Stores the current BufferedImage of the main_canvas.
private  boolean dragged
          Boolean which indicates whether the mouse has been dragged or not, once clicked.
private  int fillType
          Represents which of the 3 ways the ellipse will be drawn: a left color border with white background, left color border with left background or a left color border with right color background.
(package private)  int prevX
          This int holds the value of the Previous X coordinate.
(package private)  int prevY
          This int holds the value of the Previous Y coordinate.
 int startX
          Stores the starting x coordinate of the location where the mouse is clicked.
 int startY
          Stores the starting y coordinate of the location where the mouse is clicked.
 
Constructor Summary
ellipseTool()
           
 
Method Summary
 void clickAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
          Allows the user to click on the cavas using the ellipseTool.
 void dragAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
          Allows the user to draw an ellipse and drag it to the preferred size.
 void drawEllipse(java.awt.event.MouseEvent mevt, java.awt.Graphics2D g2D, main_canvas theCanvas)
          Performs the drawing of the ellipse.
 boolean getDragged()
          Returns a boolean reflecting the current state of the private data member dragged.
 int getFillType()
          Returns the fillType of the ellipseTool as an int.
 void mouseReleaseAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
          Allows the user to release the mouse, once it has been clicked by the user, to stop enlarging or shrinking the ellipse.
 void setFillType(int theFillType)
          Sets the fillType of ellipse, specified by the int passed in: a left color border with white background, a left color border with left background or a left color border with right color background.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startX

public int startX
Stores the starting x coordinate of the location where the mouse is clicked.


startY

public int startY
Stores the starting y coordinate of the location where the mouse is clicked.


dragged

private boolean dragged
Boolean which indicates whether the mouse has been dragged or not, once clicked.


fillType

private int fillType
Represents which of the 3 ways the ellipse will be drawn: a left color border with white background, left color border with left background or a left color border with right color background.


curImage

private java.awt.image.BufferedImage curImage
Stores the current BufferedImage of the main_canvas. We are going to have a back up image so we don't destroy the current image. We are just modifying the back up image.


backupImage

private java.awt.image.BufferedImage backupImage
This is used to store the back up image that we want and then, we are going to modify this as we continue the drawing of the ellipse.


prevX

int prevX
This int holds the value of the Previous X coordinate.


prevY

int prevY
This int holds the value of the Previous Y coordinate.

Constructor Detail

ellipseTool

public ellipseTool()
Method Detail

clickAction

public void clickAction(java.awt.event.MouseEvent mevt,
                        main_canvas theCanvas)
Allows the user to click on the cavas using the ellipseTool. It will start to draw an ellipse at the place where the mouse is clicked. It has 2 parameters which is a MouseEvent object and a main_canvas object. The MouseEvent object will determine which button is clicked and the main_canvas object is the place where the ellipse is drawn.

Specified by:
clickAction in interface ourTool
Parameters:
mevt - a MouseEvent object which is carried out when the mouse is clicked.
theCanvas - a main_canvas object which is the area where the graphic is drawn.

dragAction

public void dragAction(java.awt.event.MouseEvent mevt,
                       main_canvas theCanvas)
Allows the user to draw an ellipse and drag it to the preferred size. It will set the boolean dragged to true. It will draw horizontally or veritically according to which of the mouse button is clicked respectively. It has 2 parameters which is a MouseEvent object and a main_canvas object. The MouseEvent object will determine which button is clicked and the main_canvas object is the place where the ellipse is drawn.

Specified by:
dragAction in interface ourTool
Parameters:
mevt - This MouseEvent object determines which of the button is clicked and will draw the ellipse horizontally or vertically.
theCanvas - This is the area where the ellipse is drawn.

getDragged

public boolean getDragged()
Returns a boolean reflecting the current state of the private data member dragged.

Returns:
a boolean, dragged.

mouseReleaseAction

public void mouseReleaseAction(java.awt.event.MouseEvent mevt,
                               main_canvas theCanvas)
Allows the user to release the mouse, once it has been clicked by the user, to stop enlarging or shrinking the ellipse. It has 2 parameters which is a MouseEvent object and a main_canvas object. The MouseEvent object will determine which button is clicked and the main_canvas object is the place where the ellipse is drawn. Sets the boolean dragged to false.

Specified by:
mouseReleaseAction in interface ourTool
Parameters:
mevt - This MouseEvent object determines which of the button is clicked and will draw the ellipse horizontally or vertically.
theCanvas - This is the area where the ellipse is drawn.

setFillType

public void setFillType(int theFillType)
Sets the fillType of ellipse, specified by the int passed in: a left color border with white background, a left color border with left background or a left color border with right color background. It has an integer parameter which is used to set to the wanted type.

Parameters:
theFillType - an int value.
See Also:
getFillType()

getFillType

public int getFillType()
Returns the fillType of the ellipseTool as an int.

Returns:
int representing the fill type
See Also:
setFillType(int)

drawEllipse

public void drawEllipse(java.awt.event.MouseEvent mevt,
                        java.awt.Graphics2D g2D,
                        main_canvas theCanvas)
Performs the drawing of the ellipse. This method is called in either dragAction or mouseReleasedAction. It will draw the ellipse according to which button the mouse clicked and also, according to which 3 types of ellipses it wants. It has 3 parameters which a MouseEvent object used to determine which mouse button is clicked, a Graphics2D object to draw the ellipse and a main_canvas object which is the area where the ellipse is going to be drawn.

Parameters:
mevt - This MouseEvent object determines which of the button is clicked and will draw the ellipse horizontally or vertically.
g2D - a Graphic objct to draw the ellipse.
theCanvas - This is the area where the ellipse is drawn.