Options
All
  • Public
  • Public/Protected
  • All
Menu

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:

example
mxText.prototype.verticalTextRotation = 90;

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

  • new mxText(value: string, bounds: mxRectangle, align?: string, valign?: string, color?: string, family?: string, size?: number, fontStyle?: string | 0, spacing?: number, spacingTop?: number, spacingRight?: number, spacingBottom?: number, spacingLeft?: number, horizontal?: boolean, background?: string, border?: string, wrap?: boolean, clipped?: boolean, overflow?: string, labelPadding?: string, textDirection?: string): mxText
  • Parameters

    • value: string

      String that represents the text to be displayed. This is stored in .

    • bounds: mxRectangle

      mxRectangle that defines the bounds. This is stored in mxShape.bounds.

    • Optional align: string

      Specifies the horizontal alignment. Default is ‘’. This is stored in .

    • Optional valign: string

      Specifies the vertical alignment. Default is ‘’. This is stored in .

    • Optional color: string

      String that specifies the text color. Default is ‘black’. This is stored in .

    • Optional family: string

      String that specifies the font family. Default is mxConstants.DEFAULT_FONTFAMILY. This is stored in .

    • Optional size: number

      Integer that specifies the font size. Default is mxConstants.DEFAULT_FONTSIZE. This is stored in .

    • Optional fontStyle: string | 0

      Specifies the font style. Default is 0. This is stored in .

    • Optional spacing: number

      Integer that specifies the global spacing. Default is 2. This is stored in .

    • Optional spacingTop: number

      Integer that specifies the top spacing. Default is 0. The sum of the spacing and this is stored in .

    • Optional spacingRight: number

      Integer that specifies the right spacing. Default is 0. The sum of the spacing and this is stored in .

    • Optional spacingBottom: number

      Integer that specifies the bottom spacing. Default is 0.The sum of the spacing and this is stored in .

    • Optional spacingLeft: number

      Integer that specifies the left spacing. Default is 0. The sum of the spacing and this is stored in .

    • Optional horizontal: boolean

      Boolean that specifies if the label is horizontal. Default is true. This is stored in .

    • Optional background: string

      String that specifies the background color. Default is null. This is stored in .

    • Optional border: string

      String that specifies the label border color. Default is null. This is stored in .

    • Optional wrap: boolean

      Specifies if word-wrapping should be enabled. Default is false. This is stored in .

    • Optional clipped: boolean

      Specifies if the label should be clipped. Default is false. This is stored in .

    • Optional overflow: string

      Value of the overflow style. Default is ‘visible’.

    • Optional labelPadding: string
    • Optional textDirection: string

    Returns mxText

Properties

antiAlias

antiAlias: boolean

Variable: antiAlias

Rendering hint for configuring the canvas.

baseSpacingBottom

baseSpacingBottom: number

Variable: 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

baseSpacingLeft: number

Variable: baseSpacingLeft

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

baseSpacingRight

baseSpacingRight: number

Variable: baseSpacingRight

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

baseSpacingTop

baseSpacingTop: number

Variable: 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.

boundingBox

boundingBox: mxRectangle

Variable: boundingBox

Contains the bounding box of the shape, that is, the smallest rectangle that includes all pixels of the shape.

bounds

bounds: mxRectangle

Variable: bounds

Holds the that specifies the bounds of this shape.

cacheEnabled

cacheEnabled: boolean

Variable: cacheEnabled

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

constraints

constraints: mxConnectionConstraint[]

dialect

dialect: string

Variable: dialect

Holds the dialect in which the shape is to be painted. This can be one of the DIALECT constants in .

direction

direction: string

Specify the direction of certain shapes (eg. mxTriangle). Possible values are mxConstants.DIRECTION_EAST (default), mxConstants.DIRECTION_WEST, mxConstants.DIRECTION_NORTH, and mxConstants.DIRECTION_SOUTH.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

endArrow

endArrow: string

Possible values are all constants with an ARROW-prefix.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

endSize

endSize: number

Size of the end marker in pixels.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

fill

fill: string

Fill color.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

fillOpacity

fillOpacity: number

Fill opacity. Possible range is 0-100.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

flipH

flipH: boolean

Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply implementation).

flipV

flipV: boolean

Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply implementation).

glass

glass: boolean

Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

gradient

gradient: string

Gradient color.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

gradientDirection

gradientDirection: string

Gradient direction.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

ignoreClippedStringSize

ignoreClippedStringSize: boolean

Variable: ignoreClippedStringSize

Specifies if the string size should be measured in 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 . Default is true. has precedence over this switch.

ignoreStringSize

ignoreStringSize: boolean

Variable: ignoreStringSize

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

isDashed

isDashed: boolean

Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

isRounded

isRounded: boolean

For edges this determines whether or not joins between edges segments are smoothed to a rounded finish.
For vertices that have the rectangle shape, this determines whether or not the rectangle is rounded.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

isShadow

isShadow: boolean

Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

lastValue

lastValue: string

Variable: lastValue

Contains the last rendered text value. Used for caching.

minSvgStrokeWidth

minSvgStrokeWidth: number

Variable: minSvgStrokeWidth

Minimum stroke width for SVG output.

node

node: HTMLElement

Variable: node

Holds the outermost DOM node that represents this shape.

opacity

opacity: number

Opacity. Possible range is 0-100.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

outline

outline: boolean

Variable: outline

Specifies if the shape should be drawn as an outline. This disables all fill colors and can be used to disable other drawing states that should not be painted for outlines. Default is false. This should be set before calling .

pointerEvents

pointerEvents: boolean

Variable: pointerEvents

Specifies if pointer events should be handled. Default is true.

points

points: mxPoint[]

Variable: points

Holds the array of that specify the points of this shape.

replaceLinefeeds

replaceLinefeeds: boolean

Variable: replaceLinefeeds

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

rotation

rotation: number

Possible range is 0-360.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

scale

scale: number

Variable: scale

Holds the scale in which the shape is being painted.

shapePointerEvents

shapePointerEvents: boolean

Variable: shapePointerEvents

Specifies if pointer events outside of shape should be handled. Default is false.

spacing

spacing: number

The value represents the spacing, in pixels, added to each side of a label in a vertex (style applies to vertices only).
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

startArrow

startArrow: string

Possible values are all constants with an ARROW-prefix.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

startSize

startSize: number

Size of the start marker or the size of the swimlane title region depending on the shape it is used for.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

Optional state

Variable: state

Optional reference to the corresponding .

stencil

stencil: mxStencil

Variable: stencil

Holds the that defines the shape.

stencilPointerEvents

stencilPointerEvents: boolean

Variable: stencilPointerEvents

Specifies if pointer events outside of stencils should be handled. Default is false. Set this to true for backwards compatibility with the 1.x branch.

stroke

stroke: string

Stroke color.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

strokeOpacity

strokeOpacity: number

Stroke opacity. Possible range is 0-100.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

strokewidth

strokewidth: number

Stroke width.
Note: this property is not documented in the JavaScript API but it does exist and is necessary (see apply).

Optional style

style: {}

Variable: style

Optional reference to the style of the corresponding .

Type declaration

  • [key: string]: any

svgPointerEvents

svgPointerEvents: "all"

Variable: svgPointerEvents

Specifies if pointer events should be handled. Default is true.

svgStrokeTolerance

svgStrokeTolerance: number

Variable: svgStrokeTolerance

Event-tolerance for SVG strokes (in px). Default is 8. This is only passed to the canvas in if is true.

textWidthPadding

textWidthPadding: 4 | 3

Variable: 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.

useSvgBoundingBox

useSvgBoundingBox: boolean

Variable: useSvgBoundingBox

Allows to use the SVG bounding box in SVG. Default is false for performance reasons.

verticalTextRotation

verticalTextRotation: number

Variable: verticalTextRotation

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

visible

visible: boolean

Variable: visible

Specifies if the shape is visible. Default is true.

vmlScale

vmlScale: number

Variable: vmlScale

Scale for improving the precision of VML rendering. Default is 1.

Methods

addPoints

apply

augmentBoundingBox

checkBounds

  • checkBounds(): boolean

clear

  • clear(): void

configureCanvas

  • configureCanvas(c: mxAbstractCanvas2D, x: number, y: number, w: number, h: number): void

create

  • create(container: Element): Element
  • Function: create

    Creates and returns the DOM node(s) for the shape in the given container. This implementation invokes , or depending on the and style settings.

    Parameters:

    container - DOM node that will contain the shape.

    Parameters

    • container: Element

    Returns Element

createBoundingBox

createCanvas

  • createCanvas(): Element

createHtml

  • createHtml(): HTMLElement
  • Function: createHtml

    Creates and returns the HTML DOM node(s) to represent this shape. This implementation falls back to so that the HTML creation is optional.

    Returns HTMLElement

createSvg

  • createSvg(): Element

createSvgCanvas

createTransparentSvgRectangle

  • createTransparentSvgRectangle(x: number, y: number, w: number, h: number): Element

createVml

  • createVml(): Element

createVmlCanvas

createVmlGroup

  • createVmlGroup(): Element

destroy

  • destroy(): void
  • Function: destroy

    Destroys the shape by removing it from the DOM and releasing the DOM node associated with the shape using <mxEvent.release>.

    Returns void

getArcSize

  • getArcSize(w: number, h: number): number

getAutoDirection

  • getAutoDirection(): string
  • Function: getAutoDirection

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

    Returns string

getCursor

  • getCursor(): string

getGradientBounds

getLabelBounds

  • Function: getLabelBounds

    Returns the for the label bounds of this shape, based on the given scaled and translated bounds of the shape. This method should not change the rectangle in-place. This implementation returns the given rect.

    Parameters

    Returns mxRectangle

getLabelMargins

  • Function: getLabelMargins

    Returns the scaled top, left, bottom and right margin to be used for computing the label bounds as an , where the bottom and right margin are defined in the width and height of the rectangle, respectively.

    Parameters

    Returns null | mxRectangle

getRotation

  • getRotation(): number

getShapeRotation

  • getShapeRotation(): 0

getSpacing

getSvgScreenOffset

  • getSvgScreenOffset(): 0 | 0.5

getTextRotation

  • getTextRotation(): number

init

  • init(container: Element): void
  • Function: init

    Initializes the shape by creaing the DOM node using and adding it into the given container.

    Parameters:

    container - DOM node that will contain the shape.

    Parameters

    • container: Element

    Returns void

initStyles

  • initStyles(container: Element): void

isHtmlAllowed

  • isHtmlAllowed(): boolean
  • Function: isHtmlAllowed

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

    Returns boolean

isPaintBoundsInverted

  • isPaintBoundsInverted(): boolean

isParseVml

  • isParseVml(): boolean
  • Function: isParseVml

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

    Returns boolean

isRoundable

  • isRoundable(): boolean

paint

paintBackground

  • paintBackground(c: mxAbstractCanvas2D, x: number, y: number, w: number, h: number): void

paintEdgeShape

paintForeground

  • paintForeground(c: mxAbstractCanvas2D, x: number, y: number, w: number, h: number): void

paintGlassEffect

  • paintGlassEffect(c: mxAbstractCanvas2D, x: number, y: number, w: number, h: number, arc: number): void

paintVertexShape

  • paintVertexShape(c: mxAbstractCanvas2D, x: number, y: number, w: number, h: number): void

reconfigure

  • reconfigure(): void

redraw

  • redraw(): void

redrawHtmlShape

  • redrawHtmlShape(): void

redrawShape

  • redrawShape(): void

releaseSvgGradients

  • releaseSvgGradients(grads: any[]): void

resetStyles

  • resetStyles(): void

setCursor

  • setCursor(cursor: string): void
  • Function: setCursor

    Sets the cursor on the given shape.

    Parameters:

    cursor - The cursor to be used.

    Parameters

    • cursor: string

    Returns void

setTransparentBackgroundImage

  • setTransparentBackgroundImage(node: Element): void

updateBoundingBox

  • updateBoundingBox(): void

updateBoundsFromPoints

  • updateBoundsFromPoints(): void

updateFont

  • updateFont(node: HTMLElement): void
  • Function: updateFont

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

    Parameters

    • node: HTMLElement

    Returns void

updateHtmlBounds

  • updateHtmlBounds(node: HTMLElement): void

updateHtmlColors

  • updateHtmlColors(node: HTMLElement): void

updateHtmlFilter

  • updateHtmlFilter(): void
  • Function: updateHtmlFilter

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

    Returns void

updateHtmlFilters

  • updateHtmlFilters(node: HTMLElement): void

updateHtmlTransform

  • updateHtmlTransform(): void
  • Function: updateHtmlTransform

    Returns the spacing as an .

    Returns void

updateInnerHtml

  • updateInnerHtml(elt: HTMLElement): void
  • Function: setInnerHtml

    Sets the inner HTML of the given element to the .

    Parameters

    • elt: HTMLElement

    Returns void

updateMargin

  • updateMargin(): void

updateSize

  • updateSize(node: HTMLElement, enableWrap: boolean): void
  • Function: updateSize

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

    Parameters

    • node: HTMLElement
    • enableWrap: boolean

    Returns void

updateTransform

  • updateTransform(c: mxAbstractCanvas2D, x: number, y: number, w: number, h: number): void

updateValue

  • updateValue(): void
  • Function: updateValue

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

    Returns void

updateVmlContainer

  • updateVmlContainer(): void

Generated using TypeDoc