mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-15 15:58:41 -04:00
added orientation attribute to text element, closes #159
This commit is contained in:
parent
0f338cdecb
commit
19193e96ec
@ -13,6 +13,7 @@ import de.neemann.digital.core.extern.Application;
|
||||
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 @@ public final class Keys {
|
||||
.setMin(10)
|
||||
.setMax(70);
|
||||
|
||||
/**
|
||||
* text orientation
|
||||
*/
|
||||
public static final Key<Orientation> TEXT_ORIENTATION
|
||||
= new Key.KeyEnum<>("textOrientation", Orientation.LEFTTOP, Orientation.values()).setSecondary();
|
||||
|
||||
|
||||
/**
|
||||
* The size of a LED
|
||||
*/
|
||||
|
@ -23,6 +23,7 @@ import de.neemann.digital.lang.Lang;
|
||||
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 class TextShape implements Shape {
|
||||
this.text = Lang.evalMultilingualContent(text);
|
||||
|
||||
fontSize = attr.get(Keys.FONT_SIZE);
|
||||
orientation = attr.get(Keys.TEXT_ORIENTATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,6 +63,7 @@ public class TextShape implements Shape {
|
||||
|
||||
@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 class TextShape implements Shape {
|
||||
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 class TextShape implements Shape {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import de.neemann.digital.core.memory.ROM;
|
||||
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 @@ public final class 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 final class EditorFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private static final class OrientationEditor extends EnumEditor<Orientation> {
|
||||
public OrientationEditor(Orientation value, Key<Orientation> key) {
|
||||
super(value, key);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class BarrelShifterModeEditor extends EnumEditor<BarrelShifterMode> {
|
||||
public BarrelShifterModeEditor(BarrelShifterMode value, Key<BarrelShifterMode> key) {
|
||||
super(value, key);
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
|
@ -1145,6 +1145,18 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
||||
<string name="key_useDefShape_tt">Verwendet die einfache Form zur Darstellung. Hat nur einen Effekt, wenn die
|
||||
Schaltung eine Benutzerdefinierte Form oder eine DIL Form verwendet.</string>
|
||||
|
||||
<string name="key_textOrientation">Ausrichtung</string>
|
||||
<string name="key_textOrientation_tt">Lage der Koordinate relativ zum Text.</string>
|
||||
<string name="key_textOrientation_LEFTBOTTOM">links unten</string>
|
||||
<string name="key_textOrientation_CENTERBOTTOM">mitte unten</string>
|
||||
<string name="key_textOrientation_RIGHTBOTTOM">rechts unten</string>
|
||||
<string name="key_textOrientation_RIGHTCENTER">rechts mitte</string>
|
||||
<string name="key_textOrientation_RIGHTTOP">rechts oben</string>
|
||||
<string name="key_textOrientation_CENTERTOP">mitte oben</string>
|
||||
<string name="key_textOrientation_LEFTTOP">links oben</string>
|
||||
<string name="key_textOrientation_LEFTCENTER">links mitte</string>
|
||||
<string name="key_textOrientation_CENTERCENTER">mitte mitte</string>
|
||||
|
||||
<string name="mod_insertWire">Leitung eingefügt.</string>
|
||||
<string name="mod_insertCopied">Aus Zwischenablage eingefügt.</string>
|
||||
<string name="mod_setKey_N0_in_element_N1">Wert ''{0}'' in Element ''{1}'' verändert.</string>
|
||||
|
@ -1137,6 +1137,18 @@
|
||||
<string name="key_useDefShape">Use Default Shape</string>
|
||||
<string name="key_useDefShape_tt">Use the default shape instead of using the DIL or custom shape configured in the circuit.</string>
|
||||
|
||||
<string name="key_textOrientation">Orientation</string>
|
||||
<string name="key_textOrientation_tt">Position of the coordinate relative to the text.</string>
|
||||
<string name="key_textOrientation_LEFTBOTTOM">left bottom</string>
|
||||
<string name="key_textOrientation_CENTERBOTTOM">center bottom</string>
|
||||
<string name="key_textOrientation_RIGHTBOTTOM">right bottom</string>
|
||||
<string name="key_textOrientation_RIGHTCENTER">right center</string>
|
||||
<string name="key_textOrientation_RIGHTTOP">right top</string>
|
||||
<string name="key_textOrientation_CENTERTOP">center top</string>
|
||||
<string name="key_textOrientation_LEFTTOP">left top</string>
|
||||
<string name="key_textOrientation_LEFTCENTER">left center</string>
|
||||
<string name="key_textOrientation_CENTERCENTER">center center</string>
|
||||
|
||||
<string name="mod_insertWire">Inserted wire.</string>
|
||||
<string name="mod_insertCopied">Insert from clipboard.</string>
|
||||
<string name="mod_setKey_N0_in_element_N1">Value ''{0}'' in component ''{1}'' modified.</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user