@kieler/klighd-core
Version:
Core KLighD diagram visualization with Sprotty
176 lines • 7.22 kB
TypeScript
import { KNode, SKGraphElement } from '@kieler/klighd-interactive/lib/constraint-classes';
import { SChildElementImpl, SModelRootImpl } from 'sprotty';
import { Point, Viewport } from 'sprotty-protocol';
import { RenderOptionsRegistry } from './options/render-options-registry';
import { KRendering } from './skgraph-models';
/**
* The possible detail level of a KNode as determined by the DepthMap
*/
export declare enum DetailLevel {
FullDetails = 2,
MinimalDetails = 1,
OutOfBounds = 0
}
/**
* All DetailLevel where the children are visible
*/
type DetailWithChildren = DetailLevel.FullDetails;
/**
* Type predicate to determine whether a DetailLevel is a DetailWithChildren level
*/
export declare function isDetailWithChildren(detail: DetailLevel): detail is DetailWithChildren;
/**
* All DetailLevel where the children are not visible
*/
type DetailWithoutChildren = Exclude<DetailLevel, DetailWithChildren>;
type RegionIndexEntry = {
containingRegion: Region;
providingRegion: undefined;
} | {
containingRegion: undefined;
providingRegion: Region;
} | {
containingRegion: Region;
providingRegion: Region;
};
/**
* Divides Model KNodes into regions. On these detail level actions
* are defined via the detailLevel. Also holds additional information to determine
* the appropriate detail level, visibility and title for regions.
*/
export declare class DepthMap {
/**
* The region for immediate children of the SModelRoot,
* aka. the root regions
*/
rootRegions: Region[];
/**
* The model for which the DepthMap is generated
*/
rootElement: SModelRootImpl;
/**
* Maps a given node id to the containing/providing Region
* Root Child Nodes will have a providing region and no containing Region, while all
* other nodes will have at least a containing region
*/
protected regionIndexMap: Map<string, RegionIndexEntry>;
/**
* The last viewport for which we updated the state of KNodes
*/
viewport?: Viewport;
/**
* The threshold for which we updated the state of KNodes
*/
lastThreshold?: number;
/**
* Set for handling regions, that need to be checked for detail level changes.
* Consists of the region that contain at least one child with a lower detail level.
*/
criticalRegions: Set<Region>;
/** Singleton pattern */
private static instance?;
/**
* @param rootElement The root element of the model.
*/
private constructor();
protected reset(modelRoot: SModelRootImpl): void;
/**
* Returns the current DepthMap instance or undefined if its not initialized
* @returns DepthMap | undefined
*/
static getDM(): DepthMap | undefined;
/**
* Returns the current DepthMap instance or returns a new one.
* @param rootElement The model root element.
*/
static init(rootElement: SModelRootImpl): DepthMap;
/**
* It is generally advised to initialize the elements from root to leaf
*
* @param element The KGraphElement to initialize for DepthMap usage
*/
initKGraphElement(element: SChildElementImpl & SKGraphElement, viewport: Viewport, renderingOptions: RenderOptionsRegistry): RegionIndexEntry;
/**
* Finds the KRendering in the given graph element.
* @param element The graph element to look up the rendering for.
* @returns The KRendering.
*/
findRendering(element: SKGraphElement): KRendering | undefined;
getContainingRegion(element: SChildElementImpl & SKGraphElement, viewport: Viewport, renderOptions: RenderOptionsRegistry): Region | undefined;
getProvidingRegion(node: SChildElementImpl & KNode, viewport: Viewport, renderOptions: RenderOptionsRegistry): Region | undefined;
/**
* Decides the appropriate detail level for regions based on their size in the viewport and applies that state.
*
* @param viewport The current viewport.
*/
updateDetailLevels(viewport: Viewport, renderingOptions: RenderOptionsRegistry): void;
/**
* Set detail level for the given region and recursively determine and update the children's detail level
*
* @param region The root region
* @param viewport The current viewport
* @param relativeThreshold The detail level threshold
*/
updateRegionDetailLevel(region: Region, vis: DetailWithChildren, viewport: Viewport, relativeThreshold: number, scaleThreshold: number): void;
recursiveSetOOB(region: Region, vis: DetailWithoutChildren): void;
/**
* Looks for a change in detail level for all critical regions.
* Applies the level change and manages the critical regions.
*
* @param viewport The current viewport
* @param relativeThreshold The full detail threshold
*/
checkCriticalRegions(viewport: Viewport, relativeThreshold: number, scaleThreshold: number): void;
/**
* Decides the appropriate detail level for a region
* based on their size in the viewport and visibility
*
* @param region The region in question
* @param viewport The current viewport
* @param relativeThreshold The full detail threshold
* @returns The appropriate detail level
*/
computeDetailLevel(region: Region, viewport: Viewport, relativeThreshold: number, scaleThreshold: number): DetailLevel;
/**
* Checks visibility of a region with position from browser coordinates in current viewport.
*
* @param region The region in question for visibility.
* @param viewport The current viewport.
* @returns Boolean value indicating the visibility of the region in the current viewport.
*/
isInBounds(region: Region, viewport: Viewport): boolean;
/**
* Compares the size of a node to the viewport and returns the smallest fraction of either height or width.
*
* @param node The KNode in question
* @param viewport The current viewport
* @returns the relative size of the KNodes shortest dimension
*/
scaleMeasureInViewport(node: KNode, viewport: Viewport): number;
}
/**
* Combines KNodes into regions. These correspond to child areas. A region can correspond to
* a region or a super state in the model. Also manages the boundaries, title candidates,
* tree structure of the model and application of detail level of its KNodes.
*/
export declare class Region {
/** The rectangle of the child area in which the region lies. */
boundingRectangle: KNode;
/** The absolute position of the boundingRectangle based on the layout information of the SModel. */
absolutePosition: Point;
/** the regions current detail level that is used by all children */
detail: DetailLevel;
/** The immediate parent region of this region. */
parent?: Region;
/** All immediate child regions of this region */
children: Region[];
/** Constructor initializes element array for region. */
constructor(boundingRectangle: KNode);
/**
* Applies the detail level to all elements of a region.
* @param level the detail level to apply
*/
setDetailLevel(level: DetailLevel): void;
}
export {};
//# sourceMappingURL=depth-map.d.ts.map