+
+ while (true) {
+ List<PipeControlPoint> points = getControlPoints(pipeRun);
+ PipeControlPoint pcp = points.get(0);
+ if (pcp.isSizeChange() && pcp.getChildPoints().size() > 0) {
+ pipeRun = pcp.getPipeRun();
+ } else {
+ break;
+ }
+ }
+ List<PipeRun> all = new ArrayList<PipeRun>();
+ List<List<PipeControlPoint>> pcps = new ArrayList<List<PipeControlPoint>>();
+ while (true) {
+ all.add(pipeRun);
+ List<PipeControlPoint> points = getControlPoints(pipeRun);
+ pcps.add(points);
+ PipeControlPoint pcp = points.get(points.size()-1);
+ if (pcp.getChildPoints().size() > 0) {
+ PipeRun pipeRun2 = pcp.getChildPoints().get(0).getPipeRun();
+ if (pipeRun == pipeRun2)
+ break;
+ else
+ pipeRun = pipeRun2;
+ } else {
+ break;
+ }
+ }
+ for (int i = 0 ; i < all.size(); i++) {
+ List<PipeControlPoint> list = pcps.get(i);
+ _reverse(list);
+ }
+ for (int i = 0 ; i < all.size(); i++) {
+ boolean last = i == all.size() - 1;
+ List<PipeControlPoint> list = pcps.get(i);
+
+ if (!last) {
+ List<PipeControlPoint> list2 = pcps.get(i+1);
+ PipeControlPoint prev = list.get(list.size()-1);
+ PipeControlPoint next = list2.get(0);
+ System.out.println();
+ if (prev == next) {
+ // Reverse the component on the boundary.
+ InlineComponent ic = (InlineComponent)prev.getPipelineComponent();
+ PipeRun r1 = ic.getPipeRun();
+ PipeRun r2 = ic.getAlternativePipeRun();
+ if (r1 == null || r2 == null)
+ throw new RuntimeException("Components on PipeRun changes should refer to bot PipeRuns");
+ ic.deattach();
+ r2.addChild(ic);
+ ic.setPipeRun(r2);
+ ic.setAlternativePipeRun(r1);
+ } else {
+ throw new RuntimeException("PipeRun changes should contain shared control points");
+ }
+
+ }
+ }
+
+ }
+
+ private static void _reverse(List<PipeControlPoint> list) {