Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Dietisheim2010-03-11 00:02:56 +0000
committerAndre Dietisheim2010-03-11 00:02:56 +0000
commitcda97b9f8f97ce342731233aed3ca733db554c5a (patch)
tree95fff79dff9563608a60f3f45c57caab6cd5f431 /plugins/org.eclipse.emf.cdo.ui.branch
parent91b1f90a224256720055c26831e2fd3932bef7ae (diff)
downloadcdo-cda97b9f8f97ce342731233aed3ca733db554c5a.tar.gz
cdo-cda97b9f8f97ce342731233aed3ca733db554c5a.tar.xz
cdo-cda97b9f8f97ce342731233aed3ca733db554c5a.zip
BranchView now only has a single list of all sub branch views. layout strategies handle what sub branch view the want to get to check bounds collisions
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.ui.branch')
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchTreeLayoutAlgorithm.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchView.java69
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchViewLayoutStrategy.java (renamed from plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchLayoutStrategy.java)55
3 files changed, 37 insertions, 89 deletions
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 602a30e4b2..4e146392a6 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
@@ -123,7 +123,7 @@ public class BranchTreeLayoutAlgorithm extends AbstractLayoutAlgorithm
private BranchView buildBranch(AbstractBranchPointNode branchRootNode)
{
CDOBranch branch = branchRootNode.getBranch();
- return new BranchView(branch, branchRootNode, new BranchLayoutStrategy());
+ return new BranchView(branch, branchRootNode, new BranchViewLayoutStrategy());
}
@Override
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 5a8f3b0850..a7032e7b96 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,9 +15,7 @@ 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 baseline node of a branch. Its main purpose is to climb through the branch
@@ -27,7 +25,7 @@ import java.util.List;
* second step all branches are positioned while beginning with the latest one (in terms of time stamp).
*
* @author Andre Dietisheim
- * @see BranchLayoutStrategy
+ * @see BranchViewLayoutStrategy
*/
public class BranchView
{
@@ -37,15 +35,13 @@ public class BranchView
protected Deque<AbstractBranchPointNode> nodes = new Deque<AbstractBranchPointNode>();
- private Deque<BranchView> leftSproutingBranchViews = new Deque<BranchView>();
-
- private Deque<BranchView> rightSproutingBranchViews = new Deque<BranchView>();
+ private Deque<BranchView> subBranchViews = new Deque<BranchView>();
private ExtendedDisplayIndependentRectangle bounds;
- private BranchLayoutStrategy layoutStrategy;
+ private BranchViewLayoutStrategy layoutStrategy;
- public BranchView(CDOBranch branch, AbstractBranchPointNode baselineNode, BranchLayoutStrategy layoutStrategy)
+ public BranchView(CDOBranch branch, AbstractBranchPointNode baselineNode, BranchViewLayoutStrategy layoutStrategy)
{
this.branch = branch;
this.baselineNode = baselineNode;
@@ -77,17 +73,7 @@ public class BranchView
return nodes;
}
- public Deque<BranchView> getLeftSproutingBranchViews()
- {
- return leftSproutingBranchViews;
- }
-
- public Deque<BranchView> getRightSproutingBranchViews()
- {
- return rightSproutingBranchViews;
- }
-
- public BranchLayoutStrategy getLayoutStrategy()
+ public BranchViewLayoutStrategy getLayoutStrategy()
{
return layoutStrategy;
}
@@ -135,7 +121,6 @@ public class BranchView
* 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()
{
@@ -154,31 +139,39 @@ public class BranchView
this.bounds = bounds;
}
- public void addLeftSproutingBranch(BranchView branchView)
- {
- leftSproutingBranchViews.addFirst(branchView);
- }
-
- public void addRightSproutingBranch(BranchView branchView)
+ /**
+ * Adds the given sub branch view to this branch view.
+ *
+ * @param subBranchView
+ * the sub branch view to add
+ */
+ public void addSubBranchView(BranchView subBranchView)
{
- rightSproutingBranchViews.addFirst(branchView);
+ subBranchViews.add(subBranchView);
}
- public BranchView getLatestRightSubBranchView()
+ /**
+ * Returns not the last, but the one before the last sub branch view. If none is present, <tt>null<tt> is returned.
+ *
+ * @return the second to last sub branch view or <tt>null<tt>
+ */
+ public BranchView getSecondToLastSubBranchView()
{
- return rightSproutingBranchViews.peekFirst();
- }
+ if (subBranchViews.isEmpty() || subBranchViews.size() < 2)
+ {
+ return null;
+ }
- public BranchView getLatestLeftSubBranchView()
- {
- return leftSproutingBranchViews.peekFirst();
+ return subBranchViews.get(subBranchViews.size() - 1);
}
- public Collection<BranchView> getSubBranches()
+ /**
+ * Returns all sub branch views present in this branch view.
+ *
+ * @return all sub branch views in this branch view
+ */
+ public Collection<BranchView> getSubBranchViews()
{
- List<BranchView> branchList = new ArrayList<BranchView>(leftSproutingBranchViews);
- branchList.addAll(rightSproutingBranchViews);
- return branchList;
+ return subBranchViews;
}
-
}
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/BranchViewLayoutStrategy.java
index f486290b74..ff44234be5 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/BranchViewLayoutStrategy.java
@@ -29,23 +29,11 @@ import org.eclipse.zest.layouts.dataStructures.InternalNode;
*
* @author Andre Dietisheim
*/
-public class BranchLayoutStrategy
+public class BranchViewLayoutStrategy
{
private final SubBranchSproutingStrategy sproutRight = new SubBranchSproutingStrategy()
{
@Override
- protected void addSubBranchReference(BranchView branchView, BranchView subBranchView)
- {
- branchView.addRightSproutingBranch(subBranchView);
- }
-
- @Override
- protected BranchView getLatestSubBranch(BranchView branchView)
- {
- return branchView.getLatestRightSubBranchView();
- }
-
- @Override
protected DisplayIndependentDimension getTranslationToBranchPoint(BranchView subBranch,
BranchPointNode branchPointNode)
{
@@ -71,18 +59,6 @@ public class BranchLayoutStrategy
private final SubBranchSproutingStrategy sproutLeft = new SubBranchSproutingStrategy()
{
@Override
- protected void addSubBranchReference(BranchView branchView, BranchView subBranchView)
- {
- branchView.addLeftSproutingBranch(subBranchView);
- }
-
- @Override
- protected BranchView getLatestSubBranch(BranchView branchView)
- {
- return branchView.getLatestLeftSubBranchView();
- }
-
- @Override
protected DisplayIndependentDimension getTranslationToBranchPoint(BranchView subBranch,
BranchPointNode branchPointNode)
{
@@ -108,7 +84,7 @@ public class BranchLayoutStrategy
private SubBranchSproutingStrategy currentSproutingStrategy = sproutRight;
- protected BranchLayoutStrategy()
+ protected BranchViewLayoutStrategy()
{
}
@@ -219,7 +195,7 @@ public class BranchLayoutStrategy
*/
private void translateSubBranches(BranchView branchView, DisplayIndependentDimension dimension)
{
- for (BranchView branch : branchView.getSubBranches())
+ for (BranchView branch : branchView.getSubBranchViews())
{
branch.getLayoutStrategy().translate(branchView, dimension);
}
@@ -242,25 +218,6 @@ public class BranchLayoutStrategy
protected abstract class SubBranchSproutingStrategy
{
/**
- * Adds the given sub branch view reference to the given branch view.
- *
- * @param branchView
- * the branch view to add the sub branch to
- * @param subBranchView
- * the sub branch view to add
- */
- protected abstract void addSubBranchReference(BranchView branchView, BranchView subBranchView);
-
- /**
- * 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(BranchView branchView);
-
- /**
* 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
@@ -276,7 +233,7 @@ public class BranchLayoutStrategy
{
// translate branch off the branchPointNode (to the right or to the left)
DisplayIndependentDimension translation = getTranslationToBranchPoint(subBranchView, branchPointNode);
- BranchView latterBranch = currentSproutingStrategy.getLatestSubBranch(branchView);
+ BranchView latterBranch = branchView.getSecondToLastSubBranchView();
if (latterBranch != null && !subBranchView.getBounds().bottomEndsBefore(latterBranch.getBounds()))
{
// collides vertically with latter sub-branch -> additionally translate off latter branch (to the right or to
@@ -284,7 +241,7 @@ public class BranchLayoutStrategy
translation = GeometryUtils.union(translation, getTranslationToLatterBranch(subBranchView, latterBranch));
}
translate(subBranchView, translation);
- addSubBranchReference(branchView, subBranchView);
+ branchView.addSubBranchView(subBranchView);
}
/**
@@ -314,8 +271,6 @@ public class BranchLayoutStrategy
/**
* Switches the current sprouting strategy to the next strategy to apply after the current one .
- *
- * @return the sub branch sprouting strategy
*/
protected void switchSproutingStrategy()
{

Back to the top