diff --git a/src/main/java/de/neemann/digital/draw/graphics/Graphic.java b/src/main/java/de/neemann/digital/draw/graphics/Graphic.java index f9c1b5bb6..9b9a1c944 100644 --- a/src/main/java/de/neemann/digital/draw/graphics/Graphic.java +++ b/src/main/java/de/neemann/digital/draw/graphics/Graphic.java @@ -69,6 +69,19 @@ public interface Graphic extends Closeable { */ void drawText(VectorInterface p1, VectorInterface p2, String text, Orientation orientation, Style style); + /** + * Helper to draw a horizontal left to right text + * + * @param g the Graphic instance to draw to + * @param pos the text position + * @param text the text + * @param orientation the text orientation + * @param style the text style + */ + static void drawText(Graphic g, VectorInterface pos, String text, Orientation orientation, Style style) { + g.drawText(pos, pos.add(new Vector(1, 0)), text, orientation, style); + } + /** * opens a new group, used to create SVG grouping */ @@ -91,7 +104,6 @@ public interface Graphic extends Closeable { return false; } - /** * closes the graphics instance * diff --git a/src/main/java/de/neemann/digital/draw/shapes/RelayDTShape.java b/src/main/java/de/neemann/digital/draw/shapes/RelayDTShape.java index 38a904d1f..0db0a1cf8 100644 --- a/src/main/java/de/neemann/digital/draw/shapes/RelayDTShape.java +++ b/src/main/java/de/neemann/digital/draw/shapes/RelayDTShape.java @@ -111,6 +111,6 @@ public class RelayDTShape implements Shape { graphic.drawLine(new Vector(SIZE + SIZE2, -SIZE * 2), new Vector(SIZE * 2, -SIZE * 2), Style.NORMAL); if (label != null && label.length() > 0) - graphic.drawText(new Vector(SIZE, 4), new Vector(SIZE * 2, 4), label, Orientation.CENTERTOP, Style.SHAPE_PIN); + Graphic.drawText(graphic, new Vector(SIZE, -SIZE * 3 - 4), label, Orientation.CENTERBOTTOM, Style.SHAPE_PIN); } } diff --git a/src/main/java/de/neemann/digital/draw/shapes/RelayShape.java b/src/main/java/de/neemann/digital/draw/shapes/RelayShape.java index 07a07c722..9c1d64677 100644 --- a/src/main/java/de/neemann/digital/draw/shapes/RelayShape.java +++ b/src/main/java/de/neemann/digital/draw/shapes/RelayShape.java @@ -114,7 +114,7 @@ public class RelayShape implements Shape { graphic.drawLine(new Vector(SIZE + SIZE2, -SIZE * 2), new Vector(SIZE * 2, -SIZE * 2), Style.NORMAL); if (label != null && label.length() > 0) - graphic.drawText(new Vector(SIZE, 4), new Vector(SIZE * 2, 4), label, Orientation.CENTERTOP, Style.SHAPE_PIN); + Graphic.drawText(graphic, new Vector(SIZE, -SIZE * 3 - 4), label, Orientation.CENTERBOTTOM, Style.SHAPE_PIN); } }