[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [gef-dev] proposed possible patch for zest 2.0
|
Yep, we can probably get this in.
For legal reasons it will have to come on a bug report. Can you file a bug report and put this patch there.
Thanks for all this work Miles. When I see positive results, it gives me the motivation to get all this stuff in place.
cheers,
ian
On Wed, Nov 11, 2009 at 10:59 AM, Miles Parker
<milesparker@xxxxxxxxx> wrote:
Hi guys,
Please see blog for more details.
http://milesparker.blogspot.com/2009/11/zest-for-life.html This is obviously self-serving :), but perhaps there are changes you could make along these lines -- perhaps just put an option for node-size favoring in Zest. Or feel free to use the FreeformtreeLayout class that I've got in the blog entry.
cheers,
Miles
Index: src/org/eclipse/zest/layouts/algorithms/TreeLayoutAlgorithm.java
===================================================================
--- src/org/eclipse/zest/layouts/algorithms/TreeLayoutAlgorithm.java (revision 170)
+++ src/org/eclipse/zest/layouts/algorithms/TreeLayoutAlgorithm.java (working copy)
@@ -57,6 +57,7 @@
private boolean resize = false;
+
private LayoutContext context;
private DisplayIndependentRectangle bounds;
@@ -72,6 +73,7 @@
setDirection(direction);
}
+
public int getDirection() {
return direction;
}
@@ -121,6 +123,10 @@
AlgorithmHelper.maximizeSizes(entities);
}
+ scaleEntities(entities);
+ }
+
+ protected void scaleEntities(EntityLayout[] entities) {
DisplayIndependentRectangle bounds2 = new DisplayIndependentRectangle(bounds);
AlgorithmHelper.fitWithinBounds(entities, bounds2, resize);
}
@@ -128,6 +134,17 @@
void internalApplyLayout() {
TreeNode superRoot = treeObserver.getSuperRoot();
bounds = context.getBounds();
+ updateLeafAndLayerSizes();
+ int leafCountSoFar = 0;
+ for (Iterator iterator = superRoot.getChildren().iterator(); iterator.hasNext();) {
+ TreeNode rootInfo = (TreeNode) iterator.next();
+ computePositionRecursively(rootInfo, leafCountSoFar);
+ leafCountSoFar = leafCountSoFar + rootInfo.numOfLeaves;
+ }
+ }
+
+ protected void updateLeafAndLayerSizes() {
+ TreeNode superRoot = treeObserver.getSuperRoot();
if (direction == TOP_DOWN || direction == BOTTOM_UP) {
leafSize = bounds.width / superRoot.numOfLeaves;
layerSize = bounds.height / superRoot.height;
@@ -135,12 +152,6 @@
leafSize = bounds.height / superRoot.numOfLeaves;
layerSize = bounds.width / superRoot.height;
}
- int leafCountSoFar = 0;
- for (Iterator iterator = superRoot.getChildren().iterator(); iterator.hasNext();) {
- TreeNode rootInfo = (TreeNode) iterator.next();
- computePositionRecursively(rootInfo, leafCountSoFar);
- leafCountSoFar = leafCountSoFar + rootInfo.numOfLeaves;
- }
}
/**
@@ -171,4 +182,12 @@
relativePosition += childInfo.numOfLeaves;
}
}
+
+ protected void setLeafSize(double leafSize) {
+ this.leafSize = leafSize;
+ }
+
+ protected void setLayerSize(double layerSize) {
+ this.layerSize = layerSize;
+ }
}
_______________________________________________
gef-dev mailing list
gef-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/gef-dev
--
R. Ian Bull | EclipseSource Victoria | +1 250 477 7484
http://eclipsesource.com |
http://twitter.com/eclipsesource