org.game.Juzzle
Class PuzzlePartList

java.lang.Object
  |
  +--org.game.Juzzle.PuzzlePartList
All Implemented Interfaces:
IPuzzlePartList

public class PuzzlePartList
extends java.lang.Object
implements IPuzzlePartList

PuzzlePartList create the pieces of the image and controls these


Inner Class Summary
static class PuzzlePartList.PuzzlePart
          class for one piece
 
Field Summary
protected  java.awt.image.BufferedImage bimage
          reference to the current game image
protected  PuzzlePartList.PuzzlePart dragGroup
          selected group to drag. dragPart is a member of this group
protected  PuzzlePartList.PuzzlePart dragPart
          selected part to drag.
protected  PuzzlePartList.PuzzlePart first
          anchor for first and last part of list
protected  int imageHeight
          current game image height
protected  int imageWidth
          current game image width
protected  PuzzlePartList.PuzzlePart last
          anchor for first and last part of list
protected  int puzzleCount
          solved parts
protected  PuzzlePartList.PuzzlePart[] pz_array
          array of parts
 
Constructor Summary
PuzzlePartList(java.awt.image.BufferedImage bimage, int x_parts, int y_parts, java.awt.Dimension random_size)
          simply constructor
 
Method Summary
 void deselectPart()
          deselect the selected part if one selected
 PuzzlePartList.PuzzlePart getFirstNode()
          return the first node
 PuzzlePartList.PuzzlePart[] getPartArray()
          get the array with all parts, the array is never changing for a game, only the list is changing
 int getPartsCount()
          return the puzzle part count
 int getSolvedPartsCount()
          return the solved puzzle part count
 boolean isSelectedPart(PuzzlePartList.PuzzlePart part)
          is the part the selected part or not
 void moveLocation(int dx, int dy)
          move the selected part
protected  void moveLocationGroup(PuzzlePartList.PuzzlePart group, int dx, int dy)
          move the selected group
 boolean selectPart__(java.awt.Point point)
          another version only for part, don't used
 boolean selectPart(java.awt.Point point)
          select part at the point
 void setRedrawRect(java.awt.Rectangle repaintRect)
          ask the model for the part that has changed and should be repainted
protected  void updateGroup(PuzzlePartList.PuzzlePart dragGroup, PuzzlePartList.PuzzlePart node, PuzzlePartList.PuzzlePart node2)
          update the list and shape of group
 void updatePart()
          if the piece is releasing, test if it pass to another part and if true create a new part
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bimage

protected java.awt.image.BufferedImage bimage
reference to the current game image

imageWidth

protected int imageWidth
current game image width

imageHeight

protected int imageHeight
current game image height

first

protected PuzzlePartList.PuzzlePart first
anchor for first and last part of list

last

protected PuzzlePartList.PuzzlePart last
anchor for first and last part of list

pz_array

protected PuzzlePartList.PuzzlePart[] pz_array
array of parts

puzzleCount

protected int puzzleCount
solved parts

dragPart

protected PuzzlePartList.PuzzlePart dragPart
selected part to drag. The part can be a member of a group or be self a group

dragGroup

protected PuzzlePartList.PuzzlePart dragGroup
selected group to drag. dragPart is a member of this group
Constructor Detail

PuzzlePartList

public PuzzlePartList(java.awt.image.BufferedImage bimage,
                      int x_parts,
                      int y_parts,
                      java.awt.Dimension random_size)
simply constructor
Parameters:
bimage - reference to the game image
x_parts - horizontal divirion
y_parts - vertical division
random_size - max width and height for the random calculation
Method Detail

getPartsCount

public int getPartsCount()
return the puzzle part count
Specified by:
getPartsCount in interface IPuzzlePartList
Returns:
the puzzle part count

getSolvedPartsCount

public int getSolvedPartsCount()
return the solved puzzle part count
Specified by:
getSolvedPartsCount in interface IPuzzlePartList
Returns:
the solved puzzle part count

getFirstNode

public PuzzlePartList.PuzzlePart getFirstNode()
return the first node
Specified by:
getFirstNode in interface IPuzzlePartList
Returns:
the first node

getPartArray

public PuzzlePartList.PuzzlePart[] getPartArray()
get the array with all parts, the array is never changing for a game, only the list is changing
Specified by:
getPartArray in interface IPuzzlePartList
Returns:
a array with all parts

isSelectedPart

public boolean isSelectedPart(PuzzlePartList.PuzzlePart part)
is the part the selected part or not
Specified by:
isSelectedPart in interface IPuzzlePartList
Parameters:
part - the part to compare
Returns:
true if the same part or false if not

selectPart

public boolean selectPart(java.awt.Point point)
select part at the point
Specified by:
selectPart in interface IPuzzlePartList
Parameters:
point - point for selection
Returns:
true if selected or false if not

selectPart__

public boolean selectPart__(java.awt.Point point)
another version only for part, don't used

deselectPart

public void deselectPart()
deselect the selected part if one selected
Specified by:
deselectPart in interface IPuzzlePartList

setRedrawRect

public void setRedrawRect(java.awt.Rectangle repaintRect)
ask the model for the part that has changed and should be repainted
Specified by:
setRedrawRect in interface IPuzzlePartList
Parameters:
repaintRect - reference to the Rectangle, that get the repaint rectangle

moveLocation

public void moveLocation(int dx,
                         int dy)
move the selected part
Specified by:
moveLocation in interface IPuzzlePartList
Parameters:
dx - new x position
dy - new y position

moveLocationGroup

protected void moveLocationGroup(PuzzlePartList.PuzzlePart group,
                                 int dx,
                                 int dy)
move the selected group
Parameters:
group - group to move
dx - new x position
dy - new y position

updatePart

public void updatePart()
if the piece is releasing, test if it pass to another part and if true create a new part
Specified by:
updatePart in interface IPuzzlePartList

updateGroup

protected void updateGroup(PuzzlePartList.PuzzlePart dragGroup,
                           PuzzlePartList.PuzzlePart node,
                           PuzzlePartList.PuzzlePart node2)
update the list and shape of group
Parameters:
dragGroup - group to change
node - node of dragGroup that pass
node2 - node of another group that pass