mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-13 06:49:36 -04:00
adds a label to GND and VDD, closes #439
This commit is contained in:
parent
042124cd67
commit
f09052d0e1
@ -25,7 +25,8 @@ public class Ground implements Element {
|
|||||||
*/
|
*/
|
||||||
public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(Ground.class)
|
public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(Ground.class)
|
||||||
.addAttribute(Keys.ROTATE)
|
.addAttribute(Keys.ROTATE)
|
||||||
.addAttribute(Keys.BITS);
|
.addAttribute(Keys.BITS)
|
||||||
|
.addAttribute(Keys.LABEL);
|
||||||
|
|
||||||
private final ObservableValue output;
|
private final ObservableValue output;
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@ public class VDD implements Element {
|
|||||||
*/
|
*/
|
||||||
public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(VDD.class)
|
public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(VDD.class)
|
||||||
.addAttribute(Keys.ROTATE)
|
.addAttribute(Keys.ROTATE)
|
||||||
.addAttribute(Keys.BITS);
|
.addAttribute(Keys.BITS)
|
||||||
|
.addAttribute(Keys.LABEL);
|
||||||
|
|
||||||
private final ObservableValue output;
|
private final ObservableValue output;
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ 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.Graphic;
|
||||||
|
import de.neemann.digital.draw.graphics.Orientation;
|
||||||
import de.neemann.digital.draw.graphics.Style;
|
import de.neemann.digital.draw.graphics.Style;
|
||||||
import de.neemann.digital.draw.graphics.Vector;
|
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 {
|
public class GroundShape implements Shape {
|
||||||
|
|
||||||
private final PinDescriptions outputs;
|
private final PinDescriptions outputs;
|
||||||
|
private final String label;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance
|
* Creates a new instance
|
||||||
@ -33,6 +35,7 @@ public class GroundShape implements Shape {
|
|||||||
*/
|
*/
|
||||||
public GroundShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs) {
|
public GroundShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs) {
|
||||||
this.outputs = outputs;
|
this.outputs = outputs;
|
||||||
|
label = attr.getLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,5 +51,7 @@ public class GroundShape implements Shape {
|
|||||||
@Override
|
@Override
|
||||||
public void drawTo(Graphic graphic, Style heighLight) {
|
public void drawTo(Graphic graphic, Style heighLight) {
|
||||||
graphic.drawLine(new Vector(-SIZE2, 0), new Vector(SIZE2, 0), Style.THICK);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,20 +11,18 @@ 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;
|
||||||
import static de.neemann.digital.draw.shapes.GenericShape.SIZE2;
|
import static de.neemann.digital.draw.shapes.GenericShape.SIZE2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Vcc shape
|
* The VDD shape
|
||||||
*/
|
*/
|
||||||
public class VDDShape implements Shape {
|
public class VDDShape implements Shape {
|
||||||
static final int DOWNSHIFT = 4;
|
static final int DOWNSHIFT = 4;
|
||||||
private final PinDescriptions outputs;
|
private final PinDescriptions outputs;
|
||||||
|
private final String label;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance
|
* Creates a new instance
|
||||||
@ -35,6 +33,7 @@ public class VDDShape implements Shape {
|
|||||||
*/
|
*/
|
||||||
public VDDShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs) {
|
public VDDShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs) {
|
||||||
this.outputs = outputs;
|
this.outputs = outputs;
|
||||||
|
label = attr.getLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,5 +54,7 @@ public class VDDShape implements Shape {
|
|||||||
.add(0, DOWNSHIFT - SIZE * 2 / 3)
|
.add(0, DOWNSHIFT - SIZE * 2 / 3)
|
||||||
.add(SIZE2, DOWNSHIFT), Style.NORMAL);
|
.add(SIZE2, DOWNSHIFT), Style.NORMAL);
|
||||||
graphic.drawLine(new Vector(0, -SIZE2 + DOWNSHIFT), new Vector(0, 0), 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user