use of org.eclipse.elk.core.options.HierarchyHandling in project elk by eclipse.
the class RecursiveGraphLayoutEngine method evaluateHierarchyHandlingInheritance.
// //////////////////////////////////////////////////////////////////////////////////////
// Hierarchy Handling
/**
* Evaluates one level of inheritance for property {@link CoreOptions#HIERARCHY_HANDLING}. If the root node is
* evaluated and it is set to inherit (or not set at all) the property is set to
* {@link HierarchyHandling#SEPARATE_CHILDREN}.
*
* @param layoutNode
* The current node which should be evaluated
*/
private void evaluateHierarchyHandlingInheritance(final ElkNode layoutNode) {
// value. If the root node is set to inherit, it is set to separate the children.
if (layoutNode.getProperty(CoreOptions.HIERARCHY_HANDLING) == HierarchyHandling.INHERIT) {
if (layoutNode.getParent() == null) {
// Set root node to separate children handling
layoutNode.setProperty(CoreOptions.HIERARCHY_HANDLING, HierarchyHandling.SEPARATE_CHILDREN);
} else {
// Set hierarchy handling to the value of the parent.
// It is safe to assume that the parent has been handled before and is not set to
// INHERIT anymore.
HierarchyHandling parentHandling = layoutNode.getParent().getProperty(CoreOptions.HIERARCHY_HANDLING);
layoutNode.setProperty(CoreOptions.HIERARCHY_HANDLING, parentHandling);
}
}
}
use of org.eclipse.elk.core.options.HierarchyHandling 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;
}
use of org.eclipse.elk.core.options.HierarchyHandling in project elk by eclipse.
the class LayoutConfigurationManager method isFullHierarchyLayout.
/**
* Determine whether the given configuration store is set up to do a full-hierarchy layout,
* i.e. to process all contained hierarchy levels with a single layout algorithm invocation.
*/
protected boolean isFullHierarchyLayout(final ILayoutConfigurationStore config) {
Object layoutHierarchyVal = config.getOptionValue(CoreOptions.HIERARCHY_HANDLING.getId());
HierarchyHandling layoutHierarchy = layoutHierarchyVal instanceof HierarchyHandling ? (HierarchyHandling) layoutHierarchyVal : HierarchyHandling.valueOf((String) layoutHierarchyVal);
if (layoutHierarchy == HierarchyHandling.INCLUDE_CHILDREN) {
LayoutAlgorithmData algoData = getAlgorithm(config);
return algoData != null && (algoData.supportsFeature(GraphFeature.COMPOUND) || algoData.supportsFeature(GraphFeature.CLUSTERS));
}
return false;
}
Aggregations