Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Thienel2016-06-13 15:05:21 -0400
committerFlorian Thienel2016-06-13 15:05:21 -0400
commiteda60a9c52a4c6721e4bd832c7c043949d61775d (patch)
treea9b182d1689d52d1ab9e318c74fd6da689862bde
parent4074790aa8e0c5a3cc97340cd5d5aecb73484734 (diff)
downloadorg.eclipse.mylyn.docs.vex-eda60a9c52a4c6721e4bd832c7c043949d61775d.tar.gz
org.eclipse.mylyn.docs.vex-eda60a9c52a4c6721e4bd832c7c043949d61775d.tar.xz
org.eclipse.mylyn.docs.vex-eda60a9c52a4c6721e4bd832c7c043949d61775d.zip
use table cell as outmost box and adjust the frame height
Signed-off-by: Florian Thienel <florian@thienel.org>
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/BoxFactory.java6
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/DepthFirstBoxTraversal.java2
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralFrame.java4
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java86
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java4
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DOMVisualization.java2
6 files changed, 40 insertions, 64 deletions
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/BoxFactory.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/BoxFactory.java
index 4e33052b..39700ea9 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/BoxFactory.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/BoxFactory.java
@@ -177,11 +177,9 @@ public class BoxFactory {
return tableRow;
}
- public static TableCell tableCell(final IStructuralBox... children) {
+ public static TableCell tableCell(final IStructuralBox component) {
final TableCell tableCell = new TableCell();
- for (final IStructuralBox child : children) {
- tableCell.appendChild(child);
- }
+ tableCell.setComponent(component);
return tableCell;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/DepthFirstBoxTraversal.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/DepthFirstBoxTraversal.java
index ac6a63ca..8f87fb55 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/DepthFirstBoxTraversal.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/DepthFirstBoxTraversal.java
@@ -71,7 +71,7 @@ public abstract class DepthFirstBoxTraversal<T> extends BaseBoxVisitorWithResult
@Override
public T visit(final TableCell box) {
- return traverseChildren(box);
+ return box.getComponent().accept(this);
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralFrame.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralFrame.java
index 8c05e4e0..2495bce5 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralFrame.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralFrame.java
@@ -85,6 +85,10 @@ public class StructuralFrame extends BaseBox implements IStructuralBox, IDecorat
return height;
}
+ public void setHeight(final int height) {
+ this.height = height;
+ }
+
@Override
public Rectangle getBounds() {
return new Rectangle(left, top, width, height);
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java
index 1d775855..03a7b45c 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java
@@ -10,23 +10,20 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.boxes;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.ListIterator;
-
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.Rectangle;
/**
* @author Florian Thienel
*/
-public class TableCell extends BaseBox implements IStructuralBox, IParentBox<IStructuralBox> {
+public class TableCell extends BaseBox implements IStructuralBox, IDecoratorBox<IStructuralBox> {
private IBox parent;
private int top;
private int left;
private int width;
- private final ArrayList<IStructuralBox> children = new ArrayList<IStructuralBox>();
+
+ private IStructuralBox component;
private int startColumnIndex;
private int endColumnIndex;
@@ -116,45 +113,14 @@ public class TableCell extends BaseBox implements IStructuralBox, IParentBox<ISt
return visitor.visit(this);
}
- public boolean hasChildren() {
- return !children.isEmpty();
- }
-
- public void prependChild(final IStructuralBox child) {
- if (child == null) {
- return;
- }
- child.setParent(this);
- children.add(0, child);
- }
-
- public void appendChild(final IStructuralBox child) {
- if (child == null) {
- return;
- }
- child.setParent(this);
- children.add(child);
+ public void setComponent(final IStructuralBox component) {
+ this.component = component;
+ component.setParent(this);
}
@Override
- public void replaceChildren(final Collection<? extends IBox> oldChildren, final IStructuralBox newChild) {
- boolean newChildInserted = false;
-
- for (final ListIterator<IStructuralBox> iter = children.listIterator(); iter.hasNext();) {
- final IStructuralBox child = iter.next();
- if (oldChildren.contains(child)) {
- iter.remove();
- if (!newChildInserted) {
- iter.add(newChild);
- newChild.setParent(this);
- newChildInserted = true;
- }
- }
- }
- }
-
- public Iterable<IStructuralBox> getChildren() {
- return children;
+ public IStructuralBox getComponent() {
+ return component;
}
public int getStartColumnIndex() {
@@ -215,12 +181,13 @@ public class TableCell extends BaseBox implements IStructuralBox, IParentBox<ISt
public int calculateNaturalHeight(final Graphics graphics, final int width) {
naturalHeight = 0;
- for (int i = 0; i < children.size(); i += 1) {
- final IStructuralBox child = children.get(i);
- child.setWidth(width);
- child.layout(graphics);
- naturalHeight += child.getHeight();
+ if (component == null) {
+ return 0;
}
+
+ component.setWidth(width);
+ component.layout(graphics);
+ naturalHeight = component.getHeight();
usedHeight = 0;
return naturalHeight;
@@ -231,16 +198,22 @@ public class TableCell extends BaseBox implements IStructuralBox, IParentBox<ISt
naturalHeight = calculateNaturalHeight(graphics, width);
}
- positionChildren();
+ component.setPosition(0, 0);
+ adjustFrameHeight();
}
- private void positionChildren() {
- int childTop = 0;
- for (int i = 0; i < children.size(); i += 1) {
- final IStructuralBox child = children.get(i);
- child.setPosition(childTop, 0);
- childTop += child.getHeight();
+ private void adjustFrameHeight() {
+ final StructuralFrame frame = accept(new DepthFirstBoxTraversal<StructuralFrame>() {
+ @Override
+ public StructuralFrame visit(final StructuralFrame box) {
+ return box;
+ }
+ });
+ if (frame == null) {
+ return;
}
+
+ frame.setHeight(usedHeight);
}
@Override
@@ -252,12 +225,13 @@ public class TableCell extends BaseBox implements IStructuralBox, IParentBox<ISt
return false;
}
- positionChildren();
+ component.setPosition(0, 0);
+ adjustFrameHeight();
return true;
}
@Override
public void paint(final Graphics graphics) {
- ChildBoxPainter.paint(children, graphics);
+ ChildBoxPainter.paint(component, graphics);
}
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java
index 4c338fb0..b929ded1 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java
@@ -315,7 +315,7 @@ public class CssBasedBoxModelBuilder implements IBoxModelBuilder {
}
private IStructuralBox visualizeAsTableCell(final IElement element, final Styles styles, final Collection<VisualizeResult> childrenResults) {
- final TableCell cell = tableCell(visualizeStructuralElementContent(element, styles, childrenResults));
+ final TableCell cell = tableCell(wrapUpStructuralElementContent(element, styles, childrenResults, visualizeStructuralElementContent(element, styles, childrenResults)));
if ("entry".equals(element.getLocalName())) {
final IAttribute colName = element.getAttribute("colname");
@@ -339,7 +339,7 @@ public class CssBasedBoxModelBuilder implements IBoxModelBuilder {
// TODO HTML table
}
- return wrapUpStructuralElementContent(element, styles, childrenResults, cell);
+ return cell;
}
private static int toInt(final IAttribute attribute) {
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DOMVisualization.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DOMVisualization.java
index 4c6bbcdd..57a501d5 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DOMVisualization.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DOMVisualization.java
@@ -163,7 +163,7 @@ public class DOMVisualization {
@Override
public void visit(final TableCell box) {
- box.replaceChildren(modifiedBoxes, boxModelBuilder.visualizeStructure(node));
+ box.setComponent(boxModelBuilder.visualizeStructure(node));
}
@Override

Back to the top