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,
analyzer.stop(output);
}
output.write("*******************************************************\n");
// output.close();
output.close();
} catch (IOException e) {
throw new AssertionError();
}
......
......@@ -141,7 +141,7 @@ public class RangedTopologyView extends AbstractTopologyView<RangedLink> {
* @return max distance between hosts to still be able to communicate (ie.
* wireless range)
*/
protected double getRange() {
public double getRange() {
return range;
}
......
......@@ -40,9 +40,9 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList;
......@@ -385,64 +385,64 @@ public class VisualizationTopologyView extends JFrame
* @author Bjoern Richerzhagen
* @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;
public WorldPanel() {
this.setLayout(null);
this.setDoubleBuffered(true);
this.addMouseListener(new MouseAdapter() {
/**
* Stores the mouse position, if the mouse button is pressed
*/
@Override
public void mousePressed(MouseEvent e) {
boolean turnedSomeoneOff = false;
for (VisNodeInformation node : nodeInformation.values()) {
// Make it easier to turn things off.
if (node.clicked && node.position
.distance(e.getPoint()) < PADDING + 2) {
node.clicked = !node.clicked;
VisualizationInjector
.notifyInteractionListenersOnClick(
node.hostId, node.clicked);
turnedSomeoneOff = true;
}
}
if (!turnedSomeoneOff) {
// Turn sth on (limit to one node)
for (VisNodeInformation node : nodeInformation.values()) {
if (node.disableClickListener) {
continue;
}
if (!node.clicked && node.position
.distance(e.getPoint()) < PADDING) {
node.clicked = !node.clicked;
VisualizationInjector
.notifyInteractionListenersOnClick(
node.hostId, node.clicked);
break;
}
}
}
}
});
// this.addMouseListener(new MouseAdapter() {
//
// /**
// * Stores the mouse position, if the mouse button is pressed
// */
// @Override
// public void mousePressed(MouseEvent e) {
// boolean turnedSomeoneOff = false;
// for (VisNodeInformation node : nodeInformation.values()) {
// // Make it easier to turn things off.
// if (node.clicked && node.position
// .distance(e.getPoint()) < PADDING + 2) {
// node.clicked = !node.clicked;
// VisualizationInjector
// .notifyInteractionListenersOnClick(
// node.hostId, node.clicked);
// turnedSomeoneOff = true;
// }
// }
// if (!turnedSomeoneOff) {
// // Turn sth on (limit to one node)
// for (VisNodeInformation node : nodeInformation.values()) {
// if (node.disableClickListener) {
// continue;
// }
// if (!node.clicked && node.position
// .distance(e.getPoint()) < PADDING) {
// node.clicked = !node.clicked;
// VisualizationInjector
// .notifyInteractionListenersOnClick(
// node.hostId, node.clicked);
// break;
// }
// }
// }
// }
//
// });
}
public void addTopologyComponent(TopologyComponent comp) {
if (!nodeInformation.containsKey(comp.getHost().getId())) {
VisNodeInformation tVis = new VisNodeInformation(comp);
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
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
paintNodes(g2);
// Graphics2D g2 = (Graphics2D) g;
// g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
// RenderingHints.VALUE_ANTIALIAS_ON);
// paintNodes(g2);
super.paintComponent(g);
}
private void paintNodes(Graphics2D g2) {
for (VisNodeInformation node : nodeInformation.values()) {
if (node.clicked) {
g2.setColor(Color.MAGENTA);
g2.fillOval((int) node.position.getX() - PADDING,
(int) node.position.getY() - PADDING,
PADDING * 2 + 1, PADDING * 2 + 1);
} else {
if (showNodes) {
// Draw nodes
g2.setColor(Color.DARK_GRAY);
g2.fillOval((int) node.position.getX() - NODE_PAD,
(int) node.position.getY() - NODE_PAD,
NODE_PAD * 2 + 1, NODE_PAD * 2 + 1);
}
}
}
}
// private void paintNodes(Graphics2D g2) {
// for (VisNodeInformation node : nodeInformation.values()) {
// if (node.clicked) {
// g2.setColor(Color.MAGENTA);
// g2.fillOval((int) node.position.getX() - PADDING,
// (int) node.position.getY() - PADDING,
// PADDING * 2 + 1, PADDING * 2 + 1);
// } else {
// if (showNodes) {
// // Draw nodes
// g2.setColor(Color.DARK_GRAY);
// g2.fillOval((int) node.position.getX() - NODE_PAD,
// (int) node.position.getY() - NODE_PAD,
// NODE_PAD * 2 + 1, NODE_PAD * 2 + 1);
// }
// }
// }
// }
}
public void notifyInteractionListenersOnClick(long hostid,
......
......@@ -26,6 +26,9 @@ import java.awt.Point;
import java.awt.Polygon;
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
*
......@@ -76,4 +79,24 @@ public class VisHelper {
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 {
dataset = new YIntervalSeriesCollection();
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);
XYPlot plot = (XYPlot) chart.getPlot();
......@@ -93,15 +93,24 @@ public class XYChart {
//plot.setFixedLegendItems(new LegendItemCollection());
DeviationRenderer errorRenderer = new DeviationRenderer(true, true);
errorRenderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1));
errorRenderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1));
errorRenderer.setSeriesStroke(2, new BasicStroke(3F, 1, 1));
errorRenderer.setSeriesFillPaint(0, new Color(255, 200, 200));
errorRenderer.setSeriesFillPaint(1, new Color(200, 200, 255));
errorRenderer.setSeriesFillPaint(2, new Color(200, 255, 200));
errorRenderer.setSeriesStroke(0, new BasicStroke(2F, 1, 1));
errorRenderer.setSeriesStroke(1, new BasicStroke(1F, 1, 1));
errorRenderer.setSeriesStroke(2, new BasicStroke(1F, 1, 1));
errorRenderer.setSeriesStroke(3, new BasicStroke(1F, 1, 1));
errorRenderer.setSeriesStroke(4, new BasicStroke(1F, 1, 1));
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(1, new Color(0, 0, 255));
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.setLinesVisible(true);
//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