@Override
public void paintInstance(InstancePainter painter) {
Bounds bds = painter.getOffsetBounds();
BitWidth width = painter.getAttributeValue(StdAttr.WIDTH);
int intValue = painter.getAttributeValue(ATTR_VALUE).intValue();
Value v = Value.createKnown(width, intValue);
Location loc = painter.getLocation();
int x = loc.getX();
int y = loc.getY();
Graphics g = painter.getGraphics();
if (painter.shouldDrawColor()) {
g.setColor(BACKGROUND_COLOR);
g.fillRect(x + bds.getX(), y + bds.getY(), bds.getWidth(), bds.getHeight());
}
if (v.getWidth() == 1) {
if (painter.shouldDrawColor()) g.setColor(v.getColor());
GraphicsUtil.drawCenteredText(g, v.toString(),
x + bds.getX() + bds.getWidth() / 2,
y + bds.getY() + bds.getHeight() / 2 - 2);
} else {
g.setColor(Color.BLACK);
GraphicsUtil.drawCenteredText(g, v.toHexString(),
x + bds.getX() + bds.getWidth() / 2,
y + bds.getY() + bds.getHeight() / 2 - 2);
}
painter.drawPorts();
}