UNPKG

@kieler/klighd-core

Version:

Core KLighD diagram visualization with Sprotty

248 lines 11.5 kB
import { VNode } from 'snabbdom'; import { AbstractUIExtension, MouseTool, SGraphImpl } from 'sprotty'; import { RenderOptionsRegistry } from '../options/render-options-registry'; import { SKGraphModelRenderer } from '../skgraph-model-renderer'; import { SKNode } from '../skgraph-models'; import { ProxyFilterAndID } from './filters/proxy-view-filters'; import { ProxyVNode } from './proxy-view-util'; /** A UIExtension which adds a proxy-view to the Sprotty container. */ export declare class ProxyView extends AbstractUIExtension { /** ID. */ static readonly ID = "proxy-view"; /** * ID used to indicate whether an SKNode should be rendered as a proxy. * The corresponding property can be `true` or `false`. */ static readonly RENDER_NODE_AS_PROXY_PROPERTY = "de.cau.cs.kieler.klighd.proxyView.renderNodeAsProxy"; /** * ID used for proxy rendering property of SKNodes. * The corresponding property contains the proxy's data. */ static readonly PROXY_RENDERING_PROPERTY = "de.cau.cs.kieler.klighd.proxyView.proxyRendering"; /** * ID used for specifying depth of going into hierarchical off-screen nodes. * `0` indicates default behavior, showing only the outermost node as a proxy. * A value `x>0` indicates showing proxies up to x layers deep inside a hierarchical node. * A value `x<0` indicates always showing proxies for all layers. */ static readonly HIERARCHICAL_OFF_SCREEN_DEPTH = "de.cau.cs.kieler.klighd.proxyView.hierarchicalOffScreenDepth"; /** Number indicating at what distance a node is close. */ static readonly DISTANCE_CLOSE = 300; /** Number indicating at what distance a node is distant. */ static readonly DISTANCE_DISTANT = 700; /** ActionDispatcher mainly needed for init(). */ private actionDispatcher; /** Provides the utensil to replace HTML elements. */ private patcherProvider; private viewerOptions; /** Used to replace HTML elements. */ private patcher; /** VNode of the current HTML root element. Used by the {@link patcher}. */ private currHTMLRoot; /** The mouse tool to decorate the proxy nodes with. */ mouseTool: MouseTool; /** The registered filters. */ private filters; /** The currently rendered proxies. */ private currProxies; /** Whether the proxies should be click-through. */ private clickThrough; /** * Stores the previous opacity of edges whose opacity was modified. * Always make sure the ids from {@link getProxyId()} are used. */ private prevModifiedEdges; /** * Stores the proxy renderings of already rendered nodes. * Always make sure the ids from {@link getProxyId()} are used. */ private renderings; /** * Stores the absolute coordinates (without scroll and zoom) of already rendered nodes. * Always make sure the ids from {@link getProxyId()} are used. */ private positions; /** * Stores the distances of nodes to the canvas. * Always make sure the ids from {@link getProxyId()} are used. */ private distances; /** @see {@link ProxyViewEnabled} */ private proxyViewEnabled; /** Whether the proxy view was previously enabled. Used to avoid excessive patching. */ private prevProxyViewEnabled; /** @see {@link ProxyViewSize} */ private sizePercentage; /** @see {@link ProxyViewDecreaseProxyClutter} */ private clusteringEnabled; /** @see {@link ProxyViewDecreaseProxyClutter} */ private opacityByDistanceEnabled; /** @see {@link ProxyViewEnableEdgeProxies} */ private straightEdgeRoutingEnabled; /** @see {@link ProxyViewEnableEdgeProxies} */ private alongBorderRoutingEnabled; /** @see {@link ProxyViewEnableSegmentProxies} */ private segmentProxiesEnabled; /** @see {@link ProxyViewInteractiveProxies} */ private interactiveProxiesEnabled; /** @see {@link ProxyViewTitleScaling} */ private titleScalingEnabled; /** * Note that clusters are never highlighted, as highlighting is synthesis-specific while cluster renderings are not. * @see {@link ProxyViewHighlightSelected} */ private highlightSelected; /** @see {@link ProxyViewOpacityBySelected} */ private opacityBySelected; /** @see {@link ProxyViewUseSynthesisProxyRendering} */ private useSynthesisProxyRendering; /** @see {@link ProxyViewSimpleAlongBorderRouting} */ private simpleAlongBorderRouting; /** @see {@link ProxyViewCapProxyToParent} */ private capProxyToParent; /** @see {@link ProxyViewShowProxiesImmediately} */ private showProxiesImmediately; /** @see {@link ProxyViewShowProxiesEarly} */ private showProxiesEarly; /** @see {@link ProxyViewShowProxiesEarlyNumber} */ private showProxiesEarlyNumber; /** @see {@link ProxyViewStackingOrderByDistance} */ private stackingOrderByDistance; /** @see {@link ProxyViewStackingOrderByOpacity} */ private stackingOrderByOpacity; /** @see {@link ProxyViewStackingOrderBySelected} */ private stackingOrderBySelected; /** @see {@link ProxyViewUseDetailLevel} */ private useDetailLevel; /** @see {@link ProxyViewDrawEdgesAboveNodes} */ private edgesAboveNodes; /** @see {@link ProxyViewEdgesToOffScreenPoint} */ private edgesToOffScreenPoint; /** @see {@link ProxyViewTransparentEdges} */ private transparentEdges; /** @see {@link ProxyViewOriginalNodeScale} */ private originalNodeScale; /** @see {@link ProxyViewCapScaleToOne} */ private capScaleToOne; /** @see {@link ProxyViewClusterTransparent} */ private clusterTransparent; /** @see {@link ProxyViewClusteringCascading} */ private clusteringCascading; /** @see {@link ProxyViewClusteringSweepLine} */ private clusteringSweepLine; id(): string; containerClass(): string; init(): void; protected initializeContents(containerElement: HTMLElement): void; /** * Update step of the proxy-view. Handles everything proxy-view related. * @param model The current SGraph. * @param ctx The rendering context. */ update(model: SGraphImpl, ctx: SKGraphModelRenderer): void; /** Returns the proxy rendering for all of currRoot's off-screen children and applies logic, e.g. clustering. */ private createAllProxies; /** * Returns an object containing lists of all off-screen and on-screen nodes in `currRoot`. * Note that an off-screen node's children aren't included in the list, e.g. only outer-most off-screen nodes are returned. */ private getOffAndOnScreenNodes; /** * Returns all `offScreenNodes` matching the enabled filters. * @param offScreenNodes The nodes to filter. * @param onScreenNodes Argument for filters. * @param canvasGRF Argument for filters. */ private applyFilters; /** Performs a shallow copy of the nodes so that the original nodes aren't mutated. */ private cloneNodes; /** Calculates the opacities of `offScreenNodes`. */ private calculateOpacity; /** * Orders `offScreenNodes` such that the contextually most relevant * nodes appear at the end - therefore being rendered on top. */ private orderNodes; /** Returns the nodes updated to use the rendering specified by the synthesis. */ private getSynthesisProxyRendering; /** Applies clustering to all `offScreenNodes` until there's no more overlap. Cluster-proxies are returned as VNodes. */ private applyClustering; /** Routes edges from `onScreenNodes` to the corresponding proxies of `nodes`. */ private routeEdges; /** * Returns an edge rerouted to the proxy. * `nodeConnector` and `proxyConnector` are the endpoints of the original edge. * @param `outgoing` Whether the edge is outgoing from the proxy. */ private rerouteEdge; /** Returns an edge that can be overlayed over the given `edge` to simulate a fade-out effect. */ private getOverlayEdge; /** Connects off-screen edges. */ private connectEdgeSegments; /** Returns all edges that are both on- & off-screen. */ private getPartiallyOffScreenEdges; /** Returns the proxy rendering for an off-screen node. */ private createProxy; /** Let the mouseTool decorate this proxy rendering to activate all KLighD- and Proxy-specific mouse interactions. */ addMouseInteraction(vnode: ProxyVNode, element: SKNode): VNode; /** Returns the proxy rendering for an edge. */ private createEdgeProxy; /** Returns whether the given `node` is valid for rendering. */ private canRenderNode; /** * Calculates the TransformAttributes for this node's proxy, e.g. the position to place the proxy at aswell as its scale and bounds. * Note that the position is pre-scaling. To get position post-scaling, divide `x` and `y` by `scale`. */ private getTransform; /** * Returns the translated bounds for the given `node`. * @see {@link Canvas.translateToCRF()} */ private getTranslatedNodeBounds; /** Returns the `node`'s bounds with the absolute position. Positions are stored in {@link positions}. */ private getAbsoluteBounds; /** Recursively calculates the positions of this node and all of its predecessors and stores them in {@link positions}. */ private getAbsolutePosition; /** * Returns the distance between the node and the canvas and stores them in {@link distances}. * @see {@link getDistanceToCanvas()} */ private getNodeDistanceToCanvas; /** Transforms the KGraphData[] to ProxyKGraphData[], e.g. adds the proxyScale attribute to each data. */ private getNodeData; /** Returns a copy of `edgeData` with the decorators placed at `target`, angled from `prev` to `target`. */ private placeDecorator; /** Returns a copy of `edgeData` with the colors changed to `color`. */ private changeColor; /** * Resets the opacity of the given edges. * @param modifiedEdges The map containing the edges to reset the opacity for. */ private resetEdgeOpacity; /** Called on mouse down, used for making proxies click-through. */ setMouseDown(event: MouseEvent): void; /** Called on mouse up, used for making proxies click-through. */ setMouseUp(): void; /** Updates the proxy-view options specified in the {@link RenderOptionsRegistry}. */ updateOptions(renderOptionsRegistry: RenderOptionsRegistry): void; /** * Registers all given `filters` to be evaluated before showing a proxy. * * Try ordering the given filters by strongest filter criterion first, * secondary ordering by simplicity/cost of check. This ensures: * - proxies being filtered out early, therefore reducing the number of filters * that need to be evaluated * - less costly filters being applied first, potentially avoiding more expensive ones */ registerFilters(...filters: ProxyFilterAndID[]): void; /** Unregisters all given `filters`. */ unregisterFilters(...filters: ProxyFilterAndID[]): boolean; /** Resets the proxy-view, i.e. when the model is updated. */ reset(): void; /** Clears the {@link renderings} map. */ clearRenderings(): void; /** Clears the {@link positions} map. */ clearPositions(): void; /** Clears the {@link distances} map. */ clearDistances(): void; } //# sourceMappingURL=proxy-view.d.ts.map