Search in sources :

Example 1 with KRoundedRectangle

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

the class LinguaFrancaShapeExtensions method addErrorMessage.

/**
 * Creates and adds an error message figure
 */
public KRectangle addErrorMessage(KNode node, String title, String message) {
    // Create figure for error message
    KRectangle figure = _kRenderingExtensions.addRectangle(node);
    _kRenderingExtensions.setInvisible(figure, true);
    // Add error message box
    KRoundedRectangle errMsgBox = _kContainerRenderingExtensions.addRoundedRectangle(figure, 7, 7);
    _kContainerRenderingExtensions.setGridPlacement(errMsgBox, 1);
    _kRenderingExtensions.setLineWidth(errMsgBox, 2);
    _linguaFrancaStyleExtensions.noSelectionStyle(errMsgBox);
    if (title != null) {
        // Add title to error message box
        KText titleText = _kContainerRenderingExtensions.addText(errMsgBox, title);
        _kRenderingExtensions.setFontSize(titleText, 12);
        _kRenderingExtensions.setFontBold(titleText, true);
        _kRenderingExtensions.setForeground(titleText, Colors.RED);
        setGridPlacementDataFromPointToPoint(titleText, _kRenderingExtensions.LEFT, 8, 0, _kRenderingExtensions.TOP, 8, 0, _kRenderingExtensions.RIGHT, 8, 0, _kRenderingExtensions.BOTTOM, 4, 0);
        DiagramSyntheses.suppressSelectability(titleText);
        _linguaFrancaStyleExtensions.noSelectionStyle(titleText);
    }
    if (message != null) {
        // Add message to error message box
        KText msgText = _kContainerRenderingExtensions.addText(errMsgBox, message);
        if (title != null) {
            setGridPlacementDataFromPointToPoint(msgText, _kRenderingExtensions.LEFT, 8, 0, _kRenderingExtensions.TOP, 0, 0, _kRenderingExtensions.RIGHT, 8, 0, _kRenderingExtensions.BOTTOM, 4, 0);
        } else {
            setGridPlacementDataFromPointToPoint(msgText, _kRenderingExtensions.LEFT, 8, 0, _kRenderingExtensions.TOP, 8, 0, _kRenderingExtensions.RIGHT, 8, 0, _kRenderingExtensions.BOTTOM, 8, 0);
        }
        _linguaFrancaStyleExtensions.noSelectionStyle(msgText);
    }
    return figure;
}
Also used : KText(de.cau.cs.kieler.klighd.krendering.KText) KRoundedRectangle(de.cau.cs.kieler.klighd.krendering.KRoundedRectangle) KRectangle(de.cau.cs.kieler.klighd.krendering.KRectangle)

Example 2 with KRoundedRectangle

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

the class LinguaFrancaShapeExtensions method addCommentFigure.

public KRoundedRectangle addCommentFigure(KNode node, String message) {
    // Create rectangle for comment figure
    KRoundedRectangle commentFigure = _kRenderingExtensions.addRoundedRectangle(node, 1, 1, 1);
    _kContainerRenderingExtensions.setGridPlacement(commentFigure, 1);
    // Add message
    KText text = _kContainerRenderingExtensions.addText(commentFigure, message);
    _kRenderingExtensions.setFontSize(text, 6);
    setGridPlacementDataFromPointToPoint(text, _kRenderingExtensions.LEFT, 3, 0, _kRenderingExtensions.TOP, 3, 0, _kRenderingExtensions.RIGHT, 3, 0, _kRenderingExtensions.BOTTOM, 3, 0);
    _linguaFrancaStyleExtensions.noSelectionStyle(text);
    return commentFigure;
}
Also used : KText(de.cau.cs.kieler.klighd.krendering.KText) KRoundedRectangle(de.cau.cs.kieler.klighd.krendering.KRoundedRectangle)

Example 3 with KRoundedRectangle

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

the class LinguaFrancaShapeExtensions method addReactorFigure.

/**
 * Creates the visual representation of a reactor node
 */
public ReactorFigureComponents addReactorFigure(KNode node, ReactorInstance reactorInstance, String text) {
    int padding = getBooleanValue(LinguaFrancaSynthesis.SHOW_HYPERLINKS) ? 8 : 6;
    Function1<KRoundedRectangle, KRendering> style = r -> {
        _kRenderingExtensions.setLineWidth(r, 1);
        _kRenderingExtensions.setForeground(r, Colors.GRAY);
        _kRenderingExtensions.setBackground(r, Colors.GRAY_95);
        return _linguaFrancaStyleExtensions.boldLineSelectionStyle(r);
    };
    KRoundedRectangle figure = _kRenderingExtensions.addRoundedRectangle(node, 8, 8, 1);
    _kContainerRenderingExtensions.setGridPlacement(figure, 1);
    style.apply(figure);
    figure.setProperty(REACTOR_CONTENT_CONTAINER, true);
    // minimal node size is necessary if no text will be added
    List<Float> minSize = List.of(2 * figure.getCornerWidth(), 2 * figure.getCornerHeight());
    _kNodeExtensions.setMinimalNodeSize(node, minSize.get(0), minSize.get(1));
    // Add parent container
    KRectangle parentContainer = _kContainerRenderingExtensions.addRectangle(figure);
    _kRenderingExtensions.setInvisible(parentContainer, true);
    setGridPlacementDataFromPointToPoint(parentContainer, LEFT, padding, 0, TOP, padding, 0, RIGHT, padding, 0, BOTTOM, _utilityExtensions.hasContent(reactorInstance) ? 4 : padding, 0);
    // Add centered child container
    KRectangle childContainer = _kContainerRenderingExtensions.addRectangle(parentContainer);
    _kRenderingExtensions.setInvisible(childContainer, true);
    _kRenderingExtensions.setPointPlacementData(childContainer, _kRenderingExtensions.LEFT, 0, 0.5f, _kRenderingExtensions.TOP, 0, 0.5f, _kRenderingExtensions.H_CENTRAL, _kRenderingExtensions.V_CENTRAL, 0, 0, 0, 0);
    KGridPlacement placement = _kContainerRenderingExtensions.setGridPlacement(childContainer, 1);
    KText childText = _kContainerRenderingExtensions.addText(childContainer, text);
    DiagramSyntheses.suppressSelectability(childText);
    _linguaFrancaStyleExtensions.underlineSelectionStyle(childText);
    if (!_utilityExtensions.isRoot(reactorInstance) && reactorInstance.getDefinition().getHost() != null) {
        KRendering cloudUploadIcon = _linguaFrancaStyleExtensions.addCloudUploadIcon(childContainer);
        setGridPlacementDataFromPointToPoint(cloudUploadIcon, LEFT, 3, 0, TOP, 0, 0, RIGHT, 0, 0, BOTTOM, 0, 0);
        placement.setNumColumns(2);
        if (getBooleanValue(LinguaFrancaSynthesis.SHOW_REACTOR_HOST)) {
            KText reactorHostText = _kContainerRenderingExtensions.addText(childContainer, _utilityExtensions.toText(reactorInstance.getDefinition().getHost()));
            DiagramSyntheses.suppressSelectability(reactorHostText);
            _linguaFrancaStyleExtensions.underlineSelectionStyle(reactorHostText);
            setGridPlacementDataFromPointToPoint(reactorHostText, LEFT, 3, 0, TOP, 0, 0, RIGHT, 0, 0, BOTTOM, 0, 0);
            placement.setNumColumns(3);
        }
    }
    if (reactorInstance.isBank()) {
        List<KRendering> bank = new ArrayList<>();
        KContainerRendering container = _kRenderingExtensions.addInvisibleContainerRendering(node);
        // TODO handle unresolved width
        KRoundedRectangle banks;
        banks = _kContainerRenderingExtensions.addRoundedRectangle(container, 8, 8, 1);
        style.apply(banks);
        setGridPlacementDataFromPointToPoint(banks, LEFT, BANK_FIGURE_X_OFFSET_SUM, 0, TOP, BANK_FIGURE_Y_OFFSET_SUM, 0, RIGHT, 0, 0, BOTTOM, 0, 0);
        if (reactorInstance.getWidth() == 3) {
            banks = _kContainerRenderingExtensions.addRoundedRectangle(container, 8, 8, 1);
            style.apply(banks);
            setGridPlacementDataFromPointToPoint(banks, LEFT, BANK_FIGURE_X_OFFSET_SUM / 2, 0, TOP, BANK_FIGURE_Y_OFFSET_SUM / 2, 0, RIGHT, BANK_FIGURE_X_OFFSET_SUM / 2, 0, BOTTOM, BANK_FIGURE_Y_OFFSET_SUM / 2, 0);
        } else if (reactorInstance.getWidth() != 2 && reactorInstance.getWidth() != 3) {
            banks = _kContainerRenderingExtensions.addRoundedRectangle(container, 8, 8, 1);
            style.apply(banks);
            setGridPlacementDataFromPointToPoint(banks, LEFT, 2 * BANK_FIGURE_X_OFFSET_SUM / 3, 0, TOP, 2 * BANK_FIGURE_Y_OFFSET_SUM / 3, 0, RIGHT, BANK_FIGURE_X_OFFSET_SUM / 3, 0, BOTTOM, BANK_FIGURE_Y_OFFSET_SUM / 3, 0);
            banks = _kContainerRenderingExtensions.addRoundedRectangle(container, 8, 8, 1);
            style.apply(banks);
            setGridPlacementDataFromPointToPoint(banks, LEFT, BANK_FIGURE_X_OFFSET_SUM / 3, 0, TOP, BANK_FIGURE_Y_OFFSET_SUM / 3, 0, RIGHT, 2 * BANK_FIGURE_X_OFFSET_SUM / 3, 0, BOTTOM, 2 * BANK_FIGURE_Y_OFFSET_SUM / 3, 0);
        }
        container.getChildren().add(figure);
        setGridPlacementDataFromPointToPoint(figure, LEFT, 0, 0, TOP, 0, 0, RIGHT, BANK_FIGURE_X_OFFSET_SUM, 0, BOTTOM, BANK_FIGURE_Y_OFFSET_SUM, 0);
        bank.addAll(container.getChildren());
        KRectangle widthLabelContainer = _kContainerRenderingExtensions.addRectangle(container);
        _kRenderingExtensions.setInvisible(widthLabelContainer, true);
        setGridPlacementDataFromPointToPoint(widthLabelContainer, LEFT, 12, 0, BOTTOM, 9, 0, RIGHT, 6, 0, BOTTOM, 0.5f, 0);
        // Handle unresolved width.
        String widthLabel = reactorInstance.getWidth() >= 0 ? Integer.toString(reactorInstance.getWidth()) : "?";
        KText widthLabelText = _kContainerRenderingExtensions.addText(widthLabelContainer, widthLabel);
        _kRenderingExtensions.setHorizontalAlignment(widthLabelText, HorizontalAlignment.LEFT);
        _kRenderingExtensions.setVerticalAlignment(widthLabelText, VerticalAlignment.BOTTOM);
        _kRenderingExtensions.setFontSize(widthLabelText, 6);
        _linguaFrancaStyleExtensions.noSelectionStyle(widthLabelText);
        associateWith(widthLabelText, reactorInstance.getDefinition().getWidthSpec());
        return new ReactorFigureComponents(container, figure, bank);
    } else {
        return new ReactorFigureComponents(figure, figure, List.of(figure));
    }
}
Also used : CoreOptions(org.eclipse.elk.core.options.CoreOptions) KArc(de.cau.cs.kieler.klighd.krendering.KArc) Arc(de.cau.cs.kieler.klighd.krendering.Arc) PortSide(org.eclipse.elk.core.options.PortSide) KLabelExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KLabelExtensions) Extension(org.eclipse.xtext.xbase.lib.Extension) AbstractSynthesisExtensions(org.lflang.diagram.synthesis.AbstractSynthesisExtensions) KEdgeExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KEdgeExtensions) KAreaPlacementData(de.cau.cs.kieler.klighd.krendering.KAreaPlacementData) KContainerRenderingExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KContainerRenderingExtensions) KRenderingExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KRenderingExtensions) KDecoratorPlacementData(de.cau.cs.kieler.klighd.krendering.KDecoratorPlacementData) KPolyline(de.cau.cs.kieler.klighd.krendering.KPolyline) LineStyle(de.cau.cs.kieler.klighd.krendering.LineStyle) VerticalAlignment(de.cau.cs.kieler.klighd.krendering.VerticalAlignment) LinguaFrancaSynthesis(org.lflang.diagram.synthesis.LinguaFrancaSynthesis) PositionReferenceY(de.cau.cs.kieler.klighd.krendering.extensions.PositionReferenceY) PositionReferenceX(de.cau.cs.kieler.klighd.krendering.extensions.PositionReferenceX) DiagramSyntheses(de.cau.cs.kieler.klighd.syntheses.DiagramSyntheses) KPolygon(de.cau.cs.kieler.klighd.krendering.KPolygon) KEdge(de.cau.cs.kieler.klighd.kgraph.KEdge) KPolylineExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KPolylineExtensions) KPortExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KPortExtensions) KEllipse(de.cau.cs.kieler.klighd.krendering.KEllipse) List(java.util.List) UtilityExtensions(org.lflang.diagram.synthesis.util.UtilityExtensions) KColorExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KColorExtensions) Pair(org.eclipse.xtext.xbase.lib.Pair) StringExtensions(org.eclipse.xtext.xbase.lib.StringExtensions) KGridPlacement(de.cau.cs.kieler.klighd.krendering.KGridPlacement) KPosition(de.cau.cs.kieler.klighd.krendering.KPosition) KNodeExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KNodeExtensions) ReactionPortAdjustment(org.lflang.diagram.synthesis.postprocessor.ReactionPortAdjustment) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) KlighdConstants(de.cau.cs.kieler.klighd.KlighdConstants) KRendering(de.cau.cs.kieler.klighd.krendering.KRendering) TimerInstance(org.lflang.generator.TimerInstance) KText(de.cau.cs.kieler.klighd.krendering.KText) KNode(de.cau.cs.kieler.klighd.kgraph.KNode) KPort(de.cau.cs.kieler.klighd.kgraph.KPort) KRoundedRectangle(de.cau.cs.kieler.klighd.krendering.KRoundedRectangle) Property(org.eclipse.elk.graph.properties.Property) KRenderingFactory(de.cau.cs.kieler.klighd.krendering.KRenderingFactory) KContainerRendering(de.cau.cs.kieler.klighd.krendering.KContainerRendering) ReactionInstance(org.lflang.generator.ReactionInstance) ReactorInstance(org.lflang.generator.ReactorInstance) IterableExtensions(org.eclipse.xtext.xbase.lib.IterableExtensions) ViewSynthesisShared(de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared) KRectangle(de.cau.cs.kieler.klighd.krendering.KRectangle) Colors(de.cau.cs.kieler.klighd.krendering.Colors) HorizontalAlignment(de.cau.cs.kieler.klighd.krendering.HorizontalAlignment) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) ArrayList(java.util.ArrayList) KContainerRendering(de.cau.cs.kieler.klighd.krendering.KContainerRendering) KRoundedRectangle(de.cau.cs.kieler.klighd.krendering.KRoundedRectangle) KGridPlacement(de.cau.cs.kieler.klighd.krendering.KGridPlacement) KRectangle(de.cau.cs.kieler.klighd.krendering.KRectangle) KText(de.cau.cs.kieler.klighd.krendering.KText) KRendering(de.cau.cs.kieler.klighd.krendering.KRendering)

Example 4 with KRoundedRectangle

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

the class LinguaFrancaStyleExtensions method addCloudIcon.

public KContainerRendering addCloudIcon(final KContainerRendering parent) {
    KRectangle figure = _kContainerRenderingExtensions.addRectangle(parent);
    _kRenderingExtensions.setInvisible(figure, true);
    KRoundedRectangle roundRectangle = _kContainerRenderingExtensions.addRoundedRectangle(figure, CLOUD_WIDTH / 7, CLOUD_WIDTH / 7);
    _kRenderingExtensions.setBackground(roundRectangle, Colors.GRAY);
    _kRenderingExtensions.setForeground(roundRectangle, Colors.GRAY);
    _kRenderingExtensions.setPointPlacementData(roundRectangle, _kRenderingExtensions.LEFT, 2, 0, _kRenderingExtensions.TOP, 0, 0.5f, _kRenderingExtensions.H_LEFT, _kRenderingExtensions.V_TOP, 0, 0, CLOUD_WIDTH, CLOUD_WIDTH / 3);
    KEllipse childEllipse = _kContainerRenderingExtensions.addEllipse(figure);
    _kRenderingExtensions.setBackground(childEllipse, Colors.GRAY);
    _kRenderingExtensions.setForeground(childEllipse, Colors.GRAY);
    _kRenderingExtensions.setPointPlacementData(childEllipse, _kRenderingExtensions.LEFT, 0, 0f, _kRenderingExtensions.TOP, 0, 0.38f, _kRenderingExtensions.H_LEFT, _kRenderingExtensions.V_TOP, 0, 0, CLOUD_WIDTH / 2.5f, CLOUD_WIDTH / 2.5f);
    childEllipse = _kContainerRenderingExtensions.addEllipse(figure);
    _kRenderingExtensions.setBackground(childEllipse, Colors.GRAY);
    _kRenderingExtensions.setForeground(childEllipse, Colors.GRAY);
    _kRenderingExtensions.setPointPlacementData(childEllipse, _kRenderingExtensions.LEFT, 0, 0.5f, _kRenderingExtensions.TOP, 0, 0.25f, _kRenderingExtensions.H_RIGHT, _kRenderingExtensions.V_TOP, 0, 0, CLOUD_WIDTH / 3f, CLOUD_WIDTH / 3f);
    childEllipse = _kContainerRenderingExtensions.addEllipse(figure);
    _kRenderingExtensions.setBackground(childEllipse, Colors.GRAY);
    _kRenderingExtensions.setForeground(childEllipse, Colors.GRAY);
    _kRenderingExtensions.setPointPlacementData(childEllipse, _kRenderingExtensions.LEFT, 0, 0.4f, _kRenderingExtensions.TOP, CLOUD_WIDTH / 10, 0, _kRenderingExtensions.H_LEFT, _kRenderingExtensions.V_TOP, 0, 0, CLOUD_WIDTH / 2, CLOUD_WIDTH / 2);
    return figure;
}
Also used : KEllipse(de.cau.cs.kieler.klighd.krendering.KEllipse) KRoundedRectangle(de.cau.cs.kieler.klighd.krendering.KRoundedRectangle) KRectangle(de.cau.cs.kieler.klighd.krendering.KRectangle)

Example 5 with KRoundedRectangle

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

the class LinguaFrancaSynthesis method createReactorNode.

private Collection<KNode> createReactorNode(ReactorInstance reactorInstance, boolean expandDefault, Table<ReactorInstance, PortInstance, KPort> inputPortsReg, Table<ReactorInstance, PortInstance, KPort> outputPortsReg, Map<ReactorInstance, KNode> allReactorNodes) {
    Reactor reactor = reactorInstance.reactorDefinition;
    KNode node = _kNodeExtensions.createNode();
    allReactorNodes.put(reactorInstance, node);
    associateWith(node, reactor);
    _utilityExtensions.setID(node, reactorInstance.uniqueID());
    // save to distinguish nodes associated with the same reactor
    NamedInstanceUtil.linkInstance(node, reactorInstance);
    List<KNode> nodes = new ArrayList<>();
    nodes.add(node);
    String label = createReactorLabel(reactorInstance);
    if (reactorInstance.recursive) {
        // Mark this node
        node.setProperty(REACTOR_RECURSIVE_INSTANTIATION, true);
        // Mark root
        allReactorNodes.get(reactorInstance.root()).setProperty(REACTOR_RECURSIVE_INSTANTIATION, true);
    }
    if (reactor == null) {
        _linguaFrancaShapeExtensions.addErrorMessage(node, TEXT_REACTOR_NULL, null);
    } else if (reactorInstance.isMainOrFederated()) {
        KRoundedRectangle figure = _linguaFrancaShapeExtensions.addMainReactorFigure(node, reactorInstance, label);
        if (getObjectValue(REACTOR_PARAMETER_MODE) == ReactorParameterDisplayModes.TABLE && !reactorInstance.parameters.isEmpty()) {
            KRectangle rectangle = _kContainerRenderingExtensions.addRectangle(figure);
            _kRenderingExtensions.setInvisible(rectangle, true);
            _kRenderingExtensions.to(_kRenderingExtensions.from(_kRenderingExtensions.setGridPlacementData(rectangle), _kRenderingExtensions.LEFT, 8, 0, _kRenderingExtensions.TOP, 0, 0), _kRenderingExtensions.RIGHT, 8, 0, _kRenderingExtensions.BOTTOM, 4, 0);
            _kRenderingExtensions.setHorizontalAlignment(rectangle, HorizontalAlignment.LEFT);
            addParameterList(rectangle, reactorInstance.parameters);
        }
        if (reactorInstance.recursive) {
            nodes.add(addErrorComment(node, TEXT_ERROR_RECURSIVE));
            _linguaFrancaStyleExtensions.errorStyle(figure);
        } else {
            _kContainerRenderingExtensions.addChildArea(figure);
            node.getChildren().addAll(transformReactorNetwork(reactorInstance, new HashMap<>(), new HashMap<>(), allReactorNodes));
        }
        Iterables.addAll(nodes, createUserComments(reactor, node));
        configureReactorNodeLayout(node);
        // Additional layout adjustment for main node
        setLayoutOption(node, CoreOptions.ALGORITHM, LayeredOptions.ALGORITHM_ID);
        setLayoutOption(node, CoreOptions.DIRECTION, Direction.RIGHT);
        setLayoutOption(node, CoreOptions.NODE_SIZE_CONSTRAINTS, EnumSet.of(SizeConstraint.MINIMUM_SIZE));
        setLayoutOption(node, LayeredOptions.NODE_PLACEMENT_BK_FIXED_ALIGNMENT, FixedAlignment.BALANCED);
        setLayoutOption(node, LayeredOptions.NODE_PLACEMENT_BK_EDGE_STRAIGHTENING, EdgeStraighteningStrategy.IMPROVE_STRAIGHTNESS);
        setLayoutOption(node, LayeredOptions.SPACING_EDGE_NODE, LayeredOptions.SPACING_EDGE_NODE.getDefault() * 1.1f);
        setLayoutOption(node, LayeredOptions.SPACING_EDGE_NODE_BETWEEN_LAYERS, LayeredOptions.SPACING_EDGE_NODE_BETWEEN_LAYERS.getDefault() * 1.1f);
        if (!getBooleanValue(SHOW_HYPERLINKS)) {
            setLayoutOption(node, CoreOptions.PADDING, new ElkPadding(-1, 6, 6, 6));
            setLayoutOption(node, LayeredOptions.SPACING_COMPONENT_COMPONENT, LayeredOptions.SPACING_COMPONENT_COMPONENT.getDefault() * 0.5f);
        }
    } else {
        ReactorInstance instance = reactorInstance;
        // Expanded Rectangle
        ReactorFigureComponents comps = _linguaFrancaShapeExtensions.addReactorFigure(node, reactorInstance, label);
        comps.getOuter().setProperty(KlighdProperties.EXPANDED_RENDERING, true);
        for (KRendering figure : comps.getFigures()) {
            associateWith(figure, reactor);
            _kRenderingExtensions.addDoubleClickAction(figure, MemorizingExpandCollapseAction.ID);
        }
        _reactorIcons.handleIcon(comps.getReactor(), reactor, false);
        if (getBooleanValue(SHOW_HYPERLINKS)) {
            // Collapse button
            KText button = _linguaFrancaShapeExtensions.addTextButton(comps.getReactor(), TEXT_HIDE_ACTION);
            _kRenderingExtensions.to(_kRenderingExtensions.from(_kRenderingExtensions.setGridPlacementData(button), _kRenderingExtensions.LEFT, 8, 0, _kRenderingExtensions.TOP, 0, 0), _kRenderingExtensions.RIGHT, 8, 0, _kRenderingExtensions.BOTTOM, 0, 0);
            _kRenderingExtensions.addSingleClickAction(button, MemorizingExpandCollapseAction.ID);
            _kRenderingExtensions.addDoubleClickAction(button, MemorizingExpandCollapseAction.ID);
        }
        if (getObjectValue(REACTOR_PARAMETER_MODE) == ReactorParameterDisplayModes.TABLE && !instance.parameters.isEmpty()) {
            KRectangle rectangle = _kContainerRenderingExtensions.addRectangle(comps.getReactor());
            _kRenderingExtensions.setInvisible(rectangle, true);
            if (!getBooleanValue(SHOW_HYPERLINKS)) {
                _kRenderingExtensions.to(_kRenderingExtensions.from(_kRenderingExtensions.setGridPlacementData(rectangle), _kRenderingExtensions.LEFT, 8, 0, _kRenderingExtensions.TOP, 0, 0), _kRenderingExtensions.RIGHT, 8, 0, _kRenderingExtensions.BOTTOM, 4, 0);
            } else {
                _kRenderingExtensions.to(_kRenderingExtensions.from(_kRenderingExtensions.setGridPlacementData(rectangle), _kRenderingExtensions.LEFT, 8, 0, _kRenderingExtensions.TOP, 4, 0), _kRenderingExtensions.RIGHT, 8, 0, _kRenderingExtensions.BOTTOM, 0, 0);
            }
            _kRenderingExtensions.setHorizontalAlignment(rectangle, HorizontalAlignment.LEFT);
            addParameterList(rectangle, instance.parameters);
        }
        if (instance.recursive) {
            comps.getFigures().forEach(_linguaFrancaStyleExtensions::errorStyle);
        } else {
            _kContainerRenderingExtensions.addChildArea(comps.getReactor());
        }
        // Collapse Rectangle
        comps = _linguaFrancaShapeExtensions.addReactorFigure(node, reactorInstance, label);
        comps.getOuter().setProperty(KlighdProperties.COLLAPSED_RENDERING, true);
        for (KRendering figure : comps.getFigures()) {
            associateWith(figure, reactor);
            if (_utilityExtensions.hasContent(instance) && !instance.recursive) {
                _kRenderingExtensions.addDoubleClickAction(figure, MemorizingExpandCollapseAction.ID);
            }
        }
        _reactorIcons.handleIcon(comps.getReactor(), reactor, true);
        if (getBooleanValue(SHOW_HYPERLINKS)) {
            // Expand button
            if (_utilityExtensions.hasContent(instance) && !instance.recursive) {
                KText button = _linguaFrancaShapeExtensions.addTextButton(comps.getReactor(), TEXT_SHOW_ACTION);
                _kRenderingExtensions.to(_kRenderingExtensions.from(_kRenderingExtensions.setGridPlacementData(button), _kRenderingExtensions.LEFT, 8, 0, _kRenderingExtensions.TOP, 0, 0), _kRenderingExtensions.RIGHT, 8, 0, _kRenderingExtensions.BOTTOM, 8, 0);
                _kRenderingExtensions.addSingleClickAction(button, MemorizingExpandCollapseAction.ID);
                _kRenderingExtensions.addDoubleClickAction(button, MemorizingExpandCollapseAction.ID);
            }
        }
        if (instance.recursive) {
            comps.getFigures().forEach(_linguaFrancaStyleExtensions::errorStyle);
        }
        // Create ports
        Map<PortInstance, KPort> inputPorts = new HashMap<>();
        Map<PortInstance, KPort> outputPorts = new HashMap<>();
        for (PortInstance input : ListExtensions.reverseView(instance.inputs)) {
            inputPorts.put(input, addIOPort(node, input, true, input.isMultiport(), reactorInstance.isBank()));
        }
        for (PortInstance output : instance.outputs) {
            outputPorts.put(output, addIOPort(node, output, false, output.isMultiport(), reactorInstance.isBank()));
        }
        // Mark ports
        inputPorts.values().forEach(it -> it.setProperty(REACTOR_INPUT, true));
        outputPorts.values().forEach(it -> it.setProperty(REACTOR_OUTPUT, true));
        // Add content
        if (_utilityExtensions.hasContent(instance) && !instance.recursive) {
            node.getChildren().addAll(transformReactorNetwork(instance, inputPorts, outputPorts, allReactorNodes));
        }
        // Pass port to given tables
        if (!_utilityExtensions.isRoot(instance)) {
            if (inputPortsReg != null) {
                for (Map.Entry<PortInstance, KPort> entry : inputPorts.entrySet()) {
                    inputPortsReg.put(instance, entry.getKey(), entry.getValue());
                }
            }
            if (outputPortsReg != null) {
                for (Map.Entry<PortInstance, KPort> entry : outputPorts.entrySet()) {
                    outputPortsReg.put(instance, entry.getKey(), entry.getValue());
                }
            }
        }
        if (instance.recursive) {
            setLayoutOption(node, KlighdProperties.EXPAND, false);
            nodes.add(addErrorComment(node, TEXT_ERROR_RECURSIVE));
        } else {
            setLayoutOption(node, KlighdProperties.EXPAND, expandDefault);
            // Interface Dependencies
            _interfaceDependenciesVisualization.addInterfaceDependencies(node, expandDefault);
        }
        if (!_utilityExtensions.isRoot(instance)) {
            // add the annotation now.
            if (!getBooleanValue(SHOW_ALL_REACTORS)) {
                Iterables.addAll(nodes, createUserComments(reactor, node));
            }
        } else {
            Iterables.addAll(nodes, createUserComments(reactor, node));
        }
        configureReactorNodeLayout(node);
    }
    // Find and annotate cycles
    if (getBooleanValue(CYCLE_DETECTION) && _utilityExtensions.isRoot(reactorInstance)) {
        KNode errNode = detectAndAnnotateCycles(node, reactorInstance, allReactorNodes);
        if (errNode != null) {
            nodes.add(errNode);
        }
    }
    return nodes;
}
Also used : LineCap(de.cau.cs.kieler.klighd.krendering.LineCap) CoreOptions(org.eclipse.elk.core.options.CoreOptions) ElkMargin(org.eclipse.elk.core.math.ElkMargin) Exceptions(org.eclipse.xtext.xbase.lib.Exceptions) MemorizingExpandCollapseAction(org.lflang.diagram.synthesis.action.MemorizingExpandCollapseAction) LinguaFrancaStyleExtensions(org.lflang.diagram.synthesis.styles.LinguaFrancaStyleExtensions) PortSide(org.eclipse.elk.core.options.PortSide) KLabelExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KLabelExtensions) FileUtil(org.lflang.util.FileUtil) HashBasedTable(com.google.common.collect.HashBasedTable) ExpandAllReactorsAction(org.lflang.diagram.synthesis.action.ExpandAllReactorsAction) Extension(org.eclipse.xtext.xbase.lib.Extension) CollapseAllReactorsAction(org.lflang.diagram.synthesis.action.CollapseAllReactorsAction) LayeredOptions(org.eclipse.elk.alg.layered.options.LayeredOptions) 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) HashMultimap(com.google.common.collect.HashMultimap) KPolyline(de.cau.cs.kieler.klighd.krendering.KPolyline) LineStyle(de.cau.cs.kieler.klighd.krendering.LineStyle) Map(java.util.Map) TriggerInstance(org.lflang.generator.TriggerInstance) ReactorIcons(org.lflang.diagram.synthesis.util.ReactorIcons) Connection(org.lflang.lf.Connection) EnumSet(java.util.EnumSet) KEdge(de.cau.cs.kieler.klighd.kgraph.KEdge) KPolylineExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KPolylineExtensions) KPortExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KPortExtensions) NamedInstanceUtil(org.lflang.diagram.synthesis.util.NamedInstanceUtil) SynthesisOption(de.cau.cs.kieler.klighd.SynthesisOption) Collection(java.util.Collection) Set(java.util.Set) SizeConstraint(org.eclipse.elk.core.options.SizeConstraint) EObject(org.eclipse.emf.ecore.EObject) LinguaFrancaShapeExtensions(org.lflang.diagram.synthesis.styles.LinguaFrancaShapeExtensions) BoxLayouterOptions(org.eclipse.elk.core.options.BoxLayouterOptions) List(java.util.List) InterfaceDependenciesVisualization(org.lflang.diagram.synthesis.util.InterfaceDependenciesVisualization) KlighdProperties(de.cau.cs.kieler.klighd.util.KlighdProperties) Direction(org.eclipse.elk.core.options.Direction) UtilityExtensions(org.lflang.diagram.synthesis.util.UtilityExtensions) KLabel(de.cau.cs.kieler.klighd.kgraph.KLabel) KStyle(de.cau.cs.kieler.klighd.krendering.KStyle) Pair(org.eclipse.xtext.xbase.lib.Pair) StringExtensions(org.eclipse.xtext.xbase.lib.StringExtensions) AbstractDiagramSynthesis(de.cau.cs.kieler.klighd.syntheses.AbstractDiagramSynthesis) FileConfig(org.lflang.FileConfig) ASTUtils(org.lflang.ASTUtils) Iterables(com.google.common.collect.Iterables) KNodeExtensions(de.cau.cs.kieler.klighd.krendering.extensions.KNodeExtensions) HashMap(java.util.HashMap) Multimap(com.google.common.collect.Multimap) ListExtensions(org.eclipse.xtext.xbase.lib.ListExtensions) ModeDiagrams(org.lflang.diagram.synthesis.util.ModeDiagrams) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) EdgeStraighteningStrategy(org.eclipse.elk.alg.layered.options.EdgeStraighteningStrategy) ShowCycleAction(org.lflang.diagram.synthesis.action.ShowCycleAction) ElkPadding(org.eclipse.elk.core.math.ElkPadding) KRendering(de.cau.cs.kieler.klighd.krendering.KRendering) CycleVisualization(org.lflang.diagram.synthesis.util.CycleVisualization) TimerInstance(org.lflang.generator.TimerInstance) LinkedList(java.util.LinkedList) SynthesisErrorReporter(org.lflang.diagram.synthesis.util.SynthesisErrorReporter) KText(de.cau.cs.kieler.klighd.krendering.KText) FixedAlignment(org.eclipse.elk.alg.layered.options.FixedAlignment) FilterCycleAction(org.lflang.diagram.synthesis.action.FilterCycleAction) KNode(de.cau.cs.kieler.klighd.kgraph.KNode) KPort(de.cau.cs.kieler.klighd.kgraph.KPort) KRoundedRectangle(de.cau.cs.kieler.klighd.krendering.KRoundedRectangle) RuntimeRange(org.lflang.generator.RuntimeRange) Model(org.lflang.lf.Model) PortConstraints(org.eclipse.elk.core.options.PortConstraints) Property(org.eclipse.elk.graph.properties.Property) Conversions(org.eclipse.xtext.xbase.lib.Conversions) KVector(org.eclipse.elk.core.math.KVector) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) KContainerRendering(de.cau.cs.kieler.klighd.krendering.KContainerRendering) PortInstance(org.lflang.generator.PortInstance) ReactionInstance(org.lflang.generator.ReactionInstance) ParameterInstance(org.lflang.generator.ParameterInstance) SendRange(org.lflang.generator.SendRange) ActionInstance(org.lflang.generator.ActionInstance) LayerConstraint(org.eclipse.elk.alg.layered.options.LayerConstraint) ReactorInstance(org.lflang.generator.ReactorInstance) IterableExtensions(org.eclipse.xtext.xbase.lib.IterableExtensions) ReactorFigureComponents(org.lflang.diagram.synthesis.styles.ReactorFigureComponents) DisplayedActionData(de.cau.cs.kieler.klighd.DisplayedActionData) ViewSynthesisShared(de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared) KRectangle(de.cau.cs.kieler.klighd.krendering.KRectangle) Reactor(org.lflang.lf.Reactor) Colors(de.cau.cs.kieler.klighd.krendering.Colors) HorizontalAlignment(de.cau.cs.kieler.klighd.krendering.HorizontalAlignment) Table(com.google.common.collect.Table) PortInstance(org.lflang.generator.PortInstance) ArrayList(java.util.ArrayList) KNode(de.cau.cs.kieler.klighd.kgraph.KNode) KRoundedRectangle(de.cau.cs.kieler.klighd.krendering.KRoundedRectangle) KRectangle(de.cau.cs.kieler.klighd.krendering.KRectangle) KText(de.cau.cs.kieler.klighd.krendering.KText) ReactorInstance(org.lflang.generator.ReactorInstance) ReactorFigureComponents(org.lflang.diagram.synthesis.styles.ReactorFigureComponents) Reactor(org.lflang.lf.Reactor) KRendering(de.cau.cs.kieler.klighd.krendering.KRendering) ElkPadding(org.eclipse.elk.core.math.ElkPadding) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

KRoundedRectangle (de.cau.cs.kieler.klighd.krendering.KRoundedRectangle)8 KRectangle (de.cau.cs.kieler.klighd.krendering.KRectangle)5 KText (de.cau.cs.kieler.klighd.krendering.KText)5 KEdge (de.cau.cs.kieler.klighd.kgraph.KEdge)4 KNode (de.cau.cs.kieler.klighd.kgraph.KNode)4 KContainerRendering (de.cau.cs.kieler.klighd.krendering.KContainerRendering)3 KPort (de.cau.cs.kieler.klighd.kgraph.KPort)2 Colors (de.cau.cs.kieler.klighd.krendering.Colors)2 HorizontalAlignment (de.cau.cs.kieler.klighd.krendering.HorizontalAlignment)2 KEllipse (de.cau.cs.kieler.klighd.krendering.KEllipse)2 KGridPlacement (de.cau.cs.kieler.klighd.krendering.KGridPlacement)2 KPolyline (de.cau.cs.kieler.klighd.krendering.KPolyline)2 KRendering (de.cau.cs.kieler.klighd.krendering.KRendering)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 KLabelExtensions (de.cau.cs.kieler.klighd.krendering.extensions.KLabelExtensions)2 KNodeExtensions (de.cau.cs.kieler.klighd.krendering.extensions.KNodeExtensions)2 KPolylineExtensions (de.cau.cs.kieler.klighd.krendering.extensions.KPolylineExtensions)2