class StatisticsPanel extends JPanel {

    //Data
    private StatisticsCategory[] categories;
    private List<UIFrontEnd> frontEnds;
    //UI
    private JSqueezeBoxPanel squeezeBoxPanel;

    public StatisticsPanel() {
        initComponents();
        initCategories();
        initFrontEnds();
    }

    public void refreshModel(StatisticsModelUI model) {
        boolean needRefreshVisible = false;
        for (UIFrontEnd entry : frontEnds) {
            entry.getFrontEnd().refreshModel(model);
            if (model != null) {
                boolean visible = model.isStatisticsUIVisible(entry.getStatisticsUI());
                if (visible != entry.visible) {
                    needRefreshVisible = true;
                    entry.setVisible(visible);
                }
            }
        }
        if (needRefreshVisible) {
            refreshFrontEnd();
        }
    }

    private void refreshFrontEnd() {
        squeezeBoxPanel.cleanPanels();
        for (StatisticsCategory category : categories) {
            //Find uis in this category
            List<UIFrontEnd> uis = new ArrayList<>();
            for (UIFrontEnd uife : frontEnds) {
                if (uife.getCategory().equals(category) && uife.isVisible()) {
                    uis.add(uife);
                }
            }

            if (uis.size() > 0) {
                //Sort it by position
                Collections.sort(uis, new Comparator() {

                    @Override
                    public int compare(Object o1, Object o2) {
                        Integer p1 = ((UIFrontEnd) o1).getStatisticsUI().getPosition();
                        Integer p2 = ((UIFrontEnd) o2).getStatisticsUI().getPosition();
                        return p1.compareTo(p2);
                    }
                });

                MigLayout migLayout = new MigLayout("insets 0");
                migLayout.setColumnConstraints("[grow,fill]");
                migLayout.setRowConstraints("[pref!]");
                JPanel innerPanel = new JPanel(migLayout);

                for (UIFrontEnd sui : uis) {
                    innerPanel.add(sui.frontEnd, "wrap");
                }

                squeezeBoxPanel.addPanel(innerPanel, category.getName());
            }
        }
    }

    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());
            }
        }
    }

    private void initCategories() {<FILL_FUNCTION_BODY>}

    private void initComponents() {
        setLayout(new BorderLayout());
        squeezeBoxPanel = new JSqueezeBoxPanel();
        add(squeezeBoxPanel, BorderLayout.CENTER);
    }

    public StatisticsCategory[] getCategories() {
        return categories;
    }

    private static class UIFrontEnd {

        private final StatisticsUI statisticsUI;
        private final StatisticsFrontEnd frontEnd;
        private final StatisticsCategory category;
        private boolean visible;

        public UIFrontEnd(StatisticsUI statisticsUI, StatisticsFrontEnd frontEnd, StatisticsCategory category) {
            this.statisticsUI = statisticsUI;
            this.frontEnd = frontEnd;
            this.category = category;
            this.visible = true;
        }

        public boolean isVisible() {
            return visible;
        }

        public void setVisible(boolean visible) {
            this.visible = visible;
        }

        public StatisticsFrontEnd getFrontEnd() {
            return frontEnd;
        }

        public StatisticsUI getStatisticsUI() {
            return statisticsUI;
        }

        public StatisticsCategory getCategory() {
            return category;
        }
    }
}

        Map<String, StatisticsCategory> cats = new LinkedHashMap<>();
        cats.put(StatisticsUI.CATEGORY_NETWORK_OVERVIEW,
            new StatisticsCategory(StatisticsUI.CATEGORY_NETWORK_OVERVIEW, 100));
        cats.put(StatisticsUI.CATEGORY_COMMUNITY_DETECTION,
            new StatisticsCategory(StatisticsUI.CATEGORY_COMMUNITY_DETECTION, 150));
        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]);
    
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID