some minor changes to IEEE Standard 91-1984 shapes

This commit is contained in:
hneemann 2016-05-11 18:14:10 +02:00
parent 9c0a2923a1
commit f8bbd1069a
7 changed files with 25 additions and 21 deletions

View File

@ -37,15 +37,14 @@ public class GraphicSwing implements Graphic {
public void drawPolygon(Polygon p, Style style) { public void drawPolygon(Polygon p, Style style) {
applyStyle(style); applyStyle(style);
Path2D path = new GeneralPath(); Path2D path = new GeneralPath();
for (int i=0;i<p.size();i++) { for (int i = 0; i < p.size(); i++) {
if (i == 0) { if (i == 0) {
path.moveTo(p.get(i).x, p.get(i).y); path.moveTo(p.get(i).x, p.get(i).y);
} else { } else {
if (p.isBezierStart(i)) { if (p.isBezierStart(i)) {
path.curveTo(p.get(i).x, p.get(i).y, p.get(i+1).x, p.get(i+1).y, p.get(i+2).x, p.get(i+2).y); path.curveTo(p.get(i).x, p.get(i).y, p.get(i + 1).x, p.get(i + 1).y, p.get(i + 2).x, p.get(i + 2).y);
i+=2; i += 2;
} } else
else
path.lineTo(p.get(i).x, p.get(i).y); path.lineTo(p.get(i).x, p.get(i).y);
} }
} }

View File

@ -24,8 +24,8 @@ public class IEEEAndShape extends IEEEGenericShape {
.add(1, SIZE * 2 + SIZE2) .add(1, SIZE * 2 + SIZE2)
.add(1, -SIZE2) .add(1, -SIZE2)
.add(SIZE + SIZE2, -SIZE2) .add(SIZE + SIZE2, -SIZE2)
.add(new Vector(SIZE*2, -SIZE2),new Vector(SIZE*3, 0),new Vector(SIZE*3-1, SIZE)) .add(new Vector(SIZE * 2, -SIZE2), new Vector(SIZE * 3, 0), new Vector(SIZE * 3 - 1, SIZE))
.add(new Vector(SIZE*3-1, SIZE*2),new Vector(SIZE*2, SIZE*2+SIZE2),new Vector(SIZE+SIZE2, SIZE*2+SIZE2)); .add(new Vector(SIZE * 3 - 1, SIZE * 2), new Vector(SIZE * 2, SIZE * 2 + SIZE2), new Vector(SIZE + SIZE2, SIZE * 2 + SIZE2));
} }
/** /**

View File

@ -1,8 +1,6 @@
package de.neemann.digital.draw.shapes.ieee; package de.neemann.digital.draw.shapes.ieee;
import de.neemann.digital.core.Observer; 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.core.element.PinDescription;
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;

View File

@ -28,12 +28,14 @@ public class IEEEOrShape extends IEEEGenericShape {
.add(SIZE2, -SIZE2) .add(SIZE2, -SIZE2)
.add(new Vector(SIZE, -SIZE2), .add(new Vector(SIZE, -SIZE2),
new Vector(SIZE * 2, 0), new Vector(SIZE * 2, 0),
new Vector(SIZE * 3-1, SIZE)) new Vector(SIZE * 3, SIZE))
.add(new Vector(SIZE * 2, SIZE * 2), .add(new Vector(SIZE * 2, SIZE * 2),
new Vector(SIZE, SIZE * 2 + SIZE2), new Vector(SIZE, SIZE * 2 + SIZE2),
new Vector(SIZE2, SIZE * 2 + SIZE2)); new Vector(SIZE2, SIZE * 2 + SIZE2));
} }
private final boolean center;
/** /**
* Creates a new instance * Creates a new instance
* *
@ -43,10 +45,15 @@ public class IEEEOrShape extends IEEEGenericShape {
*/ */
public IEEEOrShape(PinDescription[] inputs, PinDescription[] outputs, boolean invert) { public IEEEOrShape(PinDescription[] inputs, PinDescription[] outputs, boolean invert) {
super(inputs, outputs, invert); super(inputs, outputs, invert);
center = (inputs.length & 1) != 0;
} }
@Override @Override
protected void drawIEEE(Graphic graphic) { protected void drawIEEE(Graphic graphic) {
graphic.drawLine(new Vector(0, 0), new Vector(4, 0), Style.WIRE);
graphic.drawLine(new Vector(0, SIZE * 2), new Vector(4, SIZE * 2), Style.WIRE);
if (center)
graphic.drawLine(new Vector(0, SIZE), new Vector(7, SIZE), Style.WIRE);
graphic.drawPolygon(POLYGON, Style.NORMAL); graphic.drawPolygon(POLYGON, Style.NORMAL);
} }
} }

View File

@ -21,16 +21,16 @@ public class IEEEXOrShape extends IEEEGenericShape {
private static Polygon createPoly() { private static Polygon createPoly() {
return new Polygon(true) return new Polygon(true)
.add(SIZE2+1, SIZE * 2 + SIZE2) .add(SIZE2 + 1, SIZE * 2 + SIZE2)
.add(new Vector(SIZE, SIZE * 2), .add(new Vector(SIZE, SIZE * 2),
new Vector(SIZE, 0), new Vector(SIZE, 0),
new Vector(SIZE2, -SIZE2)) new Vector(SIZE2 + 1, -SIZE2))
.add(new Vector(SIZE, -SIZE2), .add(new Vector(SIZE, -SIZE2),
new Vector(SIZE * 2, 0), new Vector(SIZE * 2, 0),
new Vector(SIZE * 3-1, SIZE)) new Vector(SIZE * 3, SIZE))
.add(new Vector(SIZE * 2, SIZE * 2), .add(new Vector(SIZE * 2, SIZE * 2),
new Vector(SIZE, SIZE * 2 + SIZE2), new Vector(SIZE, SIZE * 2 + SIZE2),
new Vector(SIZE2+1, SIZE * 2 + SIZE2)); new Vector(SIZE2 + 1, SIZE * 2 + SIZE2));
} }
private static Polygon createPoly2() { private static Polygon createPoly2() {
@ -54,6 +54,8 @@ public class IEEEXOrShape extends IEEEGenericShape {
@Override @Override
protected void drawIEEE(Graphic graphic) { protected void drawIEEE(Graphic graphic) {
graphic.drawLine(new Vector(0, 0), new Vector(5 + SIZE2, 0), Style.WIRE);
graphic.drawLine(new Vector(0, SIZE * 2), new Vector(5 + SIZE2, SIZE * 2), Style.WIRE);
graphic.drawPolygon(POLYGON, Style.NORMAL); graphic.drawPolygon(POLYGON, Style.NORMAL);
graphic.drawPolygon(POLYGON2, Style.NORMAL); graphic.drawPolygon(POLYGON2, Style.NORMAL);
} }

View File

@ -330,7 +330,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (new AttributeDialog(Main.this, Settings.SETTINGS_KEYS, Settings.getInstance().getAttributes()).showDialog()) if (new AttributeDialog(Main.this, Settings.SETTINGS_KEYS, Settings.getInstance().getAttributes()).showDialog())
JOptionPane.showMessageDialog(Main.this,Lang.get("msg_restartNeeded"));; JOptionPane.showMessageDialog(Main.this, Lang.get("msg_restartNeeded"));
} }
}.setToolTip(Lang.get("menu_editSettings_tt")); }.setToolTip(Lang.get("menu_editSettings_tt"));

View File

@ -16,7 +16,7 @@ import java.util.ArrayList;
* <p/> * <p/>
* Created by Helmut.Neemann on 11.05.2016. * Created by Helmut.Neemann on 11.05.2016.
*/ */
public class Settings implements AttributeListener { public final class Settings implements AttributeListener {
/** /**
* The list of supported attributes. * The list of supported attributes.
@ -27,10 +27,8 @@ public class Settings implements AttributeListener {
SETTINGS_KEYS.add(Keys.SETTINGS_IEEE_SHAPES); SETTINGS_KEYS.add(Keys.SETTINGS_IEEE_SHAPES);
} }
private static SettingsHolder settingsHolder = new SettingsHolder(); private static final class SettingsHolder {
static final Settings INSTANCE = new Settings();
private static class SettingsHolder {
Settings INSTANCE = new Settings();
} }
/** /**
@ -39,7 +37,7 @@ public class Settings implements AttributeListener {
* @return the Settings * @return the Settings
*/ */
public static Settings getInstance() { public static Settings getInstance() {
return settingsHolder.INSTANCE; return SettingsHolder.INSTANCE;
} }
private ElementAttributes attributes; private ElementAttributes attributes;