Class: AbstractTextDrawBridge

Kekule.Render. AbstractTextDrawBridge

new AbstractTextDrawBridge()

Different renderer should provide different methods to draw text. Those different implementations are wrapped in draw bridge classes. Concrete bridge classes do not need to deprived from this class, but they do need to implement all those essential methods. NOTE: Methods of the bridge (measureText, drawText, etc.) only need to handle left to right text.
Source:

Methods

addToGroup(elem, group)

Add an element to an existing group. Descendants or bridge should override this method.
Parameters:
Name Type Description
elem Object
group Object
Source:

canMeasureDrawnText(context) → {Bool}

Indicate whether this bridge and context can measure text dimension before drawing it. Raphael is a typical environment of this type. Such a bridge must also has the ability to modify text pos after drawn.
Parameters:
Name Type Description
context Object
Source:
Returns:
Type
Bool

canMeasureText(context) → {Bool}

Indicate whether this bridge and context can measure text dimension before drawing it. HTML Canvas is a typical environment of this type.
Parameters:
Name Type Description
context Object
Source:
Returns:
Type
Bool

canModifyText(context) → {Bool}

Indicate whether this bridge and context can change text content or position after drawing it. Raphael is a typical environment of this type.
Parameters:
Name Type Description
context Object
Source:
Returns:
Type
Bool

createGroup(context) → {Object}

Create a group to store render elements. Descendants or bridge should override this method. Note that not all bridge (like canvas) support group.
Parameters:
Name Type Description
context Object
Source:
Returns:
Type
Object

drawText(context, coord, text, options) → {Object}

Draw a plain text on context.
Parameters:
Name Type Description
context Object
coord Object The top left coord to draw text.
text Object
options Object Draw options, may contain the following fields: {fontSize, fontFamily, color, rotation(based on coord)}
Source:
Returns:
Null or element drawn on context.
Type
Object

measureDrawnText(context, textElem, options) → {Hash}

Mearsure the width and height of text on context after drawing it.
Parameters:
Name Type Description
context Object
textElem Object Drawn text element on context.
options Object
Source:
Returns:
An object with width and height fields, top and left is optional.
Type
Hash

measureText(context, text, options) → {Hash}

Mearsure the width and height of text on context before drawing it.
Parameters:
Name Type Description
context Object
text Object
options Object
Source:
Returns:
An object with width and height fields.
Type
Hash

modifyDrawnTextCoord(context, textElem, newCoord)

Change text drawn on context to a new coord. Not all context can apply this action.
Parameters:
Name Type Description
context Object
textElem Object
newCoord Hash The top left coord of text box.
Source:

removeFromGroup(elem, group)

Remove an element to from existing group. Descendants or bridge should override this method.
Parameters:
Name Type Description
elem Object
group Object
Source: