public class BlockConnector extends java.lang.Object implements ISupportMemento
BlockConnector is a light class that describes the socket/plug
information for each socket or plug of a particular Block. Each socket has
a kind (i.e. number, String, boolean, etc.), a label, and the block id of
the block at that socket (not to be confused with the block that hold the
socket information - socket does not have a reference to that parent block).| Modifier and Type | Class and Description |
|---|---|
static class |
BlockConnector.PositionType |
| Constructor and Description |
|---|
BlockConnector(BlockConnector con)
Constucts a new
BlockConnector by copying the connector information
from the specified con. |
BlockConnector(Workspace workspace,
java.lang.String kind,
BlockConnector.PositionType positionType,
java.lang.String label,
boolean isLabelEditable,
boolean isExpandable,
java.lang.Long connBlockID)
Constructs a new
BlockConnector |
BlockConnector(Workspace workspace,
java.lang.String kind,
BlockConnector.PositionType positionType,
java.lang.String label,
boolean isLabelEditable,
boolean isExpandable,
java.lang.String expandGroup,
java.lang.Long connBlockID)
Constructs a new
BlockConnector |
BlockConnector(Workspace workspace,
java.lang.String label,
java.lang.String kind,
boolean isLabelEditable,
boolean isExpandable)
Constructs a new
BlockConnector with the specified label and kind. |
BlockConnector(Workspace workspace,
java.lang.String kind,
java.lang.String label,
java.lang.Long socketBlockID)
Constructs a new
BlockConnector with a single position |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Long |
getBlockID()
Returns the block id attached (in) this socket
|
java.lang.String |
getExpandGroup()
Returns the expand group of this connector, or an empty string ("") if
the connector is not part of a group.
|
java.lang.String |
getKind()
Returns the kind of this
|
java.lang.String |
getLabel()
Returns the label of this
|
BlockConnector.PositionType |
getPositionType()
Returns the PositionType of this
|
org.w3c.dom.Node |
getSaveNode(org.w3c.dom.Document document,
java.lang.String conKind)
Returns the node of this.
|
java.lang.Object |
getState() |
boolean |
hasBlock()
Returns true iff a block is attached to this socket; false otherwise
|
boolean |
hasDefArg()
Returns true is this connector has a default argument; false otherwise
|
java.lang.String |
initKind()
Returns the initial kind of this
|
static BlockConnector |
instantiateFromState(Workspace workspace,
java.lang.Object memento)
This is a way of generating a BlockConnector from a memento.
|
boolean |
isExpandable()
Returns true iff this connector is expandable, meaning if a block is connected to it, it may
cause another empty connector just like this to appear.
|
boolean |
isLabelEditable()
Returns true iff this socket's label is editable.
|
java.lang.Long |
linkDefArgument()
Connects this connector with its default argument, if it has any, and
returns the block ID of the connected default argument or Block.NULL if there is none.
|
static BlockConnector |
loadBlockConnector(Workspace workspace,
org.w3c.dom.Node node,
java.util.HashMap<java.lang.Long,java.lang.Long> idMapping)
Loads information for a single BlockConnector and returns an instance
of BlockConnector with the loaded information
|
void |
loadState(java.lang.Object memento) |
void |
setConnectorBlockID(java.lang.Long id)
Sets the socket block attached to this connector
|
void |
setDefaultArgument(java.lang.String genusName,
java.lang.String label)
Sets this connector's default argument to the specified genus and initial label.
|
void |
setKind(java.lang.String kind)
Sets the socket kind of this to the specified kind
|
void |
setLabel(java.lang.String label)
Sets the socket label of this to specified label
|
void |
setPositionType(BlockConnector.PositionType pos)
Sets the position type of this connector
|
java.lang.String |
toString() |
public BlockConnector(Workspace workspace, java.lang.String kind, BlockConnector.PositionType positionType, java.lang.String label, boolean isLabelEditable, boolean isExpandable, java.lang.String expandGroup, java.lang.Long connBlockID)
BlockConnectorworkspace - The workspace this connector is created inkind - the kind of this socketpositionType - the PositionType of connectorlabel - the String label of this socketisLabelEditable - is true iff this BlockConnector can have its labels edited.isExpandable - whether this socket can expand into another connector when a block is connectedexpandGroup - the expand socket group of this connectorconnBlockID - the ID of the block connected to thispublic BlockConnector(Workspace workspace, java.lang.String kind, BlockConnector.PositionType positionType, java.lang.String label, boolean isLabelEditable, boolean isExpandable, java.lang.Long connBlockID)
BlockConnectorworkspace - The workspace this connector is created inlabel - the String label of this socketkind - the kind of this socketisLabelEditable - is true iff this BlockConnector can have its labels edited.isExpandable - true if this socket can expand into another connector when a block is connected to thispositionType - specifies the PositionType of connectorpublic BlockConnector(Workspace workspace, java.lang.String kind, java.lang.String label, java.lang.Long socketBlockID)
BlockConnector with a single positionworkspace - The workspace this connector is created inlabel - the String label of this socketkind - the kind of this socketsocketBlockID - the block id attached to this socketpublic BlockConnector(Workspace workspace, java.lang.String label, java.lang.String kind, boolean isLabelEditable, boolean isExpandable)
BlockConnector with the specified label and kind.
This new socket does not have an attached block.workspace - The workspace this connector is created inlabel - the String label of this socketisLabelEditable - is true iff this BlockConnector can have its labels edited.kind - the kind of this socketpublic BlockConnector(BlockConnector con)
BlockConnector by copying the connector information
from the specified con. Copies the con's connector label and kind.con - the BlockConnector to copy frompublic java.lang.String getLabel()
public java.lang.String getKind()
public java.lang.String initKind()
public BlockConnector.PositionType getPositionType()
public java.lang.Long getBlockID()
public boolean hasBlock()
public boolean isExpandable()
public java.lang.String getExpandGroup()
public void setLabel(java.lang.String label)
label - the desired labelpublic boolean isLabelEditable()
public void setKind(java.lang.String kind)
kind - the desired kindpublic void setConnectorBlockID(java.lang.Long id)
id - the block id of the desired block to attachpublic void setPositionType(BlockConnector.PositionType pos)
pos - the desired PositionType for thispublic boolean hasDefArg()
public void setDefaultArgument(java.lang.String genusName,
java.lang.String label)
genusName - the desired BLockGenus name of the default agrumentlabel - the initial label of the default argumentpublic java.lang.Long linkDefArgument()
public java.lang.String toString()
toString in class java.lang.Objectpublic static BlockConnector loadBlockConnector(Workspace workspace, org.w3c.dom.Node node, java.util.HashMap<java.lang.Long,java.lang.Long> idMapping)
workspace - The workspace in usenode - the Node containing the desired informationpublic org.w3c.dom.Node getSaveNode(org.w3c.dom.Document document,
java.lang.String conKind)
conKind - String containing if this is a socket or plugpublic java.lang.Object getState()
getState in interface ISupportMementopublic void loadState(java.lang.Object memento)
loadState in interface ISupportMementopublic static BlockConnector instantiateFromState(Workspace workspace, java.lang.Object memento)
workspace - The workspace in usememento - The state to load