mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-16 16:34:47 -04:00
added IEEE Not shape
This commit is contained in:
parent
0aafead235
commit
cc6d4830b1
@ -13,6 +13,7 @@ import de.neemann.digital.core.wiring.*;
|
||||
import de.neemann.digital.draw.elements.Tunnel;
|
||||
import de.neemann.digital.draw.library.ElementLibrary;
|
||||
import de.neemann.digital.draw.shapes.ieee.IEEEAndShape;
|
||||
import de.neemann.digital.draw.shapes.ieee.IEEENotShape;
|
||||
import de.neemann.digital.draw.shapes.ieee.IEEEOrShape;
|
||||
import de.neemann.digital.draw.shapes.ieee.IEEEXOrShape;
|
||||
import de.neemann.digital.gui.LibrarySelector;
|
||||
@ -55,6 +56,7 @@ public final class ShapeFactory {
|
||||
map.put(NOr.DESCRIPTION.getName(), (attributes, inputs, outputs) -> new IEEEOrShape(inputs, outputs, true));
|
||||
map.put(XOr.DESCRIPTION.getName(), (attributes, inputs, outputs) -> new IEEEXOrShape(inputs, outputs, false));
|
||||
map.put(XNOr.DESCRIPTION.getName(), (attributes, inputs, outputs) -> new IEEEXOrShape(inputs, outputs, true));
|
||||
map.put(Not.DESCRIPTION.getName(), (attributes, inputs, outputs) -> new IEEENotShape(inputs, outputs));
|
||||
} else {
|
||||
map.put(And.DESCRIPTION.getName(), new CreatorSimple("&", And.DESCRIPTION, false));
|
||||
map.put(Or.DESCRIPTION.getName(), new CreatorSimple("\u22651", Or.DESCRIPTION, false));
|
||||
@ -62,9 +64,9 @@ public final class ShapeFactory {
|
||||
map.put(NOr.DESCRIPTION.getName(), new CreatorSimple("\u22651", NOr.DESCRIPTION, true));
|
||||
map.put(XOr.DESCRIPTION.getName(), new CreatorSimple("=1", XOr.DESCRIPTION, false));
|
||||
map.put(XNOr.DESCRIPTION.getName(), new CreatorSimple("=1", XNOr.DESCRIPTION, true));
|
||||
map.put(Not.DESCRIPTION.getName(), new CreatorSimple("", Not.DESCRIPTION, true));
|
||||
}
|
||||
|
||||
map.put(Not.DESCRIPTION.getName(), new CreatorSimple("", Not.DESCRIPTION, true));
|
||||
|
||||
map.put(RAMDualPort.DESCRIPTION.getName(), (attr, inputs, outputs) -> new RAMShape("RAM", RAMDualPort.DESCRIPTION.getInputDescription(attr), RAMDualPort.DESCRIPTION.getOutputDescriptions(attr), attr.getLabel()));
|
||||
map.put(RAMSinglePort.DESCRIPTION.getName(), (attr, inputs, outputs) -> new RAMShape("RAM", RAMSinglePort.DESCRIPTION.getInputDescription(attr), RAMSinglePort.DESCRIPTION.getOutputDescriptions(attr), attr.getLabel()));
|
||||
|
@ -0,0 +1,67 @@
|
||||
package de.neemann.digital.draw.shapes.ieee;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescription;
|
||||
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.shapes.Interactor;
|
||||
import de.neemann.digital.draw.shapes.Shape;
|
||||
|
||||
import static de.neemann.digital.draw.shapes.GenericShape.SIZE;
|
||||
import static de.neemann.digital.draw.shapes.GenericShape.SIZE2;
|
||||
|
||||
/**
|
||||
* IEEE Standard 91-1984 Not Shape
|
||||
*
|
||||
* @author hneemann
|
||||
*/
|
||||
public class IEEENotShape implements Shape {
|
||||
private final PinDescription[] inputs;
|
||||
private final PinDescription[] outputs;
|
||||
private Pins pins;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param inputs the inputs
|
||||
* @param outputs the outputs
|
||||
*/
|
||||
public IEEENotShape(PinDescription[] inputs, PinDescription[] outputs) {
|
||||
this.inputs = inputs;
|
||||
this.outputs = outputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pins getPins() {
|
||||
if (pins == null) {
|
||||
pins = new Pins();
|
||||
pins.add(new Pin(new Vector(0, 0), inputs[0]));
|
||||
pins.add(new Pin(new Vector(SIZE * 2, 0), outputs[0]));
|
||||
}
|
||||
return pins;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
graphic.drawPolygon(
|
||||
new Polygon(true)
|
||||
.add(1, -SIZE2 - 2)
|
||||
.add(SIZE - 1, 0)
|
||||
.add(1, SIZE2 + 2), Style.NORMAL
|
||||
);
|
||||
graphic.drawCircle(new Vector(SIZE + 1, -SIZE2 + 1),
|
||||
new Vector(SIZE * 2 - 1, SIZE2 - 1), Style.NORMAL);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user