Class zoomTool

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

public class zoomTool
extends java.lang.Object
implements ourTool

The zoomTool is used to control and adjust the canvas's zooming size. It records the current canvas's zooming size and adjusts the size by listening for a MouseEvent. The state of zoomTool depends on the current canvas's zooming size. 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 current, backup, selected and pasted image.
(package private)  java.awt.image.BufferedImage curImage
          Holds the current, backup, selected and pasted image.
(package private)  boolean dragged
          Whether the user dragged or not.
 java.awt.Graphics2D g2D
          Holds a Graphics2D.
 java.awt.BasicStroke selectStroke
          Holds the stroke that is selected.
(package private)  double theZoom
          The current zooming size of the canvas.
(package private)  int x
          The x of a mouse click.
(package private)  int y
          The y of a mouse click.
 
Constructor Summary
zoomTool()
          Creates a zoomTool object and sets the zoom to 1.
 
Method Summary
 void clickAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
          Adjusts the canvas's zooming size by listening for the MouseEvent.
 void dragAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
          Allows the user to drag the mouse, but is unnecessary for zooming.
 int getZoom()
          Returns the value of theZoom, the state recorded by zoomTool, as an int.
 void mouseReleaseAction(java.awt.event.MouseEvent mevt, main_canvas theCanvas)
          Allows the user to release the mouse, but is unnecessary for zooming.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theZoom

double theZoom
The current zooming size of the canvas. Default value is 1.


x

int x
The x of a mouse click.


y

int y
The y of a mouse click.


dragged

boolean dragged
Whether the user dragged or not. if true the user has dragged and so done a box zoom.


backupImage

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


curImage

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


g2D

public java.awt.Graphics2D g2D
Holds a Graphics2D.


selectStroke

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

Constructor Detail

zoomTool

public zoomTool()
Creates a zoomTool object and sets the zoom to 1. 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)
Adjusts the canvas's zooming size by listening for the MouseEvent. If the left mouse button is clicked and the current canvas's zooming size is less than 8.0, the new zooming size will be the twice size of the current size. If the right mouse button is clicked and the current canvas' zooming size is greater than 1.0, the new zooming size will be the half size of the current size. In addition, the new zooming size will be recorded as the state of zoomTool.

Specified by:
clickAction in interface ourTool
Parameters:
mevt - the mouse event which will determine the zooming size.
theCanvas - the reference of main_canvas whose zooming size will be adjusted.

dragAction

public void dragAction(java.awt.event.MouseEvent mevt,
                       main_canvas theCanvas)
Allows the user to drag the mouse, but is unnecessary for zooming. It was defined because zoomTool implements OurTool.

Specified by:
dragAction in interface ourTool
Parameters:
mevt - mouse event.
theCanvas - the reference of main_canvas.

mouseReleaseAction

public void mouseReleaseAction(java.awt.event.MouseEvent mevt,
                               main_canvas theCanvas)
Allows the user to release the mouse, but is unnecessary for zooming. It was defined because zoomTool implements OurTool.

Specified by:
mouseReleaseAction in interface ourTool
Parameters:
mevt - mouse event
theCanvas - the reference of main_canvas

getZoom

public int getZoom()
Returns the value of theZoom, the state recorded by zoomTool, as an int. There are no OS dependencies and variances. No security constraints.

Returns:
theZoom