use of com.cburch.logisim.circuit.RadixOption in project logisim-evolution by reds-heig.
the class ProbeAttributes method setValue.
@SuppressWarnings("unchecked")
@Override
public <V> void setValue(Attribute<V> attr, V value) {
V Oldvalue = null;
if (attr == StdAttr.FACING) {
Direction newValue = (Direction) value;
if (facing.equals(newValue))
return;
facing = (Direction) value;
} else if (attr == StdAttr.LABEL) {
String val = (String) value;
// }
if (label.equals(val))
return;
Oldvalue = (V) label;
label = val;
} else if (attr == Pin.ATTR_LABEL_LOC) {
Direction newValue = (Direction) value;
if (labelloc.equals(newValue))
return;
labelloc = newValue;
} else if (attr == StdAttr.LABEL_FONT) {
Font NewValue = (Font) value;
if (labelfont.equals(NewValue))
return;
labelfont = NewValue;
} else if (attr == RadixOption.ATTRIBUTE) {
RadixOption NewValue = (RadixOption) value;
if (radix.equals(NewValue))
return;
radix = NewValue;
} else {
throw new IllegalArgumentException("unknown attribute");
}
fireAttributeValueChanged(attr, value, Oldvalue);
}
use of com.cburch.logisim.circuit.RadixOption in project logisim-evolution by reds-heig.
the class Probe method paintValue.
static void paintValue(InstancePainter painter, Value value) {
Graphics g = painter.getGraphics();
// intentionally with no graphics
Bounds bds = painter.getBounds();
// object - we don't want label
// included
RadixOption radix = painter.getAttributeValue(RadixOption.ATTRIBUTE);
if (radix == null || radix == RadixOption.RADIX_2) {
int x = bds.getX();
int y = bds.getY();
int wid = value.getWidth();
if (wid == 0) {
x += bds.getWidth() / 2;
y += bds.getHeight() / 2;
GraphicsUtil.switchToWidth(g, 2);
g.drawLine(x - 4, y, x + 4, y);
return;
}
int x0 = bds.getX() + bds.getWidth() - 5;
int compWidth = wid * 10;
if (compWidth < bds.getWidth() - 3) {
x0 = bds.getX() + (bds.getWidth() + compWidth) / 2 - 5;
}
int cx = x0;
int cy = bds.getY() + bds.getHeight() - 12;
int cur = 0;
for (int k = 0; k < wid; k++) {
GraphicsUtil.drawCenteredText(g, value.get(k).toDisplayString(), cx, cy);
++cur;
if (cur == 8) {
cur = 0;
cx = x0;
cy -= 20;
} else {
cx -= 10;
}
}
} else {
String text = radix.toString(value);
GraphicsUtil.drawCenteredText(g, text, bds.getX() + bds.getWidth() / 2, bds.getY() + bds.getHeight() / 2);
}
}
Aggregations