From fada619b17a4c7c4cfb7a4eaac2875a4d6ebf28c Mon Sep 17 00:00:00 2001 From: Paul Richardson Date: Mon, 17 May 2010 09:48:54 +0100 Subject: [PATCH] Changes to GraphContainer to improve flexibility * Make pack public so it can be overrided and avoid moving nodes up/down * Make moveNodesUp and moveNodesDown public so they can be overridden * isExpanded getter so other components know when node is open/closed * Since getScale() is not supported in AspectRatioFreeformLayer, changes getScale() to getScaleWidth() and getScaleHeight(). Likewise, for setScale. * computerContainerSize() assumes childAreaHeight remains the same. If the container height is altered then it cannot be reduced. Change ensures that it has a minimum height but allows for the height to be reduced. * refreshLocation() is called after the size of the container has been set, which potentially puts the size of the GraphContainer out of sync with the size of the figure. This causes problems with resizing. Thus, fix to set the size of the GraphContainer to match the figure. --- .../eclipse/zest/core/widgets/GraphContainer.java | 39 ++++++++++++++------ 1 files changed, 28 insertions(+), 11 deletions(-) diff --git a/zest.core/src/org/eclipse/zest/core/widgets/GraphContainer.java b/zest.core/src/org/eclipse/zest/core/widgets/GraphContainer.java index 68464ea..6772502 100644 --- a/zest.core/src/org/eclipse/zest/core/widgets/GraphContainer.java +++ b/zest.core/src/org/eclipse/zest/core/widgets/GraphContainer.java @@ -53,7 +53,7 @@ public class GraphContainer extends GraphNode implements IContainer { private static final double scaledHeight = 200; private static final int CONTAINER_HEIGHT = 200; private static final int MIN_WIDTH = 250; - private static final int ANIMATION_TIME = 100; + protected static final int ANIMATION_TIME = 100; private static final int SUBLAYER_OFFSET = 2; private ExpandGraphLabel expandGraphLabel; @@ -203,7 +203,7 @@ public class GraphContainer extends GraphNode implements IContainer { return (node.getBounds().x < right && node.getBounds().x + node.getBounds().width > left); } - void pack(Graph g) { + public void pack(Graph g) { GraphNode highestNode = getHighestNode(g); moveNodesUp(highestNode.getBounds(), highestNode); } @@ -232,7 +232,7 @@ public class GraphContainer extends GraphNode implements IContainer { * @param containerBounds * @param graphContainer */ - private void moveNodesUp(Rectangle containerBounds, GraphNode graphContainer) { + public void moveNodesUp(Rectangle containerBounds, GraphNode graphContainer) { // Get all nodes below this container, in order List orderedNodesBelowY = getOrderedNodesBelowY(parent.getNodes(), containerBounds.y, graphContainer); @@ -320,12 +320,16 @@ public class GraphContainer extends GraphNode implements IContainer { } + public boolean isExpanded() { + return isExpanded; + } + /** * * @param containerBounds * @param graphContainer */ - private void moveNodesDown(Rectangle containerBounds, GraphContainer graphContainer) { + public void moveNodesDown(Rectangle containerBounds, GraphContainer graphContainer) { // Find all nodes below here List nodesBelowHere = getOrderedNodesBelowY(parent.getNodes(), containerBounds.y, graphContainer); @@ -559,19 +563,29 @@ public class GraphContainer extends GraphNode implements IContainer { } /** - * Get the scale for this container. This is the scale applied to the children contained within + * Get the width scale for this container. This is the width scale applied to the children contained within + * + * @return + */ + public double getWidthScale() { + return this.scalledLayer.getWidthScale(); + } + + /** + * Get the height scale for this container. This is the height scale applied to the children contained within + * * @return */ - public double getScale() { - return this.scalledLayer.getScale(); + public double getHeightScale() { + return this.scalledLayer.getHeightScale(); } /** * Set the scale for this container. This is the scale applied to the children contained within. * @param scale */ - public void setScale(double scale) { - this.scalledLayer.setScale(scale); + public void setScale(double width, double height) { + this.scalledLayer.setScale(width, height); } /*************************************************************************** @@ -623,8 +637,8 @@ public class GraphContainer extends GraphNode implements IContainer { dimension.labelHeight = labelHeight; dimension.width = labelWidth; dimension.width = Math.max(dimension.width, this.size.width); - dimension.expandedHeight = dimension.labelHeight + childAreaHeight - SUBLAYER_OFFSET; - dimension.expandedHeight = Math.max(dimension.expandedHeight, this.size.height); + // dimension.expandedHeight = dimension.labelHeight + childAreaHeight - SUBLAYER_OFFSET; + dimension.expandedHeight = Math.max(dimension.labelHeight + CONTAINER_HEIGHT - SUBLAYER_OFFSET, this.size.height); return dimension; } @@ -796,6 +810,9 @@ public class GraphContainer extends GraphNode implements IContainer { size.width = containerDimension.width; size.height = containerDimension.labelHeight; } + this.size.width = size.width; + this.size.height = size.height; + Rectangle bounds = new Rectangle(loc, size); nodeFigure.getParent().setConstraint(nodeFigure, bounds); scrollPane.setLocation(new Point(expandGraphLabel.getLocation().x, expandGraphLabel.getLocation().y + containerDimension.labelHeight - SUBLAYER_OFFSET)); -- 1.7.0.2.msysgit.0