Commit cdfeb324 authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

Altered Attraction Generator interface

enabled direct instantiation of custom attraction points in the XML
config
parent 7470eda8
...@@ -24,10 +24,12 @@ import java.util.Random; ...@@ -24,10 +24,12 @@ import java.util.Random;
import de.tud.kom.p2psim.impl.topology.PositionVector; import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/** /**
* This is the implementation of a AttractionPoint. This type of {@link AttractionPoint} has not the * This is the implementation of a AttractionPoint. This type of
* ability to be moved. Its data come from osm-POIs, which are static locations * {@link AttractionPoint} has not the ability to be moved. Its data come from
* osm-POIs, which are static locations
* *
* @author Martin Hellwig * @author Martin Hellwig
* @version 1.0, 02.07.2015 * @version 1.0, 02.07.2015
...@@ -36,8 +38,14 @@ public class AttractionPoint { ...@@ -36,8 +38,14 @@ public class AttractionPoint {
protected static Random rnd = Randoms.getRandom(AttractionPoint.class); protected static Random rnd = Randoms.getRandom(AttractionPoint.class);
private PositionVector posVec; private PositionVector posVec;
private String name; private String name;
@XMLConfigurableConstructor({ "x", "y", "name" })
public AttractionPoint(int x, int y, String name) {
this(new PositionVector(x, y), name);
}
public AttractionPoint(PositionVector posVec, String name) { public AttractionPoint(PositionVector posVec, String name) {
this.posVec = posVec; this.posVec = posVec;
this.name = name; this.name = name;
......
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction;
import java.util.LinkedList;
import java.util.List;
/**
* For simple scenarios: add attraction points by specifying a coordinate.
*
* @author Bjoern Richerzhagen
* @version 1.0, Dec 11, 2015
*/
public class ConfigAttractionGenerator implements IAttractionGenerator {
private final List<AttractionPoint> points = new LinkedList<>();
@Override
public List<AttractionPoint> getAttractionPoints() {
return points;
}
public void setAttractionPoint(AttractionPoint point) {
this.points.add(point);
}
}
...@@ -32,7 +32,6 @@ import java.util.List; ...@@ -32,7 +32,6 @@ import java.util.List;
*/ */
public interface IAttractionGenerator { public interface IAttractionGenerator {
public void setNumberOfAttractionPoints(int maxNumberOfAttractionPoints);
public List<AttractionPoint> getAttractionPoints(); public List<AttractionPoint> getAttractionPoints();
} }
...@@ -86,7 +86,6 @@ public class JSONAttractionGenerator implements IAttractionGenerator { ...@@ -86,7 +86,6 @@ public class JSONAttractionGenerator implements IAttractionGenerator {
return new PositionVector(x, y); return new PositionVector(x, y);
} }
@Override
public void setNumberOfAttractionPoints(int numberOfAttractionPoints) { public void setNumberOfAttractionPoints(int numberOfAttractionPoints) {
this.maxNumberOfAttractionPoints = numberOfAttractionPoints; this.maxNumberOfAttractionPoints = numberOfAttractionPoints;
} }
......
...@@ -89,7 +89,6 @@ public class OnlineJSONAttractionGenerator implements IAttractionGenerator { ...@@ -89,7 +89,6 @@ public class OnlineJSONAttractionGenerator implements IAttractionGenerator {
return new PositionVector(x, y); return new PositionVector(x, y);
} }
@Override
public void setNumberOfAttractionPoints(int numberOfAttractionPoints) { public void setNumberOfAttractionPoints(int numberOfAttractionPoints) {
this.maxNumberOfAttractionPoints = numberOfAttractionPoints; this.maxNumberOfAttractionPoints = numberOfAttractionPoints;
} }
......
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