Search in sources :

Example 6 with StatisticsUI

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

the class StatisticsPanel method initFrontEnds.

private void initFrontEnds() {
    StatisticsUI[] statisticsUIs = Lookup.getDefault().lookupAll(StatisticsUI.class).toArray(new StatisticsUI[0]);
    frontEnds = new ArrayList<>();
    for (StatisticsCategory category : categories) {
        //Find uis in this category
        List<StatisticsUI> uis = new ArrayList<>();
        for (StatisticsUI sui : statisticsUIs) {
            if (sui.getCategory().equals(category.getName())) {
                uis.add(sui);
            }
        }
        if (uis.size() > 0) {
            //Sort it by position
            Collections.sort(uis, new Comparator() {

                @Override
                public int compare(Object o1, Object o2) {
                    Integer p1 = ((StatisticsUI) o1).getPosition();
                    Integer p2 = ((StatisticsUI) o2).getPosition();
                    return p1.compareTo(p2);
                }
            });
            MigLayout migLayout = new MigLayout("insets 0");
            migLayout.setColumnConstraints("[grow,fill]");
            migLayout.setRowConstraints("[pref!]");
            JPanel innerPanel = new JPanel(migLayout);
            for (StatisticsUI sui : uis) {
                StatisticsFrontEnd frontEnd = new StatisticsFrontEnd(sui);
                UIFrontEnd uife = new UIFrontEnd(sui, frontEnd, category);
                frontEnds.add(uife);
                innerPanel.add(frontEnd, "wrap");
            }
            squeezeBoxPanel.addPanel(innerPanel, category.getName());
        }
    }
}
Also used : JPanel(javax.swing.JPanel) MigLayout(net.miginfocom.swing.MigLayout) ArrayList(java.util.ArrayList) Comparator(java.util.Comparator) StatisticsUI(org.gephi.statistics.spi.StatisticsUI)

Example 7 with StatisticsUI

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

the class AvailableStatisticsChooser method setup.

public void setup(StatisticsModelUI model, StatisticsCategory[] categories) {
    //Sort categories by position
    Arrays.sort(categories, new Comparator() {

        @Override
        public int compare(Object o1, Object o2) {
            Integer p1 = ((StatisticsCategory) o1).getPosition();
            Integer p2 = ((StatisticsCategory) o2).getPosition();
            return p1.compareTo(p2);
        }
    });
    //Get UI
    StatisticsUI[] statisticsUIs = Lookup.getDefault().lookupAll(StatisticsUI.class).toArray(new StatisticsUI[0]);
    for (StatisticsCategory category : categories) {
        MigLayout migLayout = new MigLayout("insets 0 0 0 0");
        migLayout.setColumnConstraints("[grow,fill]");
        migLayout.setRowConstraints("[min!]");
        JPanel innerPanel = new JPanel(migLayout);
        //Find uis in this category
        List<StatisticsUI> uis = new ArrayList<>();
        for (StatisticsUI sui : statisticsUIs) {
            if (sui.getCategory().equals(category.getName())) {
                uis.add(sui);
            }
        }
        //Sort it by position
        Collections.sort(uis, new Comparator() {

            @Override
            public int compare(Object o1, Object o2) {
                Integer p1 = ((StatisticsUI) o1).getPosition();
                Integer p2 = ((StatisticsUI) o2).getPosition();
                return p1.compareTo(p2);
            }
        });
        for (StatisticsUI sui : uis) {
            JCheckBox checkBox = new JCheckBox(sui.getDisplayName());
            checkBox.setOpaque(false);
            checkBox.setSelected(model.isStatisticsUIVisible(sui));
            uiMap.put(checkBox, sui);
            innerPanel.add(checkBox, "wrap");
        }
        if (uis.size() > 0) {
            squeezeBoxPanel.addPanel(innerPanel, category.getName());
        }
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) StatisticsUI(org.gephi.statistics.spi.StatisticsUI) MigLayout(net.miginfocom.swing.MigLayout) ArrayList(java.util.ArrayList) Comparator(java.util.Comparator)

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