|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectroundedRectTool
public class roundedRectTool
roundedRectTool implements the interface ourTool. The tool is used to draw rounded rectangles, filled or unfilled. The mouse dragging determines the dimensions of the rounded rectangle to be drawn, when the mouse button is released. Possibility of using right or left button to draw rectangles. The rounded edge is an unadjustable 10. It should work with all operating systems and hardware. There are no variances and no security constraints.
Field Summary | |
---|---|
(package private) int |
arc_height
Holds the height of the arc, default set to 10. |
(package private) int |
arc_length
Holds the length of the arc, default set to 10. |
private java.awt.image.BufferedImage |
backupImage
Holds the current image and the saved backup image. |
private java.awt.image.BufferedImage |
curImage
Holds the current image and the saved backup image. |
private boolean |
dragged
Used as a flag detecting if the mouse was dragged. |
private int |
fillType
Holds the fill type ranging from 1-3. |
(package private) int |
prevX
Integer representing the previous x coordinate. |
(package private) int |
prevY
Integer representing the previous y coordinate. |
private int |
startX
Holds the starting x value. |
private int |
startY
Holds the starting y value. |
Constructor Summary | |
---|---|
roundedRectTool()
|
Method Summary | |
---|---|
void |
clickAction(java.awt.event.MouseEvent mevt,
main_canvas theCanvas)
This function initializes the starting point for a corner of the rounded rectangle to be drawn. |
void |
dragAction(java.awt.event.MouseEvent mevt,
main_canvas theCanvas)
Uses the dragging mouse position as the opposite corner of the rectangle, and repaints the rectangle to be painted as the mouse moves. |
void |
drawRoundRect(int x,
int y,
int width,
int height,
java.awt.event.MouseEvent mevt,
java.awt.Graphics2D g2D,
main_canvas theCanvas)
Updates the current display of canvas. |
boolean |
getDragged()
This function returns the state of the flag, dragged. |
int |
getFillType()
This function returns the fill type value (1-3). |
void |
mouseReleaseAction(java.awt.event.MouseEvent mevt,
main_canvas theCanvas)
This fuction draws the rounded rectangle onto the canvas upon release of the mouse button. |
void |
setFillType(int theFillType)
This funtion determines if the rounded rectangle is shaded or not. |
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 int fillType
final int arc_length
final int arc_height
private java.awt.image.BufferedImage curImage
private java.awt.image.BufferedImage backupImage
int prevX
int prevY
Constructor Detail |
---|
public roundedRectTool()
Method Detail |
---|
public void clickAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
clickAction
in interface ourTool
mevt
- MouseEvent of initial click, left or right buttontheCanvas
- the current main_canvaspublic void dragAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
dragAction
in interface ourTool
mevt
- MouseEvent of mouse draggingtheCanvas
- the current main_canvaspublic void mouseReleaseAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
mouseReleaseAction
in interface ourTool
mevt
- MouseEvent of releasing the button.theCanvas
- the current main_canvaspublic void setFillType(int theFillType)
theFillType
- 1: outline of left_color, 2: filled of right_color, 3: filled of left_colorgetFillType()
public int getFillType()
setFillType(int)
public void drawRoundRect(int x, int y, int width, int height, java.awt.event.MouseEvent mevt, java.awt.Graphics2D g2D, main_canvas theCanvas)
x
- the x-on-canvas coordinate of initial clicky
- the y-on-canvas coordinate of initial clickwidth
- the abs val of difference between the x and x of the current mouse positionheight
- the abs val of difference between the y and y of the current mouse positionmevt
- MouseEventg2D
- Graphics2D of displayed canvastheCanvas
- current main_canvaspublic boolean getDragged()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |