use of de.cau.cs.kieler.klighd.krendering.KRectangle in project lingua-franca by lf-lang.
the class ReactorIcons method handleIcon.
public void handleIcon(KContainerRendering rendering, ReactorDecl reactor, boolean collapsed) {
if (!collapsed) {
return;
}
URL iconLocation = locateIcon(reactor);
if (iconLocation != null) {
ImageData data = loadImage(iconLocation);
if (data != null) {
KRectangle figure = _kContainerRenderingExtensions.addRectangle(rendering);
_kRenderingExtensions.setInvisible(figure, true);
KGridPlacementData figurePlacement = _kRenderingExtensions.setGridPlacementData(figure, data.width, data.height);
_kRenderingExtensions.to(_kRenderingExtensions.from(figurePlacement, _kRenderingExtensions.LEFT, 3, 0, _kRenderingExtensions.TOP, 0, 0), _kRenderingExtensions.RIGHT, 3, 0, _kRenderingExtensions.BOTTOM, 3, 0);
KRectangle icon = _kContainerRenderingExtensions.addRectangle(figure);
_kRenderingExtensions.setInvisible(icon, true);
_kContainerRenderingExtensions.addImage(icon, data);
_kRenderingExtensions.setPointPlacementData(icon, _kRenderingExtensions.createKPosition(_kRenderingExtensions.LEFT, 0, 0.5f, _kRenderingExtensions.TOP, 0, 0.5f), _kRenderingExtensions.H_CENTRAL, _kRenderingExtensions.V_CENTRAL, 0, 0, data.width, data.height);
}
}
}
use of de.cau.cs.kieler.klighd.krendering.KRectangle 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;
}
use of de.cau.cs.kieler.klighd.krendering.KRectangle in project lingua-franca by lf-lang.
the class LinguaFrancaSynthesis method detectAndAnnotateCycles.
private KNode detectAndAnnotateCycles(KNode node, ReactorInstance reactorInstance, Map<ReactorInstance, KNode> allReactorNodes) {
if (node.getProperty(REACTOR_RECURSIVE_INSTANTIATION)) {
_filterCycleAction.resetCycleFiltering(node);
return addErrorComment(node, TEXT_ERROR_CONTAINS_RECURSION);
} else {
// only detect dependency cycles if not recursive
try {
boolean hasCycle = _cycleVisualization.detectAndHighlightCycles(reactorInstance, allReactorNodes, it -> {
if (it instanceof KNode) {
List<KRendering> renderings = IterableExtensions.toList(Iterables.filter(((KNode) it).getData(), KRendering.class));
if (renderings.size() == 1) {
_linguaFrancaStyleExtensions.errorStyle(IterableExtensions.head(renderings));
} else {
IterableExtensions.filter(renderings, rendering -> {
return rendering.getProperty(KlighdProperties.COLLAPSED_RENDERING);
}).forEach(_linguaFrancaStyleExtensions::errorStyle);
}
} else if (it instanceof KEdge) {
Iterables.filter(((KEdge) it).getData(), KRendering.class).forEach(_linguaFrancaStyleExtensions::errorStyle);
// TODO initiallyHide does not work with incremental (https://github.com/kieler/KLighD/issues/37)
// cycleEgde.initiallyShow() // Show hidden order dependencies
_kRenderingExtensions.setInvisible(_kRenderingExtensions.getKRendering(it), false);
} else if (it instanceof KPort) {
Iterables.filter(((KPort) it).getData(), KRendering.class).forEach(_linguaFrancaStyleExtensions::errorStyle);
// it.reverseTrianglePort()
}
});
if (hasCycle) {
KNode err = addErrorComment(node, TEXT_ERROR_CONTAINS_CYCLE);
// Add to existing figure
KRectangle rectangle = _kContainerRenderingExtensions.addRectangle(_kRenderingExtensions.getKContainerRendering(err));
_kRenderingExtensions.to(_kRenderingExtensions.from(_kRenderingExtensions.setGridPlacementData(rectangle), _kRenderingExtensions.LEFT, 3, 0, _kRenderingExtensions.TOP, (-1), 0), _kRenderingExtensions.RIGHT, 3, 0, _kRenderingExtensions.BOTTOM, 3, 0);
_linguaFrancaStyleExtensions.noSelectionStyle(rectangle);
_kRenderingExtensions.setInvisible(rectangle, true);
_kContainerRenderingExtensions.setGridPlacement(rectangle, 2);
KRectangle subrectangle = _kContainerRenderingExtensions.addRectangle(rectangle);
_kRenderingExtensions.to(_kRenderingExtensions.from(_kRenderingExtensions.setGridPlacementData(subrectangle), _kRenderingExtensions.LEFT, 0, 0, _kRenderingExtensions.TOP, 0, 0), _kRenderingExtensions.RIGHT, 2, 0, _kRenderingExtensions.BOTTOM, 0, 0);
_linguaFrancaStyleExtensions.noSelectionStyle(subrectangle);
_kRenderingExtensions.addSingleClickAction(subrectangle, ShowCycleAction.ID);
KText subrectangleText = _kContainerRenderingExtensions.addText(subrectangle, TEXT_ERROR_CYCLE_BTN_SHOW);
// Copy text style
List<KStyle> styles = ListExtensions.map(IterableExtensions.head(_kRenderingExtensions.getKContainerRendering(err).getChildren()).getStyles(), EcoreUtil::copy);
subrectangleText.getStyles().addAll(styles);
_kRenderingExtensions.setFontSize(subrectangleText, 5);
_kRenderingExtensions.setSurroundingSpace(subrectangleText, 1, 0);
_linguaFrancaStyleExtensions.noSelectionStyle(subrectangleText);
_kRenderingExtensions.addSingleClickAction(subrectangleText, ShowCycleAction.ID);
subrectangle = _kContainerRenderingExtensions.addRectangle(rectangle);
_kRenderingExtensions.to(_kRenderingExtensions.from(_kRenderingExtensions.setGridPlacementData(subrectangle), _kRenderingExtensions.LEFT, 0, 0, _kRenderingExtensions.TOP, 0, 0), _kRenderingExtensions.RIGHT, 0, 0, _kRenderingExtensions.BOTTOM, 0, 0);
_linguaFrancaStyleExtensions.noSelectionStyle(subrectangle);
_kRenderingExtensions.addSingleClickAction(subrectangle, FilterCycleAction.ID);
subrectangleText = _kContainerRenderingExtensions.addText(subrectangle, _filterCycleAction.isCycleFiltered(node) ? TEXT_ERROR_CYCLE_BTN_UNFILTER : TEXT_ERROR_CYCLE_BTN_FILTER);
// Copy text style
styles = ListExtensions.map(IterableExtensions.head(_kRenderingExtensions.getKContainerRendering(err).getChildren()).getStyles(), EcoreUtil::copy);
subrectangleText.getStyles().addAll(styles);
_kRenderingExtensions.setFontSize(subrectangleText, 5);
_kRenderingExtensions.setSurroundingSpace(subrectangleText, 1, 0);
_linguaFrancaStyleExtensions.noSelectionStyle(subrectangleText);
_kRenderingExtensions.addSingleClickAction(subrectangleText, FilterCycleAction.ID);
_filterCycleAction.markCycleFilterText(subrectangleText, err);
// if user interactively requested a filtered diagram keep it filtered during updates
if (_filterCycleAction.isCycleFiltered(node)) {
_filterCycleAction.filterCycle(node);
}
return err;
}
} catch (Exception e) {
_filterCycleAction.resetCycleFiltering(node);
e.printStackTrace();
return addErrorComment(node, TEXT_ERROR_CYCLE_DETECTION);
}
}
return null;
}
use of de.cau.cs.kieler.klighd.krendering.KRectangle in project lingua-franca by lf-lang.
the class LinguaFrancaShapeExtensions method addReactionFigure.
/**
* Creates the visual representation of a reaction node
*/
public KPolygon addReactionFigure(KNode node, ReactionInstance reaction) {
int minHeight = 22;
int minWidth = 45;
ReactorInstance reactor = reaction.getParent();
_kNodeExtensions.setMinimalNodeSize(node, minWidth, minHeight);
// Create base shape
KPolygon baseShape = _kRenderingExtensions.addPolygon(node);
associateWith(baseShape, reaction);
_kRenderingExtensions.setLineWidth(baseShape, 1);
_kRenderingExtensions.setForeground(baseShape, Colors.GRAY_45);
_kRenderingExtensions.setBackground(baseShape, Colors.GRAY_65);
_linguaFrancaStyleExtensions.boldLineSelectionStyle(baseShape);
baseShape.getPoints().addAll(List.of(_kRenderingExtensions.createKPosition(LEFT, 0, 0, TOP, 0, 0), _kRenderingExtensions.createKPosition(RIGHT, REACTION_POINTINESS, 0, TOP, 0, 0), _kRenderingExtensions.createKPosition(RIGHT, 0, 0, TOP, 0, 0.5f), _kRenderingExtensions.createKPosition(RIGHT, REACTION_POINTINESS, 0, BOTTOM, 0, 0), _kRenderingExtensions.createKPosition(LEFT, 0, 0, BOTTOM, 0, 0), _kRenderingExtensions.createKPosition(LEFT, REACTION_POINTINESS, 0, BOTTOM, 0, 0.5f)));
IterableExtensions.head(baseShape.getStyles()).setModifierId(ReactionPortAdjustment.ID);
KRectangle contentContainer = _kContainerRenderingExtensions.addRectangle(baseShape);
associateWith(contentContainer, reaction);
_kRenderingExtensions.setInvisible(contentContainer, true);
_kRenderingExtensions.<KRectangle>setPointPlacementData(contentContainer, _kRenderingExtensions.LEFT, REACTION_POINTINESS, 0, _kRenderingExtensions.TOP, 0, 0, _kRenderingExtensions.H_LEFT, _kRenderingExtensions.V_TOP, REACTION_POINTINESS, 0, minWidth - REACTION_POINTINESS * 2, minHeight);
_kContainerRenderingExtensions.setGridPlacement(contentContainer, 1);
if (reactor.reactions.size() > 1) {
KText textToAdd = _kContainerRenderingExtensions.addText(contentContainer, Integer.toString(reactor.reactions.indexOf(reaction) + 1));
_kRenderingExtensions.setFontBold(textToAdd, true);
_linguaFrancaStyleExtensions.noSelectionStyle(textToAdd);
DiagramSyntheses.suppressSelectability(textToAdd);
}
// optional reaction level
if (getBooleanValue(LinguaFrancaSynthesis.SHOW_REACTION_LEVEL)) {
// then some reactions will have level -1.
try {
String levels = IterableExtensions.join(reaction.getLevels(), ", ");
KText levelsText = _kContainerRenderingExtensions.addText(contentContainer, ("level: " + levels));
_kRenderingExtensions.setFontBold(levelsText, false);
_linguaFrancaStyleExtensions.noSelectionStyle(levelsText);
DiagramSyntheses.suppressSelectability(levelsText);
} catch (Exception ex) {
// If the graph has cycles, the above fails. Continue without showing levels.
}
}
// optional code content
boolean hasCode = getBooleanValue(LinguaFrancaSynthesis.SHOW_REACTION_CODE) && !StringExtensions.isNullOrEmpty(reaction.getDefinition().getCode().getBody());
if (hasCode) {
KText hasCodeText = _kContainerRenderingExtensions.addText(contentContainer, _utilityExtensions.trimCode(reaction.getDefinition().getCode()));
associateWith(hasCodeText, reaction);
_kRenderingExtensions.setFontSize(hasCodeText, 6);
_kRenderingExtensions.setFontName(hasCodeText, KlighdConstants.DEFAULT_MONOSPACE_FONT_NAME);
_linguaFrancaStyleExtensions.noSelectionStyle(hasCodeText);
_kRenderingExtensions.setHorizontalAlignment(hasCodeText, HorizontalAlignment.LEFT);
_kRenderingExtensions.setVerticalAlignment(hasCodeText, VerticalAlignment.TOP);
setGridPlacementDataFromPointToPoint(hasCodeText, _kRenderingExtensions.LEFT, 5, 0, _kRenderingExtensions.TOP, 5, 0, _kRenderingExtensions.RIGHT, 5, 0, _kRenderingExtensions.BOTTOM, 5, 0);
}
if (reaction.declaredDeadline != null) {
boolean hasDeadlineCode = getBooleanValue(LinguaFrancaSynthesis.SHOW_REACTION_CODE) && !StringExtensions.isNullOrEmpty(reaction.getDefinition().getDeadline().getCode().getBody());
if (hasCode || hasDeadlineCode) {
KPolyline line = _kContainerRenderingExtensions.addHorizontalLine(contentContainer, 0);
setGridPlacementDataFromPointToPoint(line, _kRenderingExtensions.LEFT, 5, 0, _kRenderingExtensions.TOP, 3, 0, _kRenderingExtensions.RIGHT, 5, 0, _kRenderingExtensions.BOTTOM, 6, 0);
}
// delay with stopwatch
KRectangle labelContainer = _kContainerRenderingExtensions.addRectangle(contentContainer);
_kRenderingExtensions.setInvisible(labelContainer, true);
KRendering placement = setGridPlacementDataFromPointToPoint(labelContainer, _kRenderingExtensions.LEFT, hasDeadlineCode ? 0 : -REACTION_POINTINESS * 0.5f, 0, _kRenderingExtensions.TOP, 0, reactor.reactions.size() > 1 || hasCode || hasDeadlineCode ? 0 : 0.5f, _kRenderingExtensions.RIGHT, 0, 0, _kRenderingExtensions.BOTTOM, 0, 0);
_kRenderingExtensions.setHorizontalAlignment(placement, HorizontalAlignment.LEFT);
KRectangle stopWatchFigure = addStopwatchFigure(labelContainer);
_kRenderingExtensions.setLeftTopAlignedPointPlacementData(stopWatchFigure, 0, 0, 0, 0);
KText stopWatchText = _kContainerRenderingExtensions.addText(labelContainer, reaction.declaredDeadline.maxDelay.toString());
associateWith(stopWatchText, reaction.getDefinition().getDeadline().getDelay());
_kRenderingExtensions.setForeground(stopWatchText, Colors.BROWN);
_kRenderingExtensions.setFontBold(stopWatchText, true);
_kRenderingExtensions.setFontSize(stopWatchText, 7);
_linguaFrancaStyleExtensions.underlineSelectionStyle(stopWatchText);
_kRenderingExtensions.setLeftTopAlignedPointPlacementData(stopWatchText, 15, 0, 0, 0);
// optional code content
if (hasDeadlineCode) {
KText contentContainerText = _kContainerRenderingExtensions.addText(contentContainer, _utilityExtensions.trimCode(reaction.getDefinition().getDeadline().getCode()));
associateWith(contentContainerText, reaction.deadline);
_kRenderingExtensions.setForeground(contentContainerText, Colors.BROWN);
_kRenderingExtensions.setFontSize(contentContainerText, 6);
_kRenderingExtensions.setFontName(contentContainerText, KlighdConstants.DEFAULT_MONOSPACE_FONT_NAME);
setGridPlacementDataFromPointToPoint(contentContainerText, _kRenderingExtensions.LEFT, 5, 0, _kRenderingExtensions.TOP, 0, 0, _kRenderingExtensions.RIGHT, 5, 0, _kRenderingExtensions.BOTTOM, 5, 0);
_kRenderingExtensions.setHorizontalAlignment(contentContainerText, HorizontalAlignment.LEFT);
_linguaFrancaStyleExtensions.noSelectionStyle(contentContainerText);
}
}
return baseShape;
}
use of de.cau.cs.kieler.klighd.krendering.KRectangle in project lingua-franca by lf-lang.
the class LinguaFrancaShapeExtensions method addMainReactorFigure.
/**
* Creates the main reactor frame.
*/
public KRoundedRectangle addMainReactorFigure(KNode node, ReactorInstance reactorInstance, String text) {
int padding = getBooleanValue(LinguaFrancaSynthesis.SHOW_HYPERLINKS) ? 8 : 6;
KRoundedRectangle figure = _kRenderingExtensions.addRoundedRectangle(node, 8, 8, 1);
_kContainerRenderingExtensions.setGridPlacement(figure, 1);
_kRenderingExtensions.setLineWidth(figure, 1);
_kRenderingExtensions.setForeground(figure, Colors.GRAY);
_kRenderingExtensions.setBackground(figure, Colors.WHITE);
_linguaFrancaStyleExtensions.boldLineSelectionStyle(figure);
// Create parent container
KRectangle parentContainer = _kContainerRenderingExtensions.addRectangle(figure);
_kRenderingExtensions.setInvisible(parentContainer, true);
setGridPlacementDataFromPointToPoint(parentContainer, LEFT, padding, 0, TOP, padding, 0, RIGHT, padding, 0, BOTTOM, 4, 0);
// Create 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);
// Add text to the child container
KText childText = _kContainerRenderingExtensions.addText(childContainer, text);
DiagramSyntheses.suppressSelectability(childText);
_linguaFrancaStyleExtensions.underlineSelectionStyle(childText);
if (reactorInstance.reactorDefinition.isFederated()) {
KContainerRendering cloudIcon = _linguaFrancaStyleExtensions.addCloudIcon(childContainer);
setGridPlacementDataFromPointToPoint(cloudIcon, LEFT, 3, 0, TOP, 0, 0, RIGHT, 0, 0, BOTTOM, 0, 0);
placement.setNumColumns(2);
if (reactorInstance.reactorDefinition.getHost() != null && getBooleanValue(LinguaFrancaSynthesis.SHOW_REACTOR_HOST)) {
KText hostNameText = _kContainerRenderingExtensions.addText(childContainer, _utilityExtensions.toText(reactorInstance.reactorDefinition.getHost()));
DiagramSyntheses.suppressSelectability(hostNameText);
_linguaFrancaStyleExtensions.underlineSelectionStyle(hostNameText);
setGridPlacementDataFromPointToPoint(hostNameText, LEFT, 3, 0, TOP, 0, 0, RIGHT, 0, 0, BOTTOM, 0, 0);
placement.setNumColumns(3);
}
}
return figure;
}
Aggregations