|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectlineTool
public class lineTool
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 |
---|
private int startX
private int startY
public boolean dragged
private java.awt.image.BufferedImage curImage
private java.awt.image.BufferedImage backupImage
private java.awt.Stroke lineStroke
int prevX
int prevY
Constructor Detail |
---|
public lineTool()
Method Detail |
---|
public void clickAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
clickAction
in interface ourTool
mevt
- contains information about the mouse event including
x-coordinates and y-coordinates.theCanvas
- includes contents of bufferedImage object for current and
backup images.public void dragAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
dragAction
in interface ourTool
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.public void mouseReleaseAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
mouseReleaseAction
in interface ourTool
mevt
- is used to draw line.theCanvas
- is used to the current image of the line.public void drawLine(java.awt.event.MouseEvent mevt, java.awt.Graphics2D g2D, main_canvas theCanvas)
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.public void setLineStroke(int size)
size
- specifies the width of the line for basicStroke how the line
ends, hoe lines join together.getLineStroke()
public boolean getDragged()
setDragged(boolean)
public java.awt.Stroke getLineStroke()
setLineStroke(int)
public void setDragged(boolean a)
a
- boolean true to set dragged, false if notgetDragged()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |