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