private void drawStateOutput(Graphics g, State state, Point point, Color color) 
    {
        String output = ((MooreMachine) state.getAutomaton()).getStateDescription(state);
        
        int ascent = g.getFontMetrics().getAscent();
        int heights = 0;
        int textWidth = 0;
        
        Rectangle2D bounds = g.getFontMetrics().getStringBounds(output, g);
        textWidth = Math.max((int) bounds.getWidth(), textWidth);
        heights += ascent + STATE_LABEL_PAD;
        
        heights -= STATE_LABEL_PAD;
        
        // Width of the box.
        int width = textWidth + (STATE_LABEL_PAD<<1);
        int height = heights + (STATE_LABEL_PAD<<1);
        // Upper corner of the box.
        int x = point.x - (width>>1) + STATE_RADIUS;
        int y = point.y - STATE_RADIUS - height/2;
        // Where the y point of the baseline is.
        int baseline = y;
        
        g.setColor(color);
        g.fillRect(x, y, width, height);
        g.setColor(Color.black);
        baseline += ascent + STATE_LABEL_PAD;
        g.drawString(output, x + STATE_LABEL_PAD, baseline);
        g.drawRect(x, y, width, height);
    }