Class selectallTool

java.lang.Object
  extended by selectallTool
All Implemented Interfaces:
ourTool

public class selectallTool
extends java.lang.Object
implements ourTool

The class selectallTool uses the ourTool interface. It selects a rectangular region. See also selectTool It should work with all operating systems and hardware. There are no variances and no security constraints.


Field Summary
 java.lang.String action_name
          Action name.
(package private)  java.awt.image.BufferedImage backupImage
          Holds the current, backup, selected and pasted image.
(package private)  java.awt.image.BufferedImage curImage
          Holds the current, backup, selected and pasted image.
private  boolean dragged
          Used as a flag to determine if the mouse was dragged.
 boolean drawOpaque
          Flag used to determine if drawOpaque is on or not.
private  int endX
          Holds the starting X,Y and ending X,Y.
private  int endY
          Holds the starting X,Y and ending X,Y.
private  int fillType
          1 = border left_color, 2 = fill with right_color, 3 = solid left_color.
private  java.awt.Graphics2D g2D
          Holds a Graphics2D.
private  java.awt.Graphics2D g2D_temp
          Holds a Graphics2D.
private  boolean moved
          Flag to determine is it has moved.
private  boolean moving
          Flag to determine if it is moving.
 int onCanvasFlag
          Determines if it is on the canvas.
private  boolean pasted
          Flag to determine is it has been pasted.
(package private)  java.awt.image.BufferedImage pastedImage
          Holds the current, backup, selected and pasted image.
private  int pasteX
          x coord of where to be pasted.
private  int pasteY
          y of where to be pasted.
private  boolean selected
          Flag to determine is it has been selected.
(package private)  java.awt.image.BufferedImage selectedImage
          Holds the current, backup, selected and pasted image.
private  java.awt.BasicStroke selectStroke
          Holds the stroke that is selected.
private  java.awt.BasicStroke selectStrokeW
          Holds the stroke that is selected for the white part.
private  int startX
          Holds the starting X,Y and ending X,Y.
private  int startY
          Holds the starting X,Y and ending X,Y.
(package private)  java.awt.image.BufferedImage tempImage
          Holds the temp image.
 
Constructor Summary
selectallTool()
          Creates a selectallTool and sets the Stroke.
 
Method Summary
 void clear(main_canvas theCanvas)
          clears the selected portion of image.
 void clickAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
          Allows the user to click on the canvas and select all of the image.
 void deSelect(main_canvas theCanvas)
          Resets canvas to backup image and resets all data members and flags to original values.
 void dragAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
          Selects a rectangle according to movement of mouse, as specified by the coordinates of MouseEvent.
 java.awt.image.BufferedImage getCopyImage(main_canvas theCanvas)
          Returns the selected rectangle.
 java.awt.image.BufferedImage getCutImage(main_canvas theCanvas)
          Copies selected image to be cut, and removes.
 boolean getDragged()
          This function returns the current state of the flag dragged.
 java.awt.Color getG2dColor()
          This function returns the Color of the g2d.
 boolean getOpaque()
          This function returns true if it is set to opaque, false otherwise.
 boolean getPasted()
          This function returns the current state of the flag pasted.
 boolean getSelected()
          This function 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()
          This function the state of anything being selected.
 void mouseReleaseAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
          Allows the user to release the mouse and stop selecting.
 void myDrawImage(java.awt.Color rightColor)
          Pastes image into selected area but does not update canvas -- see setPastedImage.
 void selectAll(main_canvas theCanvas)
          Allows the user to select the entire main_canvas.
 void setOpaque(boolean value)
          sets the opaque flag.
 void setPastedImage(java.awt.image.BufferedImage theImage, main_canvas theCanvas, int x, int y)
          updates canvas with pasted image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startX

private int startX
Holds the starting X,Y and ending X,Y.


startY

private int startY
Holds the starting X,Y and ending X,Y.


endX

private int endX
Holds the starting X,Y and ending X,Y.


endY

private int endY
Holds the starting X,Y and ending X,Y.


dragged

private boolean dragged
Used as a flag to determine if the mouse was dragged.


moved

private boolean moved
Flag to determine is it has moved.


fillType

private int fillType
1 = border left_color, 2 = fill with right_color, 3 = solid left_color.


curImage

java.awt.image.BufferedImage curImage
Holds the current, backup, selected and pasted image.


backupImage

java.awt.image.BufferedImage backupImage
Holds the current, backup, selected and pasted image.


selectedImage

java.awt.image.BufferedImage selectedImage
Holds the current, backup, selected and pasted image.


pastedImage

java.awt.image.BufferedImage pastedImage
Holds the current, backup, selected and pasted image.


tempImage

java.awt.image.BufferedImage tempImage
Holds the temp image.


g2D

private java.awt.Graphics2D g2D
Holds a Graphics2D.


g2D_temp

private java.awt.Graphics2D g2D_temp
Holds a Graphics2D.


selected

private boolean selected
Flag to determine is it has been selected.


pasted

private boolean pasted
Flag to determine is it has been pasted.


moving

private boolean moving
Flag to determine if it is moving.


selectStroke

private java.awt.BasicStroke selectStroke
Holds the stroke that is selected.


selectStrokeW

private java.awt.BasicStroke selectStrokeW
Holds the stroke that is selected for the white part.


pasteX

private int pasteX
x coord of where to be pasted.


pasteY

private int pasteY
y of where to be pasted.


drawOpaque

public boolean drawOpaque
Flag used to determine if drawOpaque is on or not.


onCanvasFlag

public int onCanvasFlag
Determines if it is on the canvas.


action_name

public java.lang.String action_name
Action name.

Constructor Detail

selectallTool

public selectallTool()
Creates a selectallTool and sets the Stroke. It takes in no parameters or null arguments. It does not return anything. There are no algorithms of any kind and no variances and OS dependencies. There should not be any exceptions or security constraints.

Method Detail

clickAction

public void clickAction(java.awt.event.MouseEvent mevt,
                        main_canvas theCanvas)
Allows the user to click on the canvas and select all of the image. A click in valid x,y coordinates initializes everything. A click on invalid areas does nothing.

Specified by:
clickAction in interface ourTool
Parameters:
mevt - MosueEvent upon initial click
theCanvas - current main_canvas

dragAction

public void dragAction(java.awt.event.MouseEvent mevt,
                       main_canvas theCanvas)
Selects a rectangle according to movement of mouse, as specified by the coordinates of MouseEvent.

Specified by:
dragAction in interface ourTool
Parameters:
mevt - MosueEvent dragging mouse
theCanvas - the current main_canvas

mouseReleaseAction

public void mouseReleaseAction(java.awt.event.MouseEvent mevt,
                               main_canvas theCanvas)
Allows the user to release the mouse and stop selecting. Sets the flag dragged to false and slected to true.

Specified by:
mouseReleaseAction in interface ourTool
Parameters:
mevt - MouseEvent release of click
theCanvas - the current main_canvas

selectAll

public void selectAll(main_canvas theCanvas)
Allows the user to select the entire main_canvas. It draws a rectangle around the entire BufferedImage and sets the flag dragged to false, selected to true, and pasted to false. The starting coordinates of the selection are at 0, 0. The ending coordinates of the selection are at the width and height of the image.

Parameters:
theCanvas - main_canvas object

getCopyImage

public java.awt.image.BufferedImage getCopyImage(main_canvas theCanvas)
Returns the selected rectangle.

Parameters:
theCanvas - the current main_canvas
Returns:
BufferedImage of selected rectangle image

myDrawImage

public void myDrawImage(java.awt.Color rightColor)
Pastes image into selected area but does not update canvas -- see setPastedImage.

Parameters:
rightColor - Color of right-click

getCutImage

public java.awt.image.BufferedImage getCutImage(main_canvas theCanvas)
Copies selected image to be cut, and removes.

Parameters:
theCanvas - the current main_canvas
Returns:
BufferedImage of selected portion of canvas

setPastedImage

public void setPastedImage(java.awt.image.BufferedImage theImage,
                           main_canvas theCanvas,
                           int x,
                           int y)
updates canvas with pasted image. Preserves opaqueness.

Parameters:
theImage - BufferedImage to be pasted
theCanvas - the current main_canvas
x - an int representing the x coordinate
y - an int representing the y coordinate

getPasted

public boolean getPasted()
This function returns the current state of the flag pasted.

Returns:
boolean representing the flag pasted.

deSelect

public void deSelect(main_canvas theCanvas)
Resets canvas to backup image and resets all data members and flags to original values.

Parameters:
theCanvas - main_canvas

getSelected

public boolean getSelected()
This function returns the current state of the flag selected.

Returns:
boolean representing the state of the flag selected

getStartX

public int getStartX()
This function returns the current X-position of subimage selected.

Returns:
boolean representing the state of the flag selected

getStartY

public int getStartY()
This function returns the current Y-position of subimage selected.

Returns:
boolean representing the state of the flag selected

setOpaque

public void setOpaque(boolean value)
sets the opaque flag.

Parameters:
value - boolean opaqueness passed in
See Also:
getOpaque()

getOpaque

public boolean getOpaque()
This function returns true if it is set to opaque, false otherwise.

Returns:
boolean representing opaque
See Also:
setOpaque(boolean)

clear

public void clear(main_canvas theCanvas)
clears the selected portion of image.

Parameters:
theCanvas - the current main_canvas

getG2dColor

public java.awt.Color getG2dColor()
This function returns the Color of the g2d.

Returns:
Color representing that of g2D

getDragged

public boolean getDragged()
This function returns the current state of the flag dragged.

Returns:
boolean representing the flag dragged

isSelected

public boolean isSelected()
This function the state of anything being selected.

Returns:
boolean true if area is selected, false if not.