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