|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectpolygonTool
public class polygonTool
A polygonTool implements the operations performed by a polygon. It holds the fields int lastX, lastY, curX, curY, Graphics2D polyG2D, BufferedImage polyImage, backupImage, boolean dragged, Polygon, curPolygon, private int fillType. The variable dragged is set to true only when the method dragAction is called and is set to false otherwise. The fillType is assigned as follows: 1=set the color of the border. 2=set the color of the border and the fill. otherwise only set the color of the fill. It should work with all operating systems and hardware. There are no variances and no security constraints.
Field Summary | |
---|---|
(package private) java.awt.image.BufferedImage |
backupImage
a BufferedImage with width set to 200 and height set to 200. |
(package private) java.awt.Polygon |
curPolygon
used within methods clickAction, mouseReleaseAction and deSelect. |
(package private) int |
curX
used in clickAction and mouseReleaseAction. |
(package private) int |
curY
used in clickAction and mouseReleaseAction. |
boolean |
dragged
initialized to false, but set to true when dragAction is called. |
private int |
fillType
Initialized to 1 as default. |
(package private) int |
lastX
used in clickAction and mouseReleaseAction. |
(package private) int |
lastY
used in clickAction and mouseReleaseAction. |
(package private) java.awt.Graphics2D |
polyG2D
used to create a polygon. |
(package private) java.awt.image.BufferedImage |
polyImage
a BufferedImage with width set to 200 and height set to 200. |
Constructor Summary | |
---|---|
polygonTool()
Creates a polygonTool object. |
Method Summary | |
---|---|
void |
clickAction(java.awt.event.MouseEvent evt,
main_canvas theCanvas)
allows the user to click on the canvas, using the polygonTool. |
void |
deSelect(main_canvas theCanvas)
Allows for the deselecting of the polygon. |
void |
dragAction(java.awt.event.MouseEvent evt,
main_canvas theCanvas)
Allows the user to drag the mouse on the canvas, using the polygonTool. |
boolean |
getDragged()
Returns the current state of the flag dragged. |
int |
getFillType()
Returns the fill type, which should range from 1-3. |
java.awt.Color |
getG2dColor()
Returns a Color corresponding to the private Graphics2D. |
void |
mouseReleaseAction(java.awt.event.MouseEvent evt,
main_canvas theCanvas)
Allows the user to release the mouse, and the method dragAction was called (and therefore dragged was set to true), it sets the curX and curY and adds a point to curPolygon with those coordinates. |
void |
setFillType(int theFillType)
Sets fillType to the int passed in. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
int lastX
int lastY
int curX
int curY
java.awt.Graphics2D polyG2D
java.awt.image.BufferedImage polyImage
java.awt.image.BufferedImage backupImage
public boolean dragged
java.awt.Polygon curPolygon
private int fillType
Constructor Detail |
---|
polygonTool()
Method Detail |
---|
public void clickAction(java.awt.event.MouseEvent evt, main_canvas theCanvas)
clickAction
in interface ourTool
evt
- holds a MouseEvent to set the lastX and lastY fields.theCanvas
- holds a main_canvaspublic void dragAction(java.awt.event.MouseEvent evt, main_canvas theCanvas)
dragAction
in interface ourTool
evt
- holds a MouseEvent to determine which side was clicked.theCanvas
- holds a main_canvas to set the colors.public void mouseReleaseAction(java.awt.event.MouseEvent evt, main_canvas theCanvas)
mouseReleaseAction
in interface ourTool
evt
- holds a MouseEvent to determine which side was clicked.theCanvas
- determines which side to color.public void setFillType(int theFillType)
theFillType
- holds an integer corresponding to the values given above.getFillType()
public int getFillType()
setFillType(int)
public void deSelect(main_canvas theCanvas)
theCanvas
- holds a main_canvas used to set the colors.public boolean getDragged()
public java.awt.Color getG2dColor()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |