mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-17 08:55:05 -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>
|
<string>Y</string>
|
||||||
</entry>
|
</entry>
|
||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="540" y="180"/>
|
<pos x="480" y="180"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
<elementName>Or</elementName>
|
<elementName>Or</elementName>
|
||||||
<elementAttributes/>
|
<elementAttributes/>
|
||||||
<pos x="420" y="160"/>
|
<pos x="400" y="160"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
<elementName>And</elementName>
|
<elementName>And</elementName>
|
||||||
<elementAttributes/>
|
<elementAttributes/>
|
||||||
<pos x="280" y="120"/>
|
<pos x="300" y="120"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
<elementName>And</elementName>
|
<elementName>And</elementName>
|
||||||
<elementAttributes/>
|
<elementAttributes/>
|
||||||
<pos x="280" y="200"/>
|
<pos x="300" y="200"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
<elementName>Not</elementName>
|
<elementName>Not</elementName>
|
||||||
<elementAttributes/>
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>wideShape</string>
|
||||||
|
<boolean>true</boolean>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
<pos x="220" y="120"/>
|
<pos x="220" y="120"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
<elementName>Not</elementName>
|
<elementName>Not</elementName>
|
||||||
<elementAttributes/>
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>wideShape</string>
|
||||||
|
<boolean>true</boolean>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
<pos x="220" y="240"/>
|
<pos x="220" y="240"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
@ -79,43 +89,43 @@
|
|||||||
<wires>
|
<wires>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="200" y="160"/>
|
<p1 x="200" y="160"/>
|
||||||
<p2 x="260" y="200"/>
|
<p2 x="280" y="200"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="200" y="200"/>
|
<p1 x="200" y="200"/>
|
||||||
<p2 x="260" y="160"/>
|
|
||||||
</wire>
|
|
||||||
<wire>
|
|
||||||
<p1 x="260" y="160"/>
|
|
||||||
<p2 x="280" y="160"/>
|
<p2 x="280" y="160"/>
|
||||||
</wire>
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="280" y="160"/>
|
||||||
|
<p2 x="300" y="160"/>
|
||||||
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="380" y="160"/>
|
<p1 x="380" y="160"/>
|
||||||
<p2 x="420" y="160"/>
|
<p2 x="400" y="160"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="180" y="240"/>
|
<p1 x="180" y="240"/>
|
||||||
<p2 x="200" y="240"/>
|
<p2 x="200" y="240"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="260" y="240"/>
|
<p1 x="280" y="240"/>
|
||||||
<p2 x="280" y="240"/>
|
<p2 x="300" y="240"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="200" y="240"/>
|
<p1 x="200" y="240"/>
|
||||||
<p2 x="220" y="240"/>
|
<p2 x="220" y="240"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="480" y="180"/>
|
<p1 x="460" y="180"/>
|
||||||
<p2 x="540" y="180"/>
|
<p2 x="480" y="180"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="180" y="120"/>
|
<p1 x="180" y="120"/>
|
||||||
<p2 x="200" y="120"/>
|
<p2 x="200" y="120"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="260" y="120"/>
|
<p1 x="280" y="120"/>
|
||||||
<p2 x="280" y="120"/>
|
<p2 x="300" y="120"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="200" y="120"/>
|
<p1 x="200" y="120"/>
|
||||||
@ -123,18 +133,18 @@
|
|||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="380" y="200"/>
|
<p1 x="380" y="200"/>
|
||||||
<p2 x="420" y="200"/>
|
<p2 x="400" y="200"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="260" y="200"/>
|
<p1 x="280" y="200"/>
|
||||||
<p2 x="280" y="200"/>
|
<p2 x="300" y="200"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="340" y="220"/>
|
<p1 x="360" y="220"/>
|
||||||
<p2 x="380" y="220"/>
|
<p2 x="380" y="220"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="340" y="140"/>
|
<p1 x="360" y="140"/>
|
||||||
<p2 x="380" y="140"/>
|
<p2 x="380" y="140"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
|
@ -40,9 +40,10 @@ public class GenericShape implements Shape {
|
|||||||
private boolean invert = false;
|
private boolean invert = false;
|
||||||
private Color color = Color.WHITE;
|
private Color color = Color.WHITE;
|
||||||
|
|
||||||
private transient Pins pins;
|
private Pins pins;
|
||||||
private boolean showPinLabels;
|
private boolean showPinLabels;
|
||||||
private InverterConfig inverterConfig;
|
private InverterConfig inverterConfig;
|
||||||
|
private int topBottomBorder = SIZE2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new generic shape.
|
* Creates a new generic shape.
|
||||||
@ -102,6 +103,17 @@ public class GenericShape implements Shape {
|
|||||||
return this;
|
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
|
* Sets the background color
|
||||||
*
|
*
|
||||||
@ -190,15 +202,15 @@ public class GenericShape implements Shape {
|
|||||||
@Override
|
@Override
|
||||||
public void drawTo(Graphic graphic, Style highLight) {
|
public void drawTo(Graphic graphic, Style highLight) {
|
||||||
int max = Math.max(inputs.size(), outputs.size());
|
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)
|
Polygon polygon = new Polygon(true)
|
||||||
.add(1, -SIZE2)
|
.add(1, -topBottomBorder)
|
||||||
.add(SIZE * width - 1, -SIZE2)
|
.add(SIZE * width - 1, -topBottomBorder)
|
||||||
.add(SIZE * width - 1, height)
|
.add(SIZE * width - 1, yBottom)
|
||||||
.add(1, height);
|
.add(1, yBottom);
|
||||||
|
|
||||||
if (color != Color.WHITE && !graphic.isFlagSet(Graphic.LATEX))
|
if (color != Color.WHITE && !graphic.isFlagSet(Graphic.LATEX))
|
||||||
graphic.drawPolygon(polygon, Style.NORMAL.deriveFillStyle(color));
|
graphic.drawPolygon(polygon, Style.NORMAL.deriveFillStyle(color));
|
||||||
@ -213,7 +225,7 @@ public class GenericShape implements Shape {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (label != null) {
|
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);
|
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() > 0) {
|
||||||
if (name.length() <= 3 && !showPinLabels) {
|
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);
|
graphic.drawText(pos, pos.add(1, 0), name, Orientation.CENTERTOP, Style.NORMAL);
|
||||||
} else {
|
} 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);
|
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(NOr.DESCRIPTION.getName(), new CreatorSimple("\u22651", true));
|
||||||
map.put(XOr.DESCRIPTION.getName(), new CreatorSimple("=1", false));
|
map.put(XOr.DESCRIPTION.getName(), new CreatorSimple("=1", false));
|
||||||
map.put(XNOr.DESCRIPTION.getName(), new CreatorSimple("=1", true));
|
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