Skip to content

Commit

Permalink
Merge pull request #2324 from lf-lang/sdo/selectionStyle
Browse files Browse the repository at this point in the history
Colored highlighting of selected diagram edges
  • Loading branch information
cmnrd authored Aug 16, 2024
2 parents 058e1ec + 5b7bbf3 commit 12cde59
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ public List<SynthesisOption> getDisplayedSynthesisOptions() {
ModeDiagrams.INITIALLY_COLLAPSE_MODES,
SHOW_USER_LABELS,
SHOW_HYPERLINKS,
LinguaFrancaStyleExtensions.SELECTION_HIGHLIGHTING_COLOR,
// LinguaFrancaSynthesisInterfaceDependencies.SHOW_INTERFACE_DEPENDENCIES,
REACTIONS_USE_HYPEREDGES,
USE_ALTERNATIVE_DASH_PATTERN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static de.cau.cs.kieler.klighd.krendering.extensions.PositionReferenceY.*;

import com.google.inject.Inject;
import de.cau.cs.kieler.klighd.SynthesisOption;
import de.cau.cs.kieler.klighd.internal.util.KlighdInternalProperties;
import de.cau.cs.kieler.klighd.kgraph.KEdge;
import de.cau.cs.kieler.klighd.kgraph.KLabel;
Expand Down Expand Up @@ -57,6 +58,7 @@
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.xtext.xbase.lib.Extension;
import org.lflang.diagram.synthesis.AbstractSynthesisExtensions;
import org.lflang.diagram.synthesis.LinguaFrancaSynthesis;

/**
* Extension class that provides styles and coloring for the Lingua Franca diagram synthesis.
Expand All @@ -76,6 +78,12 @@ public class LinguaFrancaStyleExtensions extends AbstractSynthesisExtensions {
@Inject @Extension private KPolylineExtensions _kPolylineExtensions;
@Extension private KRenderingFactory _kRenderingFactory = KRenderingFactory.eINSTANCE;

public static final String SELECTION_HIGHLIGHTING_COLOR_LABEL = "Selection Coloring";

public static final SynthesisOption SELECTION_HIGHLIGHTING_COLOR =
SynthesisOption.createCheckOption(SELECTION_HIGHLIGHTING_COLOR_LABEL, false)
.setCategory(LinguaFrancaSynthesis.APPEARANCE);

public KRendering noSelectionStyle(KRendering r) {
return _kRenderingExtensions.setSelectionTextStrikeout(r, false);
}
Expand All @@ -86,6 +94,11 @@ public KRendering underlineSelectionStyle(KRendering r) {

public KRendering boldLineSelectionStyle(KRendering r) {
float lineWidthValue = _kRenderingExtensions.getLineWidthValue(r);
// Improve this with content from https://github.com/lf-lang/rfcs/pull/3
boolean selectionColor = getBooleanValue(SELECTION_HIGHLIGHTING_COLOR);
if (selectionColor) {
_kRenderingExtensions.setSelectionForeground(r, Colors.ORANGE_1);
}
return _kRenderingExtensions.setSelectionLineWidth(r, lineWidthValue * 2);
}

Expand Down

0 comments on commit 12cde59

Please sign in to comment.