@kieler/klighd-core
Version:
Core KLighD diagram visualization with Sprotty
256 lines • 16.9 kB
TypeScript
/** @jsx svg */
import { KGraphData, SKGraphElement } from '@kieler/klighd-interactive/lib/constraint-classes';
import { VNode } from 'snabbdom';
import { Bounds } from 'sprotty-protocol';
import { SKGraphModelRenderer } from './skgraph-model-renderer';
import { KChildArea, KContainerRendering, KPolyline, KRendering, KShadow, KText, SKEdge, SKLabel } from './skgraph-models';
import { BoundsAndTransformation } from './views-common';
import { ColorStyles, KStyles, LineStyles } from './views-styles';
/**
* Translates a KChildArea rendering into an SVG rendering.
* @param rendering The rendering.
* @param parent The parent element.
* @param propagatedStyles The styles propagated from parent elements that should be taken into account.
* @param context The rendering context for this element.
*/
export declare function renderChildArea(rendering: KChildArea, parent: SKGraphElement, boundsAndTransformation: BoundsAndTransformation, context: SKGraphModelRenderer): VNode;
/**
* Translates a rectangular rendering into an SVG rendering.
* This includes KEllipse, KRectangle and KRoundedRectangle.
* @param rendering The rendering.
* @param parent The parent element.
* @param propagatedStyles The styles propagated from parent elements that should be taken into account.
* @param context The rendering context for this element.
* @param childOfNodeTitle If this rendering is a child of a node title. May override special renderings
*/
export declare function renderRectangularShape(rendering: KContainerRendering, parent: SKGraphElement, boundsAndTransformation: BoundsAndTransformation, styles: KStyles, stylesToPropagate: KStyles, context: SKGraphModelRenderer, childOfNodeTitle?: boolean): VNode;
/**
* Translates a line rendering into an SVG rendering.
* This includes all subclasses of and the KPolyline rendering itself.
* @param rendering The rendering.
* @param parent The parent element.
* @param propagatedStyles The styles propagated from parent elements that should be taken into account.
* @param context The rendering context for this element.
* @param childOfNodeTitle If this rendering is a child of a node title. May override special renderings
*/
export declare function renderLine(rendering: KPolyline, parent: SKGraphElement | SKEdge, boundsAndTransformation: BoundsAndTransformation, styles: KStyles, stylesToPropagate: KStyles, context: SKGraphModelRenderer, childOfNodeTitle?: boolean): VNode;
/**
* Translates a text rendering into an SVG text rendering.
* @param rendering The rendering.
* @param parent The parent element.
* @param propagatedStyles The styles propagated from parent elements that should be taken into account.
* @param context The rendering context for this element.
* @param childOfNodeTitle If this rendering is a child of a node title. May override special renderings
*/
export declare function renderKText(rendering: KText, parent: SKGraphElement | SKLabel, boundsAndTransformation: BoundsAndTransformation, styles: KStyles, context: SKGraphModelRenderer, childOfNodeTitle?: boolean): VNode;
/**
* Renders all child renderings of the given container rendering.
* @param parentRendering The parent rendering.
* @param parent The parent element containing this rendering.
* @param propagatedStyles The styles propagated from parent elements that should be taken into account.
* @param context The rendering context for this element.
* @param childOfNodeTitle If this rendering is a child of a node title. May override special renderings
*/
export declare function renderChildRenderings(parentRendering: KContainerRendering, parentElement: SKGraphElement, propagatedStyles: KStyles, context: SKGraphModelRenderer, childOfNodeTitle?: boolean): (VNode | undefined)[];
export declare function renderError(rendering: KRendering): VNode;
/**
* Renders some SVG shape, possibly with an added shadow, as given by the svgFunction. If a simple shadow
* should be added, it is added as four copies of the SVG shape with rgba(0,0,0,0.1) and the
* offsets defined by the kShadow, if a nice shadow should be added, it is added via SVG filter.
*
* @param kShadow The shadow definition for the rendering, or undefined if no shadow should be added
* @param shadowStyles specific shadow filter ID, if this element should be drawn with a smooth shadow and no simple one.
* @param svgFunction The callback function rendering the wanted SVG shape. x and y are the offsets
* for the renderings additional to any other offsets, here for the shadows, kShadow is the shadow
* definition as given to this function as well and the params are the other params given to this
* function.
* @param params The further parameters needed to call the svgFunction other than an x, y, shadowStyles, and
* kShadow.
* @returns the svg shapes generated by the svg function, with the correct shadow.
*/
export declare function renderWithShadow<T extends any[]>(kShadow: KShadow | undefined, shadowStyles: string | undefined, svgFunction: (x: number | undefined, y: number | undefined, shadowStyles: string | undefined, kShadow: KShadow | undefined, ...params: T) => VNode, ...params: T): VNode[];
/**
* Renders a rectangle with all given information.
*
* @param bounds bounds data calculated for this rectangle.
* @param lineWidth width of the line to offset the rectangle's position and size by.
* @param rx rx parameter of SVG rect
* @param ry ry parameter of SVG rect
* @param lineStyles style information for lines (stroke etc.)
* @param colorStyles style information for color
* @param shadowStyles specific shadow filter ID, if this element should be drawn with a smooth shadow and no simple one.
* @param kShadow general shadow information.
* @returns An array of SVG <rects> resulting from this. Only multiple <rect>s if a simple shadow effect should be applied.
*/
export declare function renderSVGRect(bounds: Bounds, lineWidth: number, rx: number, ry: number, lineStyles: LineStyles, colorStyles: ColorStyles, shadowStyles: string | undefined, kShadow: KShadow | undefined): VNode[];
/**
* Renders a rectangle with all given information.
* If the rendering is a shadow (has a kShadow parameter), all stroke attributes are ignored (no stroke on the shadow) and a
* black fill with 0.1 alpha is returned.
*
* @param x x offset of the rectangle, to be used for shadows only.
* @param y y offset of the rectangle, to be used for shadows only.
* @param shadowStyles specific shadow filter ID, if this element should be drawn with a smooth shadow and no simple one.
* @param kShadow shadow information. Controls what this method does.
* @param bounds bounds data calculated for this rectangle.
* @param lineWidth width of the line to offset the rectangle's position and size by.
* @param rx rx parameter of SVG rect
* @param ry ry parameter of SVG rect
* @param lineStyles style information for lines (stroke etc.)
* @param colorStyles style information for color
* @returns A single SVG <rect>.
*/
export declare function renderSingleSVGRect(x: number | undefined, y: number | undefined, shadowStyles: string | undefined, kShadow: KShadow | undefined, bounds: Bounds, rx: number, ry: number, lineWidth: number, lineStyles: LineStyles, colorStyles: ColorStyles): VNode;
/**
* Renders an definition for an image to be used later with all given information. The image will have a size of 1x1 to be scaled later in its <use>.
*
* @param imageURI The image href string
* @returns An array of SVG elements, here <image>s and <rect>s resulting from this. <rect>s are added if a shadow effect should be applied.
*/
export declare function renderSVGImageDef(imageId: string, imageURI: string): VNode;
/**
* Renders an image with all given information.
*
* @param bounds bounds data calculated for this image.
* @param image The image href string
* @param kShadow shadow information.
* @returns An array of SVG elements, here <image>s and <rect>s resulting from this. <rect>s are added if a shadow effect should be applied.
*/
export declare function renderSVGImage(bounds: Bounds, shadowStyles: string | undefined, image: string, kShadow: KShadow | undefined): VNode[];
/**
* Renders the use of a previously defined SVG shape.
*
* @param bounds bounds data calculated for this shape.
* @param image The use href string
* @param kShadow shadow information.
* @returns An array of SVG elements, here <use>s and <rect>s resulting from this. <rect>s are added if a shadow effect should be applied.
*/
export declare function renderSVGUse(bounds: Bounds, shadowStyles: string | undefined, image: string, kShadow: KShadow | undefined): VNode[];
/**
* Renders an image with all given information.
* If the rendering is a shadow, a shadow rect is drawn instead.
*
* @param x x offset of the image, to be used for shadows only.
* @param y y offset of the image, to be used for shadows only.
* @param kShadow shadow information. Controls what this method does.
* @param bounds bounds data calculated for this image.
* @param image The image href string
* @returns A single SVG <image> or <rect>.
*/
export declare function renderSingleSVGImage(x: number | undefined, y: number | undefined, shadowStyles: string | undefined, kShadow: KShadow | undefined, bounds: Bounds, image: string): VNode;
/**
* Renders a pre-defined SVG element usage with all given information.
* If the rendering is a shadow, a shadow rect is drawn instead.
*
* @param x x offset of the element, to be used for shadows only.
* @param y y offset of the element, to be used for shadows only.
* @param kShadow shadow information. Controls what this method does.
* @param bounds bounds data calculated for this element.
* @param href The use href string
* @returns A single SVG <use> or <rect>.
*/
export declare function renderSingleSVGUse(x: number | undefined, y: number | undefined, shadowStyles: string | undefined, kShadow: KShadow | undefined, bounds: Bounds, href: string): VNode;
/**
* Renders an arc with all given information.
*
* @param lineStyles style information for lines (stroke etc.)
* @param colorStyles style information for color
* @param shadowStyles specific shadow filter ID, if this element should be drawn with a smooth shadow and no simple one.
* @param path The 'd' attribute for SVG <path>
* @param kShadow general shadow information.
* @returns An array of SVG <path>s resulting from this. Only multiple <path>s if a simple shadow effect should be applied.
*/
export declare function renderSVGArc(lineStyles: LineStyles, colorStyles: ColorStyles, shadowStyles: string | undefined, path: string, kShadow: KShadow | undefined): VNode[];
/**
* Renders an arc with all given information.
* If the rendering is a shadow (has a kShadow parameter), all stroke attributes are ignored (no stroke on the shadow) and a
* black fill with 0.1 alpha is returned.
*
* @param x x offset of the arc, to be used for shadows only.
* @param y y offset of the arc, to be used for shadows only.
* @param shadowStyles specific shadow filter ID, if this element should be drawn with a smooth shadow and no simple one.
* @param kShadow shadow information. Controls what this method does.
* @param lineStyles style information for lines (stroke etc.)
* @param colorStyles style information for color
* @param path The 'd' attribute for the SVG <path>
* @returns A single SVG <path>.
*/
export declare function renderSingleSVGArc(x: number | undefined, y: number | undefined, shadowStyles: string | undefined, kShadow: KShadow | undefined, lineStyles: LineStyles, colorStyles: ColorStyles, path: string): VNode;
/**
* Renders an ellipse with all given information.
*
* @param lineWidth width of the line to offset the ellipse's position and size by.
* @param lineStyles style information for lines (stroke etc.)
* @param colorStyles style information for color
* @param shadowStyles specific shadow filter ID, if this element should be drawn with a smooth shadow and no simple one.
* @param kShadow general shadow information.
* @returns An array of SVG <ellipse>s resulting from this. Only multiple <ellipse>s if a simple shadow effect should be applied.
*/
export declare function renderSVGEllipse(bounds: Bounds, lineWidth: number, lineStyles: LineStyles, colorStyles: ColorStyles, shadowStyles: string | undefined, kShadow: KShadow | undefined): VNode[];
/**
* Renders an ellipse with all given information.
* If the rendering is a shadow (has a kShadow parameter), all stroke attributes are ignored (no stroke on the shadow) and a
* black fill with 0.1 alpha is returned.
*
* @param x x offset of the ellipse, to be used for shadows only.
* @param y y offset of the ellipse, to be used for shadows only.
* @param shadowStyles specific shadow filter ID, if this element should be drawn with a smooth shadow and no simple one.
* @param kShadow shadow information. Controls what this method does.
* @param bounds bounds data calculated for this ellipse.
* @param lineWidth width of the line to offset the ellipse's position and size by.
* @param lineStyles style information for lines (stroke etc.)
* @param colorStyles style information for color
* @returns A single SVG <ellipse>.
*/
export declare function renderSingleSVGEllipse(x: number | undefined, y: number | undefined, shadowStyles: string | undefined, kShadow: KShadow | undefined, bounds: Bounds, lineWidth: number, lineStyles: LineStyles, colorStyles: ColorStyles): VNode;
/**
* Renders a rendering with a specific path (polyline, polygon, etc.) with all given information.
*
* @param lineStyles style information for lines (stroke etc.)
* @param colorStyles style information for color
* @param shadowStyles specific shadow filter ID, if this element should be drawn with a smooth shadow and no simple one.
* @param path The 'd' attribute for the SVG <path>
* @param kShadow general shadow information.
* @returns An array of SVG <path>s resulting from this. Only multiple <path>s if a simple shadow effect should be applied.
*/
export declare function renderSVGLine(lineStyles: LineStyles, colorStyles: ColorStyles, shadowStyles: string | undefined, path: string, kShadow: KShadow | undefined): VNode[];
/**
* Renders a rendering with a specific path (polyline, polygon, etc.) with all given information.
* If the rendering is a shadow (has a kShadow parameter), all stroke attributes are ignored (no stroke on the shadow) and a
* black fill with 0.1 alpha is returned.
*
* @param x x offset of the line, to be used for shadows only.
* @param y y offset of the line, to be used for shadows only.
* @param shadowStyles specific shadow filter ID, if this element should be drawn with a smooth shadow and no simple one.
* @param kShadow shadow information. Controls what this method does.
* @param lineStyles style information for lines (stroke etc.)
* @param colorStyles style information for color
* @param path The 'd' attribute for the SVG <path>.
* @returns A single SVG <path>.
*/
export declare function renderSingleSVGLine(x: number | undefined, y: number | undefined, shadowStyles: string | undefined, kShadow: KShadow | undefined, lineStyles: LineStyles, colorStyles: ColorStyles, path: string): VNode;
/**
* Looks up the KRendering in the given data pool and generates a SVG rendering from that.
* @param datas The list of possible KRenderings and additional data.
* @param parent The parent element containing this rendering.
* @param propagatedStyles The styles propagated from parent elements that should be taken into account.
* @param context The rendering context for this rendering.
* @param childOfNodeTitle If this rendering is a child of a node title. May override special renderings
*/
export declare function getRendering(datas: KGraphData[], parent: SKGraphElement, propagatedStyles: KStyles, context: SKGraphModelRenderer, childOfNodeTitle?: boolean): VNode | undefined;
/**
* Translates any KRendering into an SVG rendering.
* @param kRendering The rendering.
* @param parent The parent element.
* @param propagatedStyles The styles propagated from parent elements that should be taken into account.
* @param context The rendering context for this element.
* @param childOfNodeTitle If this rendering is a child of a node title. May override special renderings
*/
export declare function renderKRendering(kRendering: KRendering, parent: SKGraphElement | SKLabel, propagatedStyles: KStyles, context: SKGraphModelRenderer, childOfNodeTitle?: boolean): VNode | undefined;
/**
* Renders all junction points of the given edge.
* @param edge The edge the junction points should be rendered for.
* @param context The rendering context for this rendering.
*/
export declare function getJunctionPointRenderings(edge: SKEdge, context: SKGraphModelRenderer): VNode[];
//# sourceMappingURL=views-rendering.d.ts.map