UNPKG

@kieler/klighd-core

Version:

Core KLighD diagram visualization with Sprotty

296 lines 12.2 kB
"use strict"; /* * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient * * http://rtsys.informatik.uni-kiel.de/kieler * * Copyright 2019-2024 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.isSKGraphElement = exports.isKText = exports.isPolyline = exports.isContainerRendering = exports.isRendering = exports.K_TEXT = exports.K_ROUNDED_RECTANGLE = exports.K_RECTANGLE = exports.K_SPLINE = exports.K_ROUNDED_BENDS_POLYLINE = exports.K_POLYGON = exports.K_POLYLINE = exports.K_IMAGE = exports.K_ELLIPSE = exports.K_CUSTOM_RENDERING = exports.K_ARC = exports.K_CONTAINER_RENDERING = exports.K_CHILD_AREA = exports.K_RENDERING_LIBRARY = exports.K_RENDERING_REF = exports.Underline = exports.LineStyle = exports.LineJoin = exports.LineCap = exports.Trigger = exports.VerticalAlignment = exports.HorizontalAlignment = exports.Arc = exports.ModifierState = exports.SKEdge = exports.SKLabel = exports.SKPort = exports.SKNode = exports.LABEL_TYPE = exports.PORT_TYPE = exports.EDGE_TYPE = exports.NODE_TYPE = void 0; const constraint_classes_1 = require("@kieler/klighd-interactive/lib/constraint-classes"); const sprotty_1 = require("sprotty"); exports.NODE_TYPE = 'node'; exports.EDGE_TYPE = 'edge'; exports.PORT_TYPE = 'port'; exports.LABEL_TYPE = 'label'; /** * Represents the Sprotty version of its java counterpart in KLighD. */ class SKNode extends constraint_classes_1.KNode { hasFeature(feature) { return (feature === sprotty_1.selectFeature || feature === sprotty_1.boundsFeature || feature === sprotty_1.layoutContainerFeature || (feature === sprotty_1.moveFeature && this.parent.properties && this.parent.properties['org.eclipse.elk.interactiveLayout']) || feature === sprotty_1.popupFeature); } } exports.SKNode = SKNode; /** * Represents the Sprotty version of its java counterpart in KLighD. */ class SKPort extends sprotty_1.RectangularPort { constructor() { super(...arguments); this.areChildAreaChildrenRendered = false; this.areNonChildAreaChildrenRendered = false; } hasFeature(feature) { return feature === sprotty_1.selectFeature || feature === sprotty_1.boundsFeature || feature === sprotty_1.popupFeature; } } exports.SKPort = SKPort; /** * Represents the Sprotty version of its java counterpart in KLighD. */ class SKLabel extends sprotty_1.SLabelImpl { constructor() { super(...arguments); this.areChildAreaChildrenRendered = false; this.areNonChildAreaChildrenRendered = false; } hasFeature(feature) { // The boundsFeature here is additionally needed because bounds of labels need to be // estimated during the estimateTextBounds action. return feature === sprotty_1.selectFeature || feature === sprotty_1.boundsFeature || feature === sprotty_1.popupFeature; } } exports.SKLabel = SKLabel; /** * Represents the Sprotty version of its java counterpart in KLighD. */ class SKEdge extends constraint_classes_1.KEdge { hasFeature(feature) { return feature === sprotty_1.selectFeature || feature === sprotty_1.popupFeature; } } exports.SKEdge = SKEdge; /** * The state of a modifier that it has to be in in order for some action to be performed. */ var ModifierState; (function (ModifierState) { ModifierState[ModifierState["DONT_CARE"] = 0] = "DONT_CARE"; ModifierState[ModifierState["PRESSED"] = 1] = "PRESSED"; ModifierState[ModifierState["NOT_PRESSED"] = 2] = "NOT_PRESSED"; })(ModifierState || (exports.ModifierState = ModifierState = {})); /** * The literals mirror the constants java.awt.geom.Arc2D#OPEN, java.awt.geom.Arc2D#CHORD, and java.awt.geom.Arc2D#PIE. * This is to be leveraged in implementation, so be careful while modifying this enumeration. * Represents its java counterpart in KLighD. */ var Arc; (function (Arc) { /** * Plain arc without any closing line connection from end to beginning. */ Arc[Arc["OPEN"] = 0] = "OPEN"; /** * Arc with a straight closing line connection from end to beginning via the arc's center. */ Arc[Arc["CHORD"] = 1] = "CHORD"; /** * Arc with a straight closing line connection from end to beginning. */ Arc[Arc["PIE"] = 2] = "PIE"; })(Arc || (exports.Arc = Arc = {})); /** * Represents its java counterpart in KLighD. */ var HorizontalAlignment; (function (HorizontalAlignment) { HorizontalAlignment[HorizontalAlignment["LEFT"] = 0] = "LEFT"; HorizontalAlignment[HorizontalAlignment["CENTER"] = 1] = "CENTER"; HorizontalAlignment[HorizontalAlignment["RIGHT"] = 2] = "RIGHT"; })(HorizontalAlignment || (exports.HorizontalAlignment = HorizontalAlignment = {})); /** * Represents its java counterpart in KLighD. */ var VerticalAlignment; (function (VerticalAlignment) { VerticalAlignment[VerticalAlignment["TOP"] = 0] = "TOP"; VerticalAlignment[VerticalAlignment["CENTER"] = 1] = "CENTER"; VerticalAlignment[VerticalAlignment["BOTTOM"] = 2] = "BOTTOM"; })(VerticalAlignment || (exports.VerticalAlignment = VerticalAlignment = {})); /** * Trigger presets to determine when to execute actions. * Represents its java counterpart in KLighD. */ var Trigger; (function (Trigger) { /** * Fires on a left button's single click. * Note: Corresponding actions are not fired on the first click of a double, tripple, ... click. * Thus, triggering the actions is delayed by the system wide double click period for assuring the absence of subsequent clicks. * TODO: check if this is also true on the client! */ Trigger[Trigger["SINGLECLICK"] = 0] = "SINGLECLICK"; /** * Fires on left button's double (and more) click(s). */ Trigger[Trigger["DOUBLECLICK"] = 1] = "DOUBLECLICK"; /** * Fires on left button's first click regardless if more clicks follow within the system wide double click period. */ Trigger[Trigger["SINGLE_OR_MULTICLICK"] = 2] = "SINGLE_OR_MULTICLICK"; /** * Fires on middle button's single click. * Note: Corresponding actions are not fired on the first click of a double, tripple, ... click. * Thus, triggering the actions is delayed by the system wide double click period for assuring the absence of subsequent clicks. */ Trigger[Trigger["MIDDLE_SINGLECLICK"] = 3] = "MIDDLE_SINGLECLICK"; /** * Fires on middle button's double (and more) click(s). */ Trigger[Trigger["MIDDLE_DOUBLECLICK"] = 4] = "MIDDLE_DOUBLECLICK"; /** * Fires on middle button's first click regardless if more clicks follow within the system wide double click period. */ Trigger[Trigger["MIDDLE_SINGLE_OR_MULTICLICK"] = 5] = "MIDDLE_SINGLE_OR_MULTICLICK"; })(Trigger || (exports.Trigger = Trigger = {})); /** * LineCapStyles analog to SWT LineCapStyles. * Represents its java counterpart in KLighD. */ var LineCap; (function (LineCap) { LineCap[LineCap["CAP_FLAT"] = 0] = "CAP_FLAT"; LineCap[LineCap["CAP_ROUND"] = 1] = "CAP_ROUND"; LineCap[LineCap["CAP_SQUARE"] = 2] = "CAP_SQUARE"; })(LineCap || (exports.LineCap = LineCap = {})); /** * Represents its java counterpart in KLighD. */ var LineJoin; (function (LineJoin) { LineJoin[LineJoin["JOIN_MITER"] = 0] = "JOIN_MITER"; LineJoin[LineJoin["JOIN_ROUND"] = 1] = "JOIN_ROUND"; LineJoin[LineJoin["JOIN_BEVEL"] = 2] = "JOIN_BEVEL"; })(LineJoin || (exports.LineJoin = LineJoin = {})); /** * LineStyles analog to SWT LineStyles. * Represents its java counterpart in KLighD. */ var LineStyle; (function (LineStyle) { LineStyle[LineStyle["SOLID"] = 0] = "SOLID"; LineStyle[LineStyle["DASH"] = 1] = "DASH"; LineStyle[LineStyle["DOT"] = 2] = "DOT"; LineStyle[LineStyle["DASHDOT"] = 3] = "DASHDOT"; LineStyle[LineStyle["DASHDOTDOT"] = 4] = "DASHDOTDOT"; LineStyle[LineStyle["CUSTOM"] = 5] = "CUSTOM"; })(LineStyle || (exports.LineStyle = LineStyle = {})); /** * The style of an underline. Analog to SWT Underline. * Represents its java counterpart in KLighD. */ var Underline; (function (Underline) { Underline[Underline["NONE"] = 0] = "NONE"; Underline[Underline["SINGLE"] = 1] = "SINGLE"; Underline[Underline["DOUBLE"] = 2] = "DOUBLE"; Underline[Underline["ERROR"] = 3] = "ERROR"; Underline[Underline["SQUIGGLE"] = 4] = "SQUIGGLE"; Underline[Underline["LINK"] = 5] = "LINK"; })(Underline || (exports.Underline = Underline = {})); // ----------- Rendering Class names ----------- // exports.K_RENDERING_REF = 'KRenderingRefImpl'; exports.K_RENDERING_LIBRARY = 'KRenderingLibraryImpl'; exports.K_CHILD_AREA = 'KChildAreaImpl'; exports.K_CONTAINER_RENDERING = 'KContainerRenderingImpl'; exports.K_ARC = 'KArcImpl'; exports.K_CUSTOM_RENDERING = 'KCustomRenderingImpl'; exports.K_ELLIPSE = 'KEllipseImpl'; exports.K_IMAGE = 'KImageImpl'; exports.K_POLYLINE = 'KPolylineImpl'; exports.K_POLYGON = 'KPolygonImpl'; exports.K_ROUNDED_BENDS_POLYLINE = 'KRoundedBendsPolylineImpl'; exports.K_SPLINE = 'KSplineImpl'; exports.K_RECTANGLE = 'KRectangleImpl'; exports.K_ROUNDED_RECTANGLE = 'KRoundedRectangleImpl'; exports.K_TEXT = 'KTextImpl'; /** * Returns if the given parameter is a KRendering. * instanceof cannot be used, because every rendering received by the server is typed as KGraphData and the real type can only be inferred using the type attribute. * @param test The potential KRendering. */ function isRendering(test) { const { type } = test; return (type === exports.K_RENDERING_REF || type === exports.K_CHILD_AREA || type === exports.K_CONTAINER_RENDERING || type === exports.K_ARC || type === exports.K_CUSTOM_RENDERING || type === exports.K_ELLIPSE || type === exports.K_IMAGE || type === exports.K_POLYLINE || type === exports.K_POLYGON || type === exports.K_ROUNDED_BENDS_POLYLINE || type === exports.K_SPLINE || type === exports.K_RECTANGLE || type === exports.K_ROUNDED_RECTANGLE || type === exports.K_TEXT); } exports.isRendering = isRendering; /** * Returns if the given parameter is a KContainerRendering. * @param test The potential KContainerRendering. */ function isContainerRendering(test) { const { type } = test; return (type === exports.K_CONTAINER_RENDERING || type === exports.K_ARC || type === exports.K_CUSTOM_RENDERING || type === exports.K_ELLIPSE || type === exports.K_IMAGE || type === exports.K_POLYLINE || type === exports.K_POLYGON || type === exports.K_ROUNDED_BENDS_POLYLINE || type === exports.K_SPLINE || type === exports.K_RECTANGLE || type === exports.K_ROUNDED_RECTANGLE); } exports.isContainerRendering = isContainerRendering; /** * Returns if the given parameter is a KPolyline. * @param test The potential KPolyline. */ function isPolyline(test) { const { type } = test; return type === exports.K_POLYLINE || type === exports.K_POLYGON || type === exports.K_ROUNDED_BENDS_POLYLINE || type === exports.K_SPLINE; } exports.isPolyline = isPolyline; /** * Returns if the given parameter is a KText. * @param test The potential KText */ function isKText(test) { const { type } = test; return type === exports.K_TEXT; } exports.isKText = isKText; /** * Returns if the given parameter is an SKGraphElement. * @param test The potential SKGraphElement. */ function isSKGraphElement(test) { return (test instanceof sprotty_1.SModelElementImpl && test.areChildAreaChildrenRendered !== undefined && test.areNonChildAreaChildrenRendered !== undefined && test.opacity !== undefined && test.data !== undefined); } exports.isSKGraphElement = isSKGraphElement; //# sourceMappingURL=skgraph-models.js.map