|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectmagicSelectTool
public class magicSelectTool
This magicSelectTool uses the ourTool interface. It magicSelects a region of connected color. It should work with all operating systems and hardware. There are no variances and no security constraints. uses its own inner class coords22.
Field Summary | |
---|---|
(package private) java.awt.image.BufferedImage |
backupImage
Holds the backupImage, magicSelectedImage, pastedImage. |
(package private) coords2 |
cur
The coordinates that is used to move around in the coord array of pixels and keep track which of the coords2 is not colored. |
(package private) java.awt.image.BufferedImage |
curImage
Holds the current image. |
java.awt.Polygon |
cursorPolygon
magicSelected free-hand area, closed polygon. |
int |
curX
x coordinate of current mouse position. |
int |
curY
y coordinate of current mouse position. |
boolean |
dragged
Used as a flag to determine if the mouse was dragged. |
boolean |
drawOpaque
Sets drawOpaque to true. |
(package private) static int |
eastBound
The column number of pixels. |
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. |
(package private) static int |
index
The current position in the array. |
boolean |
magicSelected
Used as a flag to determine if it was magicSelected. |
(package private) java.awt.image.BufferedImage |
magicSelectedImage
Holds the backupImage, magicSelectedImage, pastedImage. |
java.awt.BasicStroke |
magicSelectStroke
Holds the stroke that is magicSelected. |
java.awt.BasicStroke |
magicSelectStrokeW
Holds the stroke that is magicSelected in white. |
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. |
int |
onCanvasFlag
Determines if it is on the canvas. |
boolean |
pasted
Used as a flag to determine if it was pasted. |
(package private) java.awt.image.BufferedImage |
pastedImage
Holds the backupImage, magicSelectedImage, pastedImage. |
private int |
pasteX
Holds the pasted X. |
private int |
pasteY
Holds the pasted Y. |
(package private) coords2[] |
pixels
A coordinate array of the pixels used to keep track which part of the BufferedImage curImage is not colored. |
(package private) static int |
select
The new color to select the pixel with the colors wanted. |
(package private) static int |
size
The current size of the array. |
(package private) static int |
southBound
The row number of pixels. |
private int |
startX
x coord of initial click. |
private int |
startY
y coord of initial click. |
Constructor Summary | |
---|---|
magicSelectTool()
Creates a magicSelectTool and sets the Stroke. |
Method Summary | |
---|---|
void |
clear(main_canvas theCanvas)
Clears the magicSelected 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 magicSelecting, as specified by the coordinates passed in by MouseEvent. |
void |
cutBackground(java.awt.image.BufferedImage cuttingImg,
java.awt.Color rightColor)
RightColor is painted over magicSelected 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 magicSelect more according to the movement of the mouse. |
java.awt.image.BufferedImage |
getCopyImage(main_canvas theCanvas)
Copies the magicSelected portion of the canvas, but does not alter canvas. |
java.awt.image.BufferedImage |
getCutImage(main_canvas theCanvas)
Cuts magicSelected 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 magicSelected. |
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 magicSelected. |
void |
mouseReleaseAction(java.awt.event.MouseEvent mevt,
main_canvas theCanvas)
Allows the user to release the mouse and therefore stop magicSelecting. |
void |
myDrawImage(java.awt.Color rightColor)
To paste an image into the magicSelected 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 magicSelected area to be cut. |
void |
selectIt()
selectIt does the coloring. |
void |
setCursorPolygon()
setCursorPolygon determines the boundary of all the pixels. |
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
public int curX
public int curY
public boolean dragged
public boolean moved
private int fillType
java.awt.image.BufferedImage curImage
java.awt.image.BufferedImage backupImage
java.awt.image.BufferedImage magicSelectedImage
java.awt.image.BufferedImage pastedImage
java.awt.Graphics2D g2D
public boolean magicSelected
public boolean pasted
public boolean moving
public java.awt.BasicStroke magicSelectStroke
public java.awt.BasicStroke magicSelectStrokeW
private int pasteX
private int pasteY
public java.awt.Polygon cursorPolygon
public boolean drawOpaque
public int onCanvasFlag
static int select
static int index
static int size
static int eastBound
static int southBound
coords2[] pixels
coords2 cur
Constructor Detail |
---|
public magicSelectTool()
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 setCursorPolygon()
public void selectIt()
public 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 magicSelectedtheCanvas
- current main_canvasx
- an int representing the 'X' paste locationy
- an int representing the 'Y' paste locationpublic 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 magicSelected 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 magicSelected 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 |