codeblocks
Class BlockStub

java.lang.Object
  extended by codeblocks.Block
      extended by codeblocks.BlockStub
All Implemented Interfaces:
ISupportMemento

public class BlockStub
extends Block

BlockStub are a special form of blocks that provide a particular reference to its "parent" block. These references can set, get, or increment the value of its "parent" block. References may also get the value for a particular agent. Finally, for a procedure block, its reference is a call block, which executes the procedure. The parent instance for a set of stubs is not permanent. The parent intance may change if the original parent it removed and then a new one with the same parent name is added to the block canvas. BlockStub manages the mapping between stubs and their parent.


Field Summary
 
Fields inherited from class codeblocks.Block
NULL
 
Constructor Summary
  BlockStub(java.lang.Long initParentID, java.lang.String parentGenus, java.lang.String parentName, java.lang.String stubGenus)
          Constructs a new BlockStub instance using the specified genus name of its parent block, the block id of its parent, the block name of parent and its stub genus.
protected BlockStub(java.lang.Long blockID, java.lang.String stubGenus, java.lang.String label, java.lang.String parentName, java.lang.String parentGenus)
          Constructs a new BlockStub instance.
 
Method Summary
 void changeGenusTo(java.lang.String genusName)
          Overriden from Block.
 boolean doesParentExist()
           
 java.awt.Color getColor()
          Returns the Color of this; May return Color.Black if color was unspecified.
 Block getParent()
          Returns the parent block of this stub
 java.lang.String getParentGenus()
          Returns the parent block genus of this stub
 java.lang.String getParentName()
          Returns the parent name of this stub
 java.lang.String getSaveString(int x, int y, java.lang.String commentSaveString, boolean collapsed)
          Returns the save string of this using additional location information specified in x and y and comment text .
static java.lang.Iterable<java.lang.Long> getStubsOfParent(java.lang.Long blockID)
          Returns a list of the block ids of the specified parent's stubs
 boolean isCommandBlock()
          Returns true if this block is a command block (i.e.
 boolean isDataBlock()
          Returns true if this block is a data block a.k.a.
 boolean isFunctionBlock()
          Returns true iff this block is a function block, which takes in an input and produces an output.
static void parentConnectorsChanged(java.lang.Long parentID)
          Updates the BlocksStubs associated with the parent of its new page label
static void parentNameChanged(java.lang.String oldParentName, java.lang.String newParentName, java.lang.Long parentID)
          Updates BlockStub hashmaps and the BlockStubs of the parent of its new name
static void parentPageLabelChanged(java.lang.String newPageLabel, java.lang.Long parentID)
          Updates the BlockStubs associated with the parent of its new page label
static void parentPlugChanged(java.lang.Long parentID, java.lang.String kind)
          Updates the plug on caller stubs associated with the given parent.
static void putNewParentInStubMap(java.lang.Long blockID)
          Saves the parent block information with the specified blockID in the Stub Map
static void reset()
          Clears all the mappings between parents and stubs.
 java.lang.String toString()
           
 
Methods inherited from class codeblocks.Block
addSocket, addSocket, areSocketsExpandable, blockConnected, blockDisconnected, equals, escape, getAfterBlockID, getAfterConnector, getAllBlocks, getArgumentDescription, getBadMsg, getBeforeBlockID, getBeforeConnector, getBlock, getBlockDescription, getBlockID, getBlockLabel, getConnectorTo, getFreshStubs, getGenusName, getInitAfter, getInitBefore, getInitBlockImageMap, getInitialLabel, getInitPlug, getInitSockets, getLabelPrefix, getLabelSuffix, getNumSockets, getPageLabel, getPlug, getPlugBlockID, getPlugKind, getPlugLabel, getProperty, getSiblingsList, getSocketAt, getSocketIndex, getSockets, getState, getStubList, hasAfterConnector, hasBeforeConnector, hasDefaultArgs, hasFocus, hashCode, hasPageLabel, hasPlug, hasSiblings, hasStubs, isBad, isDeclaration, isInfix, isLabelEditable, isLabelValue, isListRelated, isPageLabelSetByPage, isProcedureDeclBlock, isProcedureParamBlock, isVariableDeclBlock, labelMustBeUnique, linkAllDefaultArgs, loadBlockFrom, loadState, notifyRenderable, removeBeforeAndAfter, removePlug, removeSocket, removeSocket, resetBeforeAndAfter, setBad, setBadMsg, setBlockLabel, setFocus, setPageLabel, setPlug, setPlugBlockID, setPlugKind, setPlugLabel, setProperty, setSocketAt, translateLong
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BlockStub

public BlockStub(java.lang.Long initParentID,
                 java.lang.String parentGenus,
                 java.lang.String parentName,
                 java.lang.String stubGenus)
Constructs a new BlockStub instance using the specified genus name of its parent block, the block id of its parent, the block name of parent and its stub genus. The exact reference to the parent through the specified initParentID is needed, in addition to the other specified parameters, to completely construct a new block stub.

Parameters:
initParentID - the Long block ID of its initial parent
parentGenus - the BlockGenus String name of its initial parent
parentName -
stubGenus -

BlockStub

protected BlockStub(java.lang.Long blockID,
                    java.lang.String stubGenus,
                    java.lang.String label,
                    java.lang.String parentName,
                    java.lang.String parentGenus)
Constructs a new BlockStub instance. This contructor is protected as it should only be called while Block loads its information from the save String

Parameters:
blockID - the Long block ID of this
stubGenus - the BlockGenus of this
label - the Block label of this
parentName - the String name of its parent
parentGenus - the String BlockGenus name of its parent
Method Detail

reset

public static void reset()
Clears all the mappings between parents and stubs.


getStubsOfParent

public static java.lang.Iterable<java.lang.Long> getStubsOfParent(java.lang.Long blockID)
Returns a list of the block ids of the specified parent's stubs

Parameters:
blockID -

putNewParentInStubMap

public static void putNewParentInStubMap(java.lang.Long blockID)
Saves the parent block information with the specified blockID in the Stub Map

Parameters:
blockID -

parentNameChanged

public static void parentNameChanged(java.lang.String oldParentName,
                                     java.lang.String newParentName,
                                     java.lang.Long parentID)
Updates BlockStub hashmaps and the BlockStubs of the parent of its new name

Parameters:
oldParentName -
newParentName -
parentID -

parentPageLabelChanged

public static void parentPageLabelChanged(java.lang.String newPageLabel,
                                          java.lang.Long parentID)
Updates the BlockStubs associated with the parent of its new page label

Parameters:
newPageLabel -
parentID -

parentConnectorsChanged

public static void parentConnectorsChanged(java.lang.Long parentID)
Updates the BlocksStubs associated with the parent of its new page label

Parameters:
parentID -

parentPlugChanged

public static void parentPlugChanged(java.lang.Long parentID,
                                     java.lang.String kind)
Updates the plug on caller stubs associated with the given parent.

Parameters:
kind - the new plug kind that callers should set

getParentName

public java.lang.String getParentName()
Returns the parent name of this stub

Returns:
the parent name of this stub

getParent

public Block getParent()
Returns the parent block of this stub

Returns:
the parent block of this stub

getParentGenus

public java.lang.String getParentGenus()
Returns the parent block genus of this stub

Returns:
the parent block genus of this stub

doesParentExist

public boolean doesParentExist()

changeGenusTo

public void changeGenusTo(java.lang.String genusName)
Overriden from Block. Can not change the genus of a Stub.

Overrides:
changeGenusTo in class Block
Parameters:
genusName - the String name of the BlockGenus to change this Block to

getColor

public java.awt.Color getColor()
Returns the Color of this; May return Color.Black if color was unspecified.

Overrides:
getColor in class Block
Returns:
the Color of this; May return Color.Black if color was unspecified.

toString

public java.lang.String toString()
Overrides:
toString in class Block

isCommandBlock

public boolean isCommandBlock()
Description copied from class: Block
Returns true if this block is a command block (i.e. forward, say, etc.); false otherwise FORWARDED FROM BLOCK GENUS

Overrides:
isCommandBlock in class Block
Returns:
true if this block is a command block (i.e. forward, say, etc.); false otherwise

isDataBlock

public boolean isDataBlock()
Description copied from class: Block
Returns true if this block is a data block a.k.a. a primitive (i.e. number, string, boolean); false otherwise FORWARDED FROM BLOCK GENUS

Overrides:
isDataBlock in class Block
Returns:
Returns true if this block is a data block a.k.a. a primitive (i.e. number, string, boolean); false otherwise

isFunctionBlock

public boolean isFunctionBlock()
Description copied from class: Block
Returns true iff this block is a function block, which takes in an input and produces an output. (i.e. math blocks, arctan, add to list); false otherwise. FORWARDED FROM BLOCK GENUS

Overrides:
isFunctionBlock in class Block
Returns:
true iff this block is a function block, which takes in an input and produces an output. (i.e. math blocks, arctan, add to list); false otherwise.

getSaveString

public java.lang.String getSaveString(int x,
                                      int y,
                                      java.lang.String commentSaveString,
                                      boolean collapsed)
Description copied from class: Block
Returns the save string of this using additional location information specified in x and y and comment text . NOTE: in the future will not send these coordinates and instead will have renderable block insert them.

Overrides:
getSaveString in class Block
Returns:
the save string of this