Skip to content

Commit

Permalink
Merge branch 'interactiveSCCharts' into sdo/interactiveMrTree
Browse files Browse the repository at this point in the history
  • Loading branch information
soerendomroes committed Mar 7, 2024
2 parents 3f80be6 + 44e211f commit 78ebf90
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package de.cau.cs.kieler.klighd.lsp.interactive

import de.cau.cs.kieler.klighd.KlighdDataManager
import de.cau.cs.kieler.klighd.internal.util.KlighdInternalProperties
import de.cau.cs.kieler.klighd.kgraph.KIdentifier
import de.cau.cs.kieler.klighd.kgraph.KNode
import de.cau.cs.kieler.klighd.lsp.KGraphLanguageClient
import de.cau.cs.kieler.klighd.lsp.KGraphLanguageServerExtension
Expand Down Expand Up @@ -115,8 +116,8 @@ class InteractiveUtil {

// from node to the start
for (var i = pos - 1; i >= 0; i--) {
if (layerNodes.get(i).getProperty(LayeredOptions.CROSSING_MINIMIZATION_IN_LAYER_PRED_OF) !== null
|| layerNodes.get(i + 1).getProperty(LayeredOptions.CROSSING_MINIMIZATION_IN_LAYER_SUCC_OF) !== null) {
if (layerNodes.get(i).getProperty(LayeredOptions.CROSSING_MINIMIZATION_IN_LAYER_PRED_OF) == getIdOfNode(layerNodes.get(i + 1))
|| layerNodes.get(i + 1).getProperty(LayeredOptions.CROSSING_MINIMIZATION_IN_LAYER_SUCC_OF) == getIdOfNode(layerNodes.get(i))) {
chainNodes.add(0, layerNodes.get(i))
} else {
i = -1
Expand All @@ -125,8 +126,8 @@ class InteractiveUtil {

// count from node to the end
for (var i = pos + 1; i < layerNodes.size; i++) {
if (layerNodes.get(i).getProperty(LayeredOptions.CROSSING_MINIMIZATION_IN_LAYER_SUCC_OF) !== null
|| layerNodes.get(i - 1).getProperty(LayeredOptions.CROSSING_MINIMIZATION_IN_LAYER_PRED_OF) !== null) {
if (layerNodes.get(i).getProperty(LayeredOptions.CROSSING_MINIMIZATION_IN_LAYER_SUCC_OF) == getIdOfNode(layerNodes.get(i - 1))
|| layerNodes.get(i - 1).getProperty(LayeredOptions.CROSSING_MINIMIZATION_IN_LAYER_PRED_OF) == getIdOfNode(layerNodes.get(i))) {
chainNodes.add(layerNodes.get(i))
} else {
i = layerNodes.size
Expand Down Expand Up @@ -195,4 +196,19 @@ class InteractiveUtil {
return
}

/**
* Returns id of a node.
*
* @param node The node.
* @returns The id string of the node.
*/
static def String getIdOfNode(KNode node) {
var nameStringOfReferenceNode = node.toString
val id = node.getData(KIdentifier)
if (id !== null) {
nameStringOfReferenceNode = id.id
}
return nameStringOfReferenceNode
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,15 @@ class LayeredConstraintReevaluation {
val layerConstraintTarget = ConstraintsUtils.getLayerConstraint(target)
val layerId = target.getProperty(LayeredOptions.LAYERING_LAYER_ID)
var originalLayerIndex = 0
// Calculate previous desired layer of target.
if (layerConstraintTarget === null || layerConstraintTarget <= layerId) {
originalLayerIndex = layerId
} else {
originalLayerIndex = layerConstraintTarget
}
val originalLayer = InteractiveUtil.getNodesOfLayer(originalLayerIndex, nodes)

if (originalLayer.length == 1) {
if (originalLayer.length == InteractiveUtil.getChain(target, originalLayer).size()) {
// If a layer is emptied and disappears from the drawing
// then all layer constraint with a value higher or equal than
// the disappeared layer need to be decremented.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,15 @@ class LayeredInteractiveLanguageServerExtension implements ILanguageServerExtens
val changedNodes = absoluteConstraintReevaluation.changedNodes
changedNodes.addAll(relativeConstraintReevaluation.changedNodes)
changedNodes.add(new ConstraintProperty(targetNode, property, nameStringOfReferenceNode))
if (layerSwap) {
// Already apply changes to be able to correctly identify if a chain is split because of the new
// relative constraint.
changedNodes.forEach[constraint|
val KNode kNode = constraint.KNode
kNode.setProperty(constraint.property, constraint.value)
]
absoluteConstraintReevaluation.reevaluateAfterEmptyingALayer(targetNode, referenceLayer, parentOfNode.children)
}
refreshModelInEditor(changedNodes, KGraphUtil.getRootNodeOf(targetNode), uri)
}
}
Expand Down Expand Up @@ -458,8 +467,12 @@ class LayeredInteractiveLanguageServerExtension implements ILanguageServerExtens
absoluteConstraintReevalution.reevaluatePositionConstraintsAfterPositionChangeInLayer(layerNodes, kNode, newValueId)
absoluteConstraintReevalution.reevaluatePositionConstraintInChain(kNode, newValueConstraint, chain)
}
case LayeredOptions.LAYERING_LAYER_CHOICE_CONSTRAINT:
case LayeredOptions.LAYERING_LAYER_CHOICE_CONSTRAINT: {
absoluteConstraintReevalution.reevaluateLayerConstraintsInChain(layerId, chain)
if (absoluteConstraintReevalution.reevaluateAfterEmptyingALayer(kNode, newValueConstraint, parentOfNode.children)) {
newValueConstraint--
}
}
}

changedNodes.addAll(absoluteConstraintReevalution.changedNodes)
Expand Down

0 comments on commit 78ebf90

Please sign in to comment.