use of org.gephi.graph.api.Graph in project gephi by gephi.
the class AppearanceUIModel method refreshSelectedFunctions.
private void refreshSelectedFunctions(String elementClass) {
Set<Function> functionSet = new HashSet<>();
Graph graph = graphController.getGraphModel(appearanceModel.getWorkspace()).getGraph();
for (Function func : elementClass.equals(AppearanceUIController.NODE_ELEMENT) ? appearanceModel.getNodeFunctions(graph) : appearanceModel.getEdgeFunctions(graph)) {
TransformerUI ui = func.getUI();
if (ui != null) {
functionSet.add(func);
}
}
for (Function func : functionSet) {
Function oldFunc = selectedFunction.get(elementClass).get(func.getUI());
if (oldFunc == null || !functionSet.contains(oldFunc)) {
if (func.isSimple()) {
selectedFunction.get(elementClass).put(func.getUI(), func);
}
}
}
}
use of org.gephi.graph.api.Graph in project gephi by gephi.
the class MergeNodes method execute.
@Override
public void execute() {
Graph graph = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getGraph();
GraphElementsController gec = Lookup.getDefault().lookup(GraphElementsController.class);
Node newNode = gec.mergeNodes(graph, nodes, selectedNode, columns, mergeStrategies, deleteMergedNodes);
Lookup.getDefault().lookup(DataTablesController.class).setNodeTableSelection(new Node[] { newNode });
NbPreferences.forModule(MergeNodes.class).putBoolean(DELETE_MERGED_NODES_SAVED_PREFERENCES, deleteMergedNodes);
}
use of org.gephi.graph.api.Graph in project gephi by gephi.
the class ActionsToolbar method initContent.
private void initContent() {
//Center on graph
final JButton centerOnGraphButton = new JButton();
centerOnGraphButton.setToolTipText(NbBundle.getMessage(VizBarController.class, "ActionsToolbar.centerOnGraph"));
centerOnGraphButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/centerOnGraph.png")));
centerOnGraphButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
VizController.getInstance().getGraphIO().centerOnGraph();
}
});
add(centerOnGraphButton);
//Center on zero
/*final JButton centerOnZeroButton = new JButton();
centerOnZeroButton.setToolTipText(NbBundle.getMessage(VizBarController.class, "ActionsToolbar.centerOnZero"));
centerOnZeroButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/centerOnZero.png")));
centerOnZeroButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
VizController.getInstance().getGraphIO().centerOnZero();
}
});
add(centerOnZeroButton);*/
//Reset colors
final JColorButton resetColorButton = new JColorButton(color, true, false);
resetColorButton.setToolTipText(NbBundle.getMessage(ActionsToolbar.class, "ActionsToolbar.resetColors"));
resetColorButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
color = resetColorButton.getColor();
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
GraphModel gm = gc.getGraphModel();
Graph graph = gm.getGraphVisible();
for (Node n : graph.getNodes()) {
n.setR(color.getRed() / 255f);
n.setG(color.getGreen() / 255f);
n.setB(color.getBlue() / 255f);
n.setAlpha(1f);
}
for (Edge e : graph.getEdges()) {
e.setR(color.getRed() / 255f);
e.setG(color.getGreen() / 255f);
e.setB(color.getBlue() / 255f);
e.setAlpha(0f);
}
}
});
add(resetColorButton);
//Reset sizes
//Reset label colors
final JButton resetLabelColorButton = new JButton();
resetLabelColorButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/resetLabelColor.png")));
resetLabelColorButton.setToolTipText(NbBundle.getMessage(ActionsToolbar.class, "ActionsToolbar.resetLabelColors"));
resetLabelColorButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
GraphModel gm = gc.getGraphModel();
Graph graph = gm.getGraphVisible();
for (Node n : graph.getNodes().toArray()) {
n.getTextProperties().setColor(Color.BLACK);
n.getTextProperties().setAlpha(0f);
}
for (Edge e : graph.getEdges().toArray()) {
e.getTextProperties().setColor(Color.BLACK);
e.getTextProperties().setAlpha(0f);
}
}
});
add(resetLabelColorButton);
//Reset label visible
final JButton resetLabelVisibleButton = new JButton();
resetLabelVisibleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/resetLabelVisible.png")));
resetLabelVisibleButton.setToolTipText(NbBundle.getMessage(ActionsToolbar.class, "ActionsToolbar.resetLabelVisible"));
resetLabelVisibleButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
GraphModel gm = gc.getGraphModel();
Graph graph = gm.getGraphVisible();
for (Node n : graph.getNodes()) {
n.getTextProperties().setVisible(true);
}
for (Edge e : graph.getEdges()) {
e.getTextProperties().setVisible(true);
}
}
});
add(resetLabelVisibleButton);
}
use of org.gephi.graph.api.Graph in project gephi by gephi.
the class ExporterGDF method execute.
@Override
public boolean execute() {
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel = graphController.getGraphModel(workspace);
Graph graph = exportVisible ? graphModel.getGraphVisible() : graphModel.getGraph();
graph.readLock();
try {
exportData(graph, graphModel);
} catch (Exception e) {
Logger.getLogger(ExporterGDF.class.getName()).log(Level.SEVERE, null, e);
} finally {
graph.readUnlock();
Progress.finish(progressTicket);
}
return !cancel;
}
use of org.gephi.graph.api.Graph in project gephi by gephi.
the class ExporterGraphML method execute.
@Override
public boolean execute() {
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel = graphController.getGraphModel(workspace);
Graph graph = exportVisible ? graphModel.getGraphVisible() : graphModel.getGraph();
graph.readLock();
try {
exportData(createDocument(), graph);
} catch (Exception e) {
Logger.getLogger(ExporterGraphML.class.getName()).log(Level.SEVERE, null, e);
} finally {
graph.readUnlock();
Progress.finish(progressTicket);
}
return !cancel;
}
Aggregations