package org.opentrafficsim.draw.graphs; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.djunits.value.vdouble.scalar.Length; import org.djutils.immutablecollections.Immutable; import org.djutils.immutablecollections.ImmutableArrayList; import org.opentrafficsim.draw.graphs.GraphPath.Section; /** * A {@code GraphCrossSection} defines the location of graphs. It has one section having one or more source objects depending on * the number of series. For example, a 3-lane road may result in a section with 3 series. Graphs can aggregate the series, or * show multiple series. *
* Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License.
*
* @version $Revision$, $LastChangedDate$, by $Author$, initial version 22 okt. 2018
* @author Alexander Verbraeck
* @author Peter Knoppers
* @author Wouter Schakel
* @param underlying type of path sections
*/
public class GraphCrossSection extends AbstractGraphSpace
{
/** Section. */
private final Section section;
/** Position on the section. */
private final List section, final Length position)
{
this(new ArrayList section, final List iterator(final int series)
{
List list = new ArrayList<>();
list.add(this.section.getSource(series));
return new ImmutableArrayList<>(list, Immutable.WRAP).iterator();
}
/**
* Returns the position on the underlying source of the series.
* @param series int; series number
* @return Length; position on the underlying source of the series
*/
public Length position(final int series)
{
return this.positions.get(series);
}
/** {@inheritDoc} */
@Override
public Iterator iterator()
{
return this.section.iterator();
}
/** {@inheritDoc} */
@Override
public String toString()
{
return "GraphCrossSection [section=" + this.section + ", positions=" + this.positions + "]";
}
}