|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectselectTool
public class selectTool
This selectTool uses the ourTool interface. It selects a free-hand region. 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
Holds the backupImage, selectedImage, pastedImage. |
(package private) java.awt.image.BufferedImage |
curImage
Holds the current image. |
java.awt.Polygon |
cursorPolygon
selected free-hand area, closed polygon. |
private int |
curX
x coordinate of current mouse position. |
private int |
curY
y coordinate of current mouse position. |
private boolean |
dragged
Used as a flag to determine if the mouse was dragged. |
boolean |
drawOpaque
Sets drawOpaque to true. |
private int |
endX
x coord of release of click. |
private int |
endY
y coord of release of click. |
private int |
fillType
Used to set the fill type, ranging from 1-3. |
(package private) java.awt.Graphics2D |
g2D
Holds the Graphics2D. |
private boolean |
moved
Used as a flag to determine if the mouse was moved. |
boolean |
moving
Used as a flag to determine if it was moving ======= private boolean pasted = false; /** Used as a flag to determine if it was moving. |
int |
onCanvasFlag
Determines if it is on the canvas. |
boolean |
pasted
Used as a flag to determine if it was pasted ======= private boolean selected = false; /** Used as a flag to determine if it was pasted. |
(package private) java.awt.image.BufferedImage |
pastedImage
Holds the backupImage, selectedImage, pastedImage. |
private int |
pasteX
Holds the pasted X. |
private int |
pasteY
Holds the pasted Y. |
boolean |
selected
Used as a flag to determine if it was selected. |
(package private) java.awt.image.BufferedImage |
selectedImage
Holds the backupImage, selectedImage, pastedImage. |
private java.awt.BasicStroke |
selectStroke
Holds the stroke that is selected ======= private boolean moving = false; /** Holds the stroke that is selected. |
private java.awt.BasicStroke |
selectStrokeW
Holds the stroke that is selected. |
private int |
startX
x coord of initial click. |
private int |
startY
y coord of initial click. |
Constructor Summary | |
---|---|
selectTool()
Creates a selectTool and sets the Stroke. |
Method Summary | |
---|---|
void |
clear(main_canvas theCanvas)
Clears the selected area on the main_canvas. |
void |
clickAction(java.awt.event.MouseEvent mevt,
main_canvas theCanvas)
Allows the user to click on the canvas, and begin selecting, as specified by the coordinates passed in by MouseEvent. |
void |
cutBackground(java.awt.image.BufferedImage cuttingImg,
java.awt.Color rightColor)
RightColor is painted over selected area to be cut. |
void |
deSelect(main_canvas theCanvas)
Resets canvas to backup image and resets all data members and flags to false. |
void |
dragAction(java.awt.event.MouseEvent mevt,
main_canvas theCanvas)
Allows the user to drag the mouse and select more according to the movement of the mouse. |
java.awt.image.BufferedImage |
getCopyImage(main_canvas theCanvas)
Copies the selected portion of the canvas, but does not alter canvas. |
java.awt.image.BufferedImage |
getCutImage(main_canvas theCanvas)
Cuts selected portion of image from the canvas. |
boolean |
getDragged()
Returns the current state of the flag dragged. |
java.awt.Color |
getG2dColor()
Returns the Color of the g2d. |
boolean |
getOpaque()
Returns true if it is set to opaque, false otherwise. |
boolean |
getPasted()
Returns the current state of the flag pasted. |
boolean |
getSelected()
Returns the current state of the flag selected. |
int |
getStartX()
This function returns the current X-position of subimage selected. |
int |
getStartY()
This function returns the current Y-position of subimage selected. |
boolean |
isSelected()
Returns the current state of the flag selected. |
void |
mouseReleaseAction(java.awt.event.MouseEvent mevt,
main_canvas theCanvas)
Allows the user to release the mouse and therefore stop selecting. |
void |
myDrawImage(java.awt.Color rightColor)
To paste an image into the selected rectangle but does not update canvas -- see setPastedImage 2 cases, if it is opaque or not. |
java.awt.image.BufferedImage |
pasteBackground(java.awt.image.BufferedImage cuttingImg,
java.awt.Color rightColor)
RightColor is painted over selected area to be cut. |
void |
setOpaque(boolean value)
Sets the opaque value to the boolean passed in. |
void |
setPastedImage(java.awt.image.BufferedImage theImage,
main_canvas theCanvas,
int x,
int y)
Pastes image to canvas at appropriate x and y. |
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 int endX
private int endY
private int curX
private int curY
private boolean dragged
private boolean moved
private int fillType
java.awt.image.BufferedImage curImage
java.awt.image.BufferedImage backupImage
java.awt.image.BufferedImage selectedImage
java.awt.image.BufferedImage pastedImage
java.awt.Graphics2D g2D
public boolean selected
public boolean pasted
public boolean moving
private java.awt.BasicStroke selectStroke
private java.awt.BasicStroke selectStrokeW
private int pasteX
private int pasteY
public java.awt.Polygon cursorPolygon
public boolean drawOpaque
public int onCanvasFlag
Constructor Detail |
---|
public selectTool()
Method Detail |
---|
public void clickAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
clickAction
in interface ourTool
mevt
- mouseEvent holds the coordinates where the mouse was clicked.theCanvas
- the current main_canvas, which holds the BufferedImage.public void dragAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
dragAction
in interface ourTool
mevt
- MouseEvent draggingtheCanvas
- the current main_canvaspublic void mouseReleaseAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
mouseReleaseAction
in interface ourTool
mevt
- MouseEvent of releasetheCanvas
- current main_canvaspublic java.awt.image.BufferedImage getCopyImage(main_canvas theCanvas)
theCanvas
- the current main_canvas
public java.awt.image.BufferedImage getCutImage(main_canvas theCanvas)
theCanvas
- current main_canvas
public void setPastedImage(java.awt.image.BufferedImage theImage, main_canvas theCanvas, int x, int y)
theImage
- BufferedImage - the portion of image selectedtheCanvas
- current main_canvasx
- an int representing the x coordinatey
- an int representing the y coordinatepublic void deSelect(main_canvas theCanvas)
theCanvas
- main_canvaspublic void setOpaque(boolean value)
value
- booleangetOpaque()
public void clear(main_canvas theCanvas)
theCanvas
- main_canvaspublic void myDrawImage(java.awt.Color rightColor)
rightColor
- Color, the right-click colorpublic void cutBackground(java.awt.image.BufferedImage cuttingImg, java.awt.Color rightColor)
cuttingImg
- BufferedImage of selected imagerightColor
- Color that would be painted if right click draw.public java.awt.image.BufferedImage pasteBackground(java.awt.image.BufferedImage cuttingImg, java.awt.Color rightColor)
cuttingImg
- BufferedImage of selected imagerightColor
- Color that would be painted if right click draw.
public java.awt.Color getG2dColor()
public boolean getDragged()
public boolean getSelected()
public int getStartX()
public int getStartY()
public boolean getPasted()
public boolean getOpaque()
setOpaque(boolean)
public boolean isSelected()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |