Class Pedestrian

All Implemented Interfaces:
Graph.Graphic, NamedObjectOps

public class Pedestrian extends DirectedObject2D
Class representing a pedestrian. The pedestrian's default reference point is at the center of the circle representing the pedestrian. This is generally the one that one should use as a pedestrian is a small object in a typical animation.

A pedestrian is represented by a circle, with each half a different color (one to represent hair and the other a face). The 'face' half has two smaller ellipses representing eyes, primarily to provide a sense of direction. All the features are scaled based on the circle's radius.

  • Constructor Details

    • Pedestrian

      public Pedestrian(Animation2D a2d, String name, boolean intern)
      Constructor.
      Parameters:
      a2d - the animation
      name - the name of this object
      intern - true if the object is interned in the animation's name space; false otherwise.
  • Method Details

    • configure

      public void configure(Color hairColor, Color faceColor, Color eyeColor)
      Configure the the object representing a pedestrian.
      Parameters:
      hairColor - the color of pedestrian's hair; null for the default
      faceColor - the color of the pedestrian's face; null for the default
      eyeColor - the color of the pedestrian's eyes; null for the default
    • configure

      public void configure(Color hairColor, Color faceColor, Color eyeColor, double radius)
      Configure the the object representing a pedestrian, providing a radius.
      Parameters:
      hairColor - the color of pedestrian's hair; null for the default
      faceColor - the color of the pedestrian's face; null for the default
      eyeColor - the color of the pedestrian's eyes; null for the default
      radius - the radius for the circular representation of a pedestrian (must be a positive real number)
      Throws:
      IllegalArgumentException - the radius is less than or equal to zero
    • getHairColor

      public Color getHairColor()
      Get the color used to represent the pedestrian's hair.
      Returns:
      the color used to represent the pedestrian's hair
    • getFaceColor

      public Color getFaceColor()
      Get the color used to represent the pedestrian's face.
      Returns:
      the color used to represent the pedestrian's face
    • addTo

      public void addTo(Graph graph, Graphics2D g2d, Graphics2D g2dGcS)
    • printConfiguration

      public void printConfiguration(String iPrefix, String prefix, boolean printName, PrintWriter out)
      Print the configuration for an instance of Pedestrian. The documentation for method SimObject.printConfiguration(String,String,boolean,java.io.PrintWriter) contains a description of how this method is used and how to override it. The method DirectedObject2D.printConfiguration(String,String,boolean,java.io.PrintWriter) describes the data that will be printed for the superclass of Pedestrian. The data that will be printed when this method is called is the following.

      For class Pedestrian:

      • the hair color.
      • the face color.
      • the eye color.
      • the radius of the disk representing a pedestrian.
      Overrides:
      printConfiguration in class DirectedObject2D
      Parameters:
      iPrefix - the prefix to use for an initial line when printName is true with null treated as an empty string
      prefix - a prefix string (typically whitespace) to put at the start of each line other than the initial line that is printed when printName is true
      printName - requests printing the name of an object
      out - the output print writer
    • printState

      public void printState(String iPrefix, String prefix, boolean printName, PrintWriter out)
      Print the state for an instance of Pedestrian. The documentation for method SimObject.printState(String,String,boolean,java.io.PrintWriter) contains a description of how this method is used and how to override it. The method DirectedObject2D.printState(String,String,boolean,java.io.PrintWriter) describes the data that will be printed for the superclass of Pedestrian (Pedestrian itself does not add any text).
      Overrides:
      printState in class DirectedObject2D
      Parameters:
      iPrefix - the prefix to use for an initial line when printName is true with null treated as an empty string
      prefix - a prefix string (typically whitespace) to put at the start of each line other than the initial line that is printed when printName is true
      printName - requests printing the name of an object
      out - the output print writer
    • clone

      protected Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • isInterned

      public boolean isInterned()
      Specified by:
      isInterned in interface NamedObjectOps
    • getObjectNamer

      protected Simulation getObjectNamer()
    • getName

      public final String getName()
      Specified by:
      getName in interface NamedObjectOps
    • canDelete

      public boolean canDelete()
      Specified by:
      canDelete in interface NamedObjectOps
    • delete

      public final boolean delete()
      Specified by:
      delete in interface NamedObjectOps
    • isDeleted

      public final boolean isDeleted()
      Specified by:
      isDeleted in interface NamedObjectOps
    • deletePending

      public final boolean deletePending()
      Specified by:
      deletePending in interface NamedObjectOps