use of de.cau.cs.kieler.klighd.krendering.KText in project lingua-franca by lf-lang.
the class ModeDiagrams method addModeFigure.
private KContainerRendering addModeFigure(KNode node, ModeInstance mode, boolean expanded) {
int padding = getBooleanValue(LinguaFrancaSynthesis.SHOW_HYPERLINKS) ? 8 : 6;
var figure = _kRenderingExtensions.addRoundedRectangle(node, 13, 13, 1);
_kContainerRenderingExtensions.setGridPlacement(figure, 1);
_kRenderingExtensions.setLineWidth(figure, mode.isInitial() ? 3f : 1.5f);
_kRenderingExtensions.setForeground(figure, MODE_FG);
_kRenderingExtensions.setBackground(figure, MODE_BG);
var background = _kRenderingExtensions.getBackground(figure);
background.setAlpha(MODE_BG_ALPHA);
_linguaFrancaStyleExtensions.boldLineSelectionStyle(figure);
// Invisible container
KRectangle container = _kContainerRenderingExtensions.addRectangle(figure);
_kRenderingExtensions.setInvisible(container, true);
int bottomPadding = this.hasContent(mode) && expanded ? 4 : padding;
var from = _kRenderingExtensions.from(_kRenderingExtensions.setGridPlacementData(container), _kRenderingExtensions.LEFT, padding, 0, _kRenderingExtensions.TOP, padding, 0);
_kRenderingExtensions.to(from, _kRenderingExtensions.RIGHT, padding, 0, _kRenderingExtensions.BOTTOM, bottomPadding, 0);
// Centered child container
KRectangle childContainer = _kContainerRenderingExtensions.addRectangle(container);
this._kRenderingExtensions.setInvisible(childContainer, true);
this._kRenderingExtensions.setPointPlacementData(childContainer, _kRenderingExtensions.LEFT, 0, 0.5f, _kRenderingExtensions.TOP, 0, 0.5f, _kRenderingExtensions.H_CENTRAL, _kRenderingExtensions.V_CENTRAL, 0, 0, 0, 0);
this._kContainerRenderingExtensions.setGridPlacement(childContainer, 1);
KText text = _kContainerRenderingExtensions.addText(childContainer, mode.getName());
DiagramSyntheses.suppressSelectability(text);
_linguaFrancaStyleExtensions.underlineSelectionStyle(text);
return figure;
}
use of de.cau.cs.kieler.klighd.krendering.KText 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);
}
use of de.cau.cs.kieler.klighd.krendering.KText 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);
}
use of de.cau.cs.kieler.klighd.krendering.KText in project lingua-franca by lf-lang.
the class LinguaFrancaSynthesis method addParameterList.
private void addParameterList(KContainerRendering container, List<ParameterInstance> parameters) {
int cols = 1;
try {
cols = getIntValue(REACTOR_PARAMETER_TABLE_COLS);
}// ignore
catch (Exception e) {
}
if (cols > parameters.size()) {
cols = parameters.size();
}
_kContainerRenderingExtensions.setGridPlacement(container, cols);
for (ParameterInstance param : parameters) {
KText paramText = _kContainerRenderingExtensions.addText(container, createParameterLabel(param, true));
_kRenderingExtensions.setFontSize(paramText, 8);
_kRenderingExtensions.setHorizontalAlignment(paramText, HorizontalAlignment.LEFT);
}
}
Aggregations