BlockView

public class BlockView extends AbstractBlockView<InputView>

Draws a block and handles laying out all its inputs/fields.

Inherited Constant Summary

Inherited Field Summary

Protected Constructor Summary

BlockView(Context context, WorkspaceHelper helper, VerticalBlockViewFactory factory, Block block, List<InputView> inputViews, ConnectionManager connectionManager, BlockTouchHandler touchHandler)
Create a new BlockView and associated InputViews for the given block using the WorkspaceHelper's provided style.

Public Method Summary

ColorFilter
int
int
void
onLayout(boolean changed, int left, int top, int right, int bottom)
void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)
Measure all children (i.e., block inputs) and compute their sizes and relative positions for use in onLayout(boolean, int, int, int, int).

Protected Method Summary

boolean
coordinatesAreOnBlock(int x, int y)
Checks if the coordinates (relative to this view) exist on a visible part of this view.
void
dispatchDraw(Canvas canvas)
Draw highlights and connector locators (if any) over above all child views.
void
onBlockUpdated(int updateMask)
Called when a block's inputs, fields, comment, or mutator is/are updated, and thus the shape may have changed.
void
onDraw(Canvas c)

Inherited Method Summary

Protected Constructors

protected BlockView (Context context, WorkspaceHelper helper, VerticalBlockViewFactory factory, Block block, List<InputView> inputViews, ConnectionManager connectionManager, BlockTouchHandler touchHandler)

Create a new BlockView and associated InputViews for the given block using the WorkspaceHelper's provided style.

App developers should not call this constructor directly. Instead use buildBlockViewTree(Block, BlockGroup, ConnectionManager, BlockTouchHandler).

Parameters
context The context for creating this view.
helper The WorkspaceHelper that manages the block sizes on in this Activity.
factory The VerticalBlockViewFactory that is building this view.
block The Block represented by this view.
inputViews The InputView contained in this view.
connectionManager The ConnectionManager to update when moving connections.
touchHandler The optional handler for forwarding touch events on this block to the Dragger.

Public Methods

public ColorFilter getColorFilter ()

Returns
  • The ColorFilter that applies the block's color to grayscale resources.

public int getNextBlockVerticalOffset ()

Returns
  • Vertical offset for positioning the "Next" block (if one exists). This is relative to the top of this view's area.

public int getOutputConnectorMargin ()

Returns
  • Layout margin on the left-hand side of the block (for optional Output connector).

public void onLayout (boolean changed, int left, int top, int right, int bottom)

Parameters
changed
left
top
right
bottom

public void onMeasure (int widthMeasureSpec, int heightMeasureSpec)

Measure all children (i.e., block inputs) and compute their sizes and relative positions for use in onLayout(boolean, int, int, int, int).

Parameters
widthMeasureSpec
heightMeasureSpec

Protected Methods

protected boolean coordinatesAreOnBlock (int x, int y)

Checks if the coordinates (relative to this view) exist on a visible part of this view.

Parameters
x the x coordinate relative to this view.
y the y coordinate relative to this view.
Returns
  • true if coordinates provided are on this block or it's inputs.

protected void dispatchDraw (Canvas canvas)

Draw highlights and connector locators (if any) over above all child views.

protected void onBlockUpdated (int updateMask)

Called when a block's inputs, fields, comment, or mutator is/are updated, and thus the shape may have changed.

Parameters
updateMask A bit mask denoting Block.UpdateState changes.

protected void onDraw (Canvas c)

Parameters
c