mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-16 08:25:09 -04:00
the not shape matches the standard better
This commit is contained in:
parent
76d45f5340
commit
0c3377976a
@ -31,31 +31,41 @@
|
||||
<string>Y</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="540" y="180"/>
|
||||
<pos x="480" y="180"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Or</elementName>
|
||||
<elementAttributes/>
|
||||
<pos x="420" y="160"/>
|
||||
<pos x="400" y="160"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>And</elementName>
|
||||
<elementAttributes/>
|
||||
<pos x="280" y="120"/>
|
||||
<pos x="300" y="120"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>And</elementName>
|
||||
<elementAttributes/>
|
||||
<pos x="280" y="200"/>
|
||||
<pos x="300" y="200"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Not</elementName>
|
||||
<elementAttributes/>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>wideShape</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="220" y="120"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Not</elementName>
|
||||
<elementAttributes/>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>wideShape</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="220" y="240"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
@ -79,43 +89,43 @@
|
||||
<wires>
|
||||
<wire>
|
||||
<p1 x="200" y="160"/>
|
||||
<p2 x="260" y="200"/>
|
||||
<p2 x="280" y="200"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="200" y="200"/>
|
||||
<p2 x="260" y="160"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="260" y="160"/>
|
||||
<p2 x="280" y="160"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="280" y="160"/>
|
||||
<p2 x="300" y="160"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="380" y="160"/>
|
||||
<p2 x="420" y="160"/>
|
||||
<p2 x="400" y="160"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="180" y="240"/>
|
||||
<p2 x="200" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="260" y="240"/>
|
||||
<p2 x="280" y="240"/>
|
||||
<p1 x="280" y="240"/>
|
||||
<p2 x="300" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="200" y="240"/>
|
||||
<p2 x="220" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="480" y="180"/>
|
||||
<p2 x="540" y="180"/>
|
||||
<p1 x="460" y="180"/>
|
||||
<p2 x="480" y="180"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="180" y="120"/>
|
||||
<p2 x="200" y="120"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="260" y="120"/>
|
||||
<p2 x="280" y="120"/>
|
||||
<p1 x="280" y="120"/>
|
||||
<p2 x="300" y="120"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="200" y="120"/>
|
||||
@ -123,18 +133,18 @@
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="380" y="200"/>
|
||||
<p2 x="420" y="200"/>
|
||||
<p2 x="400" y="200"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="260" y="200"/>
|
||||
<p2 x="280" y="200"/>
|
||||
<p1 x="280" y="200"/>
|
||||
<p2 x="300" y="200"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="340" y="220"/>
|
||||
<p1 x="360" y="220"/>
|
||||
<p2 x="380" y="220"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="340" y="140"/>
|
||||
<p1 x="360" y="140"/>
|
||||
<p2 x="380" y="140"/>
|
||||
</wire>
|
||||
<wire>
|
||||
|
@ -40,9 +40,10 @@ public class GenericShape implements Shape {
|
||||
private boolean invert = false;
|
||||
private Color color = Color.WHITE;
|
||||
|
||||
private transient Pins pins;
|
||||
private Pins pins;
|
||||
private boolean showPinLabels;
|
||||
private InverterConfig inverterConfig;
|
||||
private int topBottomBorder = SIZE2;
|
||||
|
||||
/**
|
||||
* Creates a new generic shape.
|
||||
@ -102,6 +103,17 @@ public class GenericShape implements Shape {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the top bottom border
|
||||
*
|
||||
* @param topBottomBorder the border
|
||||
* @return this for chaind calls
|
||||
*/
|
||||
public GenericShape setTopBottomBorder(int topBottomBorder) {
|
||||
this.topBottomBorder = topBottomBorder;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the background color
|
||||
*
|
||||
@ -190,15 +202,15 @@ public class GenericShape implements Shape {
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
int max = Math.max(inputs.size(), outputs.size());
|
||||
int height = (max - 1) * SIZE + SIZE2;
|
||||
int yBottom = (max - 1) * SIZE + topBottomBorder;
|
||||
|
||||
if (symmetric && inputs.size() > 0 && ((inputs.size() & 1) == 0)) height += SIZE;
|
||||
if (symmetric && inputs.size() > 0 && ((inputs.size() & 1) == 0)) yBottom += SIZE;
|
||||
|
||||
Polygon polygon = new Polygon(true)
|
||||
.add(1, -SIZE2)
|
||||
.add(SIZE * width - 1, -SIZE2)
|
||||
.add(SIZE * width - 1, height)
|
||||
.add(1, height);
|
||||
.add(1, -topBottomBorder)
|
||||
.add(SIZE * width - 1, -topBottomBorder)
|
||||
.add(SIZE * width - 1, yBottom)
|
||||
.add(1, yBottom);
|
||||
|
||||
if (color != Color.WHITE && !graphic.isFlagSet(Graphic.LATEX))
|
||||
graphic.drawPolygon(polygon, Style.NORMAL.deriveFillStyle(color));
|
||||
@ -213,7 +225,7 @@ public class GenericShape implements Shape {
|
||||
}
|
||||
|
||||
if (label != null) {
|
||||
Vector pos = new Vector(SIZE2 * width, -SIZE2 - 8);
|
||||
Vector pos = new Vector(SIZE2 * width, -topBottomBorder - 8);
|
||||
graphic.drawText(pos, pos.add(1, 0), label, Orientation.CENTERBOTTOM, Style.NORMAL);
|
||||
}
|
||||
|
||||
@ -238,10 +250,10 @@ public class GenericShape implements Shape {
|
||||
}
|
||||
if (name.length() > 0) {
|
||||
if (name.length() <= 3 && !showPinLabels) {
|
||||
Vector pos = new Vector(SIZE2 * width, -SIZE2 + 4);
|
||||
Vector pos = new Vector(SIZE2 * width, -topBottomBorder + 4);
|
||||
graphic.drawText(pos, pos.add(1, 0), name, Orientation.CENTERTOP, Style.NORMAL);
|
||||
} else {
|
||||
Vector pos = new Vector(SIZE2 * width, height + 4);
|
||||
Vector pos = new Vector(SIZE2 * width, yBottom + 4);
|
||||
graphic.drawText(pos, pos.add(1, 0), name, Orientation.CENTERTOP, Style.SHAPE_PIN);
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,14 @@ public final class ShapeFactory {
|
||||
map.put(NOr.DESCRIPTION.getName(), new CreatorSimple("\u22651", true));
|
||||
map.put(XOr.DESCRIPTION.getName(), new CreatorSimple("=1", false));
|
||||
map.put(XNOr.DESCRIPTION.getName(), new CreatorSimple("=1", true));
|
||||
map.put(Not.DESCRIPTION.getName(), new CreatorSimple("", true));
|
||||
map.put(Not.DESCRIPTION.getName(),
|
||||
(attributes, inputs, outputs) -> {
|
||||
final boolean ws = attributes.get(Keys.WIDE_SHAPE);
|
||||
return new GenericShape(ws ? "1" : "", inputs, outputs)
|
||||
.setTopBottomBorder(ws ? GenericShape.SIZE : GenericShape.SIZE2)
|
||||
.invert(true)
|
||||
.setWide(ws);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user