use of org.eclipse.elk.core.util.IElkProgressMonitor in project elk by eclipse.
the class LabelAndNodeSizeProcessor method process.
@Override
public void process(final LGraph layeredGraph, final IElkProgressMonitor monitor) {
monitor.begin("Node and Port Label Placement and Node Sizing", 1);
NodeDimensionCalculation.calculateLabelAndNodeSizes(LGraphAdapters.adapt(layeredGraph, true, true, node -> node.getType() == NodeType.NORMAL));
// which is the reason why we haven't handed them to the label and node size processing code
if (layeredGraph.getProperty(InternalProperties.GRAPH_PROPERTIES).contains(GraphProperties.EXTERNAL_PORTS)) {
Set<PortLabelPlacement> portLabelPlacement = layeredGraph.getProperty(LayeredOptions.PORT_LABELS_PLACEMENT);
boolean placeNextToPort = portLabelPlacement.contains(PortLabelPlacement.NEXT_TO_PORT_IF_POSSIBLE);
boolean treatAsGroup = layeredGraph.getProperty(LayeredOptions.PORT_LABELS_TREAT_AS_GROUP);
for (Layer layer : layeredGraph.getLayers()) {
layer.getNodes().stream().filter(node -> node.getType() == NodeType.EXTERNAL_PORT).forEach(dummy -> placeExternalPortDummyLabels(dummy, portLabelPlacement, placeNextToPort, treatAsGroup));
}
}
monitor.done();
}
use of org.eclipse.elk.core.util.IElkProgressMonitor in project elk by eclipse.
the class FinalSplineBendpointsCalculator method process.
@Override
public void process(final LGraph graph, final IElkProgressMonitor progressMonitor) {
this.edgeEdgeSpacing = graph.getProperty(LayeredOptions.SPACING_EDGE_EDGE_BETWEEN_LAYERS);
this.edgeNodeSpacing = graph.getProperty(LayeredOptions.SPACING_EDGE_NODE_BETWEEN_LAYERS);
this.splineRoutingMode = graph.getProperty(LayeredOptions.EDGE_ROUTING_SPLINES_MODE);
this.compactionStrategy = graph.getProperty(LayeredOptions.COMPACTION_POST_COMPACTION_STRATEGY);
// assign indices to nodes to efficiently query neighbors within the same layer
indexNodesPerLayer(graph);
// collect all edges that represent the first segment of a spline
List<LEdge> startEdges = graph.getLayers().stream().flatMap(l -> l.getNodes().stream()).flatMap(n -> StreamSupport.stream(n.getOutgoingEdges().spliterator(), false)).filter(e -> !e.isSelfLoop()).filter(e -> e.hasProperty(InternalProperties.SPLINE_ROUTE_START)).collect(Collectors.toList());
// first determine the NUB control points
for (LEdge e : startEdges) {
List<SplineSegment> spline = e.getProperty(InternalProperties.SPLINE_ROUTE_START);
spline.forEach(s -> calculateControlPoints(s));
e.setProperty(InternalProperties.SPLINE_ROUTE_START, null);
}
// ... then convert them to bezier splines
for (LEdge e : startEdges) {
// may be null
LEdge survivingEdge = e.getProperty(InternalProperties.SPLINE_SURVIVING_EDGE);
List<LEdge> edgeChain = e.getProperty(InternalProperties.SPLINE_EDGE_CHAIN);
calculateBezierBendPoints(edgeChain, survivingEdge);
// clear property
e.setProperty(InternalProperties.SPLINE_EDGE_CHAIN, null);
}
}
use of org.eclipse.elk.core.util.IElkProgressMonitor in project elk by eclipse.
the class MaxSTPhase method process.
@Override
public void process(final Graph graph, final IElkProgressMonitor progressMonitor) {
progressMonitor.begin("Maximum spanning tree construction", 1);
// inverted cost function
ICostFunction invertedCF = e -> {
return -graph.costFunction.cost(e);
};
KVector root;
if (graph.preferredRoot != null) {
root = graph.preferredRoot.vertex;
} else {
root = graph.vertices.get(0).vertex;
}
Tree<KVector> tree;
if (graph.getProperty(InternalProperties.DEBUG_SVG)) {
tree = NaiveMinST.createSpanningTree(graph.tEdges, root, invertedCF, ElkUtil.debugFolderPath("spore") + "20minst");
} else {
tree = NaiveMinST.createSpanningTree(graph.tEdges, root, invertedCF);
}
// convert result to a Tree that can be used in the execution phase
convert(tree, graph);
progressMonitor.done();
}
use of org.eclipse.elk.core.util.IElkProgressMonitor in project elk by eclipse.
the class MonitoredOperation method runOperation.
/**
* Runs the operation after synchronization with the UI handler.
*
* @param display the current display
* @param monitor the progress monitor wrapper
* @param status the returned status
*/
private void runOperation(final Display display, final Maybe<IProgressMonitor> monitor, final Maybe<IStatus> status) {
try {
synchronized (monitor) {
while (monitor.get() == null && !isCanceled()) {
try {
monitor.wait();
} catch (InterruptedException exception) {
// ignore exception
}
}
}
if (status.get() == null && !isCanceled()) {
IPreferenceStore prefStore = ElkServicePlugin.getInstance().getPreferenceStore();
IElkProgressMonitor monAdapt = new ProgressMonitorAdapter(monitor.get(), MAX_PROGRESS_LEVELS).withLogging(prefStore.getBoolean(DiagramLayoutEngine.PREF_DEBUG_LOGGING)).withExecutionTimeMeasurement(prefStore.getBoolean(DiagramLayoutEngine.PREF_DEBUG_EXEC_TIME));
status.set(execute(monAdapt));
assert status.get() != null;
}
} finally {
synchronized (status) {
if (status.get() == null) {
status.set(Status.OK_STATUS);
}
display.wake();
}
}
}
use of org.eclipse.elk.core.util.IElkProgressMonitor in project elk by eclipse.
the class ElkLayered method doCompoundLayout.
// //////////////////////////////////////////////////////////////////////////////
// Compound Graph Layout
/**
* Does a layout on the given compound graph. Connected components processing is currently not
* supported.
*
* @param lgraph the graph to layout
* @param monitor a progress monitor to show progress information in, or {@code null}
*/
public void doCompoundLayout(final LGraph lgraph, final IElkProgressMonitor monitor) {
IElkProgressMonitor theMonitor = monitor;
if (theMonitor == null) {
theMonitor = new BasicProgressMonitor().withMaxHierarchyLevels(0);
}
// SUPPRESS CHECKSTYLE MagicNumber
theMonitor.begin("Layered layout", 2);
// Preprocess the compound graph by splitting cross-hierarchy edges
notifyProcessorReady(lgraph, compoundGraphPreprocessor);
compoundGraphPreprocessor.process(lgraph, theMonitor.subTask(1));
notifyProcessorFinished(lgraph, compoundGraphPreprocessor);
hierarchicalLayout(lgraph, theMonitor.subTask(1));
// Postprocess the compound graph by combining split cross-hierarchy edges
notifyProcessorReady(lgraph, compoundGraphPostprocessor);
compoundGraphPostprocessor.process(lgraph, theMonitor.subTask(1));
notifyProcessorFinished(lgraph, compoundGraphPostprocessor);
theMonitor.done();
}
Aggregations