use of org.gephi.appearance.api.Function in project gephi by gephi.
the class StandardTest method test.
@Test
public void test() {
Graph graph = generateGraph();
AppearanceModelImpl model = new AppearanceModelImpl(workspace);
Function[] funcs = model.getNodeFunctions(graph);
// for(Function f: funcs) {
// System.out.println(f);
// }
}
use of org.gephi.appearance.api.Function in project gephi by gephi.
the class AppearanceTopComponent method refreshCombo.
private void refreshCombo() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
final DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
if (model != null) {
TransformerUI ui = model.getSelectedTransformerUI();
if (ui != null && model.isAttributeTransformerUI(ui)) {
//Ranking
Function selectedColumn = model.getSelectedFunction();
attibuteBox.removeItemListener(attributeListener);
comboBoxModel.addElement(NO_SELECTION);
comboBoxModel.setSelectedItem(NO_SELECTION);
List<Function> rows = new ArrayList<>();
rows.addAll(model.getFunctions());
Collections.sort(rows, new Comparator<Function>() {
@Override
public int compare(Function o1, Function o2) {
if (o1.isAttribute() && !o2.isAttribute()) {
return 1;
} else if (!o1.isAttribute() && o2.isAttribute()) {
return -1;
}
return o1.toString().compareTo(o2.toString());
}
});
for (Function r : rows) {
comboBoxModel.addElement(r);
if (selectedColumn != null && selectedColumn.equals(r)) {
comboBoxModel.setSelectedItem(r);
}
}
attributeListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (model != null) {
if (!attibuteBox.getSelectedItem().equals(NO_SELECTION)) {
Function selectedItem = (Function) attibuteBox.getSelectedItem();
Function selectedFunction = model.getSelectedFunction();
if (selectedFunction != selectedItem) {
controller.setSelectedFunction(selectedItem);
}
} else {
controller.setSelectedFunction(null);
}
}
}
};
attibuteBox.addItemListener(attributeListener);
}
}
attibuteBox.setModel(comboBoxModel);
}
});
}
use of org.gephi.appearance.api.Function in project gephi by gephi.
the class AppearanceUIController method setSelectedFunction.
public void setSelectedFunction(Function function) {
if (graphObserver != null) {
graphObserver.destroy();
graphObserver = null;
}
if (model != null) {
Function oldValue = model.getSelectedFunction();
if ((oldValue == null && function != null) || (oldValue != null && function == null) || (function != null && oldValue != null && !oldValue.equals(function))) {
model.setAutoApply(false);
model.setSelectedFunction(function);
firePropertyChangeEvent(AppearanceUIModelEvent.SELECTED_FUNCTION, oldValue, function);
if (function != null && !function.isSimple()) {
graphObserver = new GraphChangeObserver(function.getGraph(), function instanceof AttributeFunction ? ((AttributeFunction) function).getColumn() : null);
graphObserver.start();
}
}
}
}
use of org.gephi.appearance.api.Function in project gephi by gephi.
the class AppearanceUIModel method replaceSelectedFunction.
public synchronized Function replaceSelectedFunction() {
Graph graph = graphController.getGraphModel(appearanceModel.getWorkspace()).getGraph();
Function sFunction = getSelectedFunction();
if (sFunction instanceof AttributeFunction) {
AttributeFunction af = (AttributeFunction) sFunction;
for (Function func : getSelectedElementClass().equals(AppearanceUIController.NODE_ELEMENT) ? appearanceModel.getNodeFunctions(graph) : appearanceModel.getEdgeFunctions(graph)) {
if (func instanceof AttributeFunction) {
if (af.getColumn().equals(((AttributeFunction) func).getColumn()) && sFunction.getUI().getCategory().equals(func.getUI().getCategory())) {
return func;
}
}
}
}
return null;
}
use of org.gephi.appearance.api.Function in project gephi by gephi.
the class AppearanceUIModel method getFunctions.
public Collection<Function> getFunctions() {
Graph graph = graphController.getGraphModel(appearanceModel.getWorkspace()).getGraph();
List<Function> functions = new ArrayList<>();
for (Function func : selectedElementClass.equalsIgnoreCase(AppearanceUIController.NODE_ELEMENT) ? appearanceModel.getNodeFunctions(graph) : appearanceModel.getEdgeFunctions(graph)) {
TransformerUI ui = func.getUI();
if (ui != null && ui.getDisplayName().equals(getSelectedTransformerUI().getDisplayName())) {
if (ui.getCategory().equals(selectedCategory.get(selectedElementClass))) {
functions.add(func);
}
}
}
return functions;
}
Aggregations