void
RoutingStatsScene::addToProxyWidgetsMap(uint32_t nodeId, QString title, QString content)
{

    if(m_nodeIdProxyWidgets.find(nodeId) == m_nodeIdProxyWidgets.end())
    {
        TextBubble * tb = new TextBubble (title, content);
        QFont f(tb->font());
        f.setPointSizeF(StatsMode::getInstance()->getCurrentFontSize());
        tb->setFont(f);
        QGraphicsProxyWidget * pw = addWidget(tb);


        QFontMetrics fm(f);
        pw->setMaximumHeight(fm.height() * tb->text().count("\n"));
        pw->adjustSize();
        showInfoWidget(false);
        m_nodeIdProxyWidgets[nodeId] = pw;
        qreal newX = m_lastX + pw->widget()->width();
        if(newX >= sceneRect().right())
        {
            m_lastX = 0;
            m_lastY += pw->widget()->height() + INTERSTATS_SPACE;
        }
        pw->setPos(m_lastX, m_lastY);

        m_lastX = pw->pos().x() + pw->widget()->width() + INTERSTATS_SPACE;
        m_lastY = pw->pos().y();
        m_bottomY = m_lastY + pw->widget()->height();
        //qDebug(QString("Last X" + QString::number(m_lastX) + " w:" + QString::number(pw->widget()->width())));
        adjustRect();
        return;
    }

}
void
FlowMonStatsScene::align()
{
    m_lastX = 0;
    m_lastY = 0;
    m_bottomY = 0;
    qreal currentMaxHeight = 0;

    for(FlowIdProxyWidgetMap_t::const_iterator i = m_flowIdProxyWidgets.begin();
        i != m_flowIdProxyWidgets.end();
        ++i)
    {
        QGraphicsProxyWidget * pw = i->second;
        bool flowIsActive = StatsMode::getInstance()->isNodeActive(i->first);
        pw->setVisible(flowIsActive);
        if(flowIsActive)
        {
            TextBubble * tb = (TextBubble *) pw->widget();
            QFont f(tb->font());
            f.setPointSizeF(StatsMode::getInstance()->getCurrentFontSize());
            tb->setFont(f);

            QFontMetrics fm(f);
            pw->setMaximumHeight(fm.height() * tb->text().count("\n"));
            pw->adjustSize();

            qreal newX = m_lastX + pw->size().width();
            currentMaxHeight = qMax(currentMaxHeight, pw->size().height());
            if(newX >= sceneRect().right())
            {
                m_lastX = 0;
                m_lastY += currentMaxHeight + INTERSTATS_SPACE;
                currentMaxHeight = 0;
            }
            pw->setPos(m_lastX, m_lastY);
            m_lastX = pw->pos().x() + pw->size().width() + INTERSTATS_SPACE;
            m_lastY = pw->pos().y();
            m_bottomY = m_lastY + currentMaxHeight;
            adjustRect();
        }
    }
    if(m_flowProbeWidget)
    {
            QGraphicsProxyWidget * pw = m_flowProbeWidget;
            TextBubble * tb = (TextBubble *) pw->widget();
            QFont f(tb->font());
            f.setPointSizeF(StatsMode::getInstance()->getCurrentFontSize());
            tb->setFont(f);

            QFontMetrics fm(f);
            pw->setMaximumHeight(fm.height() * tb->text().count("\n"));
            pw->adjustSize();

            qreal newX = m_lastX + pw->size().width();
            currentMaxHeight = qMax(currentMaxHeight, pw->size().height());
            if(newX >= sceneRect().right())
            {
                m_lastX = 0;
                m_lastY += currentMaxHeight + INTERSTATS_SPACE;
                currentMaxHeight = 0;
            }
            pw->setPos(m_lastX, m_lastY);
            m_lastX = pw->pos().x() + pw->size().width() + INTERSTATS_SPACE;
            m_lastY = pw->pos().y();
            m_bottomY = m_lastY + currentMaxHeight;
            adjustRect();

    }

}