- java.lang.Object
-
- org.arakhne.afc.gis.primitive.AbstractGISElement<C,T>
-
- org.arakhne.afc.gis.primitive.AbstractBoundedGISElement<CONTAINER,AbstractBusPrimitive<CONTAINER>>
-
- org.arakhne.afc.gis.bus.network.AbstractBusPrimitive<CONTAINER>
-
- org.arakhne.afc.gis.bus.network.AbstractBusContainer<BusNetwork,BusItinerary>
-
- org.arakhne.afc.gis.bus.network.BusLine
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<BusItinerary>
,EventListener
,AttributeChangeListener
,AttributeCollection
,AttributeProvider
,BusChangeListener
,BusContainer<BusItinerary>
,BusPrimitive<BusNetwork>
,BoundedGISElement
,FlagContainer
,GISCloneable<AbstractBusPrimitive<BusNetwork>>
,GISContainer<BusItinerary>
,GISEditable
,GISElement
,GISFlagContainer
,GISPrimitive
,BoundedElement2afp<Rectangle2d>
,InformedIterable<BusItinerary>
,JsonableObject
public class BusLine extends AbstractBusContainer<BusNetwork,BusItinerary>
A bus line is group ofitineraries
.Validation
A bus line is valid if it has at list one itinerary and all its itineraries are valid in turn.- Since:
- 14.0
- Version:
- 17.0 2020-01-04 14:41:56
- Author:
- Stéphane GALLAND
- See Also:
- Serialized Form
- Maven Group Id:
- org.arakhne.afc.gis
- Maven Artifact Id:
- gisbus
-
-
Field Summary
-
Fields inherited from class org.arakhne.afc.gis.bus.network.AbstractBusPrimitive
ATTR_COLOR, DEFAULT_COLOR
-
Fields inherited from interface org.arakhne.afc.gis.primitive.FlagContainer
FLAG_READONLY, FLAG_SELECTED
-
Fields inherited from interface org.arakhne.afc.gis.primitive.GISElement
ATTR_NAME, NAME_COMPARATOR
-
Fields inherited from interface org.arakhne.afc.gis.primitive.GISPrimitive
COMPARATOR
-
-
Constructor Summary
Constructors Constructor Description BusLine()
Create bus line with a memory-based attribute provider.BusLine(String name)
Create bus line with a memory-based attribute provider.BusLine(String name, AttributeCollection attributeProvider)
Create bus line.BusLine(UUID id)
Create bus line with a memory-based attribute provider.BusLine(UUID id, String name)
Create bus line with a memory-based attribute provider.BusLine(UUID id, String name, AttributeCollection attributeProvider)
Create bus line.BusLine(UUID id, AttributeCollection attributeProvider)
Create bus line.BusLine(UUID id, BusNetwork network)
Create bus line with a memory-based attribute provider.BusLine(UUID id, BusNetwork network, String name)
Create bus line with a memory-based attribute provider.BusLine(UUID id, BusNetwork network, String name, AttributeCollection attributeProvider)
Create bus line.BusLine(UUID id, BusNetwork network, AttributeCollection attributeProvider)
Create bus line.BusLine(AttributeCollection attributeProvider)
Create bus line.BusLine(BusNetwork network)
Create bus line with a memory-based attribute provider.BusLine(BusNetwork network, String name)
Create bus line with a memory-based attribute provider.BusLine(BusNetwork network, String name, AttributeCollection attributeProvider)
Create bus line.BusLine(BusNetwork network, AttributeCollection attributeProvider)
Create bus line.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addBusItinerary(BusItinerary busItinerary)
Add a bus itinerary inside the bus line.boolean
addBusItinerary(BusItinerary busItinerary, int index)
Add a bus itinerary at the specified index.Iterable<BusItinerary>
busItineraries()
Replies the list of the bus itineraries of the bus line.Iterator<BusItinerary>
busItineraryIterator()
Replies the list of the bus itineraries of the bus line.protected Rectangle2d
calcBounds()
Compute the bounds of this element.protected void
checkPrimitiveValidity()
Check if the validity of this primitive is correctly set and change its values if necessary.BusItinerary
getBusItinerary(String name)
Replies the bus itinerary with the specified name.BusItinerary
getBusItinerary(String name, Comparator<String> nameComparator)
Replies the bus itinerary with the specified name.BusItinerary
getBusItinerary(UUID uuid)
Replies the bus itinerary with the specified uuid.BusItinerary
getBusItineraryAt(int index)
Replies the itinerary at the specified index.int
getBusItineraryCount()
Replies the count of bus itineraries into this line.BusNetwork
getBusNetwork()
Replies the bus network in which this primitive is.Class<? extends BusItinerary>
getElementType()
Replies the class of the elements in this iterable object.static String
getFirstFreeBusLineName(BusNetwork network)
Replies a bus line name that was not exist in the specified network.Shape2d<?>
getShape()
Replies the shape of this this element.int
indexInParent()
Replies the index of this primitive in its parent.int
indexOf(BusItinerary itinerary)
Replies the index of the specified bus itinerary.Iterator<BusItinerary>
iterator()
void
rebuild(boolean fireEvents)
Rebuild the primitive and all the primitive inside.void
removeAllBusItineraries()
Remove all the bus itineraries from the current line.boolean
removeBusItinerary(int index)
Remove the bus itinerary at the specified index.boolean
removeBusItinerary(BusItinerary itinerary)
Remove a bus itinerary from this line.void
resetBoundingBox()
Clear the current bounding box to force the computation of it at the next call toBoundedElement2afp.getBoundingBox()
.void
setName(String name)
Set the name of the element.int
size()
Replies the count of map elements inside this container.void
toJson(JsonBuffer buffer)
Replies the Json representation of this node.Path2d
toPath2D()
Replies the path representation of this itinerary.void
toPath2D(Path2d path)
Replies the path representation of this itinerary.-
Methods inherited from class org.arakhne.afc.gis.bus.network.AbstractBusContainer
bindChangeListener, fireGraphicalAttributeChanged, fireShapeChanged, onBusPrimitiveChanged, onBusPrimitiveGraphicalAttributeChanged, onBusPrimitiveShapeChanged, revalidate
-
Methods inherited from class org.arakhne.afc.gis.bus.network.AbstractBusPrimitive
addBusChangeListener, addGISEditableChangeListener, addListener, finalize, fireGraphicalAttributeChanged, firePrimitiveChanged, firePrimitiveChanged, firePrimitiveChanged, fireShapeChanged, fireValidityChanged, fireValidityChangedFor, getColor, getColor, getFlags, getGeoLocation, getInvalidityReason, getRawColor, hasFlag, isReadOnlyObject, isValidPrimitive, onAttributeChanged, rebuild, removeBusChangeListener, removeGISEditableChangeListener, removeListener, setColor, setFlag, setPrimitiveValidity, setReadOnlyObject, setUUID, switchFlag, unsetFlag
-
Methods inherited from class org.arakhne.afc.gis.primitive.AbstractBoundedGISElement
clone, getBoundingBox, setBoundingBox
-
Methods inherited from class org.arakhne.afc.gis.primitive.AbstractGISElement
addAttributeChangeListener, addAttributes, addAttributes, attributes, copyAttributes, flush, freeMemory, getAllAttributeNames, getAllAttributes, getAllAttributesByType, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttributeAsBool, getAttributeAsDate, getAttributeAsDouble, getAttributeAsEnumeration, getAttributeAsEnumeration, getAttributeAsFloat, getAttributeAsInetAddress, getAttributeAsInt, getAttributeAsJavaClass, getAttributeAsLong, getAttributeAsString, getAttributeAsURI, getAttributeAsURL, getAttributeAsUUID, getAttributeCollection, getAttributeCount, getAttributeObject, getAttributeProvider, getContainer, getGeoId, getName, getTopContainer, getUUID, hasAttribute, hashKey, isEventFirable, onAttributeChangeEvent, removeAllAttributes, removeAttribute, removeAttributeChangeListener, renameAttribute, renameAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setAttributes, setAttributeType, setContainer, setEventFirable, toMap, toMap, toString
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.arakhne.afc.attrs.collection.AttributeCollection
addAttributeChangeListener, addAttributes, addAttributes, flush, isEventFirable, removeAllAttributes, removeAttribute, removeAttributeChangeListener, renameAttribute, renameAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setAttributes, setAttributeType, setEventFirable
-
Methods inherited from interface org.arakhne.afc.attrs.collection.AttributeProvider
attributes, freeMemory, getAllAttributeNames, getAllAttributes, getAllAttributesByType, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttributeAsBool, getAttributeAsDate, getAttributeAsDouble, getAttributeAsEnumeration, getAttributeAsEnumeration, getAttributeAsFloat, getAttributeAsInetAddress, getAttributeAsInt, getAttributeAsJavaClass, getAttributeAsLong, getAttributeAsString, getAttributeAsURI, getAttributeAsURL, getAttributeAsUUID, getAttributeCount, getAttributeObject, hasAttribute, toMap, toMap
-
Methods inherited from interface org.arakhne.afc.math.geometry.d2.afp.BoundedElement2afp
getBoundingBox
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISContainer
getColor, getName
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISEditable
getName
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISElement
clone, copyAttributes, getName, hashKey
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISPrimitive
getGeoId, getUUID
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
BusLine
public BusLine(BusNetwork network, String name)
Create bus line with a memory-based attribute provider.- Parameters:
network
- is the network which is containing this bus line.name
- is the name of the new bus line
-
BusLine
public BusLine(UUID id, BusNetwork network, String name)
Create bus line with a memory-based attribute provider.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.network
- is the network which is containing this bus line.name
- is the name of the new bus line- Since:
- 2.0
-
BusLine
public BusLine(BusNetwork network, String name, AttributeCollection attributeProvider)
Create bus line.- Parameters:
network
- is the network which is containing this bus line.name
- is the name of the new bus lineattributeProvider
- the attribute provider.
-
BusLine
public BusLine(UUID id, BusNetwork network, String name, AttributeCollection attributeProvider)
Create bus line.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.network
- is the network which is containing this bus line.name
- is the name of the new bus lineattributeProvider
- the attribute provider.- Since:
- 2.0
-
BusLine
public BusLine(String name)
Create bus line with a memory-based attribute provider.- Parameters:
name
- is the name of the new bus line
-
BusLine
public BusLine(UUID id, String name)
Create bus line with a memory-based attribute provider.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.name
- is the name of the new bus line- Since:
- 2.0
-
BusLine
public BusLine(String name, AttributeCollection attributeProvider)
Create bus line.- Parameters:
name
- is the name of the new bus lineattributeProvider
- the attribute provider.
-
BusLine
public BusLine(UUID id, String name, AttributeCollection attributeProvider)
Create bus line.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.name
- is the name of the new bus lineattributeProvider
- the attribute provider.- Since:
- 2.0
-
BusLine
public BusLine(BusNetwork network)
Create bus line with a memory-based attribute provider.- Parameters:
network
- is the network which is containing this bus line.
-
BusLine
public BusLine(UUID id, BusNetwork network)
Create bus line with a memory-based attribute provider.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.network
- is the network which is containing this bus line.- Since:
- 2.0
-
BusLine
public BusLine(BusNetwork network, AttributeCollection attributeProvider)
Create bus line.- Parameters:
network
- is the network which is containing this bus line.attributeProvider
- the attribute provider.
-
BusLine
public BusLine(UUID id, BusNetwork network, AttributeCollection attributeProvider)
Create bus line.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.network
- is the network which is containing this bus line.attributeProvider
- the attribute provider.- Since:
- 2.0
-
BusLine
public BusLine()
Create bus line with a memory-based attribute provider.
-
BusLine
public BusLine(UUID id)
Create bus line with a memory-based attribute provider.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.- Since:
- 2.0
-
BusLine
public BusLine(AttributeCollection attributeProvider)
Create bus line.- Parameters:
attributeProvider
- the attribute provider.
-
BusLine
public BusLine(UUID id, AttributeCollection attributeProvider)
Create bus line.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.attributeProvider
- the attribute provider.- Since:
- 2.0
-
-
Method Detail
-
toJson
@Pure public void toJson(JsonBuffer buffer)
Description copied from interface:JsonableObject
Replies the Json representation of this node.- Specified by:
toJson
in interfaceJsonableObject
- Overrides:
toJson
in classAbstractBusPrimitive<BusNetwork>
- Parameters:
buffer
- the Json buffer.
-
getFirstFreeBusLineName
public static String getFirstFreeBusLineName(BusNetwork network)
Replies a bus line name that was not exist in the specified network.- Parameters:
network
- is the bus network from which a free bus line name may be computed.- Returns:
- the name suitable for a bus line.
-
rebuild
public void rebuild(boolean fireEvents)
Description copied from interface:BusPrimitive
Rebuild the primitive and all the primitive inside. Rebuilding means to reset all the internal values and recompute their values.This function should be invoked when the bus primitive was construct with its flag replied by
AttributeCollection.isEventFirable()
set tofalse
. This function permits to finalize the construction.In addition, this function automatically invoke
BoundedGISElement.resetBoundingBox()
and does the same job asBusPrimitive.revalidate()
(but does not invoke it). This function invokesAttributeCollection.setEventFirable(boolean)
withtrue
as parameter.- Parameters:
fireEvents
- indicates if the events should be fired.- See Also:
BusPrimitive.rebuild()
-
checkPrimitiveValidity
protected void checkPrimitiveValidity()
Description copied from class:AbstractBusPrimitive
Check if the validity of this primitive is correctly set and change its values if necessary. This function DO NOT revalidate the primitives inside this primitive.- Specified by:
checkPrimitiveValidity
in classAbstractBusPrimitive<BusNetwork>
- See Also:
AbstractBusPrimitive.revalidate()
-
getElementType
public Class<? extends BusItinerary> getElementType()
Description copied from interface:InformedIterable
Replies the class of the elements in this iterable object.- Returns:
- the type of the elements.
-
getBusNetwork
public BusNetwork getBusNetwork()
Description copied from interface:BusPrimitive
Replies the bus network in which this primitive is.- Returns:
- the bus network in which this primitive is.
-
setName
public void setName(String name)
Set the name of the element.- Specified by:
setName
in interfaceGISEditable
- Specified by:
setName
in interfaceGISElement
- Overrides:
setName
in classAbstractGISElement<BusNetwork,AbstractBusPrimitive<BusNetwork>>
- Parameters:
name
- the name.
-
calcBounds
protected Rectangle2d calcBounds()
Description copied from class:AbstractBoundedGISElement
Compute the bounds of this element. This function does not update the internal attribute replied byAbstractBoundedGISElement.getBoundingBox()
- Specified by:
calcBounds
in classAbstractBoundedGISElement<BusNetwork,AbstractBusPrimitive<BusNetwork>>
- Returns:
- the bounds
-
resetBoundingBox
public void resetBoundingBox()
Description copied from interface:BoundedGISElement
Clear the current bounding box to force the computation of it at the next call toBoundedElement2afp.getBoundingBox()
.- Specified by:
resetBoundingBox
in interfaceBoundedGISElement
- Specified by:
resetBoundingBox
in interfaceGISContainer<BusItinerary>
- Overrides:
resetBoundingBox
in classAbstractBoundedGISElement<BusNetwork,AbstractBusPrimitive<BusNetwork>>
-
getShape
public Shape2d<?> getShape()
Description copied from interface:BoundedGISElement
Replies the shape of this this element.The bounding box replied by
BoundedElement2afp.getBoundingBox()
encloses the replied shape.- Returns:
- the shape or
null
if not applicable.
-
toPath2D
@Pure public Path2d toPath2D()
Replies the path representation of this itinerary.- Returns:
- the path.
-
toPath2D
@Pure public void toPath2D(Path2d path)
Replies the path representation of this itinerary.- Parameters:
path
- the path to fill.
-
size
public int size()
Description copied from interface:GISContainer
Replies the count of map elements inside this container.- Returns:
- the count of map elements inside this container.
-
iterator
public Iterator<BusItinerary> iterator()
-
addBusItinerary
public boolean addBusItinerary(BusItinerary busItinerary)
Add a bus itinerary inside the bus line.- Parameters:
busItinerary
- is the bus itinerary to insert.- Returns:
true
if the bus itinerary was added, otherwisefalse
-
addBusItinerary
public boolean addBusItinerary(BusItinerary busItinerary, int index)
Add a bus itinerary at the specified index.- Parameters:
busItinerary
- is the bus itinerary to insert.index
- the index.- Returns:
true
if the bus itinerary was added, otherwisefalse
-
removeAllBusItineraries
public void removeAllBusItineraries()
Remove all the bus itineraries from the current line.
-
removeBusItinerary
public boolean removeBusItinerary(BusItinerary itinerary)
Remove a bus itinerary from this line. All the associated stops will be removed also.- Parameters:
itinerary
- is the bus itinerary to remove.- Returns:
true
if the bus itinerary was successfully removed, otherwisefalse
-
removeBusItinerary
public boolean removeBusItinerary(int index)
Remove the bus itinerary at the specified index. All the associated stops will be removed also.- Parameters:
index
- is the index of the bus itinerary to remove.- Returns:
true
if the bus itinerary was successfully removed, otherwisefalse
-
getBusItineraryCount
public int getBusItineraryCount()
Replies the count of bus itineraries into this line.- Returns:
- the count of bus itineraries into this line.
-
indexOf
public int indexOf(BusItinerary itinerary)
Replies the index of the specified bus itinerary.- Parameters:
itinerary
- is the bus itinerary to search for.- Returns:
- the index or
-1
if it was not found.
-
indexInParent
public int indexInParent()
Description copied from class:AbstractBusPrimitive
Replies the index of this primitive in its parent.- Specified by:
indexInParent
in classAbstractBusPrimitive<BusNetwork>
- Returns:
- the index of this primitive in its parent.
-
getBusItineraryAt
public BusItinerary getBusItineraryAt(int index)
Replies the itinerary at the specified index.- Parameters:
index
- the index.- Returns:
- a bus itinerary
- Throws:
IndexOutOfBoundsException
- in case of error.
-
getBusItinerary
public BusItinerary getBusItinerary(String name)
Replies the bus itinerary with the specified name.- Parameters:
name
- is the desired name- Returns:
- a bus itinerary or
null
-
getBusItinerary
public BusItinerary getBusItinerary(UUID uuid)
Replies the bus itinerary with the specified uuid.- Parameters:
uuid
- the identifier.- Returns:
- BusItinerary or
null
-
getBusItinerary
public BusItinerary getBusItinerary(String name, Comparator<String> nameComparator)
Replies the bus itinerary with the specified name.- Parameters:
name
- is the desired namenameComparator
- is used to compare the names.- Returns:
- a bus itinerary or
null
-
busItineraryIterator
public Iterator<BusItinerary> busItineraryIterator()
Replies the list of the bus itineraries of the bus line.- Returns:
- a list of bus itineraries
-
busItineraries
public Iterable<BusItinerary> busItineraries()
Replies the list of the bus itineraries of the bus line.- Returns:
- a list of bus itineraries
-
-