Search in sources :

Example 1 with Colors

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

the class LinguaFrancaShapeExtensions method addTrianglePort.

/**
 * Creates the visual representation of a reactor port.
 */
public KPolygon addTrianglePort(KPort port, boolean multiport) {
    port.setSize(8, 8);
    // Create triangle port
    KPolygon trianglePort = _kRenderingExtensions.addPolygon(port);
    // Set line width and background color according to multiport or not
    float lineWidth = multiport ? 2.2f : 1;
    _kRenderingExtensions.setLineWidth(trianglePort, lineWidth);
    _linguaFrancaStyleExtensions.boldLineSelectionStyle(trianglePort);
    Colors background = multiport ? Colors.WHITE : Colors.BLACK;
    _kRenderingExtensions.setBackground(trianglePort, background);
    List<KPosition> pointsToAdd;
    if (multiport) {
        // Compensate for line width by making triangle smaller
        // Do not adjust by port size because this will affect port distribution and cause offsets between parallel connections
        pointsToAdd = List.of(_kRenderingExtensions.createKPosition(LEFT, 0, 0, TOP, 0.6f, 0), _kRenderingExtensions.createKPosition(RIGHT, 1.2f, 0, TOP, 0, 0.5f), _kRenderingExtensions.createKPosition(LEFT, 0, 0, BOTTOM, 0.6f, 0));
    } else {
        pointsToAdd = List.of(_kRenderingExtensions.createKPosition(LEFT, 0, 0, TOP, 0, 0), _kRenderingExtensions.createKPosition(RIGHT, 0, 0, TOP, 0, 0.5f), _kRenderingExtensions.createKPosition(LEFT, 0, 0, BOTTOM, 0, 0));
    }
    trianglePort.getPoints().addAll(pointsToAdd);
    return trianglePort;
}
Also used : KPolygon(de.cau.cs.kieler.klighd.krendering.KPolygon) Colors(de.cau.cs.kieler.klighd.krendering.Colors) KPosition(de.cau.cs.kieler.klighd.krendering.KPosition)

Aggregations

Colors (de.cau.cs.kieler.klighd.krendering.Colors)1 KPolygon (de.cau.cs.kieler.klighd.krendering.KPolygon)1 KPosition (de.cau.cs.kieler.klighd.krendering.KPosition)1