|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcodeblocks.BlockLinkChecker
public class BlockLinkChecker
BlockLinkChecker
determines if two Block
objects can connect. In particular,
BlockLinkChecker
will report which sockets of the two Block
objects can connect.
Interested Block
objects may make a static call to canLink() to determine if it can link to another
Block
object.
BlockLinkChecker
uses a list of LinkRule
s to check the Connector
s of each
Block
. Rules may be added, inserted, and removed from the checker.
There is only one instance of the BlockLinkChecker
.
Constructor Summary | |
---|---|
BlockLinkChecker()
|
Method Summary | |
---|---|
static void |
addRule(LinkRule rule)
Adds a rule to the end of this checker's list of rules. |
static BlockLink |
canLink(Block block1,
Block block2,
BlockConnector con1,
BlockConnector con2)
Returns a BlockLink instance if the two specified blocks can connect at the specified block connectors at each block; null if no link is possible. |
static BlockLink |
getLink(RenderableBlock rblock1,
java.lang.Iterable<RenderableBlock> otherBlocks)
Checks to see if a RenderableBlock s can connect to other RenderableBlock s. |
static BlockConnector |
getPlugEquivalent(Block b)
|
static java.lang.Iterable<BlockConnector> |
getSocketEquivalents(Block b)
|
static BlockLink |
getWeakLink(RenderableBlock rblock1,
java.lang.Iterable<RenderableBlock> otherBlocks)
NOTE: ALWAYS prefer BlockLinkChecker.getLink over this method. |
static boolean |
hasPlugEquivalent(Block b)
|
static void |
insertRule(LinkRule rule,
int index)
Insert rule at the specified index in this checker's list of rules. |
static void |
printRules()
Prints to the console all the rules this LinkChecker currently supports. |
static void |
removeRule(LinkRule rule)
Removes the specified rule from the rule list |
static void |
reset()
Clears all the rules within this. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BlockLinkChecker()
Method Detail |
---|
public static void reset()
public static void addRule(LinkRule rule)
rule
- the desired LinkRule to be addedpublic static void insertRule(LinkRule rule, int index)
rule
- the desired rule to insertindex
- the index to insert the rule inpublic static void removeRule(LinkRule rule)
rule
- the desired LinkRule to removepublic static BlockLink canLink(Block block1, Block block2, BlockConnector con1, BlockConnector con2)
block1
- Block instance to compareblock2
- Block instance to comparecon1
- the BlockConnector at block1 to compare against con2con2
- the BlockConnector at block2 to compare against con1public static BlockLink getLink(RenderableBlock rblock1, java.lang.Iterable<RenderableBlock> otherBlocks)
RenderableBlock
s can connect to other RenderableBlock
s.
This would mean that they have BlockConnector
s that satisfy at least one of the LinkRule
s,
and that these sockets are in close proximity.
rblock1
- one of the blocks to checkotherBlocks
- the other blocks to check against
BlockLink
object that gives the two closest matching BlockConnector
s in these blocks,
or null if no such matching exists.public static BlockLink getWeakLink(RenderableBlock rblock1, java.lang.Iterable<RenderableBlock> otherBlocks)
RenderableBlock
s can connect
to other RenderableBlock
s, implying that rblock1
has at least one BlockConnector
s that satisfies at
least one of the LinkRule
s.
Does not require close proximity.
rblock1
- one of the blocks to checkotherBlocks
- the other blocks to check against
BlockLink
object that gives the two closest matching BlockConnector
s in these blocks,
or null if no such matching exists.public static boolean hasPlugEquivalent(Block b)
public static BlockConnector getPlugEquivalent(Block b)
public static java.lang.Iterable<BlockConnector> getSocketEquivalents(Block b)
public static void printRules()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |