
package turgen;

import javax.swing.JLabel;

/**Status, maintans number of generated wave files, tape images and
   direct outputs to audio system*/
public class TurgenStatus {

    private int generatedWaves = 0;
    private int generatedDirect =0;
    private int failedWaves = 0;
    private int failedDirect=0;
    private int generatedTapeImages=0;
    private int failedTapeImages;
    
    private StringBuffer messageBuf = new StringBuffer();
    private static final String STR_GENERATED_WAVES = "Wave(s): ";
    private static final String STR_GENERATED_DIRECTLY = "Directly: ";
    private static final String STR_GENERATED_FAILED = " failed. ";
    private static final String STR_OK=" ok,";
    private static final String STR_TAPE_IMAGES="Tape image(s): ";
    
    private JLabel statusLabel=null;
    
    public TurgenStatus(JLabel l) {
        statusLabel=l;
    }
    
    
    public void clearWaves() {
        this.generatedWaves=0;
        this.failedWaves=0;
        updateStatus();
    }
    
     public void clearDirect() {
        this.generatedDirect=0;
        this.failedDirect=0;
        updateStatus();
    }
     
    public void clearTapeImages()  {
        this.generatedTapeImages=0;
        this.failedTapeImages=0;
    }
     
    public void addFailedWaves() {
        this.failedWaves++;
        updateStatus();
    }
    
    public void addFailedDirect() {
        this.failedDirect++;
        updateStatus();
    }
    
    public void addGeneratedWaves() {
        this.generatedWaves++;
        updateStatus();
    }
    
    public void addGeneratedDirect() {
        this.generatedDirect++;
        updateStatus();
    }
    
    public void addFailedTapeImages() {
        this.failedTapeImages++;
        updateStatus();
    }
    
    public void addGeneratedTapeImages() {
        this.generatedTapeImages++;
        updateStatus();
    }
    
    public void updateStatusGUI() {
        messageBuf.setLength(0);
        messageBuf.append(STR_GENERATED_WAVES);
        messageBuf.append(generatedWaves);
        messageBuf.append(STR_OK);
        messageBuf.append(failedWaves);
        messageBuf.append(STR_GENERATED_FAILED);
        
        messageBuf.append(STR_GENERATED_DIRECTLY);
        messageBuf.append(generatedDirect);
        messageBuf.append(STR_OK);
        messageBuf.append(failedDirect);
        messageBuf.append(STR_GENERATED_FAILED);
        
        messageBuf.append(STR_TAPE_IMAGES);
        messageBuf.append(generatedTapeImages);
        messageBuf.append(STR_OK);
        messageBuf.append(failedTapeImages);
        messageBuf.append(STR_GENERATED_FAILED);
        
        statusLabel.setText(messageBuf.toString());
    }
    
    void updateStatus() {
        ParallelGUIUpdater.updateStatusGUI();
    }
}
