Class CellRenderer

Renders cells into a document object model. The is a global map of shape names, constructor pairs that is used in all instances. You can get a list of all available shape names using the following code.

In general the cell renderer is in charge of creating, redrawing and destroying the shape and label associated with a cell state, as well as some other graphical objects, namely controls and overlays. The shape hierarchy in the display (i.e. the hierarchy in which the DOM nodes appear in the document) does not reflect the cell hierarchy. The shapes are a (flat) sequence of shapes and labels inside the draw pane of the graph view, with some exceptions, namely the HTML labels being placed directly inside the graph container for certain browsers.

GlobalConfig.logger.show();
for (var i in mxCellRenderer.defaultShapes)
{
GlobalConfig.logger.debug(i);
}

Constructors

Properties

antiAlias: boolean = true

Antialiasing option for new shapes.

true.
defaultEdgeShape: typeof Shape = ConnectorShape

Defines the default shape for edges.

defaultTextShape: typeof TextShape = TextShape

Defines the default shape for labels.

TextShape.

defaultVertexShape: typeof RectangleShape = RectangleShape

Defines the default shape for vertices.

forceControlClickHandler: boolean = false

Specifies if the enabled state of the graph should be ignored in the control click handler (to allow folding in disabled graphs).

false.
legacyControlPosition: boolean = true

Specifies if the folding icon should ignore the horizontal orientation of a swimlane.

true.
legacySpacing: boolean = true

Specifies if spacing and label position should be ignored if overflow is fill or width.

true for backwards compatibility.
minSvgStrokeWidth: number = 1

Minimum stroke width for SVG output.

defaultShapes: {
    [key: string]: typeof Shape;
} = {}

Static array that contains the globally registered shapes which are known to all instances of this class. For adding new shapes you should use the static CellRenderer#registerShape function.

Built-in shapes: arrow, rectangle, ellipse, rhombus, image, line, label, cylinder, swimlane, connector, actor and cloud.

Methods

  • Check if style properties supporting placeholders requires resolution.

    Parameters

    Returns boolean

  • Configures the shape for the given cell state.

    Parameters

    • state: CellState

      for which the shape should be configured.

    Returns void

  • Creates the actual shape for showing the overlay for the given cell state.

    Parameters

    • state: CellState

      for which the overlay should be created.

    Returns void

  • Creates the control for the given cell state.

    Parameters

    • state: CellState

      for which the control should be created.

    Returns void

  • Hook for creating the click handler for the folding icon.

    Parameters

    • state: CellState

      whose control click handler should be returned.

    Returns ((evt: Event) => void)

      • (evt): void
      • Parameters

        • evt: Event

        Returns void

  • Creates the label for the given cell state.

    Parameters

    • state: CellState

      for which the label should be created.

    • value: string

    Returns void

  • Destroys the shapes associated with the given cell state.

    Parameters

    • state: CellState

      for which the shapes should be destroyed.

    Returns void

  • Returns the value to be used for the label.

    Parameters

    • state: CellState

      for which the label should be created.

    Returns null | string

  • Returns the scaling used for the label of the given state

    Parameters

    • state: CellState

      whose label scale should be returned.

    Returns number

  • Initializes the given control and returns the corresponding DOM node.

    Parameters

    • state: CellState

      for which the control should be initialized.

    • control: Shape

      Shape to be initialized.

    • handleEvents: boolean

      Boolean indicating if mousedown and mousemove should fire events via the graph.

    • clickHandler: EventListener

      Optional function to implement clicks on the control.

    Returns null | Element

  • Initializes the shape in the given state by calling its init method with the correct container after configuring it using configureShape.

    Parameters

    • state: CellState

      for which the shape should be initialized.

    Returns void

  • Inserts the given array of Shapes after the given nodes in the DOM.

    Parameters

    • state: CellState
    • node: null | HTMLElement | SVGElement

      Node in after which the shapes should be inserted.

    • htmlNode: null | HTMLElement | SVGElement

      Node in the graph container after which the shapes should be inserted that will not go into the (eg. HTML labels without foreignObjects).

    Returns (null | HTMLElement | SVGElement)[]

  • Installs the event listeners for the given cell state.

    Parameters

    • state: CellState

      for which the event listeners should be isntalled.

    Returns void

  • Returns true if the event is for the label of the given state. This implementation always returns true.

    Parameters

    • state: CellState

      whose label fired the event.

    • evt: MouseEvent

      Mouse event which was fired.

    Returns boolean

  • Returns true if the event is for the shape of the given state. This implementation always returns true.

    Parameters

    • state: CellState

      whose shape fired the event.

    • evt: MouseEvent

      Mouse event which was fired.

    Returns boolean

  • Returns true if the style for the text shape has changed.

    Parameters

    • state: CellState

      whose label should be checked.

    • shape: TextShape

      Text shape to be checked.

    Returns boolean

  • Replaces any reserved words used for attributes, eg. inherit, indicated or swimlane for colors in the shape for the given state. This implementation resolves these keywords on the fill, stroke and gradient color keys.

    Parameters

    Returns void

  • Updates the bounds or points and scale of the shapes for the given cell state. This is called in mxGraphView.validatePoints as the last step of updating all cells.

    Parameters

    • state: CellState

      for which the shapes should be updated.

    • force: boolean = false

      Optional boolean that specifies if the cell should be reconfiured and redrawn without any additional checks.

    • rendering: boolean = true

      Optional boolean that specifies if the cell should actually be drawn into the DOM. If this is false then redraw and/or reconfigure will not be called on the shape.

    Returns void

  • Redraws the overlays for the given cell state.

    Parameters

    • state: CellState

      whose overlays should be redrawn.

    • forced: boolean = false

    Returns void

  • Redraws the control for the given cell state.

    Parameters

    • state: CellState

      whose control should be redrawn.

    • forced: boolean = false

    Returns void

  • Redraws the label for the given cell state.

    Parameters

    • state: CellState

      whose label should be redrawn.

    • forced: boolean

    Returns void

  • Redraws the shape for the given cell state.

    Parameters

    • state: CellState

      whose label should be redrawn.

    • force: boolean = false
    • rendering: boolean = true

    Returns boolean

  • Resolves special keywords 'inherit', 'indicated' and 'swimlane' and sets the respective color on the shape.

    Parameters

    Returns void

  • Adds the shape rotation to the given label bounds and applies the alignment and offsets.

    Parameters

    Returns void

  • Registers the given constructor under the specified key in this instance of the renderer.

    Parameters

    • key: string

      the shape name.

    • shape: typeof Shape

      constructor of the Shape subclass.

    Returns void

    CellRenderer.registerShape(Constants.SHAPE_RECTANGLE, RectangleShape);