Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
fb0c821
sccharts.ui: Added dark theme for basic SCCharts
a-sr Oct 17, 2023
9fbba76
sccharts.ui: Removed direct injections of SCChartsSynthesis
a-sr Oct 18, 2023
a163c9f
sccharts.ui: Adjusted to new default in ColorPreferences property
a-sr Oct 18, 2023
7c6171c
sccharts.ui: Fixed import
a-sr Oct 18, 2023
e4d25a5
sccharts.ui: Added support for dark theme in dataflow
a-sr Oct 18, 2023
9cc6808
kicool.ui: Introduced abstract color store
a-sr Oct 18, 2023
e24cf61
sccharts.ui: Minor fixes in SCCharts DF dark mode
a-sr Oct 23, 2023
850102b
kicool.ui: Added dark theme for code placeholder diagrams
a-sr Oct 23, 2023
5a0d196
simulatin.ide: Fixed NPE in SimContext synthesis
a-sr Oct 23, 2023
71063b4
scg.klighd: Added SCG dark theme
a-sr Oct 25, 2023
242f579
Merge remote-tracking branch 'origin/master' into als/dark
a-sr Mar 25, 2025
b8c011f
sccharts: Adopted new color theme API and adjusted dark themes
a-sr Mar 25, 2025
524f5d9
scg: Fixed issue with injecting members in action that have the
a-sr Mar 25, 2025
ef5a3e1
removed old constructors from actions
NiklasRentzCAU Mar 25, 2025
a1f9318
adapted to KLighD's old canvas color property for dark theme support
NiklasRentzCAU Mar 25, 2025
fd1f8a7
transfer canvas color from child context in code container synthesis
NiklasRentzCAU Mar 26, 2025
9c35fc2
sccharts: Fixed paper mode in dark theme
a-sr Mar 26, 2025
b7d072b
sccharts: Added background color of regions adjusting to light theme
a-sr Apr 3, 2025
013bf23
Merge remote-tracking branch 'origin/master' into als/dark
a-sr Sep 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugins/de.cau.cs.kieler.kicool.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import de.cau.cs.kieler.klighd.syntheses.AbstractDiagramSynthesis
import com.google.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}.
Expand All @@ -49,6 +51,9 @@ class CodePlaceHolderSynthesis extends AbstractDiagramSynthesis<CodePlaceHolder>

@Inject
extension KColorExtensions

@Inject
extension DefaultColorStore

// -------------------------------------------------------------------------
// Constants
Expand All @@ -63,19 +68,23 @@ class CodePlaceHolderSynthesis extends AbstractDiagramSynthesis<CodePlaceHolder>
// Synthesis
override KNode transform(CodePlaceHolder placeholder) {
val startTime = System.currentTimeMillis
configureAllColors(usedContext)

val rootNode = createNode();
rootNode.children += createNode(placeholder) => [
it.associateWith(placeholder);
//outer frame
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;
]
Expand All @@ -90,12 +99,15 @@ class CodePlaceHolderSynthesis extends AbstractDiagramSynthesis<CodePlaceHolder>
]

// 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -62,6 +63,11 @@ class CodeContainerSynthesis extends AbstractDiagramSynthesis<CodeContainer> {
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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
/*
* 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.awt.Color;
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<IColor, KColor> configuration = new HashMap<IColor, KColor>();

/**
* 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());

boolean confirm = configureOwnColors(preferences);

if (confirm) {
// Complete handshake with Klighd
KColor kBackgroundColor = getColor(GeneralColor.BACKGROUND);
context.setProperty(KlighdProperties.CANVAS_COLOR, new Color(kBackgroundColor.getRed(), kBackgroundColor.getGreen(), kBackgroundColor.getBlue()));
}
}
}

/**
* 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 boolean 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;
}

/**
* Resets the entire configuration of the color store to default colors.
* Use with caution!
*/
public void resetAllColors() {
configuration.clear();
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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 boolean configureOwnColors(final ColorPreferences preferences) {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ knode operator {

krectangle {
styles: lineStyle = solid
foreground = 190r, 190g, 190b
}

kport in1 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Loading
Loading