コード例 #1
0
ファイル: WedgeBuilder.java プロジェクト: jesseeichar/debrief
  /**
   * this method is called by the 'Create' function, and it fills in the buoys into the correct
   * pattern
   */
  protected final void addBuoys(Debrief.Wrappers.BuoyPatternWrapper pattern) {
    WorldLocation origin = getKingpin();
    // note that as we calculate the LH angle
    double lh_orient_rads = MWC.Algorithms.Conversions.Degs2Rads(_orientation2);
    double rh_orient_rads = MWC.Algorithms.Conversions.Degs2Rads(_orientation1);
    double spacing_degs = MWC.Algorithms.Conversions.Nm2Degs(_spacing);

    // how many bouys in each leg?
    // an even number means we don't have one at the tip, which becomes a special case
    int num_buoys = getNumberOfBuoys().intValue();
    boolean even_num = false;
    if ((num_buoys % 2) == 0) {
      even_num = true;
    }

    // sort out how many there are in each leg
    int num_in_leg = num_buoys / 2;

    // sort out the direction
    double this_orient = rh_orient_rads;

    int buoy_counter = 0;

    // remember that we are looking at the first buoy
    boolean first_buoy = true;

    // do the first leg
    for (int i = 0; i < num_in_leg; i++) {
      // create the new symbol
      Debrief.Wrappers.LabelWrapper lw =
          new Debrief.Wrappers.LabelWrapper("W" + (buoy_counter + 1), origin, java.awt.Color.red);

      buoy_counter++;

      // get the parent to do the formatting
      this.formatSymbol(lw, pattern);

      // if this is the first buoy, mark it as the kingping
      if (first_buoy) {
        lw.setSymbolType("Kingpin");
        first_buoy = false;
      }

      // create the step to use to get to the next buoy
      WorldVector thisStep = new MWC.GenericData.WorldVector(this_orient, spacing_degs, 0.0);

      // place buoy
      origin = origin.add(thisStep);
    }

    // if we have an even number, we need to move forward 1/2 distance for one more step before we
    // change direction
    if (even_num) {
      // calculate the size of this small step
      double reverse_rh_rads = MWC.Algorithms.Conversions.Degs2Rads(_orientation1 + 180.0);
      WorldVector short_hop = new WorldVector(reverse_rh_rads, spacing_degs / 2, 0.0);

      // move the origin forward
      origin = origin.add(short_hop);

      // calculate the size of this small step
      short_hop = new WorldVector(lh_orient_rads, spacing_degs / 2, 0.0);

      // move the origin forward
      origin = origin.add(short_hop);
    } else {

      // drop a buoy at the current point
      Debrief.Wrappers.LabelWrapper lw =
          new Debrief.Wrappers.LabelWrapper("W" + (buoy_counter + 1), origin, java.awt.Color.red);
      buoy_counter++;

      // move to the correct location for the next point
      WorldVector short_hop = new WorldVector(lh_orient_rads, spacing_degs, 0.0);

      // move the origin forward
      origin = origin.add(short_hop);

      // get the parent to do the formatting
      this.formatSymbol(lw, pattern);
    }

    // now travel back down the reverse side
    // sort out the direction
    this_orient = lh_orient_rads;

    // do the first leg
    for (int i = 0; i < num_in_leg; i++) {

      // create the new symbol
      Debrief.Wrappers.LabelWrapper lw =
          new Debrief.Wrappers.LabelWrapper("W" + (buoy_counter + 1), origin, java.awt.Color.red);

      buoy_counter++;

      // get the parent to do the formatting
      this.formatSymbol(lw, pattern);

      // create the step to use to get to the next buoy
      WorldVector thisStep = new MWC.GenericData.WorldVector(this_orient, spacing_degs, 0.0);

      // start moving down the return leg
      // move buoy
      origin = origin.add(thisStep);
    }
  }