UNPKG

@kieler/klighd-core

Version:

Core KLighD diagram visualization with Sprotty

79 lines 3.13 kB
"use strict"; /* * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient * * http://rtsys.informatik.uni-kiel.de/kieler * * Copyright 2020-2023 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * SPDX-License-Identifier: EPL-2.0 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.SKGraphModelRenderer = void 0; const sprotty_1 = require("sprotty"); const skgraph_models_1 = require("./skgraph-models"); const title_storage_1 = require("./titles/title-storage"); /** * Contains additional data and functionality needed for the rendering of SKGraphs. */ class SKGraphModelRenderer extends sprotty_1.ModelRenderer { constructor(viewRegistry, targetKind, postprocessors) { super(viewRegistry, targetKind, postprocessors); this.viewRegistry = viewRegistry; this.targetKind = targetKind; /** * Storage for the title renderings */ this.titleStorage = new title_storage_1.TitleStorage(); /** Used to force rendering independant of the depthMap. Needed by the proxy-view. */ this.forceRendering = false; } /** * Renders all children of the SKGraph that should be rendered within the child area of the element. * * @param element The element to render the children from. */ renderChildAreaChildren(element) { element.areChildAreaChildrenRendered = true; return element.children .filter((child) => child.type === skgraph_models_1.NODE_TYPE || child.type === skgraph_models_1.EDGE_TYPE) .map((child) => this.renderElement(child)) .filter((vnode) => vnode !== undefined); } /** * Renders all children of the SKGraph that should be rendered outside of the child area of the element. * * @param element The element to render the children from. */ renderNonChildAreaChildren(element) { element.areNonChildAreaChildrenRendered = true; return element.children .filter((child) => child.type === skgraph_models_1.PORT_TYPE || child.type === skgraph_models_1.LABEL_TYPE) .map((child) => this.renderElement(child)) .filter((vnode) => vnode !== undefined); } /** Renders an element forcefully, i.e. independant of the depthMap. */ forceRenderElement(element) { const prevForceRendering = this.forceRendering; this.forceRendering = true; const vnode = this.renderElement(element); this.forceRendering = prevForceRendering; return vnode; } /** @inheritdoc */ renderElement(element) { this.titleStorage.decendToChild(); const node = super.renderElement(element); this.titleStorage.ascendToParent(); return node; } } exports.SKGraphModelRenderer = SKGraphModelRenderer; //# sourceMappingURL=skgraph-model-renderer.js.map