Class GuiView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by GuiView
All Implemented Interfaces:
ISolitaireListener, IView, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class GuiView
extends javax.swing.JFrame
implements ISolitaireListener, IView

The GuiView class implements a GUI-based view for the game of freecell. It is associated with a Freecell model via the setFreecell method.

Author:
Group 6
ab68 Arup Banerjee
rau Robert Buechler
pp25 Patrick Paczkowski
orl Oriana Lisker
See Also:
Serialized Form

Field Summary
 
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
GuiView()
           
 
Method Summary
 void getNextMove()
          This method does nothing in the GuiView implementation because the listeners take care of inputting new moves to the freecell class.
 void makeMove()
          This method parses the pileID's obtained from the SolitaireListeners and then sends this information to the freecell class.
 void printAll()
          This method is only implemented in the text-based program - it is used to completely redraw the view, which is not necessary in the GUI implementation.
 void printEnd()
          Informs the user they have won and asks if they would like to play again.
 void printPlayAgainQuery()
          Asks the user if they would like to play again and either tells the model to start a new game or quits based on the answer.
 void printTitle()
          Prints a title for the game.
 void processSolitaireEvent(SolitaireEvent event)
          This method is responsible for handling mouse clicks.
 void setFreecell(Freecell f)
          This method associated the GuiView object with a freecell game f.
 void showError()
          Displays an error message if the player attempts an invalid move.
 
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
 

Constructor Detail

GuiView

public GuiView()
Method Detail

processSolitaireEvent

public void processSolitaireEvent(SolitaireEvent event)
This method is responsible for handling mouse clicks. It differentiates between the click of a card(s) to move and the click of a destination pile to move the card(s). On the second click, it calls makeMove(), which parses the ID's of the piles and sends them to the freecell class so that the model can make the moves.

Specified by:
processSolitaireEvent in interface ISolitaireListener
Parameters:
event - is event generated by card-clicking (or by some other means)

setFreecell

public void setFreecell(Freecell f)
This method associated the GuiView object with a freecell game f. It also tells each of the pile models to set its view to a new GuiPileView.

Specified by:
setFreecell in interface IView
Parameters:
f - the freecell object to be linked to this view

printTitle

public void printTitle()
Prints a title for the game.

Specified by:
printTitle in interface IView

printAll

public void printAll()
This method is only implemented in the text-based program - it is used to completely redraw the view, which is not necessary in the GUI implementation.

Specified by:
printAll in interface IView

printEnd

public void printEnd()
Informs the user they have won and asks if they would like to play again.

Specified by:
printEnd in interface IView

printPlayAgainQuery

public void printPlayAgainQuery()
Asks the user if they would like to play again and either tells the model to start a new game or quits based on the answer.

Specified by:
printPlayAgainQuery in interface IView

makeMove

public void makeMove()
This method parses the pileID's obtained from the SolitaireListeners and then sends this information to the freecell class. It also tells the freecell class to check if any cards can be moved to the foundation after each move and ends the game if the Freecell class tells it that the game has ended.

Specified by:
makeMove in interface IView

showError

public void showError()
Displays an error message if the player attempts an invalid move.

Specified by:
showError in interface IView

getNextMove

public void getNextMove()
This method does nothing in the GuiView implementation because the listeners take care of inputting new moves to the freecell class.

Specified by:
getNextMove in interface IView