mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-12 14:26:09 -04:00
improved the probe shape
This commit is contained in:
parent
1de142d984
commit
ed38b08835
@ -5,13 +5,13 @@
|
||||
*/
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.IntFormat;
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.Value;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.core.IntFormat;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
import de.neemann.digital.draw.elements.Pin;
|
||||
import de.neemann.digital.draw.elements.Pins;
|
||||
@ -19,7 +19,6 @@ import de.neemann.digital.draw.graphics.Graphic;
|
||||
import de.neemann.digital.draw.graphics.Orientation;
|
||||
import de.neemann.digital.draw.graphics.Style;
|
||||
import de.neemann.digital.draw.graphics.Vector;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
/**
|
||||
* The probe shape
|
||||
@ -29,7 +28,7 @@ public class ProbeShape implements Shape {
|
||||
private final String label;
|
||||
private final PinDescriptions inputs;
|
||||
private final IntFormat format;
|
||||
private int bits;
|
||||
private final boolean isLabel;
|
||||
private ObservableValue inValue;
|
||||
private Value inValueCopy;
|
||||
|
||||
@ -42,10 +41,8 @@ public class ProbeShape implements Shape {
|
||||
*/
|
||||
public ProbeShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs) {
|
||||
this.inputs = inputs;
|
||||
String label = attr.getLabel();
|
||||
if (label == null || label.length() == 0)
|
||||
label = Lang.get("name");
|
||||
this.label = label;
|
||||
label = attr.getLabel();
|
||||
isLabel = label != null && label.length() > 0;
|
||||
this.format = attr.get(Keys.INT_FORMAT);
|
||||
}
|
||||
|
||||
@ -58,22 +55,28 @@ public class ProbeShape implements Shape {
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
inValue = ioState.getInput(0);
|
||||
inValue.addObserverToValue(guiObserver);
|
||||
bits = inValue.getBits();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readObservableValues() {
|
||||
if (bits > 1)
|
||||
if (inValue != null)
|
||||
inValueCopy = inValue.getCopy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
graphic.drawText(new Vector(2, -1), new Vector(3, -1), label, Orientation.LEFTBOTTOM, Style.NORMAL);
|
||||
if (bits > 1) {
|
||||
String v = format.formatToView(inValueCopy);
|
||||
graphic.drawText(new Vector(2, 1), new Vector(3, 1), v, Orientation.LEFTTOP, Style.NORMAL);
|
||||
int dy = -1;
|
||||
Orientation orientation = Orientation.LEFTCENTER;
|
||||
if (isLabel) {
|
||||
graphic.drawText(new Vector(2, -4), new Vector(3, -4), label, Orientation.LEFTBOTTOM, Style.NORMAL);
|
||||
dy = 4;
|
||||
orientation = Orientation.LEFTTOP;
|
||||
}
|
||||
String v = "?";
|
||||
if (inValueCopy != null)
|
||||
v = format.formatToView(inValueCopy);
|
||||
graphic.drawText(new Vector(2, dy), new Vector(3, dy), v, orientation, Style.NORMAL);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="addr">Adresse</string>
|
||||
<string name="name">Name</string>
|
||||
<string name="tableOfContent">Inhaltsverzeichnis</string>
|
||||
<string name="general">Allgemein</string>
|
||||
<string name="revision">Version</string>
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="addr">Address</string>
|
||||
<string name="name">Name</string>
|
||||
<string name="tableOfContent">Table of Contents</string>
|
||||
<string name="general">General</string>
|
||||
<string name="revision">Revision</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user