Search in sources :

Example 1 with StatisticsUI

use of org.gephi.statistics.spi.StatisticsUI in project gephi by gephi.

the class StatisticsControllerUIImpl method execute.

@Override
public void execute(final Statistics statistics) {
    StatisticsController controller = Lookup.getDefault().lookup(StatisticsController.class);
    final StatisticsUI[] uis = getUI(statistics);
    for (StatisticsUI s : uis) {
        s.setup(statistics);
    }
    model.setRunning(statistics, true);
    controller.execute(statistics, new LongTaskListener() {

        @Override
        public void taskFinished(LongTask task) {
            model.setRunning(statistics, false);
            for (StatisticsUI s : uis) {
                model.addResult(s);
                s.unsetup();
            }
        }
    });
}
Also used : StatisticsController(org.gephi.statistics.api.StatisticsController) LongTaskListener(org.gephi.utils.longtask.api.LongTaskListener) LongTask(org.gephi.utils.longtask.spi.LongTask) StatisticsUI(org.gephi.statistics.spi.StatisticsUI)

Example 2 with StatisticsUI

use of org.gephi.statistics.spi.StatisticsUI in project gephi by gephi.

the class StatisticsControllerUIImpl method getUI.

public StatisticsUI[] getUI(Statistics statistics) {
    boolean dynamic = false;
    ArrayList<StatisticsUI> list = new ArrayList<>();
    for (StatisticsUI sui : Lookup.getDefault().lookupAll(StatisticsUI.class)) {
        if (sui.getStatisticsClass().equals(statistics.getClass())) {
            list.add(sui);
        }
    }
    return list.toArray(new StatisticsUI[0]);
}
Also used : StatisticsUI(org.gephi.statistics.spi.StatisticsUI) ArrayList(java.util.ArrayList)

Example 3 with StatisticsUI

use of org.gephi.statistics.spi.StatisticsUI in project gephi by gephi.

the class StatisticsControllerUIImpl method execute.

@Override
public void execute(final Statistics statistics, final LongTaskListener listener) {
    StatisticsController controller = Lookup.getDefault().lookup(StatisticsController.class);
    final StatisticsUI[] uis = getUI(statistics);
    for (StatisticsUI s : uis) {
        s.setup(statistics);
    }
    model.setRunning(statistics, true);
    controller.execute(statistics, new LongTaskListener() {

        @Override
        public void taskFinished(LongTask task) {
            model.setRunning(statistics, false);
            for (StatisticsUI s : uis) {
                model.addResult(s);
                s.unsetup();
            }
            if (listener != null) {
                listener.taskFinished(statistics instanceof LongTask ? (LongTask) statistics : null);
            }
        }
    });
}
Also used : StatisticsController(org.gephi.statistics.api.StatisticsController) LongTaskListener(org.gephi.utils.longtask.api.LongTaskListener) LongTask(org.gephi.utils.longtask.spi.LongTask) StatisticsUI(org.gephi.statistics.spi.StatisticsUI)

Example 4 with StatisticsUI

use of org.gephi.statistics.spi.StatisticsUI in project gephi by gephi.

the class StatisticsModelUIImpl method readXML.

public void readXML(XMLStreamReader reader) throws XMLStreamException {
    Collection<? extends StatisticsUI> uis = Lookup.getDefault().lookupAll(StatisticsUI.class);
    boolean end = false;
    while (reader.hasNext() && !end) {
        int type = reader.next();
        switch(type) {
            case XMLStreamReader.START_ELEMENT:
                String name = reader.getLocalName();
                if ("result".equalsIgnoreCase(name)) {
                    String classStr = reader.getAttributeValue(null, "class");
                    StatisticsUI resultUI = null;
                    for (StatisticsUI ui : uis) {
                        if (ui.getClass().getName().equals(classStr)) {
                            resultUI = ui;
                        }
                    }
                    if (resultUI != null) {
                        String value = reader.getAttributeValue(null, "value");
                        resultMap.put(resultUI, value);
                    }
                }
                break;
            case XMLStreamReader.END_ELEMENT:
                if ("statisticsmodelui".equalsIgnoreCase(reader.getLocalName())) {
                    end = true;
                }
                break;
        }
    }
}
Also used : StatisticsUI(org.gephi.statistics.spi.StatisticsUI)

Example 5 with StatisticsUI

use of org.gephi.statistics.spi.StatisticsUI in project gephi by gephi.

the class StatisticsPanel method initCategories.

private void initCategories() {
    Map<String, StatisticsCategory> cats = new LinkedHashMap<>();
    cats.put(StatisticsUI.CATEGORY_NETWORK_OVERVIEW, new StatisticsCategory(StatisticsUI.CATEGORY_NETWORK_OVERVIEW, 100));
    cats.put(StatisticsUI.CATEGORY_NODE_OVERVIEW, new StatisticsCategory(StatisticsUI.CATEGORY_NODE_OVERVIEW, 200));
    cats.put(StatisticsUI.CATEGORY_EDGE_OVERVIEW, new StatisticsCategory(StatisticsUI.CATEGORY_EDGE_OVERVIEW, 300));
    cats.put(StatisticsUI.CATEGORY_DYNAMIC, new StatisticsCategory(StatisticsUI.CATEGORY_DYNAMIC, 400));
    int position = 500;
    for (StatisticsUI uis : Lookup.getDefault().lookupAll(StatisticsUI.class)) {
        String category = uis.getCategory();
        if (!cats.containsKey(category)) {
            cats.put(category, new StatisticsCategory(category, position));
            position += 100;
        }
    }
    categories = cats.values().toArray(new StatisticsCategory[0]);
}
Also used : StatisticsUI(org.gephi.statistics.spi.StatisticsUI) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

StatisticsUI (org.gephi.statistics.spi.StatisticsUI)7 ArrayList (java.util.ArrayList)3 Comparator (java.util.Comparator)2 JPanel (javax.swing.JPanel)2 MigLayout (net.miginfocom.swing.MigLayout)2 StatisticsController (org.gephi.statistics.api.StatisticsController)2 LongTaskListener (org.gephi.utils.longtask.api.LongTaskListener)2 LongTask (org.gephi.utils.longtask.spi.LongTask)2 LinkedHashMap (java.util.LinkedHashMap)1 JCheckBox (javax.swing.JCheckBox)1