Class main_canvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by main_canvas
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class main_canvas
extends javax.swing.JPanel

The class main_canvas represents a blank rectangular area of the screen onto which the application can draw or from which the application can trap input events from the user. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 boolean brush
          Default brush false.
 java.awt.Font current_font
          Font object that represents a current font style.
 java.awt.Stroke current_stroke
          Stroke object that represents the current stroke.
 int currentLayer
          current layer.
 boolean curve
          Default curve false.
 boolean elipse
          Default elipse false.
 boolean eraser
          Default eraser false.
(package private)  java.awt.Graphics2D gd
          Graphics2D object which represents the canvas.
 boolean grayscale
          Color scale or gray scale.
 int heig
          height of canvas.
 javax.swing.JLayeredPane layeredPane
          JLayeredPane object.
 java.util.LinkedList layerList
          LinkedList object that contains the layers.
 java.awt.Color left_color
          Color object that represents left mouse click event color.
 boolean letter
          Default letter false.
 boolean line
          Default line false.
 java.util.LinkedList list
          LinkedList object that contains the LinkedLists of BufferedImages for layers separately.
 javax.swing.ImageIcon main_icon
          Shows all image icons on TerpPaint.
 java.awt.image.BufferedImage main_image
          BufferedImage object that represents main image.
 int max_list_len
          max_list_len that indicates the max list length.
 boolean medicine
          Default medicine false.
 java.util.Vector nameList
          Vector object holding the Layer names.
(package private) static double oldZoomFactor
          Sets oldZoomFactor default 1.0.
 boolean paint
          Default paint false.
 boolean pencil
          Default pencil false.
 ScrollablePicture picture
          Image that can be scrolled by setting either the horizontal scroll bar or the vertical scroll bar.
 javax.swing.JScrollPane pictureScrollPane
          Provides scrolling functionality for the image.
 java.util.Vector place_list
          Place[i] is the spot in the BufferedImage linked list for the ith layer.
 boolean polygon
          Default polygon false.
 java.awt.Color right_color
          Color object that represents right mouse click event color.
 boolean rounded_rectangle
          Default rouned_rectangle false.
 boolean select
          Default select false.
 boolean selectall
          Default selectall false.
 boolean spray
          Default spray false.
 boolean square
          Default square false.
(package private)  java.awt.geom.AffineTransform t
          AffineTransform object for various transformations.
 java.awt.image.BufferedImage temp_x
          BufferedImage object that is for temporary storage.
 int widt
          width of the canvas.
 boolean zoom
          Default zoom false.
 double zoomFactor
          Sets zoomFactor default 1.0.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
main_canvas()
          Starts loading the image icons.
main_canvas(int h, int w)
          main_canvas constructor that creates a canvas of the size according to params.
 
Method Summary
 void addLayer()
          This method adds a new layer.
 int canvasScale(int coord)
          This method returns the coordinate.
 void changeLayer(java.lang.String correct)
          This method changes to another layer.
 void clear()
          This method sets the main image with the default size and color.
 void drawIt(java.awt.Shape s)
          This method creates and draws the graphics and adds to the image list.
 void flattenLayer(javax.swing.JDialog window)
          This method flattens all layers into one.
 java.awt.image.BufferedImage getBufferedImage()
          Returns the main image.
 java.awt.image.BufferedImage getCopy(java.awt.image.BufferedImage in)
          Returns a copy of main image object.
 boolean getGrayscale()
          Returns the grayscale or colorscale There are no OS/Hardware dependencies and no variances.
 double getOldZoom()
          Returns the size of the old zoom factor.
 double getZoom()
          Returns the size of the zoom factor.
 void invertColors()
          This method inverts the colors for drawing with the graphics context.
 void itemStateChanged(java.awt.event.ItemEvent e)
          This method responds to checkbox events.
 boolean madeChanges()
          Returns true if any changes occur more than once; otherwise false.
static void main(java.lang.String[] s)
          Creates the main drawing frame.
 void moveBottom(int number)
          This method used to move a layer to the bottom of the layer stack.
 void moveDown(int number)
          This method used to move a layer down in the layer stack.
 void moveFront(int number)
          This method used to move a layer to the top of the layer stack.
 void moveUp(int number)
          This method used to move a layer up in the layer stack.
 void noChanges()
          This method sets linked list to size 0, so that undo and redo are disabled.
 void paint(java.awt.Graphics g)
          This method sets the main image scale and draw image if the main image is not null.
 boolean redo()
          This method repeats the last drawing action.
 void removeLayer(int index)
          This method removes a layer.
 void resetLayer()
          This method resets the layer.
 void resizeImage(int width, int height)
          This method resizes the image.
 void setBufferedImage(java.awt.image.BufferedImage in)
          This method sets the main image.
 void setFont(java.awt.Font f)
          This method sets a current font style.
 void setLeftColor(java.awt.Color in)
          This method sets the left mouse button color.
 void setOldZoom(double factor)
          This method sets the size of the old zoom factor.
 void setRightColor(java.awt.Color in)
          This method sets the right mouse button color.
 void setStroke(int in)
          This method sets the characteristics of the rectangle's border or the lines for any other shape.
 void setZoom(double factor)
          This method sets the zoomFactor.
 void sizeImage(int width, int height)
          This method resizes the image.
 void undo()
          This method cancels the last drawing action.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

layeredPane

public javax.swing.JLayeredPane layeredPane
JLayeredPane object.


max_list_len

public int max_list_len
max_list_len that indicates the max list length.


layerList

public java.util.LinkedList layerList
LinkedList object that contains the layers.


nameList

public java.util.Vector nameList
Vector object holding the Layer names.


currentLayer

public int currentLayer
current layer.


list

public java.util.LinkedList list
LinkedList object that contains the LinkedLists of BufferedImages for layers separately.


main_image

public java.awt.image.BufferedImage main_image
BufferedImage object that represents main image.


temp_x

public java.awt.image.BufferedImage temp_x
BufferedImage object that is for temporary storage.


left_color

public java.awt.Color left_color
Color object that represents left mouse click event color.


right_color

public java.awt.Color right_color
Color object that represents right mouse click event color.


grayscale

public boolean grayscale
Color scale or gray scale.


current_stroke

public java.awt.Stroke current_stroke
Stroke object that represents the current stroke.


current_font

public java.awt.Font current_font
Font object that represents a current font style.


place_list

public java.util.Vector place_list
Place[i] is the spot in the BufferedImage linked list for the ith layer.


line

public boolean line
Default line false. true when this tool is chosen.


curve

public boolean curve
Default curve false. true when this tool is chosen.


rounded_rectangle

public boolean rounded_rectangle
Default rouned_rectangle false. true when this tool is chosen.


square

public boolean square
Default square false. true when this tool is chosen.


polygon

public boolean polygon
Default polygon false. true when this tool is chosen.


elipse

public boolean elipse
Default elipse false. true when this tool is chosen.


selectall

public boolean selectall
Default selectall false. true when this tool is chosen.


eraser

public boolean eraser
Default eraser false. true when this tool is chosen.


paint

public boolean paint
Default paint false. true when this tool is chosen.


medicine

public boolean medicine
Default medicine false. true when this tool is chosen.


zoom

public boolean zoom
Default zoom false. true when this tool is chosen.


pencil

public boolean pencil
Default pencil false. true when this tool is chosen.


brush

public boolean brush
Default brush false. true when this tool is chosen.


spray

public boolean spray
Default spray false. true when this tool is chosen.


letter

public boolean letter
Default letter false. true when this tool is chosen.


select

public boolean select
Default select false. true when this tool is chosen.


zoomFactor

public double zoomFactor
Sets zoomFactor default 1.0.


oldZoomFactor

static double oldZoomFactor
Sets oldZoomFactor default 1.0.


pictureScrollPane

public javax.swing.JScrollPane pictureScrollPane
Provides scrolling functionality for the image. Scrollars are shown only if they are required.


picture

public ScrollablePicture picture
Image that can be scrolled by setting either the horizontal scroll bar or the vertical scroll bar.


main_icon

public javax.swing.ImageIcon main_icon
Shows all image icons on TerpPaint.


widt

public int widt
width of the canvas.


heig

public int heig
height of canvas.


gd

java.awt.Graphics2D gd
Graphics2D object which represents the canvas.


t

java.awt.geom.AffineTransform t
AffineTransform object for various transformations.

Constructor Detail

main_canvas

public main_canvas()
Starts loading the image icons. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.


main_canvas

public main_canvas(int h,
                   int w)
main_canvas constructor that creates a canvas of the size according to params.

Parameters:
w - width param
h - height param
Method Detail

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
This method responds to checkbox events. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
e - provides the functionalities of ItemEvent

madeChanges

public boolean madeChanges()
Returns true if any changes occur more than once; otherwise false. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Returns:
true if any changes occur more than once; otherwise false.

noChanges

public void noChanges()
This method sets linked list to size 0, so that undo and redo are disabled. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.


clear

public void clear()
This method sets the main image with the default size and color. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.


setStroke

public void setStroke(int in)
This method sets the characteristics of the rectangle's border or the lines for any other shape. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
in - the border size of the line.

setFont

public void setFont(java.awt.Font f)
This method sets a current font style. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Overrides:
setFont in class javax.swing.JComponent
Parameters:
f - contains the specified font, style and size.

drawIt

public void drawIt(java.awt.Shape s)
This method creates and draws the graphics and adds to the image list. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
s - specifies the bounding of the image to display.

resizeImage

public void resizeImage(int width,
                        int height)
This method resizes the image. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
width - a new width size of the image.
height - a new height size of the image.

sizeImage

public void sizeImage(int width,
                      int height)
This method resizes the image. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
width - new width
height - new height

setBufferedImage

public void setBufferedImage(java.awt.image.BufferedImage in)
This method sets the main image. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
in - contains information of buffered image.
See Also:
getBufferedImage()

getBufferedImage

public java.awt.image.BufferedImage getBufferedImage()
Returns the main image. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Returns:
the buffereImage object.
See Also:
setBufferedImage(java.awt.image.BufferedImage)

getCopy

public java.awt.image.BufferedImage getCopy(java.awt.image.BufferedImage in)
Returns a copy of main image object. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
in - contains information of buffered image.
Returns:
the copy of buffereImage object.

setLeftColor

public void setLeftColor(java.awt.Color in)
This method sets the left mouse button color. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
in - the color to be the left_color.

setRightColor

public void setRightColor(java.awt.Color in)
This method sets the right mouse button color. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
in - the color to be the right_color.

paint

public void paint(java.awt.Graphics g)
This method sets the main image scale and draw image if the main image is not null. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - supports Graphics2D object to provide the functionality of it.

undo

public void undo()
This method cancels the last drawing action. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.


redo

public boolean redo()
This method repeats the last drawing action. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Returns:
true if redo is performed, false if not performed

canvasScale

public int canvasScale(int coord)
This method returns the coordinate. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
coord - the scale of the coordinate.
Returns:
the integer coordinate.

setZoom

public void setZoom(double factor)
This method sets the zoomFactor. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
factor - the size of the zoom factor.
See Also:
getZoom()

setOldZoom

public void setOldZoom(double factor)
This method sets the size of the old zoom factor. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
factor - the size of the zoom to be the old zoom factor.
See Also:
getOldZoom()

getZoom

public double getZoom()
Returns the size of the zoom factor. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Returns:
the size of the zoom factor.
See Also:
setZoom(double)

getOldZoom

public double getOldZoom()
Returns the size of the old zoom factor. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Returns:
the size of the old zoom factor.
See Also:
setOldZoom(double)

getGrayscale

public boolean getGrayscale()
Returns the grayscale or colorscale There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Returns:
the size of the zoom factor.

invertColors

public void invertColors()
This method inverts the colors for drawing with the graphics context. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.


moveUp

public void moveUp(int number)
This method used to move a layer up in the layer stack.

Parameters:
number - an int to represent layer number to move

moveDown

public void moveDown(int number)
This method used to move a layer down in the layer stack.

Parameters:
number - an int to represent layer number to move

moveFront

public void moveFront(int number)
This method used to move a layer to the top of the layer stack.

Parameters:
number - an int to represent layer number to move

moveBottom

public void moveBottom(int number)
This method used to move a layer to the bottom of the layer stack.

Parameters:
number - an int to represent layer number to move

changeLayer

public void changeLayer(java.lang.String correct)
This method changes to another layer. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
correct - correct layer to be displayed

addLayer

public void addLayer()
This method adds a new layer. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.


resetLayer

public void resetLayer()
This method resets the layer. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.


removeLayer

public void removeLayer(int index)
This method removes a layer. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
index - index of the layer to be removed

flattenLayer

public void flattenLayer(javax.swing.JDialog window)
This method flattens all layers into one. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
window - Shows the progress while flattening

main

public static void main(java.lang.String[] s)
Creates the main drawing frame. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

Parameters:
s - the command line argument.