Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove decorator of empty label. #59

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.eclipse.elk.core.labels.LabelManagementOptions

import static extension de.cau.cs.kieler.klighd.syntheses.DiagramSyntheses.*
import static extension de.cau.cs.kieler.klighd.util.ModelingUtil.*
import java.util.Iterator

/**
* Shows or hides or shortens transition labels.
Expand Down Expand Up @@ -78,15 +79,25 @@ class LabelShorteningHook extends SynthesisActionHook {
}

override processTransition(Transition transition, KEdge edge) {
if (HIDE_LABELS.booleanValue) {
edge.eContents.filter(KLabel).forEach[initiallyHide]
if (SHORTEN_LABEL_STRATEGY.objectValue.equals(LabelShorteningStrategies.PRIORITIES)
&& edge.source.outgoingEdges.length == 1) {
edge.labels.forEach[initiallyHide]
} else if (HIDE_LABELS.booleanValue) {
edge.labels.forEach[initiallyHide]
}
}

override executeAction(KNode rootNode) {
val viewer = usedContext.viewer

if (HIDE_LABELS.booleanValue) {
if (SHORTEN_LABEL_STRATEGY.objectValue.equals(LabelShorteningStrategies.PRIORITIES)) {
rootNode.eAllContentsOfType(KEdge).forEach[edge |
if (edge.source.outgoingEdges.length == 1) {
edge.labels.forEach[label | viewer.hide(label)]
} else {
edge.labels.forEach[label | viewer.show(label)]
}
]
} else if (HIDE_LABELS.booleanValue) {
rootNode.eAllContentsOfType(KNode, KEdge, KLabel).filter(KLabel).forEach[viewer.hide(it)]
} else {
rootNode.eAllContentsOfType(KNode, KEdge, KLabel).filter(KLabel).forEach[viewer.show(it)]
Expand All @@ -102,6 +113,7 @@ class LabelShorteningHook extends SynthesisActionHook {
if (labelManager !== null) {
labelManager.fixedTargetWidth = SHORTEN_LABEL_WIDTH.intValue
}

rootNode.setLayoutOption(LabelManagementOptions.LABEL_MANAGER, labelManager)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import de.cau.cs.kieler.klighd.kgraph.KLabel;
import de.cau.cs.kieler.klighd.krendering.KRendering;
import de.cau.cs.kieler.klighd.krendering.KRenderingRef;
import de.cau.cs.kieler.klighd.labels.decoration.LabelDecorationConfigurator;
import de.cau.cs.kieler.klighd.labels.management.AbstractKlighdLabelManager;
import de.cau.cs.kieler.sccharts.Transition;

Expand Down Expand Up @@ -67,7 +68,11 @@ public Result doResizeLabel(ElkLabel label, double targetWidth) {
// The new label is the priority followed by a period
return Result.modified(matcher.group(1) + ".");
} else {
// If no priority available
// If no priority available
// String text = kLabel.getText();
// kLabel.setText("");
// LabelDecorationConfigurator.create().applyTo(kLabel);
// label.setProperty(KRenderingOptions.K_RENDERING, null);
return Result.modified("");
}
}
Expand Down