MATSIM
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
org.matsim.vis.snapshotwriters.PositionEvent Class Reference
Inheritance diagram for org.matsim.vis.snapshotwriters.PositionEvent:
Inheritance graph
[legend]

Public Member Functions

 PositionEvent (double now, AgentSnapshotInfo position)
 
String getEventType ()
 
Coord getCoord ()
 
Id< PersongetPersonId ()
 
Id< LinkgetLinkId ()
 
Id< VehiclegetVehicleId ()
 
double getColorValueBetweenZeroAndOne ()
 
AgentSnapshotInfo.AgentState getState ()
 
Map< String, String > getAttributes ()
 
final double getTime ()
 
void setTime (double time)
 
String toString ()
 
boolean equals (Object obj)
 
int hashCode ()
 
void writeAsXML (StringBuilder out)
 

Public Attributes

String ATTRIBUTE_PERSON = "person"
 

Static Public Attributes

static final String EVENT_TYPE = "position"
 
static final String ATTRIBUTE_TIME = "time"
 
static final String ATTRIBUTE_TYPE = "type"
 
static final String ATTRIBUTE_X = "x"
 
static final String ATTRIBUTE_Y = "y"
 

Protected Member Functions

final void writeXMLStart (StringBuilder out)
 
final void writeXMLEnd (StringBuilder out)
 

Private Attributes

final AgentSnapshotInfo position
 

Detailed Description

Definition at line 14 of file PositionEvent.java.

Constructor & Destructor Documentation

◆ PositionEvent()

org.matsim.vis.snapshotwriters.PositionEvent.PositionEvent ( double  now,
AgentSnapshotInfo  position 
)

Definition at line 20 of file PositionEvent.java.

References org.matsim.vis.snapshotwriters.PositionEvent.position.

20  {
21  super(now);
22  this.position = position;
23  }

Member Function Documentation

◆ getEventType()

String org.matsim.vis.snapshotwriters.PositionEvent.getEventType ( )

Definition at line 26 of file PositionEvent.java.

References org.matsim.vis.snapshotwriters.PositionEvent.EVENT_TYPE.

26  {
27  return EVENT_TYPE;
28  }

◆ getCoord()

Coord org.matsim.vis.snapshotwriters.PositionEvent.getCoord ( )

◆ getPersonId()

Id<Person> org.matsim.vis.snapshotwriters.PositionEvent.getPersonId ( )

Implements org.matsim.api.core.v01.events.HasPersonId.

Definition at line 36 of file PositionEvent.java.

References org.matsim.vis.snapshotwriters.AgentSnapshotInfo.getId().

36  {
37  return position.getId();
38  }
Here is the call graph for this function:

◆ getLinkId()

Id<Link> org.matsim.vis.snapshotwriters.PositionEvent.getLinkId ( )

Definition at line 40 of file PositionEvent.java.

References org.matsim.vis.snapshotwriters.AgentSnapshotInfo.getLinkId().

Here is the call graph for this function:

◆ getVehicleId()

Id<Vehicle> org.matsim.vis.snapshotwriters.PositionEvent.getVehicleId ( )

Definition at line 44 of file PositionEvent.java.

References org.matsim.vis.snapshotwriters.AgentSnapshotInfo.getVehicleId().

44  {
45  return position.getVehicleId();
46  }
Here is the call graph for this function:

◆ getColorValueBetweenZeroAndOne()

double org.matsim.vis.snapshotwriters.PositionEvent.getColorValueBetweenZeroAndOne ( )

Definition at line 48 of file PositionEvent.java.

References org.matsim.vis.snapshotwriters.AgentSnapshotInfo.getColorValueBetweenZeroAndOne().

Here is the call graph for this function:

◆ getState()

AgentSnapshotInfo.AgentState org.matsim.vis.snapshotwriters.PositionEvent.getState ( )

Definition at line 52 of file PositionEvent.java.

References org.matsim.vis.snapshotwriters.AgentSnapshotInfo.getAgentState().

Here is the call graph for this function:

◆ getAttributes()

Map<String, String> org.matsim.vis.snapshotwriters.PositionEvent.getAttributes ( )

Definition at line 57 of file PositionEvent.java.

References org.matsim.vis.snapshotwriters.AgentSnapshotInfo.getAgentState(), org.matsim.vis.snapshotwriters.AgentSnapshotInfo.getLinkId(), and org.matsim.vis.snapshotwriters.AgentSnapshotInfo.getVehicleId().

57  {
58  try {
59  var attr = super.getAttributes();
60  attr.put("state", position.getAgentState().toString());
61  attr.put("linkId", position.getLinkId().toString());
62  if (position.getVehicleId() != null)
63  attr.put("vehicleId", position.getVehicleId().toString());
64  return attr;
65  } catch (Exception e) {
66  throw new RuntimeException("oh no!");
67  }
68  }
Here is the call graph for this function:

◆ getTime()

final double org.matsim.api.core.v01.events.Event.getTime ( )
inherited

◆ setTime()

void org.matsim.api.core.v01.events.Event.setTime ( double  time)
inherited

Definition at line 78 of file Event.java.

References org.matsim.api.core.v01.events.Event.time.

78  {
79  this.time = time;
80  }

◆ toString()

String org.matsim.api.core.v01.events.Event.toString ( )
inherited

Definition at line 82 of file Event.java.

References org.matsim.api.core.v01.events.Event.getAttributes().

Referenced by org.matsim.api.core.v01.events.TransitDriverStartsEvent.getAttributes(), and org.matsim.api.core.v01.events.TransitDriverStartsEvent.writeAsXML().

82  {
83  Map<String,String> attr = this.getAttributes() ;
84  StringBuilder eventXML = new StringBuilder("\t<event ");
85  for (Map.Entry<String, String> entry : attr.entrySet()) {
86  eventXML.append(entry.getKey());
87  eventXML.append("=\"");
88  eventXML.append(entry.getValue());
89  eventXML.append("\" ");
90  }
91  eventXML.append(" />");
92  return eventXML.toString();
93  }
Map< String, String > getAttributes()
Definition: Event.java:44
Here is the call graph for this function:

◆ equals()

boolean org.matsim.api.core.v01.events.Event.equals ( Object  obj)
inherited

Definition at line 96 of file Event.java.

References org.matsim.api.core.v01.events.Event.Event(), org.matsim.api.core.v01.events.Event.getAttributes(), org.matsim.api.core.v01.events.Event.getEventType(), and org.matsim.api.core.v01.events.Event.time.

96  {
97  if (!(obj instanceof Event)) {
98  return false;
99  } else {
100  Event other = (Event) obj;
101  return time == other.time &&
102  getEventType().equals(other.getEventType()) &&
103  getAttributes().equals(other.getAttributes());
104  }
105  }
Map< String, String > getAttributes()
Definition: Event.java:44
Here is the call graph for this function:

◆ hashCode()

int org.matsim.api.core.v01.events.Event.hashCode ( )
inherited

Definition at line 108 of file Event.java.

References org.matsim.api.core.v01.events.Event.getAttributes().

108  {
109  return getAttributes().hashCode(); // Two equal events must at least have the same attributes, so they will get the same hashCode like this.
110  }
Map< String, String > getAttributes()
Definition: Event.java:44
Here is the call graph for this function:

◆ writeXMLStart()

final void org.matsim.api.core.v01.events.Event.writeXMLStart ( StringBuilder  out)
protectedinherited

Write the start of the xml representation and some common attributes. This method should be called first by writeAsXML(StringBuilder).

Definition at line 116 of file Event.java.

References org.matsim.api.core.v01.BasicLocation.getCoord(), org.matsim.api.core.v01.events.Event.getEventType(), org.matsim.api.core.v01.events.HasFacilityId.getFacilityId(), org.matsim.api.core.v01.events.HasLinkId.getLinkId(), org.matsim.api.core.v01.events.HasPersonId.getPersonId(), and org.matsim.api.core.v01.events.HasVehicleId.getVehicleId().

Referenced by org.matsim.api.core.v01.events.VehicleAbortsEvent.writeAsXML(), org.matsim.api.core.v01.events.PersonEntersVehicleEvent.writeAsXML(), org.matsim.api.core.v01.events.PersonLeavesVehicleEvent.writeAsXML(), org.matsim.api.core.v01.events.PersonStuckAndContinueEvent.writeAsXML(), org.matsim.api.core.v01.events.PersonArrivalEvent.writeAsXML(), org.matsim.api.core.v01.events.LinkEnterEvent.writeAsXML(), org.matsim.api.core.v01.events.PersonScoreEvent.writeAsXML(), org.matsim.api.core.v01.events.LinkLeaveEvent.writeAsXML(), org.matsim.api.core.v01.events.PersonDepartureEvent.writeAsXML(), org.matsim.api.core.v01.events.PersonStuckEvent.writeAsXML(), org.matsim.api.core.v01.events.TransitDriverStartsEvent.writeAsXML(), org.matsim.api.core.v01.events.ActivityEndEvent.writeAsXML(), org.matsim.api.core.v01.events.ActivityStartEvent.writeAsXML(), and org.matsim.api.core.v01.events.PersonMoneyEvent.writeAsXML().

116  {
117  out.append("\t<event time=\"").append(time).append("\" type=\"");
118  writeEncodedAttributeValue(out, getEventType()).append("\" ");
119 
120  if (this instanceof HasPersonId hasPersonId && hasPersonId.getPersonId() != null) {
121  out.append("person=\"");
122  writeEncodedAttributeValue(out, hasPersonId.getPersonId().toString()).append("\" ");
123  }
124 
125  if (this instanceof HasFacilityId hasFacilityId && hasFacilityId.getFacilityId() != null) {
126  out.append("facility=\"");
127  writeEncodedAttributeValue(out, hasFacilityId.getFacilityId().toString()).append("\" ");
128  }
129 
130  if (this instanceof HasLinkId hasLinkId && hasLinkId.getLinkId() != null) {
131  out.append("link=\"");
132  writeEncodedAttributeValue(out, hasLinkId.getLinkId().toString()).append("\" ");
133  }
134 
135  if (this instanceof BasicLocation basicLocation && basicLocation.getCoord() != null) {
136  if (basicLocation.getCoord() != null) {
137  out.append("x=\"").append(basicLocation.getCoord().getX()).append("\" ");
138  out.append("y=\"").append(basicLocation.getCoord().getY()).append("\" ");
139  }
140  }
141 
142  if (this instanceof HasVehicleId hasVehicleId && hasVehicleId.getVehicleId() != null) {
143  out.append("vehicle=\"");
144  writeEncodedAttributeValue(out, hasVehicleId.getVehicleId().toString()).append("\" ");
145  }
146  }
Here is the call graph for this function:

◆ writeXMLEnd()

final void org.matsim.api.core.v01.events.Event.writeXMLEnd ( StringBuilder  out)
protectedinherited

◆ writeAsXML()

void org.matsim.api.core.v01.events.Event.writeAsXML ( StringBuilder  out)
inherited

Write a xml representation of this event to the given writer. The implementation must write the whole xml element <event ... />. Starting with and adding a newline at the end.

The provided default implementation writes the whole element based on getAttributes(). This is slow and should be overridden. The overriding implementation must not call the super method.

Definition at line 162 of file Event.java.

References org.matsim.core.utils.io.XmlUtils.encodeAttributeValue(), and org.matsim.api.core.v01.events.Event.getAttributes().

162  {
163  out.append("\t<event ");
164  Map<String, String> attr = getAttributes();
165  for (Map.Entry<String, String> entry : attr.entrySet()) {
166  out.append(entry.getKey());
167  out.append("=\"");
168  out.append(XmlUtils.encodeAttributeValue(entry.getValue()));
169  out.append("\" ");
170  }
171  out.append(" />\n");
172  }
Map< String, String > getAttributes()
Definition: Event.java:44
Here is the call graph for this function:

Member Data Documentation

◆ EVENT_TYPE

final String org.matsim.vis.snapshotwriters.PositionEvent.EVENT_TYPE = "position"
static

◆ position

final AgentSnapshotInfo org.matsim.vis.snapshotwriters.PositionEvent.position
private

◆ ATTRIBUTE_TIME

final String org.matsim.api.core.v01.events.Event.ATTRIBUTE_TIME = "time"
staticinherited

◆ ATTRIBUTE_TYPE

final String org.matsim.api.core.v01.events.Event.ATTRIBUTE_TYPE = "type"
staticinherited

Definition at line 34 of file Event.java.

◆ ATTRIBUTE_X

final String org.matsim.api.core.v01.events.Event.ATTRIBUTE_X = "x"
staticinherited

◆ ATTRIBUTE_Y

final String org.matsim.api.core.v01.events.Event.ATTRIBUTE_Y = "y"
staticinherited

◆ ATTRIBUTE_PERSON

String org.matsim.api.core.v01.events.HasPersonId.ATTRIBUTE_PERSON = "person"
inherited

The documentation for this class was generated from the following file: