|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
cafe.gui.GuiMain
public class GuiMain
Graphical User Interface's main class. This class is the only class in the GUI component that is connected with the rest of the system. It manages most of the program logic in the gui, by changing views and reacting to events.
Field Summary | |
---|---|
static javax.swing.border.Border |
DEFAULT_BORDER
Default thin black border used around panels. |
static java.awt.Dimension |
DEFAULT_BUTTON_SIZE
Size for navigation buttons |
static java.awt.Color |
DEFAULT_COLOR
Default background color (yellowish) |
static javax.swing.border.Border |
DEFAULT_MARGINS
A 10 px margin of the same color as the backgroud grey is, used as spacer between frame border and content panel. |
static int |
FINGER_MAX_INDEX
Maximum index of fingers, corresponding to little finger. |
static int |
FINGER_MIN_INDEX
Minimum index of fingers, corresponding to thumb. |
static java.awt.Dimension |
GROUP_SCROLL_ARROW_SIZE
Size for product group scrolling buttons |
static java.awt.Dimension |
LANGUAGE_BUTTON_SIZE
Size for language change button |
static int |
NO_FINGER_SET
Constant for indicating that no finger has been selected. |
static int |
NO_FINGERPRINT_SET
Constant for indicating that a fingerprint is not set on a certain finger. |
static java.awt.Dimension |
PRODUCT_SCROLL_ARROW_SIZE
Size for product list scrolling buttons |
Fields inherited from class javax.swing.JFrame |
---|
EXIT_ON_CLOSE |
Fields inherited from class java.awt.Frame |
---|
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.WindowConstants |
---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
GuiMain()
Default constructor. |
|
GuiMain(GUISettings guiSettings,
UserInterfaceEvent userInterfaceEvent)
Constructs the GUI and sets it to the start/title view. |
Method Summary | |
---|---|
void |
addAlert()
Confirms that an alert should be added to the currently selected product in the alert view. |
void |
addFingerprint(int id)
Adds the fingerprint given as an argument to the current user's currently selected finger if a finger is selected and the GUI is in "waiting for a new fingerprint" state. |
void |
addingFingerprint(int finger)
Sets the GUI to fingerprint insert mode, so that it waits for a fingerprint to the finger that is given as a parameter. |
void |
alertProduct(ImportProduct product)
Sets the product given as argument as the currently selected product in alert adding view. |
void |
authenticatedUser(UserInfo user,
int fingerprintid)
Sets the user given as an argument as the current user and changes to the product export view. |
void |
authenticateUser(java.lang.String username,
java.lang.String password)
Authenticates the user based on the username and password given as an argument. |
void |
buyProduct(ExportProduct product)
Debits the product given as an arugement from the current user's account. |
void |
cancelFingerprintAdd()
Cancels fingerprint insert mode and returns to normal mode. |
void |
cancelLastAction()
Cancels the previous product export transaction from the currently logged on user. |
void |
changeAlertView()
Changes the current view to add product alert view |
void |
changeConfigView()
Changes the current view to "my settings" view |
void |
changeImportView()
Changes the current view to product import view |
void |
changeLanguage()
Changes the current language and resets/redraws the current view |
void |
changeRegisterView()
Changes the current view to the new user registration view. |
void |
changeShopView()
Changes the current view to product export view |
void |
changeStartView()
Changes the current view to start view (title screen), saves user data if a user is logged on and logs user out. |
void |
confirmImport(ImportProduct product,
double amount)
Credits user's account with the value of the import product of a certain size given as an argument. |
void |
continueProgram()
This method restores the GUI in its normal state, if it is in error state. |
double |
getBalance(java.lang.String[] productGroup)
Returns logged on user's balance in given product group. |
LanguageEnum |
getCurrentLanguage()
Gets the current language used in the GUI |
int |
getErrorTimeout()
Gets the time to show "finger not recognized" error message. |
java.lang.String |
getFirstAndLastName()
Gets current user's first and last name. |
GuiMain |
getGuiMain()
|
java.lang.String |
getGuiText(java.lang.String id)
Gets the text/string corresponding to the id in the current language. |
int |
getIdleTimeout()
Gets the time to wait until automatic logout, if user doesn't do anything. |
javax.swing.ImageIcon |
getLanguageImage()
Gets the icon (country flag) used as a symbol for the current language. |
int |
getPayTimeout()
Gets the time to wait until automatic debit of export product, if user doesn't make any other choices. |
void |
groupSelected()
Stops the countdown timer in import view when a product group is selected. |
void |
importProduct(ImportProduct product,
double amount)
Sets the currently selected product in import view. |
boolean |
isCancelAllowed()
Gets the info about if the user is allowed to cancel previous export transaction. |
void |
logoutTimerExpired()
A view in the user interface can use this to logout the current user after a certain time of inactivity has expired. |
void |
productSelected(ExportProduct product)
Sets the currently selected export product either in export product view or config view (meaning favorite product selection). |
void |
removeAlert(ImportProduct product)
Removes product alert from the product given as parameter |
void |
setFavoriteProduct(ExportProduct product)
Sets the current user's favorite product. |
void |
setUserName(java.lang.String givenName,
java.lang.String familyName)
Sets current user's first and family name |
void |
stopForProblem(java.lang.String problemStringId)
This method puts the GUI in a error state where users cannot do anything else but change the language. |
boolean |
unknownUser()
Shows an error message if current view is the title (start) view and the GUI is not waiting for a new fingerprint. |
Methods inherited from class javax.swing.JFrame |
---|
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, update |
Methods inherited from class java.awt.Frame |
---|
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated |
Methods inherited from class java.awt.Window |
---|
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.MenuContainer |
---|
getFont, postEvent |
Field Detail |
---|
public static final java.awt.Color DEFAULT_COLOR
public static final javax.swing.border.Border DEFAULT_BORDER
public static final javax.swing.border.Border DEFAULT_MARGINS
public static final java.awt.Dimension DEFAULT_BUTTON_SIZE
public static final java.awt.Dimension LANGUAGE_BUTTON_SIZE
public static final java.awt.Dimension PRODUCT_SCROLL_ARROW_SIZE
public static final java.awt.Dimension GROUP_SCROLL_ARROW_SIZE
public static final int FINGER_MIN_INDEX
public static final int FINGER_MAX_INDEX
public static final int NO_FINGERPRINT_SET
public static final int NO_FINGER_SET
Constructor Detail |
---|
public GuiMain(GUISettings guiSettings, UserInterfaceEvent userInterfaceEvent)
guiSettings
- Properties for the gui component.userInterfaceEvent
- Interface used to communicate with the rest of the system.public GuiMain()
Method Detail |
---|
public void authenticatedUser(UserInfo user, int fingerprintid)
authenticatedUser
in interface UserInterface
user
- user's informationfingerprintid
- the id of the fingerprint that was recognizedpublic boolean unknownUser()
true
.
unknownUser
in interface UserInterface
true
if GUI is currently waiting for a new
fingerprint, false if notpublic void addFingerprint(int id)
addFingerprint
in interface UserInterface
id
- id of the new fingerprint
java.lang.IllegalStateException
- When there is no user currently logged on or GUI is not
waiting for a fingerprint.public void stopForProblem(java.lang.String problemStringId)
stopForProblem
in interface UserInterface
problemStringId
- name of the string to be displayed (corresponding to a name of
a string in the language files, e.g. finnish.xml)public void continueProgram()
continueProgram
in interface UserInterface
public void changeStartView()
changeStartView
in interface ViewEventInterface
public void changeShopView()
changeShopView
in interface ViewEventInterface
java.lang.IllegalStateException
- When there is no user currently logged on.public void changeImportView()
changeImportView
in interface ViewEventInterface
java.lang.IllegalStateException
- When there is no user currently logged on.public void changeConfigView()
changeConfigView
in interface ViewEventInterface
java.lang.IllegalStateException
- When there is no user currently logged on.public void changeAlertView()
changeAlertView
in interface ViewEventInterface
public void changeRegisterView()
changeRegisterView
in interface ViewEventInterface
public void changeLanguage()
changeLanguage
in interface ViewEventInterface
public java.lang.String getGuiText(java.lang.String id)
getGuiText
in interface ViewEventInterface
id
- name of the string to get. Valid string names are those
defined in the language XML files (e.g. finnish.xml).
public void importProduct(ImportProduct product, double amount)
importProduct
in interface ViewEventInterface
product
- the selected import productamount
- the selected amount/size of the productpublic void confirmImport(ImportProduct product, double amount)
confirmImport
in interface ViewEventInterface
product
- the product user wants to importamount
- the selected import amount/size
java.lang.IllegalStateException
- When there is no user currently logged on.public void setFavoriteProduct(ExportProduct product)
setFavoriteProduct
in interface ViewEventInterface
product
- the export product to set as the favorite
java.lang.IllegalStateException
- When there is no user currently logged on.public void addAlert()
addAlert
in interface ViewEventInterface
public void authenticateUser(java.lang.String username, java.lang.String password)
authenticateUser
in interface ViewEventInterface
username
- username to use in the authenticationpassword
- password to use in the authenticationpublic void setUserName(java.lang.String givenName, java.lang.String familyName)
setUserName
in interface ViewEventInterface
givenName
- user's given namefamilyName
- user's family name
java.lang.IllegalStateException
- When there is no user currently logged on.public void buyProduct(ExportProduct product)
buyProduct
in interface ViewEventInterface
product
- the product to export/debit
java.lang.IllegalStateException
- When there is no user currently logged on.public void productSelected(ExportProduct product)
productSelected
in interface ViewEventInterface
product
- the selected productpublic void removeAlert(ImportProduct product)
removeAlert
in interface ViewEventInterface
product
- the product to remove the alert frompublic LanguageEnum getCurrentLanguage()
getCurrentLanguage
in interface ViewEventInterface
public javax.swing.ImageIcon getLanguageImage()
getLanguageImage
in interface ViewEventInterface
public void addingFingerprint(int finger)
addingFingerprint
in interface ViewEventInterface
finger
- the finger to wait the fingerprint for, from 0-4, where 0
means thumb and 4 means little finger.
java.lang.IllegalArgumentException
- When fingerprint index is not between 0 and 4.public void cancelFingerprintAdd()
cancelFingerprintAdd
in interface ViewEventInterface
public void cancelLastAction()
cancelLastAction
in interface ViewEventInterface
java.lang.IllegalStateException
- When there is no user currently logged on or cancel is not
allowed.public void alertProduct(ImportProduct product)
alertProduct
in interface ViewEventInterface
product
- product that has been selected for alert addingpublic double getBalance(java.lang.String[] productGroup)
getBalance
in interface ViewEventInterface
productGroup
- the product group
java.lang.IllegalStateException
- When there is no user currently logged on.public boolean isCancelAllowed()
isCancelAllowed
in interface ViewEventInterface
true
if cancelling is allowed, false
if not
java.lang.IllegalStateException
- When there is no user currently logged on.public void logoutTimerExpired()
logoutTimerExpired
in interface ViewEventInterface
public int getIdleTimeout()
getIdleTimeout
in interface ViewEventInterface
public int getPayTimeout()
getPayTimeout
in interface ViewEventInterface
public int getErrorTimeout()
getErrorTimeout
in interface ViewEventInterface
public java.lang.String getFirstAndLastName()
getFirstAndLastName
in interface ViewEventInterface
java.lang.IllegalStateException
- When there is no user currently logged on.public void groupSelected()
groupSelected
in interface ViewEventInterface
public GuiMain getGuiMain()
getGuiMain
in interface ViewEventInterface
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |