Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Dietisheim2010-03-10 23:36:37 +0000
committerAndre Dietisheim2010-03-10 23:36:37 +0000
commit1a85121b9744d76165dbda3b9d3201239baff8ec (patch)
treea53ffe33aac620cedf6d19cc063bd7cd0737dafb /plugins/org.eclipse.emf.cdo.ui.branch/src/org
parentf1480a0b3faf9ed5ddc5d27b90f1b86a9fbb2dec (diff)
downloadcdo-1a85121b9744d76165dbda3b9d3201239baff8ec.tar.gz
cdo-1a85121b9744d76165dbda3b9d3201239baff8ec.tar.xz
cdo-1a85121b9744d76165dbda3b9d3201239baff8ec.zip
removed state from BranchLayoutStrategy, made BranchLayoutStrategy global to all BranchView's
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.ui.branch/src/org')
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchLayoutStrategy.java212
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchTreeLayoutAlgorithm.java17
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchView.java84
3 files changed, 160 insertions, 153 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchLayoutStrategy.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchLayoutStrategy.java
index 3423b63015..f486290b74 100644
--- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchLayoutStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchLayoutStrategy.java
@@ -20,10 +20,6 @@ import org.eclipse.zest.layouts.dataStructures.DisplayIndependentDimension;
import org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle;
import org.eclipse.zest.layouts.dataStructures.InternalNode;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
/**
* A strategy that layouts a branch. A branch centers its (sibling) nodes below each other while using their time stamp
* to set the y coordinate. Sub-Branches are displaced to the right or to the left (left and right sub branches are
@@ -35,18 +31,18 @@ import java.util.List;
*/
public class BranchLayoutStrategy
{
- private final SubBranchSproutingStrategy SPROUT_RIGHT = new SubBranchSproutingStrategy()
+ private final SubBranchSproutingStrategy sproutRight = new SubBranchSproutingStrategy()
{
@Override
- protected void addSubBranchReference(BranchView branch)
+ protected void addSubBranchReference(BranchView branchView, BranchView subBranchView)
{
- rightSproutingBranches.addFirst(branch);
+ branchView.addRightSproutingBranch(subBranchView);
}
@Override
- protected BranchView getLatestSubBranch()
+ protected BranchView getLatestSubBranch(BranchView branchView)
{
- return rightSproutingBranches.peekFirst();
+ return branchView.getLatestRightSubBranchView();
}
@Override
@@ -56,7 +52,7 @@ public class BranchLayoutStrategy
InternalNode branchPointInternalNode = BranchTreeUtils.getInternalNode(branchPointNode);
return new DisplayIndependentDimension( //
// translate branch completely to visible area
- Math.abs(subBranch.getLayoutStrategy().getBounds().x)
+ Math.abs(subBranch.getBounds().x)
// add branch point position and its width
+ branchPointInternalNode.getInternalX() + branchPointInternalNode.getInternalWidth() //
// add padding
@@ -66,24 +62,24 @@ public class BranchLayoutStrategy
@Override
protected DisplayIndependentDimension getTranslationToLatterBranch(BranchView subBranch, BranchView latterBranch)
{
- ExtendedDisplayIndependentRectangle latterBranchBounds = latterBranch.getLayoutStrategy().getBounds();
+ ExtendedDisplayIndependentRectangle latterBranchBounds = latterBranch.getBounds();
return new DisplayIndependentDimension(//
latterBranchBounds.x + latterBranchBounds.width, 0);
}
};
- private final SubBranchSproutingStrategy SPROUT_LEFT = new SubBranchSproutingStrategy()
+ private final SubBranchSproutingStrategy sproutLeft = new SubBranchSproutingStrategy()
{
@Override
- protected void addSubBranchReference(BranchView branch)
+ protected void addSubBranchReference(BranchView branchView, BranchView subBranchView)
{
- leftSproutingBranches.addFirst(branch);
+ branchView.addLeftSproutingBranch(subBranchView);
}
@Override
- protected BranchView getLatestSubBranch()
+ protected BranchView getLatestSubBranch(BranchView branchView)
{
- return leftSproutingBranches.peekFirst();
+ return branchView.getLatestLeftSubBranchView();
}
@Override
@@ -91,7 +87,7 @@ public class BranchLayoutStrategy
BranchPointNode branchPointNode)
{
InternalNode branchPointInternalNode = BranchTreeUtils.getInternalNode(branchPointNode);
- DisplayIndependentRectangle subBranchBounds = subBranch.getLayoutStrategy().getBounds();
+ DisplayIndependentRectangle subBranchBounds = subBranch.getBounds();
return new DisplayIndependentDimension(-( //
// translate completely to invisible area
subBranchBounds.width + subBranchBounds.x
@@ -102,62 +98,55 @@ public class BranchLayoutStrategy
}
@Override
- protected DisplayIndependentDimension getTranslationToLatterBranch(BranchView subBranch, BranchView latterBranch)
+ protected DisplayIndependentDimension getTranslationToLatterBranch(BranchView subBranch, BranchView latterBranchView)
{
- DisplayIndependentRectangle latterBranchBounds = latterBranch.getLayoutStrategy().getBounds();
+ DisplayIndependentRectangle latterBranchBounds = latterBranchView.getBounds();
return new DisplayIndependentDimension( //
latterBranchBounds.x - getBranchPadding(), 0);
}
};
- private SubBranchSproutingStrategy currentSproutingStrategy = SPROUT_RIGHT;
-
- // protected Deque<AbstractBranchPointNode> nodeDeque = new Deque<AbstractBranchPointNode>();
- //
- // private Deque<BranchView> leftSproutingBranches = new Deque<BranchView>();
- //
- // private Deque<BranchView> rightSproutingBranches = new Deque<BranchView>();
- //
- // private ExtendedDisplayIndependentRectangle bounds;
- //
- // private ExtendedDisplayIndependentRectangle siblingBounds;
+ private SubBranchSproutingStrategy currentSproutingStrategy = sproutRight;
protected BranchLayoutStrategy()
{
}
- public void setRootNode(AbstractBranchPointNode node)
+ public void layoutBaselineNode(BranchView branchView, AbstractBranchPointNode node)
{
- nodeDeque.add(node);
BranchTreeUtils.setInternalSize(node);
- setRootNodeLocation(node);
- initBranchBounds(node);
+ setBaselineNodeLocation(node);
+ initBranchBounds(branchView, node);
}
- protected void initBranchBounds(AbstractBranchPointNode node)
+ protected void initBranchBounds(BranchView branchView, AbstractBranchPointNode node)
{
- InternalNode rootInternalNode = BranchTreeUtils.getInternalNode(node);
- bounds = new ExtendedDisplayIndependentRectangle(rootInternalNode.getInternalX(), rootInternalNode.getInternalY(),
- rootInternalNode.getInternalWidth(), rootInternalNode.getInternalHeight());
- siblingBounds = new ExtendedDisplayIndependentRectangle(bounds);
+ InternalNode baselineInternalNode = BranchTreeUtils.getInternalNode(node);
+ ExtendedDisplayIndependentRectangle bounds = new ExtendedDisplayIndependentRectangle(baselineInternalNode
+ .getInternalX(), baselineInternalNode.getInternalY(), baselineInternalNode.getInternalWidth(),
+ baselineInternalNode.getInternalHeight());
+ branchView.setBounds(bounds);
}
/**
- * Layout the given node as sibling node of the root (and its siblings) node.
+ * Layout the given node as sibling node to the baseline node (and its siblings).
+ *
+ * @param branchView
+ * the branch view to layout the node to
+ * @param node
+ * the node to layout
*/
- public void addNode(AbstractBranchPointNode node)
+ public void layoutNode(BranchView branchView, AbstractBranchPointNode node, AbstractBranchPointNode previousNode)
{
- AbstractBranchPointNode previousNode = nodeDeque.peekLast();
- nodeDeque.add(node);
BranchTreeUtils.setInternalSize(node);
setSiblingNodeLocation(node, previousNode);
- setBranchBounds(node);
+ setBranchBounds(branchView, node);
}
/**
* Sets the bounds of the given node. The node is centered horizontally to the given previous node.
*/
- protected void setRootNodeLocation(AbstractBranchPointNode node)
+ protected void setBaselineNodeLocation(AbstractBranchPointNode node)
{
BranchTreeUtils.setInternalSize(node);
@@ -179,17 +168,11 @@ public class BranchLayoutStrategy
* Sets the bounds of the current branch for the given additional node. The bounds are expanded if the size of the
* node requires it.
*/
- protected void setBranchBounds(AbstractBranchPointNode node)
+ protected void setBranchBounds(BranchView branchView, AbstractBranchPointNode node)
{
InternalNode internalNode = BranchTreeUtils.getInternalNode(node);
- bounds.union( //
- internalNode.getInternalX() //
- , internalNode.getInternalY() //
- , internalNode.getInternalWidth() //
- , internalNode.getInternalHeight());
-
- siblingBounds.union(//
+ branchView.getBounds().union( //
internalNode.getInternalX() //
, internalNode.getInternalY() //
, internalNode.getInternalWidth() //
@@ -202,39 +185,30 @@ public class BranchLayoutStrategy
* previous one to the left etc. .
*
* @param branchPointNode
- * the node on the current branch, the sub-branch's attached to
- * @param subBranch
- * the sub branch to add
- * @return the branch that precedes the given branch
+ * the node on the current branch view that the sub-branch view shall be attached to
+ * @param subBranchView
+ * the sub branch view to add
+ * @param branchView
+ * the branch view
*/
- public void layoutBranch(BranchView subBranch, BranchPointNode branchPointNode)
+ public void layoutBranch(BranchView branchView, BranchView subBranchView, BranchPointNode branchPointNode)
{
- if (subBranch != null)
+ if (subBranchView != null)
{
- currentSproutingStrategy.setSubBranchLocation(subBranch, branchPointNode);
- bounds.union(subBranch.getLayoutStrategy().getBounds());
+ currentSproutingStrategy.setSubBranchLocation(branchView, subBranchView, branchPointNode);
+ branchView.getBounds().union(subBranchView.getBounds());
currentSproutingStrategy.switchSproutingStrategy();
}
}
/**
- * Gets all nodes within this branch.
- *
- * @see AbstractBranchPointNode
- */
- public Collection<AbstractBranchPointNode> getNodes()
- {
- return nodeDeque;
- }
-
- /**
* Translates this branch by the given dimension.
*/
- public void translate(DisplayIndependentDimension dimension)
+ public void translate(BranchView branchView, DisplayIndependentDimension dimension)
{
- translateSiblingNodes(dimension);
- translateSubBranches(dimension);
- bounds.translate(dimension.width, dimension.height);
+ translateSiblingNodes(branchView, dimension);
+ translateSubBranches(branchView, dimension);
+ branchView.getBounds().translate(dimension.width, dimension.height);
}
/**
@@ -243,100 +217,74 @@ public class BranchLayoutStrategy
* @param dimension
* the dimension to translate this branch by
*/
- private void translateSubBranches(DisplayIndependentDimension dimension)
+ private void translateSubBranches(BranchView branchView, DisplayIndependentDimension dimension)
{
- for (BranchView branch : getSubBranches())
+ for (BranchView branch : branchView.getSubBranches())
{
- branch.getLayoutStrategy().translate(dimension);
+ branch.getLayoutStrategy().translate(branchView, dimension);
}
}
/**
- * Returns all sub branches of this branch.
- *
- * @return the sub branches
- */
- Collection<BranchView> getSubBranches()
- {
- List<BranchView> branchList = new ArrayList<BranchView>(leftSproutingBranches);
- branchList.addAll(rightSproutingBranches);
- return branchList;
- }
-
- /**
* Translates all the sibling nodes of this branch by the given horizontal and vertical offset.
*/
- private void translateSiblingNodes(DisplayIndependentDimension dimension)
+ private void translateSiblingNodes(BranchView branchView, DisplayIndependentDimension dimension)
{
- for (AbstractBranchPointNode node : getNodes())
+ for (AbstractBranchPointNode node : branchView.getNodes())
{
BranchTreeUtils.translateInternalLocation(node, dimension.width, dimension.height);
}
}
/**
- * Returns whether the bounds of the given branch intersects the bounds of this branch.
- *
- * @return true, if the given branch intersects this branch
- */
- boolean collidesWith(BranchView branch)
- {
- return bounds.bottomEndsBefore(branch.getLayoutStrategy().bounds);
- }
-
- /**
- * Gets the bounds.
- */
- ExtendedDisplayIndependentRectangle getBounds()
- {
- return bounds;
- }
-
- /**
* A layout strategy that handles the layout of sub branches in this branch
*/
protected abstract class SubBranchSproutingStrategy
{
/**
- * Adds the reference to the sub branch.
+ * Adds the given sub branch view reference to the given branch view.
*
- * @param branch
- * the branch
+ * @param branchView
+ * the branch view to add the sub branch to
+ * @param subBranchView
+ * the sub branch view to add
*/
- protected abstract void addSubBranchReference(BranchView branch);
+ protected abstract void addSubBranchReference(BranchView branchView, BranchView subBranchView);
/**
- * Gets the latest sub branch.
+ * Gets the latest sub branch of the given sub branch view.
*
+ * @param branchView
+ * the branch view to retrieve the latest sub branch from
* @return the latest sub branch
*/
- protected abstract BranchView getLatestSubBranch();
+ protected abstract BranchView getLatestSubBranch(BranchView branchView);
/**
- * Sets the location of the given sub branch in the current branch. Branches are created and located with their root
- * node at x == 0, y == 0. The bounds of the sub branch (and its sub sub-branches) are from negative x-coordinates
- * up to positive x-coordinates. The purpose of this method is to translate the whole sub branch to the correct
- * location to the right or to the left of its branch point.
+ * Sets the location of the given sub branch in the current branch. Branches are created and located with their
+ * baseline node at x == 0, y == 0. The bounds of the sub branch (and its sub sub-branches) are from negative
+ * x-coordinates up to positive x-coordinates. The purpose of this method is to translate the whole sub branch to
+ * the correct location to the right or to the left of its branch point.
*
- * @param subBranch
+ * @param subBranchView
* the sub branch to layout in the current branch
+ * @param subBranchView2
* @param branchPointNode
* the branch point node the given sub branch is attached to
*/
- void setSubBranchLocation(BranchView subBranch, BranchPointNode branchPointNode)
+ void setSubBranchLocation(BranchView subBranchView, BranchView branchView, BranchPointNode branchPointNode)
{
// translate branch off the branchPointNode (to the right or to the left)
- DisplayIndependentDimension translation = getTranslationToBranchPoint(subBranch, branchPointNode);
- ExtendedDisplayIndependentRectangle subBranchBounds = subBranch.getLayoutStrategy().getBounds();
- BranchView latterBranch = currentSproutingStrategy.getLatestSubBranch();
- if (latterBranch != null && !subBranchBounds.bottomEndsBefore(latterBranch.getLayoutStrategy().getBounds()))
+ DisplayIndependentDimension translation = getTranslationToBranchPoint(subBranchView, branchPointNode);
+ BranchView latterBranch = currentSproutingStrategy.getLatestSubBranch(branchView);
+ if (latterBranch != null && !subBranchView.getBounds().bottomEndsBefore(latterBranch.getBounds()))
{
// collides vertically with latter sub-branch -> additionally translate off latter branch (to the right or to
// the left)
- translation = GeometryUtils.union(translation, getTranslationToLatterBranch(subBranch, latterBranch));
+ translation = GeometryUtils.union(translation, getTranslationToLatterBranch(subBranchView, latterBranch));
}
- subBranch.getLayoutStrategy().translate(translation);
- addSubBranchReference(subBranch);
+ translate(subBranchView, translation);
+ addSubBranchReference(branchView, subBranchView);
}
/**
@@ -371,13 +319,13 @@ public class BranchLayoutStrategy
*/
protected void switchSproutingStrategy()
{
- if (currentSproutingStrategy == SPROUT_RIGHT)
+ if (currentSproutingStrategy == sproutRight)
{
- currentSproutingStrategy = SPROUT_LEFT;
+ currentSproutingStrategy = sproutLeft;
}
else
{
- currentSproutingStrategy = SPROUT_RIGHT;
+ currentSproutingStrategy = sproutRight;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchTreeLayoutAlgorithm.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchTreeLayoutAlgorithm.java
index f7004c5e34..602a30e4b2 100644
--- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchTreeLayoutAlgorithm.java
+++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchTreeLayoutAlgorithm.java
@@ -10,11 +10,11 @@
*/
package org.eclipse.emf.cdo.ui.internal.branch.layout;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.ui.internal.branch.item.AbstractBranchPointNode;
import org.eclipse.emf.cdo.ui.internal.branch.item.BranchTreeUtils;
import org.eclipse.emf.cdo.ui.internal.branch.item.RootNode;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.zest.layouts.LayoutStyles;
import org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm;
import org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle;
@@ -54,21 +54,25 @@ public class BranchTreeLayoutAlgorithm extends AbstractLayoutAlgorithm
this(LayoutStyles.NONE);
}
+ @Override
public void setLayoutArea(double x, double y, double width, double height)
{
throw new RuntimeException();
}
+ @Override
protected int getCurrentLayoutStep()
{
return 0;
}
+ @Override
protected int getTotalNumberOfLayoutSteps()
{
return LAYOUT_STEPS;
}
+ @Override
protected void preLayoutAlgorithm(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider,
double x, double y, double width, double height)
{
@@ -77,8 +81,6 @@ public class BranchTreeLayoutAlgorithm extends AbstractLayoutAlgorithm
if (entitiesToLayout.length > 0)
{
initRootAndLatestNode(entitiesToLayout);
- Assert.isTrue(rootNode != null, "root node was not found");
- Assert.isTrue(latestNode != null, "latest node was not found");
}
}
@@ -101,15 +103,15 @@ public class BranchTreeLayoutAlgorithm extends AbstractLayoutAlgorithm
{
rootNode = (RootNode)node.getLatter(rootNode);
}
- latestNode = (AbstractBranchPointNode)node.getLatter(latestNode);
+ latestNode = node.getLatter(latestNode);
}
}
}
+ @Override
protected void applyLayoutInternal(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider,
double boundsX, double boundsY, double boundsWidth, double boundsHeight)
{
-
if (entitiesToLayout.length > 0)
{
buildBranch(rootNode);
@@ -120,15 +122,18 @@ public class BranchTreeLayoutAlgorithm extends AbstractLayoutAlgorithm
private BranchView buildBranch(AbstractBranchPointNode branchRootNode)
{
- return new BranchView(branchRootNode);
+ CDOBranch branch = branchRootNode.getBranch();
+ return new BranchView(branch, branchRootNode, new BranchLayoutStrategy());
}
+ @Override
protected void postLayoutAlgorithm(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider)
{
updateLayoutLocations(entitiesToLayout);
fireProgressEvent(LAYOUT_STEPS, LAYOUT_STEPS);
}
+ @Override
protected boolean isValidConfiguration(boolean asynchronous, boolean continueous)
{
if (asynchronous && continueous)
diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchView.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchView.java
index f9d12cbb24..5a8f3b0850 100644
--- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchView.java
+++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchView.java
@@ -15,11 +15,13 @@ import org.eclipse.emf.cdo.ui.internal.branch.geometry.ExtendedDisplayIndependen
import org.eclipse.emf.cdo.ui.internal.branch.item.AbstractBranchPointNode;
import org.eclipse.emf.cdo.ui.internal.branch.item.BranchPointNode;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
/**
- * A Branch is a structure that holds the root node of a branch. Its main purpose is to climb through the branch tree
- * and call the layout strategy on all nodes in an appropriate manner.
+ * A Branch is a structure that holds the baseline node of a branch. Its main purpose is to climb through the branch
+ * tree and call the layout strategy on all nodes in an appropriate manner.
* <p>
* The strategy is to first lay out all (sibling) nodes in the order of their time stamp. Sub-branches are skipped. In a
* second step all branches are positioned while beginning with the latest one (in terms of time stamp).
@@ -33,8 +35,6 @@ public class BranchView
private AbstractBranchPointNode baselineNode;
- private BranchLayoutStrategy layoutStrategy = new BranchLayoutStrategy();
-
protected Deque<AbstractBranchPointNode> nodes = new Deque<AbstractBranchPointNode>();
private Deque<BranchView> leftSproutingBranchViews = new Deque<BranchView>();
@@ -43,20 +43,22 @@ public class BranchView
private ExtendedDisplayIndependentRectangle bounds;
- private ExtendedDisplayIndependentRectangle siblingBounds;
+ private BranchLayoutStrategy layoutStrategy;
- public BranchView(CDOBranch branch, AbstractBranchPointNode baselineNode)
+ public BranchView(CDOBranch branch, AbstractBranchPointNode baselineNode, BranchLayoutStrategy layoutStrategy)
{
this.branch = branch;
this.baselineNode = baselineNode;
- layoutStrategy.setRootNode(baselineNode);
+ this.layoutStrategy = layoutStrategy;
+ nodes.add(baselineNode);
+ layoutStrategy.layoutBaselineNode(this, baselineNode);
addNode(baselineNode.getNextSibling());
if (baselineNode instanceof BranchPointNode)
{
// add a branch to this node
BranchPointNode branchpointNode = (BranchPointNode)baselineNode;
- addBranchView(branchpointNode.getNextChild(), branchpointNode);
+ addBranchView(branch, branchpointNode.getNextChild(), branchpointNode);
}
}
@@ -103,7 +105,8 @@ public class BranchView
{
if (node != null)
{
- layoutStrategy.addNode(node);
+ AbstractBranchPointNode previousNode = nodes.peekLast();
+ layoutStrategy.layoutNode(this, node, previousNode);
// recursively navigate to sibling
addNode(node.getNextSibling());
@@ -111,20 +114,71 @@ public class BranchView
{
// add a branch to this node
BranchPointNode branchpointNode = (BranchPointNode)node;
- addBranchView(branchpointNode.getNextChild(), branchpointNode);
+ addBranchView(branch, branchpointNode.getNextChild(), branchpointNode);
}
}
}
/**
- * Adds a sub-branch to the given branch point node with the given root node.
+ * Adds a sub-branch to the given branch point node with the given baseline node.
*/
- private void addBranchView(CDOBranch branch, AbstractBranchPointNode rootNode, BranchPointNode branchPointNode)
+ private void addBranchView(CDOBranch branch, AbstractBranchPointNode baselineNode, BranchPointNode branchPointNode)
{
- if (rootNode != null)
+ if (baselineNode != null)
{
- BranchView subBranch = new BranchView(branch, rootNode);
- layoutStrategy.layoutBranch(subBranch, branchPointNode);
+ BranchView subBranch = new BranchView(branch, baselineNode, layoutStrategy);
+ layoutStrategy.layoutBranch(this, subBranch, branchPointNode);
}
}
+
+ /**
+ * Returns the bounds of this branch view. The bounds returned contain all sub-branches (and their nodes)
+ *
+ * @return the bounds
+ * @see #getNudeBranchBounds()
+ */
+ public ExtendedDisplayIndependentRectangle getBounds()
+ {
+ return bounds;
+ }
+
+ /**
+ * Sets the bounds of this branch view. The bounds must contain this branch and all its sub branch views (and all
+ * their nodes)
+ *
+ * @param bounds
+ * the new bounds
+ */
+ public void setBounds(ExtendedDisplayIndependentRectangle bounds)
+ {
+ this.bounds = bounds;
+ }
+
+ public void addLeftSproutingBranch(BranchView branchView)
+ {
+ leftSproutingBranchViews.addFirst(branchView);
+ }
+
+ public void addRightSproutingBranch(BranchView branchView)
+ {
+ rightSproutingBranchViews.addFirst(branchView);
+ }
+
+ public BranchView getLatestRightSubBranchView()
+ {
+ return rightSproutingBranchViews.peekFirst();
+ }
+
+ public BranchView getLatestLeftSubBranchView()
+ {
+ return leftSproutingBranchViews.peekFirst();
+ }
+
+ public Collection<BranchView> getSubBranches()
+ {
+ List<BranchView> branchList = new ArrayList<BranchView>(leftSproutingBranchViews);
+ branchList.addAll(rightSproutingBranchViews);
+ return branchList;
+ }
+
}

Back to the top