Search in sources :

Example 1 with Spacing

use of org.eclipse.elk.core.math.Spacing in project lingua-franca by lf-lang.

the class InterfaceDependenciesVisualization method addInterfaceDependencies.

/**
 * Adds interface dependencies to the node if this option is active.
 * Visibility will be adjusted based on expansion state.
 */
public Spacing addInterfaceDependencies(KNode node, boolean expanded) {
    Spacing marginInit = null;
    if (getBooleanValue(SHOW_INTERFACE_DEPENDENCIES)) {
        List<Pair<KPort, KPort>> deps = getPortDependencies(node);
        if (!deps.isEmpty()) {
            for (Pair<KPort, KPort> pair : deps) {
                createDependencyEdge(pair, expanded);
            }
            // Fix content (label) of collapsed rendering
            KContainerRendering contentContainer = IterableExtensions.findFirst(Iterables.filter(node.getData(), KContainerRendering.class), it -> {
                return it.getProperty(KlighdProperties.COLLAPSED_RENDERING);
            });
            if (contentContainer != null) {
                if (!contentContainer.getProperty(LinguaFrancaShapeExtensions.REACTOR_CONTENT_CONTAINER)) {
                    contentContainer = IteratorExtensions.findFirst(Iterators.filter(contentContainer.eAllContents(), KContainerRendering.class), it -> {
                        return it.getProperty(LinguaFrancaShapeExtensions.REACTOR_CONTENT_CONTAINER);
                    });
                }
                if (contentContainer != null) {
                    List<KRendering> content = ImmutableList.copyOf(contentContainer.getChildren());
                    // Put into two new containers such that they are not centered/maximized
                    KRectangle firstContainer = _kContainerRenderingExtensions.addRectangle(contentContainer);
                    _kRenderingExtensions.setInvisible(firstContainer, true);
                    KRectangle secondContainer = _kContainerRenderingExtensions.addRectangle(firstContainer);
                    _kRenderingExtensions.setInvisible(secondContainer, true);
                    _kContainerRenderingExtensions.setGridPlacement(secondContainer, 1);
                    Iterables.addAll(secondContainer.getChildren(), content);
                    _kRenderingExtensions.setPointPlacementData(secondContainer, _kRenderingExtensions.LEFT, 0, 0.5f, _kRenderingExtensions.TOP, 0, 0, _kRenderingExtensions.H_CENTRAL, _kRenderingExtensions.V_TOP, 0, 0, 0, 0);
                    // Adjust ports separate dependency edges from label/content
                    if (content.size() > 0) {
                        marginInit = _utilityExtensions.getPortMarginsInitIfAbsent(node).add(new ElkMargin((content.size() * 20) - 8, 0, 0, 0));
                    }
                }
            }
        }
    }
    return marginInit;
}
Also used : CoreOptions(org.eclipse.elk.core.options.CoreOptions) Iterables(com.google.common.collect.Iterables) ElkMargin(org.eclipse.elk.core.math.ElkMargin) Spacing(org.eclipse.elk.core.math.Spacing) LinguaFrancaStyleExtensions(org.lflang.diagram.synthesis.styles.LinguaFrancaStyleExtensions) Inject(com.google.inject.Inject) Random(java.util.Random) Extension(org.eclipse.xtext.xbase.lib.Extension) AbstractSynthesisExtensions(org.lflang.diagram.synthesis.AbstractSynthesisExtensions) Iterators(com.google.common.collect.Iterators) KEdgeExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KEdgeExtensions) KContainerRenderingExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KContainerRenderingExtensions) KRenderingExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KRenderingExtensions) KPolyline(de.cau.cs.kieler.klighd.krendering.KPolyline) LineStyle(de.cau.cs.kieler.klighd.krendering.LineStyle) ImmutableList(com.google.common.collect.ImmutableList) KRendering(de.cau.cs.kieler.klighd.krendering.KRendering) LinguaFrancaSynthesis(org.lflang.diagram.synthesis.LinguaFrancaSynthesis) DiagramSyntheses(de.cau.cs.kieler.klighd.syntheses.DiagramSyntheses) KEdge(de.cau.cs.kieler.klighd.kgraph.KEdge) KNode(de.cau.cs.kieler.klighd.kgraph.KNode) KPort(de.cau.cs.kieler.klighd.kgraph.KPort) KInvisibility(de.cau.cs.kieler.klighd.krendering.KInvisibility) SynthesisOption(de.cau.cs.kieler.klighd.SynthesisOption) Property(org.eclipse.elk.graph.properties.Property) KRenderingFactory(de.cau.cs.kieler.klighd.krendering.KRenderingFactory) Set(java.util.Set) KContainerRendering(de.cau.cs.kieler.klighd.krendering.KContainerRendering) LinguaFrancaShapeExtensions(org.lflang.diagram.synthesis.styles.LinguaFrancaShapeExtensions) Sets(com.google.common.collect.Sets) IteratorExtensions(org.eclipse.xtext.xbase.lib.IteratorExtensions) List(java.util.List) IterableExtensions(org.eclipse.xtext.xbase.lib.IterableExtensions) KlighdProperties(de.cau.cs.kieler.klighd.util.KlighdProperties) ViewSynthesisShared(de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared) KRectangle(de.cau.cs.kieler.klighd.krendering.KRectangle) Pair(org.eclipse.xtext.xbase.lib.Pair) Spacing(org.eclipse.elk.core.math.Spacing) KPort(de.cau.cs.kieler.klighd.kgraph.KPort) KContainerRendering(de.cau.cs.kieler.klighd.krendering.KContainerRendering) KRendering(de.cau.cs.kieler.klighd.krendering.KRendering) Pair(org.eclipse.xtext.xbase.lib.Pair) KRectangle(de.cau.cs.kieler.klighd.krendering.KRectangle) ElkMargin(org.eclipse.elk.core.math.ElkMargin)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 Iterables (com.google.common.collect.Iterables)1 Iterators (com.google.common.collect.Iterators)1 Sets (com.google.common.collect.Sets)1 Inject (com.google.inject.Inject)1 SynthesisOption (de.cau.cs.kieler.klighd.SynthesisOption)1 KEdge (de.cau.cs.kieler.klighd.kgraph.KEdge)1 KNode (de.cau.cs.kieler.klighd.kgraph.KNode)1 KPort (de.cau.cs.kieler.klighd.kgraph.KPort)1 KContainerRendering (de.cau.cs.kieler.klighd.krendering.KContainerRendering)1 KInvisibility (de.cau.cs.kieler.klighd.krendering.KInvisibility)1 KPolyline (de.cau.cs.kieler.klighd.krendering.KPolyline)1 KRectangle (de.cau.cs.kieler.klighd.krendering.KRectangle)1 KRendering (de.cau.cs.kieler.klighd.krendering.KRendering)1 KRenderingFactory (de.cau.cs.kieler.klighd.krendering.KRenderingFactory)1 LineStyle (de.cau.cs.kieler.klighd.krendering.LineStyle)1 ViewSynthesisShared (de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared)1 KContainerRenderingExtensions (de.cau.cs.kieler.klighd.krendering.extensions.KContainerRenderingExtensions)1 KEdgeExtensions (de.cau.cs.kieler.klighd.krendering.extensions.KEdgeExtensions)1 KRenderingExtensions (de.cau.cs.kieler.klighd.krendering.extensions.KRenderingExtensions)1