Commit aaf9a8b6 authored by Clemens Krug's avatar Clemens Krug
Browse files

Added Javadoc to class involved in the node debugging

parent cb05b09c
......@@ -12,7 +12,8 @@ import java.util.Objects;
import java.util.Vector;
/**
* Created by Clemens on 20.02.2017.
* The actual frame/view displaying the node data. Simply a frame that holds a table
* displaying the info.
*/
public class DebugNodeView extends JFrame
{
......@@ -29,6 +30,9 @@ public class DebugNodeView extends JFrame
SwingUtilities.invokeLater(this::createGUI);
}
/**
* Initialise the UI
*/
private void createGUI()
{
panel = new JPanel();
......@@ -56,14 +60,23 @@ public class DebugNodeView extends JFrame
}
/**
* Updates an entry for a node
* @param subject The class which provided the info
* @param entry the entry/key
* @param value the value
*/
public void update(Class subject, String entry, String value)
{
int rowIndex = findEntry(subject.getSimpleName(), entry);
//If the entry already existed it needs to be updates.
if(rowIndex >= 0)
{
//2 is the position of the value in the vector.
((Vector) model.getDataVector().get(rowIndex)).set(2, value);
model.fireTableDataChanged();
}
//If the entry didn't exist, a new row is inserted.
else
{
String[] data = {subject.getSimpleName(), entry, value};
......@@ -71,6 +84,12 @@ public class DebugNodeView extends JFrame
}
}
/**
* Finds the row in the data vector which holds the specified entry
* @param subject the providing class
* @param entry the entry
* @return the index of the row holding the entry
*/
private int findEntry(String subject, String entry)
{
Vector data = model.getDataVector();
......@@ -87,6 +106,12 @@ public class DebugNodeView extends JFrame
return -1;
}
/**
* Converts a hashmap with the per node information as provided by the {@link NodeDebugMonitor}
* to a data vector which can be used in a table model.
* @param nodeData the data which should be converted.
* @return a vector holding all the data which can be used for table models.
*/
private Vector<Vector<String>> convertToTableVector(Map<Class, HashMap<String, Object>> nodeData)
{
Vector<Vector<String>> tableData = new Vector<>();
......
package de.tud.kom.p2psim.impl.topology.views.visualization.ui;
import de.tud.kom.p2psim.api.common.NodeDebugUpdateListener;
import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView;
import de.tud.kom.p2psim.impl.topology.views.visualization.world.NodeVisInteractionListener;
import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.NodeDebugMonitor;
import de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID;
import de.tudarmstadt.maki.simonstrator.api.component.core.NodeDebugMonitorComponent;
......@@ -12,10 +10,13 @@ import de.tudarmstadt.maki.simonstrator.api.component.core.NodeDebugMonitorCompo
import java.util.HashMap;
/**
* Created by Clemens on 02.04.2017.
* Managing class for the presentation of the per node data. All the little "per-node-frames" are handled here.
*/
public class NodeDebugVisualisation implements NodeVisInteractionListener, NodeDebugMonitorComponent.NodeDebugUpdateListener
{
/**
* The info frames that currently exist.
*/
private HashMap<Long, DebugNodeView> frames = new HashMap<>();
public NodeDebugVisualisation()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment