Search in sources :

Example 16 with KText

use of de.cau.cs.kieler.klighd.krendering.KText in project lingua-franca by lf-lang.

the class ModeDiagrams method addModeFigure.

private KContainerRendering addModeFigure(KNode node, ModeInstance mode, boolean expanded) {
    int padding = getBooleanValue(LinguaFrancaSynthesis.SHOW_HYPERLINKS) ? 8 : 6;
    var figure = _kRenderingExtensions.addRoundedRectangle(node, 13, 13, 1);
    _kContainerRenderingExtensions.setGridPlacement(figure, 1);
    _kRenderingExtensions.setLineWidth(figure, mode.isInitial() ? 3f : 1.5f);
    _kRenderingExtensions.setForeground(figure, MODE_FG);
    _kRenderingExtensions.setBackground(figure, MODE_BG);
    var background = _kRenderingExtensions.getBackground(figure);
    background.setAlpha(MODE_BG_ALPHA);
    _linguaFrancaStyleExtensions.boldLineSelectionStyle(figure);
    // Invisible container
    KRectangle container = _kContainerRenderingExtensions.addRectangle(figure);
    _kRenderingExtensions.setInvisible(container, true);
    int bottomPadding = this.hasContent(mode) && expanded ? 4 : padding;
    var from = _kRenderingExtensions.from(_kRenderingExtensions.setGridPlacementData(container), _kRenderingExtensions.LEFT, padding, 0, _kRenderingExtensions.TOP, padding, 0);
    _kRenderingExtensions.to(from, _kRenderingExtensions.RIGHT, padding, 0, _kRenderingExtensions.BOTTOM, bottomPadding, 0);
    // Centered child container
    KRectangle childContainer = _kContainerRenderingExtensions.addRectangle(container);
    this._kRenderingExtensions.setInvisible(childContainer, true);
    this._kRenderingExtensions.setPointPlacementData(childContainer, _kRenderingExtensions.LEFT, 0, 0.5f, _kRenderingExtensions.TOP, 0, 0.5f, _kRenderingExtensions.H_CENTRAL, _kRenderingExtensions.V_CENTRAL, 0, 0, 0, 0);
    this._kContainerRenderingExtensions.setGridPlacement(childContainer, 1);
    KText text = _kContainerRenderingExtensions.addText(childContainer, mode.getName());
    DiagramSyntheses.suppressSelectability(text);
    _linguaFrancaStyleExtensions.underlineSelectionStyle(text);
    return figure;
}
Also used : KText(de.cau.cs.kieler.klighd.krendering.KText) SizeConstraint(org.eclipse.elk.core.options.SizeConstraint) LayerConstraint(org.eclipse.elk.alg.layered.options.LayerConstraint) KRectangle(de.cau.cs.kieler.klighd.krendering.KRectangle)

Example 17 with KText

use of de.cau.cs.kieler.klighd.krendering.KText in project lingua-franca by lf-lang.

the class LinguaFrancaStyleExtensions method applyOnEdgeDelayStyle.

public void applyOnEdgeDelayStyle(KLabel label) {
    if (_onEdgeDelayLabelConfigurator == null) {
        LabelDecorationConfigurator configurator = LabelDecorationConfigurator.create().withInlineLabels(true);
        configurator = configurator.withLabelTextRenderingProvider((KContainerRendering container, KLabel klabel) -> {
            KText kText = _kRenderingFactory.createKText();
            _kRenderingExtensions.setFontSize(kText, 8);
            boldTextSelectionStyle(kText);
            kText.setProperty(KlighdInternalProperties.MODEL_ELEMEMT, klabel.getProperty(KlighdInternalProperties.MODEL_ELEMEMT));
            container.getChildren().add(kText);
            return kText;
        });
        configurator = configurator.addDecoratorRenderingProvider(new IDecoratorRenderingProvider() {

            @Override
            public ElkPadding createDecoratorRendering(KContainerRendering container, KLabel label, LabelDecorationConfigurator.LayoutMode layoutMode) {
                ElkPadding padding = new ElkPadding();
                padding.left = 2;
                padding.right = 2;
                padding.bottom = Math.max(padding.bottom, 1);
                KPolygon polygon = _kRenderingFactory.createKPolygon();
                _kRenderingExtensions.from(polygon, LEFT, (-2), 0, BOTTOM, 0, 0);
                _kRenderingExtensions.to(polygon, LEFT, 2, 0, TOP, 0, 0);
                _kRenderingExtensions.to(polygon, RIGHT, (-2), 0, TOP, 0, 0);
                _kRenderingExtensions.to(polygon, RIGHT, 2, 0, BOTTOM, 0, 0);
                _kRenderingExtensions.setBackground(polygon, Colors.WHITE);
                _kRenderingExtensions.setForeground(polygon, Colors.WHITE);
                container.getChildren().add(polygon);
                KPolyline polyline = _kRenderingFactory.createKPolyline();
                _kRenderingExtensions.from(polyline, LEFT, (-2), 0, BOTTOM, 0, 0);
                _kRenderingExtensions.to(polyline, LEFT, 2, 0, TOP, 0, 0);
                container.getChildren().add(polyline);
                polyline = _kRenderingFactory.createKPolyline();
                _kRenderingExtensions.from(polyline, RIGHT, 2, 0, BOTTOM, 0, 0);
                _kRenderingExtensions.to(polyline, RIGHT, (-2), 0, TOP, 0, 0);
                container.getChildren().add(polyline);
                return padding;
            }
        });
        _onEdgeDelayLabelConfigurator = configurator;
    }
    _onEdgeDelayLabelConfigurator.applyTo(label);
}
Also used : KText(de.cau.cs.kieler.klighd.krendering.KText) KPolygon(de.cau.cs.kieler.klighd.krendering.KPolygon) KLabel(de.cau.cs.kieler.klighd.kgraph.KLabel) LabelDecorationConfigurator(de.cau.cs.kieler.klighd.labels.decoration.LabelDecorationConfigurator) KContainerRendering(de.cau.cs.kieler.klighd.krendering.KContainerRendering) IDecoratorRenderingProvider(de.cau.cs.kieler.klighd.labels.decoration.IDecoratorRenderingProvider) ElkPadding(org.eclipse.elk.core.math.ElkPadding) KPolyline(de.cau.cs.kieler.klighd.krendering.KPolyline)

Example 18 with KText

use of de.cau.cs.kieler.klighd.krendering.KText in project lingua-franca by lf-lang.

the class LinguaFrancaStyleExtensions method applyOnEdgeStyle.

public void applyOnEdgeStyle(KLabel label) {
    if (_onEdgeLabelConfigurator == null) {
        LabelDecorationConfigurator configurator = LabelDecorationConfigurator.create().withInlineLabels(true);
        _onEdgeLabelConfigurator = configurator.withLabelTextRenderingProvider((KContainerRendering container, KLabel klabel) -> {
            KText kText = _kRenderingFactory.createKText();
            _kRenderingExtensions.setFontSize(kText, 9);
            container.getChildren().add(kText);
            return kText;
        });
    }
    _onEdgeLabelConfigurator.applyTo(label);
}
Also used : KText(de.cau.cs.kieler.klighd.krendering.KText) KLabel(de.cau.cs.kieler.klighd.kgraph.KLabel) LabelDecorationConfigurator(de.cau.cs.kieler.klighd.labels.decoration.LabelDecorationConfigurator) KContainerRendering(de.cau.cs.kieler.klighd.krendering.KContainerRendering)

Example 19 with KText

use of de.cau.cs.kieler.klighd.krendering.KText in project lingua-franca by lf-lang.

the class LinguaFrancaSynthesis method addParameterList.

private void addParameterList(KContainerRendering container, List<ParameterInstance> parameters) {
    int cols = 1;
    try {
        cols = getIntValue(REACTOR_PARAMETER_TABLE_COLS);
    }// ignore
     catch (Exception e) {
    }
    if (cols > parameters.size()) {
        cols = parameters.size();
    }
    _kContainerRenderingExtensions.setGridPlacement(container, cols);
    for (ParameterInstance param : parameters) {
        KText paramText = _kContainerRenderingExtensions.addText(container, createParameterLabel(param, true));
        _kRenderingExtensions.setFontSize(paramText, 8);
        _kRenderingExtensions.setHorizontalAlignment(paramText, HorizontalAlignment.LEFT);
    }
}
Also used : ParameterInstance(org.lflang.generator.ParameterInstance) KText(de.cau.cs.kieler.klighd.krendering.KText) SizeConstraint(org.eclipse.elk.core.options.SizeConstraint) LayerConstraint(org.eclipse.elk.alg.layered.options.LayerConstraint)

Aggregations

KText (de.cau.cs.kieler.klighd.krendering.KText)19 KContainerRendering (de.cau.cs.kieler.klighd.krendering.KContainerRendering)8 KRectangle (de.cau.cs.kieler.klighd.krendering.KRectangle)8 KPolygon (de.cau.cs.kieler.klighd.krendering.KPolygon)7 KPolyline (de.cau.cs.kieler.klighd.krendering.KPolyline)7 KLabel (de.cau.cs.kieler.klighd.kgraph.KLabel)6 KRoundedRectangle (de.cau.cs.kieler.klighd.krendering.KRoundedRectangle)6 ElkPadding (org.eclipse.elk.core.math.ElkPadding)6 KEdge (de.cau.cs.kieler.klighd.kgraph.KEdge)5 KNode (de.cau.cs.kieler.klighd.kgraph.KNode)5 KRendering (de.cau.cs.kieler.klighd.krendering.KRendering)5 KPort (de.cau.cs.kieler.klighd.kgraph.KPort)4 LayerConstraint (org.eclipse.elk.alg.layered.options.LayerConstraint)4 SizeConstraint (org.eclipse.elk.core.options.SizeConstraint)4 Pair (org.eclipse.xtext.xbase.lib.Pair)4 Iterables (com.google.common.collect.Iterables)3 Colors (de.cau.cs.kieler.klighd.krendering.Colors)3 HorizontalAlignment (de.cau.cs.kieler.klighd.krendering.HorizontalAlignment)3 KPosition (de.cau.cs.kieler.klighd.krendering.KPosition)3 LineStyle (de.cau.cs.kieler.klighd.krendering.LineStyle)3