|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectcurveTool
public class curveTool
This is a class for the curve tool which is located at row 6 column 2 of the drawing icon. It allows us to use the mouse to draw a line into a curve shape and we can also drag the mouse and move it around, changing the curve. The curve can also be any color chosen from the bottom of the TerpPaint. Also we can specify the thickness of the curve. 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 curve. |
int |
clicks
This is used as a flag, showing which state are you at. |
private java.awt.image.BufferedImage |
curImage
This is used to store the current Image that we have. |
private java.awt.Stroke |
curveStroke
This is used as the line attributes for the Graphics2D. |
private boolean |
dragged
This is a boolean used to indicate whether the mouse has been dragged or not. |
private int |
firstX
This is used to store the x coordinate of the place where the mouse is clicked. |
private int |
firstY
This is used to store the y coordinate of the place where the mouse is clicked. |
private java.awt.Graphics2D |
g2D
This is a 2D graphic which is used to draw the line. |
private int |
lineEndX
This is used to store the end of the line for the x coordinate. |
private int |
lineEndY
This is used to store the end of the line for the y coordinate. |
private int |
secondX
This is used as a backup for the integer firstX during state 2. |
private int |
secondY
This is used as a backup for the integer firstY during state 2. |
private int |
startX
This is used to store the starting location of the curve line for the x coordinate. |
private int |
startY
This is used to store the starting location of the curve line for the y coordinate. |
Constructor Summary | |
---|---|
curveTool()
Creates a curveTool and initializes the curveStroke to 1. |
Method Summary | |
---|---|
void |
clickAction(java.awt.event.MouseEvent mevt,
main_canvas theCanvas)
Allows the user to click on the cavas using the curveTool. |
void |
deSelect(main_canvas theCanvas)
Sets the width of the curved line and will draw the the curved line if the state is not state 1. |
void |
dragAction(java.awt.event.MouseEvent mevt,
main_canvas theCanvas)
Allows the user to drag the mouse using the curveTool. |
void |
drawCurve(java.awt.event.MouseEvent mevt,
java.awt.Graphics2D g2D,
main_canvas theCanvas)
Draws a curve once the mouse has been clicked more than once. |
void |
drawLine(java.awt.event.MouseEvent mevt,
java.awt.Graphics2D g2D,
main_canvas theCanvas)
Draws one straight line once the user clicks on the canvas. |
int |
getClicks()
Returns the number of clicks, between 1 and 3. |
java.awt.Stroke |
getCurveStroke()
Returns the curveStroke of the current curveTool. |
boolean |
getDragged()
This function returns the current state of the flag dragged. |
int |
getfirstX()
This function returns the value for firstX. |
int |
getfirstY()
This function returns the value for firstY. |
java.awt.Color |
getG2dColor()
Returns the Color of the Graphics2D, g2d. |
int |
getSecondX()
This function returns the value for secondX. |
int |
getSecondY()
This function returns the value for secondY. |
int |
getStartX()
This function returns the value for startX. |
int |
getStartY()
This function returns the value for startY. |
void |
mouseReleaseAction(java.awt.event.MouseEvent mevt,
main_canvas theCanvas)
Allows the user to release the mouse using curveTool. |
void |
setClicks(int i)
Sets the number of clicks, between 1 and 3. |
void |
setCurveStroke(int size)
Sets the width of the curveStroke as specified by the int, size, 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
private boolean dragged
private java.awt.image.BufferedImage curImage
private java.awt.image.BufferedImage backupImage
private java.awt.Stroke curveStroke
private int firstX
private int firstY
private int secondX
private int secondY
private int lineEndX
private int lineEndY
public int clicks
private java.awt.Graphics2D g2D
Constructor Detail |
---|
public curveTool()
Method Detail |
---|
public void clickAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
clickAction
in interface ourTool
mevt
- a MouseEvent object which is carried out when the mouse is clicked. It will
give a new x and y coordinate and with the start and end coordinate, this will create
a new curved line.theCanvas
- a main_canvas object which is the area where the graphic is drawn.public int getStartY()
public int getStartX()
public int getfirstX()
public int getfirstY()
public int getSecondX()
public int getSecondY()
public boolean getDragged()
public void dragAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
dragAction
in interface ourTool
mevt
- a MouseEvent object which is carried out when the mouse is dragged. It will
give a new x and y coordinate and with the start and end coordinate, this will create
a new curved line. Note: this action can only be invoked once the user clicks on the
cavas, and clickAction is called.theCanvas
- a main_canvas object which is the area where the graphic is drawn.public void mouseReleaseAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
mouseReleaseAction
in interface ourTool
mevt
- a MouseEvent object which is carried out when the mouse is released. It will
give a new x and y coordinate and with the start and end coordinate, this will create
a new curved line. Note: this action can only be invoked once the user clicks on the
cavas, and clickAction is called.theCanvas
- a main_canvas object which is the area where the graphic is drawn.public void drawCurve(java.awt.event.MouseEvent mevt, java.awt.Graphics2D g2D, main_canvas theCanvas)
mevt
- a MouseEvent object which is used to determine which mouse button is clicked.g2D
- a Graphic object which is used to set the color and draw the line.theCanvas
- a main_canvas object which is the area where the graphic is drawn.public void drawLine(java.awt.event.MouseEvent mevt, java.awt.Graphics2D g2D, main_canvas theCanvas)
mevt
- a MouseEvent object which is used to determine which mouse button is clicked.g2D
- a Graphic object which is used to set the color and draw the line.theCanvas
- a main_canvas object which is the area where the graphic is drawn.public void setCurveStroke(int size)
size
- an int value.getCurveStroke()
public java.awt.Stroke getCurveStroke()
setCurveStroke(int)
public void deSelect(main_canvas theCanvas)
theCanvas
- a main_canvas object which is the area where the graphic is drawn.public void setClicks(int i)
i
- an integer that represents the number of clicksgetClicks()
public int getClicks()
setClicks(int)
public java.awt.Color getG2dColor()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |