use smaller start and end tag markers

Signed-off-by: Florian Thienel <florian@thienel.org>
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 794dc0f..e47f8e1 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
@@ -211,11 +211,13 @@
 		return bullet;
 	}
 
-	public static NodeTag nodeTag(final Kind kind, final INode node, final Color foreground) {
+	public static NodeTag nodeTag(final Kind kind, final INode node, final Color foreground, final boolean showText, final float fontSize) {
 		final NodeTag nodeTag = new NodeTag();
 		nodeTag.setKind(kind);
 		nodeTag.setNode(node);
 		nodeTag.setColor(foreground);
+		nodeTag.setShowText(showText);
+		nodeTag.setFontSize(fontSize);
 		return nodeTag;
 	}
 }
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeTag.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeTag.java
index e7a95e3..773115d 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeTag.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeTag.java
@@ -25,6 +25,10 @@
 		NODE, START, END;
 	}
 
+	private static final int MARGIN = 2;
+	private static final float SIZE_RATIO = 0.5f;
+	private static final float BASELINE_RATIO = 1.1f;
+
 	private int width;
 	private int height;
 	private int baseline;
@@ -33,6 +37,7 @@
 	private INode node;
 	private Color color;
 	private boolean showText;
+	private float fontSize;
 
 	@Override
 	public int getWidth() {
@@ -69,6 +74,14 @@
 		this.showText = showText;
 	}
 
+	public void setFontSize(final float fontSize) {
+		this.fontSize = fontSize;
+	}
+
+	public float getFontSize() {
+		return fontSize;
+	}
+
 	@Override
 	public void accept(final IBoxVisitor visitor) {
 		visitor.visit(this);
@@ -82,9 +95,13 @@
 	@Override
 	public void layout(final Graphics graphics) {
 		final Point tagSize = getTagSize(graphics);
-		width = tagSize.getX();
+		width = tagSize.getX() + MARGIN;
 		height = tagSize.getY();
-		baseline = NodeGraphics.getTagBaseline(graphics);
+		if (kind == Kind.NODE || showText) {
+			baseline = NodeGraphics.getTagBaseline(graphics);
+		} else {
+			baseline = Math.round(height * BASELINE_RATIO);
+		}
 	}
 
 	private Point getTagSize(final Graphics graphics) {
@@ -92,9 +109,19 @@
 		case NODE:
 			return NodeGraphics.getTagSize(graphics, getText());
 		case START:
-			return NodeGraphics.getStartTagSize(graphics, getText());
+			if (showText) {
+				return NodeGraphics.getStartTagSize(graphics, getText());
+			} else {
+				final int size = Math.round(fontSize * SIZE_RATIO);
+				return new Point(size, size);
+			}
 		case END:
-			return NodeGraphics.getEndTagSize(graphics, getText());
+			if (showText) {
+				return NodeGraphics.getEndTagSize(graphics, getText());
+			} else {
+				final int size = Math.round(fontSize * SIZE_RATIO);
+				return new Point(size, size);
+			}
 		default:
 			throw new IllegalStateException("Unknown kind " + kind + " of NodeTag.");
 		}
@@ -117,16 +144,24 @@
 
 	@Override
 	public void paint(final Graphics graphics) {
-		graphics.setForeground(graphics.getColor(color));
+		graphics.setColor(graphics.getColor(color));
 		switch (kind) {
 		case NODE:
-			NodeGraphics.drawTag(graphics, getText(), 0, 0, false, false, true);
+			NodeGraphics.drawTag(graphics, getText(), MARGIN / 2, 0, false, false, true);
 			break;
 		case START:
-			NodeGraphics.drawStartTag(graphics, getText(), 0, 0, false, true);
+			if (showText) {
+				NodeGraphics.drawStartTag(graphics, getText(), MARGIN, 0, false, true);
+			} else {
+				NodeGraphics.drawSimpleStartTag(graphics, MARGIN, 0, height, false, true);
+			}
 			break;
 		case END:
-			NodeGraphics.drawEndTag(graphics, getText(), 0, 0, false, true);
+			if (showText) {
+				NodeGraphics.drawEndTag(graphics, getText(), 0, 0, false, true);
+			} else {
+				NodeGraphics.drawSimpleEndTag(graphics, 0, 0, height, false, true);
+			}
 			break;
 		default:
 			throw new IllegalStateException("Unknown kind " + kind + " of NodeTag.");
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/NodeGraphics.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/NodeGraphics.java
index 7780895..e569979 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/NodeGraphics.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/NodeGraphics.java
@@ -126,6 +126,31 @@
 		return new Point(width, height);
 	}
 
+	public static void drawSimpleStartTag(final Graphics graphics, final int x, final int y, final int size, final boolean verticallyCentered, final boolean transparent) {
+		final int effectiveY;
+		if (verticallyCentered) {
+			effectiveY = y - size / 2;
+		} else {
+			effectiveY = y;
+		}
+
+		if (!transparent) {
+			graphics.fillPolygon(simpleArrowRight(x, effectiveY, size));
+		} else {
+			graphics.setLineStyle(LineStyle.SOLID);
+			graphics.setLineWidth(1);
+			graphics.drawPolygon(simpleArrowRight(x, effectiveY, size));
+		}
+	}
+
+	private static int[] simpleArrowRight(final int x, final int y, final int size) {
+		return new int[] {
+				x, y + size,
+				x, y,
+				x + size - 1, y + size / 2
+		};
+	}
+
 	public static void drawEndTag(final Graphics graphics, final INode node, final int x, final int y, final boolean verticallyCentered, final boolean transparent) {
 		drawEndTag(graphics, getNodeName(node), x, y, verticallyCentered, false);
 	}
@@ -176,6 +201,31 @@
 		return new Point(width, height);
 	}
 
+	public static void drawSimpleEndTag(final Graphics graphics, final int x, final int y, final int size, final boolean verticallyCentered, final boolean transparent) {
+		final int effectiveY;
+		if (verticallyCentered) {
+			effectiveY = y - size / 2;
+		} else {
+			effectiveY = y;
+		}
+
+		if (!transparent) {
+			graphics.fillPolygon(simpleArrowLeft(x, effectiveY, size));
+		} else {
+			graphics.setLineStyle(LineStyle.SOLID);
+			graphics.setLineWidth(1);
+			graphics.drawPolygon(simpleArrowLeft(x, effectiveY, size));
+		}
+	}
+
+	private static int[] simpleArrowLeft(final int x, final int y, final int size) {
+		return new int[] {
+				x + size - 1, y + size,
+				x + size - 1, y,
+				x, y + size / 2
+		};
+	}
+
 	public static String getNodeName(final INode node) {
 		return node.accept(new BaseNodeVisitorWithResult<String>() {
 			@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBoxFactory.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBoxFactory.java
index bb618fd..3ea7236 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBoxFactory.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBoxFactory.java
@@ -144,6 +144,7 @@
 		nodeTag.setNode(node);
 		nodeTag.setColor(styles.getColor());
 		nodeTag.setShowText(true);
+		nodeTag.setFontSize(styles.getFontSize());
 		return nodeTag;
 	}
 
@@ -153,6 +154,7 @@
 		nodeTag.setNode(node);
 		nodeTag.setColor(styles.getColor());
 		nodeTag.setShowText(false);
+		nodeTag.setFontSize(styles.getFontSize());
 		return nodeTag;
 	}
 
@@ -162,6 +164,7 @@
 		nodeTag.setNode(node);
 		nodeTag.setColor(styles.getColor());
 		nodeTag.setShowText(false);
+		nodeTag.setFontSize(styles.getFontSize());
 		return nodeTag;
 	}