From fb0c821e4ebbe7c36de13602de07df5ea07b02f9 Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Tue, 17 Oct 2023 21:16:55 +0200 Subject: [PATCH 01/17] sccharts.ui: Added dark theme for basic SCCharts --- .../ui/synthesis/SCChartsSynthesis.xtend | 12 +- .../ui/synthesis/ScopeSynthesis.xtend | 7 +- .../synthesis/hooks/BlackWhiteModeHook.xtend | 2 +- .../ui/synthesis/styles/ColorStore.java | 136 ++++++++++++++++-- .../ui/synthesis/styles/CommentStyles.xtend | 1 + .../ui/synthesis/styles/EquationStyles.xtend | 4 +- .../ui/synthesis/styles/StateStyles.xtend | 9 +- .../synthesis/styles/TransitionStyles.xtend | 14 +- 8 files changed, 160 insertions(+), 25 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/SCChartsSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/SCChartsSynthesis.xtend index accdc3b81b..6ab4b3d5b5 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/SCChartsSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/SCChartsSynthesis.xtend @@ -26,6 +26,7 @@ import de.cau.cs.kieler.klighd.kgraph.KNode import de.cau.cs.kieler.klighd.krendering.Colors import de.cau.cs.kieler.klighd.krendering.KText import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared +import de.cau.cs.kieler.klighd.krendering.extensions.KColorExtensions import de.cau.cs.kieler.klighd.krendering.extensions.KEdgeExtensions import de.cau.cs.kieler.klighd.krendering.extensions.KNodeExtensions import de.cau.cs.kieler.klighd.krendering.extensions.KPolylineExtensions @@ -39,6 +40,7 @@ import de.cau.cs.kieler.sccharts.extensions.SCChartsInheritanceExtensions import de.cau.cs.kieler.sccharts.extensions.SCChartsScopeExtensions import de.cau.cs.kieler.sccharts.extensions.SCChartsSerializeHRExtensions import de.cau.cs.kieler.sccharts.ui.synthesis.hooks.SynthesisHooks +import de.cau.cs.kieler.sccharts.ui.synthesis.styles.ColorStore import de.cau.cs.kieler.sccharts.ui.synthesis.styles.TransitionStyles import java.util.HashMap import java.util.LinkedHashSet @@ -75,6 +77,7 @@ class SCChartsSynthesis extends AbstractDiagramSynthesis { @Inject extension PragmaExtensions @Inject extension TransitionStyles @Inject extension KPolylineExtensions + @Inject extension ColorStore @Inject StateSynthesis stateSynthesis @Inject ControlflowRegionSynthesis controlflowSynthesis @Inject DataflowRegionSynthesis dataflowSynthesis @@ -147,7 +150,7 @@ class SCChartsSynthesis extends AbstractDiagramSynthesis { return options.toList } - + override transform(SCCharts sccharts) { val startTime = System.currentTimeMillis @@ -171,7 +174,10 @@ class SCChartsSynthesis extends AbstractDiagramSynthesis { // If dot is used draw edges first to prevent overlapping with states when layout is bad usedContext.setProperty(KlighdProperties.EDGES_FIRST, !USE_KLAY.booleanValue) - clearSymbols + // Configure color theme + configureAllColors(usedContext) + + clearSymbols() for(symbolTable : scc.getStringPragmas(PRAGMA_SYMBOLS)) { var prefix = "" if (symbolTable.values.size > 1) prefix = symbolTable.values.get(1) @@ -180,7 +186,7 @@ class SCChartsSynthesis extends AbstractDiagramSynthesis { if (symbolTable.values.head.equals(PRAGMA_SYMBOLS_MATH_SCRIPT)) { defineMathScriptSymbols(prefix) } if (symbolTable.values.head.equals(PRAGMA_SYMBOLS_MATH_FRAKTUR)) { defineMathFrakturSymbols(prefix) } if (symbolTable.values.head.equals(PRAGMA_SYMBOLS_MATH_DOUBLESTRUCK)) { defineMathDoubleStruckSymbols(prefix) } - } + } for(symbol : scc.getStringPragmas(PRAGMA_SYMBOL)) { symbol.values.head.defineSymbol(symbol.values.get(1)) } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ScopeSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ScopeSynthesis.xtend index 2823dac6dd..31f72b6f9e 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ScopeSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ScopeSynthesis.xtend @@ -22,6 +22,7 @@ import de.cau.cs.kieler.sccharts.ControlflowRegion import de.cau.cs.kieler.sccharts.Scope import de.cau.cs.kieler.sccharts.State import de.cau.cs.kieler.sccharts.ui.synthesis.hooks.SynthesisHooks +import de.cau.cs.kieler.sccharts.ui.synthesis.styles.ColorStore import java.util.LinkedHashSet import static de.cau.cs.kieler.sccharts.ui.synthesis.GeneralSynthesisOptions.* @@ -38,6 +39,7 @@ import static de.cau.cs.kieler.sccharts.ui.synthesis.GeneralSynthesisOptions.* class ScopeSynthesis extends AbstractDiagramSynthesis { @Inject extension KNodeExtensions + @Inject extension ColorStore @Inject StateSynthesis stateSynthesis @Inject DataflowRegionSynthesis dataflowSynthesis @@ -68,9 +70,12 @@ class ScopeSynthesis extends AbstractDiagramSynthesis { override transform(Scope root) { val rootNode = createNode - + hooks.invokeStart(root, rootNode) + // Configure color theme + configureAllColors(usedContext) + usedContext.setProperty(KlighdProperties.EDGES_FIRST, !USE_KLAY.booleanValue) if (root instanceof State) { diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/BlackWhiteModeHook.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/BlackWhiteModeHook.xtend index 6928a62491..64dcbd3bf2 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/BlackWhiteModeHook.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/BlackWhiteModeHook.xtend @@ -66,7 +66,7 @@ class BlackWhiteModeHook extends SynthesisHook { configureColor(TRANSITION_ABORT_DECORATOR, Colors.GRAY); configureColor(TRANSITION_TERMINATION_DECORATOR, Colors.GRAY); - configureColor(STATE_FOREGROND, Colors.BLACK); + configureColor(STATE_FOREGROUND, Colors.BLACK); configureColor(STATE_BACKGROUND_GRADIENT_1, Colors.GRAY_95); configureColor(STATE_BACKGROUND_GRADIENT_2, Colors.GRAY_95); configureColor(STATE_REFERENCED_BACKGROUND_GRADIENT_1, Colors.GRAY_97); diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java index bf338515f5..0b7a30793f 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java @@ -13,13 +13,17 @@ package de.cau.cs.kieler.sccharts.ui.synthesis.styles; import java.util.HashMap; +import java.util.Map; import org.eclipse.emf.ecore.util.EcoreUtil; +import de.cau.cs.kieler.klighd.ViewContext; import de.cau.cs.kieler.klighd.krendering.Colors; import de.cau.cs.kieler.klighd.krendering.KColor; import de.cau.cs.kieler.klighd.krendering.KRenderingFactory; import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared; +import de.cau.cs.kieler.klighd.util.ColorPreferences; +import de.cau.cs.kieler.klighd.util.KlighdProperties; /** * The SCCharts colors. @@ -32,8 +36,8 @@ public class ColorStore { public enum Color { - STATE_CONNECTOR(Colors.BLACK), - STATE_FOREGROND(Colors.GRAY), + STATE_FOREGROUND(Colors.GRAY), + STATE_TEXT_FOREGROUND(Colors.BLACK), STATE_INITIAL_FOREGROND(Colors.BLACK), STATE_FIANL_FOREGROND(Colors.BLACK), STATE_FINAL_FOREGROND_BACKGROUND(Colors.WHITE), @@ -41,10 +45,12 @@ public enum Color { STATE_BACKGROUND_GRADIENT_2(205, 220, 243), STATE_REFERENCED_BACKGROUND_GRADIENT_1(0xfc, 0xf7, 0xfc), STATE_REFERENCED_BACKGROUND_GRADIENT_2(0xe6, 0xcb, 0xf2), + STATE_CONNECTOR(Colors.BLACK), STATE_SHADOW(Colors.BLACK), STATE_VIOLATION_BACKGROUND_GRADIENT_1(253, 244, 240), STATE_VIOLATION_BACKGROUND_GRADIENT_2(245, 160, 163), + TRANSITION_FOREGROND(Colors.BLACK), TRANSITION_HISTORY(60, 60, 60), TRANSITION_HISTORY_DECORATOR(Colors.WHITE), TRANSITION_DEFERRED(Colors.RED), @@ -53,6 +59,7 @@ public enum Color { TRANSITION_TERMINATION_DECORATOR(Colors.GREEN), TRANSITION_PROBABILITY(Colors.STEEL_BLUE_2), TRANSITION_NONDETERMINISTIC(234, 154, 86), // darker SANDY_BROWN + TRANSITION_LABEL_FOREGROND(Colors.BLACK), REGION_FOREGROUND(Colors.GRAY), REGION_BACKGROUND(Colors.WHITE), @@ -63,19 +70,12 @@ public enum Color { REGION_BUTTON_FOREGROUND(Colors.WHITE), REGION_LABEL(Colors.DIM_GRAY), - REGION_ENTRY_BACKGROUND_GRADIENT_1(Colors.WHITE), - REGION_ENTRY_BACKGROUND_GRADIENT_2(120, 220, 120), - REGION_ENTRY_FOREGROUND(Colors.GREEN), - INPUTNODE_BACKGROUND_GRADIENT_1(248, 249, 253), INPUTNODE_BACKGROUND_GRADIENT_2(205, 220, 243), INPUTNODE_FOREGROUND(Colors.GRAY), OUTPUTNODE_BACKGROUND_GRADIENT_1(248, 249, 253), OUTPUTNODE_BACKGROUND_GRADIENT_2(205, 220, 243), OUTPUTNODE_FOREGROUND(Colors.GRAY), -// OPERATORNODE_BACKGROUND_GRADIENT_1(254, 254, 240), -// OPERATORNODE_BACKGROUND_GRADIENT_2(224, 176, 9), -// OPERATORNODE_FOREGROUND(Colors.GRAY), OPERATORNODE_BACKGROUND_GRADIENT_1(248, 249, 253), OPERATORNODE_BACKGROUND_GRADIENT_2(205, 220, 243), OPERATORNODE_FOREGROUND(Colors.GRAY), @@ -139,11 +139,96 @@ private KColor getDefaultColor() { return defaultColor; } }; - + + private final static KRenderingFactory FACTORY = KRenderingFactory.eINSTANCE; + /** the configuration */ - private HashMap configuration = new HashMap(); + private Map configuration = new HashMap(); + /** + * Configures the entire color store based on the configuration in the view context. + * + * @param context + * the ViewContext + */ + public void configureAllColors(final ViewContext context) { + ColorPreferences preferences = context.getProperty(KlighdProperties.COLOR_PREFERENCES); + + var fg = preferences.getForeground(); + var bg = preferences.getBackground(); + + // check if it can be considered dark mode + var bgHSB = java.awt.Color.RGBtoHSB(bg.getRed(), bg.getGreen(), bg.getBlue(), null); + boolean dark = bgHSB[2] < 0.6f; + + if (dark) { + configureColor(Color.STATE_FOREGROUND, fg); + configureColor(Color.STATE_TEXT_FOREGROUND, fg); + configureColor(Color.STATE_INITIAL_FOREGROND, fg); + configureColor(Color.STATE_FIANL_FOREGROND, fg); + configureColor(Color.STATE_FINAL_FOREGROND_BACKGROUND, bg); + configureColor(Color.STATE_BACKGROUND_GRADIENT_1, 74, 90, 115); + configureColor(Color.STATE_BACKGROUND_GRADIENT_2, 98, 103, 125); + configureColor(Color.STATE_REFERENCED_BACKGROUND_GRADIENT_1, 103, 74, 115); + configureColor(Color.STATE_REFERENCED_BACKGROUND_GRADIENT_2, 125, 98, 125); + configureColor(Color.STATE_CONNECTOR, fg); + configureColor(Color.STATE_SHADOW, Colors.LIGHT_GRAY); + + configureColor(Color.TRANSITION_FOREGROND, fg); + configureColor(Color.TRANSITION_HISTORY, Colors.LIGHT_GRAY); + configureColor(Color.TRANSITION_HISTORY_DECORATOR, Colors.BLACK); + configureColor(Color.TRANSITION_DEFERRED, Colors.RED_3); + configureColor(Color.TRANSITION_DEFERRED_DECORATOR, fg); + configureColor(Color.TRANSITION_ABORT_DECORATOR, Colors.RED_3); + configureColor(Color.TRANSITION_TERMINATION_DECORATOR, Colors.GREEN_3); + configureColor(Color.TRANSITION_PROBABILITY, Colors.STEEL_BLUE_2); + configureColor(Color.TRANSITION_NONDETERMINISTIC, 234, 154, 86); + configureColor(Color.TRANSITION_LABEL_FOREGROND, fg); + + configureColor(Color.REGION_FOREGROUND, fg); + configureColor(Color.REGION_BACKGROUND, bg); + configureColor(Color.REGION_OVERRIDE_FOREGROUND, adjustBrightness(Color.REGION_OVERRIDE_FOREGROUND.defaultColor, 0.2f)); + configureColor(Color.REGION_OVERRIDE_BACKGROUND, bg); + configureColor(Color.REGION_ABORT_FOREGROUND, Colors.RED_3); + configureColor(Color.REGION_ABORT_BACKGROUND, bg); + configureColor(Color.REGION_BUTTON_FOREGROUND, bg); + configureColor(Color.REGION_LABEL, fg); + + configureColor(Color.INPUTNODE_BACKGROUND_GRADIENT_1, getColor(Color.STATE_BACKGROUND_GRADIENT_1)); + configureColor(Color.INPUTNODE_BACKGROUND_GRADIENT_2, getColor(Color.STATE_BACKGROUND_GRADIENT_2)); + configureColor(Color.INPUTNODE_FOREGROUND, getColor(Color.STATE_FOREGROUND)); + configureColor(Color.OUTPUTNODE_BACKGROUND_GRADIENT_1, getColor(Color.STATE_BACKGROUND_GRADIENT_1)); + configureColor(Color.OUTPUTNODE_BACKGROUND_GRADIENT_2, getColor(Color.STATE_BACKGROUND_GRADIENT_2)); + configureColor(Color.OUTPUTNODE_FOREGROUND, getColor(Color.STATE_FOREGROUND)); + configureColor(Color.OPERATORNODE_BACKGROUND_GRADIENT_1, getColor(Color.STATE_BACKGROUND_GRADIENT_1)); + configureColor(Color.OPERATORNODE_BACKGROUND_GRADIENT_2, getColor(Color.STATE_BACKGROUND_GRADIENT_2)); + configureColor(Color.OPERATORNODE_FOREGROUND, getColor(Color.STATE_FOREGROUND)); + configureColor(Color.REFERENCENODE_BACKGROUND_GRADIENT_1, getColor(Color.STATE_REFERENCED_BACKGROUND_GRADIENT_1)); + configureColor(Color.REFERENCENODE_BACKGROUND_GRADIENT_2, getColor(Color.STATE_REFERENCED_BACKGROUND_GRADIENT_2)); + configureColor(Color.REFERENCENODE_FOREGROUND, getColor(Color.STATE_FOREGROUND)); + + configureColor(Color.COMMENT_FOREGROND, Colors.ANTIQUE_WHITE_3); + configureColor(Color.COMMENT_FOREGROND_TRANSITION, Colors.ANTIQUE_WHITE_3); + configureColor(Color.COMMENT_BACKGROUND_GRADIENT_1, Colors.ANTIQUE_WHITE_4); + configureColor(Color.COMMENT_BACKGROUND_GRADIENT_2, Colors.ANTIQUE_WHITE_4); + configureColor(Color.COMMENT_TEXT, fg); + configureColor(Color.COMMENT_EDGE, Colors.ANTIQUE_WHITE_3); + + configureColor(Color.USER_SCHEDULE_COLOR, 0x28, 0x99, 0x7E); + configureColor(Color.DEPENDENCY_ABSWRITEREAD, 0, 192, 0); + configureColor(Color.DEPENDENCY_ABSWRITERELWRITE, 0, 0, 255); + configureColor(Color.DEPENDENCY_ABSWRITEABSWRITE, 255, 0, 0); + + configureColor(Color.METHOD_FOREGROUND, getColor(Color.REGION_FOREGROUND)); + configureColor(Color.METHOD_BACKGROUND, adjustBrightness(getColor(Color.REGION_BACKGROUND), 0.15f)); + + configureColor(Color.SELECTION, adjustBrightness(Color.SELECTION.defaultColor, 0.2f)); + + configureColor(Color.KEYWORD, 0xC5, 0x86, 0xC0); + } + } + /** * Configures the given color with RGB values. * @@ -177,6 +262,18 @@ public void configureColor(final Color color, final Colors cColor) { kColor.setColor(cColor); configuration.put(color, kColor); } + + /** + * Configures the given color with a {@link Colors} color. + * + * @param color + * the color to configure + * @param color + * the {@link KColor} color + */ + public void configureColor(final Color color, final KColor kColor) { + configuration.put(color, kColor); + } /** * @param color @@ -191,4 +288,21 @@ public KColor getColor(Color color) { } return null; } + + /** + * Adjusts the brightness of the given color. + */ + private KColor adjustBrightness(KColor color, float adjustment) { + var HSB = java.awt.Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); + HSB[2] += adjustment; + HSB[2] = Math.max(0, Math.min(1, HSB[2])); + var RGB = java.awt.Color.getHSBColor(HSB[0],HSB[1],HSB[2]); + + KColor newColor = FACTORY.createKColor(); + newColor.setRed(RGB.getRed()); + newColor.setGreen(RGB.getGreen()); + newColor.setBlue(RGB.getBlue()); + + return newColor; + } } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/CommentStyles.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/CommentStyles.xtend index 582351e586..4dac47435e 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/CommentStyles.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/CommentStyles.xtend @@ -71,6 +71,7 @@ class CommentStyles { def KText addCommentText(KNode node, String text) { node.getKContainerRendering.addText(text) => [ fontSize = 7; + foreground = COMMENT_TEXT.color; setGridPlacementData().from(LEFT, 4, 0, TOP, 4, 0).to(RIGHT, 4, 0, BOTTOM, 4, 0); ] } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/EquationStyles.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/EquationStyles.xtend index 558a172053..e48f236636 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/EquationStyles.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/EquationStyles.xtend @@ -334,7 +334,7 @@ class EquationStyles { // Mark this figure as container for further content setProperty(IS_CONTENT_CONTAINER, true); setBackgroundGradient(STATE_BACKGROUND_GRADIENT_1.color, STATE_BACKGROUND_GRADIENT_2.color, 90); - foreground = STATE_FOREGROND.color; + foreground = STATE_FOREGROUND.color; ] } @@ -347,7 +347,7 @@ class EquationStyles { // Mark this figure as container for further content setProperty(IS_CONTENT_CONTAINER, true); setBackgroundGradient(STATE_BACKGROUND_GRADIENT_1.color, STATE_BACKGROUND_GRADIENT_2.color, 90); - foreground = STATE_FOREGROND.color; + foreground = STATE_FOREGROUND.color; setGridPlacement(1); ] } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/StateStyles.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/StateStyles.xtend index ae9e92360b..66c322be9a 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/StateStyles.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/StateStyles.xtend @@ -80,7 +80,7 @@ class StateStyles { /** This property is set a rendering and indicates the content container */ public static final IProperty IS_CONTENT_CONTAINER = new Property( "de.cau.cs.kieler.sccharts.ui.synthesis.style.state.content", false); - /** This property is set a rendering and indicates the redering is not visible and only present for layout purpose */ + /** This property is set a rendering and indicates the rendering is not visible and only present for layout purpose */ public static final IProperty IS_LAYOUT_ELEMENT = new Property( "de.cau.cs.kieler.sccharts.ui.synthesis.style.layout", false); /** This property is set on the content container rendering and points to the container holding the action labels */ @@ -112,7 +112,7 @@ class StateStyles { // Mark this figure as container for further content setProperty(IS_CONTENT_CONTAINER, true); setBackgroundGradient(STATE_BACKGROUND_GRADIENT_1.color, STATE_BACKGROUND_GRADIENT_2.color, 90); - foreground = STATE_FOREGROND.color; + foreground = STATE_FOREGROUND.color; ] } @@ -125,7 +125,7 @@ class StateStyles { // Mark this figure as container for further content setProperty(IS_CONTENT_CONTAINER, true); setBackgroundGradient(STATE_BACKGROUND_GRADIENT_1.color, STATE_BACKGROUND_GRADIENT_2.color, 90); - foreground = STATE_FOREGROND.color; + foreground = STATE_FOREGROUND.color; setGridPlacement(1); ] } @@ -231,6 +231,7 @@ class StateStyles { fontBold = true fontSize = stateLabelTextSize + foreground = STATE_TEXT_FOREGROUND.color suppressSelectability selectionTextUnderline = Underline.NONE // prevents default selection style // setProperty(KlighdProperties.IS_NODE_TITLE, true) @@ -315,6 +316,7 @@ class StateStyles { ktext = it.addText(builder.append(" ").toString) => [ horizontalAlignment = H_LEFT selectionTextUnderline = Underline.SINGLE + foreground = STATE_TEXT_FOREGROUND.color ] if (keyword == TextFormat.KEYWORD) { ktext.highlightKeyword @@ -335,6 +337,7 @@ class StateStyles { ktext = addText(builder.toString) => [ horizontalAlignment = H_LEFT selectionTextUnderline = Underline.SINGLE + foreground = STATE_TEXT_FOREGROUND.color ] if (keyword == TextFormat.KEYWORD) { ktext.highlightKeyword diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/TransitionStyles.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/TransitionStyles.xtend index 0705c545f5..5cda5f41e2 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/TransitionStyles.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/TransitionStyles.xtend @@ -81,12 +81,14 @@ class TransitionStyles { */ def KSpline addTransitionSpline(KEdge edge) { edge.addSpline => [ + foreground = TRANSITION_FOREGROND.color; lineWidth = TRANSITION_LINE_WIDTH; ] } def KPolyline addTransitionPolyline(KEdge edge) { edge.addPolyline => [ + foreground = TRANSITION_FOREGROND.color; lineWidth = TRANSITION_LINE_WIDTH; ] } @@ -201,6 +203,7 @@ class TransitionStyles { } edge.line.addEllipse() => [ lineWidth = 1; + foreground = STATE_FOREGROUND.color; background = TRANSITION_DEFERRED.color; if (isAdditionalArrowHead) { setDecoratorPlacementData(10, 10, -19, 1, false); @@ -234,7 +237,8 @@ class TransitionStyles { edge.line.addEllipse() => [ setDecoratorPlacementData(10, 10, 4, 0, false); lineWidth = 1; - background = TRANSITION_ABORT_DECORATOR.color + foreground = STATE_FOREGROUND.color; + background = TRANSITION_ABORT_DECORATOR.color; ] } @@ -246,7 +250,8 @@ class TransitionStyles { edge.line.drawTriangle() => [ setDecoratorPlacementData(11, 11, 5, 0, true); lineWidth = 1; - background = TRANSITION_TERMINATION_DECORATOR.color + foreground = STATE_FOREGROUND.color; + background = TRANSITION_TERMINATION_DECORATOR.color; ] } @@ -261,6 +266,7 @@ class TransitionStyles { def configureTransitionLabelRendering(KRendering rendering) { rendering.fontSize = 11; rendering.fontBold = true; + rendering.foreground = TRANSITION_LABEL_FOREGROND.color; } def KLabel addLabel(KEdge edge, String text, KColor backgroundColor) { @@ -269,7 +275,7 @@ class TransitionStyles { label.getKRendering => [ // Configure text fontSize = 7; - foreground = COMMENT_FOREGROND_TRANSITION.color + foreground = COMMENT_TEXT.color background = backgroundColor ] return label; @@ -282,7 +288,7 @@ class TransitionStyles { //label.selectionFontBold = true //label.selectionForeground = SELECTION.color return label - } + } def configureTransitionTailLabelRendering(KRendering rendering) { rendering.fontSize = 8 From 9fbba76c469bf10d40d56ab7c0b42b3f83637228 Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Wed, 18 Oct 2023 14:57:50 +0200 Subject: [PATCH 02/17] sccharts.ui: Removed direct injections of SCChartsSynthesis Because this will reset the ViewSynthesisShared scope if it is done inside a different synthesis (e.g. ScopeSynthesis) due to reusage of sub-syntheses. --- .../sccharts/ui/synthesis/AdaptiveZoom.xtend | 6 +-- .../ui/synthesis/EquationSynthesis.xtend | 9 ++-- .../ui/synthesis/SCChartsSynthesis.xtend | 30 ++----------- .../ui/synthesis/styles/ActorSkins.xtend | 45 +++++++++++++++++++ 4 files changed, 57 insertions(+), 33 deletions(-) create mode 100644 plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ActorSkins.xtend diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/AdaptiveZoom.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/AdaptiveZoom.xtend index 8e1ec4d19a..71d09aaea1 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/AdaptiveZoom.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/AdaptiveZoom.xtend @@ -16,9 +16,11 @@ import de.cau.cs.kieler.annotations.CommentAnnotation import de.cau.cs.kieler.kexpressions.Declaration import de.cau.cs.kieler.klighd.SynthesisOption import de.cau.cs.kieler.klighd.kgraph.KEdge +import de.cau.cs.kieler.klighd.kgraph.KLabel import de.cau.cs.kieler.klighd.kgraph.KNode import de.cau.cs.kieler.klighd.krendering.KText import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared +import de.cau.cs.kieler.klighd.syntheses.AbstractDiagramSynthesis import de.cau.cs.kieler.sccharts.Action import de.cau.cs.kieler.sccharts.Region import de.cau.cs.kieler.sccharts.State @@ -26,7 +28,6 @@ import de.cau.cs.kieler.sccharts.Transition import javax.inject.Inject import static extension de.cau.cs.kieler.klighd.syntheses.DiagramSyntheses.* -import de.cau.cs.kieler.klighd.kgraph.KLabel /** * @author als @@ -41,8 +42,7 @@ class AdaptiveZoom { static val TUNNEL_EFFECT = 0.85 static val DEFAULT_LOWER_SCALE_BOUND = 0.15 - @Inject - SCChartsSynthesis synthesis + @Inject AbstractDiagramSynthesis synthesis dispatch def configureNodeLOD(KNode node, Region region) { // Create a tunnel effect with regions to benifit from adaptive zoom diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend index 9f4f86694c..84e822ff84 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend @@ -59,6 +59,7 @@ import de.cau.cs.kieler.sccharts.extensions.SCChartsReferenceExtensions import de.cau.cs.kieler.sccharts.extensions.SCChartsSerializeHRExtensions import de.cau.cs.kieler.sccharts.ui.SCChartsUiModule import de.cau.cs.kieler.sccharts.ui.synthesis.actions.ReferenceExpandAction +import de.cau.cs.kieler.sccharts.ui.synthesis.styles.ActorSkins import de.cau.cs.kieler.sccharts.ui.synthesis.styles.EquationStyles import de.cau.cs.kieler.sccharts.ui.synthesis.styles.TransitionStyles import java.util.EnumSet @@ -131,7 +132,6 @@ class EquationSynthesis extends SubSynthesis { @Inject extension KExpressionsValuedObjectExtensions @Inject extension KExpressionsCreateExtensions @Inject extension SCChartsSerializeHRExtensions - @Inject extension SCChartsSynthesis @Inject extension EquationStyles @Inject extension KExtDeclarationExtensions @Inject extension AnnotationsExtensions @@ -141,6 +141,7 @@ class EquationSynthesis extends SubSynthesis { @Inject extension EquationSynthesisHelper @Inject extension EquationSimplification @Inject extension TransitionStyles + @Inject extension ActorSkins @Inject StateSynthesis stateSynthesis val HashMap referenceNodes = newHashMap @@ -901,7 +902,7 @@ class EquationSynthesis extends SubSynthesis { val referenceDeclaration = voRef.valuedObject.declaration as ReferenceDeclaration if (referenceDeclaration.hasAnnotation(ANNOTATION_FIGURE)) { newNode = referenceDeclaration.createKGTNode("OPERATOR", label) - newNode.setProperty(SCChartsSynthesis.SKINPATH, getSkinPath(usedContext)) + newNode.setProperty(ActorSkins.SKINPATH, getSkinPath(usedContext)) newNode.addNodeLabelWithPadding(label, INPUT_OUTPUT_TEXT_SIZE, PADDING_INPUT_LEFT, PADDING_INPUT_RIGHT) newNode.setProperty(REFERENCE_NODE, true) val rendering = newNode.data.filter(KContainerRendering).head @@ -918,7 +919,7 @@ class EquationSynthesis extends SubSynthesis { if (referenceDeclaration.reference !== null && referenceDeclaration.reference.asAnnotatable.hasAnnotation(ANNOTATION_FIGURE)) { newNode = referenceDeclaration.reference.createKGTNode("OPERATOR", label) - newNode.setProperty(SCChartsSynthesis.SKINPATH, getSkinPath(usedContext)) + newNode.setProperty(ActorSkins.SKINPATH, getSkinPath(usedContext)) newNode.addNodeLabelWithPadding(label, INPUT_OUTPUT_TEXT_SIZE, PADDING_INPUT_LEFT, PADDING_INPUT_RIGHT) newNode.setProperty(REFERENCE_NODE, true) val rendering = newNode.data.filter(KContainerRendering).head @@ -967,7 +968,7 @@ class EquationSynthesis extends SubSynthesis { EnumSet.of(SizeConstraint.PORTS, SizeConstraint.PORT_LABELS, SizeConstraint.MINIMUM_SIZE, SizeConstraint.NODE_LABELS )) - newNode.setProperty(SCChartsSynthesis.SKINPATH, getSkinPath(usedContext)) + newNode.setProperty(ActorSkins.SKINPATH, getSkinPath(usedContext)) newNode.setProperty(REFERENCE_NODE, true) return newNode } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/SCChartsSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/SCChartsSynthesis.xtend index 6ab4b3d5b5..bddd503bfd 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/SCChartsSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/SCChartsSynthesis.xtend @@ -20,13 +20,11 @@ import de.cau.cs.kieler.kexpressions.VariableDeclaration import de.cau.cs.kieler.kicool.compilation.Compile import de.cau.cs.kieler.kicool.ide.klighd.KiCoDiagramViewProperties import de.cau.cs.kieler.klighd.LightDiagramServices -import de.cau.cs.kieler.klighd.ViewContext import de.cau.cs.kieler.klighd.internal.util.SourceModelTrackingAdapter import de.cau.cs.kieler.klighd.kgraph.KNode import de.cau.cs.kieler.klighd.krendering.Colors import de.cau.cs.kieler.klighd.krendering.KText import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared -import de.cau.cs.kieler.klighd.krendering.extensions.KColorExtensions import de.cau.cs.kieler.klighd.krendering.extensions.KEdgeExtensions import de.cau.cs.kieler.klighd.krendering.extensions.KNodeExtensions import de.cau.cs.kieler.klighd.krendering.extensions.KPolylineExtensions @@ -40,6 +38,7 @@ import de.cau.cs.kieler.sccharts.extensions.SCChartsInheritanceExtensions import de.cau.cs.kieler.sccharts.extensions.SCChartsScopeExtensions import de.cau.cs.kieler.sccharts.extensions.SCChartsSerializeHRExtensions import de.cau.cs.kieler.sccharts.ui.synthesis.hooks.SynthesisHooks +import de.cau.cs.kieler.sccharts.ui.synthesis.styles.ActorSkins import de.cau.cs.kieler.sccharts.ui.synthesis.styles.ColorStore import de.cau.cs.kieler.sccharts.ui.synthesis.styles.TransitionStyles import java.util.HashMap @@ -53,8 +52,6 @@ import org.eclipse.elk.core.options.CoreOptions import org.eclipse.elk.core.options.Direction import org.eclipse.elk.core.service.util.CompoundGraphElementVisitor import org.eclipse.elk.core.util.IGraphElementVisitor -import org.eclipse.elk.graph.properties.IProperty -import org.eclipse.elk.graph.properties.Property import static de.cau.cs.kieler.sccharts.ui.synthesis.GeneralSynthesisOptions.* @@ -78,6 +75,7 @@ class SCChartsSynthesis extends AbstractDiagramSynthesis { @Inject extension TransitionStyles @Inject extension KPolylineExtensions @Inject extension ColorStore + @Inject extension ActorSkins @Inject StateSynthesis stateSynthesis @Inject ControlflowRegionSynthesis controlflowSynthesis @Inject DataflowRegionSynthesis dataflowSynthesis @@ -87,9 +85,6 @@ class SCChartsSynthesis extends AbstractDiagramSynthesis { @Inject PolicySynthesis policySynthesis @Inject package SynthesisHooks hooks - - public static final IProperty SKINPATH = new Property( - "de.cau.cs.kieler.sccharts.ui.synthesis.skinPath", ""); static val PRAGMA_SYMBOLS = "symbols" static val PRAGMA_SYMBOL = "symbol" @@ -98,7 +93,7 @@ class SCChartsSynthesis extends AbstractDiagramSynthesis { static val PRAGMA_SYMBOLS_MATH_SCRIPT = "math script" static val PRAGMA_SYMBOLS_MATH_FRAKTUR = "math fraktur" static val PRAGMA_SYMBOLS_MATH_DOUBLESTRUCK = "math doublestruck" - static val PRAGMA_FONT = "font" + static val PRAGMA_FONT = "font" static val PRAGMA_SKINPATH = "skinpath" static val PRAGMA_HIDE_IMPORTED_SCCHARTS = "HideImportedSCCharts" @@ -174,7 +169,7 @@ class SCChartsSynthesis extends AbstractDiagramSynthesis { // If dot is used draw edges first to prevent overlapping with states when layout is bad usedContext.setProperty(KlighdProperties.EDGES_FIRST, !USE_KLAY.booleanValue) - // Configure color theme + // Configure color theme (before start to allow for changes by hooks) configureAllColors(usedContext) clearSymbols() @@ -337,23 +332,6 @@ class SCChartsSynthesis extends AbstractDiagramSynthesis { } } - def String getSkinPath(ViewContext context) { - val rootNode = context.viewModel - var sp = rootNode.getProperty(SKINPATH) - if (sp.nullOrEmpty) { - sp = context.getProperty(SKINPATH) - if (!sp.nullOrEmpty) { - sp.setSkinPath(context) - } - } - return sp - } - - def void setSkinPath(String sp, ViewContext context) { - val rootNode = context.viewModel - rootNode.setProperty(SKINPATH, sp) - } - override List getAdditionalLayoutConfigs(KNode viewModel) { val List additionalLayoutRuns = newArrayList // Add interactive Layout run. diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ActorSkins.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ActorSkins.xtend new file mode 100644 index 0000000000..5a1fbdc246 --- /dev/null +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ActorSkins.xtend @@ -0,0 +1,45 @@ +/* + * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient + * + * http://rtsys.informatik.uni-kiel.de/kieler + * + * Copyright 2023 by + * + Kiel University + * + Department of Computer Science + * + Real-Time and Embedded Systems Group + * + * This code is provided under the terms of the Eclipse Public License (EPL). + */ +package de.cau.cs.kieler.sccharts.ui.synthesis.styles + +import de.cau.cs.kieler.klighd.ViewContext +import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared +import org.eclipse.elk.graph.properties.IProperty +import org.eclipse.elk.graph.properties.Property + +/** + * @author als + */ +@ViewSynthesisShared +class ActorSkins { + + public static final IProperty SKINPATH = new Property( + "de.cau.cs.kieler.sccharts.ui.synthesis.skinPath", ""); + + def String getSkinPath(ViewContext context) { + val rootNode = context.viewModel + var sp = rootNode.getProperty(SKINPATH) + if (sp.nullOrEmpty) { + sp = context.getProperty(SKINPATH) + if (!sp.nullOrEmpty) { + sp.setSkinPath(context) + } + } + return sp + } + + def void setSkinPath(String sp, ViewContext context) { + val rootNode = context.viewModel + rootNode.setProperty(SKINPATH, sp) + } +} \ No newline at end of file From a163c9fa5ac432a0149254915446f7cb91f7f2dc Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Wed, 18 Oct 2023 14:58:29 +0200 Subject: [PATCH 03/17] sccharts.ui: Adjusted to new default in ColorPreferences property --- .../kieler/sccharts/ui/synthesis/ScopeSynthesis.xtend | 6 +++--- .../sccharts/ui/synthesis/styles/ColorStore.java | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ScopeSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ScopeSynthesis.xtend index 31f72b6f9e..1fe7889545 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ScopeSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ScopeSynthesis.xtend @@ -71,10 +71,10 @@ class ScopeSynthesis extends AbstractDiagramSynthesis { val rootNode = createNode - hooks.invokeStart(root, rootNode) - - // Configure color theme + // Configure color theme (before start to allow for changes by hooks) configureAllColors(usedContext) + + hooks.invokeStart(root, rootNode) usedContext.setProperty(KlighdProperties.EDGES_FIRST, !USE_KLAY.booleanValue) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java index 0b7a30793f..7b27298fc9 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java @@ -153,10 +153,14 @@ private KColor getDefaultColor() { * the ViewContext */ public void configureAllColors(final ViewContext context) { - ColorPreferences preferences = context.getProperty(KlighdProperties.COLOR_PREFERENCES); + var fg = FACTORY.createKColor().setColor(Colors.BLACK); + var bg = FACTORY.createKColor().setColor(Colors.WHITE); - var fg = preferences.getForeground(); - var bg = preferences.getBackground(); + ColorPreferences preferences = context.getProperty(KlighdProperties.COLOR_PREFERENCES); + if (preferences != null) { + fg = preferences.getForeground(); + bg = preferences.getBackground(); + } // check if it can be considered dark mode var bgHSB = java.awt.Color.RGBtoHSB(bg.getRed(), bg.getGreen(), bg.getBlue(), null); From 7c6171cf23c06240d9d5f9d6a7d6199992e50d66 Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Wed, 18 Oct 2023 14:59:35 +0200 Subject: [PATCH 04/17] sccharts.ui: Fixed import --- .../ui/synthesis/actions/ReferenceExpandAction.xtend | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/actions/ReferenceExpandAction.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/actions/ReferenceExpandAction.xtend index 7046054b6f..51ff35140a 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/actions/ReferenceExpandAction.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/actions/ReferenceExpandAction.xtend @@ -24,7 +24,7 @@ import de.cau.cs.kieler.klighd.util.KlighdSynthesisProperties import de.cau.cs.kieler.sccharts.Region import de.cau.cs.kieler.sccharts.State import de.cau.cs.kieler.sccharts.extensions.SCChartsScopeExtensions -import de.cau.cs.kieler.sccharts.ui.synthesis.SCChartsSynthesis +import de.cau.cs.kieler.sccharts.ui.synthesis.styles.ActorSkins import org.eclipse.elk.graph.properties.MapPropertyHolder /** @@ -76,7 +76,7 @@ class ReferenceExpandAction extends CollapseExpandAction { context.getKNode.data += node.data } } else if (modelElement instanceof ValuedObjectReference) { - val propagatedSkinPath = context.KNode.getProperty(SCChartsSynthesis.SKINPATH) + val propagatedSkinPath = context.KNode.getProperty(ActorSkins.SKINPATH) val declaration = modelElement.valuedObject.eContainer if (declaration instanceof ReferenceDeclaration) { @@ -85,7 +85,7 @@ class ReferenceExpandAction extends CollapseExpandAction { context.viewContext, new MapPropertyHolder => [ setProperty(KlighdSynthesisProperties.REQUESTED_DIAGRAM_SYNTHESIS, "de.cau.cs.kieler.sccharts.ui.synthesis.ScopeSynthesis") - setProperty(SCChartsSynthesis.SKINPATH, propagatedSkinPath) + setProperty(ActorSkins.SKINPATH, propagatedSkinPath) ] ) var extractedDataflow = diagram.children.head.children From e4d25a596d776a39a22bb8ead7c697cf1fe000ad Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Wed, 18 Oct 2023 16:30:54 +0200 Subject: [PATCH 05/17] sccharts.ui: Added support for dark theme in dataflow --- .../OperatorExpressionArithmetical.kgt | 1 - .../resources/skins/default/Input.kgt | 22 +++--- .../resources/skins/default/InputOutput.kgt | 6 +- .../resources/skins/default/Local.kgt | 6 +- .../skins/default/OperatorExpression.kgt | 6 +- .../OperatorExpressionArithmetical.kgt | 6 +- .../default/OperatorExpressionCONDITIONAL.kgt | 6 +- .../skins/default/OperatorExpressionINIT.kgt | 6 +- .../skins/default/OperatorExpressionPRE.kgt | 6 +- .../skins/default/OperatorExpressionPRE2.kgt | 6 +- .../default/OperatorExpressionUPDATE.kgt | 6 +- .../default/OperatorExpressionUPDATE2.kgt | 6 +- .../skins/default/OperatorExpressionUnary.kgt | 6 +- .../resources/skins/default/Output.kgt | 6 +- .../synthesis/DataflowRegionSynthesis.xtend | 2 +- .../ui/synthesis/EquationSynthesis.xtend | 71 ++++++++++++++++++- .../ui/synthesis/styles/ActorSkins.xtend | 3 + 17 files changed, 121 insertions(+), 50 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/circuit/OperatorExpressionArithmetical.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/circuit/OperatorExpressionArithmetical.kgt index d868cd6dd8..ecdb753abc 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/circuit/OperatorExpressionArithmetical.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/circuit/OperatorExpressionArithmetical.kgt @@ -6,7 +6,6 @@ knode operator { krectangle { styles: lineStyle = solid - foreground = 190r, 190g, 190b } kport in1 { diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/Input.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/Input.kgt index 548ef37776..35ecac2856 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/Input.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/Input.kgt @@ -1,19 +1,19 @@ knode source { size: width = 25 height = 12 properties: - org.eclipse.elk.portLabels.placement = INSIDE - org.eclipse.elk.portConstraints = FIXED_ORDER + org.eclipse.elk.portLabels.placement = INSIDE + org.eclipse.elk.portConstraints = FIXED_ORDER - kpolygon { + kpolygon [ + de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts = true + ] { points: - left,top; - right 6,top; - right, top 50%; - right 6, bottom; - left,bottom - styles: lineStyle = solid - foreground = 190r, 190g, 190b - background = 248r, 249g, 253b, 255a -> 205r, 220g, 243b, 243a (90) + left,top; + right 6,top; + right, top 50%; + right 6, bottom; + left,bottom + styles: lineStyle = solid } kport out { diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/InputOutput.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/InputOutput.kgt index 5bed61d51d..4fdb4e75bd 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/InputOutput.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/InputOutput.kgt @@ -4,7 +4,9 @@ knode source { org.eclipse.elk.portLabels.placement = INSIDE org.eclipse.elk.portConstraints = FIXED_ORDER - kpolygon { + kpolygon [ + de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts = true + ] { points: left, top 50%; left 6,top; @@ -13,8 +15,6 @@ knode source { right 6, bottom; left 6,bottom styles: lineStyle = solid - foreground = 190r, 190g, 190b - background = 248r, 249g, 253b, 255a -> 205r, 220g, 243b, 243a (90) fontSize = 4pt } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/Local.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/Local.kgt index 352297d0d5..88d612f305 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/Local.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/Local.kgt @@ -4,7 +4,9 @@ knode source { org.eclipse.elk.portLabels.placement = INSIDE org.eclipse.elk.portConstraints = FIXED_ORDER - kpolygon { + kpolygon [ + de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts = true + ] { points: left 50%, top; right, top 6; @@ -12,8 +14,6 @@ knode source { left, bottom; left, top 6 styles: lineStyle = solid - foreground = 190r, 190g, 190b - background = 248r, 249g, 253b, 255a -> 205r, 220g, 243b, 243a (90) fontSize = 4pt } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpression.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpression.kgt index 6a51393e35..9a296488ef 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpression.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpression.kgt @@ -4,10 +4,10 @@ knode operator { org.eclipse.elk.portLabels.placement = INSIDE org.eclipse.elk.portConstraints = FIXED_ORDER - krectangle { + krectangle [ + de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts = true + ] { styles: lineStyle = solid - foreground = 190r, 190g, 190b - background = 248r, 249g, 253b, 255a -> 205r, 220g, 243b, 243a (90) } kport in1 { diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionArithmetical.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionArithmetical.kgt index 574962ef16..8405ad2483 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionArithmetical.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionArithmetical.kgt @@ -4,10 +4,10 @@ knode operator { org.eclipse.elk.portLabels.placement = INSIDE org.eclipse.elk.portConstraints = FIXED_ORDER - krectangle { + krectangle [ + de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts = true + ] { styles: lineStyle = solid - foreground = 190r, 190g, 190b - background = 248r, 249g, 253b, 255a -> 205r, 220g, 243b, 243a (90) } kport in1 { diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionCONDITIONAL.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionCONDITIONAL.kgt index ba6424737e..3dba6a8786 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionCONDITIONAL.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionCONDITIONAL.kgt @@ -4,14 +4,14 @@ knode operator { org.eclipse.elk.portLabels.placement = INSIDE org.eclipse.elk.portConstraints = FIXED_POS - kpolygon { + kpolygon [ + de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts = true + ] { points: right, top 20%; left,top 0%; left,bottom 0%; right,bottom 20% styles: lineStyle = solid - foreground = 190r, 190g, 190b - background = 248r, 249g, 253b, 255a -> 205r, 220g, 243b, 243a (90) } kport in1 { diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionINIT.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionINIT.kgt index 6e6da58586..cf1087405b 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionINIT.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionINIT.kgt @@ -4,10 +4,10 @@ knode operator { org.eclipse.elk.portLabels.placement = INSIDE org.eclipse.elk.portConstraints = FIXED_ORDER - krectangle { + krectangle [ + de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts = true + ] { styles: lineStyle = solid - foreground = 190r, 190g, 190b - background = 248r, 249g, 253b, 255a -> 205r, 220g, 243b, 243a (90) kpolyline{ gridData: diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionPRE.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionPRE.kgt index 38b8de8457..a607270e0c 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionPRE.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionPRE.kgt @@ -11,10 +11,10 @@ knode operator { } } - krectangle { + krectangle [ + de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts = true + ] { styles: lineStyle = solid - foreground = 190r, 190g, 190b - background = 248r, 249g, 253b, 255a -> 205r, 220g, 243b, 243a (90) } kport in0 { diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionPRE2.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionPRE2.kgt index 9836776115..90afb0836b 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionPRE2.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionPRE2.kgt @@ -4,10 +4,10 @@ knode operator { org.eclipse.elk.portLabels.placement = INSIDE org.eclipse.elk.portConstraints = FIXED_ORDER - krectangle { + krectangle [ + de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts = true + ] { styles: lineStyle = solid - foreground = 190r, 190g, 190b - background = 248r, 249g, 253b, 255a -> 205r, 220g, 243b, 243a (90) krectangle { gridData: diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionUPDATE.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionUPDATE.kgt index 1f7e870ef8..fb82fa81d6 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionUPDATE.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionUPDATE.kgt @@ -5,14 +5,14 @@ knode operator { org.eclipse.elk.portLabels.placement = INSIDE org.eclipse.elk.portConstraints = FIXED_POS - kpolygon { + kpolygon [ + de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts = true + ] { points: right, top 25%; left, top 25%; left,bottom 0%; right,bottom 25% styles: lineStyle = solid - foreground = 190r, 190g, 190b - background = 248r, 249g, 253b, 255a -> 205r, 220g, 243b, 243a (90) } kport in1 { diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionUPDATE2.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionUPDATE2.kgt index f2df20a0a1..79fe413c91 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionUPDATE2.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionUPDATE2.kgt @@ -4,10 +4,10 @@ knode operator { org.eclipse.elk.portLabels.placement = INSIDE org.eclipse.elk.portConstraints = FIXED_ORDER - krectangle { + krectangle [ + de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts = true + ] { styles: lineStyle = solid - foreground = 190r, 190g, 190b - background = 248r, 249g, 253b, 255a -> 205r, 220g, 243b, 243a (90) kpolyline{ gridData: diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionUnary.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionUnary.kgt index fb89744581..3c13f09673 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionUnary.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionUnary.kgt @@ -4,10 +4,10 @@ knode operator { org.eclipse.elk.portLabels.placement = INSIDE org.eclipse.elk.portConstraints = FIXED_ORDER - krectangle { + krectangle [ + de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts = true + ] { styles: lineStyle = solid - foreground = 190r, 190g, 190b - background = 248r, 249g, 253b, 255a -> 205r, 220g, 243b, 243a (90) } kport in0 { diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/Output.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/Output.kgt index 8a7a911c3d..41887d738b 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/Output.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/Output.kgt @@ -4,7 +4,9 @@ knode source { org.eclipse.elk.portLabels.placement = INSIDE org.eclipse.elk.portConstraints = FIXED_ORDER - kpolygon { + kpolygon [ + de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts = true + ] { points: right,top; left 6,top; @@ -12,8 +14,6 @@ knode source { left 6, bottom; right,bottom styles: lineStyle = solid - foreground = 190r, 190g, 190b - background = 248r, 249g, 253b, 255a -> 205r, 220g, 243b, 243a (90) fontSize = 4pt } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/DataflowRegionSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/DataflowRegionSynthesis.xtend index 99c2797eaf..435f7b3d2f 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/DataflowRegionSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/DataflowRegionSynthesis.xtend @@ -95,7 +95,7 @@ class DataflowRegionSynthesis extends SubSynthesis { if (CIRCUIT.booleanValue) { node.addLayoutParam(LayeredOptions::CROSSING_MINIMIZATION_SEMI_INTERACTIVE, true) - node.addLayoutParam(LayeredOptions::CROSSING_MINIMIZATION_GREEDY_SWITCH_TYPE, GreedySwitchType::TWO_SIDED) + node.addLayoutParam(LayeredOptions::CROSSING_MINIMIZATION_GREEDY_SWITCH_TYPE, GreedySwitchType::TWO_SIDED) node.setLayoutOption(CoreOptions::SPACING_NODE_NODE, 10d); //10.5 // 8f node.setLayoutOption(CoreOptions::PADDING, new ElkPadding(4d)); diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend index 84e822ff84..6593a0cfda 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend @@ -39,10 +39,16 @@ import de.cau.cs.kieler.klighd.kgraph.KIdentifier import de.cau.cs.kieler.klighd.kgraph.KNode import de.cau.cs.kieler.klighd.kgraph.KPort import de.cau.cs.kieler.klighd.krendering.Colors +import de.cau.cs.kieler.klighd.krendering.KArc +import de.cau.cs.kieler.klighd.krendering.KBackground import de.cau.cs.kieler.klighd.krendering.KContainerRendering +import de.cau.cs.kieler.klighd.krendering.KEllipse +import de.cau.cs.kieler.klighd.krendering.KForeground import de.cau.cs.kieler.klighd.krendering.KPolygon import de.cau.cs.kieler.klighd.krendering.KPolyline +import de.cau.cs.kieler.klighd.krendering.KRectangle import de.cau.cs.kieler.klighd.krendering.KRendering +import de.cau.cs.kieler.klighd.krendering.KRoundedRectangle import de.cau.cs.kieler.klighd.krendering.KText import de.cau.cs.kieler.klighd.krendering.LineStyle import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared @@ -60,6 +66,7 @@ import de.cau.cs.kieler.sccharts.extensions.SCChartsSerializeHRExtensions import de.cau.cs.kieler.sccharts.ui.SCChartsUiModule import de.cau.cs.kieler.sccharts.ui.synthesis.actions.ReferenceExpandAction import de.cau.cs.kieler.sccharts.ui.synthesis.styles.ActorSkins +import de.cau.cs.kieler.sccharts.ui.synthesis.styles.ColorStore import de.cau.cs.kieler.sccharts.ui.synthesis.styles.EquationStyles import de.cau.cs.kieler.sccharts.ui.synthesis.styles.TransitionStyles import java.util.EnumSet @@ -80,6 +87,7 @@ import org.eclipse.elk.core.options.SizeConstraint import org.eclipse.emf.ecore.EObject import static de.cau.cs.kieler.sccharts.ide.synthesis.EquationSynthesisProperties.* +import static de.cau.cs.kieler.sccharts.ui.synthesis.styles.ColorStore.Color.* import static extension de.cau.cs.kieler.annotations.ide.klighd.CommonSynthesisUtil.* import static extension de.cau.cs.kieler.klighd.syntheses.DiagramSyntheses.* @@ -142,6 +150,7 @@ class EquationSynthesis extends SubSynthesis { @Inject extension EquationSimplification @Inject extension TransitionStyles @Inject extension ActorSkins + @Inject extension ColorStore @Inject StateSynthesis stateSynthesis val HashMap referenceNodes = newHashMap @@ -309,7 +318,9 @@ class EquationSynthesis extends SubSynthesis { n.addLayoutParam(CoreOptions.NODE_SIZE_MINIMUM, new KVector(0, 0)) n.addLayoutParam(CoreOptions.PADDING, new ElkPadding(0, 0, 0, 0)) } - return nodes.reWireInlining.addMissingReferenceInputs + val finalNodes = nodes.reWireInlining.addMissingReferenceInputs + finalNodes.applyColors() + return finalNodes } /** @@ -1176,4 +1187,62 @@ class EquationSynthesis extends SubSynthesis { } } } + + private def void applyColors(List nodes) { + val allNodes = newArrayList() + allNodes += nodes + for (n : nodes) { + allNodes += n.eAllContents.filter(KNode).toIterable + } + + for (node : allNodes) { + for (rendering : node.data.filter(KRendering)) { + rendering.applyColors() + } + for (edge : node.outgoingEdges) { + for (rendering : edge.data.filter(KRendering)) { + rendering.applyColors() + } + } + } + } + + private def void applyColors(KRendering rendering) { + switch (rendering) { + KText: { + if (!rendering.styles.exists[it instanceof KForeground]) { + rendering.foreground = STATE_TEXT_FOREGROUND.color + } + } + KArc, + KEllipse, + KPolyline, + KRectangle, + KRoundedRectangle: { + if (rendering.hasProperty(ActorSkins.SKIN_STYLE_KEY_SCCHARTS)) { + // Apply SCCharts state style + rendering.foreground = STATE_FOREGROUND.color + rendering.setBackgroundGradient( + STATE_BACKGROUND_GRADIENT_1.color, + STATE_BACKGROUND_GRADIENT_2.color, + 90 + ); + } else { + if (!rendering.styles.exists[it instanceof KForeground]) { + rendering.foreground = STATE_FOREGROUND.color // Fixme + } + if (!rendering.styles.exists[it instanceof KBackground]) { + rendering.background = REGION_BACKGROUND.color // Fixme + } + } + } + } + + // continue recursive + if (rendering instanceof KContainerRendering) { + for (child : rendering.children) { + child.applyColors() + } + } + } } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ActorSkins.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ActorSkins.xtend index 5a1fbdc246..7ffd06777e 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ActorSkins.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ActorSkins.xtend @@ -25,6 +25,9 @@ class ActorSkins { public static final IProperty SKINPATH = new Property( "de.cau.cs.kieler.sccharts.ui.synthesis.skinPath", ""); + + public static final IProperty SKIN_STYLE_KEY_SCCHARTS = new Property( + "de.cau.cs.kieler.sccharts.ui.synthesis.style.sccharts", false); def String getSkinPath(ViewContext context) { val rootNode = context.viewModel From 9cc68083a504cc2a8ed334869fba07cc028f9831 Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Wed, 18 Oct 2023 17:01:16 +0200 Subject: [PATCH 06/17] kicool.ui: Introduced abstract color store --- .../META-INF/MANIFEST.MF | 1 + .../synthesis/colors/AbstractColorStore.java | 171 ++++++++++++++++++ .../kicool/ui/synthesis/colors/ColorUtil.java | 41 +++++ .../ui/synthesis/EquationSynthesis.xtend | 5 +- .../ui/synthesis/styles/ColorStore.java | 122 ++----------- 5 files changed, 227 insertions(+), 113 deletions(-) create mode 100644 plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java create mode 100644 plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/ColorUtil.java diff --git a/plugins/de.cau.cs.kieler.kicool.ui/META-INF/MANIFEST.MF b/plugins/de.cau.cs.kieler.kicool.ui/META-INF/MANIFEST.MF index 7c435bf5ef..053045d16b 100644 --- a/plugins/de.cau.cs.kieler.kicool.ui/META-INF/MANIFEST.MF +++ b/plugins/de.cau.cs.kieler.kicool.ui/META-INF/MANIFEST.MF @@ -58,6 +58,7 @@ Export-Package: de.cau.cs.kieler.kicool.ui, de.cau.cs.kieler.kicool.ui.quickfix, de.cau.cs.kieler.kicool.ui.synthesis, de.cau.cs.kieler.kicool.ui.synthesis.actions, + de.cau.cs.kieler.kicool.ui.synthesis.colors, de.cau.cs.kieler.kicool.ui.synthesis.feedback, de.cau.cs.kieler.kicool.ui.synthesis.styles, de.cau.cs.kieler.kicool.ui.synthesis.updates, diff --git a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java new file mode 100644 index 0000000000..e7a75a8621 --- /dev/null +++ b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java @@ -0,0 +1,171 @@ +/* + * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient + * + * http://rtsys.informatik.uni-kiel.de/kieler + * + * Copyright 2023 by + * + Kiel University + * + Department of Computer Science + * + Real-Time and Embedded Systems Group + * + * This code is provided under the terms of the Eclipse Public License (EPL). + */ +package de.cau.cs.kieler.kicool.ui.synthesis.colors; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.emf.ecore.util.EcoreUtil; + +import de.cau.cs.kieler.klighd.ViewContext; +import de.cau.cs.kieler.klighd.krendering.Colors; +import de.cau.cs.kieler.klighd.krendering.KColor; +import de.cau.cs.kieler.klighd.krendering.KRenderingFactory; +import de.cau.cs.kieler.klighd.util.ColorPreferences; +import de.cau.cs.kieler.klighd.util.KlighdProperties; + +/** + * A general color store. + * + * @author als + */ +public abstract class AbstractColorStore { + + public interface IColor { + /** + * @return the default color + */ + public KColor getDefaultColor(); + } + + + public enum GeneralColor implements IColor { + FOREGROUND(Colors.BLACK), + BACKGROUND(Colors.WHITE), + HIGHLIGHT(Colors.RED); + + /** the default color */ + private final KColor defaultColor = KRenderingFactory.eINSTANCE.createKColor(); + + /** + * Hidden constructor. + * + * @param red + * the red component of the desired color in range of 0 to 255 + * @param green + * the green component of the desired color in range of 0 to 255 + * @param blue + * the blue component of the desired color in range of 0 to 255 + */ + private GeneralColor(final int red, final int green, final int blue) { + defaultColor.setRed(red); + defaultColor.setGreen(green); + defaultColor.setBlue(blue); + } + + /** + * Hidden constructor. + * + * @param color + * the {@link Colors} color + */ + private GeneralColor(final Colors color) { + defaultColor.setColor(color); + } + + /** + * @return the default color + */ + public KColor getDefaultColor() { + return defaultColor; + } + }; + + private final static KRenderingFactory FACTORY = KRenderingFactory.eINSTANCE; + + /** the configuration */ + private Map configuration = new HashMap(); + + /** + * Configures the entire color store based on the configuration in the view context. + * + * @param context + * the ViewContext + */ + public void configureAllColors(final ViewContext context) { + ColorPreferences preferences = context.getProperty(KlighdProperties.COLOR_PREFERENCES); + if (preferences != null) { + configureColor(GeneralColor.FOREGROUND, preferences.getForeground()); + configureColor(GeneralColor.BACKGROUND, preferences.getBackground()); + configureColor(GeneralColor.HIGHLIGHT, preferences.getHighlight()); + + configureOwnColors(preferences); + } + } + + /** + * Handles the color adjustment for the colors of the deriving class. + * @param preferences + */ + protected abstract void configureOwnColors(ColorPreferences preferences); + + /** + * Configures the given color with RGB values. + * + * @param color + * the color to configure + * @param red + * the red component of the desired color in range of 0 to 255 + * @param green + * the green component of the desired color in range of 0 to 255 + * @param blue + * the blue component of the desired color in range of 0 to 255 + */ + public void configureColor(final IColor color, final int red, final int green, final int blue) { + KColor kColor = FACTORY.createKColor(); + kColor.setRed(red); + kColor.setGreen(green); + kColor.setBlue(blue); + configuration.put(color, kColor); + } + + /** + * Configures the given color with a {@link Colors} color. + * + * @param color + * the color to configure + * @param color + * the {@link Colors} color + */ + public void configureColor(final IColor color, final Colors cColor) { + KColor kColor = FACTORY.createKColor(); + kColor.setColor(cColor); + configuration.put(color, kColor); + } + + /** + * Configures the given color with a {@link Colors} color. + * + * @param color + * the color to configure + * @param color + * the {@link KColor} color + */ + public void configureColor(final IColor color, final KColor kColor) { + configuration.put(color, EcoreUtil.copy(kColor)); + } + + /** + * @param color + * the color + * @return a new {@link KColor} for the given color respecting all configurations. + */ + public KColor getColor(IColor color) { + if (configuration.containsKey(color)) { + return EcoreUtil.copy(configuration.get(color)); + } else if (color != null) { + return EcoreUtil.copy(color.getDefaultColor()); + } + return null; + } +} diff --git a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/ColorUtil.java b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/ColorUtil.java new file mode 100644 index 0000000000..f72d50b617 --- /dev/null +++ b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/ColorUtil.java @@ -0,0 +1,41 @@ +/* + * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient + * + * http://rtsys.informatik.uni-kiel.de/kieler + * + * Copyright 2023 by + * + Kiel University + * + Department of Computer Science + * + Real-Time and Embedded Systems Group + * + * This code is provided under the terms of the Eclipse Public License (EPL). + */ +package de.cau.cs.kieler.kicool.ui.synthesis.colors; + +import de.cau.cs.kieler.klighd.krendering.KColor; +import de.cau.cs.kieler.klighd.krendering.KRenderingFactory; + +/** + * @author als + */ +public class ColorUtil { + + private final static KRenderingFactory FACTORY = KRenderingFactory.eINSTANCE; + + /** + * Adjusts the brightness of the given color. + */ + public static KColor adjustBrightness(KColor color, float adjustment) { + var HSB = java.awt.Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); + HSB[2] += adjustment; + HSB[2] = Math.max(0, Math.min(1, HSB[2])); + var RGB = java.awt.Color.getHSBColor(HSB[0],HSB[1],HSB[2]); + + var newColor = FACTORY.createKColor(); + newColor.setRed(RGB.getRed()); + newColor.setGreen(RGB.getGreen()); + newColor.setBlue(RGB.getBlue()); + + return newColor; + } +} diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend index 6593a0cfda..f4057fb624 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend @@ -34,6 +34,7 @@ import de.cau.cs.kieler.kexpressions.keffects.Assignment import de.cau.cs.kieler.kexpressions.kext.DeclarationScope import de.cau.cs.kieler.kexpressions.kext.extensions.KExtDeclarationExtensions import de.cau.cs.kieler.kicool.ui.synthesis.KGTLoader +import de.cau.cs.kieler.kicool.ui.synthesis.colors.AbstractColorStore.GeneralColor import de.cau.cs.kieler.klighd.SynthesisOption import de.cau.cs.kieler.klighd.kgraph.KIdentifier import de.cau.cs.kieler.klighd.kgraph.KNode @@ -1229,10 +1230,10 @@ class EquationSynthesis extends SubSynthesis { ); } else { if (!rendering.styles.exists[it instanceof KForeground]) { - rendering.foreground = STATE_FOREGROUND.color // Fixme + rendering.foreground = GeneralColor.FOREGROUND.color } if (!rendering.styles.exists[it instanceof KBackground]) { - rendering.background = REGION_BACKGROUND.color // Fixme + rendering.background = GeneralColor.BACKGROUND.color } } } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java index 7b27298fc9..0d3e5e37cb 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java @@ -12,30 +12,24 @@ */ package de.cau.cs.kieler.sccharts.ui.synthesis.styles; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.emf.ecore.util.EcoreUtil; - -import de.cau.cs.kieler.klighd.ViewContext; +import de.cau.cs.kieler.kicool.ui.synthesis.colors.AbstractColorStore; import de.cau.cs.kieler.klighd.krendering.Colors; import de.cau.cs.kieler.klighd.krendering.KColor; import de.cau.cs.kieler.klighd.krendering.KRenderingFactory; import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared; import de.cau.cs.kieler.klighd.util.ColorPreferences; -import de.cau.cs.kieler.klighd.util.KlighdProperties; + +import static de.cau.cs.kieler.kicool.ui.synthesis.colors.ColorUtil.*; /** * The SCCharts colors. * * @author als - * @kieler.design 2015-10-27 proposed - * @kieler.rating 2015-10-27 proposed yellow */ @ViewSynthesisShared -public class ColorStore { - - public enum Color { +public class ColorStore extends AbstractColorStore { + + public enum Color implements IColor { STATE_FOREGROUND(Colors.GRAY), STATE_TEXT_FOREGROUND(Colors.BLACK), STATE_INITIAL_FOREGROND(Colors.BLACK), @@ -135,32 +129,15 @@ private Color(final Colors color) { /** * @return the default color */ - private KColor getDefaultColor() { + public KColor getDefaultColor() { return defaultColor; } }; - - private final static KRenderingFactory FACTORY = KRenderingFactory.eINSTANCE; - - /** the configuration */ - private Map configuration = new HashMap(); - - /** - * Configures the entire color store based on the configuration in the view context. - * - * @param context - * the ViewContext - */ - public void configureAllColors(final ViewContext context) { - var fg = FACTORY.createKColor().setColor(Colors.BLACK); - var bg = FACTORY.createKColor().setColor(Colors.WHITE); - - ColorPreferences preferences = context.getProperty(KlighdProperties.COLOR_PREFERENCES); - if (preferences != null) { - fg = preferences.getForeground(); - bg = preferences.getBackground(); - } + @Override + public void configureOwnColors(final ColorPreferences preferences) { + var fg = preferences.getForeground(); + var bg = preferences.getBackground(); // check if it can be considered dark mode var bgHSB = java.awt.Color.RGBtoHSB(bg.getRed(), bg.getGreen(), bg.getBlue(), null); @@ -232,81 +209,4 @@ public void configureAllColors(final ViewContext context) { configureColor(Color.KEYWORD, 0xC5, 0x86, 0xC0); } } - - /** - * Configures the given color with RGB values. - * - * @param color - * the color to configure - * @param red - * the red component of the desired color in range of 0 to 255 - * @param green - * the green component of the desired color in range of 0 to 255 - * @param blue - * the blue component of the desired color in range of 0 to 255 - */ - public void configureColor(final Color color, final int red, final int green, final int blue) { - KColor kColor = FACTORY.createKColor(); - kColor.setRed(red); - kColor.setGreen(green); - kColor.setBlue(blue); - configuration.put(color, kColor); - } - - /** - * Configures the given color with a {@link Colors} color. - * - * @param color - * the color to configure - * @param color - * the {@link Colors} color - */ - public void configureColor(final Color color, final Colors cColor) { - KColor kColor = FACTORY.createKColor(); - kColor.setColor(cColor); - configuration.put(color, kColor); - } - - /** - * Configures the given color with a {@link Colors} color. - * - * @param color - * the color to configure - * @param color - * the {@link KColor} color - */ - public void configureColor(final Color color, final KColor kColor) { - configuration.put(color, kColor); - } - - /** - * @param color - * the color - * @return a new {@link KColor} for the given color respecting all configurations. - */ - public KColor getColor(Color color) { - if (configuration.containsKey(color)) { - return EcoreUtil.copy(configuration.get(color)); - } else if (color != null) { - return EcoreUtil.copy(color.getDefaultColor()); - } - return null; - } - - /** - * Adjusts the brightness of the given color. - */ - private KColor adjustBrightness(KColor color, float adjustment) { - var HSB = java.awt.Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); - HSB[2] += adjustment; - HSB[2] = Math.max(0, Math.min(1, HSB[2])); - var RGB = java.awt.Color.getHSBColor(HSB[0],HSB[1],HSB[2]); - - KColor newColor = FACTORY.createKColor(); - newColor.setRed(RGB.getRed()); - newColor.setGreen(RGB.getGreen()); - newColor.setBlue(RGB.getBlue()); - - return newColor; - } } From e24cf61474efa8feaea14df3732a61ead0a860a9 Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Mon, 23 Oct 2023 16:36:16 +0200 Subject: [PATCH 07/17] sccharts.ui: Minor fixes in SCCharts DF dark mode --- .../default/OperatorExpressionCONDITIONAL.kgt | 4 +-- .../ui/synthesis/EquationSynthesis.xtend | 26 ++++++++++++++++--- .../ui/synthesis/styles/EquationStyles.xtend | 18 ++++++++----- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionCONDITIONAL.kgt b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionCONDITIONAL.kgt index 3dba6a8786..7fe335e677 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionCONDITIONAL.kgt +++ b/plugins/de.cau.cs.kieler.sccharts.ui/resources/skins/default/OperatorExpressionCONDITIONAL.kgt @@ -41,7 +41,7 @@ knode operator { kport in0 { pos: x = 6 y = 25 - size: width = 2 height = 2 + size: width = 0 height = 0 properties: org.eclipse.elk.port.side = SOUTH org.eclipse.elk.port.borderOffset = -3.0 org.eclipse.elk.layered.allowNonFlowPortsToSwitchSides = true @@ -56,7 +56,7 @@ knode operator { kport out { pos: x = 14.5 y = 11.5 - size: width = 2 height = 2 + size: width = 0 height = 0 properties: org.eclipse.elk.port.side = EAST diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend index f4057fb624..732d2d9da7 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend @@ -93,6 +93,7 @@ import static de.cau.cs.kieler.sccharts.ui.synthesis.styles.ColorStore.Color.* import static extension de.cau.cs.kieler.annotations.ide.klighd.CommonSynthesisUtil.* import static extension de.cau.cs.kieler.klighd.syntheses.DiagramSyntheses.* import static extension org.eclipse.emf.ecore.util.EcoreUtil.* +import static extension com.google.common.collect.Iterables.concat /** * @author ssm @@ -1172,17 +1173,26 @@ class EquationSynthesis extends SubSynthesis { if (portLabel !== null) { port.labels.remove(0) } - port.createLabel().configureOutsidePortLabel(label, PORT_LABEL_FONT_SIZE) + port.createLabel() => [ + it.configureOutsidePortLabel(label, PORT_LABEL_FONT_SIZE) + it.KRendering.foreground = TRANSITION_LABEL_FOREGROND.color + ] } else { if (portLabel !== null) { port.labels.remove(0) } - port.createLabel().configureInsidePortLabel(label, PORT_LABEL_FONT_SIZE) + port.createLabel() => [ + it.configureInsidePortLabel(label, PORT_LABEL_FONT_SIZE) + it.KRendering.foreground = TRANSITION_LABEL_FOREGROND.color + ] } } } else { if (portLabel === null) { - port.createLabel.configureInsidePortLabel(label, PORT_LABEL_FONT_SIZE) + port.createLabel() => [ + it.configureInsidePortLabel(label, PORT_LABEL_FONT_SIZE) + it.KRendering.foreground = TRANSITION_LABEL_FOREGROND.color + ] } else { portLabel.text = label } @@ -1204,6 +1214,16 @@ class EquationSynthesis extends SubSynthesis { for (rendering : edge.data.filter(KRendering)) { rendering.applyColors() } + for (label : edge.labels) { + if (label.KRendering !== null) { + label.KRendering.applyColors() + } + } + } + for (label : node.labels.concat(node.ports.map[labels].flatten)) { + if (label.KRendering !== null) { + label.KRendering.applyColors() + } } } } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/EquationStyles.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/EquationStyles.xtend index e48f236636..e08d089fdb 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/EquationStyles.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/EquationStyles.xtend @@ -15,11 +15,16 @@ package de.cau.cs.kieler.sccharts.ui.synthesis.styles import com.google.common.base.Joiner import com.google.inject.Inject +import de.cau.cs.kieler.kicool.ui.synthesis.colors.AbstractColorStore.GeneralColor +import de.cau.cs.kieler.klighd.kgraph.KEdge +import de.cau.cs.kieler.klighd.kgraph.KNode import de.cau.cs.kieler.klighd.krendering.Colors import de.cau.cs.kieler.klighd.krendering.KContainerRendering +import de.cau.cs.kieler.klighd.krendering.KFontSize import de.cau.cs.kieler.klighd.krendering.KPointPlacementData import de.cau.cs.kieler.klighd.krendering.KRectangle import de.cau.cs.kieler.klighd.krendering.KRenderingFactory +import de.cau.cs.kieler.klighd.krendering.KRoundedBendsPolyline import de.cau.cs.kieler.klighd.krendering.KRoundedRectangle import de.cau.cs.kieler.klighd.krendering.KText import de.cau.cs.kieler.klighd.krendering.LineStyle @@ -29,7 +34,9 @@ import de.cau.cs.kieler.klighd.krendering.extensions.KEdgeExtensions import de.cau.cs.kieler.klighd.krendering.extensions.KNodeExtensions import de.cau.cs.kieler.klighd.krendering.extensions.KPolylineExtensions import de.cau.cs.kieler.klighd.krendering.extensions.KRenderingExtensions +import java.util.EnumSet import java.util.List +import org.eclipse.elk.core.math.ElkMargin import org.eclipse.elk.core.options.CoreOptions import org.eclipse.elk.core.options.SizeConstraint import org.eclipse.elk.graph.properties.IProperty @@ -38,12 +45,6 @@ import org.eclipse.elk.graph.properties.Property import static de.cau.cs.kieler.sccharts.ui.synthesis.styles.ColorStore.Color.* import static extension org.eclipse.emf.ecore.util.EcoreUtil.* -import de.cau.cs.kieler.klighd.krendering.KRoundedBendsPolyline -import de.cau.cs.kieler.klighd.kgraph.KNode -import de.cau.cs.kieler.klighd.kgraph.KEdge -import org.eclipse.elk.core.math.ElkMargin -import java.util.EnumSet -import de.cau.cs.kieler.klighd.krendering.KFontSize /** * Styles for {@link Equations}. @@ -242,7 +243,10 @@ class EquationStyles { def KEdge addWireFigure(KEdge edge) { edge.addRoundedBendsPolyline(4, 1) => [ - it.addJunctionPointDecorator + it.addJunctionPointDecorator => [ + it.foreground = GeneralColor.FOREGROUND.color + it.background = GeneralColor.FOREGROUND.color + ] ] return edge } From 850102bc590dbf9a1616dc82a3630f8d0837cbc7 Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Mon, 23 Oct 2023 17:20:17 +0200 Subject: [PATCH 08/17] kicool.ui: Added dark theme for code placeholder diagrams --- .../syntheses/CodePlaceHolderSynthesis.xtend | 14 ++++++++- .../synthesis/colors/DefaultColorStore.java | 30 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/DefaultColorStore.java diff --git a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/klighd/syntheses/CodePlaceHolderSynthesis.xtend b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/klighd/syntheses/CodePlaceHolderSynthesis.xtend index 1ad7683b0b..5bf9641845 100644 --- a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/klighd/syntheses/CodePlaceHolderSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/klighd/syntheses/CodePlaceHolderSynthesis.xtend @@ -27,6 +27,8 @@ import de.cau.cs.kieler.klighd.syntheses.AbstractDiagramSynthesis import javax.inject.Inject import static extension de.cau.cs.kieler.klighd.syntheses.DiagramSyntheses.* +import de.cau.cs.kieler.kicool.ui.synthesis.colors.DefaultColorStore +import de.cau.cs.kieler.kicool.ui.synthesis.colors.AbstractColorStore.GeneralColor /** * Diagram synthesis for a {@link CodePlaceHolder}. @@ -49,6 +51,9 @@ class CodePlaceHolderSynthesis extends AbstractDiagramSynthesis @Inject extension KColorExtensions + + @Inject + extension DefaultColorStore // ------------------------------------------------------------------------- // Constants @@ -63,6 +68,8 @@ class CodePlaceHolderSynthesis extends AbstractDiagramSynthesis // Synthesis override KNode transform(CodePlaceHolder placeholder) { val startTime = System.currentTimeMillis + configureAllColors(usedContext) + val rootNode = createNode(); rootNode.children += createNode(placeholder) => [ it.associateWith(placeholder); @@ -70,12 +77,14 @@ class CodePlaceHolderSynthesis extends AbstractDiagramSynthesis it.addRoundedRectangle(8, 8) => [ it.addDoubleClickAction(OpenCodeInEditorAction.ID); it.setGridPlacement(1); + it.foreground = GeneralColor.FOREGROUND.color; // title val titleText = if (placeholder.name.nullOrEmpty) placeholder.typeLabel else placeholder.typeLabel + " - " + placeholder.name it.addText(titleText) => [ it.fontSize = 11; it.fontBold = true; + it.foreground = GeneralColor.FOREGROUND.color; it.setGridPlacementData().from(LEFT, 8, 0, TOP, 4, 0).to(RIGHT, 8, 0, BOTTOM, 4, 0); it.suppressSelectability; ] @@ -90,12 +99,15 @@ class CodePlaceHolderSynthesis extends AbstractDiagramSynthesis ] // separator - it.addHorizontalSeperatorLine(1, 0); + it.addHorizontalSeperatorLine(1, 0) => [ + it.foreground = GeneralColor.FOREGROUND.color; + ] // code preview it.addText(placeholder.code.generatePreview) => [ it.fontSize = 8; it.fontName = KlighdConstants.DEFAULT_MONOSPACE_FONT_NAME; + it.foreground = GeneralColor.FOREGROUND.color; it.setGridPlacementData().from(LEFT, 8, 0, TOP, 4, 0).to(RIGHT, 8, 0, BOTTOM, 4, 0); it.suppressSelectability; it.addDoubleClickAction(OpenCodeInEditorAction.ID); diff --git a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/DefaultColorStore.java b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/DefaultColorStore.java new file mode 100644 index 0000000000..1a87174590 --- /dev/null +++ b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/DefaultColorStore.java @@ -0,0 +1,30 @@ +/* + * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient + * + * http://rtsys.informatik.uni-kiel.de/kieler + * + * Copyright 2023 by + * + Kiel University + * + Department of Computer Science + * + Real-Time and Embedded Systems Group + * + * This code is provided under the terms of the Eclipse Public License (EPL). + */ +package de.cau.cs.kieler.kicool.ui.synthesis.colors; + +import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared; +import de.cau.cs.kieler.klighd.util.ColorPreferences; + +/** + * Only the general colors. + * + * @author als + */ +@ViewSynthesisShared +public class DefaultColorStore extends AbstractColorStore { + + @Override + public void configureOwnColors(final ColorPreferences preferences) { + // nothing to configure + } +} From 5a0d1968587fe2a27f469a8c3065e4fb4cd28e15 Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Mon, 23 Oct 2023 17:26:13 +0200 Subject: [PATCH 09/17] simulatin.ide: Fixed NPE in SimContext synthesis --- .../ide/synthesis/SimulationContextSynthesis.xtend | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/de.cau.cs.kieler.simulation.ide/src/de/cau/cs/kieler/simulation/ide/synthesis/SimulationContextSynthesis.xtend b/plugins/de.cau.cs.kieler.simulation.ide/src/de/cau/cs/kieler/simulation/ide/synthesis/SimulationContextSynthesis.xtend index 65c7c2e2ab..65b962c2ed 100644 --- a/plugins/de.cau.cs.kieler.simulation.ide/src/de/cau/cs/kieler/simulation/ide/synthesis/SimulationContextSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.simulation.ide/src/de/cau/cs/kieler/simulation/ide/synthesis/SimulationContextSynthesis.xtend @@ -13,8 +13,8 @@ package de.cau.cs.kieler.simulation.ide.synthesis import com.google.inject.Inject +import de.cau.cs.kieler.klighd.LightDiagramServices import de.cau.cs.kieler.klighd.ide.model.MessageModel -import de.cau.cs.kieler.klighd.ide.syntheses.MessageModelSynthesis import de.cau.cs.kieler.klighd.kgraph.KNode import de.cau.cs.kieler.klighd.krendering.Colors import de.cau.cs.kieler.klighd.krendering.KImage @@ -39,9 +39,6 @@ class SimulationContextSynthesis extends AbstractDiagramSynthesis Date: Wed, 25 Oct 2023 15:52:08 +0200 Subject: [PATCH 10/17] scg.klighd: Added SCG dark theme --- .../cau/cs/kieler/scg/klighd/ColorStore.java | 116 +++++++---------- .../klighd/SCGraphComponentSynthesis.xtend | 36 ++++-- .../scg/klighd/SCGraphDiagramSynthesis.xtend | 33 +++-- .../klighd/SCGraphHierarchySynthesis.xtend | 37 +++--- .../cs/kieler/scg/klighd/SCGraphShapes.xtend | 122 ++++++++---------- .../scg/klighd/SCGraphSynthesisHelper.xtend | 8 +- .../klighd/SCGraphsDiagramSynthesisOld.xtend | 4 +- 7 files changed, 172 insertions(+), 184 deletions(-) diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ColorStore.java b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ColorStore.java index d9467e40d4..0c99d42ffe 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ColorStore.java +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ColorStore.java @@ -12,25 +12,31 @@ */ package de.cau.cs.kieler.scg.klighd; -import java.util.HashMap; - -import org.eclipse.emf.ecore.util.EcoreUtil; - +import de.cau.cs.kieler.kicool.ui.synthesis.colors.AbstractColorStore; import de.cau.cs.kieler.klighd.krendering.Colors; import de.cau.cs.kieler.klighd.krendering.KColor; import de.cau.cs.kieler.klighd.krendering.KRenderingFactory; +import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared; +import de.cau.cs.kieler.klighd.util.ColorPreferences; /** - * The SCCharts colors. + * The SCG colors. * * @author als - * @kieler.design 2015-10-27 proposed - * @kieler.rating 2015-10-27 proposed yellow */ -public class ColorStore { +@ViewSynthesisShared +public class ColorStore extends AbstractColorStore { - public enum Color { - SCCHARTSBLUE(205, 220, 243), + public enum Color implements IColor { + NODE_FOREGROUND(Colors.BLACK), + NODE_BACKGROUND(Colors.WHITE), + NODE_TEXT(Colors.BLACK), + NODE_SHADOW(Colors.BLACK), + NODE_REFERENCED_BACKGROUND_GRADIENT_1(0xfc, 0xf7, 0xfc), + NODE_REFERENCED_BACKGROUND_GRADIENT_2(0xe6, 0xcb, 0xf2), + + THREAD_LABEL(Colors.BLACK), + THREAD_BACKGROUND(205, 220, 243), COMMENT_FOREGROND(0xf0, 0xf0, 0x24), COMMENT_FOREGROND_TRANSITION(0x00, 0x00, 0x00), @@ -41,6 +47,7 @@ public enum Color { USER_SCHEDULE_COLOR(0x28, 0x99, 0x7E), + CONTROLFLOW_EDGE(0, 0, 0), DEPENDENCY_ABSWRITEREAD(0, 192, 0), DEPENDENCY_RELWRITEREAD(0, 192, 192), DEPENDENCY_ABSWRITERELWRITE(0, 0, 255), @@ -55,15 +62,12 @@ public enum Color { NODE_PRIORITY_COLOR(255, 30, 30), OPT_PRIORITY_COLOR(30, 30, 255), PASSIVE_REGION_COLOR(255, 101, 127), - STANDARD_CONTROLFLOWEDGE(0, 0, 0), - BASICBLOCKBORDER(248, 0, 253), - SCHEDULINGBLOCKBORDER(128, 0, 243), - SCHEDULEBORDER(0, 0, 128), + BASICBLOCK_BORDER(248, 0, 253), + SCHEDULINGBLOCK_BORDER(128, 0, 243), + SCHEDULE_BORDER(0, 0, 128), SCHEDULING_DEADCODE(128, 128, 128), - SCHEDULING_SCHEDULINGEDGE(128, 0, 253), - PROBLEM_COLOR(255, 0, 0), - - KEYWORD(115, 0, 65); + SCHEDULING_SCHEDULING_EDGE(128, 0, 253), + PROBLEM_COLOR(255, 0, 0); /** the default color */ private final KColor defaultColor = KRenderingFactory.eINSTANCE.createKColor(); @@ -97,64 +101,38 @@ private Color(final Colors color) { /** * @return the default color */ - private KColor getDefaultColor() { + public KColor getDefaultColor() { return defaultColor; } }; - private final static KRenderingFactory FACTORY = KRenderingFactory.eINSTANCE; - /** the configuration */ - private HashMap configuration = new HashMap(); + @Override + public void configureOwnColors(final ColorPreferences preferences) { + var fg = preferences.getForeground(); + var bg = preferences.getBackground(); + + // check if it can be considered dark mode + var bgHSB = java.awt.Color.RGBtoHSB(bg.getRed(), bg.getGreen(), bg.getBlue(), null); + boolean dark = bgHSB[2] < 0.6f; - /** - * Configures the given color with RGB values. - * - * @param color - * the color to configure - * @param red - * the red component of the desired color in range of 0 to 255 - * @param green - * the green component of the desired color in range of 0 to 255 - * @param blue - * the blue component of the desired color in range of 0 to 255 - */ - public void configureColor(final Color color, final int red, final int green, final int blue) { - KColor kColor = FACTORY.createKColor(); - kColor.setRed(red); - kColor.setGreen(green); - kColor.setBlue(blue); - configuration.put(color, kColor); - } + configureColor(Color.NODE_FOREGROUND, fg); + configureColor(Color.NODE_BACKGROUND, bg); + configureColor(Color.NODE_TEXT, fg); + configureColor(Color.CONTROLFLOW_EDGE, fg); + if (dark) { + configureColor(Color.NODE_SHADOW, Colors.LIGHT_GRAY); + configureColor(Color.NODE_REFERENCED_BACKGROUND_GRADIENT_1, 103, 74, 115); + configureColor(Color.NODE_REFERENCED_BACKGROUND_GRADIENT_2, 125, 98, 125); - /** - * Configures the given color with a {@link Colors} color. - * - * @param color - * the color to configure - * @param color - * the {@link Colors} color - */ - public void configureColor(final Color color, final Colors cColor) { - KColor kColor = FACTORY.createKColor(); - kColor.setColor(cColor); - configuration.put(color, kColor); - } + configureColor(Color.THREAD_LABEL, fg); + configureColor(Color.THREAD_BACKGROUND, 98, 103, 125); - /** - * @param color - * the color - * @return a new {@link KColor} for the given color respecting all configurations. - */ - public KColor getColor(Color color) { - if (configuration.containsKey(color)) { - return EcoreUtil.copy(configuration.get(color)); - } else if (color != null) { - return EcoreUtil.copy(color.getDefaultColor()); + configureColor(Color.COMMENT_FOREGROND, Colors.ANTIQUE_WHITE_3); + configureColor(Color.COMMENT_FOREGROND_TRANSITION, Colors.ANTIQUE_WHITE_3); + configureColor(Color.COMMENT_BACKGROUND_GRADIENT_1, Colors.ANTIQUE_WHITE_4); + configureColor(Color.COMMENT_BACKGROUND_GRADIENT_2, Colors.ANTIQUE_WHITE_4); + configureColor(Color.COMMENT_TEXT, fg); + configureColor(Color.COMMENT_EDGE, Colors.ANTIQUE_WHITE_3); } - return null; } - - public KColor getColor2(Color color) { - return this.getColor(color); - } } diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphComponentSynthesis.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphComponentSynthesis.xtend index 0a654040be..9abe19c65d 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphComponentSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphComponentSynthesis.xtend @@ -88,7 +88,10 @@ class SCGraphComponentSynthesis { // Straightforward rectangle drawing val figure = node.addRoundedRectangle(SCGraphSynthesisHelper.CORNERRADIUS, SCGraphSynthesisHelper.CORNERRADIUS, SCGraphSynthesisHelper.LINEWIDTH) - figure.addText("").setSurroundingSpace(6, 0, 2, 0) + figure.addText("") => [ + it.setSurroundingSpace(6, 0, 2, 0) + it.foreground = NODE_TEXT.color + ] var isSCGRef = false if (assignment.expression instanceof ReferenceCall) { val call = assignment.expression as ReferenceCall @@ -97,12 +100,11 @@ class SCGraphComponentSynthesis { isSCGRef = decl.reference instanceof SCGraph } } + + node.initialiseFigure(assignment) if (isSCGRef) { - figure.setBackgroundGradient("#fcf7fc".color, "#e6cbf2".color, 90.0f) - } else { - figure.background = "white".color; + figure.setBackgroundGradient(NODE_REFERENCED_BACKGROUND_GRADIENT_1.color, NODE_REFERENCED_BACKGROUND_GRADIENT_2.color, 90.0f) } - node.initialiseFigure(assignment) // Add ports for control-flow and dependency routing. if (isGuardSCG) { @@ -148,10 +150,12 @@ class SCGraphComponentSynthesis { } } else { if (assignment.hasAnnotation(SCGAnnotations.ANNOTATION_HEADNODE)) { - var sbHeadNodeName = assignment.getStringAnnotationValue(SCGAnnotations.ANNOTATION_HEADNODE) - sbHeadNodeName.createLabel(node).associateWith(assignment). - configureOutsideTopLeftNodeLabel(sbHeadNodeName, 9, KlighdConstants::DEFAULT_FONT_NAME). - KRendering.foreground = "black".color + val sbHeadNodeName = assignment.getStringAnnotationValue(SCGAnnotations.ANNOTATION_HEADNODE) + sbHeadNodeName.createLabel(node) => [ + it.associateWith(assignment) + it.configureOutsideTopLeftNodeLabel(sbHeadNodeName, 9, KlighdConstants::DEFAULT_FONT_NAME) + it.KRendering.foreground = NODE_TEXT.color + ] } } @@ -343,8 +347,11 @@ class SCGraphComponentSynthesis { if (ALIGN_ENTRYEXIT_NODES.booleanValue) node.addLayoutParam(LayeredOptions::LAYERING_LAYER_CONSTRAINT, LayerConstraint::FIRST) // Draw an ellipse figure for exit nodes... - val figure = node.addEllipse().background = "white".color; - figure.addText("").setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 1, 0) + val figure = node.addEllipse() + figure.addText("") => [ + it.setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 1, 0) + it.foreground = NODE_TEXT.color + ] val text = if(entry.hasAnnotation("label")) entry.getStringAnnotationValue("label") else "entry" node.initialiseFigure(SHOW_CAPTION.booleanValue ? text : "") if (scg.method) { @@ -414,8 +421,11 @@ class SCGraphComponentSynthesis { if (ALIGN_ENTRYEXIT_NODES.booleanValue) node.addLayoutParam(LayeredOptions::LAYERING_LAYER_CONSTRAINT, LayerConstraint::LAST) // Draw an ellipse for an exit node... - val figure = node.addEllipse().background = "white".color; - figure.addText("").setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 1, 0) + val figure = node.addEllipse() + figure.addText("") => [ + it.setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 1, 0) + it.foreground = NODE_TEXT.color + ] node.initialiseFigure(SHOW_CAPTION.booleanValue ? "exit" : "") if (exit.final) { diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphDiagramSynthesis.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphDiagramSynthesis.xtend index 158be4c6c9..a73ee315a2 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphDiagramSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphDiagramSynthesis.xtend @@ -107,7 +107,6 @@ class SCGraphDiagramSynthesis extends AbstractDiagramSynthesis { @Inject extension KPortExtensions @Inject extension KContainerRenderingExtensions @Inject extension KPolylineExtensions - @Inject extension KColorExtensions @Inject extension AnnotationsExtensions @Inject extension SCGCoreExtensions @Inject extension SCGControlFlowExtensions @@ -250,6 +249,9 @@ class SCGraphDiagramSynthesis extends AbstractDiagramSynthesis { scc = prioAuxData.stronglyConnectedComponents } } + + // Apply color theme + configureAllColors(usedContext) // Invoke the synthesis. SCGraph = model @@ -498,12 +500,13 @@ class SCGraphDiagramSynthesis extends AbstractDiagramSynthesis { aNode.setMinimalNodeSize(16, 16) aNode.addRoundedRectangle(1, 1, 1) => [ - setBackgroundGradient(COMMENT_BACKGROUND_GRADIENT_1.color2, COMMENT_BACKGROUND_GRADIENT_2.color2, 90); - foreground = COMMENT_FOREGROND.color2; + setBackgroundGradient(COMMENT_BACKGROUND_GRADIENT_1.color, COMMENT_BACKGROUND_GRADIENT_2.color, 90); + foreground = COMMENT_FOREGROND.color; ] aNode.getKContainerRendering.addText(commentText) => [ fontSize = 8; setGridPlacementData().from(LEFT, 4, 0, TOP, 4, 0).to(RIGHT, 4, 0, BOTTOM, 4, 0); + foreground = COMMENT_TEXT.color; ] val edge = createEdge() @@ -599,12 +602,14 @@ class SCGraphDiagramSynthesis extends AbstractDiagramSynthesis { edge.addRoundedBendsPolyline(8, CONTROLFLOW_THICKNESS.floatValue) => [ it.lineStyle = LineStyle::SOLID it.addHeadArrowDecorator - it.foreground = STANDARD_CONTROLFLOWEDGE.color + it.foreground = CONTROLFLOW_EDGE.color it.foreground.propagateToChildren = true ] // If the outgoing identifier indicates a 'then branch', add a 'then label'. if (outgoingPortId == SCGraphSynthesisHelper.SCGPORTID_OUTGOING_THEN) { - edge.createLabel.configureTailEdgeLabel('true', 9, KlighdConstants::DEFAULT_FONT_NAME) + edge.createLabel.configureTailEdgeLabel('true', 9, KlighdConstants::DEFAULT_FONT_NAME) => [ + it.KRendering.foreground = NODE_TEXT.color + ] } if (controlFlow.targetNode.schizophrenic) { @@ -626,12 +631,14 @@ class SCGraphDiagramSynthesis extends AbstractDiagramSynthesis { it.setPortSize(50, 20) it.KContainerRendering.setProperty(PRIO_STATEMENTS_PROPERTY, true) var rec = it.KContainerRendering.addRoundedRectangle(SCGraphSynthesisHelper.CORNERRADIUS, - SCGraphSynthesisHelper.CORNERRADIUS, SCGraphSynthesisHelper.LINEWIDTH) - rec.background = "white".color - var txt = rec.addText("prio(" + tgtPrio.value + ")") - txt.fontSize = 7 - var x = txt.setAreaPlacementData - x.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 1, 0, BOTTOM, 1, 0) + SCGraphSynthesisHelper.CORNERRADIUS, SCGraphSynthesisHelper.LINEWIDTH) => [ + background = NODE_BACKGROUND.color + ] + rec.addText("prio(" + tgtPrio.value + ")") => [ + fontSize = 7 + foreground = NODE_TEXT.color + setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 1, 0, BOTTOM, 1, 0) + ] ] } } @@ -791,7 +798,7 @@ class SCGraphDiagramSynthesis extends AbstractDiagramSynthesis { if (!nonScheduleDependencies.empty) { nonScheduleDependencies.forEach [ - colorDependency(SCHEDULING_SCHEDULINGEDGE.color) + colorDependency(SCHEDULING_SCHEDULING_EDGE.color) thickenDependency(CONTROLFLOW_SCHEDULINGEDGE_WIDTH) dependencyAlpha(SCHEDULING_SCHEDULINGEDGE_ALPHA) ] @@ -800,7 +807,7 @@ class SCGraphDiagramSynthesis extends AbstractDiagramSynthesis { it.source = sourceKNode it.target = targetKNode it.addRoundedBendsPolyline(8, CONTROLFLOW_SCHEDULINGEDGE_WIDTH) => [ - it.foreground = SCHEDULING_SCHEDULINGEDGE.color + it.foreground = SCHEDULING_SCHEDULING_EDGE.color it.foreground.alpha = SCHEDULING_SCHEDULINGEDGE_ALPHA it.addHeadArrowDecorator ] diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphHierarchySynthesis.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphHierarchySynthesis.xtend index a94da92ea6..e94bd642bb 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphHierarchySynthesis.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphHierarchySynthesis.xtend @@ -130,13 +130,13 @@ class SCGraphHierarchySynthesis { } else { label = entry.getStringAnnotationValue(ANNOTATION_REGIONNAME) } - val REGION_LABEL = label + val threadLabel = label entry.getThreadNodes.createHierarchy(NODEGROUPING_HIERARCHY, null) => [ var text = "" - if(!REGION_LABEL.nullOrEmpty) text = REGION_LABEL + if(!threadLabel.nullOrEmpty) text = threadLabel val threadPathType = threadTypes.get(entry) if (threadPathType !== null) { - if(!REGION_LABEL.nullOrEmpty) text = text + " - " + if(!threadLabel.nullOrEmpty) text = text + " - " text = text + threadPathType.toString2 + (entry.hasAnnotation(SCGAnnotations.ANNOTATION_CONTROLFLOWTHREADPATHTYPE_PREEMPTION) ? " " + entry.getStringAnnotationValue(SCGAnnotations.ANNOTATION_CONTROLFLOWTHREADPATHTYPE_PREEMPTION) : "" ) } @@ -146,9 +146,8 @@ class SCGraphHierarchySynthesis { threadSegmentIDText = "ThreadID: " + (entry.getAnnotation( PriorityAuxiliaryData.THREAD_SEGMENT_ANNOTATION) as IntAnnotation).value.toString - val labelTR = addOutsideTopLeftNodeLabel(threadSegmentIDText, 10, - KlighdConstants::DEFAULT_FONT_NAME) => [ - it.KRendering.setForeground(REGION_LABEL.color) + val labelTR = addOutsideTopLeftNodeLabel(threadSegmentIDText, 10, KlighdConstants::DEFAULT_FONT_NAME) => [ + it.KRendering.setForeground(THREAD_LABEL.color) ] labelTR.KRendering.setProperty(SCGraphDiagramSynthesis.THREAD_PRIO_PROPERTY, true) } @@ -156,7 +155,7 @@ class SCGraphHierarchySynthesis { if (SHOW_POTENTIALPROBLEMS.booleanValue) { // Workaround for fixing the massive whitespace: using centered labels addInsideTopCenteredNodeLabel(text, 10, KlighdConstants::DEFAULT_FONT_NAME) => [ - it.KRendering.setForeground(REGION_LABEL.color); + it.KRendering.setForeground(THREAD_LABEL.color); ] } @@ -230,7 +229,7 @@ class SCGraphHierarchySynthesis { bbName = bbName.replaceAll("_g", "g") bbName.createLabel(bbContainer).configureOutsideTopLeftNodeLabel(bbName, 9, - KlighdConstants::DEFAULT_FONT_NAME).KRendering.foreground = BASICBLOCKBORDER.color + KlighdConstants::DEFAULT_FONT_NAME).KRendering.foreground = BASICBLOCK_BORDER.color } if (SHOW_SCHEDULINGBLOCKS.booleanValue) { for (schedulingBlock : basicBlock.schedulingBlocks) { @@ -260,7 +259,7 @@ class SCGraphHierarchySynthesis { sbName = sbName.replaceAll("_g", "g") sbName.createLabel(sbContainer).associateWith(schedulingBlock). configureOutsideTopLeftNodeLabel(sbName, 9, KlighdConstants::DEFAULT_FONT_NAME). - KRendering.foreground = SCHEDULINGBLOCKBORDER.color + KRendering.foreground = SCHEDULINGBLOCK_BORDER.color } if (basicBlock.deadBlock) { @@ -390,10 +389,10 @@ class SCGraphHierarchySynthesis { if (nodeGrouping == NODEGROUPING_HIERARCHY) { kContainer.addRoundedRectangle(5, 5, 0) - kContainer.KRendering.foreground = SCCHARTSBLUE.color; + kContainer.KRendering.foreground = THREAD_BACKGROUND.color; kContainer.KRendering.foreground.alpha = Math.round( HIERARCHY_TRANSPARENCY.objectValue as Float) - kContainer.KRendering.background = SCCHARTSBLUE.color; + kContainer.KRendering.background = THREAD_BACKGROUND.color; kContainer.KRendering.background.alpha = Math.round( HIERARCHY_TRANSPARENCY.objectValue as Float) } @@ -402,9 +401,9 @@ class SCGraphHierarchySynthesis { lineStyle = LineStyle::SOLID associateWith(contextObject) ] - kContainer.KRendering.foreground = BASICBLOCKBORDER.color; + kContainer.KRendering.foreground = BASICBLOCK_BORDER.color; kContainer.KRendering.foreground.alpha = Math.round(255f) - kContainer.KRendering.background = SCCHARTSBLUE.color; + kContainer.KRendering.background = THREAD_BACKGROUND.color; kContainer.KRendering.background.alpha = Math.round(0f) } if (nodeGrouping == NODEGROUPING_SCHEDULINGBLOCK) { @@ -412,9 +411,9 @@ class SCGraphHierarchySynthesis { lineStyle = LineStyle::SOLID associateWith(contextObject) ] - kContainer.KRendering.foreground = SCHEDULINGBLOCKBORDER.color; + kContainer.KRendering.foreground = SCHEDULINGBLOCK_BORDER.color; kContainer.KRendering.foreground.alpha = Math.round(255f) - kContainer.KRendering.background = SCCHARTSBLUE.color; + kContainer.KRendering.background = THREAD_BACKGROUND.color; kContainer.KRendering.background.alpha = Math.round(0f) } if (nodeGrouping == NODEGROUPING_GUARDBLOCK) { @@ -432,9 +431,9 @@ class SCGraphHierarchySynthesis { lineStyle = LineStyle::SOLID associateWith(contextObject) ] - kContainer.KRendering.foreground = SCHEDULEBORDER.color; + kContainer.KRendering.foreground = SCHEDULE_BORDER.color; kContainer.KRendering.foreground.alpha = Math.round(196f) - kContainer.KRendering.background = SCCHARTSBLUE.color; + kContainer.KRendering.background = THREAD_BACKGROUND.color; kContainer.KRendering.background.alpha = Math.round(0f) } if (nodeGrouping == NODEGROUPING_SCC) { @@ -442,9 +441,9 @@ class SCGraphHierarchySynthesis { lineStyle = LineStyle::SOLID associateWith(contextObject) ] - kContainer.KRendering.foreground = SCHEDULINGBLOCKBORDER.color; + kContainer.KRendering.foreground = SCHEDULINGBLOCK_BORDER.color; kContainer.KRendering.foreground.alpha = Math.round(196f) - kContainer.KRendering.background = SCCHARTSBLUE.color; + kContainer.KRendering.background = THREAD_BACKGROUND.color; kContainer.KRendering.background.alpha = Math.round(0f) } diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphShapes.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphShapes.xtend index 19f76bb5ae..818495ecd2 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphShapes.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphShapes.xtend @@ -24,6 +24,8 @@ import javax.inject.Inject import de.cau.cs.kieler.klighd.kgraph.util.KGraphUtil import de.cau.cs.kieler.klighd.krendering.extensions.KContainerRenderingExtensions +import static de.cau.cs.kieler.scg.klighd.ColorStore.Color.* + /** * KRendering Utility class for KLighD visualization. * @@ -38,52 +40,7 @@ class SCGraphShapes { @Inject extension KColorExtensions @Inject extension KNodeExtensions @Inject extension KContainerRenderingExtensions - - - def KNode createRoundedRectangulareNode(Object o) { - val node = o.node; - val rect = KRenderingFactory::eINSTANCE.createKRoundedRectangle; - rect.setCornerHeight(10); - rect.setCornerWidth(10); - node.data.add(rect); - node.KRendering.background = "white".color - return node; - } - - def KNode createRoundedRectangulareNode(Object o, int height, int width) { - val node = o.createRoundedRectangulareNode; - node.height = height; - node.width = width; - return node; - } - - def KNode createRectangulareNode(Object o) { - val node = o.node; - val rect = KRenderingFactory::eINSTANCE.createKRectangle; - node.data.add(rect); - return node; - } - - def KNode createRectangulareNode(Object o, int height, int width) { - val node = o.createRectangulareNode; - node.height = height; - node.width = width; - return node; - } - - def KNode createEllipseNode(Object o) { - val node = o.node; - val rect = KRenderingFactory::eINSTANCE.createKEllipse; - node.data.add(rect); - return node; - } - - def KNode createEllipseNode(Object o, int height, int width) { - val node = o.createEllipseNode; - node.height = height; - node.width = width; - return node; - } + @Inject extension ColorStore def KPolygon createTriangleShape(KPolygon poly) { poly => [ @@ -91,8 +48,12 @@ class SCGraphShapes { it.points += createKPosition(LEFT, 0, 1.0f, TOP, 0, 1.0f); it.points += createKPosition(LEFT, 0, 0.0f, TOP, 0, 1.0f); it.points += createKPosition(LEFT, 0, 0.5f, TOP, 0, 0); - it.background = "white".color - addText("").setAreaPlacementData.from(LEFT, 0, 0, TOP, 4, 0).to(RIGHT, 0, 0, BOTTOM, 0, 0) + + it.foreground = NODE_FOREGROUND.color + it.background = NODE_BACKGROUND.color + addText("").setAreaPlacementData.from(LEFT, 0, 0, TOP, 4, 0).to(RIGHT, 0, 0, BOTTOM, 0, 0) => [ + it.foreground = NODE_TEXT.color + ] ]; } @@ -102,8 +63,12 @@ class SCGraphShapes { it.points += createKPosition(LEFT, 0, 1.0f, TOP, 0, 0.0f); it.points += createKPosition(LEFT, 0, 1.0f, TOP, 0, 1.0f); it.points += createKPosition(LEFT, 0, 0.0f, TOP, 0, 0.5f); - it.background = "white".color - addText("").setAreaPlacementData.from(LEFT, 2, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 2, 0) + + it.foreground = NODE_FOREGROUND.color + it.background = NODE_BACKGROUND.color + addText("").setAreaPlacementData.from(LEFT, 2, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 2, 0) => [ + it.foreground = NODE_TEXT.color + ] ]; } @@ -113,8 +78,12 @@ class SCGraphShapes { it.points += createKPosition(LEFT, 0, 1.0f, TOP, 0, 0f); it.points += createKPosition(LEFT, 0, 0.0f, TOP, 0, 0f); it.points += createKPosition(LEFT, 0, 0.5f, TOP, 0, 1.0f); - it.background = "white".color - addText("").setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 10, 0) + + it.foreground = NODE_FOREGROUND.color + it.background = NODE_BACKGROUND.color + addText("").setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 10, 0) => [ + it.foreground = NODE_TEXT.color + ] ]; } @@ -124,8 +93,12 @@ class SCGraphShapes { it.points += createKPosition(LEFT, 0, 1.0f, TOP, 0, 0.5f); it.points += createKPosition(LEFT, 0, 0.0f, TOP, 0, 1.0f); it.points += createKPosition(LEFT, 0, 0.0f, TOP, 0, 0.0f); - it.background = "white".color - addText("").setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 4, 0) + + it.foreground = NODE_FOREGROUND.color + it.background = NODE_BACKGROUND.color + it.addText("").setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 4, 0) => [ + it.foreground = NODE_TEXT.color + ] ]; } @@ -136,10 +109,11 @@ class SCGraphShapes { it.points += createKPosition(LEFT, 0, 0.5f, TOP, 0, 1.0f); it.points += createKPosition(LEFT, 0, 0f, TOP, 0, 0.5f); it.points += createKPosition(LEFT, 0, 0.5f, TOP, 0, 0f); - it.background = "white".color - it.addText("").setAreaPlacementData. - from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 1, 0, BOTTOM, 1, 0) => [ - it.background = "white".color + + it.foreground = NODE_FOREGROUND.color + it.background = NODE_BACKGROUND.color + it.addText("").setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 1, 0, BOTTOM, 1, 0) => [ + it.foreground = NODE_TEXT.color it.background.alpha = 196 ] ]; @@ -153,8 +127,12 @@ class SCGraphShapes { it.points += createKPosition(LEFT, 0, 0.0f, TOP, 0, 1.0f); it.points += createKPosition(LEFT, 0, 0.0f, TOP, 0, 0.33f); it.points += createKPosition(LEFT, 0, 0.5f, TOP, 0, 0); - it.background = "white".color - addText("") + + it.foreground = NODE_FOREGROUND.color + it.background = NODE_BACKGROUND.color + addText("") => [ + it.foreground = NODE_TEXT.color + ] ]; } @@ -166,8 +144,12 @@ class SCGraphShapes { it.points += createKPosition(LEFT, 0, 0.25f, TOP, 0, 1.0f); it.points += createKPosition(LEFT, 0, 0.0f, TOP, 0, 0.5f); it.points += createKPosition(LEFT, 0, 0.25f, TOP, 0, 0); - it.background = "white".color - addText("").setAreaPlacementData.from(LEFT, 10, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 3, 0) + + it.foreground = NODE_FOREGROUND.color + it.background = NODE_BACKGROUND.color + addText("").setAreaPlacementData.from(LEFT, 10, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 3, 0) => [ + it.foreground = NODE_TEXT.color + ] ]; } @@ -179,8 +161,12 @@ class SCGraphShapes { it.points += createKPosition(LEFT, 0, 0.0f, TOP, 0, 0.0f); it.points += createKPosition(LEFT, 0, 0.0f, TOP, 0, 0.66f); it.points += createKPosition(LEFT, 0, 0.5f, TOP, 0, 1.0f); - it.background = "white".color - addText("").setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 4, 0) + + it.foreground = NODE_FOREGROUND.color + it.background = NODE_BACKGROUND.color + addText("").setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 0, 0, BOTTOM, 4, 0) => [ + it.foreground = NODE_TEXT.color + ] ]; } @@ -192,8 +178,12 @@ class SCGraphShapes { it.points += createKPosition(LEFT, 0, 0.75f, TOP, 0, 1.0f); it.points += createKPosition(LEFT, 0, 0.0f, TOP, 0, 1.0f); it.points += createKPosition(LEFT, 0, 0.0f, TOP, 0, 0.0f); - it.background = "white".color - addText("").setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 10, 0, BOTTOM, 2, 0) + + it.foreground = NODE_FOREGROUND.color + it.background = NODE_BACKGROUND.color + addText("").setAreaPlacementData.from(LEFT, 0, 0, TOP, 0, 0).to(RIGHT, 10, 0, BOTTOM, 2, 0) => [ + it.foreground = NODE_TEXT.color + ] ]; } diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphSynthesisHelper.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphSynthesisHelper.xtend index 75cdc6f054..9cd68aa791 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphSynthesisHelper.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphSynthesisHelper.xtend @@ -155,7 +155,9 @@ class SCGraphSynthesisHelper { def initialiseFigure(KNode node, Object object) { node.setMinimalNodeSize(MINIMALWIDTH, MINIMALHEIGHT) val figure = node.data.filter(KContainerRendering).last - if(SHOW_SHADOW.booleanValue) figure.shadow = "black".color + figure.foreground = NODE_FOREGROUND.color + figure.background = NODE_BACKGROUND.color + if(SHOW_SHADOW.booleanValue) figure.shadow = NODE_SHADOW.color var label = "" if (object instanceof Annotatable) { if (object.hasAnnotation(ANNOTATION_LABEL)) { @@ -168,7 +170,8 @@ class SCGraphSynthesisHelper { } else if (object instanceof String) { label = object } - figure.children.filter(KText).head.text = label + val ktext = figure.children.filter(KText).head + ktext.text = label } /** @@ -187,6 +190,7 @@ class SCGraphSynthesisHelper { edge.setProperty(CoreOptions::EDGE_ROUTING, EdgeRouting::ORTHOGONAL); edge.addRoundedBendsPolyline(8, CONTROLFLOW_THICKNESS.floatValue) => [ it.lineStyle = LineStyle::DOT; + it.foreground = CONTROLFLOW_EDGE.color ] if (USE_ADAPTIVEZOOM.booleanValue) edge.setProperty(KlighdProperties.VISIBILITY_SCALE_LOWER_BOUND, 0.70); diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphsDiagramSynthesisOld.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphsDiagramSynthesisOld.xtend index c2f80e1719..d2e80ee947 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphsDiagramSynthesisOld.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/SCGraphsDiagramSynthesisOld.xtend @@ -1594,8 +1594,8 @@ class SCGraphsDiagramSynthesisOld extends AbstractDiagramSynthesis { aNode.setMinimalNodeSize(16, 16) aNode.addRoundedRectangle(1, 1, 1) => [ - setBackgroundGradient(COMMENT_BACKGROUND_GRADIENT_1.color2, COMMENT_BACKGROUND_GRADIENT_2.color2, 90); - foreground = COMMENT_FOREGROND.color2; + setBackgroundGradient(COMMENT_BACKGROUND_GRADIENT_1.color, COMMENT_BACKGROUND_GRADIENT_2.color, 90); + foreground = COMMENT_FOREGROND.color; ] aNode.getKContainerRendering.addText(commentText) => [ fontSize = 8; From b8c011f53f4941df71fae078c22b5aa042b1d3f2 Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Tue, 25 Mar 2025 15:53:38 +0100 Subject: [PATCH 11/17] sccharts: Adopted new color theme API and adjusted dark themes --- .../synthesis/colors/AbstractColorStore.java | 12 +++++++++-- .../synthesis/colors/DefaultColorStore.java | 4 ++-- .../hooks/LabelPlacementSideHook.xtend | 3 ++- .../ui/synthesis/styles/ColorStore.java | 16 ++++++++------- .../cau/cs/kieler/scg/klighd/ColorStore.java | 20 +++++++++++++------ 5 files changed, 37 insertions(+), 18 deletions(-) diff --git a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java index e7a75a8621..597cea485a 100644 --- a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java +++ b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java @@ -99,15 +99,23 @@ public void configureAllColors(final ViewContext context) { configureColor(GeneralColor.BACKGROUND, preferences.getBackground()); configureColor(GeneralColor.HIGHLIGHT, preferences.getHighlight()); - configureOwnColors(preferences); + boolean confirm = configureOwnColors(preferences); + + if (confirm) { + // Complete handshake with Klighd + context.setProperty(KlighdProperties.DIAGRAM_BACKGROUND, getColor(GeneralColor.BACKGROUND)); + } } } /** * Handles the color adjustment for the colors of the deriving class. + * * @param preferences + * @return true if the color theme was accepted (is supported), false if a fallback to a white + * canvas is requested. */ - protected abstract void configureOwnColors(ColorPreferences preferences); + protected abstract boolean configureOwnColors(ColorPreferences preferences); /** * Configures the given color with RGB values. diff --git a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/DefaultColorStore.java b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/DefaultColorStore.java index 1a87174590..38eb7d9b39 100644 --- a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/DefaultColorStore.java +++ b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/DefaultColorStore.java @@ -24,7 +24,7 @@ public class DefaultColorStore extends AbstractColorStore { @Override - public void configureOwnColors(final ColorPreferences preferences) { - // nothing to configure + public boolean configureOwnColors(final ColorPreferences preferences) { + return true; } } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/LabelPlacementSideHook.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/LabelPlacementSideHook.xtend index 056465d26d..2d0e3f9afa 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/LabelPlacementSideHook.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/LabelPlacementSideHook.xtend @@ -89,7 +89,8 @@ class LabelPlacementSideHook extends SynthesisHook { // Colors we shall use val foregroundKColor = REGION_FOREGROUND.color val foreground = new Color(foregroundKColor.red, foregroundKColor.green, foregroundKColor.blue); - val background = new Color(255, 255, 255, 220); + val backgroundKColor = REGION_BACKGROUND.color + val background = new Color(backgroundKColor.red, backgroundKColor.green, backgroundKColor.blue, 220); // Create and properly configure an inline label configurator that will do most of our work for us val inlineLabelConfigurator = LabelDecorationConfigurator.create.withInlineLabels(true) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java index 0d3e5e37cb..f4c5210d14 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java @@ -18,6 +18,7 @@ import de.cau.cs.kieler.klighd.krendering.KRenderingFactory; import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared; import de.cau.cs.kieler.klighd.util.ColorPreferences; +import de.cau.cs.kieler.klighd.util.ColorThemeKind; import static de.cau.cs.kieler.kicool.ui.synthesis.colors.ColorUtil.*; @@ -135,15 +136,14 @@ public KColor getDefaultColor() { }; @Override - public void configureOwnColors(final ColorPreferences preferences) { - var fg = preferences.getForeground(); - var bg = preferences.getBackground(); - - // check if it can be considered dark mode - var bgHSB = java.awt.Color.RGBtoHSB(bg.getRed(), bg.getGreen(), bg.getBlue(), null); - boolean dark = bgHSB[2] < 0.6f; + public boolean configureOwnColors(final ColorPreferences preferences) { + boolean dark = preferences.getKind() == ColorThemeKind.DARK || preferences.getKind() == ColorThemeKind.HIGH_CONTRAST_DARK; if (dark) { + var fg = preferences.getForeground(); + // Make normal background slightly brighter than canvas + var bg = adjustBrightness(preferences.getBackground(), 0.05f); + configureColor(Color.STATE_FOREGROUND, fg); configureColor(Color.STATE_TEXT_FOREGROUND, fg); configureColor(Color.STATE_INITIAL_FOREGROND, fg); @@ -208,5 +208,7 @@ public void configureOwnColors(final ColorPreferences preferences) { configureColor(Color.KEYWORD, 0xC5, 0x86, 0xC0); } + + return true; } } diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ColorStore.java b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ColorStore.java index 0c99d42ffe..dc087a1ee1 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ColorStore.java +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ColorStore.java @@ -12,12 +12,15 @@ */ package de.cau.cs.kieler.scg.klighd; +import static de.cau.cs.kieler.kicool.ui.synthesis.colors.ColorUtil.adjustBrightness; + import de.cau.cs.kieler.kicool.ui.synthesis.colors.AbstractColorStore; import de.cau.cs.kieler.klighd.krendering.Colors; import de.cau.cs.kieler.klighd.krendering.KColor; import de.cau.cs.kieler.klighd.krendering.KRenderingFactory; import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared; import de.cau.cs.kieler.klighd.util.ColorPreferences; +import de.cau.cs.kieler.klighd.util.ColorThemeKind; /** * The SCG colors. @@ -107,20 +110,23 @@ public KColor getDefaultColor() { }; @Override - public void configureOwnColors(final ColorPreferences preferences) { + public boolean configureOwnColors(final ColorPreferences preferences) { var fg = preferences.getForeground(); var bg = preferences.getBackground(); - - // check if it can be considered dark mode - var bgHSB = java.awt.Color.RGBtoHSB(bg.getRed(), bg.getGreen(), bg.getBlue(), null); - boolean dark = bgHSB[2] < 0.6f; configureColor(Color.NODE_FOREGROUND, fg); configureColor(Color.NODE_BACKGROUND, bg); configureColor(Color.NODE_TEXT, fg); configureColor(Color.CONTROLFLOW_EDGE, fg); + + boolean dark = preferences.getKind() == ColorThemeKind.DARK || preferences.getKind() == ColorThemeKind.HIGH_CONTRAST_DARK; + if (dark) { - configureColor(Color.NODE_SHADOW, Colors.LIGHT_GRAY); + // Make normal background slightly brighter than canvas + bg = adjustBrightness(preferences.getBackground(), 0.06f); + configureColor(Color.NODE_BACKGROUND, bg); + + configureColor(Color.NODE_SHADOW, bg); configureColor(Color.NODE_REFERENCED_BACKGROUND_GRADIENT_1, 103, 74, 115); configureColor(Color.NODE_REFERENCED_BACKGROUND_GRADIENT_2, 125, 98, 125); @@ -134,5 +140,7 @@ public void configureOwnColors(final ColorPreferences preferences) { configureColor(Color.COMMENT_TEXT, fg); configureColor(Color.COMMENT_EDGE, Colors.ANTIQUE_WHITE_3); } + + return true; } } From 524f5d93a9d21a2d0f125944db5b76620ac2d655 Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Tue, 25 Mar 2025 16:47:26 +0100 Subject: [PATCH 12/17] scg: Fixed issue with injecting members in action that have the ViewSynthesisShared annotation --- .../kieler/scg/klighd/actions/NodePriorityActions.xtend | 8 ++------ .../cs/kieler/scg/klighd/actions/OptNodePrioActions.xtend | 7 ++----- .../kieler/scg/klighd/actions/PrioStatementsActions.xtend | 8 ++------ .../de/cau/cs/kieler/scg/klighd/actions/SCCActions.xtend | 3 ++- .../kieler/scg/klighd/actions/ThreadPriorityActions.xtend | 3 ++- 5 files changed, 10 insertions(+), 19 deletions(-) diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/NodePriorityActions.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/NodePriorityActions.xtend index 30787368cf..939c238c75 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/NodePriorityActions.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/NodePriorityActions.xtend @@ -14,9 +14,9 @@ package de.cau.cs.kieler.scg.klighd.actions import com.google.inject.Guice import com.google.inject.Inject -import de.cau.cs.kieler.klighd.IAction import de.cau.cs.kieler.klighd.SynthesisOption import de.cau.cs.kieler.klighd.ViewContext +import de.cau.cs.kieler.klighd.actions.SynthesizingAction import de.cau.cs.kieler.klighd.kgraph.KNode import de.cau.cs.kieler.klighd.krendering.extensions.KRenderingExtensions import de.cau.cs.kieler.scg.klighd.SCGraphSynthesisHelper @@ -30,7 +30,7 @@ import static extension de.cau.cs.kieler.klighd.util.ModelingUtil.* * @author lpe * */ -class NodePriorityActions implements IAction { +class NodePriorityActions extends SynthesizingAction { private static final String NODE_ID = "de.cau.cs.kieler.scg.klighd.actions.priorityActions" @@ -78,8 +78,4 @@ class NodePriorityActions implements IAction { } } - new() { - Guice.createInjector.injectMembers(this) - } - } diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/OptNodePrioActions.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/OptNodePrioActions.xtend index 32a7ff1c1c..3ef7d9f803 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/OptNodePrioActions.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/OptNodePrioActions.xtend @@ -23,13 +23,14 @@ import de.cau.cs.kieler.scg.klighd.SCGraphSynthesisHelper import static de.cau.cs.kieler.scg.klighd.SCGraphSynthesisOptions.* import static extension de.cau.cs.kieler.klighd.util.ModelingUtil.* +import de.cau.cs.kieler.klighd.actions.SynthesizingAction /** * Action class to display the optimized node priorities in the scg. * @author lpe * */ -class OptNodePrioActions implements IAction { +class OptNodePrioActions extends SynthesizingAction { @Inject extension KRenderingExtensions @@ -78,8 +79,4 @@ class OptNodePrioActions implements IAction { } } - new(){ - Guice.createInjector.injectMembers(this) - } - } diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/PrioStatementsActions.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/PrioStatementsActions.xtend index afd8e860e6..689ad0dc26 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/PrioStatementsActions.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/PrioStatementsActions.xtend @@ -24,13 +24,14 @@ import de.cau.cs.kieler.scg.klighd.SCGraphDiagramSynthesis import static de.cau.cs.kieler.scg.klighd.SCGraphSynthesisOptions.* import static extension de.cau.cs.kieler.klighd.util.ModelingUtil.* +import de.cau.cs.kieler.klighd.actions.SynthesizingAction /** * Action class to display the prio statements in the SCG. * @author lpe * */ -class PrioStatementsActions implements IAction { +class PrioStatementsActions extends SynthesizingAction { private static final String PRIO_STATEMENTS_ID = "de.cau.cs.kieler.scg.klighd.actions.priorityStatements" @@ -94,9 +95,4 @@ class PrioStatementsActions implements IAction { } } - new(){ - Guice.createInjector.injectMembers(this) - } - - } \ No newline at end of file diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/SCCActions.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/SCCActions.xtend index ff1a163bdd..7555caa163 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/SCCActions.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/SCCActions.xtend @@ -29,13 +29,14 @@ import org.eclipse.elk.graph.properties.Property import static de.cau.cs.kieler.scg.klighd.SCGraphSynthesisOptions.* import static extension de.cau.cs.kieler.klighd.util.ModelingUtil.* +import de.cau.cs.kieler.klighd.actions.SynthesizingAction /** * Action class to display Strongly Connected Components in the SCG. * @author lpe * */ -class SCCActions implements IAction { +class SCCActions extends SynthesizingAction { private final static String SCC_ID = "de.cau.cs.kieler.scg.klighd.actions.sccActions" diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/ThreadPriorityActions.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/ThreadPriorityActions.xtend index 1904af7f43..7121a63b6f 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/ThreadPriorityActions.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/ThreadPriorityActions.xtend @@ -24,13 +24,14 @@ import de.cau.cs.kieler.scg.klighd.SCGraphDiagramSynthesis import static de.cau.cs.kieler.scg.klighd.SCGraphSynthesisOptions.* import static extension de.cau.cs.kieler.klighd.util.ModelingUtil.* +import de.cau.cs.kieler.klighd.actions.SynthesizingAction /** * Action class to display the thread priorities in the SCG * @author lpe * */ -class ThreadPriorityActions implements IAction { +class ThreadPriorityActions extends SynthesizingAction { @Inject extension KRenderingExtensions From ef5a3e13500ed690c253d56af7a07353d4be905d Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Tue, 25 Mar 2025 18:54:34 +0100 Subject: [PATCH 13/17] removed old constructors from actions --- .../de/cau/cs/kieler/scg/klighd/actions/SCCActions.xtend | 7 ------- .../kieler/scg/klighd/actions/ThreadPriorityActions.xtend | 6 ------ 2 files changed, 13 deletions(-) diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/SCCActions.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/SCCActions.xtend index 7555caa163..71a43992e0 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/SCCActions.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/SCCActions.xtend @@ -12,9 +12,7 @@ */ package de.cau.cs.kieler.scg.klighd.actions -import com.google.inject.Guice import com.google.inject.Inject -import de.cau.cs.kieler.klighd.IAction import de.cau.cs.kieler.klighd.SynthesisOption import de.cau.cs.kieler.klighd.ViewContext import de.cau.cs.kieler.klighd.kgraph.KNode @@ -77,11 +75,6 @@ class SCCActions extends SynthesizingAction { return ActionResult.createResult(true) } - - new(){ - Guice.createInjector.injectMembers(this) - } - /** * Convenience getter. * diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/ThreadPriorityActions.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/ThreadPriorityActions.xtend index 7121a63b6f..0d22d4a413 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/ThreadPriorityActions.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/actions/ThreadPriorityActions.xtend @@ -12,9 +12,7 @@ */ package de.cau.cs.kieler.scg.klighd.actions -import com.google.inject.Guice import com.google.inject.Inject -import de.cau.cs.kieler.klighd.IAction import de.cau.cs.kieler.klighd.SynthesisOption import de.cau.cs.kieler.klighd.ViewContext import de.cau.cs.kieler.klighd.kgraph.KNode @@ -78,8 +76,4 @@ class ThreadPriorityActions extends SynthesizingAction { + option.getName() + " expecting a Boolean value."); } } - - new(){ - Guice.createInjector.injectMembers(this) - } } \ No newline at end of file From a1f93185ee73ad30a654fe78cec56b8567d522dd Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Tue, 25 Mar 2025 18:56:02 +0100 Subject: [PATCH 14/17] adapted to KLighD's old canvas color property for dark theme support --- .../kieler/kicool/ui/synthesis/colors/AbstractColorStore.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java index 597cea485a..4c522d2c0f 100644 --- a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java +++ b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java @@ -12,6 +12,7 @@ */ package de.cau.cs.kieler.kicool.ui.synthesis.colors; +import java.awt.Color; import java.util.HashMap; import java.util.Map; @@ -103,7 +104,8 @@ public void configureAllColors(final ViewContext context) { if (confirm) { // Complete handshake with Klighd - context.setProperty(KlighdProperties.DIAGRAM_BACKGROUND, getColor(GeneralColor.BACKGROUND)); + KColor kBackgroundColor = getColor(GeneralColor.BACKGROUND); + context.setProperty(KlighdProperties.CANVAS_COLOR, new Color(kBackgroundColor.getRed(), kBackgroundColor.getGreen(), kBackgroundColor.getBlue())); } } } From fd1f8a7d420c6c2c31c945a769c31692cc9dc65b Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Wed, 26 Mar 2025 10:02:20 +0100 Subject: [PATCH 15/17] transfer canvas color from child context in code container synthesis --- .../kieler/kicool/ui/synthesis/CodeContainerSynthesis.xtend | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/CodeContainerSynthesis.xtend b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/CodeContainerSynthesis.xtend index b180e46956..ba90e31669 100644 --- a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/CodeContainerSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/CodeContainerSynthesis.xtend @@ -21,6 +21,7 @@ import de.cau.cs.kieler.klighd.SynthesisOption import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared import de.cau.cs.kieler.klighd.krendering.extensions.KNodeExtensions import de.cau.cs.kieler.klighd.syntheses.AbstractDiagramSynthesis +import de.cau.cs.kieler.klighd.util.KlighdProperties /** * Generic synthesis for strings. @@ -62,6 +63,11 @@ class CodeContainerSynthesis extends AbstractDiagramSynthesis { val cphNode = if (diagramVC.viewModel.children.head.children.nullOrEmpty) diagramVC.viewModel.children.head else diagramVC.viewModel.children.head.children.head + + // transfer canvas color from child context + if (diagramVC.hasProperty(KlighdProperties.CANVAS_COLOR)) { + myViewContext.setProperty(KlighdProperties.CANVAS_COLOR, diagramVC.getProperty(KlighdProperties.CANVAS_COLOR)) + } rootNode.children += cphNode } From 9c35fc2ba1516cd51a8bcc3b3afc2cdbd0bb85d7 Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Wed, 26 Mar 2025 10:55:02 +0100 Subject: [PATCH 16/17] sccharts: Fixed paper mode in dark theme --- .../ui/synthesis/colors/AbstractColorStore.java | 8 ++++++++ .../ui/synthesis/hooks/BlackWhiteModeHook.xtend | 11 ++++++++--- .../src/de/cau/cs/kieler/scg/klighd/ColorStore.java | 2 ++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java index 4c522d2c0f..c285027599 100644 --- a/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java +++ b/plugins/de.cau.cs.kieler.kicool.ui/src/de/cau/cs/kieler/kicool/ui/synthesis/colors/AbstractColorStore.java @@ -178,4 +178,12 @@ public KColor getColor(IColor color) { } return null; } + + /** + * Resets the entire configuration of the color store to default colors. + * Use with caution! + */ + public void resetAllColors() { + configuration.clear(); + } } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/BlackWhiteModeHook.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/BlackWhiteModeHook.xtend index 64dcbd3bf2..13a18879e4 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/BlackWhiteModeHook.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/BlackWhiteModeHook.xtend @@ -19,13 +19,14 @@ import de.cau.cs.kieler.klighd.kgraph.KNode import de.cau.cs.kieler.klighd.krendering.Colors import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared import de.cau.cs.kieler.klighd.krendering.extensions.KRenderingExtensions +import de.cau.cs.kieler.klighd.util.KlighdProperties import de.cau.cs.kieler.sccharts.Scope import de.cau.cs.kieler.sccharts.State -import de.cau.cs.kieler.sccharts.ui.synthesis.hooks.SynthesisHook import de.cau.cs.kieler.sccharts.ui.synthesis.GeneralSynthesisOptions import de.cau.cs.kieler.sccharts.ui.synthesis.StateSynthesis import de.cau.cs.kieler.sccharts.ui.synthesis.styles.ColorStore import de.cau.cs.kieler.sccharts.ui.synthesis.styles.StateStyles +import java.awt.Color import static de.cau.cs.kieler.sccharts.ui.synthesis.styles.ColorStore.Color.* @@ -33,8 +34,6 @@ import static de.cau.cs.kieler.sccharts.ui.synthesis.styles.ColorStore.Color.* * Applies paper color theme. * * @author als - * @kieler.design 2015-08-13 proposed - * @kieler.rating 2015-08-13 proposed yellow * */ @ViewSynthesisShared @@ -62,6 +61,9 @@ class BlackWhiteModeHook extends SynthesisHook { override start(Scope scope, KNode root) { if (PAPER_BW.booleanValue) { + // Reset to light theme + resetAllColors(); + configureColor(TRANSITION_DEFERRED_DECORATOR, Colors.GRAY); configureColor(TRANSITION_ABORT_DECORATOR, Colors.GRAY); configureColor(TRANSITION_TERMINATION_DECORATOR, Colors.GRAY); @@ -75,6 +77,9 @@ class BlackWhiteModeHook extends SynthesisHook { configureColor(KEYWORD, Colors.DIM_GRAY); baseLineWidth = 2; + + // Set canvas to white + usedContext.setProperty(KlighdProperties.CANVAS_COLOR, new Color(255, 255, 255)); } } diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ColorStore.java b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ColorStore.java index dc087a1ee1..aca336089b 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ColorStore.java +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ColorStore.java @@ -139,6 +139,8 @@ public boolean configureOwnColors(final ColorPreferences preferences) { configureColor(Color.COMMENT_BACKGROUND_GRADIENT_2, Colors.ANTIQUE_WHITE_4); configureColor(Color.COMMENT_TEXT, fg); configureColor(Color.COMMENT_EDGE, Colors.ANTIQUE_WHITE_3); + + configureColor(Color.SCHEDULINGBLOCK_BORDER, 161, 71, 243); } return true; From b7d072bb0989d43dd0aa037a84ab20f93ae19930 Mon Sep 17 00:00:00 2001 From: Alexander Schulz-Rosengarten Date: Thu, 3 Apr 2025 14:55:59 +0200 Subject: [PATCH 17/17] sccharts: Added background color of regions adjusting to light theme --- .../sccharts/ui/synthesis/styles/ColorStore.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java index f4c5210d14..92f09fb9dd 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/styles/ColorStore.java @@ -139,10 +139,12 @@ public KColor getDefaultColor() { public boolean configureOwnColors(final ColorPreferences preferences) { boolean dark = preferences.getKind() == ColorThemeKind.DARK || preferences.getKind() == ColorThemeKind.HIGH_CONTRAST_DARK; + var fg = preferences.getForeground(); + var bg = preferences.getBackground(); + if (dark) { - var fg = preferences.getForeground(); // Make normal background slightly brighter than canvas - var bg = adjustBrightness(preferences.getBackground(), 0.05f); + bg = adjustBrightness(preferences.getBackground(), 0.05f); configureColor(Color.STATE_FOREGROUND, fg); configureColor(Color.STATE_TEXT_FOREGROUND, fg); @@ -207,6 +209,12 @@ public boolean configureOwnColors(final ColorPreferences preferences) { configureColor(Color.SELECTION, adjustBrightness(Color.SELECTION.defaultColor, 0.2f)); configureColor(Color.KEYWORD, 0xC5, 0x86, 0xC0); + } else { + // Adjust some background colors to light theme + configureColor(Color.REGION_BACKGROUND, bg); + configureColor(Color.REGION_OVERRIDE_BACKGROUND, bg); + configureColor(Color.REGION_ABORT_BACKGROUND, bg); + configureColor(Color.REGION_BUTTON_FOREGROUND, bg); } return true;