@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 = getFromLocale("counterLabel");
b = getFromLocale("registerWidthLabel", "" + widthVal.getWidth());
}
// draw boundary, label
painter.drawBounds();
painter.drawLabel();