ks.common.view
Class PileView

java.lang.Object
  extended byks.common.view.Widget
      extended byks.common.view.PileView
All Implemented Interfaces:
ElementListener

public class PileView
extends Widget

Creates view of a pile of cards (only top one being visible).

Cards are extracted from the top of a pile using getCardViewForTopCard() which returns a ColumnView object even though only one card can be extracted at a time.

Note: Since v1.6, supports the returnWidget(Widget) interface to reverse the action of getCardViewForTopCard().

Creation date: (10/27/01 1:20:11 PM)


Constructor Summary
PileView(Element me)
          PileView constructor comment.
 
Method Summary
 CardView getCardViewForTopCard(java.awt.event.MouseEvent me)
          If the MouseEvent falls on the top card of this Column, remove the top card from the Model and return a CardView widget to manage the card as it is dragged on the screen.
 void redraw()
          redraw Widget image.
 boolean returnWidget(Widget w)
          Return the CardView widget's model element back onto the underlying Pile.
 
Methods inherited from class ks.common.view.Widget
getBounds, getCardImages, getContainer, getHeight, getImage, getModelElement, getMouseManager, getName, getWidth, getX, getXY, getY, inBounds, isDirty, modelChanged, paint, paint, paint, refresh, refresh, setBounds, setBounds, setContainer, setDirty, setHeight, setImage, setMouseAdapter, setMouseManager, setMouseMotionAdapter, setName, setUndoAdapter, setWidth, setX, setXY, setY, toString, translate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PileView

public PileView(Element me)
PileView constructor comment.

Parameters:
me - ks.common.model.Element
Method Detail

getCardViewForTopCard

public CardView getCardViewForTopCard(java.awt.event.MouseEvent me)
If the MouseEvent falls on the top card of this Column, remove the top card from the Model and return a CardView widget to manage the card as it is dragged on the screen. This method uses Widget's CardImages to make this calculation.

Note: the Column Model will be altered by this method if the mouseEvent maps to the top card in the Pile View.

Don't forget to let container know that we are the source for the dragging widget.

Parameters:
me - java.awt.event.MouseEvent

redraw

public void redraw()
redraw Widget image.

If the Pile is empty, a thin rectangle border is drawn. Any faceup/facedown cards in the Pile are drawn as appropriate.

Specified by:
redraw in class Widget

returnWidget

public boolean returnWidget(Widget w)
Return the CardView widget's model element back onto the underlying Pile.

If parameter widget is not a CardView object, this method will throw an IllegalCastException.

Overrides:
returnWidget in class Widget
Parameters:
w - ks.common.view.Widget
Returns:
boolean