Skip to content
Snippets Groups Projects
Unverified Commit 76c6e39b authored by David Bohn's avatar David Bohn
Browse files

Refactoring and fixing the invisible graph bug

parent a37596f9
Branches
No related tags found
1 merge request!6Overlay topology
package fucoin.configurations;
import akka.actor.ActorRef;
import akka.dispatch.OnSuccess;
import akka.pattern.Patterns;
import akka.util.Timeout;
import fucoin.actions.transaction.ActionGetAmount;
......@@ -9,7 +10,6 @@ import fucoin.configurations.internal.ConfigurationName;
import fucoin.configurations.internal.GephiLoader;
import fucoin.gui.gephi.GraphWindow;
import org.gephi.graph.api.Graph;
import scala.concurrent.Await;
import scala.concurrent.Future;
import scala.concurrent.duration.Duration;
......@@ -42,13 +42,13 @@ public class GephiConfiguration extends AbstractConfiguration {
ActorRef wallet = walletByName(node.getLabel());
Future<Object> future = Patterns.ask(wallet, new ActionGetAmount(), timeout);
ActionGetAmountAnswer answer = null;
try {
answer = (ActionGetAmountAnswer) Await.result(future, timeout.duration());
} catch (Exception e) {
System.err.println("An error occured while fetching the wallet info: "+e.getMessage());
}
graphWindow.setInfobarText(node.getLabel()+" has "+answer.amount+" FUCs");
future.onSuccess(new OnSuccess<Object>() {
@Override
public void onSuccess(Object result) throws Throwable {
ActionGetAmountAnswer answer = (ActionGetAmountAnswer) result;
graphWindow.setInfobarText(node.getLabel()+" has "+answer.amount+" FUCs");
}
}, context().dispatcher());
});
graphWindow.setVisible(true);
......
package fucoin.gui.gephi;
import fucoin.configurations.internal.NodeClickHandler;
import org.gephi.graph.api.Node;
import org.gephi.preview.api.*;
import org.gephi.preview.types.DependantOriginalColor;
......@@ -50,10 +49,10 @@ public class GraphWindow extends JFrame implements NodeMouseListener {
JPanel infobar = new JPanel(new BorderLayout());
infobar.add(infobarText, BorderLayout.WEST);
JPanel zoomOptions = new JPanel(new FlowLayout(FlowLayout.CENTER, 5,2));
JPanel zoomOptions = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 2));
zoomOptions.add(new JLabel("Zoom: "));
Dimension zoomBtnSize = new Dimension(20,20);
Dimension zoomBtnSize = new Dimension(20, 20);
JButton minusButton = new JButton("-");
minusButton.setPreferredSize(zoomBtnSize);
......@@ -114,10 +113,10 @@ public class GraphWindow extends JFrame implements NodeMouseListener {
super.setVisible(b);
previewController.refreshPreview();
previewSketch.repaint();
previewSketch.refreshSketch();
}
public void setInfobarText(String text){
public void setInfobarText(String text) {
SwingUtilities.invokeLater(() -> infobarText.setText(text));
}
}
package fucoin.configurations.internal;
package fucoin.gui.gephi;
import org.gephi.graph.api.Node;
import org.gephi.preview.api.PreviewMouseEvent;
import java.util.function.BiConsumer;
/**
* @author davidbohn
*/
public interface NodeClickHandler extends BiConsumer<Node, PreviewMouseEvent> {
}
......@@ -11,6 +11,7 @@ import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import org.gephi.preview.api.G2DTarget;
import org.gephi.preview.api.PreviewController;
import org.gephi.preview.api.PreviewMouseEvent;
......@@ -59,6 +60,10 @@ public class PreviewSketch extends JPanel implements MouseListener, MouseWheelLi
g.drawImage(target.getImage(), 0, 0, getWidth(), getHeight(), this);
}
public void refreshSketch() {
refreshLoop.refreshSketch();
}
public void setMoving(boolean moving) {
target.setMoving(moving);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment