1 package org.opentrafficsim.draw.graphs;
2
3 import java.util.Iterator;
4 import java.util.List;
5
6 /**
7 * Common functionality between a cross-section and a path.
8 * <p>
9 * Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
10 * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
11 * <p>
12 * @version $Revision$, $LastChangedDate$, by $Author$, initial version 23 okt. 2018 <br>
13 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
14 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
15 * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
16 * @param <S> underlying type of path sections
17 */
18 public abstract class AbstractGraphSpace<S> implements Iterable<S>
19 {
20
21 /** Series names. */
22 private final List<String> seriesNames;
23
24 /**
25 * Constructor.
26 * @param seriesNames List<String>; names of series
27 */
28 public AbstractGraphSpace(final List<String> seriesNames)
29 {
30 this.seriesNames = seriesNames;
31 }
32
33 /**
34 * Returns the name of the series.
35 * @param series int; series
36 * @return String; name of the series
37 */
38 public String getName(final int series)
39 {
40 return this.seriesNames.get(series);
41 }
42
43 /**
44 * Returns the number of series.
45 * @return int; number of series
46 */
47 public int getNumberOfSeries()
48 {
49 return this.seriesNames.size();
50 }
51
52 /**
53 * Returns an iterator over the sources on the given series.
54 * @param series int; number of the series
55 * @return Iterator<S>; iterator over the sources on the given series
56 */
57 abstract Iterator<S> iterator(int series);
58
59 }