Class lineTool

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

public class lineTool
extends java.lang.Object
implements ourTool

The class lineTool represents the mouse events for drawing lines, setting the line stroke. The lineTool class includes methods for clicking, dragging and releasing the mouse, for drawing the lines, and for setting line stroke with basic stroke. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.


Field Summary
private  java.awt.image.BufferedImage backupImage
          BufferedImage object that represents the backup image.
private  java.awt.image.BufferedImage curImage
          BufferedImage object that represents the current image.
 boolean dragged
          The status of the drag event.
private  java.awt.Stroke lineStroke
          Stroke object that represents the the width of the line to be filled.
(package private)  int prevX
          Stores the previous x coord.
(package private)  int prevY
          Stores the previous y coord.
private  int startX
          The x-coordinate of the starting point of the line.
private  int startY
          The y-coordinate of the starting point of the line.
 
Constructor Summary
lineTool()
          Creates a lineTool and initializes the lineStroke to 1.f to represent a basic Stroke.
 
Method Summary
 void clickAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
          Allows the user to click on the canvas using the lineTool.
 void dragAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
          Allows the user to drag the mouse using the lineTool, once the mouse has been clicked and clickAction has been called.
 void drawLine(java.awt.event.MouseEvent mevt, java.awt.Graphics2D g2D, main_canvas theCanvas)
          Draws the line as specified by the parameters passed in.
 boolean getDragged()
          Returns a boolean reflecting the state of the flag, dragged.
 java.awt.Stroke getLineStroke()
          Returns the Stroke of the line.
 void mouseReleaseAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
          Allows the user to release the mouse and stop drawing the line, once the mouse has been clicked and clickAction has been called.
 void setDragged(boolean a)
          This is a mutator to set the state of variable 'dragged' to true or false.
 void setLineStroke(int size)
          Sets the size of the lineStroke as specified by the int passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startX

private int startX
The x-coordinate of the starting point of the line.


startY

private int startY
The y-coordinate of the starting point of the line.


dragged

public boolean dragged
The status of the drag event. Default false


curImage

private java.awt.image.BufferedImage curImage
BufferedImage object that represents the current image.


backupImage

private java.awt.image.BufferedImage backupImage
BufferedImage object that represents the backup image.


lineStroke

private java.awt.Stroke lineStroke
Stroke object that represents the the width of the line to be filled.


prevX

int prevX
Stores the previous x coord.


prevY

int prevY
Stores the previous y coord.

Constructor Detail

lineTool

public lineTool()
Creates a lineTool and initializes the lineStroke to 1.f to represent a basic Stroke. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Method Detail

clickAction

public void clickAction(java.awt.event.MouseEvent mevt,
                        main_canvas theCanvas)
Allows the user to click on the canvas using the lineTool. The parameters passed in are a MouseEvent, which holds the coordinates of where the mouse was clicked, and a main_canvas which holds the bufferedImage. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Specified by:
clickAction in interface ourTool
Parameters:
mevt - contains information about the mouse event including x-coordinates and y-coordinates.
theCanvas - includes contents of bufferedImage object for current and backup images.

dragAction

public void dragAction(java.awt.event.MouseEvent mevt,
                       main_canvas theCanvas)
Allows the user to drag the mouse using the lineTool, once the mouse has been clicked and clickAction has been called. The parameters passed in are a MouseEvent, which holds the coordinates of where the mouse was clicked, and a main_canvas which holds the bufferedImage. Sets the boolean dragged to true. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Specified by:
dragAction in interface ourTool
Parameters:
mevt - contains information of the mouse event including x-coordinates and y-coordinates.
theCanvas - provides the contents of the main canvas to draw the line.

mouseReleaseAction

public void mouseReleaseAction(java.awt.event.MouseEvent mevt,
                               main_canvas theCanvas)
Allows the user to release the mouse and stop drawing the line, once the mouse has been clicked and clickAction has been called. Sets the boolean dragged to false. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Specified by:
mouseReleaseAction in interface ourTool
Parameters:
mevt - is used to draw line.
theCanvas - is used to the current image of the line.

drawLine

public void drawLine(java.awt.event.MouseEvent mevt,
                     java.awt.Graphics2D g2D,
                     main_canvas theCanvas)
Draws the line as specified by the parameters passed in. The MouseEvent holds which button on the mouse was clicked on by the user and colors the line accordingly. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
mevt - contains the x-coordinate and y-coordinate of the end point.
g2D - sets the color of the line depending on the mouse button action. Sets the left color if left button event occurs, else right color. Also sets stroke.
theCanvas - contains contents of the main canvas.

setLineStroke

public void setLineStroke(int size)
Sets the size of the lineStroke as specified by the int passed in. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
size - specifies the width of the line for basicStroke how the line ends, hoe lines join together.
See Also:
getLineStroke()

getDragged

public boolean getDragged()
Returns a boolean reflecting the state of the flag, dragged.

Returns:
boolean, dragged
See Also:
setDragged(boolean)

getLineStroke

public java.awt.Stroke getLineStroke()
Returns the Stroke of the line.

Returns:
Stroke
See Also:
setLineStroke(int)

setDragged

public void setDragged(boolean a)
This is a mutator to set the state of variable 'dragged' to true or false.

Parameters:
a - boolean true to set dragged, false if not
See Also:
getDragged()