prioritizer
Class PlanningGame

java.lang.Object
  extended byprioritizer.PlanningGame

public class PlanningGame
extends java.lang.Object

Defines the Planning Game prioritization method.

Author:
Mikael Jönsson & Per Klingnäs

Nested Class Summary
(package private)  class PlanningGame.Card
          Defines a Card representing a Requirement in the Planning Game method
(package private)  class PlanningGame.Pile
          Defines a Pile where the cards can be put
 
Field Summary
static int CARD_HEIGHT
           
static int CARD_WIDTH
           
private  java.util.LinkedList cardsInCurrentPile
           
private  java.util.LinkedList cardsOnDeskList
           
private  javax.swing.JPanel desk
           
static int DESK
           
private  int deskHeight
           
private  int deskWidth
           
private  int dx
           
private  int dy
           
private  PlanningGame.Pile high
           
static int HIGH
           
private  PlanningGame.Pile low
           
static int LOW
           
private  PlanningGame.Pile medium
           
static int MEDIUM
           
private  int oldX
           
private  int oldY
           
private  java.util.Random rand
           
private  RequirementList rList
           
private  PlanningGame.Card selectedCard
           
private  java.util.LinkedList selectedCardsList
           
 
Constructor Summary
PlanningGame(RequirementList rList)
          Constructor for the Planning Game technique.
 
Method Summary
 void addCardToSelectionList(java.awt.Point p)
           
 void deselectCard()
          Deselects the selected Card.
 void drawDesk(java.awt.Graphics g, javax.swing.JPanel c)
          Draws all the cards and piles on the desk
 void drawPile(java.awt.Graphics g, int pileType)
          Draws the cards in the specified Pile.
 int getDx()
          Gets the horizontal distance between the left edge of the card and the clicked position.
 int getDy()
          Gets the vertical distance between the upper edge of the card and the clicked position.
 int getNbrOfCardsInCurrentPile()
          Gets the number of cards in he currently selected Pile.
 int getNbrOfCardsOnDesk()
          Gets the number of cards on the desk.
 java.util.LinkedList getPile(java.lang.String pileName)
          Gets the LinkedList representing the specified Pile.
 Requirement getRequirement(java.lang.String pileName, int i)
          Gets the Requirement at the specified index in the specified Pile.
 Requirement getRequirementAt(java.awt.Point p, int pileType)
          Tries to get the Requirement on the desk or in a Pile at the specified position.
 RequirementList getRequirementList()
          Gets the list containing all the requirements to be prioritized.
private  void highlight(PlanningGame.Card c)
          Highlights a Card
private  void highlight(PlanningGame.Pile p)
          Highlights a Pile.
 void makeCards(int deskWidth, int deskHeight)
          Create a Card for each Requirement and assign a random position, within the specified drawing area limits.
 void moveCardToEmptyPlace()
          Moves away a card to an empty place in the pile.
 void moveSelectedCardsTo(int x, int y, java.awt.Dimension deskSize)
          Moves all cards in the selection square when they are dragged.
 void moveSelectedInPileTo(int y, int pileType)
          Moves the selected card to a new position in the Pile when dragged & dropped.
 void moveSelectedTo(int x, int y, java.awt.Dimension dim)
          Moves the selected card to a new position on the desk.
 boolean putCardInPile()
          Removes the selected card from the desk and adds it to the highlighted pile.
 Requirement select(int x, int y, int pileType)
          Tries to select a Card on the desk or in a Pile at the specified position.
 void selectCardsInSelectionSquare(java.awt.Point startPoint, java.awt.Point endPoint)
          Selects all the cards withing the user-drawn selection square.
 java.lang.Object[] selectPile(int x, int y)
          Tries to select a pile at the given position.
 void sendToDesk(int pileType)
          Sends the selected card in the specified Pile, to the desk.
 void setCurrentPrioritiesAndShuffle(java.lang.String criteria, boolean skipPriorities)
          Rank the requirements by the order in the planning game lists.
private  void setRandomCardPosition(PlanningGame.Card c)
          Sets a random position on the screen, for the Card to be drawn at
private  void unhighlight(PlanningGame.Card c)
          Unhighlights a Card.
private  void unhighlight(PlanningGame.Pile p)
          Unhighlists a Pile.
 void unhighlightAllPiles()
          Unhighlights all piles.
private  void unhighlightAndUnselectAllCards()
          Unhighlights all cards
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CARD_WIDTH

public static final int CARD_WIDTH
See Also:
Constant Field Values

CARD_HEIGHT

public static final int CARD_HEIGHT
See Also:
Constant Field Values

HIGH

public static final int HIGH
See Also:
Constant Field Values

MEDIUM

public static final int MEDIUM
See Also:
Constant Field Values

LOW

public static final int LOW
See Also:
Constant Field Values

DESK

public static final int DESK
See Also:
Constant Field Values

cardsOnDeskList

private java.util.LinkedList cardsOnDeskList

cardsInCurrentPile

private java.util.LinkedList cardsInCurrentPile

desk

private javax.swing.JPanel desk

deskWidth

private int deskWidth

deskHeight

private int deskHeight

dx

private int dx

dy

private int dy

high

private PlanningGame.Pile high

medium

private PlanningGame.Pile medium

low

private PlanningGame.Pile low

oldX

private int oldX

oldY

private int oldY

rand

private java.util.Random rand

rList

private RequirementList rList

selectedCard

private PlanningGame.Card selectedCard

selectedCardsList

private java.util.LinkedList selectedCardsList
Constructor Detail

PlanningGame

public PlanningGame(RequirementList rList)
Constructor for the Planning Game technique.

Parameters:
rList - the RequirementList containing the Requirements to be prioritized
Method Detail

highlight

private void highlight(PlanningGame.Card c)
Highlights a Card

Parameters:
c - the Card to highlight

highlight

private void highlight(PlanningGame.Pile p)
Highlights a Pile.

Parameters:
p - the Pile to highlight

setRandomCardPosition

private void setRandomCardPosition(PlanningGame.Card c)
Sets a random position on the screen, for the Card to be drawn at

Parameters:
c - the Card to set the randomized position for

unhighlight

private void unhighlight(PlanningGame.Card c)
Unhighlights a Card.

Parameters:
c - the Card to unhighlight

unhighlightAndUnselectAllCards

private void unhighlightAndUnselectAllCards()
Unhighlights all cards


unhighlight

private void unhighlight(PlanningGame.Pile p)
Unhighlists a Pile.

Parameters:
p - the Pile to unhighlight

deselectCard

public void deselectCard()
Deselects the selected Card.


drawDesk

public void drawDesk(java.awt.Graphics g,
                     javax.swing.JPanel c)
Draws all the cards and piles on the desk

Parameters:
g - the graphics component to use for drawing
c - the panel (desk) to draw upon

drawPile

public void drawPile(java.awt.Graphics g,
                     int pileType)
Draws the cards in the specified Pile.

Parameters:
g - the graphics component to use for drawing
pileType - the pile to be drawn, HIGH, MEDIUM or LOW

getDx

public int getDx()
Gets the horizontal distance between the left edge of the card and the clicked position.

Returns:
the horizontal distance

getDy

public int getDy()
Gets the vertical distance between the upper edge of the card and the clicked position.

Returns:
the vertical distance

getNbrOfCardsInCurrentPile

public int getNbrOfCardsInCurrentPile()
Gets the number of cards in he currently selected Pile.

Returns:
the number of cards in the selected Pile; 0 if no Pile is selected

getNbrOfCardsOnDesk

public int getNbrOfCardsOnDesk()
Gets the number of cards on the desk.

Returns:
the number of cards on the desk

getPile

public java.util.LinkedList getPile(java.lang.String pileName)
Gets the LinkedList representing the specified Pile.

Parameters:
pileName - the specified Pile
Returns:
the list containing the cards in the specified Pile

getRequirement

public Requirement getRequirement(java.lang.String pileName,
                                  int i)
Gets the Requirement at the specified index in the specified Pile.

Parameters:
pileName - the Pile to ge the Requirement from
i - the index of the requirement in the Pile
Returns:
the sought requirement if found; null if not found

getRequirementList

public RequirementList getRequirementList()
Gets the list containing all the requirements to be prioritized.

Returns:
the list containing all the requirements to be prioritized

makeCards

public void makeCards(int deskWidth,
                      int deskHeight)
Create a Card for each Requirement and assign a random position, within the specified drawing area limits.

Parameters:
deskWidth - the width of the drawing area
deskHeight - the height of the drawing area

moveCardToEmptyPlace

public void moveCardToEmptyPlace()
Moves away a card to an empty place in the pile.

Used in the Pile when moving cards.


moveSelectedInPileTo

public void moveSelectedInPileTo(int y,
                                 int pileType)
Moves the selected card to a new position in the Pile when dragged & dropped. Also makes sure that cards are "snapped" into the right positions when dropped.

Parameters:
y - the vertical position where the card is dropped
pileType - the pile in which the card is being moved

moveSelectedTo

public void moveSelectedTo(int x,
                           int y,
                           java.awt.Dimension dim)
Moves the selected card to a new position on the desk. Also Highlights the correct Pile if the card is dragged over it.

Parameters:
x - the horizontal position of the mouse pointer
y - the vertical position of the mouse pointer

moveSelectedCardsTo

public void moveSelectedCardsTo(int x,
                                int y,
                                java.awt.Dimension deskSize)
Moves all cards in the selection square when they are dragged.

Parameters:
x - the x-position of the mouse pointer
y - the y-position of the mouse pointer
deskSize - the size of the desk's drawing area

putCardInPile

public boolean putCardInPile()
Removes the selected card from the desk and adds it to the highlighted pile. Also sets a new position for the card in the Pile.

Returns:
true if the move suceeded; else false

select

public Requirement select(int x,
                          int y,
                          int pileType)
Tries to select a Card on the desk or in a Pile at the specified position.

Parameters:
x - the horizontal position of the mouse pointer
y - the vertical position of the mouse pointer
pileType - HIGH, MEDIUM, LOW or DESK depending on where the card is
Returns:
the Requirement associated with the Card if selection succeeded; else null

addCardToSelectionList

public void addCardToSelectionList(java.awt.Point p)

getRequirementAt

public Requirement getRequirementAt(java.awt.Point p,
                                    int pileType)
Tries to get the Requirement on the desk or in a Pile at the specified position.

Parameters:
p - the specified position
pileType - HIGH, MEDIUM, LOW or DESK depending on where the card is
Returns:
the Requirement associated with the Card if selection succeeded; else null

selectCardsInSelectionSquare

public void selectCardsInSelectionSquare(java.awt.Point startPoint,
                                         java.awt.Point endPoint)
Selects all the cards withing the user-drawn selection square.

Parameters:
startPoint - upper left corner in the selection square
endPoint - lower righti corner in the selection square

selectPile

public java.lang.Object[] selectPile(int x,
                                     int y)
Tries to select a pile at the given position.

Parameters:
x - the horizontal position of the mouse pointer
y - the vertical position of the mouse pointer
Returns:
an array in the form of:
[name of the pile][list containing the cards in the pile]

sendToDesk

public void sendToDesk(int pileType)
Sends the selected card in the specified Pile, to the desk.

Parameters:
pileType - the specified Pile

setCurrentPrioritiesAndShuffle

public void setCurrentPrioritiesAndShuffle(java.lang.String criteria,
                                           boolean skipPriorities)
Rank the requirements by the order in the planning game lists. The integer part is each requirements priority in the pile and the decimal part decides which pile it belongs to. Piles: x.0 = high, x.1 = medium and x.2 = low e.g. 3.2 means that it is the fourth requirement in the lower pile.

Also sets new random positions for the cards

Parameters:
criteria - the current prioritization criteria
skipPriorities - true if priorities are set by $100 method

unhighlightAllPiles

public void unhighlightAllPiles()
Unhighlights all piles.