mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-24 04:42:51 -04:00
adds small inputs and outputs; closes #755
This commit is contained in:
parent
0c19684d5e
commit
467064ffa1
@ -234,6 +234,11 @@ public final class Keys {
|
||||
.setMax(10)
|
||||
.setSecondary();
|
||||
|
||||
/**
|
||||
* flag to select small inputs and outputs
|
||||
*/
|
||||
public static final Key<Boolean> IN_OUT_SMALL
|
||||
= new Key<>("small", false).allowGroupEdit().setSecondary();
|
||||
|
||||
/**
|
||||
* flag to enable realtime mode at a clock
|
||||
|
@ -41,6 +41,7 @@ public class In implements Element {
|
||||
.addAttribute(Keys.INT_FORMAT)
|
||||
.addAttribute(Keys.PINNUMBER)
|
||||
.addAttribute(Keys.ADD_VALUE_TO_GRAPH)
|
||||
.addAttribute(Keys.IN_OUT_SMALL)
|
||||
.supportsHDL();
|
||||
|
||||
private final ObservableValue output;
|
||||
|
@ -38,6 +38,7 @@ public class Out implements Element {
|
||||
.addAttribute(Keys.INT_FORMAT)
|
||||
.addAttribute(Keys.PINNUMBER)
|
||||
.addAttribute(Keys.ADD_VALUE_TO_GRAPH)
|
||||
.addAttribute(Keys.IN_OUT_SMALL)
|
||||
.supportsHDL();
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@ import de.neemann.gui.Screen;
|
||||
import java.awt.*;
|
||||
|
||||
import static de.neemann.digital.draw.shapes.GenericShape.SIZE2;
|
||||
import static de.neemann.digital.draw.shapes.OutputShape.*;
|
||||
import static de.neemann.digital.draw.shapes.OutputShape.LATEX_RAD;
|
||||
|
||||
/**
|
||||
* The input shape
|
||||
@ -39,6 +39,7 @@ public class InputShape implements Shape {
|
||||
private final boolean isHighZ;
|
||||
private final boolean avoidLow;
|
||||
private final int bits;
|
||||
private final boolean small;
|
||||
private IOState ioState;
|
||||
private SingleValueDialog dialog;
|
||||
private Value value;
|
||||
@ -66,6 +67,7 @@ public class InputShape implements Shape {
|
||||
avoidLow = isHighZ && attr.get(Keys.AVOID_ACTIVE_LOW);
|
||||
|
||||
bits = attr.getBits();
|
||||
small = attr.get(Keys.IN_OUT_SMALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -106,15 +108,16 @@ public class InputShape implements Shape {
|
||||
Vector textPos = new Vector(-SIZE2 - LATEX_RAD.x, 0);
|
||||
graphic.drawText(textPos, label, Orientation.RIGHTCENTER, Style.INOUT);
|
||||
} else {
|
||||
Style style = Style.NORMAL;
|
||||
final Polygon box = new Polygon(true).add(-OUT_SIZE * 2 - 1, -OUT_SIZE).add(-1, -OUT_SIZE).add(-1, OUT_SIZE).add(-OUT_SIZE * 2 - 1, OUT_SIZE);
|
||||
int outSize = OutputShape.getOutSize(small);
|
||||
Style style = OutputShape.getOutStyle(small);
|
||||
final Polygon box = new Polygon(true).add(-outSize * 2 - 1, -outSize).add(-1, -outSize).add(-1, outSize).add(-outSize * 2 - 1, outSize);
|
||||
if (value != null) {
|
||||
style = Style.getWireStyle(value);
|
||||
if (value.getBits() > 1) {
|
||||
Value v = value;
|
||||
if (inValue != null)
|
||||
v = inValue;
|
||||
Vector textPos = new Vector(-1 - OUT_SIZE, -4 - OUT_SIZE);
|
||||
Vector textPos = new Vector(-1 - outSize, -4 - outSize);
|
||||
graphic.drawText(textPos, formatter.formatToView(v), Orientation.CENTERBOTTOM, Style.NORMAL);
|
||||
} else {
|
||||
if (inValue != null && !inValue.isEqual(value))
|
||||
@ -124,10 +127,11 @@ public class InputShape implements Shape {
|
||||
|
||||
graphic.drawPolygon(box, Style.NORMAL);
|
||||
|
||||
Vector center = new Vector(-1 - OUT_SIZE, 0);
|
||||
graphic.drawCircle(center.sub(RAD), center.add(RAD), style);
|
||||
Vector center = new Vector(-1 - outSize, 0);
|
||||
Vector rad = OutputShape.getOutRad(small);
|
||||
graphic.drawCircle(center.sub(rad), center.add(rad), style);
|
||||
|
||||
Vector textPos = new Vector(-OUT_SIZE * 3, 0);
|
||||
Vector textPos = new Vector(-outSize * 3, 0);
|
||||
graphic.drawText(textPos, label, Orientation.RIGHTCENTER, Style.INOUT);
|
||||
}
|
||||
}
|
||||
|
@ -24,24 +24,54 @@ import static de.neemann.digital.draw.shapes.GenericShape.SIZE2;
|
||||
* The output shape
|
||||
*/
|
||||
public class OutputShape implements Shape {
|
||||
|
||||
/**
|
||||
* The size of the used grid
|
||||
* Size of the normal sized inputs and outputs
|
||||
*/
|
||||
public static final int OUT_SIZE = GenericShape.SIZE * 3 / 4;
|
||||
|
||||
/**
|
||||
* The size of the inputs and outputs
|
||||
*
|
||||
* @param small true if small symbol is used
|
||||
* @return the size
|
||||
*/
|
||||
public static int getOutSize(boolean small) {
|
||||
if (small)
|
||||
return SIZE2;
|
||||
else
|
||||
return OUT_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* The size of the inputs and outputs
|
||||
*
|
||||
* @param small true if small symbol is used
|
||||
* @return the size
|
||||
*/
|
||||
public static Style getOutStyle(boolean small) {
|
||||
if (small)
|
||||
return Style.THIN;
|
||||
else
|
||||
return Style.NORMAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inner circle size used for inputs and outputs
|
||||
*
|
||||
* @param small true if small symbol is used
|
||||
* @return the output circle radius as a vector
|
||||
*/
|
||||
public static final Vector RAD = new Vector(OUT_SIZE - 6, OUT_SIZE - 6);
|
||||
|
||||
public static Vector getOutRad(boolean small) {
|
||||
int s = getOutSize(small);
|
||||
return new Vector(s - 6, s - 6);
|
||||
}
|
||||
|
||||
static final Vector LATEX_RAD = new Vector(Style.MAXLINETHICK, Style.MAXLINETHICK);
|
||||
/**
|
||||
* Outer circle size used for inputs and outputs
|
||||
*/
|
||||
public static final Vector RADL = new Vector(OUT_SIZE, OUT_SIZE);
|
||||
private final String label;
|
||||
private final PinDescriptions inputs;
|
||||
private final ValueFormatter formatter;
|
||||
private final boolean small;
|
||||
private IOState ioState;
|
||||
private Value value;
|
||||
|
||||
@ -61,6 +91,7 @@ public class OutputShape implements Shape {
|
||||
this.label = attr.getLabel() + " (" + pinNumber + ")";
|
||||
|
||||
formatter = attr.getValueFormatter();
|
||||
small = attr.get(Keys.IN_OUT_SMALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,19 +119,23 @@ public class OutputShape implements Shape {
|
||||
Vector textPos = new Vector(SIZE2 + LATEX_RAD.x, 0);
|
||||
graphic.drawText(textPos, label, Orientation.LEFTCENTER, Style.INOUT);
|
||||
} else {
|
||||
Style style = Style.NORMAL;
|
||||
int outSize = getOutSize(small);
|
||||
Style style = getOutStyle(small);
|
||||
if (value != null) {
|
||||
style = Style.getWireStyle(value);
|
||||
if (value.getBits() > 1) {
|
||||
Vector textPos = new Vector(1 + OUT_SIZE, -4 - OUT_SIZE);
|
||||
Vector textPos = new Vector(1 + outSize, -4 - outSize);
|
||||
graphic.drawText(textPos, formatter.formatToView(value), Orientation.CENTERBOTTOM, Style.NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
Vector center = new Vector(1 + OUT_SIZE, 0);
|
||||
graphic.drawCircle(center.sub(RAD), center.add(RAD), style);
|
||||
graphic.drawCircle(center.sub(RADL), center.add(RADL), Style.NORMAL);
|
||||
Vector textPos = new Vector(OUT_SIZE * 3, 0);
|
||||
Vector radl = new Vector(outSize, outSize);
|
||||
Vector rad = getOutRad(small);
|
||||
|
||||
Vector center = new Vector(1 + outSize, 0);
|
||||
graphic.drawCircle(center.sub(rad), center.add(rad), style);
|
||||
graphic.drawCircle(center.sub(radl), center.add(radl), Style.NORMAL);
|
||||
Vector textPos = new Vector(outSize * 3, 0);
|
||||
graphic.drawText(textPos, label, Orientation.LEFTCENTER, Style.INOUT);
|
||||
}
|
||||
}
|
||||
|
@ -1292,6 +1292,8 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
||||
<string name="key_Label_tt">Die Bezeichnung dieses Elementes.</string>
|
||||
<string name="key_Size">Größe</string><!-- LED, SevenSeg -->
|
||||
<string name="key_Size_tt">Die Größe der Darstellung in der Schaltung.</string>
|
||||
<string name="key_small">Kleines Symbol</string>
|
||||
<string name="key_small_tt">Verwendet ein verkleinertes Symbol zur Darstellung.</string>
|
||||
<string name="key_Language">Sprache</string>
|
||||
<string name="key_Language_tt">Sprache der Oberfläche. Wird erst nach einem Neustart wirksam.</string>
|
||||
<string name="key_NetName">Netzname</string><!-- Tunnel -->
|
||||
|
@ -1278,6 +1278,8 @@
|
||||
<string name="key_Label_tt">The name of this element.</string>
|
||||
<string name="key_Size">Size</string><!-- LED, SevenSeg -->
|
||||
<string name="key_Size_tt">The size of the shape in the circuit.</string>
|
||||
<string name="key_small">Small Shape</string>
|
||||
<string name="key_small_tt">If selected, a smaller shape will be used.</string>
|
||||
<string name="key_Language">Language</string>
|
||||
<string name="key_Language_tt">Language of the GUI. Will only take effect after a restart.</string>
|
||||
<string name="key_NetName">Net name</string><!-- Tunnel -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user