diff options
author | Andre Dietisheim | 2010-03-16 23:56:20 +0000 |
---|---|---|
committer | Andre Dietisheim | 2010-03-16 23:56:20 +0000 |
commit | 0e6c9821a29aaacea54e5663843c314845fbeaa5 (patch) | |
tree | a825dd7c0582c0be7f6082f3cb5d476ffc4e1cce /plugins | |
parent | 95a6df26bc8335d08e6aa28a6ab448be96bd47e0 (diff) | |
download | cdo-0e6c9821a29aaacea54e5663843c314845fbeaa5.tar.gz cdo-0e6c9821a29aaacea54e5663843c314845fbeaa5.tar.xz cdo-0e6c9821a29aaacea54e5663843c314845fbeaa5.zip |
[256624] [UI] Create a Commit History ViewPart
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256624
started to implement custom #fitWithinBounds
Diffstat (limited to 'plugins')
2 files changed, 104 insertions, 15 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractBranchViewLayoutStrategy.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractBranchViewLayoutStrategy.java index 4a29906e3c..e9df346547 100644 --- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractBranchViewLayoutStrategy.java +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractBranchViewLayoutStrategy.java @@ -13,8 +13,9 @@ package org.eclipse.emf.cdo.ui.internal.branch.layout; import org.eclipse.emf.cdo.ui.internal.branch.geometry.GeometryUtils; import org.eclipse.emf.cdo.ui.internal.branch.item.AbstractBranchPointNode; import org.eclipse.emf.cdo.ui.internal.branch.item.BranchPointNode; -import org.eclipse.emf.cdo.ui.internal.branch.item.BranchTreeUtils; +import org.eclipse.emf.cdo.ui.internal.branch.item.BranchPointNodeUtils; +import org.eclipse.zest.layouts.dataStructures.DisplayIndependentDimension; import org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle; import org.eclipse.zest.layouts.dataStructures.InternalNode; @@ -35,14 +36,14 @@ public abstract class AbstractBranchViewLayoutStrategy implements BranchViewLayo public void layoutBaselineNode(BranchView branchView, AbstractBranchPointNode node) { - BranchTreeUtils.setInternalSize(node); + BranchPointNodeUtils.setInternalSize(node); setBaselineNodeLocation(node); initBranchBounds(branchView, node); } protected void initBranchBounds(BranchView branchView, AbstractBranchPointNode node) { - InternalNode baselineInternalNode = BranchTreeUtils.getInternalNode(node); + InternalNode baselineInternalNode = BranchPointNodeUtils.getInternalNode(node); DisplayIndependentRectangle bounds = new DisplayIndependentRectangle(baselineInternalNode.getInternalX(), baselineInternalNode.getInternalY(), baselineInternalNode.getInternalWidth(), baselineInternalNode .getInternalHeight()); @@ -59,7 +60,7 @@ public abstract class AbstractBranchViewLayoutStrategy implements BranchViewLayo */ public void layoutNode(BranchView branchView, AbstractBranchPointNode node, AbstractBranchPointNode previousNode) { - BranchTreeUtils.setInternalSize(node); + BranchPointNodeUtils.setInternalSize(node); setSameBranchNodeLocation(node, previousNode); setBranchBounds(branchView, node); } @@ -70,7 +71,7 @@ public abstract class AbstractBranchViewLayoutStrategy implements BranchViewLayo protected void setBaselineNodeLocation(AbstractBranchPointNode node) { double y = node.getTimeStamp(); - BranchTreeUtils.centerHorizontally(node, y); + BranchPointNodeUtils.centerHorizontally(node, y); } /** @@ -79,22 +80,28 @@ public abstract class AbstractBranchViewLayoutStrategy implements BranchViewLayo protected void setSameBranchNodeLocation(AbstractBranchPointNode node, AbstractBranchPointNode previousNode) { double y = node.getTimeStamp(); - BranchTreeUtils.centerHorizontally(node, previousNode, y); + BranchPointNodeUtils.centerHorizontally(node, previousNode, y); } /** * Sets the bounds of the current branch for the given additional node. The bounds are expanded if the size of the * node requires it. + * + * @param branchView + * the branch view to set the bounds + * @param node + * the node that was added and shall be included in the given branch view */ protected void setBranchBounds(BranchView branchView, AbstractBranchPointNode node) { - InternalNode internalNode = BranchTreeUtils.getInternalNode(node); + InternalNode internalNode = BranchPointNodeUtils.getInternalNode(node); - GeometryUtils.union(branchView.getBounds(), // + DisplayIndependentRectangle bounds = GeometryUtils.union(branchView.getBounds(), // internalNode.getInternalX() // , internalNode.getInternalY() // , internalNode.getInternalWidth() // , internalNode.getInternalHeight()); + branchView.setBounds(bounds); } /** @@ -114,10 +121,92 @@ public abstract class AbstractBranchViewLayoutStrategy implements BranchViewLayo if (subBranchView != null) { setBranchViewLocation(branchView, subBranchView, branchPointNode); - GeometryUtils.union(branchView.getBounds(), subBranchView.getBounds()); + branchView.setBounds(GeometryUtils.union(branchView.getBounds(), subBranchView.getBounds())); } } protected abstract void setBranchViewLocation(BranchView branchView, BranchView subBranchView, BranchPointNode branchPointNode); + + public void translateBy(BranchView branchView, DisplayIndependentDimension offsets) + { + translateBranchNodesBy(branchView, offsets); + translateSubBranchesBy(branchView, offsets); + GeometryUtils.translateRectangle(offsets.width, offsets.height, branchView.getBounds()); + } + + /** + * Translates all sub branches of the given branch. + * + * @param dimension + * the dimension to translate this branch by + */ + protected void translateSubBranchesBy(BranchView branchView, DisplayIndependentDimension dimension) + { + for (BranchView subBranch : branchView.getSubBranchViews()) + { + translateBy(subBranch, dimension); + } + } + + /** + * Translates all the sibling nodes in this branch view. Applies the given horizontal and vertical offset. + * + * @param branchView + * the branch view to translate the nodes of + * @param dimension + * the dimension to translate by + */ + protected void translateBranchNodesBy(BranchView branchView, DisplayIndependentDimension dimension) + { + for (AbstractBranchPointNode node : branchView.getNodes()) + { + BranchPointNodeUtils.translateInternalLocation(node, dimension.width, dimension.height); + } + } + + public void scale(BranchView branchView, DisplayIndependentDimension scaling) + { + scaleSameBranchNodes(branchView, scaling); + scaleSubBranches(branchView, scaling); + } + + public void scale(BranchView branchView, DisplayIndependentRectangle targetBounds) + { + DisplayIndependentRectangle bounds = branchView.getBounds(); + DisplayIndependentDimension scaling = new DisplayIndependentDimension(bounds.width / targetBounds.width, + bounds.height / targetBounds.height); + branchView.getLayoutStrategy().scale(branchView, scaling); + branchView.getLayoutStrategy().translateBy(branchView, + GeometryUtils.getTranslation(branchView.getBounds(), targetBounds.x, targetBounds.y)); + } + + protected void scaleSameBranchNodes(BranchView branchView, DisplayIndependentDimension scaling) + { + double centerX = BranchPointNodeUtils.getCenterX(branchView.getBaselineNode()); + branchView.resetBounds(); + for (AbstractBranchPointNode node : branchView.getNodes()) + { + InternalNode internalNode = BranchPointNodeUtils.getInternalNode(node); + double newX = centerX / scaling.width - internalNode.getInternalWidth() / 2; + double newY = internalNode.getInternalY() / scaling.height; + internalNode.setInternalLocation(newX, newY); + if (!branchView.areBoundsSet()) + { + initBranchBounds(branchView, node); + } + else + { + setBranchBounds(branchView, node); + } + } + } + + protected void scaleSubBranches(BranchView branchView, DisplayIndependentDimension targetDimension) + { + for (BranchView subBranch : branchView.getSubBranchViews()) + { + scale(subBranch, targetDimension); + } + } } diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/VerticallyDistributedSubBranches.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/VerticallyDistributedSubBranches.java index 5af064f1b2..7fbd0c6bf7 100644 --- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/VerticallyDistributedSubBranches.java +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/VerticallyDistributedSubBranches.java @@ -12,7 +12,7 @@ package org.eclipse.emf.cdo.ui.internal.branch.layout; import org.eclipse.emf.cdo.ui.internal.branch.geometry.GeometryUtils; import org.eclipse.emf.cdo.ui.internal.branch.item.BranchPointNode; -import org.eclipse.emf.cdo.ui.internal.branch.item.BranchTreeUtils; +import org.eclipse.emf.cdo.ui.internal.branch.item.BranchPointNodeUtils; import org.eclipse.zest.layouts.dataStructures.DisplayIndependentDimension; import org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle; @@ -35,7 +35,7 @@ public class VerticallyDistributedSubBranches extends AbstractBranchViewLayoutSt protected DisplayIndependentDimension getTranslationToBranchPoint(BranchView subBranchView, BranchPointNode branchPointNode) { - InternalNode branchPointInternalNode = BranchTreeUtils.getInternalNode(branchPointNode); + InternalNode branchPointInternalNode = BranchPointNodeUtils.getInternalNode(branchPointNode); return new DisplayIndependentDimension( // GeometryUtils.getTranslation(subBranchView.getBounds().x, branchPointInternalNode.getInternalX()) // + branchPointInternalNode.getInternalWidth() // @@ -57,7 +57,7 @@ public class VerticallyDistributedSubBranches extends AbstractBranchViewLayoutSt protected DisplayIndependentDimension getTranslationToBranchPoint(BranchView subBranch, BranchPointNode branchPointNode) { - InternalNode branchPointInternalNode = BranchTreeUtils.getInternalNode(branchPointNode); + InternalNode branchPointInternalNode = BranchPointNodeUtils.getInternalNode(branchPointNode); DisplayIndependentRectangle subBranchBounds = subBranch.getBounds(); return new DisplayIndependentDimension( // GeometryUtils.getTranslation(subBranchBounds.x, branchPointInternalNode.getInternalX()) // @@ -94,7 +94,7 @@ public class VerticallyDistributedSubBranches extends AbstractBranchViewLayoutSt { return RIGHT; } - + return LEFT; } @@ -120,9 +120,9 @@ public class VerticallyDistributedSubBranches extends AbstractBranchViewLayoutSt { // collides vertically with latter sub-branch -> additionally translate off latter branch (to the right or to // the left) - translation = GeometryUtils.union(translation, getTranslationToLatterBranch(subBranchView, latterBranch)); + GeometryUtils.union(translation, getTranslationToLatterBranch(subBranchView, latterBranch)); } - subBranchView.translate(translation); + translateBy(subBranchView, translation); } /** |