diff --git a/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/YconstreeLayoutProvider.java b/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/YconstreeLayoutProvider.java index 56b8b1032..5d8222be2 100644 --- a/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/YconstreeLayoutProvider.java +++ b/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/YconstreeLayoutProvider.java @@ -16,6 +16,7 @@ import org.eclipse.elk.alg.yconstree.p4absolute.AbsoluteXPlacerStrategy; import org.eclipse.elk.alg.yconstree.p5edgerouting.EdgerouterStrategy; import org.eclipse.elk.core.AbstractLayoutProvider; +import org.eclipse.elk.core.UnsupportedConfigurationException; import org.eclipse.elk.core.alg.AlgorithmAssembler; import org.eclipse.elk.core.alg.ILayoutProcessor; import org.eclipse.elk.core.util.IElkProgressMonitor; @@ -40,14 +41,14 @@ public void layout(final ElkNode graph, final IElkProgressMonitor progressMonito ElkNode root = YconstreeUtil.findRoot(graph); graph.setProperty(InternalProperties.ROOT_NODE, root); if (root == null) { - throw new IllegalArgumentException("The given graph is not a tree!"); + throw new UnsupportedConfigurationException("The given graph is not a tree!"); } for (ElkNode child : graph.getChildren()) { int numberOfParents; numberOfParents = child.getIncomingEdges().size(); if (numberOfParents > 1) { - throw new IllegalArgumentException("The given graph is not an acyclic tree!"); + throw new UnsupportedConfigurationException("The given graph is not an acyclic tree!"); } } diff --git a/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p2yplacement/NodeYPlacer.java b/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p2yplacement/NodeYPlacer.java index c7da9d567..1246de53d 100644 --- a/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p2yplacement/NodeYPlacer.java +++ b/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p2yplacement/NodeYPlacer.java @@ -30,19 +30,14 @@ public class NodeYPlacer implements ILayoutPhase @Override public void process(final ElkNode graph, final IElkProgressMonitor progressMonitor) { - //elkGraph.setX(0.0); + myProgressMonitor = progressMonitor; myProgressMonitor.begin("YPlacer", 1); - try { - if (!graph.getChildren().isEmpty()) { - ElkNode parent = graph.getProperty(InternalProperties.ROOT_NODE); - setYLevels(parent, 0.0); - } - } catch (Exception e) { - // TODO Auto-generated catch block - // Handle this exception properly - e.printStackTrace(); + + if (!graph.getChildren().isEmpty()) { + ElkNode parent = graph.getProperty(InternalProperties.ROOT_NODE); + setYLevels(parent, 0.0); } myProgressMonitor.done(); @@ -58,7 +53,6 @@ private void setYLevels(final ElkNode node, double minHeight) { // TODO figure out what below todo means and whether it is still relevant // TODO: Y-Level_Constraints, remove different heightlevels. if (node.hasProperty(YconstreeOptions.VERTICAL_CONSTRAINT)) { - myProgressMonitor.log("hier hab ich einen Constraint"); minHeight = node.getProperty(YconstreeOptions.VERTICAL_CONSTRAINT); } node.setY(minHeight); diff --git a/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p3relative/RelativeXPlacer.java b/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p3relative/RelativeXPlacer.java index c9f6230e0..f2f511aa4 100644 --- a/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p3relative/RelativeXPlacer.java +++ b/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p3relative/RelativeXPlacer.java @@ -45,22 +45,16 @@ public void process(final ElkNode graph, final IElkProgressMonitor progressMonit spacingNodeNode = graph.getProperty(CoreOptions.SPACING_NODE_NODE); - try { - if (!graph.getChildren().isEmpty()) { - ElkNode parent = graph.getProperty(InternalProperties.ROOT_NODE); - - String strategy = graph.getProperty(YconstreeOptions.LAYOUT_STRATEGY); - if (strategy == null || strategy.equals("straight")) { //TODO use enum instead of string for strategy - yConsTreeStep(parent); - } else { - alternativeYConsTreeStep(parent); - } - + if (!graph.getChildren().isEmpty()) { + ElkNode parent = graph.getProperty(InternalProperties.ROOT_NODE); + + String strategy = graph.getProperty(YconstreeOptions.LAYOUT_STRATEGY); + if (strategy == null || strategy.equals("straight")) { //TODO use enum instead of string for strategy + yConsTreeStep(parent); + } else { + alternativeYConsTreeStep(parent); } - } catch (Exception e) { - // TODO properly handle exceptions - // TODO Auto-generated catch block - e.printStackTrace(); + } myProgressMonitor.done(); @@ -379,7 +373,7 @@ private void alternativeYConsTreeStep(final ElkNode graph) { */ private void sortSubTrees(final List children) { - // fist, we sort the SubTrees by the Y-coordinate of their root. + // first, we sort the SubTrees by the Y-coordinate of their root. Collections.sort(children, new NodeComparator()); // now we need to put them in a V-shape diff --git a/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p4absolute/AbsoluteXPlacer.java b/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p4absolute/AbsoluteXPlacer.java index 00eea121a..2bd4fb86b 100644 --- a/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p4absolute/AbsoluteXPlacer.java +++ b/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p4absolute/AbsoluteXPlacer.java @@ -29,23 +29,17 @@ public void process(final ElkNode graph, final IElkProgressMonitor progressMonit myProgressMonitor = progressMonitor; myProgressMonitor.begin("AbsolutPlacer", 1); - try { - if (!graph.getChildren().isEmpty()) { - ElkNode parent = graph.getProperty(InternalProperties.ROOT_NODE); - - // first, move the root - parent.setX(parent.getX() - findMinimalX(parent)); - // a little offset - parent.setX(parent.getX() + 10.0); // TODO remove magic number - // now we update the whole tree to absolute X - absoluteTreeCoords(parent); - } - } catch (Exception e) { - // TODO properly handle exception - // TODO Auto-generated catch block - e.printStackTrace(); + if (!graph.getChildren().isEmpty()) { + ElkNode parent = graph.getProperty(InternalProperties.ROOT_NODE); + + // first, move the root + parent.setX(parent.getX() - findMinimalX(parent)); + // a little offset + parent.setX(parent.getX() + 10.0); // TODO remove magic number + // now we update the whole tree to absolute X + absoluteTreeCoords(parent); } - + myProgressMonitor.done(); } diff --git a/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p5edgerouting/Edgerouter.java b/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p5edgerouting/Edgerouter.java index 90e431700..b35d8e9f2 100644 --- a/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p5edgerouting/Edgerouter.java +++ b/plugins/org.eclipse.elk.alg.yconstree/src/org/eclipse/elk/alg/yconstree/p5edgerouting/Edgerouter.java @@ -35,19 +35,13 @@ public void process(final ElkNode graph, final IElkProgressMonitor progressMonit myProgressMonitor = progressMonitor; myProgressMonitor.begin("EdgeRouter", 1); - try { - if (!graph.getChildren().isEmpty()) { - ElkNode parent = graph.getProperty(InternalProperties.ROOT_NODE); - - routeEdges(parent); - setCanvas(graph); - } - } catch (Exception e) { - // TODO properly handle exceptions - // TODO Auto-generated catch block - e.printStackTrace(); + if (!graph.getChildren().isEmpty()) { + ElkNode parent = graph.getProperty(InternalProperties.ROOT_NODE); + + routeEdges(parent); + setCanvas(graph); } - + myProgressMonitor.done(); }