AppletInterface
Class MainFrame

java.lang.Object
  extended byjava.awt.Component
      extended byamber.server.component.ComponentHandler
          extended byamber.server.component.PanelHandler
              extended byamber.server.panel.BasePanel
                  extended byamber.server.panel.BaseFrame
                      extended byAppletInterface.MainFrame
All Implemented Interfaces:
java.awt.event.ActionListener, amber.server.application.ApplicationInterface, java.awt.event.ComponentListener, amber.awt.event.ComponentWindowListener, amber.server.panel.ContainerHandler, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.ItemListener, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, amber.utility.TimerInterface

public class MainFrame
extends amber.server.panel.BaseFrame
implements java.awt.event.ItemListener, java.awt.event.ActionListener, amber.utility.TimerInterface, amber.awt.event.ComponentWindowListener, java.awt.event.ComponentListener

Author:
student This class is the main engine behind the application. It is responsible for generation of stock values, updating information displayed, as well as buying and selling stocks.
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  UserAddress_Data address
           
private  amber.server.component.ButtonHandler btnAdd
           
private  amber.server.component.FloatButtonHandler btnBuy
           
private  amber.server.component.FloatButtonHandler btnLogout
           
private  amber.server.component.FloatButtonHandler btnMain
           
private  amber.server.component.ButtonHandler btnRemove
           
private  amber.server.component.FloatButtonHandler btnSell
           
private  amber.server.component.FloatButtonHandler btnUpdate
           
private  amber.server.component.FloatButtonHandler btnViewInfo
           
private  amber.server.component.ChoiceHandler chBuyStocks
           
private  amber.server.component.ChoiceHandler chSellStocks
           
private  amber.server.component.ChoiceHandler chShares
           
private  int currentCount
           
 int FRAMEHEIGHT
           
 int FRAMEWIDTH
           
private  amber.server.component.ImageHandler imgBanner
           
private  Stock_Data[] interested
           
private  float[] lastLines
           
private  amber.server.component.LabelHandler lblAccountBuy
           
private  amber.server.component.LabelHandler lblAccountSell
           
private  amber.server.component.LabelHandler lblBuy
           
private  amber.server.component.LabelHandler lblBuyInfo
           
private  amber.server.component.LabelHandler lblCps
           
private  amber.server.component.LabelHandler lblCpsDefinition
           
private  amber.server.component.LabelHandler lblCurrValueBuy
           
private  amber.server.component.LabelHandler lblCurrValueSell
           
private  amber.server.component.LabelHandler lblDividends
           
private  amber.server.component.LabelHandler lblHigh
           
private  amber.server.component.LabelHandler lblInfo
           
private  amber.server.component.LabelHandler lblLow
           
private  amber.server.component.LabelHandler lblMain
           
private  amber.server.component.LabelHandler lblNotes
           
private  amber.server.component.LabelHandler lblPeRatio
           
private  amber.server.component.LabelHandler lblPeRatioDefinition
           
private  amber.server.component.LabelHandler lblQtyBuy
           
private  amber.server.component.LabelHandler lblQtySell
           
private  amber.server.component.LabelHandler lblSell
           
private  amber.server.component.LabelHandler lblSellInfo
           
private  amber.server.component.LabelHandler lblStockCode
           
private  amber.server.component.LabelHandler lblStockName
           
private  amber.server.component.LabelHandler lblTcDefinition
           
private  amber.server.component.LabelHandler lblTotalBuy
           
private  amber.server.component.LabelHandler lblTotalSell
           
private  amber.server.component.LabelHandler lblTs
           
private  amber.server.component.LabelHandler lblYld
           
private  amber.server.component.LabelHandler lblYldDefinition
           
private  java.awt.Font level1
           
private  java.awt.Font level2
           
private  float[] lines
           
private  StockOwnership_Data[] ownedstocks
           
private  int PlotHeight
           
private  int PlotLeft
           
private  int PlotTop
           
private  int PlotWidth
           
private  amber.server.component.TimePlotHandler pltShares
           
private  amber.server.panel.GenericPanel pnlBuy
           
private  amber.server.panel.GenericPanel pnlGraph
           
private  amber.server.panel.GenericPanel pnlSell
           
private  java.awt.Color[] seriesColors
           
private  ServletConnection servletconn
           
private static int STABILITY_FACTOR
           
private  java.lang.String[] stockNames
           
private static double TAX_RATE
           
private  amber.utility.Timer timer
           
private  Stock_Data[] totalstocks
           
private  amber.server.component.TextFieldHandler txtQtyBuy
           
private  amber.server.component.TextFieldHandler txtQtySell
           
private  UserManager umanager
           
private  amber.server.component.LabelHandler untitledLabel
           
private  User_Data user
           
private  XmlGenerator xmlgenerator
           
private  XmlUnmarshal xmlunmarshal
           
 
Fields inherited from class amber.server.panel.BaseFrame
title
 
Fields inherited from class amber.server.panel.BasePanel
autoDoLayoutState, xOffset, yOffset
 
Fields inherited from class amber.server.component.PanelHandler
AddOperation, autoRedrawState, defaultSpecialKeyCodes, defaultSpecialModifiers, drawOperations, InsertOperation, PaintPanel, PanelNextAvailableCommand, postInPacketListeners, preInPacketListeners, RemoveAllOperations, RemoveOperation, ReplaceOperation, SetBorder, SetReDraw, SetSpecialKeys, specialKeyCodesCache, SpecialKeyEvent, specialKeyModifierCache
 
Fields inherited from class amber.server.component.ComponentHandler
actionCommand, active, ApplicationId, CancelReturn, dataEncoder, DefaultTimeout, enabledState, encoderBytes, id, InvalidId, MaximumId, NoReturn, OkCancelType, OkReturn, OkType, OkYesReturn, parentPage, responsePackets, timeoutValue, UnchangeableInvalidId, visibleState, YesNoCancelType, YesNoType, YesReturn
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface amber.server.panel.ContainerHandler
AddComponent, AutoDoLayout, ForceDoLayout, GetInsets, GetInsetsResponse, NextAvailableCommand, RemoveAllComponents, RemoveComponent, SetBounds
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MainFrame()
          This is the constructor for MainFrame.java
MainFrame(amber.server.application.ApplicationInterface appHandler)
          The initialising constructor.
MainFrame(int id, amber.server.application.ApplicationInterface appHandler)
          The initialising constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
private  void addComponents()
          This method is being used for adding the components to the frame and the 3 panels.
private  void addListeners()
          This method is being used for adding listeners to the components that are being used in this user interface.
 void calculateDividendYield(Stock_Data stock)
          This method is being used for calculating the dividend yield for a given stock.
 void calculatePERatio(Stock_Data stock)
          This method is being used for calculating the PERatio of the given stock.
 void calculateRatios()
          This method is being used for calling calculateRatio() for each stock.
 boolean canClose()
          This function determines if the panel can be closed.
 void componentHidden(java.awt.event.ComponentEvent e)
           
 void componentMoved(java.awt.event.ComponentEvent e)
           
 void componentResized(java.awt.event.ComponentEvent e)
           
 void componentShown(java.awt.event.ComponentEvent e)
           
private  void debugStocksOwned(User_Data user)
          This method is being used as a utility method for debugging purpose.
protected  void defineComponents()
          This function is called to define the components which are a part of this panel.
 void fillControls()
          This function would normally never need to be called, but is required to be defined as it is called internally.
 void generateStockValues()
          This method is being used for generating stock values at each timer event.
private  Stock_Data getStock(java.lang.String name)
          This method is being used as a utility method to get a specified stock given a stock name.
private  Stock_Data[] getStocks(java.lang.String[] names)
          This method is being used as a utility method to get the stocks defined by the names.
protected  StockTradingApplication getStockTradingApplication()
          This method is being used for getting the parent application.
private  boolean isNumber(java.lang.String s)
          This utility method is being used to check if the given string is an int or not.
 void itemStateChanged(java.awt.event.ItemEvent ie)
           
protected  void redrawCaptions()
          This function draws information on the captions for the graph on the remote client.
 void refresh()
          This method is being used for refreshing the user interface after updating user information.
 double round(double x, int dec)
          This method is being used as a utility method for rounding a given double value to the given number of decimal places.
 void saveData()
          This function is called to save any required information in the panel.
private  void setProperties()
          This method is being used for setting the properties of components being used in this frame.
 void shutDown()
           
 void timeEventOccurred()
           
 void updateBuyPanel()
          This method is being used for updating stock information in the buy panel (Top right of main frame).
 void updateBuyPanelLabels()
          This method is being used for updating only the labels in the buy panel (top right of the main frame).
private  void updateGraph()
          This method is being used for adding the updated stock values to the graph - TimePlotHandler.
 void updateSellPanel()
          This method is being used for updating stock information in the sell panel (bottom right of the main frame).
 void updateSellPanelLabels()
          Method: updateSellPanelLabels This method is being used for updating only the labels in the sell panel (bottom right of the main frame).
 void updateStockInfo()
          This method is being used for updating the displayed stock information in the centre og the main frame.
 void windowActivated(amber.awt.event.ComponentWindowEvent e)
           
 void windowClosed(amber.awt.event.ComponentWindowEvent e)
           
 void windowClosing(amber.awt.event.ComponentWindowEvent e)
           
 void windowDeactivated(amber.awt.event.ComponentWindowEvent e)
           
 void windowDeiconified(amber.awt.event.ComponentWindowEvent e)
           
 void windowIconified(amber.awt.event.ComponentWindowEvent e)
           
 void windowOpened(amber.awt.event.ComponentWindowEvent e)
           
 
Methods inherited from class amber.server.panel.BaseFrame
getPanelType, getTitle, isVisible, setActive, setBounds, setBounds, setInternalBounds, setInternalBounds, setInternalLocation, setInternalLocation, setInternalSize, setInternalSize, setLocation, setLocation, setSize, setSize, setTitle, setVisible, toBack, toFront
 
Methods inherited from class amber.server.panel.BasePanel
add, addComponent, addInPostPacketListener, addInPrePacketListener, buildComponent, buildComponent, doPanelLayout, fireInPostPacketPerformed, fireInPrePacketPerformed, forwardPacket, getAutoDoLayout, getComponents, getComponentStructure, getInsets, getPanelComponent, getPanelComponentAt, getPanelComponentAt, getPanelComponentAt, getPanelComponentAt, getPanelGroup, isMyId, isSelected, matchComponentToControl, matchIdToControl, processCurrentPacket, recreatePanel, remove, removeComponent, removeInPostPacketListener, removeInPrePacketListener, setAutoDoLayout, setBounds, setBounds, setComponentBaseOffset, setLocation, setLocation, setPanelGroup, setPanelLocation, setPanelLocation, setSelected, setSelectedInternal, setSize, setSize, setUpComponent
 
Methods inherited from class amber.server.component.PanelHandler
addComponent, addComponent, addDraw3DRect, addDrawArc, addDrawImage, addDrawImage, addDrawImage, addDrawImage, addDrawLine, addDrawOval, addDrawPolygon, addDrawPolyline, addDrawRect, addDrawRoundRect, addDrawString, addDrawString, addFill3DRect, addFillArc, addFillOval, addFillPolygon, addFillRect, addFillRoundRect, addOperation, addSetClip, addSetColour, addSetFont, addSetPaintMode, addSetXORMode, addSpecialKeyListener, disableSpecialKeyEvents, enableSpecialKeyEvents, getDrawOperations, getSpecialKeyCodes, handlePacket, handleToIndex, insertDraw3DRect, insertDrawArc, insertDrawImage, insertDrawImage, insertDrawImage, insertDrawImage, insertDrawLine, insertDrawPolygon, insertDrawPolyline, insertDrawRect, insertDrawRoundRect, insertDrawString, insertDrawString, insertFill3DRect, insertFill3DRect, insertFillArc, insertFillOval, insertFillPolygon, insertFillRect, insertFillRoundRect, insertOperation, insertSetClip, insertSetColour, insertSetFont, insertSetPaintMode, insertSetXORMode, performSetBounds, performSetLocation, performSetSize, processEvent, processSpecialKeyEvent, removeAllComponents, removeAllDrawOperations, removeDrawOperation, removeSpecialKeyListener, repaintPanel, replaceDraw3DRect, replaceDrawArc, replaceDrawImage, replaceDrawImage, replaceDrawImage, replaceDrawImage, replaceDrawLine, replaceDrawPolygon, replaceDrawPolyline, replaceDrawRect, replaceDrawRoundRect, replaceDrawString, replaceDrawString, replaceFill3DRect, replaceFill3DRect, replaceFillArc, replaceFillOval, replaceFillPolygon, replaceFillRect, replaceFillRoundRect, replaceOperation, replaceSetClip, replaceSetColour, replaceSetFont, replaceSetPaintMode, replaceSetXORMode, resetState, setAutoRepaint, setBorder, setSpecialKeyCodes, setSpecialKeyEventState
 
Methods inherited from class amber.server.component.ComponentHandler
addActionListener, addCloseable, addComponentListener, addEventMask, addFocusListener, addItemListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addReceivedPacket, addTextListener, addWindowListener, booleanToInt, createDataInput, directPacket, displayMessageBox, fireWindowActivated, fireWindowClosed, fireWindowClosing, fireWindowDeactivated, fireWindowDeiconified, fireWindowEvent, fireWindowIconified, fireWindowOpened, forceComponentGetUrl, forceComponentGetUrl, forwardEventPacket, generateActionEvent, generateFocusEvent, generateItemEvent, generateKeyEvent, generateMouseEvent, getActionCommand, getAllCloseable, getBounds, getDataEncoderStream, getDefaultParameters, getEncoderStream, getEventMask, getFontCharacteristics, getFontCharacteristics, getFontCharacteristics, getFontCharacteristics, getFontStyle, getId, getLocation, getLog, getMaximumSize, getMinimumSize, getModalObject, getParentApplication, getParentContainer, getParentServer, getPreferredSize, getRemoteProperties, getResponsePacket, getSelectedObjects, getSize, getSizeCharacteristics, getTimeout, getToolTip, getValidId, getX, getY, handleMessages, internalForwardPacket, internalGetBounds, intToBoolean, isActive, isApplicationActive, isComponentModal, isConnected, isEnabled, isSpecialPacket, processActionEvent, processApplicationPacket, processComponentEvent, processFocusEvent, processItemEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processNormalResponse, processTextEvent, queryMessageBox, removeActionListener, removeCloseable, removeComponentListener, removeEventMask, removeFocusListener, removeItemListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removeTextListener, removeToolTip, removeWindowListener, requestFocus, restart, sendPacket, sendPacketAndBlock, sendPacketAndBlock, sendPendingPackets, setActionCommand, setBackground, setComponentModal, setConnectedState, setCursor, setEnabled, setEventMask, setFont, setFont, setFontStyle, setForeground, setForegroundBackground, setId, setLog, setModalObject, setParentApplication, setParentContainer, setParentServer, setRemoteProperties, setTimeout, setToolTip, setX, setY, shutDownClient, shutDownClient, start
 
Methods inherited from class java.awt.Component
action, add, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, getWidth, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setName, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

address

private UserAddress_Data address

btnAdd

private amber.server.component.ButtonHandler btnAdd

btnBuy

private amber.server.component.FloatButtonHandler btnBuy

btnLogout

private amber.server.component.FloatButtonHandler btnLogout

btnMain

private amber.server.component.FloatButtonHandler btnMain

btnRemove

private amber.server.component.ButtonHandler btnRemove

btnSell

private amber.server.component.FloatButtonHandler btnSell

btnUpdate

private amber.server.component.FloatButtonHandler btnUpdate

btnViewInfo

private amber.server.component.FloatButtonHandler btnViewInfo

chBuyStocks

private amber.server.component.ChoiceHandler chBuyStocks

chSellStocks

private amber.server.component.ChoiceHandler chSellStocks

chShares

private amber.server.component.ChoiceHandler chShares

currentCount

private int currentCount

FRAMEHEIGHT

public final int FRAMEHEIGHT
See Also:
Constant Field Values

FRAMEWIDTH

public final int FRAMEWIDTH
See Also:
Constant Field Values

imgBanner

private amber.server.component.ImageHandler imgBanner

interested

private Stock_Data[] interested

lastLines

private float[] lastLines

lblAccountBuy

private amber.server.component.LabelHandler lblAccountBuy

lblAccountSell

private amber.server.component.LabelHandler lblAccountSell

lblBuy

private amber.server.component.LabelHandler lblBuy

lblBuyInfo

private amber.server.component.LabelHandler lblBuyInfo

lblCps

private amber.server.component.LabelHandler lblCps

lblCpsDefinition

private amber.server.component.LabelHandler lblCpsDefinition

lblCurrValueBuy

private amber.server.component.LabelHandler lblCurrValueBuy

lblCurrValueSell

private amber.server.component.LabelHandler lblCurrValueSell

lblDividends

private amber.server.component.LabelHandler lblDividends

lblHigh

private amber.server.component.LabelHandler lblHigh

lblInfo

private amber.server.component.LabelHandler lblInfo

lblLow

private amber.server.component.LabelHandler lblLow

lblMain

private amber.server.component.LabelHandler lblMain

lblNotes

private amber.server.component.LabelHandler lblNotes

lblPeRatio

private amber.server.component.LabelHandler lblPeRatio

lblPeRatioDefinition

private amber.server.component.LabelHandler lblPeRatioDefinition

lblQtyBuy

private amber.server.component.LabelHandler lblQtyBuy

lblQtySell

private amber.server.component.LabelHandler lblQtySell

lblSell

private amber.server.component.LabelHandler lblSell

lblSellInfo

private amber.server.component.LabelHandler lblSellInfo

lblStockCode

private amber.server.component.LabelHandler lblStockCode

lblStockName

private amber.server.component.LabelHandler lblStockName

lblTcDefinition

private amber.server.component.LabelHandler lblTcDefinition

lblTotalBuy

private amber.server.component.LabelHandler lblTotalBuy

lblTotalSell

private amber.server.component.LabelHandler lblTotalSell

lblTs

private amber.server.component.LabelHandler lblTs

lblYld

private amber.server.component.LabelHandler lblYld

lblYldDefinition

private amber.server.component.LabelHandler lblYldDefinition

level1

private java.awt.Font level1

level2

private java.awt.Font level2

lines

private float[] lines

ownedstocks

private StockOwnership_Data[] ownedstocks

PlotHeight

private int PlotHeight

PlotLeft

private int PlotLeft

PlotTop

private int PlotTop

PlotWidth

private int PlotWidth

pltShares

private amber.server.component.TimePlotHandler pltShares

pnlBuy

private amber.server.panel.GenericPanel pnlBuy

pnlGraph

private amber.server.panel.GenericPanel pnlGraph

pnlSell

private amber.server.panel.GenericPanel pnlSell

seriesColors

private java.awt.Color[] seriesColors

servletconn

private ServletConnection servletconn

STABILITY_FACTOR

private static int STABILITY_FACTOR

stockNames

private java.lang.String[] stockNames

TAX_RATE

private static double TAX_RATE

timer

private amber.utility.Timer timer

totalstocks

private Stock_Data[] totalstocks

txtQtyBuy

private amber.server.component.TextFieldHandler txtQtyBuy

txtQtySell

private amber.server.component.TextFieldHandler txtQtySell

umanager

private UserManager umanager

untitledLabel

private amber.server.component.LabelHandler untitledLabel

user

private User_Data user

xmlgenerator

private XmlGenerator xmlgenerator

xmlunmarshal

private XmlUnmarshal xmlunmarshal
Constructor Detail

MainFrame

public MainFrame()
This is the constructor for MainFrame.java


MainFrame

public MainFrame(amber.server.application.ApplicationInterface appHandler)
The initialising constructor.

Parameters:
appHandler - The handle to the main ApplicationInterface which handles the functions of the overall application.

MainFrame

public MainFrame(int id,
                 amber.server.application.ApplicationInterface appHandler)
The initialising constructor.

Parameters:
id - The int containing the id of the corresponding remote component residing on the browser.
appHandler - The handle to the main ApplicationInterface which handles the functions of the overall application.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

addComponents

private void addComponents()
This method is being used for adding the components to the frame and the 3 panels.

Returns:
void

addListeners

private void addListeners()
This method is being used for adding listeners to the components that are being used in this user interface.

Returns:
void

calculateDividendYield

public void calculateDividendYield(Stock_Data stock)
This method is being used for calculating the dividend yield for a given stock.

Parameters:
stock - The stock for which the dividend yield has to be calculated.
Returns:
void

calculatePERatio

public void calculatePERatio(Stock_Data stock)
This method is being used for calculating the PERatio of the given stock.

Parameters:
stock - The stock for which PE ratio is to be calculated.
Returns:
void

calculateRatios

public void calculateRatios()
This method is being used for calling calculateRatio() for each stock.

Returns:
void

canClose

public boolean canClose()
This function determines if the panel can be closed. The derived panels must determine if this panel can close. If this is not possible the function should return false.

Specified by:
canClose in interface amber.server.panel.ContainerHandler
Returns:
boolean false if it is not possible to close this panel.

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Specified by:
componentHidden in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Specified by:
componentShown in interface java.awt.event.ComponentListener

debugStocksOwned

private void debugStocksOwned(User_Data user)
This method is being used as a utility method for debugging purpose.

Parameters:
user - The user whose information is to be displayed.
Returns:
void

defineComponents

protected void defineComponents()
This function is called to define the components which are a part of this panel. This function is called by the constructor to set up the normal static components and their locations. This method is required.


fillControls

public void fillControls()
This function would normally never need to be called, but is required to be defined as it is called internally. Its specific purpose is to set the controls to a known state once they are created.

Specified by:
fillControls in interface amber.server.panel.ContainerHandler

generateStockValues

public void generateStockValues()
This method is being used for generating stock values at each timer event.

Returns:
void

getStock

private Stock_Data getStock(java.lang.String name)
This method is being used as a utility method to get a specified stock given a stock name.

Parameters:
name - The name of the stock.
Returns:
Stock_Data The stock which has the name defined by param name.

getStocks

private Stock_Data[] getStocks(java.lang.String[] names)
This method is being used as a utility method to get the stocks defined by the names.

Parameters:
names - The array of names of stocks which are to be retrieved.
Returns:
Stock_Data[] The array of stocks that are returned based on the given names.

getStockTradingApplication

protected StockTradingApplication getStockTradingApplication()
This method is being used for getting the parent application.

Returns:
StockTradingApplication The parent application.

isNumber

private boolean isNumber(java.lang.String s)
This utility method is being used to check if the given string is an int or not.

Parameters:
s - The string which may contain a number.
Returns:
boolean Specifies whether validation is successful.

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent ie)
Specified by:
itemStateChanged in interface java.awt.event.ItemListener

redrawCaptions

protected void redrawCaptions()
                       throws amber.server.exception.ComponentHandlerException
This function draws information on the captions for the graph on the remote client.

Throws:
amber.server.exception - with any messaging errors.
amber.server.exception.ComponentHandlerException

refresh

public void refresh()
This method is being used for refreshing the user interface after updating user information.

Returns:
void

round

public double round(double x,
                    int dec)
This method is being used as a utility method for rounding a given double value to the given number of decimal places.

Parameters:
x - The original double value.
dec - The number of decimal places to be rounded to.
Returns:
double The rounded double value.

saveData

public void saveData()
This function is called to save any required information in the panel. This function is called externally when another panel wishes to take over the base panel or when closing the panel. This function need not actually do something.

Specified by:
saveData in interface amber.server.panel.ContainerHandler

setProperties

private void setProperties()
This method is being used for setting the properties of components being used in this frame.

Returns:
void

shutDown

public void shutDown()
Specified by:
shutDown in interface amber.server.application.ApplicationInterface

timeEventOccurred

public void timeEventOccurred()
Specified by:
timeEventOccurred in interface amber.utility.TimerInterface

updateBuyPanel

public void updateBuyPanel()
This method is being used for updating stock information in the buy panel (Top right of main frame).

Returns:
void

updateBuyPanelLabels

public void updateBuyPanelLabels()
This method is being used for updating only the labels in the buy panel (top right of the main frame).

Returns:
void

updateGraph

private void updateGraph()
This method is being used for adding the updated stock values to the graph - TimePlotHandler.

Returns:
void

updateSellPanel

public void updateSellPanel()
This method is being used for updating stock information in the sell panel (bottom right of the main frame).

Returns:
void

updateSellPanelLabels

public void updateSellPanelLabels()
Method: updateSellPanelLabels This method is being used for updating only the labels in the sell panel (bottom right of the main frame).

Returns:
void

updateStockInfo

public void updateStockInfo()
This method is being used for updating the displayed stock information in the centre og the main frame.

Returns:
void

windowActivated

public void windowActivated(amber.awt.event.ComponentWindowEvent e)
Specified by:
windowActivated in interface amber.awt.event.ComponentWindowListener

windowClosed

public void windowClosed(amber.awt.event.ComponentWindowEvent e)
Specified by:
windowClosed in interface amber.awt.event.ComponentWindowListener

windowClosing

public void windowClosing(amber.awt.event.ComponentWindowEvent e)
Specified by:
windowClosing in interface amber.awt.event.ComponentWindowListener

windowDeactivated

public void windowDeactivated(amber.awt.event.ComponentWindowEvent e)
Specified by:
windowDeactivated in interface amber.awt.event.ComponentWindowListener

windowDeiconified

public void windowDeiconified(amber.awt.event.ComponentWindowEvent e)
Specified by:
windowDeiconified in interface amber.awt.event.ComponentWindowListener

windowIconified

public void windowIconified(amber.awt.event.ComponentWindowEvent e)
Specified by:
windowIconified in interface amber.awt.event.ComponentWindowListener

windowOpened

public void windowOpened(amber.awt.event.ComponentWindowEvent e)
Specified by:
windowOpened in interface amber.awt.event.ComponentWindowListener