GeezerVison is showing maxgraph.github.io — CellRenderer | @maxgraph/core
Renders Cells into a document object model.
In general, the CellRenderer 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 GraphView, with some exceptions,
namely the HTML labels being placed directly inside the graph container for certain browsers.
Constructors
constructor
-
new CellRenderer(): CellRenderer
Returns CellRenderer
Properties
antiAlias
antiAlias: boolean = true
Antialiasing option for new shapes.
defaultEdgeShape
Defines the default shape for edges.
defaultTextShape
defaultTextShape: typeof TextShape = TextShape
Defines the default shape for labels.
defaultVertexShape
Defines the default shape for vertices.
forceControlClickHandler
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).
legacyControlPosition
legacyControlPosition: boolean = true
Specifies if the folding icon should ignore the horizontal orientation of a swimlane.
legacySpacing
legacySpacing: boolean = true
Specifies if spacing and label position should be ignored if overflow is fill or width.
Defaulttrue for backwards compatibility.
minSvgStrokeWidth
minSvgStrokeWidth: number = 1
Minimum stroke width for SVG output.
Methods
checkPlaceholderStyles
-
checkPlaceholderStyles(state: CellState): boolean
Check if style properties supporting placeholders requires resolution.
Returns boolean
ProtectedconfigureOverlayShape
-
Configure the Shape of the overlay. Generally, it is used to configure the DOM node of the Shape
The default implementation set the cursor in the DOM node of the Shape based on the CellOverlay.cursor.
Returns void
configureShape
-
Configures the shape for the given cell state.
Returns void
createCellOverlays
-
Creates the actual shape for showing the overlay for the given cell state.
Returns void
createControl
-
Creates the control for the given cell state.
Returns void
createControlClickHandler
-
createControlClickHandler(state: CellState): (evt: Event) => void
Hook for creating the click handler for the folding icon.
Returns (evt: Event) => void
createIndicatorShape
-
Creates the indicator shape for the given cell state.
Returns void
createLabel
-
createLabel(state: CellState, value: string): void
Creates the label for the given cell state.
Returns void
ProtectedcreateOverlayShape
-
Create the Shape of the overlay.
createShape
-
Creates and returns the shape for the given cell state.
destroy
-
Destroys the shapes associated with the given cell state.
Returns void
doRedrawShape
-
Invokes redraw on the shape of the given state.
Returns void
getControlBounds
-
Returns the bounds to be used to draw the control (folding icon) of the given state.
getLabelBounds
-
Returns the bounds to be used to draw the label of the given state.
getLabelValue
-
getLabelValue(state: CellState): string | null
Returns the value to be used for the label.
Returns string | null
getShape
-
Parameters
Optionalname: string | null
getShapeConstructor
-
Returns the constructor to be used for creating the shape.
getShapesForState
-
Returns the Shapes for the given cell state in the order in which they should appear in the DOM.
getTextScale
-
Returns the scaling used for the label of the given state
Returns number
initControl
-
initControl( state: CellState, control: Shape, handleEvents: boolean, clickHandler: EventListener,): Element | null
Initializes the given control and returns the corresponding DOM node.
Parameters
- state: CellState
CellState for which the control should be initialized.
- control: Shape
- 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 Element | null
initializeLabel
-
Initializes the label with a suitable container.
Returns void
initializeOverlay
-
Initializes the given overlay.
Returns void
initializeShape
-
Initializes the shape in the given state by calling its init method with
the correct container after configuring it using configureShape.
Returns void
insertStateAfter
-
insertStateAfter( state: CellState, node: HTMLElement | SVGElement | null, htmlNode: HTMLElement | SVGElement | null,): ( HTMLElement | SVGElement | null) []
Inserts the given CellState after the given nodes in the DOM.
Parameters
- state: CellState
- node: HTMLElement | SVGElement | null
- htmlNode: HTMLElement | SVGElement | null
Node in the graph container after which the shapes should be inserted that
will not go into the GraphView.drawPane (e.g. HTML labels without foreignObjects).
Returns (HTMLElement | SVGElement | null)[]
installCellOverlayListeners
installListeners
-
Installs the event listeners for the given cell state.
Returns void
isLabelEvent
-
isLabelEvent(state: CellState, evt: MouseEvent): boolean
Returns true if the event is for the label of the given state.
This implementation always returns true.
Parameters
- state: CellState
- evt: MouseEvent
Mouse event which was fired.
Returns boolean
isShapeEvent
-
isShapeEvent(state: CellState, evt: MouseEvent): boolean
Returns true if the event is for the shape of the given state.
This implementation always returns true.
Parameters
- state: CellState
- evt: MouseEvent
Mouse event which was fired.
Returns boolean
isShapeInvalid
-
Returns true if the given shape must be repainted.
Returns boolean
isTextShapeInvalid
-
Returns true if the style for the text shape has changed.
Returns boolean
postConfigureShape
-
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.
Returns void
redraw
-
redraw(state: CellState, force?: boolean, rendering?: boolean): 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
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
redrawCellOverlays
-
redrawCellOverlays(state: CellState, forced?: boolean): void
Redraws the overlays for the given cell state.
Returns void
redrawControl
-
redrawControl(state: CellState, forced?: boolean): void
Redraws the control for the given cell state.
Returns void
redrawLabel
-
redrawLabel(state: CellState, forced: boolean): void
Redraws the label for the given cell state.
Returns void
redrawLabelShape
-
Called to invoked redraw on the given text shape.
Returns void
redrawShape
-
redrawShape(state: CellState, force?: boolean, rendering?: boolean): boolean
Redraws the shape for the given cell state.
Parameters
- state: CellState
- force: boolean = false
- rendering: boolean = true
Returns boolean
resolveColor
-
resolveColor(state: CellState, field: string, key: string): void
Resolves special keywords 'inherit', 'indicated' and 'swimlane' and sets
the respective color on the shape.
Returns void
rotateLabelBounds
-
Adds the shape rotation to the given label bounds and
applies the alignment and offsets.
Returns void
On This Page
Constructors
Properties
Methods
|