@kieler/klighd-interactive
Advanced tools
Comparing version 0.3.0-next.c73817f to 0.3.0-next.d995a50
@@ -36,3 +36,3 @@ import { RectangularNode, SEdge, SParentElement } from 'sprotty'; | ||
hasFeature(feature: symbol): boolean; | ||
properties: NodeProperties; | ||
properties: Record<string, unknown>; | ||
direction: Direction; | ||
@@ -51,18 +51,2 @@ shadow: boolean; | ||
/** | ||
* Properties needed for client side layout or visualization. | ||
* Send together with the nodes from server to client. | ||
* They correspond to properties on the server. | ||
*/ | ||
export declare class NodeProperties { | ||
algorithm: string; | ||
aspectRatio: number; | ||
currentPosition: number; | ||
desiredPosition: number; | ||
interactiveLayout: boolean; | ||
layerConstraint: number; | ||
layerId: number; | ||
positionConstraint: number; | ||
positionId: number; | ||
} | ||
/** | ||
* This class can be extended to hold arbitrary additional data for | ||
@@ -69,0 +53,0 @@ * graph elements, such as layout or rendering information. |
@@ -34,3 +34,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.KEdge = exports.NodeProperties = exports.Direction = exports.KNode = void 0; | ||
exports.KEdge = exports.Direction = exports.KNode = void 0; | ||
var sprotty_1 = require("sprotty"); | ||
@@ -49,3 +49,3 @@ /** | ||
KNode.prototype.hasFeature = function (feature) { | ||
return feature === sprotty_1.selectFeature || (feature === sprotty_1.moveFeature && this.parent.properties.interactiveLayout); | ||
return feature === sprotty_1.selectFeature || (feature === sprotty_1.moveFeature && this.parent.properties['org.eclipse.elk.interactiveLayout']); | ||
}; | ||
@@ -64,13 +64,2 @@ return KNode; | ||
/** | ||
* Properties needed for client side layout or visualization. | ||
* Send together with the nodes from server to client. | ||
* They correspond to properties on the server. | ||
*/ | ||
var NodeProperties = /** @class */ (function () { | ||
function NodeProperties() { | ||
} | ||
return NodeProperties; | ||
}()); | ||
exports.NodeProperties = NodeProperties; | ||
/** | ||
* Represents its java counterpart in KLighD. | ||
@@ -77,0 +66,0 @@ */ |
@@ -16,6 +16,6 @@ "use strict"; | ||
var result = undefined; | ||
if (root.properties.algorithm === undefined || root.properties.algorithm.endsWith('layered')) { | ||
if (root.properties['org.eclipse.elk.algorithm'] === undefined || root.properties['org.eclipse.elk.algorithm'].endsWith('layered')) { | ||
result = layered_interactive_view_1.renderHierarchyLevel(nodes); | ||
} | ||
else if (root.properties.algorithm.endsWith('rectpacking')) { | ||
else if (root.properties['org.eclipse.elk.algorithm'].endsWith('rectpacking')) { | ||
result = rect_packing_interactive_view_1.renderHierarchyLevel(nodes); | ||
@@ -36,3 +36,3 @@ } | ||
var result = sprotty_1.svg("g", null); | ||
var algorithm = node.parent.properties.algorithm; | ||
var algorithm = node.parent.properties['org.eclipse.elk.algorithm']; | ||
if (algorithm === undefined || algorithm.endsWith('layered')) { | ||
@@ -42,3 +42,3 @@ result = layered_interactive_view_1.renderLayeredConstraint(node); | ||
else if (algorithm.endsWith('rectpacking')) { | ||
if (node.properties.desiredPosition !== -1) { | ||
if (node.properties['org.eclipse.elk.alg.rectpacking.desiredPosition'] !== -1) { | ||
result = rect_packing_interactive_view_1.renderRectPackConstraint(node); | ||
@@ -45,0 +45,0 @@ } |
@@ -99,7 +99,7 @@ "use strict"; | ||
if (targetNode && targetNode instanceof sprotty_1.SNode) { | ||
if (targetNode.parent.properties.interactiveLayout) { | ||
if (targetNode.parent.properties['org.eclipse.elk.interactiveLayout']) { | ||
this.target = targetNode; | ||
// Set layer bounds | ||
this.nodes = helper_methods_1.filterKNodes(this.target.parent.children); | ||
var algorithm = targetNode.parent.properties.algorithm; | ||
var algorithm = targetNode.parent.properties['org.eclipse.elk.algorithm']; | ||
// Set algorithm specific data | ||
@@ -147,3 +147,3 @@ if (algorithm === undefined || algorithm.endsWith('layered')) { | ||
var result = _super.prototype.mouseUp.call(this, this.target, event); | ||
var algorithm = this.target.parent.properties.algorithm; | ||
var algorithm = this.target.parent.properties['org.eclipse.elk.algorithm']; | ||
if (algorithm === undefined || algorithm.endsWith('layered')) { | ||
@@ -150,0 +150,0 @@ result = [constraint_utils_1.setProperty(this.nodes, this.data.get('layered'), this.target)].concat(_super.prototype.mouseUp.call(this, this.target, event)); |
@@ -68,3 +68,4 @@ "use strict"; | ||
// Examine all nodes that have a layer Id left or equal to the layerCandidate and that have a layerCons > their layerId | ||
var layerConstraintLeftOfCandidate = nodes.filter(function (n) { return n.properties.layerId <= layerCandidate && n.properties.layerConstraint > n.properties.layerId; }); | ||
var layerConstraintLeftOfCandidate = nodes.filter(function (n) { return n.properties['org.eclipse.elk.layered.layering.layerId'] <= layerCandidate | ||
&& n.properties['org.eclipse.elk.layered.layering.layerChoiceConstraint'] > n.properties['org.eclipse.elk.layered.layering.layerId']; }); | ||
// In case that there are no such nodes return the layerCandidate | ||
@@ -81,3 +82,3 @@ if (layerConstraintLeftOfCandidate.length === 0) { | ||
var n = layerConstraintLeftOfCandidate_1[_i]; | ||
var layerConstraint = n.properties.layerConstraint; | ||
var layerConstraint = n.properties['org.eclipse.elk.layered.layering.layerChoiceConstraint']; | ||
if (layerConstraint > maxCons) { | ||
@@ -89,3 +90,3 @@ nodeWithMaxCons = n; | ||
if (nodeWithMaxCons !== null) { | ||
var idDiff = layerCandidate - nodeWithMaxCons.properties.layerId; | ||
var idDiff = layerCandidate - nodeWithMaxCons.properties['org.eclipse.elk.layered.layering.layerId']; | ||
return maxCons + idDiff; | ||
@@ -109,5 +110,5 @@ } | ||
var upperNeighbor = layerNodes[upperIndex]; | ||
var posConsOfUpper = upperNeighbor.properties.positionConstraint; | ||
var posConsOfUpper = upperNeighbor.properties['org.eclipse.elk.layered.crossingMinimization.positionChoiceConstraint']; | ||
if (posConsOfUpper > upperIndex) { | ||
if (alreadyInLayer && upperNeighbor.properties.positionId === localTargetIndex) { | ||
if (alreadyInLayer && upperNeighbor.properties['org.eclipse.elk.layered.crossingMinimization.positionId'] === localTargetIndex) { | ||
localTargetIndex = posConsOfUpper; | ||
@@ -129,3 +130,3 @@ } | ||
// All nodes within one hierarchy level have the same direction | ||
nodes.sort(function (a, b) { return a.properties.layerId - b.properties.layerId; }); | ||
nodes.sort(function (a, b) { return a.properties['org.eclipse.elk.layered.layering.layerId'] - b.properties['org.eclipse.elk.layered.layering.layerId']; }); | ||
var layers = []; | ||
@@ -142,3 +143,3 @@ var layer = 0; | ||
var node = nodes[i]; | ||
if (node.properties.layerId !== layer) { | ||
if (node.properties['org.eclipse.elk.layered.layering.layerId'] !== layer) { | ||
// node is in the next layer | ||
@@ -276,3 +277,3 @@ layers[layer] = new constraint_types_1.Layer(beginCoordinate, endCoordinate, beginCoordinate + (endCoordinate - beginCoordinate) / 2, direction); | ||
var node = nodes_1[_i]; | ||
if (node.properties.layerId === layer) { | ||
if (node.properties['org.eclipse.elk.layered.layering.layerId'] === layer) { | ||
nodesOfLayer[nodesOfLayer.length] = node; | ||
@@ -328,3 +329,5 @@ } | ||
var node_1 = connectedNodes_1[_b]; | ||
if (node_1.properties.layerId === layer && node_1.properties.layerConstraint !== -1) { | ||
if (node_1.properties['org.eclipse.elk.layered.layering.layerId'] === layer | ||
&& node_1.properties['org.eclipse.elk.layered.layering.layerChoiceConstraint'] !== -1 | ||
&& node_1.properties['org.eclipse.elk.layered.layering.layerChoiceConstraint'] !== undefined) { | ||
// layer is forbidden for the given node | ||
@@ -373,3 +376,3 @@ return true; | ||
} | ||
else if (targetNode.properties.layerId !== layerOfTarget) { | ||
else if (targetNode.properties['org.eclipse.elk.layered.layering.layerId'] !== layerOfTarget) { | ||
// layer constraint should only be set if the layer index changed | ||
@@ -397,3 +400,3 @@ if (shouldOnlyLCBeSet(targetNode, layers, direction)) { | ||
// position constraint should only be set if the position of the node changed | ||
if (targetNode.properties.positionId !== positionOfTarget) { | ||
if (targetNode.properties['org.eclipse.elk.layered.crossingMinimization.positionId'] !== positionOfTarget) { | ||
// set the position Constraint | ||
@@ -400,0 +403,0 @@ return actions_2.SetPositionConstraintAction.create({ |
@@ -27,3 +27,3 @@ "use strict"; | ||
// determines whether only the layer constraint will be set when the node is released | ||
var onlyLC = constraint_utils_1.shouldOnlyLCBeSet(selNode, layers, direction) && selNode.properties.layerId !== currentLayer; | ||
var onlyLC = constraint_utils_1.shouldOnlyLCBeSet(selNode, layers, direction) && selNode.properties['org.eclipse.elk.layered.layering.layerId'] !== currentLayer; | ||
// create layers | ||
@@ -100,3 +100,3 @@ var result = sprotty_1.svg("g", null); | ||
var curPos = constraint_utils_1.getPositionInLayer(layerNodes, target); | ||
layerNodes.sort(function (a, b) { return a.properties.positionId - b.properties.positionId; }); | ||
layerNodes.sort(function (a, b) { return a.properties['org.eclipse.elk.layered.crossingMinimization.positionId'] - b.properties['org.eclipse.elk.layered.crossingMinimization.positionId']; }); | ||
if (layerNodes.length > 0) { | ||
@@ -260,13 +260,13 @@ var result = sprotty_1.svg("g", null); | ||
var constraintOffset = 2; | ||
var positionConstraint = node.properties.positionConstraint; | ||
var layerConstraint = node.properties.layerConstraint; | ||
if (layerConstraint !== -1 && positionConstraint !== -1) { | ||
var positionConstraint = node.properties['org.eclipse.elk.layered.crossingMinimization.positionChoiceConstraint']; | ||
var layerConstraint = node.properties['org.eclipse.elk.layered.layering.layerChoiceConstraint']; | ||
if (layerConstraint !== -1 && positionConstraint !== -1 && layerConstraint !== undefined && positionConstraint !== undefined) { | ||
// layer and position Constraint are set | ||
result = sprotty_1.svg("g", null, interactive_view_objects_1.renderLock(x, y)); | ||
} | ||
else if (layerConstraint !== -1) { | ||
else if (layerConstraint !== -1 && layerConstraint !== undefined) { | ||
// only layer Constraint is set | ||
result = sprotty_1.svg("g", null, renderLayerConstraint(x + constraintOffset, y - constraintOffset, node.direction)); | ||
} | ||
else if (positionConstraint !== -1) { | ||
else if (positionConstraint !== -1 && positionConstraint !== undefined) { | ||
// only position Constraint is set | ||
@@ -273,0 +273,0 @@ result = sprotty_1.svg("g", null, renderPositionConstraint(x + constraintOffset, y - constraintOffset, node.direction)); |
@@ -46,9 +46,9 @@ "use strict"; | ||
&& event.pageY > lowY && event.pageY < highY) { | ||
var actualPosition = node.properties.currentPosition; | ||
if (node.properties.desiredPosition !== -1) { | ||
actualPosition = node.properties.desiredPosition; | ||
var actualPosition = node.properties['org.eclipse.elk.rectPacking.currentPosition']; | ||
if (node.properties['org.eclipse.elk.alg.rectpacking.desiredPosition'] !== -1) { | ||
actualPosition = node.properties['org.eclipse.elk.alg.rectpacking.desiredPosition']; | ||
} | ||
var actualTargetPosition = target.properties.currentPosition; | ||
if (node.properties.desiredPosition !== -1) { | ||
actualTargetPosition = target.properties.desiredPosition; | ||
var actualTargetPosition = target.properties['org.eclipse.elk.rectPacking.currentPosition']; | ||
if (node.properties['org.eclipse.elk.alg.rectpacking.desiredPosition'] !== -1) { | ||
actualTargetPosition = target.properties['org.eclipse.elk.alg.rectpacking.desiredPosition']; | ||
} | ||
@@ -86,3 +86,3 @@ if (actualPosition !== actualTargetPosition && actualPosition !== -1) { | ||
// If changed update aspect ratio. | ||
if (parent && parent.properties.aspectRatio !== aspectRatio) { | ||
if (parent && parent.properties['org.eclipse.elk.rectPacking.aspectRatio'] !== aspectRatio) { | ||
return actions_1.SetAspectRatioAction.create({ | ||
@@ -89,0 +89,0 @@ id: parent.id, |
{ | ||
"name": "@kieler/klighd-interactive", | ||
"version": "0.3.0-next.c73817f", | ||
"version": "0.3.0-next.d995a50", | ||
"description": "A module for klighd-core to interactively apply constraints to the diagram", | ||
@@ -5,0 +5,0 @@ "author": "Kiel University <rt-kieler-devel@informatik.uni-kiel.de>", |
@@ -55,6 +55,6 @@ /* | ||
hasFeature(feature: symbol): boolean { | ||
return feature === selectFeature || (feature === moveFeature && (this.parent as KNode).properties.interactiveLayout) | ||
return feature === selectFeature || (feature === moveFeature && (this.parent as KNode).properties['org.eclipse.elk.interactiveLayout'] as boolean) | ||
} | ||
properties: NodeProperties | ||
properties: Record<string, unknown> | ||
@@ -77,19 +77,2 @@ direction: Direction | ||
/** | ||
* Properties needed for client side layout or visualization. | ||
* Send together with the nodes from server to client. | ||
* They correspond to properties on the server. | ||
*/ | ||
export class NodeProperties { | ||
algorithm: string | ||
aspectRatio: number | ||
currentPosition: number | ||
desiredPosition: number | ||
interactiveLayout: boolean | ||
layerConstraint: number | ||
layerId: number | ||
positionConstraint: number | ||
positionId: number | ||
} | ||
/** | ||
* This class can be extended to hold arbitrary additional data for | ||
@@ -96,0 +79,0 @@ * graph elements, such as layout or rendering information. |
@@ -84,3 +84,3 @@ /* | ||
if (targetNode && targetNode instanceof SNode) { | ||
if (((targetNode as KNode).parent as KNode).properties.interactiveLayout) { | ||
if (((targetNode as KNode).parent as KNode).properties['org.eclipse.elk.interactiveLayout']) { | ||
this.target = targetNode as KNode | ||
@@ -90,3 +90,3 @@ // Set layer bounds | ||
const algorithm = ((targetNode as KNode).parent as KNode).properties.algorithm | ||
const algorithm = ((targetNode as KNode).parent as KNode).properties['org.eclipse.elk.algorithm'] as string | ||
// Set algorithm specific data | ||
@@ -135,3 +135,3 @@ if (algorithm === undefined || algorithm.endsWith('layered')) { | ||
let result = super.mouseUp(this.target, event) | ||
const algorithm = (this.target.parent as KNode).properties.algorithm | ||
const algorithm = (this.target.parent as KNode).properties['org.eclipse.elk.algorithm'] as string | ||
if (algorithm === undefined || algorithm.endsWith('layered')) { | ||
@@ -138,0 +138,0 @@ result = [setProperty(this.nodes, this.data.get('layered'), this.target)].concat(super.mouseUp(this.target, event)); |
@@ -49,3 +49,3 @@ /* | ||
(direction === Direction.UNDEFINED || direction === Direction.RIGHT || direction === Direction.DOWN) || | ||
coordinateInLayoutDirection > layer.end && (direction === Direction.LEFT || direction === Direction.UP)) { | ||
coordinateInLayoutDirection > layer.end && (direction === Direction.LEFT || direction === Direction.UP)) { | ||
return i | ||
@@ -75,3 +75,4 @@ } | ||
// Examine all nodes that have a layer Id left or equal to the layerCandidate and that have a layerCons > their layerId | ||
const layerConstraintLeftOfCandidate = nodes.filter(n => n.properties.layerId <= layerCandidate && n.properties.layerConstraint > n.properties.layerId) | ||
const layerConstraintLeftOfCandidate = nodes.filter(n => n.properties['org.eclipse.elk.layered.layering.layerId'] as number <= layerCandidate | ||
&& (n.properties['org.eclipse.elk.layered.layering.layerChoiceConstraint'] as number) > (n.properties['org.eclipse.elk.layered.layering.layerId'] as number)) | ||
@@ -89,3 +90,3 @@ // In case that there are no such nodes return the layerCandidate | ||
for (const n of layerConstraintLeftOfCandidate) { | ||
const layerConstraint = n.properties.layerConstraint | ||
const layerConstraint = n.properties['org.eclipse.elk.layered.layering.layerChoiceConstraint'] as number | ||
if (layerConstraint > maxCons) { | ||
@@ -98,3 +99,3 @@ nodeWithMaxCons = n | ||
if (nodeWithMaxCons !== null) { | ||
const idDiff = layerCandidate - nodeWithMaxCons.properties.layerId | ||
const idDiff = layerCandidate - (nodeWithMaxCons.properties['org.eclipse.elk.layered.layering.layerId'] as number) | ||
return maxCons + idDiff | ||
@@ -119,5 +120,5 @@ } | ||
const upperNeighbor = layerNodes[upperIndex] | ||
const posConsOfUpper = upperNeighbor.properties.positionConstraint | ||
const posConsOfUpper = upperNeighbor.properties['org.eclipse.elk.layered.crossingMinimization.positionChoiceConstraint'] as number | ||
if (posConsOfUpper > upperIndex) { | ||
if (alreadyInLayer && upperNeighbor.properties.positionId === localTargetIndex) { | ||
if (alreadyInLayer && upperNeighbor.properties['org.eclipse.elk.layered.crossingMinimization.positionId'] === localTargetIndex) { | ||
localTargetIndex = posConsOfUpper | ||
@@ -138,3 +139,3 @@ } else { | ||
// All nodes within one hierarchy level have the same direction | ||
nodes.sort((a, b) => a.properties.layerId - b.properties.layerId) | ||
nodes.sort((a, b) => (a.properties['org.eclipse.elk.layered.layering.layerId'] as number) - (b.properties['org.eclipse.elk.layered.layering.layerId'] as number)) | ||
const layers = [] | ||
@@ -151,3 +152,3 @@ let layer = 0 | ||
const node = nodes[i] | ||
if (node.properties.layerId !== layer) { | ||
if (node.properties['org.eclipse.elk.layered.layering.layerId'] !== layer) { | ||
// node is in the next layer | ||
@@ -285,3 +286,3 @@ layers[layer] = new Layer(beginCoordinate, endCoordinate, beginCoordinate + (endCoordinate - beginCoordinate) / 2, direction) | ||
for (const node of nodes) { | ||
if (node.properties.layerId === layer) { | ||
if (node.properties['org.eclipse.elk.layered.layering.layerId'] === layer) { | ||
nodesOfLayer[nodesOfLayer.length] = node | ||
@@ -336,3 +337,5 @@ } | ||
for (const node of connectedNodes) { | ||
if (node.properties.layerId === layer && node.properties.layerConstraint !== -1) { | ||
if (node.properties['org.eclipse.elk.layered.layering.layerId'] === layer | ||
&& node.properties['org.eclipse.elk.layered.layering.layerChoiceConstraint'] !== -1 | ||
&& node.properties['org.eclipse.elk.layered.layering.layerChoiceConstraint'] !== undefined) { | ||
// layer is forbidden for the given node | ||
@@ -381,3 +384,3 @@ return true | ||
return RefreshDiagramAction.create() | ||
} else if (targetNode.properties.layerId !== layerOfTarget) { | ||
} else if (targetNode.properties['org.eclipse.elk.layered.layering.layerId'] !== layerOfTarget) { | ||
// layer constraint should only be set if the layer index changed | ||
@@ -404,3 +407,3 @@ if (shouldOnlyLCBeSet(targetNode, layers, direction)) { | ||
// position constraint should only be set if the position of the node changed | ||
if (targetNode.properties.positionId !== positionOfTarget) { | ||
if (targetNode.properties['org.eclipse.elk.layered.crossingMinimization.positionId'] !== positionOfTarget) { | ||
// set the position Constraint | ||
@@ -407,0 +410,0 @@ return SetPositionConstraintAction.create({ |
@@ -46,19 +46,19 @@ /* | ||
&& event.pageY > lowY && event.pageY < highY) { | ||
let actualPosition = node.properties.currentPosition | ||
if (node.properties.desiredPosition !== -1) { | ||
actualPosition = node.properties.desiredPosition | ||
} | ||
let actualTargetPosition = target.properties.currentPosition | ||
if (node.properties.desiredPosition !== -1) { | ||
actualTargetPosition = target.properties.desiredPosition | ||
} | ||
if (actualPosition !== actualTargetPosition && actualPosition !== -1) { | ||
result = RectPackSetPositionConstraintAction.create({ | ||
id: target.id, order: actualPosition | ||
}) | ||
} | ||
let actualPosition = node.properties['org.eclipse.elk.rectPacking.currentPosition'] as number | ||
if (node.properties['org.eclipse.elk.alg.rectpacking.desiredPosition'] !== -1) { | ||
actualPosition = node.properties['org.eclipse.elk.alg.rectpacking.desiredPosition'] as number | ||
} | ||
let actualTargetPosition = target.properties['org.eclipse.elk.rectPacking.currentPosition'] as number | ||
if (node.properties['org.eclipse.elk.alg.rectpacking.desiredPosition'] !== -1) { | ||
actualTargetPosition = target.properties['org.eclipse.elk.alg.rectpacking.desiredPosition'] as number | ||
} | ||
if (actualPosition !== actualTargetPosition && actualPosition !== -1) { | ||
result = RectPackSetPositionConstraintAction.create({ | ||
id: target.id, order: actualPosition | ||
}) | ||
} | ||
} | ||
} | ||
}); | ||
if (result.kind === RefreshDiagramAction.KIND) { | ||
if (result.kind === RefreshDiagramAction.KIND) { | ||
// Case node should not be swapped. | ||
@@ -88,3 +88,3 @@ | ||
// If changed update aspect ratio. | ||
if (parent && parent.properties.aspectRatio !== aspectRatio) { | ||
if (parent && parent.properties['org.eclipse.elk.rectPacking.aspectRatio'] !== aspectRatio) { | ||
return SetAspectRatioAction.create({ | ||
@@ -91,0 +91,0 @@ id: parent.id, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
227777
3925