Class PaymentCanvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--PaymentCanvas

class PaymentCanvas
extends java.awt.Canvas
implements java.awt.event.MouseMotionListener

See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
(package private)  double apr
          variable to display the APR(Annual Percentage Rate) in the textfield
(package private)  java.awt.Graphics g
          The graphics context of the instantiating applet
(package private)  int height
          varianle determines the height of the drawing canvas
(package private)  java.awt.Image imageObject
          contstuctor to create an image variable to create an image on the applet panel
(package private)  java.awt.TextField interestPaid
          textfield for Interest paid during the period
(package private)  java.awt.TextField mon
          textfield for months
(package private)  double monthlyPayment
          variable to display the monthly payment
(package private)  java.awt.TextField monthPay
          textfield for Monthly payment
(package private)  int months
          variable to input the number of months the mortgage is taken
(package private)  java.awt.Checkbox paidInterest
          Checkbox to select the type of graph for interest paid
(package private)  java.awt.Checkbox paidPrincipal
          Checkbox to select the type of graph for Principal paid
(package private)  int principal
          variable to display the principal amount on the applet textfield
(package private)  java.awt.TextField principalPaid
          textfield for Principal paid
(package private)  java.awt.Checkbox principalUnpaid
          Checkbox to select the type of graph for unpaid principal
(package private)  java.awt.TextField unpaidPrincipal
          textfield for unpaid Principal amount
(package private)  int width
          variable determines the width of the drawing canvas
(package private)  int xborder
          variable representing the x coordinate of the graph canvas
(package private)  double xincr
          variable to increment the loop value to draw the graph according to value changes
(package private)  int yborder
          variable representing the y coordinate of the graph canvas
(package private)  int years
          variable to display the number of years on the applet textfield
 
Fields inherited from class java.awt.Canvas
base, graphicsConfig, nameCounter, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
(package private) PaymentCanvas()
           
 
Method Summary
(package private)  void draw()
           
(package private)  double interestPaid(int i)
          function to calculate the value of the interest paid to the period
 void mouseDragged(java.awt.event.MouseEvent e)
          This method is defined for the sake of convinience Basically this function is called when the mouse is moved by pressing left mouse button
 void mouseMoved(java.awt.event.MouseEvent e)
          This method is called when the mouse is moved over the graph panel this class implements MouseMotionListener, an abstract class
(package private)  double paidPrincipal(int i)
          function to calculate the value of the paid principal to the period
 void paint(java.awt.Graphics g)
          Paint method to paint the points again when the values are changed by the user
(package private)  void setParameters(java.awt.TextField loanAmount, java.awt.TextField numberYears, java.awt.TextField annualRate)
          function to set the parameters to their corresponding calculated values.
(package private)  void setup(java.awt.TextField unpaidPrincipal, java.awt.TextField principalPaid, java.awt.TextField interestPaid, java.awt.TextField monthPay, java.awt.TextField mon, java.awt.Checkbox paidPrincipal, java.awt.Checkbox paidInterest, java.awt.Checkbox principalUnpaid)
          function to set the self-referenced values of the textfields and the checkboxes on the applet panel.
(package private)  double totalPaid(int i)
          function to calculate the value of the total amount paid during the period the loan is borrowed
(package private)  int transform(double y, double top)
          function to transform the obtained calculated values into the data points on the graph
(package private)  double unpaidPrincipal(int i)
          function to calculate the value of the unpaid principle of the loan amount
 
Methods inherited from class java.awt.Canvas
, addNotify, constructComponentName, postsOldMouseEvents
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getIntrinsicCursor, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, initIDs, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, printHeavyweightComponents, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, readObject, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

imageObject

java.awt.Image imageObject
contstuctor to create an image variable to create an image on the applet panel

g

java.awt.Graphics g
The graphics context of the instantiating applet

principal

int principal
variable to display the principal amount on the applet textfield

years

int years
variable to display the number of years on the applet textfield

xborder

int xborder
variable representing the x coordinate of the graph canvas

yborder

int yborder
variable representing the y coordinate of the graph canvas

width

int width
variable determines the width of the drawing canvas

height

int height
varianle determines the height of the drawing canvas

months

int months
variable to input the number of months the mortgage is taken

xincr

double xincr
variable to increment the loop value to draw the graph according to value changes

monthlyPayment

double monthlyPayment
variable to display the monthly payment

apr

double apr
variable to display the APR(Annual Percentage Rate) in the textfield

unpaidPrincipal

java.awt.TextField unpaidPrincipal
textfield for unpaid Principal amount

principalPaid

java.awt.TextField principalPaid
textfield for Principal paid

interestPaid

java.awt.TextField interestPaid
textfield for Interest paid during the period

monthPay

java.awt.TextField monthPay
textfield for Monthly payment

mon

java.awt.TextField mon
textfield for months

paidPrincipal

java.awt.Checkbox paidPrincipal
Checkbox to select the type of graph for Principal paid

paidInterest

java.awt.Checkbox paidInterest
Checkbox to select the type of graph for interest paid

principalUnpaid

java.awt.Checkbox principalUnpaid
Checkbox to select the type of graph for unpaid principal
Constructor Detail

PaymentCanvas

PaymentCanvas()
Method Detail

setup

void setup(java.awt.TextField unpaidPrincipal,
           java.awt.TextField principalPaid,
           java.awt.TextField interestPaid,
           java.awt.TextField monthPay,
           java.awt.TextField mon,
           java.awt.Checkbox paidPrincipal,
           java.awt.Checkbox paidInterest,
           java.awt.Checkbox principalUnpaid)
function to set the self-referenced values of the textfields and the checkboxes on the applet panel.
Parameters:
unpaidPrincipal - variable to display the unpaid principal amount
principalPaid - variable to display the paid principal amount
interestPaid - variable to display the interest paid to the date
monthPay - non-editable textfield variable to display the monthly payment
mon - non-editable textfield variable to display the number of months
paidPrincipal - checkbox variable to see the graph of principal paid during the period
paidInterest - checkbox variable to see the graph of interest paid during the period
principalUnpaid - checkbox variable to see the graph of unpaid principal during the period

setParameters

void setParameters(java.awt.TextField loanAmount,
                   java.awt.TextField numberYears,
                   java.awt.TextField annualRate)
function to set the parameters to their corresponding calculated values. This function first checks the input and convert it into specified format then catches the throwed exception and do the following action.
Parameters:
loanAmount - textfield to input the loan amount borrowed
numberYears - textfield to input the number of years for which the loan is borrowed
annualRate - textfield to input the annual percentage rate of the loan borrowed

unpaidPrincipal

double unpaidPrincipal(int i)
function to calculate the value of the unpaid principle of the loan amount

paidPrincipal

double paidPrincipal(int i)
function to calculate the value of the paid principal to the period

interestPaid

double interestPaid(int i)
function to calculate the value of the interest paid to the period

totalPaid

double totalPaid(int i)
function to calculate the value of the total amount paid during the period the loan is borrowed

transform

int transform(double y,
              double top)
function to transform the obtained calculated values into the data points on the graph

draw

void draw()

paint

public void paint(java.awt.Graphics g)
Paint method to paint the points again when the values are changed by the user
Overrides:
paint in class java.awt.Canvas
Parameters:
g - Graphics context of an applet

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
This method is defined for the sake of convinience Basically this function is called when the mouse is moved by pressing left mouse button
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e - MouseEvent object supplied by the system

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
This method is called when the mouse is moved over the graph panel this class implements MouseMotionListener, an abstract class
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
e - MouseEvent object supplied by the system