val = data == null ? Value.FALSE : (Value) data.getValue();
} else {
val = Value.FALSE;
}
Color color = painter.getAttributeValue(Io.ATTR_COLOR);
if (!painter.shouldDrawColor()) {
int hue = (color.getRed() + color.getGreen() + color.getBlue()) / 3;
color = new Color(hue, hue, hue);
}
Graphics g = painter.getGraphics();
int depress;
if (val == Value.TRUE) {
x += DEPTH;
y += DEPTH;
Object labelLoc = painter.getAttributeValue(Io.ATTR_LABEL_LOC);
if (labelLoc == Io.LABEL_CENTER || labelLoc == Direction.NORTH
|| labelLoc == Direction.WEST) {
depress = DEPTH;
} else {
depress = 0;
}
Object facing = painter.getAttributeValue(StdAttr.FACING);
if (facing == Direction.NORTH || facing == Direction.WEST) {
Location p = painter.getLocation();
int px = p.getX();
int py = p.getY();
GraphicsUtil.switchToWidth(g, Wire.WIDTH);
g.setColor(Value.TRUE_COLOR);
if (facing == Direction.NORTH) g.drawLine(px, py, px, py + 10);
else g.drawLine(px, py, px + 10, py);
GraphicsUtil.switchToWidth(g, 1);
}
g.setColor(color);
g.fillRect(x, y, w - DEPTH, h - DEPTH);
g.setColor(Color.BLACK);
g.drawRect(x, y, w - DEPTH, h - DEPTH);
} else {
depress = 0;
int[] xp = new int[] { x, x + w - DEPTH, x + w, x + w, x + DEPTH, x };
int[] yp = new int[] { y, y, y + DEPTH, y + h, y + h, y + h - DEPTH };
g.setColor(color.darker());
g.fillPolygon(xp, yp, xp.length);
g.setColor(color);
g.fillRect(x, y, w - DEPTH, h - DEPTH);
g.setColor(Color.BLACK);
g.drawRect(x, y, w - DEPTH, h - DEPTH);