/** * 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); } } }
/** * toString Returns a String representation of the Brick * * @return a String */ @Override public String toString() { String strDur = (this.duration == 0) ? "*" : Integer.toString(this.duration); return name + " " + BrickLibrary.keyNumToName(key) + " " + strDur + " (type " + type + ") " + endValueString(); }
/** * toBrickDefinition Returns a Polylist formatted specifically to replicate the Brick's original * definition format * * @return a Polylist containing the Brick's definition information */ public Polylist toBrickDefinition() { PolylistBuffer buffer = new PolylistBuffer(); for (Block b : getSubBlocks()) { buffer.append(b.toPolylist()); } if (!variant.equals("")) { return Polylist.list( BrickLibrary.DEF_BRICK, dashed(name) + "(" + variant + ")", mode, dashed(type), BrickLibrary.keyNumToName(key)) .append(buffer.toPolylist()); } else { return Polylist.list( BrickLibrary.DEF_BRICK, dashed(name), mode, dashed(type), BrickLibrary.keyNumToName(key)) .append(buffer.toPolylist()); } }
/** * toRoadmapSave is used to create a Polylist for saving to a RoadMap This is NOT the same as the * Polylist usedd to save in the dictionary. Returns a Polylist representation of a Brick. * * @return a Polylist containing the Brick's contents */ @Override public Polylist toRoadmapSave() { PolylistBuffer buffer = new PolylistBuffer(); buffer.append(BRICK_KEYWORD); buffer.append(Polylist.list("name", dashed(name))); buffer.append(Polylist.list("variant", variant)); buffer.append(Polylist.list("type", type)); buffer.append(Polylist.list("key", BrickLibrary.keyNumToName(key))); buffer.append(Polylist.list("mode", mode)); buffer.append(Polylist.list("duration", duration)); buffer.append(Polylist.list("overlap", overlap)); buffer.append(Polylist.list("end", endValue)); buffer.append(subBlocksToRoadmapSave()); return buffer.toPolylist(); }
/** * toPolylist Returns a Polylist representation of a Brick. * * @return a Polylist containing the Brick's contents */ @Override public Polylist toPolylist() { return Polylist.list(BRICK_KEYWORD, dashed(name), BrickLibrary.keyNumToName(key), duration); }