Class Bicycle

All Implemented Interfaces:
Graph.Graphic, NamedObjectOps

public class Bicycle extends DirectedObject2D
Class representing a bicycle. The bicycle's reference point is at the location of the seat, which is at the center of the bicycle's bounding box for the default configuration.
  • Constructor Details

    • Bicycle

      public Bicycle(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 helmetColor, Color bikeColor)
      Configure the the object representing a bicycle using default dimensions.
      Parameters:
      helmetColor - the color of the rider's helmet
      bikeColor - the color of the bicycle
    • configure

      public void configure(Color helmetColor, Color bikeColor, double helmetScaleFactor)
      Configure the the object representing a bicycle using default dimensions but with helmet scaling.
      Parameters:
      helmetColor - the color of the rider's helmet
      bikeColor - the color of the bicycle
      helmetScaleFactor - the factor by which the dimensions of a helmet will be multiplied when the helmet is configured
    • configure

      public void configure(Color helmetColor, Color bikeColor, double helmetScaleFactor, double lookStringScaleFactor)
      Configure the the object representing a bicycle using default dimensions but with helmet scaling and look-string scaling.

      The scale factor used to size the 'look' string will be lookStringScaleFactor when helmetScaleFactor is less than 1.0, and helmetScaleFactor*lookStringScaleFactor otherwise. The value of lookStringScaleFactor must not be less than 1.0.

      Parameters:
      helmetColor - the color of the rider's helmet
      bikeColor - the color of the bicycle
      helmetScaleFactor - the factor by which the dimensions of a helmet will be multiplied when the helmet is configured
      lookStringScaleFactor - the fraction by which the dimensions of the look-string text will be scaled.
    • configure

      public void configure(Color helmetColor, Color bikeColor, double bikeHead, double bikeTail, double bikeWidth, double handlebarPosition, double handlebarHalfLength, double handlebarTail)
      Configure the the object representing a bicycle with default helmet dimensions.
      Parameters:
      helmetColor - the color of the rider's helmet
      bikeColor - the color of the bicycle
      bikeHead - the distance from the seat to the front of the bicycle
      bikeTail - the distance from the seat to the rear of the bicycle
      bikeWidth - the width of the bicycle tubing (e.g., the frame)
      handlebarPosition - the distance from the seat to the handle bars
      handlebarHalfLength - the distance the handlebars extend perpendicular to the frame, measured from the frame and excluding the portion of the handlebars parallel to the frame
      handlebarTail - the length of the portion of the handlebars parallel to the bicycle
    • configure

      public void configure(Color helmetColor, Color bikeColor, double bikeHead, double bikeTail, double bikeWidth, double handlebarPosition, double handlebarHalfLength, double handlebarTail, double helmetScaleFactor) throws IllegalArgumentException
      Configure the the object representing a bicycle and helmet, providing a helmet-scaling factor. When the helemtScaleFactor argument is larger than 1.0, the position and font size of the string displayed when setLooking(true) is called will be changed from the default value.
      Parameters:
      helmetColor - the color of the rider's helmet
      bikeColor - the color of the bicycle
      bikeHead - the distance from the seat to the front of the bicycle
      bikeTail - the distance from the seat to the rear of the bicycle
      bikeWidth - the width of the bicycle tubing (e.g., the frame)
      handlebarPosition - the distance from the seat to the handle bars
      handlebarHalfLength - the distance the handlebars extend perpendicular to the frame, measured from the frame and excluding the portion of the handlebars parallel to the frame
      handlebarTail - the length of the portion of the handlebars parallel to the bicycle
      helmetScaleFactor - the factor by which the dimensions of a helmet will be multiplied when the helmet is configured
      Throws:
      IllegalArgumentException
    • configure

      public void configure(Color helmetColor, Color bikeColor, double bikeHead, double bikeTail, double bikeWidth, double handlebarPosition, double handlebarHalfLength, double handlebarTail, double helmetScaleFactor, double lookStringScaleFactor) throws IllegalArgumentException
      Configure the the object representing a bicycle and helmet, providing a helmet-scaling factor and look-string scaling factor. When the helemtScaleFactor argument is larger than 1.0, the position and font size of the string displayed when setLooking(true) is called will be changed from the default value.

      The scale factor used to size the 'look' string will be lookStringScaleFactor when helmetScaleFactor is less than 1.0, and helmetScaleFactor*lookStringScaleFactor otherwise. The value of lookStringScaleFactor must not be less than 1.0.

      Parameters:
      helmetColor - the color of the rider's helmet
      bikeColor - the color of the bicycle
      bikeHead - the distance from the seat to the front of the bicycle
      bikeTail - the distance from the seat to the rear of the bicycle
      bikeWidth - the width of the bicycle tubing (e.g., the frame)
      handlebarPosition - the distance from the seat to the handle bars
      handlebarHalfLength - the distance the handlebars extend perpendicular to the frame, measured from the frame and excluding the portion of the handlebars parallel to the frame
      handlebarTail - the length of the portion of the handlebars parallel to the bicycle
      helmetScaleFactor - the factor by which the dimensions of a helmet will be multiplied when the helmet is configured
      lookStringScaleFactor - the fraction by which the dimensions of the look-string text will be scaled.
      Throws:
      IllegalArgumentException
    • getLookString

      public String getLookString()
      Get the string to display when setLooking is given the argument 'true'.
      Returns:
      the string to display
    • setLookString

      public void setLookString(String string)
      Set the string to display when setLooking is given the argument 'true'.
      Parameters:
      string - the string to display; null or an empty string for the default (the string "Look")
    • setLooking

      public void setLooking(boolean value)
      Set whether or not the word "Look", or the value provided by the method setLookString, should be displayed in front of the helmet.
      Parameters:
      value - true if the string should be displayed, false otherwise.
    • setLookParams

      public void setLookParams(Color color)
      Set the font color for a "looking" indication. Calling any of the methods named configure will set the color to the default value, so to set the color to a different value, call this method after the config method is called.
      Parameters:
      color - the text color
    • setHelmetAngle

      public void setHelmetAngle(double angle)
      Set the angle of the helmet relative to the bicycle. An angle of zero points in the direction in which the bicycle is pointed, and angles are measured counterclockwise in radians.
      Parameters:
      angle - the angle
    • getHelmetAngle

      public double getHelmetAngle()
      Get the angle of the helmet relative to the bicycle. An angle of zero points in the direction in which the bicycle is pointed.
      Returns:
      the helmet angle
    • getSeatXGCS

      public double getSeatXGCS()
      Get the X coordinate of the seat in graph coordinate space.
      Returns:
      the X coordinate of the seat in graph coordinate space.
    • getSeatYGCS

      public double getSeatYGCS()
      Get the Y coordinate of the seat in graph coordinate space.
      Returns:
      the Y coordinate of the seat in graph coordinate space.
    • 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 Bicycle. 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 this class. The data that will be printed when this method is called is the following.

      For class Bicycle:

      • the bicycle's color.
      • the color of the rider's helmet.
      • the helmet scale factor (when "looking", the helmet can be magnified to make it more obvious).
      • the bicycle head (the distance from the seat to the front of the bicycle).
      • the bicycle tail (the distance from the seat to the rear of the bicycle).
      • the width of the bicycle.
      • the handlebar position (the distance from the seat to the handlebars).
      • the handlebar half length (extent to which one half of the hanglebars extends outwards).
      • the handlebar tail (the length of a line drawn parallel to the bicycle to represent the ends of the handlebars).
      • the helmet angle (the angle from the direction in which the bicycle is pointed, indicating the direction in which a rider would be looking).
      • the look string (the string that will be displayed to indicate that a rider is looking at something).
      • looking (a boolean that, when true, indicates that the look string is displayed).
      • look-string color (the color of the font used for the look string).
      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 Bicycle. 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 this class. The data that will be printed when this method is called is the following.

      For class Bicycle:

      • the helmet angle (the angle from the direction in which the bicycle is pointed, indicating the direction in which a rider would be looking).
      • the look string (the string that will be displayed to indicate that a rider is looking at something).
      • looking (a boolean that, when true, indicates that the look string is displayed).
      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