Search in sources :

Example 6 with KContainerRendering

use of de.cau.cs.kieler.klighd.krendering.KContainerRendering 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 7 with KContainerRendering

use of de.cau.cs.kieler.klighd.krendering.KContainerRendering 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 8 with KContainerRendering

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

the class LinguaFrancaStyleExtensions method addCloudUploadIcon.

public KRendering addCloudUploadIcon(KContainerRendering parent) {
    KContainerRendering cloudIcon = addCloudIcon(parent);
    KPolygon cloudPolygon = _kContainerRenderingExtensions.addPolygon(cloudIcon);
    _kRenderingExtensions.setBackground(cloudPolygon, Colors.WHITE);
    _kRenderingExtensions.setForeground(cloudPolygon, Colors.WHITE);
    cloudPolygon.getPoints().addAll(List.of(_kRenderingExtensions.createKPosition(LEFT, -1.5f, 0.5f, TOP, CLOUD_WIDTH / 3, 0.5f), _kRenderingExtensions.createKPosition(LEFT, -1.5f, 0.5f, TOP, 0, 0.58f), _kRenderingExtensions.createKPosition(LEFT, (-4), 0.5f, TOP, 0, 0.58f), _kRenderingExtensions.createKPosition(LEFT, 0, 0.5f, TOP, 0, 0.35f), _kRenderingExtensions.createKPosition(LEFT, 4, 0.5f, TOP, 0, 0.58f), _kRenderingExtensions.createKPosition(LEFT, 1.5f, 0.5f, TOP, 0, 0.58f), _kRenderingExtensions.createKPosition(LEFT, 1.5f, 0.5f, TOP, CLOUD_WIDTH / 3, 0.5f)));
    return cloudIcon;
}
Also used : KPolygon(de.cau.cs.kieler.klighd.krendering.KPolygon) KContainerRendering(de.cau.cs.kieler.klighd.krendering.KContainerRendering)

Aggregations

KContainerRendering (de.cau.cs.kieler.klighd.krendering.KContainerRendering)8 KText (de.cau.cs.kieler.klighd.krendering.KText)6 KPolygon (de.cau.cs.kieler.klighd.krendering.KPolygon)5 KLabel (de.cau.cs.kieler.klighd.kgraph.KLabel)4 KPolyline (de.cau.cs.kieler.klighd.krendering.KPolyline)4 LabelDecorationConfigurator (de.cau.cs.kieler.klighd.labels.decoration.LabelDecorationConfigurator)4 KRectangle (de.cau.cs.kieler.klighd.krendering.KRectangle)3 IDecoratorRenderingProvider (de.cau.cs.kieler.klighd.labels.decoration.IDecoratorRenderingProvider)3 ElkPadding (org.eclipse.elk.core.math.ElkPadding)3 KEdge (de.cau.cs.kieler.klighd.kgraph.KEdge)2 KNode (de.cau.cs.kieler.klighd.kgraph.KNode)2 KPort (de.cau.cs.kieler.klighd.kgraph.KPort)2 KRendering (de.cau.cs.kieler.klighd.krendering.KRendering)2 KRenderingFactory (de.cau.cs.kieler.klighd.krendering.KRenderingFactory)2 KSpline (de.cau.cs.kieler.klighd.krendering.KSpline)2 LineStyle (de.cau.cs.kieler.klighd.krendering.LineStyle)2 ViewSynthesisShared (de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared)2 KContainerRenderingExtensions (de.cau.cs.kieler.klighd.krendering.extensions.KContainerRenderingExtensions)2 KEdgeExtensions (de.cau.cs.kieler.klighd.krendering.extensions.KEdgeExtensions)2 KRenderingExtensions (de.cau.cs.kieler.klighd.krendering.extensions.KRenderingExtensions)2