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-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
10 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
11 * </p>
12 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
13 * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
14 * @author <a href="https://dittlab.tudelft.nl">Wouter Schakel</a>
15 * @param <S> underlying type of path sections
16 */
17 public abstract class AbstractGraphSpace<S> implements Iterable<S>
18 {
19
20 /** Series names. */
21 private final List<String> seriesNames;
22
23 /**
24 * Constructor.
25 * @param seriesNames List<String>; names of series
26 */
27 public AbstractGraphSpace(final List<String> seriesNames)
28 {
29 this.seriesNames = seriesNames;
30 }
31
32 /**
33 * Returns the name of the series.
34 * @param series int; series
35 * @return String; name of the series
36 */
37 public String getName(final int series)
38 {
39 return this.seriesNames.get(series);
40 }
41
42 /**
43 * Returns the number of series.
44 * @return int; number of series
45 */
46 public int getNumberOfSeries()
47 {
48 return this.seriesNames.size();
49 }
50
51 /**
52 * Returns an iterator over the sources on the given series.
53 * @param series int; number of the series
54 * @return Iterator<S>; iterator over the sources on the given series
55 */
56 abstract Iterator<S> iterator(int series);
57
58 }