Skip to content
Snippets Groups Projects
Unverified Commit 4e64d4d7 authored by Luca Keidel's avatar Luca Keidel
Browse files

Node info will now only be display for a certain amount of time in the GraphWindow info bar

parent 3bd8710a
No related branches found
No related tags found
1 merge request!6Overlay topology
......@@ -46,13 +46,17 @@ public class GephiConfiguration extends AbstractConfiguration {
graphWindow.setDisplayedFilename(selectedTopology.getName());
graphWindow.setVisible(true);
// add a click listener for displaying further information about a wallet when clicking on a node
graphWindow.addNodeClickHandler((node, event) -> {
// get associated wallet and ask for its amount
ActorRef wallet = walletByName(node.getLabel());
Future<Object> future = Patterns.ask(wallet, new ActionGetAmount(), timeout);
future.onSuccess(new OnSuccess<Object>() {
@Override
public void onSuccess(Object result) throws Throwable {
// display the amount when an answer is received
ActionGetAmountAnswer answer = (ActionGetAmountAnswer) result;
graphWindow.setInfobarText(node.getLabel()+" has "+answer.amount+" FUCs");
}
......
......@@ -11,6 +11,7 @@ import java.awt.*;
import java.lang.reflect.Field;
import java.util.*;
import java.util.List;
import java.util.Timer;
public class GraphWindow extends JFrame implements NodeMouseListener {
......@@ -19,12 +20,16 @@ public class GraphWindow extends JFrame implements NodeMouseListener {
private final PreviewSketch previewSketch;
private JLabel infobarText;
private Timer timer;
private final String baseWindowTitle = "Network Overlay Graph";
private final String defaultInfoBarText = "Click on a node to see further information.";
public GraphWindow() {
super();
timer = new Timer();
setTitle(baseWindowTitle);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
......@@ -44,7 +49,7 @@ public class GraphWindow extends JFrame implements NodeMouseListener {
G2DTarget target = (G2DTarget) previewController.getRenderTarget(RenderTarget.G2D_TARGET);
previewSketch = new PreviewSketch(target, isRetina());
infobarText = new JLabel("Click on a node to see further information.", SwingConstants.LEFT);
infobarText = new JLabel(defaultInfoBarText, SwingConstants.LEFT);
this.add(previewSketch, BorderLayout.CENTER);
......@@ -122,7 +127,20 @@ public class GraphWindow extends JFrame implements NodeMouseListener {
previewSketch.refreshSketch();
}
/**
* Sets the displayed text of the infobar to text.
* After a certain time the text will be reset to the default text.
*
* @param text new infobar text
*/
public void setInfobarText(String text) {
SwingUtilities.invokeLater(() -> infobarText.setText(text));
// set text back to default text after 2 seconds
timer.schedule(new TimerTask() {
@Override
public void run() {
SwingUtilities.invokeLater(() -> infobarText.setText(defaultInfoBarText));
}
}, 2000);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment