/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package data;

import java.util.ArrayList;

/**
 *
 * @author Tom
 */
public class MotifData {
    private ArrayList<Beat> motif = null;
    private String type = "";
    private int numerator = 4;
    private int denominator = 4;
    private String key = "C major";

    public MotifData() {
    }

    public MotifData(ArrayList<Beat> motif, String type) {
        this.motif = motif;
        this.type = type;
    }
    
    public MotifData(ArrayList<Beat> motif, String type, int numerator, int denominator, String key) {
        this.motif = motif;
        this.type = type;
        this.numerator = numerator;
        this.denominator = denominator;
        this.key = key;
    }

    public ArrayList<Beat> getMotif() {
        return motif;
    }

    public void addMotif(Beat motif) {
        if (this.motif == null){
            this.motif = new ArrayList<>();
        }
        this.motif.add(motif);
    }

    /**
     * liefert die Anzahl der gefundenen Motive
     * @return Anzahl der Motive
     */
    public int getCount() {
        return motif.size();
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getNumerator() {
        return numerator;
    }

    public void setNumerator(int numerator) {
        this.numerator = numerator;
    }

    public int getDenominator() {
        return denominator;
    }

    public void setDenominator(int denominator) {
        this.denominator = denominator;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }
    
    @Override
    public String toString(){
        String s = "Type: " +type +" Count: " +getCount() +" | ";
        for (Beat b : motif){
            for (NoteData d : b.getBeat()){
              s += d.getNote() +d.getQuantizedDuration() +" ";
            }
            s += "| ";
            //wenn es sich um eine Wiederholung handelt
            //reicht die Ausgabe eines Vorkommnisses
            if (type.equalsIgnoreCase("Rep")){
                break;
            }
        }
        return s;
    }
}
