private void drawCircuitLabel(InstancePainter painter, Bounds bds,
Direction facing, Direction defaultFacing) {
AttributeSet staticAttrs = source.getStaticAttributes();
String label = staticAttrs.getValue(CircuitAttributes.CIRCUIT_LABEL_ATTR);
if (label != null && !label.equals("")) {
Direction up = staticAttrs.getValue(CircuitAttributes.CIRCUIT_LABEL_FACING_ATTR);
Font font = staticAttrs.getValue(CircuitAttributes.CIRCUIT_LABEL_FONT_ATTR);
int back = label.indexOf('\\');
int lines = 1;
boolean backs = false;
while (back >= 0 && back <= label.length() - 2) {
char c = label.charAt(back + 1);
if (c == 'n') lines++;
else if (c == '\\') backs = true;
back = label.indexOf('\\', back + 2);
}
int x = bds.getX() + bds.getWidth() / 2;
int y = bds.getY() + bds.getHeight() / 2;
Graphics g = painter.getGraphics().create();
double angle = Math.PI / 2 - (up.toRadians() - defaultFacing.toRadians()) - facing.toRadians();
if (g instanceof Graphics2D && Math.abs(angle) > 0.01) {
Graphics2D g2 = (Graphics2D) g;
g2.rotate(angle, x, y);
}
g.setFont(font);