diff --git a/src/main/java/de/neemann/digital/core/element/Keys.java b/src/main/java/de/neemann/digital/core/element/Keys.java index b490497bb..19e9db783 100644 --- a/src/main/java/de/neemann/digital/core/element/Keys.java +++ b/src/main/java/de/neemann/digital/core/element/Keys.java @@ -13,6 +13,7 @@ import de.neemann.digital.core.io.InValue; import de.neemann.digital.core.memory.DataField; import de.neemann.digital.core.memory.rom.ROMManger; +import de.neemann.digital.draw.graphics.Orientation; import de.neemann.digital.draw.graphics.Style; import de.neemann.digital.draw.library.ElementLibrary; import de.neemann.digital.draw.model.InverterConfig; @@ -140,6 +141,13 @@ private Keys() { .setMin(10) .setMax(70); + /** + * text orientation + */ + public static final Key TEXT_ORIENTATION + = new Key.KeyEnum<>("textOrientation", Orientation.LEFTTOP, Orientation.values()).setSecondary(); + + /** * The size of a LED */ @@ -515,7 +523,7 @@ private Keys() { new Key.KeyInteger("pinCount", 0) .setMin(0) .setDependsOn(IS_DIL) - .setSecondary(); + .setSecondary(); /** diff --git a/src/main/java/de/neemann/digital/draw/shapes/TextShape.java b/src/main/java/de/neemann/digital/draw/shapes/TextShape.java index cdde56cd0..8861dab96 100644 --- a/src/main/java/de/neemann/digital/draw/shapes/TextShape.java +++ b/src/main/java/de/neemann/digital/draw/shapes/TextShape.java @@ -23,6 +23,7 @@ public class TextShape implements Shape { private final String text; private final int fontSize; + private Orientation orientation; /** * Create a new instance @@ -47,6 +48,7 @@ public TextShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions this.text = Lang.evalMultilingualContent(text); fontSize = attr.get(Keys.FONT_SIZE); + orientation = attr.get(Keys.TEXT_ORIENTATION); } @Override @@ -61,6 +63,7 @@ public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) { @Override public void drawTo(Graphic graphic, Style highLight) { + StringBuilder sb = new StringBuilder(); Style style = Style.NORMAL.deriveFontStyle(fontSize, true); Vector pos = new Vector(0, 0); @@ -69,7 +72,7 @@ public void drawTo(Graphic graphic, Style highLight) { char c = text.charAt(i); if (c == '\n') { if (sb.length() > 0) { - graphic.drawText(pos, pos.add(1, 0), sb.toString(), Orientation.LEFTTOP, style); + graphic.drawText(pos, pos.add(1, 0), sb.toString(), orientation, style); sb.setLength(0); } pos = pos.add(0, dy); @@ -77,6 +80,6 @@ public void drawTo(Graphic graphic, Style highLight) { sb.append(c); } if (sb.length() > 0) - graphic.drawText(pos, pos.add(1, 0), sb.toString(), Orientation.LEFTTOP, style); + graphic.drawText(pos, pos.add(1, 0), sb.toString(), orientation, style); } } diff --git a/src/main/java/de/neemann/digital/gui/components/EditorFactory.java b/src/main/java/de/neemann/digital/gui/components/EditorFactory.java index 22c417bf9..c552917bd 100644 --- a/src/main/java/de/neemann/digital/gui/components/EditorFactory.java +++ b/src/main/java/de/neemann/digital/gui/components/EditorFactory.java @@ -18,6 +18,7 @@ import de.neemann.digital.core.memory.rom.ROMManger; import de.neemann.digital.draw.elements.PinException; import de.neemann.digital.draw.elements.VisualElement; +import de.neemann.digital.draw.graphics.Orientation; import de.neemann.digital.draw.library.ElementNotFoundException; import de.neemann.digital.draw.model.InverterConfig; import de.neemann.digital.draw.model.ModelCreator; @@ -65,6 +66,7 @@ private EditorFactory() { add(BarrelShifterMode.class, BarrelShifterModeEditor.class); add(LeftRightFormat.class, LeftRightFormatsEditor.class); add(IntFormat.class, IntFormatsEditor.class); + add(Orientation.class, OrientationEditor.class); add(Language.class, LanguageEditor.class); add(TestCaseDescription.class, TestCaseDescriptionEditor.class); add(FormatToExpression.class, FormatEditor.class); @@ -589,6 +591,12 @@ public IntFormatsEditor(IntFormat value, Key key) { } } + private static final class OrientationEditor extends EnumEditor { + public OrientationEditor(Orientation value, Key key) { + super(value, key); + } + } + private static final class BarrelShifterModeEditor extends EnumEditor { public BarrelShifterModeEditor(BarrelShifterMode value, Key key) { super(value, key); diff --git a/src/main/java/de/neemann/digital/gui/components/data/DummyElement.java b/src/main/java/de/neemann/digital/gui/components/data/DummyElement.java index 64289ab6c..5caf929b8 100644 --- a/src/main/java/de/neemann/digital/gui/components/data/DummyElement.java +++ b/src/main/java/de/neemann/digital/gui/components/data/DummyElement.java @@ -32,6 +32,7 @@ public class DummyElement implements Element { public static final ElementTypeDescription TEXTDESCRIPTION = new ElementTypeDescription("Text", DummyElement.class) .addAttribute(Keys.DESCRIPTION) .addAttribute(Keys.ROTATE) + .addAttribute(Keys.TEXT_ORIENTATION) .addAttribute(Keys.FONT_SIZE); /** diff --git a/src/main/resources/lang/lang_de.xml b/src/main/resources/lang/lang_de.xml index a0e5c505c..e29965312 100644 --- a/src/main/resources/lang/lang_de.xml +++ b/src/main/resources/lang/lang_de.xml @@ -1145,6 +1145,18 @@ Sind evtl. die Namen der Variablen nicht eindeutig? Verwendet die einfache Form zur Darstellung. Hat nur einen Effekt, wenn die Schaltung eine Benutzerdefinierte Form oder eine DIL Form verwendet. + Ausrichtung + Lage der Koordinate relativ zum Text. + links unten + mitte unten + rechts unten + rechts mitte + rechts oben + mitte oben + links oben + links mitte + mitte mitte + Leitung eingefügt. Aus Zwischenablage eingefügt. Wert ''{0}'' in Element ''{1}'' verändert. diff --git a/src/main/resources/lang/lang_en.xml b/src/main/resources/lang/lang_en.xml index 3d7488c4b..4b9eae790 100644 --- a/src/main/resources/lang/lang_en.xml +++ b/src/main/resources/lang/lang_en.xml @@ -1137,6 +1137,18 @@ Use Default Shape Use the default shape instead of using the DIL or custom shape configured in the circuit. + Orientation + Position of the coordinate relative to the text. + left bottom + center bottom + right bottom + right center + right top + center top + left top + left center + center center + Inserted wire. Insert from clipboard. Value ''{0}'' in component ''{1}'' modified.