UNPKG

@maxgraph/core

Version:

maxGraph is a fully client side JavaScript diagramming library that uses SVG and HTML for rendering.

67 lines (66 loc) 2.31 kB
import AbstractCanvas2D from '../canvas/AbstractCanvas2D.js'; import CellState from '../cell/CellState.js'; /** * Creates a new image export instance to be used with an export canvas. * * Here is an example that uses this class to create an image via a backend using {@link XmlCanvas2D}. * * ```javascript * const xmlDoc = xmlUtils.createXmlDocument(); * const root = xmlDoc.createElement('output'); * xmlDoc.appendChild(root); * * const xmlCanvas = new XmlCanvas2D(root); * const imageExport = new ImageExport(); * * imageExport.drawState(graph.getView().getState(graph.model.root), xmlCanvas); * const xml = xmlUtils.getXml(root); * * const bounds = graph.getGraphBounds(); * const w = Math.ceil(bounds.x + bounds.width); * const h = Math.ceil(bounds.y + bounds.height); * * new MaxXmlRequest('export', 'format=png&w=' + w + * '&h=' + h + '&bg=#F9F7ED&xml=' + encodeURIComponent(xml)) * .simulate(document, '_blank'); * ``` * * @category Serialization */ declare class ImageExport { /** * Specifies if overlays should be included in the export. * @default false */ includeOverlays: boolean; /** * Draws the given state and all its descendants to the given canvas. */ drawState(state: CellState, canvas: AbstractCanvas2D): void; /** * Visits the given state and all its descendants to the given canvas recursively. */ visitStatesRecursive(state: CellState, canvas: AbstractCanvas2D, visitor: (state: CellState, canvas: AbstractCanvas2D) => void): void; /** * Returns the link for the given cell state and canvas. This returns null. */ getLinkForCellState(_state: CellState, _canvas: AbstractCanvas2D): any; /** * Draws the given state to the given canvas. */ drawCellState(state: CellState, canvas: AbstractCanvas2D): void; /** * Draws the shape of the given state. */ drawShape(state: CellState, canvas: AbstractCanvas2D): void; /** * Draws the text of the given state. */ drawText(state: CellState, canvas: AbstractCanvas2D): void; /** * Draws the overlays for the given state. This is called if <includeOverlays> * is true. */ drawOverlays(state: CellState, canvas: AbstractCanvas2D): void; } export default ImageExport;