resetColorButton.setToolTipText(NbBundle.getMessage(ActionsToolbar.class, "ActionsToolbar.resetColors"));
resetColorButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
color = resetColorButton.getColor();
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
Graph graph = gc.getModel().getGraphVisible();
for (Node n : graph.getNodes().toArray()) {
n.getNodeData().setR(color.getRed() / 255f);
n.getNodeData().setG(color.getGreen() / 255f);
n.getNodeData().setB(color.getBlue() / 255f);
n.getNodeData().setAlpha(1f);
}
for (Edge e : graph.getEdges().toArray()) {
e.getEdgeData().setR(-1f);
e.getEdgeData().setG(color.getGreen() / 255f);
e.getEdgeData().setB(color.getBlue() / 255f);
e.getEdgeData().setAlpha(1f);
}
}
});
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() {
public void actionPerformed(ActionEvent e) {
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
Graph graph = gc.getModel().getGraphVisible();
for (Node n : graph.getNodes().toArray()) {
n.getNodeData().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() {
public void actionPerformed(ActionEvent evt) {
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
Graph graph = gc.getModel().getGraphVisible();
for (Node n : graph.getNodes().toArray()) {
n.getNodeData().getTextData().setColor(null);
}
for (Edge e : graph.getEdges().toArray()) {
e.getEdgeData().getTextData().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() {
public void actionPerformed(ActionEvent evt) {
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
Graph graph = gc.getModel().getGraphVisible();
for (Node n : graph.getNodes().toArray()) {
n.getNodeData().getTextData().setVisible(true);
}
for (Edge e : graph.getEdges().toArray()) {
e.getEdgeData().getTextData().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() {
public void actionPerformed(ActionEvent e) {
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
Graph graph = gc.getModel().getGraphVisible();
for (Node n : graph.getNodes().toArray()) {
n.getNodeData().getTextData().setSize(1f);
}
}
});