adds a label to GND and VDD, closes #439

This commit is contained in:
hneemann 2020-04-10 09:51:14 +02:00
parent 042124cd67
commit f09052d0e1
4 changed files with 15 additions and 7 deletions

View File

@ -25,7 +25,8 @@ public class Ground implements Element {
*/
public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(Ground.class)
.addAttribute(Keys.ROTATE)
.addAttribute(Keys.BITS);
.addAttribute(Keys.BITS)
.addAttribute(Keys.LABEL);
private final ObservableValue output;

View File

@ -25,7 +25,8 @@ public class VDD implements Element {
*/
public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(VDD.class)
.addAttribute(Keys.ROTATE)
.addAttribute(Keys.BITS);
.addAttribute(Keys.BITS)
.addAttribute(Keys.LABEL);
private final ObservableValue output;

View File

@ -12,6 +12,7 @@ import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
import de.neemann.digital.draw.graphics.Graphic;
import de.neemann.digital.draw.graphics.Orientation;
import de.neemann.digital.draw.graphics.Style;
import de.neemann.digital.draw.graphics.Vector;
@ -23,6 +24,7 @@ import static de.neemann.digital.draw.shapes.GenericShape.SIZE2;
public class GroundShape implements Shape {
private final PinDescriptions outputs;
private final String label;
/**
* Creates a new instance
@ -33,6 +35,7 @@ public class GroundShape implements Shape {
*/
public GroundShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs) {
this.outputs = outputs;
label = attr.getLabel();
}
@Override
@ -48,5 +51,7 @@ public class GroundShape implements Shape {
@Override
public void drawTo(Graphic graphic, Style heighLight) {
graphic.drawLine(new Vector(-SIZE2, 0), new Vector(SIZE2, 0), Style.THICK);
if (!label.isEmpty())
graphic.drawText(new Vector(0, SIZE2), label, Orientation.CENTERTOP, Style.SHAPE_PIN);
}
}

View File

@ -11,20 +11,18 @@ import de.neemann.digital.core.element.PinDescriptions;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
import de.neemann.digital.draw.graphics.Graphic;
import de.neemann.digital.draw.graphics.Polygon;
import de.neemann.digital.draw.graphics.Style;
import de.neemann.digital.draw.graphics.Vector;
import de.neemann.digital.draw.graphics.*;
import static de.neemann.digital.draw.shapes.GenericShape.SIZE;
import static de.neemann.digital.draw.shapes.GenericShape.SIZE2;
/**
* The Vcc shape
* The VDD shape
*/
public class VDDShape implements Shape {
static final int DOWNSHIFT = 4;
private final PinDescriptions outputs;
private final String label;
/**
* Creates a new instance
@ -35,6 +33,7 @@ public class VDDShape implements Shape {
*/
public VDDShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs) {
this.outputs = outputs;
label = attr.getLabel();
}
@Override
@ -55,5 +54,7 @@ public class VDDShape implements Shape {
.add(0, DOWNSHIFT - SIZE * 2 / 3)
.add(SIZE2, DOWNSHIFT), Style.NORMAL);
graphic.drawLine(new Vector(0, -SIZE2 + DOWNSHIFT), new Vector(0, 0), Style.NORMAL);
if (!label.isEmpty())
graphic.drawText(new Vector(0, DOWNSHIFT - SIZE * 2 / 3 - SIZE2), label, Orientation.CENTERBOTTOM, Style.SHAPE_PIN);
}
}