improve visibility of cursor and node tag
Signed-off-by: Florian Thienel <florian@thienel.org>
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 2c8909e..671f561 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
@@ -26,7 +26,7 @@
private static final FontSpec FONT = new FontSpec("Arial", FontSpec.BOLD, 10.0f);
public static void drawStartTag(final Graphics graphics, final INode node, final int x, final int y, final boolean verticallyCentered) {
- drawTag(graphics, getNodeStartMarker(node), x, y, false, verticallyCentered);
+ drawSimpleTag(graphics, getNodeStartMarker(node), x, y, false, verticallyCentered);
}
public static void drawTag(final Graphics graphics, final INode node, final int x, final int y, final boolean horizontallyCentered, final boolean verticallyCentered) {
@@ -34,30 +34,60 @@
}
public static void drawEndTag(final Graphics graphics, final INode node, final int x, final int y, final boolean verticallyCentered) {
- drawTag(graphics, getNodeEndMarker(node), x, y, false, verticallyCentered);
+ drawSimpleTag(graphics, getNodeEndMarker(node), x, y, false, verticallyCentered);
}
- private static void drawTag(final Graphics graphics, final String text, final int x, final int y, final boolean horizontallyCentered, final boolean verticallyCentered) {
+ private static void drawSimpleTag(final Graphics graphics, final String text, final int x, final int y, final boolean horizontallyCentered, final boolean verticallyCentered) {
graphics.setCurrentFont(graphics.getFont(FONT));
- final int textWidth = graphics.stringWidth(text);
- final int textHeight = graphics.getFontMetrics().getHeight();
final int textPadding = 3;
+ final int textWidth = graphics.stringWidth(text) + textPadding * 2;
+ final int textHeight = graphics.getFontMetrics().getHeight() + textPadding * 2;
final int effectiveX;
if (horizontallyCentered) {
- effectiveX = x - (textWidth + textPadding * 2) / 2;
+ effectiveX = x - textWidth / 2;
} else {
effectiveX = x;
}
final int effectiveY;
if (verticallyCentered) {
- effectiveY = y - (textHeight + textPadding * 2) / 2;
+ effectiveY = y - textHeight / 2;
} else {
effectiveY = y;
}
- graphics.fillRect(effectiveX, effectiveY, textWidth + textPadding * 2, textHeight + textPadding * 2);
+ graphics.setLineWidth(1);
+ graphics.fillRect(effectiveX, effectiveY, textWidth, textHeight);
+ graphics.drawRect(effectiveX, effectiveY, textWidth, textHeight);
+ graphics.drawString(text, effectiveX + textPadding, effectiveY + textPadding);
+ }
+
+ private static void drawTag(final Graphics graphics, final String text, final int x, final int y, final boolean horizontallyCentered, final boolean verticallyCentered) {
+ graphics.setCurrentFont(graphics.getFont(FONT));
+ final int textPadding = 3;
+ final int textWidth = graphics.stringWidth(text) + textPadding * 2;
+ final int textHeight = graphics.getFontMetrics().getHeight() + textPadding * 2;
+ final int arc = textHeight / 3;
+ final int margin = 2;
+
+ final int effectiveX;
+ if (horizontallyCentered) {
+ effectiveX = x - textWidth / 2;
+ } else {
+ effectiveX = x;
+ }
+
+ final int effectiveY;
+ if (verticallyCentered) {
+ effectiveY = y - textHeight / 2;
+ } else {
+ effectiveY = y;
+ }
+
+ graphics.setLineWidth(1);
+ graphics.fillRoundRect(effectiveX - margin, effectiveY - margin, textWidth + margin * 2 + 1, textHeight + margin * 2 + 1, arc, arc);
+ graphics.drawRoundRect(effectiveX, effectiveY, textWidth, textHeight, arc, arc);
graphics.drawString(text, effectiveX + textPadding, effectiveY + textPadding);
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/cursor/Cursor.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/cursor/Cursor.java
index 64fc818..99e1bb3 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/cursor/Cursor.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/cursor/Cursor.java
@@ -26,7 +26,6 @@
import org.eclipse.vex.core.internal.boxes.StructuralNodeReference;
import org.eclipse.vex.core.internal.boxes.TextContent;
import org.eclipse.vex.core.internal.core.Color;
-import org.eclipse.vex.core.internal.core.ColorResource;
import org.eclipse.vex.core.internal.core.FontSpec;
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.NodeGraphics;
@@ -406,6 +405,11 @@
final int x = area.getX();
final int y = area.getY();
+ graphics.swapColors();
+ graphics.fillRect(x - 2, y - 2, area.getWidth(), 6);
+ graphics.fillRect(x - 2, y - 2, 6, area.getHeight());
+ graphics.swapColors();
+
graphics.fillRect(x, y, area.getWidth(), 2);
graphics.fillRect(x, y, 2, area.getHeight());
@@ -564,6 +568,11 @@
final int x = area.getX();
final int y = area.getY() + area.getHeight();
+ graphics.swapColors();
+ graphics.fillRect(x - 2, y - 2, area.getWidth(), 6);
+ graphics.fillRect(x - 2, y - 2, 6, area.getHeight());
+ graphics.swapColors();
+
graphics.fillRect(x, y, area.getWidth(), 2);
graphics.fillRect(x + area.getWidth() - 2, y, 2, -area.getHeight());