renderable
Class BlockUtilities

java.lang.Object
  extended by renderable.BlockUtilities

public class BlockUtilities
extends java.lang.Object


Constructor Summary
BlockUtilities()
           
 
Method Summary
static boolean blockExists(BlockNode node)
          Checks to see if the block still exists
static RenderableBlock cloneBlock(Block myblock)
           
static void deleteBlock(RenderableBlock block)
           
static java.lang.String disambiguousStringRep(RenderableBlock block)
          Creates a string representation for the given RenderableBlock that is disambiguated from string representations for blocks with the same label by appending socket information to the end of the block's label.
static java.util.List<TextualFactoryBlock> getAllMatchingBlocks(java.lang.String keyword)
           
static RenderableBlock getBlock(java.lang.String genusName, java.lang.String label)
          Returns a new RenderableBlock instance with the matching genusName.
static java.util.List<TextualFactoryBlock> getDigits(java.lang.String digits)
           
static java.util.List<TextualFactoryBlock> getPlusBlocks(java.lang.String plus)
           
static boolean isLabelValid(Block block, java.lang.String label)
           
static boolean isLabelValid(java.lang.Long blockID, java.lang.String label)
          Returns true if the specified label is valid according to the specifications of this block's genus.
static BlockNode makeNodeWithChildren(java.lang.Long blockID)
           
static BlockNode makeNodeWithStack(java.lang.Long blockID)
           
static RenderableBlock makeRenderable(BlockNode node, WorkspaceWidget widget)
           
static void reset()
           
static void setZoomLevel(double newZoom)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockUtilities

public BlockUtilities()
Method Detail

reset

public static void reset()

setZoomLevel

public static void setZoomLevel(double newZoom)

isLabelValid

public static boolean isLabelValid(java.lang.Long blockID,
                                   java.lang.String label)
Returns true if the specified label is valid according to the specifications of this block's genus. For example, if this block's label must be unique (as specified from its genus), this method verifies that its label is unique relative to the other instances present.

Parameters:
label - the String block label to test
Returns:
true if the specified label is valid according to the specifications of this block's genus.

isLabelValid

public static boolean isLabelValid(Block block,
                                   java.lang.String label)

deleteBlock

public static void deleteBlock(RenderableBlock block)

cloneBlock

public static RenderableBlock cloneBlock(Block myblock)

disambiguousStringRep

public static java.lang.String disambiguousStringRep(RenderableBlock block)
Creates a string representation for the given RenderableBlock that is disambiguated from string representations for blocks with the same label by appending socket information to the end of the block's label. The created string is in the form: BlockLabel [socketLabel1, ..., socketLabelN]

Parameters:
block - the FactoryRenderableBlock to create a string representation of
Returns:
a String containing the given block's keyword with a list of its socket labels appended to the end.

getAllMatchingBlocks

public static java.util.List<TextualFactoryBlock> getAllMatchingBlocks(java.lang.String keyword)
Parameters:
keyword -
Returns:
List of TextualFactoryBlocks, {T}, such that: T.toString contains keyword T == null if no matching blocks were found T.toString is unique for each T

getPlusBlocks

public static java.util.List<TextualFactoryBlock> getPlusBlocks(java.lang.String plus)
Parameters:
plus -
Returns:
List containing the two "+" TextualFactoryBlocks and any other blocks containing "+"

getDigits

public static java.util.List<TextualFactoryBlock> getDigits(java.lang.String digits)
Parameters:
digits -
Returns:
List containing a number TextualFactoryBlock and any other blocks containing the numbers

getBlock

public static RenderableBlock getBlock(java.lang.String genusName,
                                       java.lang.String label)
Returns a new RenderableBlock instance with the matching genusName. New block will also have matching label is label is not-null. May return null.

Parameters:
genusName -
label -
Returns:
A new RenderableBlock with matching genusName and label (if label is not-null). If no matching blocks were found, return null.

makeNodeWithChildren

public static BlockNode makeNodeWithChildren(java.lang.Long blockID)

makeNodeWithStack

public static BlockNode makeNodeWithStack(java.lang.Long blockID)

blockExists

public static boolean blockExists(BlockNode node)
Checks to see if the block still exists

Returns:
True if renderable block is still there, False otherwise

makeRenderable

public static RenderableBlock makeRenderable(BlockNode node,
                                             WorkspaceWidget widget)