added a label to the new LED

This commit is contained in:
hneemann 2018-03-30 17:53:46 +02:00
parent 763d68b22f
commit e950254f34

View File

@ -14,10 +14,7 @@ import de.neemann.digital.core.element.PinDescriptions;
import de.neemann.digital.draw.elements.IOState; import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin; import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins; import de.neemann.digital.draw.elements.Pins;
import de.neemann.digital.draw.graphics.Graphic; import de.neemann.digital.draw.graphics.*;
import de.neemann.digital.draw.graphics.Polygon;
import de.neemann.digital.draw.graphics.Style;
import de.neemann.digital.draw.graphics.Vector;
import static de.neemann.digital.draw.shapes.GenericShape.SIZE; import static de.neemann.digital.draw.shapes.GenericShape.SIZE;
@ -32,6 +29,7 @@ public class RealLEDShape implements Shape {
private static final int RAD = SIZE * 3 / 4; private static final int RAD = SIZE * 3 / 4;
private final PinDescriptions inputs; private final PinDescriptions inputs;
private final Style style; private final Style style;
private final String label;
private ObservableValue aValue; private ObservableValue aValue;
private ObservableValue cValue; private ObservableValue cValue;
private Value a; private Value a;
@ -47,6 +45,7 @@ public class RealLEDShape implements Shape {
public RealLEDShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs) { public RealLEDShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs) {
this.inputs = inputs; this.inputs = inputs;
style = Style.NORMAL.deriveFillStyle(attr.get(Keys.COLOR)); style = Style.NORMAL.deriveFillStyle(attr.get(Keys.COLOR));
label = attr.getLabel();
} }
@Override @Override
@ -83,12 +82,14 @@ public class RealLEDShape implements Shape {
Style.NORMAL Style.NORMAL
); );
graphic.drawLine(new Vector(0, SIZE * 4 - SIZE2), new Vector(0, SIZE * 4), Style.NORMAL); graphic.drawLine(new Vector(0, SIZE * 4 - SIZE2), new Vector(0, SIZE * 4), Style.NORMAL);
Vector textPos = new Vector(SIZE + SIZE2, SIZE);
graphic.drawText(textPos, textPos.add(1, 0), label, Orientation.LEFTCENTER, Style.NORMAL);
if (a == null || c == null) { if (a == null || c == null) {
graphic.drawPolygon( graphic.drawPolygon(
new Polygon(true) new Polygon(true)
.add(-SIZE2, -SIZE + 1 + SIZE + SIZE2) .add(-SIZE2, 1 + SIZE2)
.add(SIZE2, -SIZE + 1 + SIZE + SIZE2) .add(SIZE2, 1 + SIZE2)
.add(0, -1 + SIZE + SIZE2), .add(0, -1 + SIZE + SIZE2),
Style.NORMAL Style.NORMAL
); );
@ -96,18 +97,17 @@ public class RealLEDShape implements Shape {
graphic.drawLine(new Vector(0, -1 + SIZE + SIZE2), new Vector(0, SIZE * 4 - HEIGHT - SIZE2), Style.NORMAL); graphic.drawLine(new Vector(0, -1 + SIZE + SIZE2), new Vector(0, SIZE * 4 - HEIGHT - SIZE2), Style.NORMAL);
graphic.drawLine(new Vector(0, 0), new Vector(0, -1 + SIZE2), Style.NORMAL); graphic.drawLine(new Vector(0, 0), new Vector(0, -1 + SIZE2), Style.NORMAL);
graphic.drawLine(new Vector(SIZE - 1, SIZE2 + 1), new Vector(SIZE2, SIZE), Style.THIN); graphic.drawLine(new Vector(SIZE - 0, SIZE2 + 2), new Vector(SIZE2 + 1, SIZE + 1), Style.THIN);
graphic.drawLine(new Vector(SIZE - 3, SIZE2), new Vector(SIZE, SIZE2), Style.THIN); graphic.drawLine(new Vector(SIZE - 2, SIZE2 + 1), new Vector(SIZE + 1, SIZE2 + 1), Style.THIN);
graphic.drawLine(new Vector(SIZE, SIZE2 + 3), new Vector(SIZE, SIZE2), Style.THIN); graphic.drawLine(new Vector(SIZE + 1, SIZE2 + 4), new Vector(SIZE + 1, SIZE2 + 1), Style.THIN);
graphic.drawLine(new Vector(SIZE - 1 + 4, SIZE2 + 1 + 4), new Vector(SIZE2 + 4, SIZE + 4), Style.THIN); graphic.drawLine(new Vector(SIZE + 6, SIZE2 + 8), new Vector(SIZE2 + 7, SIZE + 7), Style.THIN);
graphic.drawLine(new Vector(SIZE - 3 + 4, SIZE2 + 4), new Vector(SIZE + 4, SIZE2 + 4), Style.THIN); graphic.drawLine(new Vector(SIZE + 4, SIZE2 + 7), new Vector(SIZE + 7, SIZE2 + 7), Style.THIN);
graphic.drawLine(new Vector(SIZE + 4, SIZE2 + 3 + 4), new Vector(SIZE + 4, SIZE2 + 4), Style.THIN); graphic.drawLine(new Vector(SIZE + 7, SIZE2 + 10), new Vector(SIZE + 7, SIZE2 + 7), Style.THIN);
} else { } else {
Vector center = new Vector(0, SIZE); Vector center = new Vector(0, SIZE);
Vector rad = new Vector(RAD, RAD); Vector rad = new Vector(RAD, RAD);
graphic.drawLine(new Vector(0, SIZE * 4 - SIZE2 - HEIGHT), new Vector(0, SIZE * 2 - 4), Style.NORMAL); graphic.drawLine(new Vector(0, SIZE * 4 - SIZE2 - HEIGHT), new Vector(0, 0), Style.NORMAL);
graphic.drawLine(new Vector(0, 0), new Vector(0, 5), Style.NORMAL);
graphic.drawCircle(center.sub(rad), center.add(rad), Style.FILLED); graphic.drawCircle(center.sub(rad), center.add(rad), Style.FILLED);
if (a.getBool() && !c.getBool()) { if (a.getBool() && !c.getBool()) {