use of de.cau.cs.kieler.klighd.krendering.KDecoratorPlacementData in project lingua-franca by lf-lang.
the class LinguaFrancaStyleExtensions method addArrayDecorator.
public void addArrayDecorator(KEdge edge, Integer size) {
final KRendering line = _kRenderingExtensions.getKRendering(edge);
if (line instanceof KPolyline) {
KDecoratorPlacementData placement = _kRenderingFactory.createKDecoratorPlacementData();
placement.setRotateWithLine(true);
placement.setRelative(0f);
placement.setAbsolute(6f);
KPolyline slash = _kContainerRenderingExtensions.addChild((KContainerRendering) line, _kRenderingFactory.createKPolyline());
slash.getPoints().add(_kRenderingExtensions.createKPosition(_kRenderingExtensions.RIGHT, 0, 0, _kRenderingExtensions.TOP, 0, 0));
slash.getPoints().add(_kRenderingExtensions.createKPosition(_kRenderingExtensions.LEFT, 0, 0, _kRenderingExtensions.BOTTOM, 0, 0));
KDecoratorPlacementData slashPlacement = EcoreUtil.copy(placement);
slashPlacement.setWidth(5);
slashPlacement.setHeight(10);
slashPlacement.setYOffset(-5f);
slash.setPlacementData(slashPlacement);
if (size != null) {
KText num = _kContainerRenderingExtensions.addChild((KContainerRendering) line, _kRenderingFactory.createKText());
num.setText(size.toString());
_kRenderingExtensions.setFontSize(num, 5);
noSelectionStyle(num);
KDecoratorPlacementData numPlacement = EcoreUtil.copy(placement);
numPlacement.setXOffset(2f);
num.setPlacementData(numPlacement);
}
}
}
use of de.cau.cs.kieler.klighd.krendering.KDecoratorPlacementData in project lingua-franca by lf-lang.
the class LinguaFrancaStyleExtensions method addFixedTailArrowDecorator.
public KRendering addFixedTailArrowDecorator(KPolyline pl) {
KRendering head = _kPolylineExtensions.addTailArrowDecorator(pl);
KDecoratorPlacementData placement = _kRenderingFactory.createKDecoratorPlacementData();
placement.setRotateWithLine(true);
placement.setRelative(0f);
placement.setAbsolute(2f);
placement.setWidth(8);
placement.setHeight(6);
placement.setXOffset(-3f);
placement.setYOffset(-4f);
head.setPlacementData(placement);
return head;
}
use of de.cau.cs.kieler.klighd.krendering.KDecoratorPlacementData in project lingua-franca by lf-lang.
the class LinguaFrancaShapeExtensions method addActionDecorator.
/**
* Creates the triangular line decorator with text.
*/
public KPolygon addActionDecorator(KPolyline line, String text) {
final float size = 18;
// Create action decorator
KPolygon actionDecorator = _kContainerRenderingExtensions.addPolygon(line);
_kRenderingExtensions.setBackground(actionDecorator, Colors.WHITE);
List<KPosition> pointsToAdd = List.of(_kRenderingExtensions.createKPosition(LEFT, 0, 0.5f, TOP, 0, 0), _kRenderingExtensions.createKPosition(RIGHT, 0, 0, BOTTOM, 0, 0), _kRenderingExtensions.createKPosition(LEFT, 0, 0, BOTTOM, 0, 0));
actionDecorator.getPoints().addAll(pointsToAdd);
// Set placement data of the action decorator
KDecoratorPlacementData placementData = _kRenderingFactory.createKDecoratorPlacementData();
placementData.setRelative(0.5f);
placementData.setAbsolute(-size / 2);
placementData.setWidth(size);
placementData.setHeight(size);
placementData.setYOffset(-size * 0.66f);
placementData.setRotateWithLine(true);
actionDecorator.setPlacementData(placementData);
// Add text to the action decorator
KText textToAdd = _kContainerRenderingExtensions.addText(actionDecorator, text);
_kRenderingExtensions.setFontSize(textToAdd, 8);
_linguaFrancaStyleExtensions.noSelectionStyle(textToAdd);
DiagramSyntheses.suppressSelectability(textToAdd);
_kRenderingExtensions.setPointPlacementData(textToAdd, _kRenderingExtensions.LEFT, 0, 0.5f, _kRenderingExtensions.TOP, size * 0.15f, 0.5f, _kRenderingExtensions.H_CENTRAL, _kRenderingExtensions.V_CENTRAL, 0, 0, size, size);
return actionDecorator;
}
Aggregations