Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] proposed possible patch for zest 2.0

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;
+ }
}


Back to the top