private int computeStage(InstanceState state, MouseEvent e) {
Integer lenObj = state.getAttributeValue(ShiftRegister.ATTR_LENGTH);
BitWidth widObj = state.getAttributeValue(StdAttr.WIDTH);
Boolean loadObj = state.getAttributeValue(ShiftRegister.ATTR_LOAD);
Bounds bds = state.getInstance().getBounds();
int y = bds.getY();
String label = state.getAttributeValue(StdAttr.LABEL);
if (label == null || label.equals("")) y += bds.getHeight() / 2;
else y += 3 * bds.getHeight() / 4;
y = e.getY() - y;
if (y <= -6 || y >= 8) return -1;
int x = e.getX() - (bds.getX() + 15);
if (!loadObj.booleanValue() || widObj.getWidth() > 4) return -1;
if (x < 0 || x >= lenObj.intValue() * 10) return -1;
return x / 10;
}