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