Search in sources :

Example 1 with KSpline

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

the class LinguaFrancaStyleExtensions method applyOnEdgePysicalDelayStyle.

public void applyOnEdgePysicalDelayStyle(KLabel label, Colors parentBackgroundColor) {
    if (_onEdgePysicalDelayLabelConfigurator == 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 = 8;
                padding.right = 16;
                padding.bottom = Math.max(padding.bottom, 1);
                KPolygon polygon = _kRenderingFactory.createKPolygon();
                _kRenderingExtensions.from(polygon, LEFT, 0, 0, BOTTOM, 0, 0.5f);
                _kRenderingExtensions.to(polygon, LEFT, 0, 0, TOP, 1, 0.5f);
                _kRenderingExtensions.to(polygon, RIGHT, 0, 0, TOP, 1, 0.5f);
                _kRenderingExtensions.to(polygon, RIGHT, 0, 0, BOTTOM, 0, 0.5f);
                _kRenderingExtensions.setBackground(polygon, label.getProperty(LABEL_PARENT_BACKGROUND));
                _kRenderingExtensions.setForeground(polygon, label.getProperty(LABEL_PARENT_BACKGROUND));
                container.getChildren().add(polygon);
                KSpline kSpline = _kRenderingFactory.createKSpline();
                _kRenderingExtensions.from(kSpline, LEFT, -0.66f, 0, BOTTOM, -0.5f, 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 1, 0, BOTTOM, -0.5f, 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 3, 0, BOTTOM, 8, 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 5, 0, BOTTOM, 0, 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 5.5f, 0, BOTTOM, -1.5f, 0.5f);
                container.getChildren().add(kSpline);
                kSpline = _kRenderingFactory.createKSpline();
                _kRenderingExtensions.from(kSpline, RIGHT, 15f, 0, BOTTOM, 3.5f, 0.5f);
                _kRenderingExtensions.to(kSpline, RIGHT, 14f, 0, BOTTOM, 0, 0.5f);
                _kRenderingExtensions.to(kSpline, RIGHT, 11, 0, BOTTOM, -8, 0.5f);
                _kRenderingExtensions.to(kSpline, RIGHT, 9, 0, BOTTOM, 0, 0.5f);
                _kRenderingExtensions.to(kSpline, RIGHT, 7, 0, BOTTOM, 8, 0.5f);
                _kRenderingExtensions.to(kSpline, RIGHT, 4f, 0, BOTTOM, 2, 0.5f);
                _kRenderingExtensions.to(kSpline, RIGHT, 1.5f, 0, BOTTOM, 0.5f, 0.5f);
                _kRenderingExtensions.to(kSpline, RIGHT, 0.2f, 0, BOTTOM, -0.5f, 0.5f);
                _kRenderingExtensions.to(kSpline, RIGHT, -0.7f, 0, BOTTOM, -0.5f, 0.5f);
                container.getChildren().add(kSpline);
                polygon = _kRenderingFactory.createKPolygon();
                _kRenderingExtensions.from(polygon, LEFT, 4, 0, BOTTOM, 0, 0);
                _kRenderingExtensions.to(polygon, LEFT, 8, 0, TOP, 0, 0);
                _kRenderingExtensions.to(polygon, RIGHT, 12, 0, TOP, 0, 0);
                _kRenderingExtensions.to(polygon, RIGHT, 16, 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, 4, 0, BOTTOM, 0, 0);
                _kRenderingExtensions.to(polyline, LEFT, 8, 0, TOP, 0, 0);
                container.getChildren().add(polyline);
                polyline = _kRenderingFactory.createKPolyline();
                _kRenderingExtensions.from(polyline, RIGHT, 16, 0, BOTTOM, 0, 0);
                _kRenderingExtensions.to(polyline, RIGHT, 12, 0, TOP, 0, 0);
                container.getChildren().add(polyline);
                return padding;
            }
        });
        _onEdgePysicalDelayLabelConfigurator = configurator;
    }
    label.setProperty(LABEL_PARENT_BACKGROUND, parentBackgroundColor);
    _onEdgePysicalDelayLabelConfigurator.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) KSpline(de.cau.cs.kieler.klighd.krendering.KSpline) KPolyline(de.cau.cs.kieler.klighd.krendering.KPolyline)

Example 2 with KSpline

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

the class LinguaFrancaStyleExtensions method applyOnEdgePysicalStyle.

public void applyOnEdgePysicalStyle(KLabel label, Colors parentBackgroundColor) {
    if (_onEdgePysicalLabelConfigurator == null) {
        LabelDecorationConfigurator configurator = LabelDecorationConfigurator.create().withInlineLabels(true);
        configurator = configurator.withLabelTextRenderingProvider((KContainerRendering container, KLabel klabel) -> {
            KText kText = _kRenderingFactory.createKText();
            _kRenderingExtensions.setInvisible(kText, true);
            container.getChildren().add(kText);
            return kText;
        });
        configurator = configurator.addDecoratorRenderingProvider(new IDecoratorRenderingProvider() {

            @Override
            public ElkPadding createDecoratorRendering(final KContainerRendering container, final KLabel label, final LabelDecorationConfigurator.LayoutMode layoutMode) {
                ElkPadding padding = new ElkPadding();
                padding.left = 3;
                padding.right = 3;
                padding.bottom = Math.max(padding.bottom, 1);
                KPolygon polygon = _kRenderingFactory.createKPolygon();
                _kRenderingExtensions.from(polygon, LEFT, 0, 0, BOTTOM, 0, 0.5f);
                _kRenderingExtensions.to(polygon, LEFT, 0, 0, TOP, 1, 0.5f);
                _kRenderingExtensions.to(polygon, RIGHT, 0, 0, TOP, 1, 0.5f);
                _kRenderingExtensions.to(polygon, RIGHT, 0, 0, BOTTOM, 0, 0.5f);
                _kRenderingExtensions.setBackground(polygon, label.getProperty(LABEL_PARENT_BACKGROUND));
                _kRenderingExtensions.setForeground(polygon, label.getProperty(LABEL_PARENT_BACKGROUND));
                container.getChildren().add(polygon);
                KSpline kSpline = _kRenderingFactory.createKSpline();
                _kRenderingExtensions.from(kSpline, LEFT, (-0.66f), 0, BOTTOM, (-0.5f), 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 1, 0, BOTTOM, (-0.5f), 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 0, 0.1f, BOTTOM, 8, 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 0, 0.2f, BOTTOM, 0, 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 0, 0.3f, BOTTOM, (-8), 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 0, 0.4f, BOTTOM, 0, 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 0, 0.45f, BOTTOM, 4f, 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 0, 0.5f, BOTTOM, 8, 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 0, 0.55f, BOTTOM, 4f, 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 0, 0.6f, BOTTOM, 0, 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 0, 0.65f, BOTTOM, (-4), 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 0, 0.7f, BOTTOM, (-8), 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 0, 0.8f, BOTTOM, (-4), 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 0, 0.9f, BOTTOM, 0, 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, (-1), 1, BOTTOM, (-0.5f), 0.5f);
                _kRenderingExtensions.to(kSpline, LEFT, 0.66f, 1, BOTTOM, (-0.5f), 0.5f);
                container.getChildren().add(kSpline);
                return padding;
            }
        });
        _onEdgePysicalLabelConfigurator = configurator;
    }
    label.setProperty(LABEL_PARENT_BACKGROUND, parentBackgroundColor);
    _onEdgePysicalLabelConfigurator.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) KSpline(de.cau.cs.kieler.klighd.krendering.KSpline)

Aggregations

KLabel (de.cau.cs.kieler.klighd.kgraph.KLabel)2 KContainerRendering (de.cau.cs.kieler.klighd.krendering.KContainerRendering)2 KPolygon (de.cau.cs.kieler.klighd.krendering.KPolygon)2 KSpline (de.cau.cs.kieler.klighd.krendering.KSpline)2 KText (de.cau.cs.kieler.klighd.krendering.KText)2 IDecoratorRenderingProvider (de.cau.cs.kieler.klighd.labels.decoration.IDecoratorRenderingProvider)2 LabelDecorationConfigurator (de.cau.cs.kieler.klighd.labels.decoration.LabelDecorationConfigurator)2 ElkPadding (org.eclipse.elk.core.math.ElkPadding)2 KPolyline (de.cau.cs.kieler.klighd.krendering.KPolyline)1