| author | ujhelyiz | 2011-02-20 15:42:56 (EST) |
|---|---|---|
| committer | Fabian Steeg | 2011-02-20 19:57:46 (EST) |
| commit | a9321ada963c2291bfe4c5719f72e3d0620bc442 (patch) (side-by-side diff) | |
| tree | b6234d8fd29599b652492042ef449f03113af7ff | |
| parent | 155d5db1d93bcd45510c6d7d768f960041a1501a (diff) | |
| download | org.eclipse.gef4-a9321ada963c2291bfe4c5719f72e3d0620bc442.zip org.eclipse.gef4-a9321ada963c2291bfe4c5719f72e3d0620bc442.tar.gz org.eclipse.gef4-a9321ada963c2291bfe4c5719f72e3d0620bc442.tar.bz2 | |
Added support for default curved edges
| -rw-r--r-- | org.eclipse.zest.jface/src/org/eclipse/zest/core/viewers/internal/AbstractStylingModelFactory.java | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/org.eclipse.zest.jface/src/org/eclipse/zest/core/viewers/internal/AbstractStylingModelFactory.java b/org.eclipse.zest.jface/src/org/eclipse/zest/core/viewers/internal/AbstractStylingModelFactory.java index 0054e1e..16f379f 100644 --- a/org.eclipse.zest.jface/src/org/eclipse/zest/core/viewers/internal/AbstractStylingModelFactory.java +++ b/org.eclipse.zest.jface/src/org/eclipse/zest/core/viewers/internal/AbstractStylingModelFactory.java @@ -69,12 +69,13 @@ public abstract class AbstractStylingModelFactory implements if (dest != source) { leftList = getConnectionList(dest, source); } - + int size = (leftList != null) ? leftList.size() + rightList.size() + : rightList.size(); // adjust the arcs going from source to destination - adjustCurves(rightList); + adjustCurves(rightList, size); // adjust the arcs going from destination to source if (leftList != null) { - adjustCurves(leftList); + adjustCurves(leftList, size); } } @@ -83,31 +84,20 @@ public abstract class AbstractStylingModelFactory implements * the bezier curves based on the number of curves in the list. * * @param rightList + * @param size + * total number of arcs - may be bigger then connections.size */ - protected void adjustCurves(List connections) { - // @tag TODO curves : add back this code to adjust the curves - // int scale = 3; - // for (int i = 0; i < connections.size(); i++) { - // GraphConnection conn = (GraphConnection) connections.get(i); - // if (conn.getSource() == conn.getDestination()) { - // scale = 5; - // } - // // even if the connection isn't curved in the style, the edit part - // // may decide that it should be curved if source and dest are equal. - // // @tag drawing(arcs) : check here if arcs are too close when being - // // drawn. Adjust the constant. - // int lineWidth = conn.getLineWidth(); - // conn.setCurveDepth((i + 1) * (scale + lineWidth)); - // - // // @tag zest(bug(152530-Bezier(fix))) : set the angles, etc based on - // // the count. - // // limit the angle to 90 degrees. - // conn.setStartAngle(90.0 - 85.0 / Math.pow(i, 1.0 / 9.0)); - // conn.setEndAngle(85.0 / Math.pow(i, 1.0 / 9.0) - 90.0); - // // limit the length to 1 - // conn.setStartLength(.75 - .25 / (Math.sqrt(i))); - // conn.setEndLength(.75 - .25 / (Math.sqrt(i))); - // } + protected void adjustCurves(List connections, int size) { + for (int i = 0; i < connections.size(); i++) { + GraphConnection conn = (GraphConnection) connections.get(i); + int radius = 20; + if (conn.getSource() == conn.getDestination()) { + radius = 40; + } else if (size < 2) { + radius = 0; + } + conn.setCurveDepth((i + 1) * radius); + } } /** |

