@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
final JButton resetSizeButton = new JButton();
resetSizeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/resetSize.png")));
resetSizeButton.setToolTipText(NbBundle.getMessage(ActionsToolbar.class, "ActionsToolbar.resetSizes"));
resetSizeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
GraphModel gm = gc.getGraphModel();
Graph graph = gm.getGraphVisible();
for (Node n : graph.getNodes()) {
n.setSize(size);
}
}
});
resetSizeButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
Object res = JOptionPane.showInputDialog(resetSizeButton, NbBundle.getMessage(ActionsToolbar.class, "ActionsToolbar.resetSizes.dialog"), "" + size);
if (res != null) {
try {
size = Float.parseFloat((String) res);
} catch (Exception ex) {
}
}
}
}
});
add(resetSizeButton);
//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(null);
}
for (Edge e : graph.getEdges().toArray()) {
e.getTextProperties().setColor(null);
}
}
});
add(resetLabelColorButton);
//Reset label colors
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);
//Reset label size
JButton resetLabelSizeButton = new JButton();
resetLabelSizeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/resetLabelSize.png")));
resetLabelSizeButton.setToolTipText(NbBundle.getMessage(ActionsToolbar.class, "ActionsToolbar.resetLabelSizes"));
resetLabelSizeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
GraphModel gm = gc.getGraphModel();
Graph graph = gm.getGraphVisible();
for (Node n : graph.getNodes()) {
n.getTextProperties().setSize(1f);
}
}
});
add(resetLabelSizeButton);