Esempio n. 1
0
  /**
   * printBrick Prints a String representation of a Brick with its subblocks to the error
   * printstream
   */
  public void printBrick() {
    String brickName = this.getName();
    if (!this.getVariant().isEmpty()) {
      brickName += "(" + this.getVariant() + ")";
    }
    String brickKey = BrickLibrary.keyNumToName(this.getKey());
    long brickDur = this.getDuration();
    String brickType = this.getType();
    System.out.println(
        "Printing brick " + brickName + " " + brickType + " " + brickKey + " " + brickDur);

    ArrayList<Block> subBlockList = this.getSubBlocks();
    Iterator<Block> blockIter = subBlockList.iterator();

    while (blockIter.hasNext()) {
      Block currentBlock = blockIter.next();

      if (currentBlock instanceof Brick) {
        Brick currentBrick = (Brick) currentBlock;
        String currentBrickName = currentBrick.getName();
        Long currentBrickKey = currentBrick.getKey();
        String currentBrickKeyString = BrickLibrary.keyNumToName(currentBrickKey);
        long dur = currentBrick.getDuration();
        System.out.println(
            "Printing brick " + currentBrickName + " " + currentBrickKeyString + " " + dur);
      } else if (currentBlock instanceof ChordBlock) {
        ChordBlock currentChord = (ChordBlock) currentBlock;
        String currentChordName = currentChord.getName();
        int currentDuration = currentChord.getDuration();
        System.out.println("Printing Chord" + currentChordName + " " + currentDuration);
      }
    }
  }
Esempio n. 2
0
  /**
   * Brick / 1 Copy constructor for a brick. Makes a deep copy.
   *
   * @param brick, a Brick
   */
  public Brick(Brick brick) {
    super(brick.name, brick.getKey());
    variant = brick.getVariant();
    subBlocks = new ArrayList<Block>();

    // Loop through all the subblocks, making copies of each
    ListIterator blockIter = brick.getSubBlocks().listIterator();
    while (blockIter.hasNext()) {
      Block block = (Block) blockIter.next();
      if (block.isOverlap()) {
        if (block.isBrick()) {
          Brick overlapBrick = new Brick((Brick) block);
          subBlocks.addAll(overlapBrick.flattenBlock());
        }
      } else if (block instanceof Brick) {
        Brick nextBrick = new Brick((Brick) block);
        String subName = nextBrick.getName();
        if (subName.contains(LAUNCHER_KEYWORD)) {
          String newName = subName.replaceAll(" \\(Launcher\\)", "");
          newName = newName.replaceAll(LAUNCHER_KEYWORD, APPROACH_KEYWORD);
          nextBrick.setName(newName);
        }
        subBlocks.add(nextBrick);
      } else {
        subBlocks.add(new ChordBlock((ChordBlock) block));
      }
    }

    type = brick.getType();
    this.updateDuration();
    mode = brick.getMode();
    endValue = getSectionEnd();
  }