UNPKG

@kieler/klighd-core

Version:

Core KLighD diagram visualization with Sprotty

218 lines 11.2 kB
/** @jsx svg */ import { KGraphData, SKGraphElement } from '@kieler/klighd-interactive/lib/constraint-classes'; import { VNode } from 'snabbdom'; import { SKGraphModelRenderer } from './skgraph-model-renderer'; import { HorizontalAlignment, KBackground, KColoring, KFontBold, KFontItalic, KFontName, KFontSize, KForeground, KHorizontalAlignment, KInvisibility, KLineCap, KLineJoin, KLineStyle, KLineWidth, KRotation, KShadow, KStyle, KStyleHolder, KStyleRef, KTextStrikeout, KTextUnderline, KVerticalAlignment, LineCap, LineJoin, LineStyle, SKEdge, VerticalAlignment } from './skgraph-models'; export declare const K_COLORING = "KColoringImpl"; export declare const K_BACKGROUND = "KBackgroundImpl"; export declare const K_FOREGROUND = "KForegroundImpl"; export declare const K_FONT_BOLD = "KFontBoldImpl"; export declare const K_FONT_ITALIC = "KFontItalicImpl"; export declare const K_FONT_NAME = "KFontNameImpl"; export declare const K_FONT_SIZE = "KFontSizeImpl"; export declare const K_HORIZONTAL_ALIGNMENT = "KHorizontalAlignmentImpl"; export declare const K_INVISIBILITY = "KInvisibilityImpl"; export declare const K_LINE_CAP = "KLineCapImpl"; export declare const K_LINE_JOIN = "KLineJoinImpl"; export declare const K_LINE_STYLE = "KLineStyleImpl"; export declare const K_LINE_WIDTH = "KLineWidthImpl"; export declare const K_ROTATION = "KRotationImpl"; export declare const K_SHADOW = "KShadowImpl"; export declare const K_STYLE_REF = "KStyleRefImpl"; export declare const K_TEXT_STRIKEOUT = "KTextStrikeoutImpl"; export declare const K_TEXT_UNDERLINE = "KTextUnderlineImpl"; export declare const K_VERTICAL_ALIGNMENT = "KVerticalAlignmentImpl"; export declare const DEFAULT_FONT_BOLD = false; export declare const DEFAULT_K_FONT_BOLD: KFontBold; export declare const DEFAULT_FONT_ITALIC = false; export declare const DEFAULT_K_FONT_ITALIC: KFontItalic; export declare const DEFAULT_FONT_NAME = "Overpass, sans-serif"; export declare const DEFAULT_K_FONT_NAME: KFontName; export declare const DEFAULT_FONT_SIZE = 10; export declare const DEFAULT_K_FONT_SIZE: KFontSize; export declare const DEFAULT_HORIZONTAL_ALIGNMENT = HorizontalAlignment.CENTER; export declare const DEFAULT_K_HORIZONTAL_ALIGNMENT: KHorizontalAlignment; export declare const DEFAULT_INVISIBILITY = false; export declare const DEFAULT_K_INVISIBILITY: KInvisibility; export declare const DEFAULT_LINE_CAP = LineCap.CAP_FLAT; export declare const DEFAULT_K_LINE_CAP: KLineCap; export declare const DEFAULT_LINE_JOIN = LineJoin.JOIN_MITER; export declare const DEFAULT_MITER_LIMIT = 10; export declare const DEFAULT_K_LINE_JOIN: KLineJoin; export declare const DEFAULT_LINE_STYLE = LineStyle.SOLID; export declare const DEFAULT_K_LINE_STYLE: KLineStyle; export declare const DEFAULT_LINE_WIDTH = 1; export declare const DEFAULT_K_LINE_WIDTH: KLineWidth; export declare const DEFAULT_FILL: ColorStyle; export declare const DEFAULT_CLICKABLE_FILL: ColorStyle; export declare const DEFAULT_FOREGROUND: ColorStyle; export declare const DEFAULT_VERTICAL_ALIGNMENT = VerticalAlignment.CENTER; export declare const DEFAULT_K_VERTICAL_ALIGNMENT: KVerticalAlignment; export declare const DEFAULT_SHADOW: undefined; export declare const DEFAULT_SHADOW_DEF: undefined; export declare const DEFAULT_CORNER_WIDTH = 0; export declare const DEFAULT_CORNER_HEIGHT = 0; export declare const DEFAULT_LINE_CAP_SVG = "butt"; export declare const DEFAULT_LINE_JOIN_SVG = "miter"; export declare const DEFAULT_MITER_LIMIT_SVG = "4"; /** * Data class to hold each possible KStyle of any rendering. Defaults each style to undefined or its default value from PNodeController.java */ export declare class KStyles { kBackground: KBackground | undefined; kForeground: KForeground | undefined; kFontBold: KFontBold | undefined; kFontItalic: KFontItalic | undefined; kFontName: KFontName | undefined; kFontSize: KFontSize | undefined; kHorizontalAlignment: KHorizontalAlignment | undefined; kInvisibility: KInvisibility | undefined; kLineCap: KLineCap | undefined; kLineJoin: KLineJoin | undefined; kLineStyle: KLineStyle | undefined; kLineWidth: KLineWidth | undefined; kRotation: KRotation | undefined; kShadow: KShadow | undefined; kStyleRef: KStyleRef | undefined; kTextStrikeout: KTextStrikeout | undefined; kTextUnderline: KTextUnderline | undefined; kVerticalAlignment: KVerticalAlignment | undefined; constructor(initialize?: boolean); } /** * Calculates the renderings for all styles contained in styleList into an object. * @param styleList The list of all styles that should have their rendering calculated. * @param propagatedStyles The styles propagated from parent elements that should be taken into account. * @param stylesToPropagate The optional styles object that should be propagated further to children. It is modified in this method. */ export declare function getKStyles(parent: SKGraphElement, styleHolder: KStyleHolder & KGraphData, propagatedStyles: KStyles, context: SKGraphModelRenderer, stylesToPropagate?: KStyles): KStyles; /** * The default selection styles for text renderings. * @returns A list of default selection text styles. */ export declare function getDefaultTextSelectionStyles(): KStyle[]; /** * The default selection styles for non-text renderings. * @returns A list of default selection non-text styles. */ export declare function getDefaultNonTextSelectionStyles(): KStyle[]; /** * Apply the given style to the given styles object. If it should be propagated, also apply it to the stylesToPropagage object. * @param style The style to apply. * @param styles The styles object the style should be applied to. * @param stylesToPropagage The styles object that gets propagated. */ export declare function applyKStyle(style: KStyle, styles: KStyles, stylesToPropagage?: KStyles): void; /** * Copies the content from one to the other KStyles object. * @param from The KStyles to copy from. * @param to The KStyles to copy to. */ export declare function copyStyles(from: KStyles, to: KStyles): void; /** * SVG element for color gradient definition. * @param colorId The unique identifying string for this color. * @param start The SVG data for the start color of the gradient. * @param end The SVG data for the end color of the gradient. * @param angle The angle at which the gradient should flow. */ export declare function colorDefinition(colorId: string, start: ColorStyle, end: ColorStyle, angle: number | undefined): VNode; /** * SVG element for a shadow definition. * @param shadowId The unique identifying string for this shadow. * @param color The color of the shadow. * @param blur The amount of blur of the shadow. * @param xOffset The x-offset of the shadow. * @param yOffset The y-offset of the shadow. */ export declare function shadowDefinition(shadowId: string, color: string | undefined, blur: number, xOffset: number, yOffset: number): VNode; /** * Returns the identifying string for the given shadow style, that can be put into the SVG 'filter' attribute. * Also remembers the shadow definition in the rendering context to be added to the top of the final SVG. * @param styles The KStyles of the rendering. * @param context The rendering context. */ export declare function getSvgShadowStyles(styles: KStyles, context: SKGraphModelRenderer): string | undefined; /** * Returns the identifying strings for the given foreground- and background styles that can be put in the SVG 'stroke' and 'fill' attributes, * depending on the rendering the styles have to be applied for. * The identifying string can either be a simple rgb color reference (such as rgb(0,0,0) for black), a rgba color reference (such as rgba(0,0,0,128) for a transparent black) * or a url for a gradient color definition that is remembered in the rendering context and has to be added to the SVG later. * @param styles The KStyles of the rendering. * @param context The rendering context. */ export declare function getSvgColorStyles(styles: KStyles, context: SKGraphModelRenderer, parent: SKGraphElement | SKEdge): ColorStyles; /** * The same as getSvgColorStyles, only that it only handles one of the two styles. * @param coloring The KColoring of which the color string should be returned. * @param context The rendering context. * @see getSvgColorStyles */ export declare function getSvgColorStyle(coloring: KColoring | undefined, context: SKGraphModelRenderer): ColorStyle | undefined; /** * Returns if the rendering should be rendered or if it is invisible and only its children are relevant. * @param styles The KStyles of the rendering. */ export declare function isInvisible(styles: KStyles): boolean; /** * Returns the SVG strings for line styles that can be applied to the following SVG attributes: * 'stroke-linecap' has to be set to the lineCap style, * 'stroke-linejoin' has to be set to the lineJoin style, * 'stroke-width' has to be set to the lineWidth style, * 'stroke-dasharray' has to be set to the dashArray style, * 'stroke-miterlimit' has to be set to the miterLimit style. (This is not a string, but a number.) * @param styles The KStyles of the rendering. * @param target The target of the line * @param context The current rendering context */ export declare function getSvgLineStyles(styles: KStyles, target: SKGraphElement, context: SKGraphModelRenderer): LineStyles; /** * Returns the SVG strings for text styles that can be applied to the following SVG attributes: * 'dominant-baseline' has to be set to the dominantBaseline style, * 'font-family' has to be set to the fontFamily style, * 'font-size' has to be set to the fontSize style, * 'font-style' has to be set to the fontStyle style, * 'font-weight' has to be set to the fontWeight style, * 'text-decoration-line' has to be set to the textDecorationLine style, * 'text-decoration-style' has to be set to the textDecorationStyle style. * @param styles The KStyles of the rendering. */ export declare function getSvgTextStyles(styles: KStyles): TextStyles; /** * Data class holding the SVG attributes for a single color */ export interface ColorStyle { color: string; opacity: string | undefined; } /** * Data class holding the different SVG attributes for color related styles. */ export interface ColorStyles { foreground: ColorStyle; background: ColorStyle; opacity: string; } /** * Data class holding the different SVG attributes for line related styles. */ export interface LineStyles { lineWidth: string | undefined; lineCap: 'butt' | 'round' | 'square' | undefined; lineJoin: 'bevel' | 'miter' | 'round' | undefined; dashArray: string | undefined; miterLimit: string | undefined; } /** * Data class holding the different SVG attributes for text related styles. */ export interface TextStyles { dominantBaseline: string | undefined; fontFamily: string | undefined; fontSize: string | undefined; fontStyle: string | undefined; fontWeight: string | undefined; textDecorationLine: string | undefined; textDecorationStyle: string | undefined; } //# sourceMappingURL=views-styles.d.ts.map