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.| Constructor and Description |
|---|
BlockStub(Workspace workspace,
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. |
| Modifier and Type | Method and Description |
|---|---|
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
|
org.w3c.dom.Node |
getSaveNode(org.w3c.dom.Document document,
int x,
int y,
org.w3c.dom.Node commentNode,
boolean collapsed)
Returns the node of this using additional location information
specified in x and y and comment text .
|
static java.lang.Iterable<java.lang.Long> |
getStubsOfParent(Workspace workspace,
Block block)
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. forward, say, etc.); false otherwise
FORWARDED FROM BLOCK GENUS
|
boolean |
isDataBlock()
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
|
boolean |
isFunctionBlock()
Returns true iff this block is a function block, which takes in an input and produces an
output.
|
static void |
parentConnectorsChanged(Workspace workspace,
java.lang.Long parentID)
Updates the BlocksStubs associated with the parent of its new page label
|
static void |
parentNameChanged(Workspace workspace,
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(Workspace workspace,
java.lang.String newPageLabel,
java.lang.Long parentID)
Updates the BlockStubs associated with the parent of its new page label
|
static void |
parentPlugChanged(Workspace workspace,
java.lang.Long parentID,
java.lang.String kind)
Updates the plug on caller stubs associated with the given parent.
|
static void |
putNewParentInStubMap(Workspace workspace,
java.lang.Long blockID)
Saves the parent block information with the specified blockID in the Stub Map
|
java.lang.String |
toString() |
addSocket, addSocket, areSocketsExpandable, blockConnected, blockDisconnected, equals, getAfterBlockID, getAfterConnector, getArgumentDescription, getBadMsg, getBeforeBlockID, getBeforeConnector, 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, getWorkspace, hasAfterConnector, hasBeforeConnector, hasDefaultArgs, hasFocus, hashCode, hasPageLabel, hasPlug, hasSiblings, hasStubs, isBad, isDeclaration, isInfix, isLabelEditable, isLabelValue, isListRelated, isPageLabelSetByPage, isProcedureDeclBlock, isProcedureParamBlock, isVariableDeclBlock, labelMustBeUnique, linkAllDefaultArgs, loadBlockFrom, loadState, notifyRenderable, removeSocket, removeSocket, setBad, setBadMsg, setBlockLabel, setFocus, setPageLabel, setPlug, setPlugBlockID, setPlugKind, setPlugLabel, setProperty, setSocketAt, translateLongpublic BlockStub(Workspace workspace, java.lang.Long initParentID, java.lang.String parentGenus, java.lang.String parentName, java.lang.String stubGenus)
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.initParentID - the Long block ID of its initial parentparentGenus - the BlockGenus String name of its initial parentparentName - stubGenus - public static java.lang.Iterable<java.lang.Long> getStubsOfParent(Workspace workspace, Block block)
blockID - public static void putNewParentInStubMap(Workspace workspace, java.lang.Long blockID)
blockID - public static void parentNameChanged(Workspace workspace, java.lang.String oldParentName, java.lang.String newParentName, java.lang.Long parentID)
oldParentName - newParentName - parentID - public static void parentPageLabelChanged(Workspace workspace, java.lang.String newPageLabel, java.lang.Long parentID)
newPageLabel - parentID - public static void parentConnectorsChanged(Workspace workspace, java.lang.Long parentID)
parentID - public static void parentPlugChanged(Workspace workspace, java.lang.Long parentID, java.lang.String kind)
kind - the new plug kind that callers should setpublic java.lang.String getParentName()
public Block getParent()
public java.lang.String getParentGenus()
public boolean doesParentExist()
public void changeGenusTo(java.lang.String genusName)
changeGenusTo in class BlockgenusName - the String name of the BlockGenus to change this Block topublic java.awt.Color getColor()
public java.lang.String toString()
public boolean isCommandBlock()
BlockisCommandBlock in class Blockpublic boolean isDataBlock()
BlockisDataBlock in class Blockpublic boolean isFunctionBlock()
BlockisFunctionBlock in class Blockpublic org.w3c.dom.Node getSaveNode(org.w3c.dom.Document document,
int x,
int y,
org.w3c.dom.Node commentNode,
boolean collapsed)
BlockgetSaveNode in class Block