本文整理汇总了Java中com.cburch.logisim.circuit.RadixOption.RADIX_2属性的典型用法代码示例。如果您正苦于以下问题:Java RadixOption.RADIX_2属性的具体用法?Java RadixOption.RADIX_2怎么用?Java RadixOption.RADIX_2使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.cburch.logisim.circuit.RadixOption
的用法示例。
在下文中一共展示了RadixOption.RADIX_2属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
@Override
public void draw(Graphics g) {
Value v = canvas.getCircuitState().getValue(wire.getEnd0());
RadixOption radix1 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX1.get());
RadixOption radix2 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX2.get());
if (radix1 == null)
radix1 = RadixOption.RADIX_2;
String vStr = radix1.toString(v);
if (radix2 != null && v.getWidth() > 1) {
vStr += " / " + radix2.toString(v);
}
FontMetrics fm = g.getFontMetrics();
g.setColor(caretColor);
g.fillRect(x + 2, y + 2, fm.stringWidth(vStr) + 4, fm.getAscent() + fm.getDescent() + 4);
g.setColor(Color.BLACK);
g.drawRect(x + 2, y + 2, fm.stringWidth(vStr) + 4, fm.getAscent() + fm.getDescent() + 4);
g.fillOval(x - 2, y - 2, 5, 5);
g.drawString(vStr, x + 4, y + 4 + fm.getAscent());
}
示例2: mouseReleased
@Override
public void mouseReleased(InstanceState state, MouseEvent e) {
if (state.getAttributeValue(RadixOption.ATTRIBUTE) == RadixOption.RADIX_2) {
int bit = getBit(state, e);
if (bit == bitPressed && bit >= 0) {
handleBitPress(state, bit, e);
}
bitPressed = -1;
} else {
PinState pinState = getState(state);
EditText dialog = new EditText(pinState.intendedValue,
state.getAttributeValue(RadixOption.ATTRIBUTE),
pinState.intendedValue.getWidth());
dialog.setLocation(e.getXOnScreen(), e.getYOnScreen());
dialog.setVisible(true);
// System.err.println("New Value: '" + dialog.getValue() + "'");
pinState.intendedValue = dialog.getValue();
state.fireInvalidated();
}
}
示例3: draw
@Override
public void draw(Graphics g) {
Value v = canvas.getCircuitState().getValue(wire.getEnd0());
RadixOption radix1 = RadixOption
.decode(AppPreferences.POKE_WIRE_RADIX1.get());
RadixOption radix2 = RadixOption
.decode(AppPreferences.POKE_WIRE_RADIX2.get());
if (radix1 == null)
radix1 = RadixOption.RADIX_2;
String vStr = radix1.toString(v);
if (radix2 != null && v.getWidth() > 1) {
vStr += " / " + radix2.toString(v);
}
FontMetrics fm = g.getFontMetrics();
g.setColor(caretColor);
g.fillRect(x + 2, y + 2, fm.stringWidth(vStr) + 4, fm.getAscent()
+ fm.getDescent() + 4);
g.setColor(Color.BLACK);
g.drawRect(x + 2, y + 2, fm.stringWidth(vStr) + 4, fm.getAscent()
+ fm.getDescent() + 4);
g.fillOval(x - 2, y - 2, 5, 5);
g.drawString(vStr, x + 4, y + 4 + fm.getAscent());
}
示例4: draw
@Override
public void draw(Graphics g) {
Value v = canvas.getCircuitState().getValue(wire.getEnd0());
RadixOption radix1 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX1.get());
RadixOption radix2 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX2.get());
if (radix1 == null) radix1 = RadixOption.RADIX_2;
String vStr = radix1.toString(v);
if (radix2 != null && v.getWidth() > 1) {
vStr += " / " + radix2.toString(v);
}
FontMetrics fm = g.getFontMetrics();
g.setColor(caretColor);
g.fillRect(x + 2, y + 2, fm.stringWidth(vStr) + 4,
fm.getAscent() + fm.getDescent() + 4);
g.setColor(Color.BLACK);
g.drawRect(x + 2, y + 2, fm.stringWidth(vStr) + 4,
fm.getAscent() + fm.getDescent() + 4);
g.fillOval(x - 2, y - 2, 5, 5);
g.drawString(vStr, x + 4, y + 4 + fm.getAscent());
}
示例5: paintValue
static void paintValue(InstancePainter painter, Value value) {
Graphics g = painter.getGraphics();
Bounds bds = painter.getBounds(); // intentionally with no graphics
// 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);
}
}
示例6: paintValue
static void paintValue(InstancePainter painter, Value value) {
Graphics g = painter.getGraphics();
Bounds bds = painter.getBounds(); // intentionally with no graphics
// 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);
}
}
示例7: paintValue
static void paintValue(InstancePainter painter, Value value) {
Graphics g = painter.getGraphics();
Bounds bds = painter.getBounds(); // intentionally with no graphics 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);
}
}