Search in sources :

Example 1 with IntermediateProcessorStrategy

use of org.eclipse.elk.alg.layered.intermediate.IntermediateProcessorStrategy in project elk by eclipse.

the class GraphConfigurator method getPhaseIndependentLayoutProcessorConfiguration.

/**
 * Returns an intermediate processing configuration with processors not tied to specific phases.
 *
 * @param lgraph the layered graph to be processed. The configuration may vary depending on certain
 *               properties of the graph.
 * @return intermediate processing configuration. May be {@code null}.
 */
private LayoutProcessorConfiguration<LayeredPhases, LGraph> getPhaseIndependentLayoutProcessorConfiguration(final LGraph lgraph) {
    Set<GraphProperties> graphProperties = lgraph.getProperty(InternalProperties.GRAPH_PROPERTIES);
    // Basic configuration
    LayoutProcessorConfiguration<LayeredPhases, LGraph> configuration = LayoutProcessorConfiguration.createFrom(BASELINE_PROCESSING_CONFIGURATION);
    // Hierarchical layout.
    // Note that the recursive graph layout engine made sure that at this point
    // 'INCLUDE_CHILDREN' has been propagated to all parent nodes with 'INHERIT'.
    // Thus, every lgraph of the hierarchical lgraph structure is configured with the following additions.
    HierarchyHandling hierarchyHandling = lgraph.getProperty(LayeredOptions.HIERARCHY_HANDLING);
    if (hierarchyHandling == HierarchyHandling.INCLUDE_CHILDREN) {
        configuration.addAll(HIERARCHICAL_ADDITIONS);
    }
    // Port side processor, put to first slot only if requested and routing is orthogonal
    if (lgraph.getProperty(LayeredOptions.FEEDBACK_EDGES)) {
        configuration.addBefore(LayeredPhases.P1_CYCLE_BREAKING, IntermediateProcessorStrategy.PORT_SIDE_PROCESSOR);
    } else {
        configuration.addBefore(LayeredPhases.P3_NODE_ORDERING, IntermediateProcessorStrategy.PORT_SIDE_PROCESSOR);
    }
    // If the graph has a label manager, so add label management additions
    if (lgraph.getProperty(LabelManagementOptions.LABEL_MANAGER) != null) {
        configuration.addAll(LABEL_MANAGEMENT_ADDITIONS);
    }
    // If the graph should be laid out interactively, add the layers and positions to the nodes.
    if (lgraph.getProperty(LayeredOptions.INTERACTIVE_LAYOUT)) {
        configuration.addAfter(LayeredPhases.P5_EDGE_ROUTING, IntermediateProcessorStrategy.CONSTRAINTS_POSTPROCESSOR);
    }
    // graph transformations for unusual layout directions
    switch(lgraph.getProperty(LayeredOptions.DIRECTION)) {
        case LEFT:
        case DOWN:
        case UP:
            configuration.addBefore(LayeredPhases.P1_CYCLE_BREAKING, IntermediateProcessorStrategy.DIRECTION_PREPROCESSOR).addAfter(LayeredPhases.P5_EDGE_ROUTING, IntermediateProcessorStrategy.DIRECTION_POSTPROCESSOR);
            break;
        default:
            // don't need any processors here
            break;
    }
    // Additional dependencies
    if (graphProperties.contains(GraphProperties.COMMENTS)) {
        configuration.addBefore(LayeredPhases.P1_CYCLE_BREAKING, IntermediateProcessorStrategy.COMMENT_PREPROCESSOR).addBefore(LayeredPhases.P4_NODE_PLACEMENT, IntermediateProcessorStrategy.COMMENT_NODE_MARGIN_CALCULATOR).addAfter(LayeredPhases.P5_EDGE_ROUTING, IntermediateProcessorStrategy.COMMENT_POSTPROCESSOR);
    }
    // Node-Promotion application for reduction of dummy nodes after layering
    if (lgraph.getProperty(LayeredOptions.LAYERING_NODE_PROMOTION_STRATEGY) != NodePromotionStrategy.NONE) {
        configuration.addBefore(LayeredPhases.P3_NODE_ORDERING, IntermediateProcessorStrategy.NODE_PROMOTION);
    }
    // Preserve certain partitions during layering
    if (graphProperties.contains(GraphProperties.PARTITIONS)) {
        configuration.addBefore(LayeredPhases.P1_CYCLE_BREAKING, IntermediateProcessorStrategy.PARTITION_PREPROCESSOR);
        configuration.addBefore(LayeredPhases.P2_LAYERING, IntermediateProcessorStrategy.PARTITION_MIDPROCESSOR);
        configuration.addBefore(LayeredPhases.P3_NODE_ORDERING, IntermediateProcessorStrategy.PARTITION_POSTPROCESSOR);
    }
    // Additional horizontal compaction depends on orthogonal edge routing
    if (lgraph.getProperty(LayeredOptions.COMPACTION_POST_COMPACTION_STRATEGY) != GraphCompactionStrategy.NONE && lgraph.getProperty(LayeredOptions.EDGE_ROUTING) != EdgeRouting.POLYLINE) {
        configuration.addAfter(LayeredPhases.P5_EDGE_ROUTING, IntermediateProcessorStrategy.HORIZONTAL_COMPACTOR);
    }
    // Move trees of high degree nodes to separate layers
    if (lgraph.getProperty(LayeredOptions.HIGH_DEGREE_NODES_TREATMENT)) {
        configuration.addBefore(LayeredPhases.P3_NODE_ORDERING, IntermediateProcessorStrategy.HIGH_DEGREE_NODE_LAYER_PROCESSOR);
    }
    // Introduce in-layer constraints to preserve the order of regular nodes
    if (lgraph.getProperty(LayeredOptions.CROSSING_MINIMIZATION_SEMI_INTERACTIVE)) {
        configuration.addBefore(LayeredPhases.P3_NODE_ORDERING, IntermediateProcessorStrategy.SEMI_INTERACTIVE_CROSSMIN_PROCESSOR);
    }
    // ElkLayered#reviewAndCorrectHierarchicalProcessors(...)
    if (activateGreedySwitchFor(lgraph)) {
        final GreedySwitchType greedySwitchType;
        if (isHierarchicalLayout(lgraph)) {
            greedySwitchType = lgraph.getProperty(LayeredOptions.CROSSING_MINIMIZATION_GREEDY_SWITCH_HIERARCHICAL_TYPE);
        } else {
            greedySwitchType = lgraph.getProperty(LayeredOptions.CROSSING_MINIMIZATION_GREEDY_SWITCH_TYPE);
        }
        IntermediateProcessorStrategy internalGreedyType = (greedySwitchType == GreedySwitchType.ONE_SIDED) ? IntermediateProcessorStrategy.ONE_SIDED_GREEDY_SWITCH : IntermediateProcessorStrategy.TWO_SIDED_GREEDY_SWITCH;
        configuration.addBefore(LayeredPhases.P4_NODE_PLACEMENT, internalGreedyType);
    }
    // Wrapping of graphs
    switch(lgraph.getProperty(LayeredOptions.WRAPPING_STRATEGY)) {
        case SINGLE_EDGE:
            configuration.addBefore(LayeredPhases.P4_NODE_PLACEMENT, IntermediateProcessorStrategy.SINGLE_EDGE_GRAPH_WRAPPER);
            break;
        case MULTI_EDGE:
            configuration.addBefore(LayeredPhases.P3_NODE_ORDERING, IntermediateProcessorStrategy.BREAKING_POINT_INSERTER).addBefore(LayeredPhases.P4_NODE_PLACEMENT, IntermediateProcessorStrategy.BREAKING_POINT_PROCESSOR).addAfter(LayeredPhases.P5_EDGE_ROUTING, IntermediateProcessorStrategy.BREAKING_POINT_REMOVER);
            break;
        // OFF
        default:
    }
    if (lgraph.getProperty(LayeredOptions.CONSIDER_MODEL_ORDER_STRATEGY) != OrderingStrategy.NONE) {
        configuration.addBefore(LayeredPhases.P3_NODE_ORDERING, IntermediateProcessorStrategy.SORT_BY_INPUT_ORDER_OF_MODEL);
    }
    return configuration;
}
Also used : HierarchyHandling(org.eclipse.elk.core.options.HierarchyHandling) GraphProperties(org.eclipse.elk.alg.layered.options.GraphProperties) GreedySwitchType(org.eclipse.elk.alg.layered.options.GreedySwitchType) IntermediateProcessorStrategy(org.eclipse.elk.alg.layered.intermediate.IntermediateProcessorStrategy) LGraph(org.eclipse.elk.alg.layered.graph.LGraph)

Aggregations

LGraph (org.eclipse.elk.alg.layered.graph.LGraph)1 IntermediateProcessorStrategy (org.eclipse.elk.alg.layered.intermediate.IntermediateProcessorStrategy)1 GraphProperties (org.eclipse.elk.alg.layered.options.GraphProperties)1 GreedySwitchType (org.eclipse.elk.alg.layered.options.GreedySwitchType)1 HierarchyHandling (org.eclipse.elk.core.options.HierarchyHandling)1