/**
   * Function to add a specific message to the map
   *
   * @param message
   */
  public void setMarker(MsiMessageExtended message) {
    this.message = message;
    this.msiLocation = message.msiMessage.getLocation().getCenter();
    LatLonPoint center = (LatLonPoint) mapBean.getCenter();
    GeoLocation geoCenter = new GeoLocation(center.getLatitude(), center.getLongitude());
    double bearing = Calculator.bearing(geoCenter, msiLocation, Heading.RL);

    Projection projection = mapBean.getProjection();
    Point2D projectedMSI =
        projection.forward(msiLocation.getLatitude(), msiLocation.getLongitude());

    Point2D origin = new Point2D.Double(mapBean.getWidth() * 0.5f, mapBean.getHeight() * 0.5f);
    Line2D direction = new Line2D.Double(origin, projectedMSI);

    double boxWidth = mapBean.getWidth() - IMAGE_SIZE / 2;
    double boxHeight = mapBean.getHeight() - IMAGE_SIZE / 2;
    Line2D topFrame = new Line2D.Double(IMAGE_SIZE / 2, IMAGE_SIZE / 2, boxWidth, IMAGE_SIZE / 2);
    Line2D rightFrame = new Line2D.Double(boxWidth, IMAGE_SIZE / 2, boxWidth, boxHeight);
    Line2D bottomFrame = new Line2D.Double(IMAGE_SIZE / 2, boxHeight, boxWidth, boxHeight);
    Line2D leftFrame = new Line2D.Double(IMAGE_SIZE / 2, IMAGE_SIZE / 2, IMAGE_SIZE / 2, boxHeight);

    boolean intersects = false;

    if (intersects(direction, topFrame)) intersects = true;
    if (intersects(direction, rightFrame)) intersects = true;
    if (intersects(direction, bottomFrame)) intersects = true;
    if (intersects(direction, leftFrame)) intersects = true;

    if (!intersects) return;

    int x = Math.round((float) intersection.getX());
    int y = Math.round((float) intersection.getY());

    directionRaster = new CenterRaster(x, y, directionImage);
    directionRaster.setRotationAngle(Math.toRadians(bearing));

    markerRaster = new CenterRaster(x, y, markerImage);

    add(markerRaster);
    add(directionRaster);
  }
  public IntendedRouteLegGraphic(
      int index,
      IntendedRouteGraphic intendedRouteGraphic,
      boolean activeWaypoint,
      GeoLocation start,
      GeoLocation end,
      Color legColor) {

    super(
        start.getLatitude(),
        start.getLongitude(),
        end.getLatitude(),
        end.getLongitude(),
        LINETYPE_RHUMB);
    this.index = index;
    this.intendedRouteGraphic = intendedRouteGraphic;
    if (activeWaypoint) {
      setStroke(
          new BasicStroke(
              2.0f, // Width
              BasicStroke.CAP_SQUARE, // End cap
              BasicStroke.JOIN_MITER, // Join style
              10.0f, // Miter limit
              new float[] {3.0f, 10.0f}, // Dash pattern
              0.0f)); // Dash phase)
    } else {
      setStroke(
          new BasicStroke(
              3.0f, // Width
              BasicStroke.CAP_SQUARE, // End cap
              BasicStroke.JOIN_MITER, // Join style
              10.0f, // Miter limit
              new float[] {10.0f, 8.0f}, // Dash pattern
              0.0f)); // Dash phase)
    }
    setLinePaint(legColor);
  }