Commit db3d7740 authored by Simon Luser's avatar Simon Luser
Browse files

adapted Vis

parent 2ac40564
...@@ -215,7 +215,7 @@ public class DefaultMonitor implements MonitorComponent, EventHandler, ...@@ -215,7 +215,7 @@ public class DefaultMonitor implements MonitorComponent, EventHandler,
analyzer.stop(output); analyzer.stop(output);
} }
output.write("*******************************************************\n"); output.write("*******************************************************\n");
// output.close(); output.close();
} catch (IOException e) { } catch (IOException e) {
throw new AssertionError(); throw new AssertionError();
} }
......
...@@ -141,7 +141,7 @@ public class RangedTopologyView extends AbstractTopologyView<RangedLink> { ...@@ -141,7 +141,7 @@ public class RangedTopologyView extends AbstractTopologyView<RangedLink> {
* @return max distance between hosts to still be able to communicate (ie. * @return max distance between hosts to still be able to communicate (ie.
* wireless range) * wireless range)
*/ */
protected double getRange() { public double getRange() {
return range; return range;
} }
......
...@@ -40,9 +40,9 @@ import java.awt.event.MouseAdapter; ...@@ -40,9 +40,9 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
...@@ -385,64 +385,64 @@ public class VisualizationTopologyView extends JFrame ...@@ -385,64 +385,64 @@ public class VisualizationTopologyView extends JFrame
* @author Bjoern Richerzhagen * @author Bjoern Richerzhagen
* @version 1.0, 19.03.2012 * @version 1.0, 19.03.2012
*/ */
protected class WorldPanel extends JLayeredPane { public class WorldPanel extends JLayeredPane {
protected HashMap<INodeID, VisNodeInformation> nodeInformation = new HashMap<INodeID, VisNodeInformation>(); protected ConcurrentHashMap<INodeID, VisNodeInformation> nodeInformation = new ConcurrentHashMap<INodeID, VisNodeInformation>();
protected final static int PADDING = 16; public final static int PADDING = 16;
protected final static int NODE_PAD = 2; public final static int NODE_PAD = 2;
private static final long serialVersionUID = -3023020559483652110L; private static final long serialVersionUID = -3023020559483652110L;
public WorldPanel() { public WorldPanel() {
this.setLayout(null); this.setLayout(null);
this.setDoubleBuffered(true); this.setDoubleBuffered(true);
this.addMouseListener(new MouseAdapter() { // this.addMouseListener(new MouseAdapter() {
//
/** // /**
* Stores the mouse position, if the mouse button is pressed // * Stores the mouse position, if the mouse button is pressed
*/ // */
@Override // @Override
public void mousePressed(MouseEvent e) { // public void mousePressed(MouseEvent e) {
boolean turnedSomeoneOff = false; // boolean turnedSomeoneOff = false;
for (VisNodeInformation node : nodeInformation.values()) { // for (VisNodeInformation node : nodeInformation.values()) {
// Make it easier to turn things off. // // Make it easier to turn things off.
if (node.clicked && node.position // if (node.clicked && node.position
.distance(e.getPoint()) < PADDING + 2) { // .distance(e.getPoint()) < PADDING + 2) {
node.clicked = !node.clicked; // node.clicked = !node.clicked;
VisualizationInjector // VisualizationInjector
.notifyInteractionListenersOnClick( // .notifyInteractionListenersOnClick(
node.hostId, node.clicked); // node.hostId, node.clicked);
turnedSomeoneOff = true; // turnedSomeoneOff = true;
} // }
} // }
if (!turnedSomeoneOff) { // if (!turnedSomeoneOff) {
// Turn sth on (limit to one node) // // Turn sth on (limit to one node)
for (VisNodeInformation node : nodeInformation.values()) { // for (VisNodeInformation node : nodeInformation.values()) {
if (node.disableClickListener) { // if (node.disableClickListener) {
continue; // continue;
} // }
if (!node.clicked && node.position // if (!node.clicked && node.position
.distance(e.getPoint()) < PADDING) { // .distance(e.getPoint()) < PADDING) {
node.clicked = !node.clicked; // node.clicked = !node.clicked;
VisualizationInjector // VisualizationInjector
.notifyInteractionListenersOnClick( // .notifyInteractionListenersOnClick(
node.hostId, node.clicked); // node.hostId, node.clicked);
break; // break;
} // }
} // }
} // }
} // }
//
}); // });
} }
public void addTopologyComponent(TopologyComponent comp) { public void addTopologyComponent(TopologyComponent comp) {
if (!nodeInformation.containsKey(comp.getHost().getId())) { if (!nodeInformation.containsKey(comp.getHost().getId())) {
VisNodeInformation tVis = new VisNodeInformation(comp); VisNodeInformation tVis = new VisNodeInformation(comp);
comp.requestLocationUpdates(null, tVis); comp.requestLocationUpdates(null, tVis);
nodeInformation.put(comp.getHost().getId(), tVis); nodeInformation.putIfAbsent(comp.getHost().getId(), tVis);
} }
} }
...@@ -454,32 +454,31 @@ public class VisualizationTopologyView extends JFrame ...@@ -454,32 +454,31 @@ public class VisualizationTopologyView extends JFrame
@Override @Override
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g; // Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON); // RenderingHints.VALUE_ANTIALIAS_ON);
paintNodes(g2); // paintNodes(g2);
super.paintComponent(g); super.paintComponent(g);
} }
private void paintNodes(Graphics2D g2) { // private void paintNodes(Graphics2D g2) {
for (VisNodeInformation node : nodeInformation.values()) { // for (VisNodeInformation node : nodeInformation.values()) {
if (node.clicked) { // if (node.clicked) {
g2.setColor(Color.MAGENTA); // g2.setColor(Color.MAGENTA);
g2.fillOval((int) node.position.getX() - PADDING, // g2.fillOval((int) node.position.getX() - PADDING,
(int) node.position.getY() - PADDING, // (int) node.position.getY() - PADDING,
PADDING * 2 + 1, PADDING * 2 + 1); // PADDING * 2 + 1, PADDING * 2 + 1);
} else { // } else {
if (showNodes) { // if (showNodes) {
// Draw nodes // // Draw nodes
g2.setColor(Color.DARK_GRAY); // g2.setColor(Color.DARK_GRAY);
g2.fillOval((int) node.position.getX() - NODE_PAD, // g2.fillOval((int) node.position.getX() - NODE_PAD,
(int) node.position.getY() - NODE_PAD, // (int) node.position.getY() - NODE_PAD,
NODE_PAD * 2 + 1, NODE_PAD * 2 + 1); // NODE_PAD * 2 + 1, NODE_PAD * 2 + 1);
} // }
} // }
} // }
} // }
} }
public void notifyInteractionListenersOnClick(long hostid, public void notifyInteractionListenersOnClick(long hostid,
......
...@@ -26,6 +26,9 @@ import java.awt.Point; ...@@ -26,6 +26,9 @@ import java.awt.Point;
import java.awt.Polygon; import java.awt.Polygon;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tud.kom.p2psim.impl.util.Triple;
/** /**
* Helpers for your own visualization components * Helpers for your own visualization components
* *
...@@ -76,4 +79,24 @@ public class VisHelper { ...@@ -76,4 +79,24 @@ public class VisHelper {
drawArrow(g2, from.getX(), from.getY(), to.getX(), to.getY(), thickness); drawArrow(g2, from.getX(), from.getY(), to.getX(), to.getY(), thickness);
} }
/**
* uses the start-/end position and the percentage and determines with
* vector addition the new position on the line between start and end
* according to the percentage of already traveled distance.
*
* @param messageBall
* @return the current position of the message.
*/
public static PositionVector determineNewMessageBallPosition(
Triple<PositionVector, PositionVector, Integer> messageBall) {
double distance = messageBall.getA().distanceTo(messageBall.getB());
PositionVector differenceVector = messageBall.getB()
.minus(messageBall.getA());
differenceVector.normalize();
differenceVector.multiplyScalar(
messageBall.getC().doubleValue() / 100d * distance);
PositionVector pos = messageBall.getA().clone();
pos.add(differenceVector);
return pos;
}
} }
...@@ -64,7 +64,7 @@ public class XYChart { ...@@ -64,7 +64,7 @@ public class XYChart {
dataset = new YIntervalSeriesCollection(); dataset = new YIntervalSeriesCollection();
dataset.addSeries(new YIntervalSeries(seriesName)); dataset.addSeries(new YIntervalSeries(seriesName));
chart = ChartFactory.createXYLineChart(null, "Time [h:m:s]", null, dataset, PlotOrientation.VERTICAL, true, true, false); chart = ChartFactory.createXYLineChart(null, "Time [s]", null, dataset, PlotOrientation.VERTICAL, true, true, false);
chart.setBackgroundPaint(plotBackgroundColor); chart.setBackgroundPaint(plotBackgroundColor);
XYPlot plot = (XYPlot) chart.getPlot(); XYPlot plot = (XYPlot) chart.getPlot();
...@@ -93,15 +93,24 @@ public class XYChart { ...@@ -93,15 +93,24 @@ public class XYChart {
//plot.setFixedLegendItems(new LegendItemCollection()); //plot.setFixedLegendItems(new LegendItemCollection());
DeviationRenderer errorRenderer = new DeviationRenderer(true, true); DeviationRenderer errorRenderer = new DeviationRenderer(true, true);
errorRenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); errorRenderer.setSeriesStroke(0, new BasicStroke(2F, 1, 1));
errorRenderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1)); errorRenderer.setSeriesStroke(1, new BasicStroke(1F, 1, 1));
errorRenderer.setSeriesStroke(2, new BasicStroke(3F, 1, 1)); errorRenderer.setSeriesStroke(2, new BasicStroke(1F, 1, 1));
errorRenderer.setSeriesFillPaint(0, new Color(255, 200, 200)); errorRenderer.setSeriesStroke(3, new BasicStroke(1F, 1, 1));
errorRenderer.setSeriesFillPaint(1, new Color(200, 200, 255)); errorRenderer.setSeriesStroke(4, new BasicStroke(1F, 1, 1));
errorRenderer.setSeriesFillPaint(2, new Color(200, 255, 200)); errorRenderer.setSeriesStroke(5, new BasicStroke(1F, 1, 1));
errorRenderer.setSeriesFillPaint(0, new Color(255, 0, 0));
errorRenderer.setSeriesFillPaint(1, new Color(0, 0, 255));
errorRenderer.setSeriesFillPaint(2, new Color(0, 255, 0));
errorRenderer.setSeriesFillPaint(3, new Color(255, 255, 0));
errorRenderer.setSeriesFillPaint(4, new Color(128, 0, 0));
errorRenderer.setSeriesFillPaint(5, new Color(0, 255, 255));
errorRenderer.setSeriesPaint(0, new Color(255, 0, 0)); errorRenderer.setSeriesPaint(0, new Color(255, 0, 0));
errorRenderer.setSeriesPaint(1, new Color(0, 0, 255)); errorRenderer.setSeriesPaint(1, new Color(0, 0, 255));
errorRenderer.setSeriesPaint(2, new Color(0, 255, 0)); errorRenderer.setSeriesPaint(2, new Color(0, 255, 0));
errorRenderer.setSeriesPaint(3, new Color(255, 255, 0));
errorRenderer.setSeriesPaint(4, new Color(128, 0, 0));
errorRenderer.setSeriesPaint(5, new Color(0, 255, 255));
//errorRenderer.setShapesVisible(false); //errorRenderer.setShapesVisible(false);
//errorRenderer.setLinesVisible(true); //errorRenderer.setLinesVisible(true);
//errorRenderer.setAlpha(0.0f); //errorRenderer.setAlpha(0.0f);
......
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