mxText

Extends mxShape to implement a text shape.  To change vertical text from bottom to top to top to bottom, the following code can be used:

mxText.prototype.verticalTextRotation = 90;
Summary
mxTextExtends mxShape to implement a text shape.
Functions
mxTextConstructs a new text shape.
Variables
baseSpacingTopSpecifies the spacing to be added to the top spacing.
baseSpacingBottomSpecifies the spacing to be added to the bottom spacing.
baseSpacingLeftSpecifies the spacing to be added to the left spacing.
baseSpacingRightSpecifies the spacing to be added to the right spacing.
replaceLinefeedsSpecifies if linefeeds in HTML labels should be replaced with BR tags.
verticalTextRotationRotation for vertical text.
ignoreClippedStringSizeSpecifies if the string size should be measured in updateBoundingBox if the label is clipped and the label position is center and middle.
ignoreStringSizeSpecifies if the actual string size should be measured.
textWidthPaddingSpecifies the padding to be added to the text width for the bounding box.
lastValueContains the last rendered text value.
cacheEnabledSpecifies if caching for HTML labels should be enabled.
Functions
isParseVmlText shapes do not contain VML markup and do not need to be parsed.
isHtmlAllowedReturns true if HTML is allowed for this shape.
getSvgScreenOffsetDisables offset in IE9 for crisper image output.
checkBoundsReturns true if the bounds are not null and all of its variables are numeric.
paintGeneric rendering code.
redrawRenders the text using the given DOM nodes.
resetStylesResets all styles.
applyExtends mxShape to update the text styles.
getAutoDirectionUsed to determine the automatic text direction.
getContentNodeReturns the node that contains the rendered input.
updateBoundingBoxUpdates the <boundingBox> for this shape using the given node and position.
getShapeRotationReturns 0 to avoid using rotation in the canvas via updateTransform.
getTextRotationReturns the rotation for the text label of the corresponding shape.
isPaintBoundsInvertedInverts the bounds if <mxShape.isBoundsInverted> returns true or if the horizontal style is false.
configureCanvasSets the state of the canvas for drawing the shape.
updateVmlContainerSets the width and height of the container to 1px.
getHtmlValuePrivate helper function to create SVG elements
getTextCssPrivate helper function to create SVG elements
redrawHtmlShapeUpdates the HTML node(s) to reflect the latest bounds and scale.
redrawHtmlShapeWithCss3Updates the HTML node(s) to reflect the latest bounds and scale.
updateHtmlTransformReturns the spacing as an mxPoint.
updateInnerHtmlSets the inner HTML of the given element to the <value>.
updateHtmlFilterRotated text rendering quality is bad for IE9 quirks/IE8 standards
updateValueUpdates the HTML node(s) to reflect the latest bounds and scale.
updateFontUpdates the HTML node(s) to reflect the latest bounds and scale.
updateSizeUpdates the HTML node(s) to reflect the latest bounds and scale.
getMarginReturns the spacing as an mxPoint.
getSpacingReturns the spacing as an mxPoint.

Functions

mxText

function mxText(value,
bounds,
align,
valign,
color,
family,
size,
fontStyle,
spacing,
spacingTop,
spacingRight,
spacingBottom,
spacingLeft,
horizontal,
background,
border,
wrap,
clipped,
overflow,
labelPadding,
textDirection)

Constructs a new text shape.

Parameters

valueString that represents the text to be displayed.  This is stored in <value>.
boundsmxRectangle that defines the bounds.  This is stored in mxShape.bounds.
alignSpecifies the horizontal alignment.  Default is ‘’.  This is stored in <align>.
valignSpecifies the vertical alignment.  Default is ‘’.  This is stored in <valign>.
colorString that specifies the text color.  Default is ‘black’.  This is stored in <color>.
familyString that specifies the font family.  Default is mxConstants.DEFAULT_FONTFAMILY.  This is stored in <family>.
sizeInteger that specifies the font size.  Default is mxConstants.DEFAULT_FONTSIZE.  This is stored in <size>.
fontStyleSpecifies the font style.  Default is 0.  This is stored in <fontStyle>.
spacingInteger that specifies the global spacing.  Default is 2.  This is stored in <spacing>.
spacingTopInteger that specifies the top spacing.  Default is 0.  The sum of the spacing and this is stored in <spacingTop>.
spacingRightInteger that specifies the right spacing.  Default is 0.  The sum of the spacing and this is stored in <spacingRight>.
spacingBottomInteger that specifies the bottom spacing.  Default is 0.The sum of the spacing and this is stored in <spacingBottom>.
spacingLeftInteger that specifies the left spacing.  Default is 0.  The sum of the spacing and this is stored in <spacingLeft>.
horizontalBoolean that specifies if the label is horizontal.  Default is true.  This is stored in <horizontal>.
backgroundString that specifies the background color.  Default is null.  This is stored in <background>.
borderString that specifies the label border color.  Default is null.  This is stored in <border>.
wrapSpecifies if word-wrapping should be enabled.  Default is false.  This is stored in <wrap>.
clippedSpecifies if the label should be clipped.  Default is false.  This is stored in <clipped>.
overflowValue of the overflow style.  Default is ‘visible’.

Variables

baseSpacingTop

mxText.prototype.baseSpacingTop

Specifies the spacing to be added to the top spacing.  Default is 0.  Use the value 5 here to get the same label positions as in mxGraph 1.x.

baseSpacingBottom

mxText.prototype.baseSpacingBottom

Specifies the spacing to be added to the bottom spacing.  Default is 0.  Use the value 1 here to get the same label positions as in mxGraph 1.x.

baseSpacingLeft

mxText.prototype.baseSpacingLeft

Specifies the spacing to be added to the left spacing.  Default is 0.

baseSpacingRight

mxText.prototype.baseSpacingRight

Specifies the spacing to be added to the right spacing.  Default is 0.

replaceLinefeeds

mxText.prototype.replaceLinefeeds

Specifies if linefeeds in HTML labels should be replaced with BR tags.  Default is true.

verticalTextRotation

mxText.prototype.verticalTextRotation

Rotation for vertical text.  Default is -90 (bottom to top).

ignoreClippedStringSize

mxText.prototype.ignoreClippedStringSize

Specifies if the string size should be measured in updateBoundingBox if the label is clipped and the label position is center and middle.  If this is true, then the bounding box will be set to <bounds>.  Default is true.  ignoreStringSize has precedence over this switch.

ignoreStringSize

mxText.prototype.ignoreStringSize

Specifies if the actual string size should be measured.  If disabled the boundingBox will not ignore the actual size of the string, otherwise <bounds> will be used instead.  Default is false.

textWidthPadding

mxText.prototype.textWidthPadding

Specifies the padding to be added to the text width for the bounding box.  This is needed to make sure no clipping is applied to borders.  Default is 4 for IE 8 standards mode and 3 for all others.

lastValue

mxText.prototype.lastValue

Contains the last rendered text value.  Used for caching.

cacheEnabled

mxText.prototype.cacheEnabled

Specifies if caching for HTML labels should be enabled.  Default is true.

Functions

isParseVml

mxText.prototype.isParseVml = function()

Text shapes do not contain VML markup and do not need to be parsed.  This method returns false to speed up rendering in IE8.

isHtmlAllowed

mxText.prototype.isHtmlAllowed = function()

Returns true if HTML is allowed for this shape.  This implementation returns true if the browser is not in IE8 standards mode.

getSvgScreenOffset

mxText.prototype.getSvgScreenOffset = function()

Disables offset in IE9 for crisper image output.

checkBounds

mxText.prototype.checkBounds = function()

Returns true if the bounds are not null and all of its variables are numeric.

paint

mxText.prototype.paint = function(c,
update)

Generic rendering code.

redraw

mxText.prototype.redraw = function()

Renders the text using the given DOM nodes.

resetStyles

mxText.prototype.resetStyles = function()

Resets all styles.

apply

mxText.prototype.apply = function(state)

Extends mxShape to update the text styles.

Parameters

statemxCellState of the corresponding cell.

getAutoDirection

mxText.prototype.getAutoDirection = function()

Used to determine the automatic text direction.  Returns mxConstants.TEXT_DIRECTION_LTR or mxConstants.TEXT_DIRECTION_RTL depending on the contents of <value>.  This is not invoked for HTML, wrapped content or if <value> is a DOM node.

getContentNode

mxText.prototype.getContentNode = function()

Returns the node that contains the rendered input.

updateBoundingBox

mxText.prototype.updateBoundingBox = function()

Updates the <boundingBox> for this shape using the given node and position.

getShapeRotation

mxText.prototype.getShapeRotation = function()

Returns 0 to avoid using rotation in the canvas via updateTransform.

getTextRotation

mxText.prototype.getTextRotation = function()

Returns the rotation for the text label of the corresponding shape.

isPaintBoundsInverted

mxText.prototype.isPaintBoundsInverted = function()

Inverts the bounds if <mxShape.isBoundsInverted> returns true or if the horizontal style is false.

configureCanvas

mxText.prototype.configureCanvas = function(c,
x,
y,
w,
h)

Sets the state of the canvas for drawing the shape.

updateVmlContainer

mxText.prototype.updateVmlContainer = function()

Sets the width and height of the container to 1px.

getHtmlValue

mxText.prototype.getHtmlValue = function()

Private helper function to create SVG elements

getTextCss

mxText.prototype.getTextCss = function()

Private helper function to create SVG elements

redrawHtmlShape

mxText.prototype.redrawHtmlShape = function()

Updates the HTML node(s) to reflect the latest bounds and scale.

redrawHtmlShapeWithCss3

mxText.prototype.redrawHtmlShapeWithCss3 = function()

Updates the HTML node(s) to reflect the latest bounds and scale.

updateHtmlTransform

mxText.prototype.updateHtmlTransform = function()

Returns the spacing as an mxPoint.

updateInnerHtml

mxText.prototype.updateInnerHtml = function(elt)

Sets the inner HTML of the given element to the <value>.

updateHtmlFilter

mxText.prototype.updateHtmlFilter = function()

Rotated text rendering quality is bad for IE9 quirks/IE8 standards

updateValue

mxText.prototype.updateValue = function()

Updates the HTML node(s) to reflect the latest bounds and scale.

updateFont

mxText.prototype.updateFont = function(node)

Updates the HTML node(s) to reflect the latest bounds and scale.

updateSize

mxText.prototype.updateSize = function(node,
enableWrap)

Updates the HTML node(s) to reflect the latest bounds and scale.

getMargin

Returns the spacing as an mxPoint.

getSpacing

mxText.prototype.getSpacing = function()

Returns the spacing as an mxPoint.

Base class for all shapes.
function mxText(value,
bounds,
align,
valign,
color,
family,
size,
fontStyle,
spacing,
spacingTop,
spacingRight,
spacingBottom,
spacingLeft,
horizontal,
background,
border,
wrap,
clipped,
overflow,
labelPadding,
textDirection)
Constructs a new text shape.
mxText.prototype.baseSpacingTop
Specifies the spacing to be added to the top spacing.
mxText.prototype.baseSpacingBottom
Specifies the spacing to be added to the bottom spacing.
mxText.prototype.baseSpacingLeft
Specifies the spacing to be added to the left spacing.
mxText.prototype.baseSpacingRight
Specifies the spacing to be added to the right spacing.
mxText.prototype.replaceLinefeeds
Specifies if linefeeds in HTML labels should be replaced with BR tags.
mxText.prototype.verticalTextRotation
Rotation for vertical text.
mxText.prototype.ignoreClippedStringSize
Specifies if the string size should be measured in updateBoundingBox if the label is clipped and the label position is center and middle.
mxText.prototype.updateBoundingBox = function()
Updates the boundingBox for this shape using the given node and position.
mxText.prototype.ignoreStringSize
Specifies if the actual string size should be measured.
mxText.prototype.textWidthPadding
Specifies the padding to be added to the text width for the bounding box.
mxText.prototype.lastValue
Contains the last rendered text value.
mxText.prototype.cacheEnabled
Specifies if caching for HTML labels should be enabled.
mxText.prototype.isParseVml = function()
Text shapes do not contain VML markup and do not need to be parsed.
mxText.prototype.isHtmlAllowed = function()
Returns true if HTML is allowed for this shape.
mxText.prototype.getSvgScreenOffset = function()
Disables offset in IE9 for crisper image output.
mxText.prototype.checkBounds = function()
Returns true if the bounds are not null and all of its variables are numeric.
mxText.prototype.paint = function(c,
update)
Generic rendering code.
mxText.prototype.redraw = function()
Renders the text using the given DOM nodes.
mxText.prototype.resetStyles = function()
Resets all styles.
mxText.prototype.apply = function(state)
Extends mxShape to update the text styles.
mxText.prototype.getAutoDirection = function()
Used to determine the automatic text direction.
mxText.prototype.getContentNode = function()
Returns the node that contains the rendered input.
mxText.prototype.getShapeRotation = function()
Returns 0 to avoid using rotation in the canvas via updateTransform.
mxText.prototype.getTextRotation = function()
Returns the rotation for the text label of the corresponding shape.
mxText.prototype.isPaintBoundsInverted = function()
Inverts the bounds if mxShape.isBoundsInverted returns true or if the horizontal style is false.
mxText.prototype.configureCanvas = function(c,
x,
y,
w,
h)
Sets the state of the canvas for drawing the shape.
mxText.prototype.updateVmlContainer = function()
Sets the width and height of the container to 1px.
mxText.prototype.getHtmlValue = function()
Private helper function to create SVG elements
mxText.prototype.getTextCss = function()
Private helper function to create SVG elements
mxText.prototype.redrawHtmlShape = function()
Updates the HTML node(s) to reflect the latest bounds and scale.
mxText.prototype.redrawHtmlShapeWithCss3 = function()
Updates the HTML node(s) to reflect the latest bounds and scale.
mxText.prototype.updateHtmlTransform = function()
Returns the spacing as an mxPoint.
Implements a 2-dimensional vector with double precision coordinates.
mxText.prototype.updateInnerHtml = function(elt)
Sets the inner HTML of the given element to the value.
mxText.prototype.updateHtmlFilter = function()
Rotated text rendering quality is bad for IE9 quirks/IE8 standards
mxText.prototype.updateValue = function()
Updates the HTML node(s) to reflect the latest bounds and scale.
mxText.prototype.updateFont = function(node)
Updates the HTML node(s) to reflect the latest bounds and scale.
mxText.prototype.updateSize = function(node,
enableWrap)
Updates the HTML node(s) to reflect the latest bounds and scale.
mxText.prototype.getSpacing = function()
Returns the spacing as an mxPoint.
Extends mxPoint to implement a 2-dimensional rectangle with double precision coordinates.
mxShape.prototype.bounds
Holds the mxRectangle that specifies the bounds of this shape.
DEFAULT_FONTFAMILY: 'Arial
Defines the default family for all fonts.
DEFAULT_FONTSIZE: 11
Defines the default size (in px).
Represents the current state of a cell in a given mxGraphView.
TEXT_DIRECTION_LTR: 'ltr'
Constant for text direction left to right.
TEXT_DIRECTION_RTL: 'rtl'
Constant for text direction right to left.
Close