codeblocks
Class BlockShape

java.lang.Object
  extended by codeblocks.BlockShape
Direct Known Subclasses:
InfixBlockShape

public class BlockShape
extends java.lang.Object

This class separates block shape from the RenderableBlock class. BlockShape uses information from RenderableBlock to determine shape and dimensions of the block being drawn. BlockShape does not know where it is in the world -- all coords are local.


Field Summary
protected static BlockConnectorShape BCS
          Draws the individual connectors.
protected  Block block
          The Block associated to this BlockShape
protected  java.awt.Rectangle blockBody
          Body of the block
protected  float blockCornerRadius
           
protected  long blockID
          The blockID associated to this BlockShape
protected  java.awt.geom.Point2D botLeftCorner
           
protected  java.awt.geom.Point2D botRightCorner
           
static float BOTTOM_SOCKET_MIDDLE_SPACER
          spacer for in between bottom sockets
static float BOTTOM_SOCKET_SIDE_SPACER
          spacer for bottom sockets to block sides and other bottom sockets
static float BOTTOM_SOCKET_UPPER_SPACER
          spacer on top of bottom sockets to give continuous top
protected static BlockShapeUtil BSU
          Tools to draw block shape.
static float COMMAND_PORT_OFFSET
          left alignment buffer for command ports
static float CORNER_RADIUS
          radius of rounded corners
protected  java.awt.geom.GeneralPath gpBottom
          Outline of bottom-left conrner, bottom edge, and bottom-right corner (Counter-Clockwise)
protected  boolean hasCurvedCorners
          block properties determining shape
protected  RenderableBlock rb
          The RenderableBlock associated to this BlockShape
protected  java.awt.geom.Point2D topLeftCorner
           
protected  java.awt.geom.Point2D topRightCorner
           
static float VARIABLE_DECLARATION_SPACER
          variable declaration spacer
 
Constructor Summary
BlockShape(RenderableBlock rb)
          BlockShape constructor
 
Method Summary
static void addCustomShapes(CustomBlockShapeSet cbs)
          Add a new set of custom shapes
protected  int determineBlockHeight()
          Determines the height of a block by summing it's socket heights OR plug height if no sockets TODO: this contains a lot of starlogo specific checks - should be refactored into slcodeblocks?
protected  int determineBlockWidth()
          Determines the width of the block by checking for numerous block characteristics TODO: this contains a lot of starlogo specific checks - should be refactored into slcodeblocks?
protected  java.awt.geom.GeneralPath getBottomSide()
          Returns the GeneralPath of the bottom side of this block shape.
protected  java.awt.geom.GeneralPath getLeftSide()
          Returns the GeneralPath of the left side of this block shape.
protected  java.awt.geom.GeneralPath getRightSide()
          Returns the GeneralPath of the right side of this block shape.
protected  int getSocketSpacerHeight(BlockConnector socket, float defaultHeight)
          Returns the height of the spacer associated with a socket if it exists, else it returns the given default height.
protected  java.awt.geom.GeneralPath getTopSide()
          Returns the GeneralPath of the top side of this block shape.
protected  int getTotalHeightOfSockets()
          Returns the total height of this blocks sockets based on connector shape and position type; 0 if this block has no sockets
protected  void makeBottomSide()
           
protected  void makeLeftSide()
           
protected  void makeRightSide()
           
protected  void makeTopSide()
           
 java.awt.geom.Area reformArea()
          Reform the BlockShape area.
protected  void setEndPoint(java.awt.geom.GeneralPath gp, java.awt.geom.Point2D currentCorner, java.awt.geom.Point2D otherCorner, boolean firstPointOnSide)
          Sets the end point for a particular side of a block.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BCS

protected static BlockConnectorShape BCS
Draws the individual connectors. Shouldn't need more than one of these


BSU

protected static BlockShapeUtil BSU
Tools to draw block shape. Shouldn't need more than one of these


rb

protected RenderableBlock rb
The RenderableBlock associated to this BlockShape


blockID

protected long blockID
The blockID associated to this BlockShape


block

protected Block block
The Block associated to this BlockShape


COMMAND_PORT_OFFSET

public static final float COMMAND_PORT_OFFSET
left alignment buffer for command ports

See Also:
Constant Field Values

CORNER_RADIUS

public static final float CORNER_RADIUS
radius of rounded corners

See Also:
Constant Field Values

VARIABLE_DECLARATION_SPACER

public static final float VARIABLE_DECLARATION_SPACER
variable declaration spacer

See Also:
Constant Field Values

BOTTOM_SOCKET_SIDE_SPACER

public static final float BOTTOM_SOCKET_SIDE_SPACER
spacer for bottom sockets to block sides and other bottom sockets

See Also:
Constant Field Values

BOTTOM_SOCKET_MIDDLE_SPACER

public static final float BOTTOM_SOCKET_MIDDLE_SPACER
spacer for in between bottom sockets

See Also:
Constant Field Values

BOTTOM_SOCKET_UPPER_SPACER

public static final float BOTTOM_SOCKET_UPPER_SPACER
spacer on top of bottom sockets to give continuous top

See Also:
Constant Field Values

gpBottom

protected java.awt.geom.GeneralPath gpBottom
Outline of bottom-left conrner, bottom edge, and bottom-right corner (Counter-Clockwise)


blockBody

protected java.awt.Rectangle blockBody
Body of the block


topLeftCorner

protected java.awt.geom.Point2D topLeftCorner

topRightCorner

protected java.awt.geom.Point2D topRightCorner

botLeftCorner

protected java.awt.geom.Point2D botLeftCorner

botRightCorner

protected java.awt.geom.Point2D botRightCorner

hasCurvedCorners

protected boolean hasCurvedCorners
block properties determining shape


blockCornerRadius

protected float blockCornerRadius
Constructor Detail

BlockShape

public BlockShape(RenderableBlock rb)
BlockShape constructor

Parameters:
rb -
Method Detail

determineBlockWidth

protected int determineBlockWidth()
Determines the width of the block by checking for numerous block characteristics TODO: this contains a lot of starlogo specific checks - should be refactored into slcodeblocks?


getTotalHeightOfSockets

protected int getTotalHeightOfSockets()
Returns the total height of this blocks sockets based on connector shape and position type; 0 if this block has no sockets

Returns:
the total height of this blocks sockets based on connector shape and position type; 0 if this block has no sockets

determineBlockHeight

protected int determineBlockHeight()
Determines the height of a block by summing it's socket heights OR plug height if no sockets TODO: this contains a lot of starlogo specific checks - should be refactored into slcodeblocks?


makeTopSide

protected void makeTopSide()

makeRightSide

protected void makeRightSide()

makeLeftSide

protected void makeLeftSide()

makeBottomSide

protected void makeBottomSide()

setEndPoint

protected void setEndPoint(java.awt.geom.GeneralPath gp,
                           java.awt.geom.Point2D currentCorner,
                           java.awt.geom.Point2D otherCorner,
                           boolean firstPointOnSide)
Sets the end point for a particular side of a block. firstPointOnSide == true : Used to "moveTo" first point of a side, firstPointOnSide == false : "lineTo" the last point of a side.


getSocketSpacerHeight

protected int getSocketSpacerHeight(BlockConnector socket,
                                    float defaultHeight)
Returns the height of the spacer associated with a socket if it exists, else it returns the given default height.


getBottomSide

protected java.awt.geom.GeneralPath getBottomSide()
Returns the GeneralPath of the bottom side of this block shape.

Returns:
the GeneralPath of the bottom side of this block shape.

getLeftSide

protected java.awt.geom.GeneralPath getLeftSide()
Returns the GeneralPath of the left side of this block shape.

Returns:
the GeneralPath of the left side of this block shape.

getTopSide

protected java.awt.geom.GeneralPath getTopSide()
Returns the GeneralPath of the top side of this block shape.

Returns:
the GeneralPath of the top side of this block shape.

getRightSide

protected java.awt.geom.GeneralPath getRightSide()
Returns the GeneralPath of the right side of this block shape.

Returns:
the GeneralPath of the right side of this block shape.

reformArea

public java.awt.geom.Area reformArea()
Reform the BlockShape area. This is the major procedure that makes all of the sides combines them in their correct directions, and connects them so they are all one direction.

Returns:
reformed Area of the BlockShape

addCustomShapes

public static void addCustomShapes(CustomBlockShapeSet cbs)
Add a new set of custom shapes