Package jadex.bdiv3.examples.blocksworld
Class Block
- java.lang.Object
-
- jadex.bdiv3.examples.blocksworld.Block
-
- Direct Known Subclasses:
Table
public class Block extends java.lang.Object
A block in the blocks-world.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.Color
color
The color of the block.protected double
dx
The x translation for drawing (0-1).protected double
dy
The y translation for drawing (0-1).protected Block
lower
The block where this block is located on.protected int
number
The number of the block.SimplePropertyChangeSupport
pcs
The helper object for bean events.protected Block
upper
The block located on upper of this block.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addBlock(Block block)
Add a block to this block.void
addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.boolean
equals(java.lang.Object o)
Check for equality.java.awt.Color
getColor()
Get the color of the block.Block
getLower()
Get the block where this block is located on.protected static int
getNumber()
Get an instance number.Block
getUpper()
Get the upper.int
hashCode()
boolean
isClear()
Check if this block is clear.protected void
removeBlock(Block block)
Remove a block from this block.void
removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.protected void
setLower(Block lower)
Set the lower block, where this block is located on.void
stackOn(Block lower)
Move this block on top of another block.java.lang.String
toString()
Create a string representation of this block.
-
-
-
Field Detail
-
number
protected int number
The number of the block.
-
color
protected java.awt.Color color
The color of the block.
-
lower
protected Block lower
The block where this block is located on.
-
upper
protected Block upper
The block located on upper of this block.
-
pcs
public SimplePropertyChangeSupport pcs
The helper object for bean events.
-
dx
protected double dx
The x translation for drawing (0-1).
-
dy
protected double dy
The y translation for drawing (0-1).
-
-
Constructor Detail
-
Block
public Block(java.awt.Color color, Block lower)
Create a new block.- Parameters:
color
- The color of the block.lower
- The block where this block is located on.
-
Block
public Block(int number, java.awt.Color color, Block lower)
Create a new block.- Parameters:
number
- The number of the block.color
- The color of the block.lower
- The block where this block is located on.
-
-
Method Detail
-
getNumber
protected static int getNumber()
Get an instance number.
-
getColor
public java.awt.Color getColor()
Get the color of the block.- Returns:
- The color of the block.
-
getLower
public Block getLower()
Get the block where this block is located on.- Returns:
- The block where this block is located on.
-
getUpper
public Block getUpper()
Get the upper.- Returns:
- The upper.
-
isClear
public boolean isClear()
Check if this block is clear.
-
stackOn
public void stackOn(Block lower)
Move this block on top of another block.
-
setLower
protected void setLower(Block lower)
Set the lower block, where this block is located on.- Parameters:
lower
- The lower block.
-
addBlock
protected void addBlock(Block block)
Add a block to this block.
-
removeBlock
protected void removeBlock(Block block)
Remove a block from this block.
-
toString
public java.lang.String toString()
Create a string representation of this block.- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
Check for equality.- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. The listener is registered for all properties.- Parameters:
listener
- The PropertyChangeListener to be added.
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.- Parameters:
listener
- The PropertyChangeListener to be removed.
-
-