Search in sources :

Example 1 with StripContainerCell

use of org.eclipse.elk.alg.common.nodespacing.cellsystem.StripContainerCell in project elk by eclipse.

the class LabelPlacer method placeVerticalOuterNodeLabelContainer.

/**
 * Places a vertical outer node label container on the given side.
 */
private static void placeVerticalOuterNodeLabelContainer(final NodeContext nodeContext, final boolean outerNodeLabelsOverhang, final PortSide portSide) {
    KVector nodeSize = nodeContext.nodeSize;
    StripContainerCell nodeLabelContainer = nodeContext.outsideNodeLabelContainers.get(portSide);
    ElkRectangle nodeLabelContainerRect = nodeLabelContainer.getCellRectangle();
    // Set the container's width and height to its minimum width and height
    nodeLabelContainerRect.width = nodeLabelContainer.getMinimumWidth();
    nodeLabelContainerRect.height = nodeLabelContainer.getMinimumHeight();
    // The container must be at least as high as the node is
    nodeLabelContainerRect.height = Math.max(nodeLabelContainerRect.height, nodeSize.y);
    // If node labels are not allowed to overhang and if they would do so right now, make the container smaller
    if (nodeLabelContainerRect.height > nodeSize.y && !outerNodeLabelsOverhang) {
        nodeLabelContainerRect.height = nodeSize.y;
    }
    // Container's y coordinate
    nodeLabelContainerRect.y = -(nodeLabelContainerRect.height - nodeSize.y) / 2;
    // Container's x coordinate depends on whether we place the thing on the eastern or western side
    switch(portSide) {
        case WEST:
            nodeLabelContainerRect.x = -nodeLabelContainerRect.width;
            break;
        case EAST:
            nodeLabelContainerRect.x = nodeSize.x;
            break;
    }
    // Layout the container's children
    nodeLabelContainer.layoutChildrenHorizontally();
    nodeLabelContainer.layoutChildrenVertically();
}
Also used : KVector(org.eclipse.elk.core.math.KVector) ElkRectangle(org.eclipse.elk.core.math.ElkRectangle) StripContainerCell(org.eclipse.elk.alg.common.nodespacing.cellsystem.StripContainerCell)

Example 2 with StripContainerCell

use of org.eclipse.elk.alg.common.nodespacing.cellsystem.StripContainerCell in project elk by eclipse.

the class LabelPlacer method placeHorizontalOuterNodeLabelContainer.

/**
 * Places a horizontal outer node label container on the given side.
 */
private static void placeHorizontalOuterNodeLabelContainer(final NodeContext nodeContext, final boolean outerNodeLabelsOverhang, final PortSide portSide) {
    KVector nodeSize = nodeContext.nodeSize;
    StripContainerCell nodeLabelContainer = nodeContext.outsideNodeLabelContainers.get(portSide);
    ElkRectangle nodeLabelContainerRect = nodeLabelContainer.getCellRectangle();
    // Set the container's width and height to its minimum width and height
    nodeLabelContainerRect.width = nodeLabelContainer.getMinimumWidth();
    nodeLabelContainerRect.height = nodeLabelContainer.getMinimumHeight();
    // The container must be at least as wide as the node is
    nodeLabelContainerRect.width = Math.max(nodeLabelContainerRect.width, nodeSize.x);
    // If node labels are not allowed to overhang and if they would do so right now, make the container smaller
    if (nodeLabelContainerRect.width > nodeSize.x && !outerNodeLabelsOverhang) {
        nodeLabelContainerRect.width = nodeSize.x;
    }
    // Container's x coordinate
    nodeLabelContainerRect.x = -(nodeLabelContainerRect.width - nodeSize.x) / 2;
    // Container's y coordinate depends on whether we place the thing on the northern or southern side
    switch(portSide) {
        case NORTH:
            nodeLabelContainerRect.y = -nodeLabelContainerRect.height;
            break;
        case SOUTH:
            nodeLabelContainerRect.y = nodeSize.y;
            break;
    }
    // Layout the container's children
    nodeLabelContainer.layoutChildrenHorizontally();
    nodeLabelContainer.layoutChildrenVertically();
}
Also used : KVector(org.eclipse.elk.core.math.KVector) ElkRectangle(org.eclipse.elk.core.math.ElkRectangle) StripContainerCell(org.eclipse.elk.alg.common.nodespacing.cellsystem.StripContainerCell)

Example 3 with StripContainerCell

use of org.eclipse.elk.alg.common.nodespacing.cellsystem.StripContainerCell in project elk by eclipse.

the class NodeLabelCellCreator method createNodeLabelCellContainers.

// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Cell Creation and Retrieval
/**
 * Creates all node label containers.
 */
private static void createNodeLabelCellContainers(final NodeContext nodeContext, final boolean onlyInside) {
    boolean symmetry = !nodeContext.sizeOptions.contains(SizeOptions.ASYMMETRICAL);
    boolean tabularNodeLabels = nodeContext.sizeOptions.contains(SizeOptions.FORCE_TABULAR_NODE_LABELS);
    // Inside container
    nodeContext.insideNodeLabelContainer = new GridContainerCell(tabularNodeLabels, symmetry, nodeContext.labelCellSpacing);
    if (nodeContext.nodeLabelsPadding != null) {
        nodeContext.insideNodeLabelContainer.getPadding().copy(nodeContext.nodeLabelsPadding);
    }
    nodeContext.nodeContainerMiddleRow.setCell(ContainerArea.CENTER, nodeContext.insideNodeLabelContainer);
    // Outside containers, if requested
    if (!onlyInside) {
        StripContainerCell northContainer = new StripContainerCell(Strip.HORIZONTAL, symmetry, nodeContext.labelCellSpacing);
        northContainer.getPadding().bottom = nodeContext.nodeLabelSpacing;
        nodeContext.outsideNodeLabelContainers.put(PortSide.NORTH, northContainer);
        StripContainerCell southContainer = new StripContainerCell(Strip.HORIZONTAL, symmetry, nodeContext.labelCellSpacing);
        southContainer.getPadding().top = nodeContext.nodeLabelSpacing;
        nodeContext.outsideNodeLabelContainers.put(PortSide.SOUTH, southContainer);
        StripContainerCell westContainer = new StripContainerCell(Strip.VERTICAL, symmetry, nodeContext.labelCellSpacing);
        westContainer.getPadding().right = nodeContext.nodeLabelSpacing;
        nodeContext.outsideNodeLabelContainers.put(PortSide.WEST, westContainer);
        StripContainerCell eastContainer = new StripContainerCell(Strip.VERTICAL, symmetry, nodeContext.labelCellSpacing);
        eastContainer.getPadding().left = nodeContext.nodeLabelSpacing;
        nodeContext.outsideNodeLabelContainers.put(PortSide.EAST, eastContainer);
    }
}
Also used : GridContainerCell(org.eclipse.elk.alg.common.nodespacing.cellsystem.GridContainerCell) StripContainerCell(org.eclipse.elk.alg.common.nodespacing.cellsystem.StripContainerCell)

Example 4 with StripContainerCell

use of org.eclipse.elk.alg.common.nodespacing.cellsystem.StripContainerCell in project elk by eclipse.

the class NodeLabelCellCreator method retrieveNodeLabelCell.

/**
 * Retrieves the node label cell for the given location. If it doesn't exist yet, it is created.
 */
private static LabelCell retrieveNodeLabelCell(final NodeContext nodeContext, final NodeLabelLocation nodeLabelLocation, final boolean horizontalLayoutMode) {
    LabelCell nodeLabelCell = nodeContext.nodeLabelCells.get(nodeLabelLocation);
    if (nodeLabelCell == null) {
        // The node label cell doesn't exist yet, so create one and add it to the relevant container
        nodeLabelCell = new LabelCell(nodeContext.labelLabelSpacing, nodeLabelLocation, horizontalLayoutMode);
        nodeContext.nodeLabelCells.put(nodeLabelLocation, nodeLabelCell);
        // Find the correct container and add the cell to it
        if (nodeLabelLocation.isInsideLocation()) {
            nodeContext.insideNodeLabelContainer.setCell(nodeLabelLocation.getContainerRow(), nodeLabelLocation.getContainerColumn(), nodeLabelCell);
        } else {
            PortSide outsideSide = nodeLabelLocation.getOutsideSide();
            StripContainerCell containerCell = nodeContext.outsideNodeLabelContainers.get(outsideSide);
            switch(outsideSide) {
                case NORTH:
                case SOUTH:
                    nodeLabelCell.setContributesToMinimumHeight(true);
                    containerCell.setCell(nodeLabelLocation.getContainerColumn(), nodeLabelCell);
                    break;
                case WEST:
                case EAST:
                    nodeLabelCell.setContributesToMinimumWidth(true);
                    containerCell.setCell(nodeLabelLocation.getContainerRow(), nodeLabelCell);
                    break;
            }
        }
    }
    return nodeLabelCell;
}
Also used : LabelCell(org.eclipse.elk.alg.common.nodespacing.cellsystem.LabelCell) PortSide(org.eclipse.elk.core.options.PortSide) StripContainerCell(org.eclipse.elk.alg.common.nodespacing.cellsystem.StripContainerCell)

Aggregations

StripContainerCell (org.eclipse.elk.alg.common.nodespacing.cellsystem.StripContainerCell)4 ElkRectangle (org.eclipse.elk.core.math.ElkRectangle)2 KVector (org.eclipse.elk.core.math.KVector)2 GridContainerCell (org.eclipse.elk.alg.common.nodespacing.cellsystem.GridContainerCell)1 LabelCell (org.eclipse.elk.alg.common.nodespacing.cellsystem.LabelCell)1 PortSide (org.eclipse.elk.core.options.PortSide)1