|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jrummikub.model.StoneTray<E>
E
- Type of positioned objects (must implement Sizeable)public class StoneTray<E extends Sizeable>
A StoneTray is a collection of positioned objects (for example Stone
s
or StoneSet
s.
Nested Class Summary | |
---|---|
protected static class |
StoneTray.Direction
Possible move directions in case of overlapping Stones/Sets |
Field Summary | |
---|---|
protected java.util.HashMap<E,Pair<E,Position>> |
objects
|
private static long |
serialVersionUID
|
Constructor Summary | |
---|---|
StoneTray()
|
Method Summary | |
---|---|
IStoneTray<E> |
clone()
Create a clone of the StoneTray |
boolean |
contains(E object)
Search for an object within the stone tray |
void |
drop(E object,
Position position)
Adds object to the tray |
private void |
drop(E object,
Position position,
StoneTray.Direction direction)
Subroutine to "drop" to consider and determine the direction the objects dropped one collides with position-wise evade in |
private void |
dropUnchecked(E object,
Position position,
StoneTray.Direction direction)
Subroutine to "drop" to execute the actual drop |
protected Pair<Position,StoneTray.Direction> |
fixInvalidDrop(E object,
Position pos,
StoneTray.Direction dir)
Checks whether the object may be placed on the given position, computes new position if not |
private StoneTray.Direction |
getMoveDirection(E object,
Position position,
Pair<E,Position> blocking)
Returns the direction to move the object in |
private boolean |
getMoveOrientation(E object,
Position position,
Pair<E,Position> blocking)
Will the object be moved horizontally or vertically |
private Position |
getNewPosition(E object,
Position position,
StoneTray.Direction newDirection,
E currentObject,
Position currentPosition)
|
Position |
getPosition(E object)
Returns the position of an object that is already on the tray |
int |
getSize()
Return the number of objects on the tray |
java.util.Iterator<Pair<E,Position>> |
iterator()
|
private static boolean |
lessOrEqual(double d,
double e)
Static method for determining a less or equal relation considering a small fuzziness |
private boolean |
objectsOverlap(E object1,
Position position1,
E object2,
Position position2)
Tests whether two objects overlap |
boolean |
pickUp(E object)
Tries to pick up (remove) a given object |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
protected java.util.HashMap<E extends Sizeable,Pair<E extends Sizeable,Position>> objects
Constructor Detail |
---|
public StoneTray()
Method Detail |
---|
public void drop(E object, Position position)
IStoneTray
drop
in interface IStoneTray<E extends Sizeable>
object
- object to add to Handposition
- Position
to put the objectprivate void drop(E object, Position position, StoneTray.Direction direction)
object
- the object to add to Handposition
- Position
to put the objectdirection
- the direction the other stones evade inprivate void dropUnchecked(E object, Position position, StoneTray.Direction direction)
object
- the object to add to Handposition
- Position
to put the objectdirection
- the direction the other stones evade inprivate Position getNewPosition(E object, Position position, StoneTray.Direction newDirection, E currentObject, Position currentPosition)
protected Pair<Position,StoneTray.Direction> fixInvalidDrop(E object, Position pos, StoneTray.Direction dir)
object
- to be droppeddir
- pos
- the object is dropped at
private static boolean lessOrEqual(double d, double e)
d
- the value to be less or equale
- than the other one
private boolean objectsOverlap(E object1, Position position1, E object2, Position position2)
object1
- first objectposition1
- first object's positionobject2
- second objectposition2
- second object's position
private StoneTray.Direction getMoveDirection(E object, Position position, Pair<E,Position> blocking)
object
- the objectposition
- the object's positionblocking
- the object thats blocking
private boolean getMoveOrientation(E object, Position position, Pair<E,Position> blocking)
object
- the objectposition
- the objects positionblocking
- the object thats blocking
public Position getPosition(E object)
IStoneTray
getPosition
in interface IStoneTray<E extends Sizeable>
object
- object whose position is requested
public boolean contains(E object)
IStoneTray
contains
in interface IStoneTray<E extends Sizeable>
object
- object to search for
public java.util.Iterator<Pair<E,Position>> iterator()
iterator
in interface java.lang.Iterable<Pair<E extends Sizeable,Position>>
public boolean pickUp(E object)
IStoneTray
pickUp
in interface IStoneTray<E extends Sizeable>
object
- object to pick up
public IStoneTray<E> clone()
IStoneTray
clone
in interface IStoneTray<E extends Sizeable>
clone
in class java.lang.Object
public int getSize()
IStoneTray
getSize
in interface IStoneTray<E extends Sizeable>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |