Commit 41865f71 authored by Julian Zobel's avatar Julian Zobel
Browse files

Area Roaming adaptions and minimum distance in random attraction generator from ocnfig

parent 722b46a9
......@@ -60,8 +60,8 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
private double minimumRadius = 10;
@XMLConfigurableConstructor({"numberOfAttractionPoints"})
public RandomAttractionGenerator(int numberOfAttractionPoints) {
@XMLConfigurableConstructor({"numberOfAttractionPoints", "maximumRadius", "minimumRadius", "minimumDistance"})
public RandomAttractionGenerator(int numberOfAttractionPoints, double maximumRadius, double minimumRadius, double minimumDistance) {
this.rand = Randoms.getRandom(RandomAttractionGenerator.class);
this.worldDimension = Binder.getComponentOrNull(Topology.class)
.getWorldDimensions();
......@@ -71,6 +71,9 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
}
this.numberOfAPsSet = true;
this.numberOfAttractionPoints = numberOfAttractionPoints;
this.maximumRadius = maximumRadius;
this.minimumRadius = minimumRadius;
this.minimumDistance = minimumDistance;
attractionPoints.clear();
createAttractionPoints();
}
......@@ -93,7 +96,7 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
// make a break counter to prevent more than 10 iterations and an infinity loop in general.
int c = 0;
create: for (int i = 0; i < numberOfAttractionPoints; i++) {
PositionVector posVec = createPosVec();
......@@ -155,7 +158,7 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
}
/**
* Set a maximum radius that an attraction point can have. Minimum is 10 meters.
* Set a maximum radius that an attraction point can have.
* @param radius
*/
public void setMaximumRadius(double radius) {
......@@ -163,10 +166,16 @@ public class RandomAttractionGenerator implements IAttractionGenerator {
}
/**
* Set a maximum radius that an attraction point can have. Minimum is 10 meters.
* Set a minimum radius that an attraction point can have. Minimum is 10 meters.
* @param radius
*/
public void setMinimumRadius(double radius) {
this.minimumRadius = radius;
if(radius < 10) {
this.minimumRadius = 10;
}
else {
this.minimumRadius = radius;
}
}
}
......@@ -51,6 +51,8 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedTran
protected final static int EVENT_ROAMING_PAUSE_ENDED = 2;
private boolean useGaussianDistributedPauseTime = false;
@Override
public void addComponent(SimLocationActuator comp) {
this.roamingStates.put(comp, roamingTransitionState.TRANSITION);
......@@ -68,15 +70,27 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedTran
// start roaming if the AP was reached
if(roamingStates.get(comp) == roamingTransitionState.TRANSITION) {
// schedule the end of the roaming phase, which will make a new transition
Event.scheduleWithDelay(gaussianDistributionPauseTime(pauseTimeMax-pauseTimeMin, 0.5*(pauseTimeMax-pauseTimeMin)), this, comp, EVENT_PAUSE_ENDED);
Event.scheduleWithDelay(getPauseTime(), this, comp, EVENT_PAUSE_ENDED);
}
this.roamingStates.put(comp, roamingTransitionState.PAUSE);
// schedule roaming
Event.scheduleWithDelay(gaussianDistributionPauseTime(Time.MINUTE * 1, Time.MINUTE), this, comp, EVENT_ROAMING_PAUSE_ENDED);
Event.scheduleWithDelay(gaussianDistributionPauseTime(Time.MINUTE, Time.MINUTE), this, comp, EVENT_ROAMING_PAUSE_ENDED);
}
@Override
protected long getPauseTime() {
if(useGaussianDistributedPauseTime) {
return gaussianDistributionPauseTime(pauseTimeMax-pauseTimeMin, 0.5*(pauseTimeMax-pauseTimeMin));
}
else {
return super.getPauseTime();
}
}
/**
* Use a gaussian distribution for the pause time interval generation, using a mean value and a standard deviation
*
......@@ -131,6 +145,9 @@ public class InAreaRoamingTransitionStrategy extends AbstractAttractionBasedTran
}
}
public void setGaussianPauseTime(boolean useGaussian) {
useGaussianDistributedPauseTime = useGaussian;
}
private AttractionPoint pickNewAttractionPoint(SimLocationActuator component) {
double score = rnd.nextDouble();
......
......@@ -156,7 +156,7 @@ public class VisualizationTopologyView extends JFrame
worldPanel.setPreferredSize(
new Dimension(VisualizationInjector.getWorldX(),
VisualizationInjector.getWorldY()));
this.setPreferredSize(new Dimension(800, 600));
this.setPreferredSize(new Dimension(VisualizationInjector.getWorldX() + 50, VisualizationInjector.getWorldY() + 100));
this.setExtendedState(Frame.MAXIMIZED_BOTH);
Thread t = new Thread(this);
......
......@@ -30,6 +30,8 @@ import javax.swing.border.BevelBorder;
import com.google.common.collect.Maps;
import de.tud.kom.p2psim.impl.util.guirunner.Config;
/**
* JFrame which holds all the live plots.
*
......@@ -42,9 +44,16 @@ import com.google.common.collect.Maps;
* they will stay add a minimum height of 250 px and a scrollbar will be added instead.
*/
public class PlottingView extends JFrame {
private static final int VIEW_WIDTH = 900;
private static final int VIEW_HEIGHT = 800;
/*
* Configuration paths
*/
static final String CONF_PATH = "GUIRunner/LivePlotWindow/";
static final String CONF_PATH_POSX = CONF_PATH + "PosX";
static final String CONF_PATH_POSY = CONF_PATH + "PosY";
static final String CONF_PATH_WIDTH = CONF_PATH + "Width";
static final String CONF_PATH_HEIGHT = CONF_PATH + "Height";
private static final int PLOT_HEIGHT_MIN = 250;
private static final Color PLOT_BACKGROUND_COLOR = Color.WHITE;
......@@ -69,8 +78,16 @@ public class PlottingView extends JFrame {
spane = new JScrollPane(plotBox);
add(spane);
setSize(VIEW_WIDTH, VIEW_HEIGHT);
setPreferredSize(new Dimension(VIEW_WIDTH, VIEW_HEIGHT));
int locationX = Config.getValue(CONF_PATH_POSX, 0);
int locationY = Config.getValue(CONF_PATH_POSY, 0);
setLocation(locationX, locationY);
int winWidth = Config.getValue(CONF_PATH_WIDTH, 900);
int winHeight = Config.getValue(CONF_PATH_HEIGHT, 800);
setSize(winWidth, winHeight);
setPreferredSize(new Dimension(winWidth, winHeight));
}
public XYChart createPlot(String name, String seriesName) {
......@@ -170,7 +187,7 @@ public class PlottingView extends JFrame {
private class PlotBox extends JPanel implements Scrollable
{
private boolean enableScroll = false;
private Dimension preferredSize = new Dimension(VIEW_WIDTH, 800);
private Dimension preferredSize = new Dimension( Config.getValue(CONF_PATH_WIDTH, 900), 800);
@Override
public Component add(Component comp)
......
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