本文整理汇总了Java中com.cburch.logisim.util.StringUtil.toHexString方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtil.toHexString方法的具体用法?Java StringUtil.toHexString怎么用?Java StringUtil.toHexString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.cburch.logisim.util.StringUtil
的用法示例。
在下文中一共展示了StringUtil.toHexString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintInstance
import com.cburch.logisim.util.StringUtil; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
Graphics g = painter.getGraphics();
Bounds bds = painter.getBounds();
StateData state = (StateData) painter.getData();
BitWidth widthVal = painter.getAttributeValue(StdAttr.WIDTH);
int width = widthVal == null ? 8 : widthVal.getWidth();
// draw boundary, label
painter.drawRoundBounds(Color.WHITE);
painter.drawLabel();
// draw input and output ports
painter.drawPort(OUT, "Q", Direction.WEST);
painter.drawPort(RST);
painter.drawPort(NXT);
painter.drawClock(CK, Direction.EAST);
// draw contents
if (painter.getShowState()) {
int val = state == null ? 0 : state.value;
String str = StringUtil.toHexString(width, val);
if (str.length() <= 4) {
GraphicsUtil.drawText(g, str, bds.getX() + 15, bds.getY() + 4, GraphicsUtil.H_CENTER,
GraphicsUtil.V_TOP);
} else {
int split = str.length() - 4;
GraphicsUtil.drawText(g, str.substring(0, split), bds.getX() + 15, bds.getY() + 3,
GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
GraphicsUtil.drawText(g, str.substring(split), bds.getX() + 15, bds.getY() + 15, GraphicsUtil.H_CENTER,
GraphicsUtil.V_TOP);
}
}
}
示例2: DrawData
import com.cburch.logisim.util.StringUtil; //导入方法依赖的package包/类
private void DrawData(InstancePainter painter, int xpos, int ypos,
int NrOfBits, int Value) {
Graphics g = painter.getGraphics();
GraphicsUtil.switchToWidth(g, 2);
g.drawRect(xpos, ypos, 80, 20);
if (painter.getShowState()) {
String str = StringUtil.toHexString(NrOfBits, Value);
GraphicsUtil.drawCenteredText(g, str, xpos + 40, ypos + 10);
}
painter.drawPort(OUT);
GraphicsUtil.switchToWidth(g, 1);
}
示例3: paintInstance
import com.cburch.logisim.util.StringUtil; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
Graphics g = painter.getGraphics();
Bounds bds = painter.getBounds();
StateData state = (StateData) painter.getData();
BitWidth widthVal = painter.getAttributeValue(StdAttr.WIDTH);
int width = widthVal == null ? 8 : widthVal.getWidth();
// draw boundary, label
painter.drawBounds();
painter.drawLabel();
// draw input and output ports
painter.drawPort(OUT, "Q", Direction.WEST);
painter.drawPort(RST);
painter.drawPort(NXT);
painter.drawClock(CK, Direction.EAST);
// draw contents
if (painter.getShowState()) {
int val = state == null ? 0 : state.value;
String str = StringUtil.toHexString(width, val);
if (str.length() <= 4) {
GraphicsUtil.drawText(g, str,
bds.getX() + 15, bds.getY() + 4,
GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
} else {
int split = str.length() - 4;
GraphicsUtil.drawText(g, str.substring(0, split),
bds.getX() + 15, bds.getY() + 3,
GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
GraphicsUtil.drawText(g, str.substring(split),
bds.getX() + 15, bds.getY() + 15,
GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
}
}
}
示例4: paintInstance
import com.cburch.logisim.util.StringUtil; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
Graphics g = painter.getGraphics();
Bounds bds = painter.getBounds();
RegisterData state = (RegisterData) painter.getData();
BitWidth widthVal = painter.getAttributeValue(StdAttr.WIDTH);
int width = widthVal == null ? 8 : widthVal.getWidth();
// determine text to draw in label
String a;
String b = null;
if (painter.getShowState()) {
int val = state == null ? 0 : state.value;
String str = StringUtil.toHexString(width, val);
if (str.length() <= 4) {
a = str;
} else {
int split = str.length() - 4;
a = str.substring(0, split);
b = str.substring(split);
}
} else {
a = Strings.get("counterLabel");
b = Strings.get("registerWidthLabel", "" + widthVal.getWidth());
}
// draw boundary, label
painter.drawRoundBounds(Color.WHITE);
painter.drawLabel();
// draw input and output ports
if (b == null) {
painter.drawPort(IN, "D", Direction.EAST);
painter.drawPort(OUT, "Q", Direction.WEST);
} else {
painter.drawPort(IN);
painter.drawPort(OUT);
}
g.setColor(Color.GRAY);
painter.drawPort(LD);
painter.drawPort(CARRY);
painter.drawPort(PRE);
painter.drawPort(CLR, "0", Direction.SOUTH);
painter.drawPort(CT, Strings.get("counterEnableLabel"), Direction.EAST);
g.setColor(Color.BLACK);
painter.drawClock(CK, Direction.NORTH);
// draw contents
if (b == null) {
GraphicsUtil.drawText(g, a, bds.getX() + 15, bds.getY() + 4, GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
} else {
GraphicsUtil.drawText(g, a, bds.getX() + 15, bds.getY() + 3, GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
GraphicsUtil.drawText(g, b, bds.getX() + 15, bds.getY() + 15, GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
}
}
示例5: paintInstance
import com.cburch.logisim.util.StringUtil; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
Graphics g = painter.getGraphics();
Bounds bds = painter.getBounds();
RegisterData state = (RegisterData) painter.getData();
BitWidth widthVal = painter.getAttributeValue(StdAttr.WIDTH);
int width = widthVal == null ? 8 : widthVal.getWidth();
// determine text to draw in label
String a;
String b = null;
if (painter.getShowState()) {
int val = state == null ? 0 : state.value;
String str = StringUtil.toHexString(width, val);
if (str.length() <= 4) {
a = str;
} else {
int split = str.length() - 4;
a = str.substring(0, split);
b = str.substring(split);
}
} else {
a = Strings.get("registerLabel");
b = Strings.get("registerWidthLabel", "" + widthVal.getWidth());
}
// draw boundary, label
painter.drawRoundBounds(Color.WHITE);
// draw input and output ports
if (b == null) {
painter.drawPort(IN, "D", Direction.EAST);
painter.drawPort(OUT, "Q", Direction.WEST);
} else {
painter.drawPort(IN);
painter.drawPort(OUT);
}
g.setColor(Color.GRAY);
painter.drawPort(CLR, "0", Direction.SOUTH);
painter.drawPort(PRE);
painter.drawPort(EN, Strings.get("memEnableLabel"), Direction.EAST);
painter.drawPort(CS);
g.setColor(Color.BLACK);
painter.drawClock(CK, Direction.NORTH);
// draw contents
if (b == null) {
GraphicsUtil.drawText(g, a, bds.getX() + 15, bds.getY() + 4, GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
} else {
GraphicsUtil.drawText(g, a, bds.getX() + 15, bds.getY() + 3, GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
GraphicsUtil.drawText(g, b, bds.getX() + 15, bds.getY() + 15, GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
}
painter.drawLabel();
}
示例6: DrawRegister
import com.cburch.logisim.util.StringUtil; //导入方法依赖的package包/类
public static void DrawRegister(InstancePainter painter, int x, int y,
int nr_of_bits, boolean isLatch, boolean neg_active,
boolean has_we, Value value) {
int dq_width = (nr_of_bits == 1) ? 3 : 5;
int len = (nr_of_bits + 3) / 4;
int wid = 7 * len + 2;
int xoff = (60 - wid) / 2;
Graphics g = painter.getGraphics();
if (painter.getShowState()&&(value!=null)) {
if (value.isFullyDefined())
g.setColor(Color.LIGHT_GRAY);
else if (value.isErrorValue())
g.setColor(Color.RED);
else g.setColor(Color.BLUE);
g.fillRect(x + xoff, y + 1, wid, 16);
if (value.isFullyDefined())
g.setColor(Color.DARK_GRAY);
else
g.setColor(Color.YELLOW);
String str = "";
if (value.isFullyDefined())
str = StringUtil.toHexString(nr_of_bits, value.toIntValue());
else {
for (int i = 0 ; i < len ; i++)
str = str.concat("?");
}
GraphicsUtil.drawCenteredText(g, str, x + 30, y + 8);
g.setColor(Color.black);
}
GraphicsUtil.switchToWidth(g, 2);
g.drawRect(x + 10, y + 20, 40, 60);
if (nr_of_bits > 1) {
g.drawLine(x + 15, y + 80, x + 15, y + 85);
g.drawLine(x + 15, y + 85, x + 55, y + 85);
g.drawLine(x + 55, y + 25, x + 55, y + 85);
g.drawLine(x + 50, y + 25, x + 55, y + 25);
if (nr_of_bits > 2) {
g.drawLine(x + 20, y + 85, x + 20, y + 90);
g.drawLine(x + 20, y + 90, x + 60, y + 90);
g.drawLine(x + 60, y + 30, x + 60, y + 90);
g.drawLine(x + 55, y + 30, x + 60, y + 30);
}
}
GraphicsUtil.switchToWidth(g, 1);
GraphicsUtil.switchToWidth(g, dq_width);
g.drawLine(x, y + 30, x + 8, y + 30);
g.drawLine(x + 52, y + 30, x + 60, y + 30);
GraphicsUtil.switchToWidth(g, 1);
GraphicsUtil.drawCenteredText(g, "D", x + 18, y + 30);
GraphicsUtil.drawCenteredText(g, "Q", x + 41, y + 30);
GraphicsUtil.switchToWidth(g, 3);
g.drawLine(x + 30, y + 81, x + 30, y + 90);
GraphicsUtil.switchToWidth(g, 1);
g.setColor(Color.GRAY);
GraphicsUtil.drawCenteredText(g, "R", x + 30, y + 70);
g.setColor(Color.BLACK);
if (has_we) {
GraphicsUtil.drawCenteredText(g, "WE", x + 22, y + 50);
GraphicsUtil.switchToWidth(g, 3);
g.drawLine(x, y + 50, x + 10, y + 50);
GraphicsUtil.switchToWidth(g, 1);
}
if (!isLatch) {
GraphicsUtil.switchToWidth(g, 2);
g.drawLine(x + 10, y + 65, x + 20, y + 70);
g.drawLine(x + 10, y + 75, x + 20, y + 70);
GraphicsUtil.switchToWidth(g, 1);
} else {
GraphicsUtil.drawCenteredText(g, "E", x + 18, y + 70);
}
if (!neg_active) {
GraphicsUtil.switchToWidth(g, 3);
g.drawLine(x, y + 70, x + 10, y + 70);
GraphicsUtil.switchToWidth(g, 1);
} else {
GraphicsUtil.switchToWidth(g, 2);
g.drawOval(x, y + 65, 10, 10);
GraphicsUtil.switchToWidth(g, 1);
}
}
示例7: paintInstance
import com.cburch.logisim.util.StringUtil; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
Graphics g = painter.getGraphics();
Bounds bds = painter.getBounds();
RegisterData state = (RegisterData) painter.getData();
BitWidth widthVal = painter.getAttributeValue(StdAttr.WIDTH);
int width = widthVal == null ? 8 : widthVal.getWidth();
// determine text to draw in label
String a;
String b = null;
if (painter.getShowState()) {
int val = state == null ? 0 : state.value;
String str = StringUtil.toHexString(width, val);
if (str.length() <= 4) {
a = str;
} else {
int split = str.length() - 4;
a = str.substring(0, split);
b = str.substring(split);
}
} else {
a = Strings.get("counterLabel");
b = Strings.get("registerWidthLabel", "" + widthVal.getWidth());
}
// draw boundary, label
painter.drawBounds();
painter.drawLabel();
// draw input and output ports
if (b == null) {
painter.drawPort(IN, "D", Direction.EAST);
painter.drawPort(OUT, "Q", Direction.WEST);
} else {
painter.drawPort(IN);
painter.drawPort(OUT);
}
g.setColor(Color.GRAY);
painter.drawPort(LD);
painter.drawPort(CARRY);
painter.drawPort(CLR, "0", Direction.SOUTH);
painter.drawPort(CT, Strings.get("counterEnableLabel"), Direction.EAST);
g.setColor(Color.BLACK);
painter.drawClock(CK, Direction.NORTH);
// draw contents
if (b == null) {
GraphicsUtil.drawText(g, a, bds.getX() + 15, bds.getY() + 4,
GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
} else {
GraphicsUtil.drawText(g, a, bds.getX() + 15, bds.getY() + 3,
GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
GraphicsUtil.drawText(g, b, bds.getX() + 15, bds.getY() + 15,
GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
}
}
示例8: paintInstance
import com.cburch.logisim.util.StringUtil; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
Graphics g = painter.getGraphics();
Bounds bds = painter.getBounds();
RegisterData state = (RegisterData) painter.getData();
BitWidth widthVal = painter.getAttributeValue(StdAttr.WIDTH);
int width = widthVal == null ? 8 : widthVal.getWidth();
// determine text to draw in label
String a;
String b = null;
if (painter.getShowState()) {
int val = state == null ? 0 : state.value;
String str = StringUtil.toHexString(width, val);
if (str.length() <= 4) {
a = str;
} else {
int split = str.length() - 4;
a = str.substring(0, split);
b = str.substring(split);
}
} else {
a = Strings.get("registerLabel");
b = Strings.get("registerWidthLabel", "" + widthVal.getWidth());
}
// draw boundary, label
painter.drawBounds();
painter.drawLabel();
// draw input and output ports
if (b == null) {
painter.drawPort(IN, "D", Direction.EAST);
painter.drawPort(OUT, "Q", Direction.WEST);
} else {
painter.drawPort(IN);
painter.drawPort(OUT);
}
g.setColor(Color.GRAY);
painter.drawPort(CLR, "0", Direction.SOUTH);
painter.drawPort(EN, Strings.get("memEnableLabel"), Direction.EAST);
g.setColor(Color.BLACK);
painter.drawClock(CK, Direction.NORTH);
// draw contents
if (b == null) {
GraphicsUtil.drawText(g, a, bds.getX() + 15, bds.getY() + 4,
GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
} else {
GraphicsUtil.drawText(g, a, bds.getX() + 15, bds.getY() + 3,
GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
GraphicsUtil.drawText(g, b, bds.getX() + 15, bds.getY() + 15,
GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
}
}