codeblocks
Class Block

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

public class Block
extends java.lang.Object
implements ISupportMemento

Block holds the mutable prop (data) of a particular block. These mutable prop include socket, before, after and blocks, "bad"-ness. In addition, Block maintains information to describe a particular blockÕs relationship with other blocks.


Field Summary
static java.lang.Long NULL
           
 
Constructor Summary
protected Block(java.lang.Long id, java.lang.String genusName, java.lang.String label, boolean linkToStubs)
          Constructs a new Block from the specified information.
  Block(java.lang.String genusName)
          Constructs a new Block instance.
  Block(java.lang.String genusName, boolean linkToStubs)
          Constructs a new Block instance.
  Block(java.lang.String genusName, java.lang.String label)
          Constructs a new Block instance.
  Block(java.lang.String genusName, java.lang.String label, boolean linkToStubs)
          Constructs a new Block instance.
 
Method Summary
 BlockConnector addSocket(int index, java.lang.String kind, BlockConnector.PositionType positionType, java.lang.String label, boolean isLabelEditable, boolean isExpandable, java.lang.Long blockID)
          Adds another socket to this.
 void addSocket(java.lang.String kind, BlockConnector.PositionType positionType, java.lang.String label, boolean isLabelEditable, boolean isExpandable, java.lang.Long blockID)
          Adds another socket to this.
 boolean areSocketsExpandable()
          Returns true if this genus has expandable sockets; false otherwise FORWARDED FROM BLOCK GENUS
 void blockConnected(BlockConnector connectedSocket, java.lang.Long connectedBlockID)
          Informs this Block that a block with id connectedBlockID has connected to the specified connectedSocket
 void blockDisconnected(BlockConnector disconnectedSocket)
          Informs this Block that a block has disconnected from the specified disconnectedSocket
 void changeGenusTo(java.lang.String genusName)
          Changes the genus of this block, while maintaining this current blocks relationships with other blocks it's connected to.
 boolean equals(java.lang.Object other)
          Returns true iff the other Object is an instance of Block and has the same blockID as this; false otherwise
static java.lang.String escape(java.lang.String s)
          Returns an escaped (safe) version of string.
 java.lang.Long getAfterBlockID()
          Returns the Block ID connected to the after connector of this; Block.Null if this does not have an after block
 BlockConnector getAfterConnector()
          Returns the BlockConnector representing the connection to the block after this
static java.lang.Iterable<Block> getAllBlocks()
           
 java.lang.String getArgumentDescription(int index)
          Returns the the argument description at index i.
 java.lang.String getBadMsg()
          Returns the "bad" message of this block.
 java.lang.Long getBeforeBlockID()
          Returns the Block ID connected to the before connector of this; Block.Null if this does not have a before block
 BlockConnector getBeforeConnector()
          Returns the BlockConnector representing the connection to the block before this
static Block getBlock(java.lang.Long blockID)
          Returns the Block instance with the specified blockID
 java.lang.String getBlockDescription()
          Returns the String block text description of this.
 java.lang.Long getBlockID()
          Returns the block ID of this
 java.lang.String getBlockLabel()
          Returns the block label of this
 java.awt.Color getColor()
          Returns the Color of this; May return Color.Black if color was unspecified.
 BlockConnector getConnectorTo(java.lang.Long otherBlockID)
          Searches for the BlockConnector linking this block to another block
 java.lang.Iterable<BlockStub> getFreshStubs()
          Returns the Stubs of this Block, if it has Stubs; null otherwise
 java.lang.String getGenusName()
          Returns the name of this genus FORWARDED FROM BLOCK GENUS
 BlockConnector getInitAfter()
          Returns the initial after connector of this FORWARDED FROM BLOCK GENUS
 BlockConnector getInitBefore()
          Returns the initial before connector of this FORWARDED FROM BLOCK GENUS
 java.util.Map<BlockImageIcon.ImageLocation,BlockImageIcon> getInitBlockImageMap()
          Returns the initial BlockImageIcon mapping of this.
 java.lang.String getInitialLabel()
          Returns the initial label of this FORWARDED FROM BLOCK GENUS
 BlockConnector getInitPlug()
          Returns the initial plug connector of this FORWARDED FROM BLOCK GENUS
 java.lang.Iterable<BlockConnector> getInitSockets()
          Returns the initial set of sockets of this FORWARDED FROM BLOCK GENUS
 java.lang.String getLabelPrefix()
          Returns the String block label prefix of this FORWARDED FROM BLOCK GENUS
 java.lang.String getLabelSuffix()
          Returns the String block label prefix of this FORWARDED FROM BLOCK GENUS
 int getNumSockets()
          Returns the number of sockets of this
 java.lang.String getPageLabel()
          Returns the page label string of this
 BlockConnector getPlug()
          Returns the BlockConnector plug of this
 java.lang.Long getPlugBlockID()
          Return plug block id; null if plug does not exist
 java.lang.String getPlugKind()
          Return plug kind; null if plug does not exist
 java.lang.String getPlugLabel()
          Return plug label; null if plug does not exist
 java.lang.String getProperty(java.lang.String property)
          Returns the value of the specified language dependent property (partially) FORWARDED FROM BLOCK GENUS depending on specified property
 java.lang.String getSaveString(int x, int y, java.lang.String commentSaveString, boolean isCollapsed)
          Returns the save string of this using additional location information specified in x and y and comment text .
 java.util.List<java.lang.String> getSiblingsList()
          Returns the siblings of this genus.
 BlockConnector getSocketAt(int index)
          Returns the socket (BlockConnector instance) at the specified index
 int getSocketIndex(BlockConnector socket)
          Returns the index number of a given socket
 java.lang.Iterable<BlockConnector> getSockets()
          Returns an unmodifiable iterable over a safe copy of the Sockets of this
 java.lang.Object getState()
           
 java.lang.Iterable<java.lang.String> getStubList()
          Returns a list of the stub kinds (or stub genus names) of this; if this genus does not have any stubs, returns an empty list FORWARDED FROM BLOCK GENUS
 boolean hasAfterConnector()
          Returns true if this genus has a "after" connector; false otherwise.
 boolean hasBeforeConnector()
          Returns true if this genus has a "before" connector; false otherwise.
 boolean hasDefaultArgs()
          Returns true iff any one of the connectors for this genus has default arguments; false otherwise FORWARDED FROM BLOCK GENUS
 boolean hasFocus()
          Returns true iff this block has focus.
 int hashCode()
          Returns the hash code of this
 boolean hasPageLabel()
          Returns true iff this block has a page label and it is non-empty
 boolean hasPlug()
          Returns if BlockConnector plug exists
 boolean hasSiblings()
          Returns true if this genus has siblings; false otherwise.
 boolean hasStubs()
          Returns true is this genus has stubs (references such as getters, setters, etc.); false otherwise FORWARDED FROM BLOCK GENUS
 boolean isBad()
          Returns true iff this block is "bad." Bad means that this block has an associated compile error.
 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 isDeclaration()
          Returns true if this genus is a declaration block.
 boolean isFunctionBlock()
          Returns true iff this block is a function block, which takes in an input and produces an output.
 boolean isInfix()
          Returns true if this genus is infix (i.e.
 boolean isLabelEditable()
          Returns true if the label of this is editable; false otherwise FORWARDED FROM BLOCK GENUS
 boolean isLabelValue()
          Returns true if the value of this genus is contained within the label of this; false otherwise FORWARDED FROM BLOCK GENUS
 boolean isListRelated()
          Returns true if this block is a list or a list operator (determined by whether it has at least one list connector of any type); false otherwise.
 boolean isPageLabelSetByPage()
          Returns true iff page label of this is set by a page FORWARDED FROM BLOCK GENUS
 boolean isProcedureDeclBlock()
          Returns true if this block is a procedure declaration block; false otherwise FORWARDED FROM BLOCK GENUS
 boolean isProcedureParamBlock()
          Returns true if this block is a procedure parameter block; false otherwise.
 boolean isVariableDeclBlock()
          Returns true if this block is a variable block; false otherwise FORWARDED FROM BLOCK GENUS
 boolean labelMustBeUnique()
          Returns true if the label of this must be unique; false otherwise FORWARDED FROM BLOCK GENUS
 java.lang.Iterable<java.lang.Long> linkAllDefaultArgs()
          Links all the default arguments specified in the BlockGenus of this to the specified sockets of this block.
static Block loadBlockFrom(org.w3c.dom.Node node, java.util.HashMap<java.lang.Long,java.lang.Long> idMapping)
          Loads Block information from the specified node and return a Block instance with the loaded information
 void loadState(java.lang.Object memento)
           
 void notifyRenderable()
          Notifies the "views" (in this case the RenderableBlock) of any changes to the Block data that would need an immediate visual update.
(package private)  void removeBeforeAndAfter()
          Removes the before and after connectors.
(package private)  void removePlug()
          Removes the plug.
 void removeSocket(BlockConnector socket)
          Removes specified socket
 void removeSocket(int index)
          Removes the socket at the specified index
static void reset()
          Clears all block instances and resets id assigment.
(package private)  void resetBeforeAndAfter()
          Resets the before and after connectors to their initial kinds.
 void setBad(boolean isBad)
          Sets the "bad"-ness of this block.
 void setBadMsg(java.lang.String badMsg)
          Sets the message describing this block's badness.
 void setBlockLabel(java.lang.String newLabel)
          Sets the block label of this iff this block label is editable
 void setFocus(boolean hasFocus)
          Sets the focus state of the block.
 void setPageLabel(java.lang.String newPageLabel)
          Sets the page label of this
 void setPlug(java.lang.String kind, BlockConnector.PositionType positionType, java.lang.String label, boolean isLabelEditable, java.lang.Long blockID)
          Sets the plug of this.
 void setPlugBlockID(java.lang.Long id)
          Sets the block attached to this plug
 void setPlugKind(java.lang.String kind)
          Sets the plug kind of this
 void setPlugLabel(java.lang.String label)
          Sets the plug label of this
 boolean setProperty(java.lang.String property, java.lang.String value)
          Sets the block property with the specified property and value.
 boolean setSocketAt(int index, java.lang.String kind, BlockConnector.PositionType pos, java.lang.String label, boolean isLabelEditable, boolean isExpandable, java.lang.Long blockID)
          Replaces the socket at the specified index with the new specified parameters
 java.lang.String toString()
           
static java.lang.Long translateLong(java.lang.Long input, java.util.HashMap<java.lang.Long,java.lang.Long> mapping)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final java.lang.Long NULL
Constructor Detail

Block

protected Block(java.lang.Long id,
                java.lang.String genusName,
                java.lang.String label,
                boolean linkToStubs)
Constructs a new Block from the specified information. This class constructor is protected as block loading from XML content or the (careful!) creation of its subclasses should override BlockID assignment.

Parameters:
id - the Block ID of this
genusName - the String name of this block's BlockGenus
label - the String label of this Block

Block

public Block(java.lang.String genusName,
             java.lang.String label,
             boolean linkToStubs)
Constructs a new Block instance. Using the genusName specified of this Block's corresponding BlockGenus, this constructor populates this Block with its genus information.

Parameters:
genusName - the name of its associated BlockGenus
label - the label of this Block.
linkToStubs - if true, this block can have stubs and be linked to them; if false, then this block even though the genus specifies it will not be linked to stubs

Block

public Block(java.lang.String genusName,
             java.lang.String label)
Constructs a new Block instance. Using the genusName specified of this Block's corresponding BlockGenus, this constructor populates this Block with its genus information.

Parameters:
genusName - the name of its associated BlockGenus
label - the label of this Block.

Block

public Block(java.lang.String genusName)
Constructs a new Block instance. Using the genusName specified of this Block's corresponding BlockGenus, this constructor populates this Block with its genus information.

Parameters:
genusName - the name of its associated BlockGenus

Block

public Block(java.lang.String genusName,
             boolean linkToStubs)
Constructs a new Block instance. Using the genusName specified of this Block's corresponding BlockGenus, this constructor populates this Block with its genus information.

Parameters:
genusName - the name of its associated BlockGenus
linkToStubs - if true, this block can have stubs and be linked to them; if false, then this block even though the genus specifies it will not be linked to stubs
Method Detail

getBlock

public static Block getBlock(java.lang.Long blockID)
Returns the Block instance with the specified blockID

Parameters:
blockID -
Returns:
the Block instance with the specified blockID

reset

public static void reset()
Clears all block instances and resets id assigment.


getBlockID

public java.lang.Long getBlockID()
Returns the block ID of this

Returns:
the block ID of this

setProperty

public boolean setProperty(java.lang.String property,
                           java.lang.String value)
Sets the block property with the specified property and value. If this block's genus already contains a value with the same property, then the specified property will not be added to this block's property collection.

Parameters:
property - the property key to set
value - the value associated with this property
Returns:
true if this property was set successfully

getBlockLabel

public java.lang.String getBlockLabel()
Returns the block label of this

Returns:
the block label of this

hasPageLabel

public boolean hasPageLabel()
Returns true iff this block has a page label and it is non-empty

Returns:
true iff this block has a page label and it is non-empty

getPageLabel

public java.lang.String getPageLabel()
Returns the page label string of this

Returns:
the page label string of this

setBlockLabel

public void setBlockLabel(java.lang.String newLabel)
Sets the block label of this iff this block label is editable

Parameters:
newLabel - the desired label

setPageLabel

public void setPageLabel(java.lang.String newPageLabel)
Sets the page label of this

Parameters:
newPageLabel - the desired page label

changeGenusTo

public void changeGenusTo(java.lang.String genusName)
Changes the genus of this block, while maintaining this current blocks relationships with other blocks it's connected to.

Parameters:
genusName - the String name of the BlockGenus to change this Block to

getBeforeBlockID

public java.lang.Long getBeforeBlockID()
Returns the Block ID connected to the before connector of this; Block.Null if this does not have a before block

Returns:
the Block ID connected to the before connector of this; Block.Null if this does not have a before block

getAfterBlockID

public java.lang.Long getAfterBlockID()
Returns the Block ID connected to the after connector of this; Block.Null if this does not have an after block

Returns:
the Block ID connected to the after connector of this; Block.Null if this does not have an after block

getAfterConnector

public BlockConnector getAfterConnector()
Returns the BlockConnector representing the connection to the block after this

Returns:
the BlockConnector of the after connector

getBeforeConnector

public BlockConnector getBeforeConnector()
Returns the BlockConnector representing the connection to the block before this

Returns:
the BlockConnector of the before connector

resetBeforeAndAfter

void resetBeforeAndAfter()
Resets the before and after connectors to their initial kinds. Only privileged classes (ie. BlockStub) should call this method.


removeBeforeAndAfter

void removeBeforeAndAfter()
Removes the before and after connectors. Only privileged classes (ie. BlockStub) should call this method.


blockConnected

public void blockConnected(BlockConnector connectedSocket,
                           java.lang.Long connectedBlockID)
Informs this Block that a block with id connectedBlockID has connected to the specified connectedSocket


blockDisconnected

public void blockDisconnected(BlockConnector disconnectedSocket)
Informs this Block that a block has disconnected from the specified disconnectedSocket

Parameters:
disconnectedSocket -

getSockets

public java.lang.Iterable<BlockConnector> getSockets()
Returns an unmodifiable iterable over a safe copy of the Sockets of this

Returns:
an unmodifiable iterable over a safe copy of the Sockets of this

getNumSockets

public int getNumSockets()
Returns the number of sockets of this

Returns:
the number of sockets of this

getSocketAt

public BlockConnector getSocketAt(int index)
Returns the socket (BlockConnector instance) at the specified index

Parameters:
index - the index of the desired socket. 0 <= index < getNumSockets()
Returns:
the socket (BlockConnector instance) at the specified index

setSocketAt

public boolean setSocketAt(int index,
                           java.lang.String kind,
                           BlockConnector.PositionType pos,
                           java.lang.String label,
                           boolean isLabelEditable,
                           boolean isExpandable,
                           java.lang.Long blockID)
Replaces the socket at the specified index with the new specified parameters

Parameters:
index - of the BlockConnector to replace
isLabelEditable - is true iff this BlockConnector can have its labels edited.
Returns:
true if socket successfully replaced

getSocketIndex

public int getSocketIndex(BlockConnector socket)
Returns the index number of a given socket

Parameters:
socket - a socket of this block
Returns:
the index number of a given socket or -1 if socket doesn't exists on the block

addSocket

public void addSocket(java.lang.String kind,
                      BlockConnector.PositionType positionType,
                      java.lang.String label,
                      boolean isLabelEditable,
                      boolean isExpandable,
                      java.lang.Long blockID)
Adds another socket to this. Socket is added to the "end" of socket list.

Parameters:
kind - the socket kind of new socket
label - the label of the new socket
positionType - the BlockConnector.PositionType of the new connector
isLabelEditable - is true iff this BlockConnector can have its labels edited.
isExpandable - true iff this connector can expand to another connector
blockID - the block id of the block attached to new socket

addSocket

public BlockConnector addSocket(int index,
                                java.lang.String kind,
                                BlockConnector.PositionType positionType,
                                java.lang.String label,
                                boolean isLabelEditable,
                                boolean isExpandable,
                                java.lang.Long blockID)
Adds another socket to this. Socket is inserted at the specified index of socket list, where 0 is the first socket. if index is equal numOfSockets(), then socket is added to the end of the socket list. If index > numOfSockets(), an exception is thrown.

Parameters:
index - the index to insert new socket to
kind - the socket kind of new socket
label - the label of the new socket
positionType - the BlockConnector.PositionType of the new connector
isLabelEditable - is true iff this BlockConnector can have its labels edited.
isExpandable - true iff this connector can expand to another connector
blockID - the block id of the block attached to new socket

removeSocket

public void removeSocket(int index)
Removes the socket at the specified index

Parameters:
index - the index of the socket to remove

removeSocket

public void removeSocket(BlockConnector socket)
Removes specified socket

Parameters:
socket - BlockConnector to remove from this

hasPlug

public boolean hasPlug()
Returns if BlockConnector plug exists

Returns:
if BlockConnector plug exists

getPlug

public BlockConnector getPlug()
Returns the BlockConnector plug of this

Returns:
the BlockConnector plug of this

setPlug

public void setPlug(java.lang.String kind,
                    BlockConnector.PositionType positionType,
                    java.lang.String label,
                    boolean isLabelEditable,
                    java.lang.Long blockID)
Sets the plug of this.

Parameters:
kind - the socket kind of plug
label - the label of the plug
positionType - the BlockConnector.PositionType of this plug
isLabelEditable - is true iff this BlockConnector can have its labels edited.
blockID - the block id of the block attached to plug

setPlugKind

public void setPlugKind(java.lang.String kind)
Sets the plug kind of this

Parameters:
kind - the desired plug kind

setPlugLabel

public void setPlugLabel(java.lang.String label)
Sets the plug label of this

Parameters:
label - the desired plug label

setPlugBlockID

public void setPlugBlockID(java.lang.Long id)
Sets the block attached to this plug

Parameters:
id - the block id to attach to this plug

getPlugKind

public java.lang.String getPlugKind()
Return plug kind; null if plug does not exist

Returns:
plug kind; null if plug does not exist

getPlugLabel

public java.lang.String getPlugLabel()
Return plug label; null if plug does not exist

Returns:
plug label; null if plug does not exist

getPlugBlockID

public java.lang.Long getPlugBlockID()
Return plug block id; null if plug does not exist

Returns:
plug block id; null if plug does not exist

removePlug

void removePlug()
Removes the plug.


getConnectorTo

public BlockConnector getConnectorTo(java.lang.Long otherBlockID)
Searches for the BlockConnector linking this block to another block

Parameters:
otherBlockID - the Block ID if the other block
Returns:
the BlockConnector linking this block to the other block

isBad

public boolean isBad()
Returns true iff this block is "bad." Bad means that this block has an associated compile error.


setBad

public void setBad(boolean isBad)
Sets the "bad"-ness of this block. Bad means that this block has an associated compile error.

Parameters:
isBad -

getBadMsg

public java.lang.String getBadMsg()
Returns the "bad" message of this block.


setBadMsg

public void setBadMsg(java.lang.String badMsg)
Sets the message describing this block's badness. In other words, the message describes the compile error associated with this block.

Parameters:
badMsg -

hasFocus

public boolean hasFocus()
Returns true iff this block has focus. Focus means it is currently selected in the workspace. Multiple blocks can have focus simultaniously.


setFocus

public void setFocus(boolean hasFocus)
Sets the focus state of the block. Should only be used by FocusManager.

Parameters:
hasFocus -

linkAllDefaultArgs

public java.lang.Iterable<java.lang.Long> linkAllDefaultArgs()
Links all the default arguments specified in the BlockGenus of this to the specified sockets of this block. By default a new Block does not have default arguments attached. Each index in the Long list corresponds to the index of the socket the default argument is attached to. If an element in this list is Block.NULL, then no default argument exists for that socket or there already is a block attached at that socket. Default arguments are linked whenever a block is dragged to the workspace for the first time

Returns:
Returns a Long list of the newly created default argument block IDs; null if this block has none.

getFreshStubs

public java.lang.Iterable<BlockStub> getFreshStubs()
Returns the Stubs of this Block, if it has Stubs; null otherwise

Returns:
the Stubs of this Block, if it has Stubs; null otherwise

notifyRenderable

public void notifyRenderable()
Notifies the "views" (in this case the RenderableBlock) of any changes to the Block data that would need an immediate visual update. note: to be used only if there is no other convenient way to update view of an event/change to the block data from the ui side


getSiblingsList

public java.util.List<java.lang.String> getSiblingsList()
Returns the siblings of this genus. If this does not have siblings, returns an empty list. Each element in the list is the block genus name of a sibling. FORWARDED FROM BLOCK GENUS

Returns:
the siblings of this genus.

hasSiblings

public boolean hasSiblings()
Returns true if this genus has siblings; false otherwise. Note: For a genus to have siblings, its label must be uneditable. An editable label interferes with the drop down menu widget that blocks with siblings have. FORWARDED FROM BLOCK GENUS

Returns:
true if this genus has siblings; false otherwise.

getStubList

public java.lang.Iterable<java.lang.String> getStubList()
Returns a list of the stub kinds (or stub genus names) of this; if this genus does not have any stubs, returns an empty list FORWARDED FROM BLOCK GENUS

Returns:
a list of the stub kinds (or stub genus names) of this; if this genus does not have any stubs, returns an empty list

hasStubs

public boolean hasStubs()
Returns true is this genus has stubs (references such as getters, setters, etc.); false otherwise FORWARDED FROM BLOCK GENUS

Returns:
true is this genus has stubs (references such as getters, setters, etc.); false otherwise

hasDefaultArgs

public boolean hasDefaultArgs()
Returns true iff any one of the connectors for this genus has default arguments; false otherwise FORWARDED FROM BLOCK GENUS

Returns:
true iff any one of the connectors for this genus has default arguments; false otherwise

isCommandBlock

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

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

isDataBlock

public 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

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()
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

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.

isVariableDeclBlock

public boolean isVariableDeclBlock()
Returns true if this block is a variable block; false otherwise FORWARDED FROM BLOCK GENUS

Returns:
true if this block is a variable block; false otherwise

isProcedureDeclBlock

public boolean isProcedureDeclBlock()
Returns true if this block is a procedure declaration block; false otherwise FORWARDED FROM BLOCK GENUS

Returns:
true if this block is a procedure declaration block; false otherwise

isDeclaration

public boolean isDeclaration()
Returns true if this genus is a declaration block. Declaration blocks define variables and procedures. FORWARDED FROM BLOCK GENUS

Returns:
true if this genus is a declaration block; false otherwise

isProcedureParamBlock

public boolean isProcedureParamBlock()
Returns true if this block is a procedure parameter block; false otherwise. FORWARDED FROM BLOCK GENUS


isListRelated

public boolean isListRelated()
Returns true if this block is a list or a list operator (determined by whether it has at least one list connector of any type); false otherwise.

Returns:
is determined by whether it has at least one list connector of any type. FORWARDED FROM BLOCK GENUS

hasBeforeConnector

public boolean hasBeforeConnector()
Returns true if this genus has a "before" connector; false otherwise. FORWARDED FROM BLOCK GENUS

Returns:
true is this genus has a "before" connector; false otherwise.

hasAfterConnector

public boolean hasAfterConnector()
Returns true if this genus has a "after" connector; false otherwise. FORWARDED FROM BLOCK GENUS

Returns:
true if this genus has a "after" connector; false otherwise.

getInitBefore

public BlockConnector getInitBefore()
Returns the initial before connector of this FORWARDED FROM BLOCK GENUS

Returns:
the initial before connector of this

getInitAfter

public BlockConnector getInitAfter()
Returns the initial after connector of this FORWARDED FROM BLOCK GENUS

Returns:
the initial after connector of this

isLabelValue

public boolean isLabelValue()
Returns true if the value of this genus is contained within the label of this; false otherwise FORWARDED FROM BLOCK GENUS

Returns:
true if the value of this genus is contained within the label of this; false otherwise

isLabelEditable

public boolean isLabelEditable()
Returns true if the label of this is editable; false otherwise FORWARDED FROM BLOCK GENUS

Returns:
true if the label of this is editable; false otherwise

isPageLabelSetByPage

public boolean isPageLabelSetByPage()
Returns true iff page label of this is set by a page FORWARDED FROM BLOCK GENUS

Returns:
true iff page label of this is set by a page

labelMustBeUnique

public boolean labelMustBeUnique()
Returns true if the label of this must be unique; false otherwise FORWARDED FROM BLOCK GENUS

Returns:
true if the label of this must be unique; false otherwise

isInfix

public boolean isInfix()
Returns true if this genus is infix (i.e. math blocks, and/or blocks); false otherwise FORWARDED FROM BLOCK GENUS

Returns:
true if this genus is infix (i.e. math blocks, and/or blocks); false otherwise

areSocketsExpandable

public boolean areSocketsExpandable()
Returns true if this genus has expandable sockets; false otherwise FORWARDED FROM BLOCK GENUS

Returns:
true if this genus has expandable sockets; false otherwise

getGenusName

public java.lang.String getGenusName()
Returns the name of this genus FORWARDED FROM BLOCK GENUS

Returns:
the name of this genus

getInitialLabel

public java.lang.String getInitialLabel()
Returns the initial label of this FORWARDED FROM BLOCK GENUS

Returns:
the initial label of this

getLabelPrefix

public java.lang.String getLabelPrefix()
Returns the String block label prefix of this FORWARDED FROM BLOCK GENUS

Returns:
the String block label prefix of this

getLabelSuffix

public java.lang.String getLabelSuffix()
Returns the String block label prefix of this FORWARDED FROM BLOCK GENUS

Returns:
the String block label prefix of this

getBlockDescription

public java.lang.String getBlockDescription()
Returns the String block text description of this. Also known as the block tool tip, or block description. If no descriptions exists, return null. FORWARDED FROM BLOCK GENUS


getArgumentDescription

public java.lang.String getArgumentDescription(int index)
Returns the the argument description at index i. If the index is out of bounds or if no argument description exists for arguemnt at index i , return null.


getColor

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

Returns:
the Color of this; May return Color.Black if color was unspecified.

getInitBlockImageMap

public java.util.Map<BlockImageIcon.ImageLocation,BlockImageIcon> getInitBlockImageMap()
Returns the initial BlockImageIcon mapping of this. Returned Map is unmodifiable. FORWARDED FROM BLOCK GENUS

Returns:
the initial and unmodifiable BlockImageIcon mapping of this

getProperty

public java.lang.String getProperty(java.lang.String property)
Returns the value of the specified language dependent property (partially) FORWARDED FROM BLOCK GENUS depending on specified property

Parameters:
property - the property to look up
Returns:
the value of the specified language dependent property; null if property does not exist

getInitSockets

public java.lang.Iterable<BlockConnector> getInitSockets()
Returns the initial set of sockets of this FORWARDED FROM BLOCK GENUS

Returns:
the initial set of sockets of this

getInitPlug

public BlockConnector getInitPlug()
Returns the initial plug connector of this FORWARDED FROM BLOCK GENUS

Returns:
the initial plug connector of this

toString

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

equals

public boolean equals(java.lang.Object other)
Returns true iff the other Object is an instance of Block and has the same blockID as this; false otherwise

Overrides:
equals in class java.lang.Object
Returns:
true iff the other Object is an instance of Block and has the same blockID as this; false otherwise

hashCode

public int hashCode()
Returns the hash code of this

Overrides:
hashCode in class java.lang.Object
Returns:
hash code of this

escape

public static java.lang.String escape(java.lang.String s)
Returns an escaped (safe) version of string.


getSaveString

public java.lang.String getSaveString(int x,
                                      int y,
                                      java.lang.String commentSaveString,
                                      boolean isCollapsed)
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.

Parameters:
x -
y -
Returns:
the save string of this

loadBlockFrom

public static Block loadBlockFrom(org.w3c.dom.Node node,
                                  java.util.HashMap<java.lang.Long,java.lang.Long> idMapping)
Loads Block information from the specified node and return a Block instance with the loaded information

Parameters:
node - Node cantaining desired information
Returns:
Block instance containing loaded information

translateLong

public static java.lang.Long translateLong(java.lang.Long input,
                                           java.util.HashMap<java.lang.Long,java.lang.Long> mapping)

getAllBlocks

public static java.lang.Iterable<Block> getAllBlocks()

getState

public java.lang.Object getState()
Specified by:
getState in interface ISupportMemento

loadState

public void loadState(java.lang.Object memento)
Specified by:
loadState in interface ISupportMemento