Search in sources :

Example 1 with CeciliaObject

use of blue.soundObject.ceciliaModule.CeciliaObject in project blue by kunstmusik.

the class CeciliaModule method loadFromXML.

/*
     * (non-Javadoc)
     * 
     * @see blue.soundObject.SoundObject#loadFromXML(electric.xml.Element)
     */
public static SoundObject loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
    CeciliaModule ceciliaModule = new CeciliaModule();
    SoundObjectUtilities.initBasicFromXML(data, ceciliaModule);
    ceciliaModule.setOrchestraVersion(Integer.parseInt(data.getTextString("orchestraVersion")));
    ceciliaModule.setGenSize(data.getTextString("genSize"));
    ceciliaModule.setModuleDefinition(ModuleDefinition.loadFromXML(data.getElement("moduleDefinition")));
    Elements stateNodes = data.getElements("ceciliaObject");
    while (stateNodes.hasMoreElements()) {
        Element elem = stateNodes.next();
        String key = elem.getAttributeValue("nameKey");
        CeciliaObject cObj = (CeciliaObject) ObjectUtilities.loadFromXML(elem);
        ceciliaModule.stateData.put(key, cObj);
    }
    return ceciliaModule;
}
Also used : CeciliaObject(blue.soundObject.ceciliaModule.CeciliaObject) Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 2 with CeciliaObject

use of blue.soundObject.ceciliaModule.CeciliaObject in project blue by kunstmusik.

the class CFilePanel method editCeciliaModule.

public void editCeciliaModule(CeciliaModule cm) {
    clearFileInputs();
    String tk_interface = cm.getModuleDefinition().tk_interface;
    StringTokenizer st = new StringTokenizer(tk_interface, "\n");
    String line;
    while (st.hasMoreTokens()) {
        line = st.nextToken().trim();
        if (line.length() == 0) {
            continue;
        }
        StringTokenizer objectTokenizer = new StringTokenizer(line);
        if (objectTokenizer.countTokens() < 2) {
            continue;
        }
        String objectType = objectTokenizer.nextToken();
        String objectName = objectTokenizer.nextToken();
        if (objectType.equals("cfilein")) {
            boolean isAudio = true;
            while (objectTokenizer.hasMoreTokens()) {
                String token = objectTokenizer.nextToken().trim();
                if (token.equals("-type") && objectTokenizer.hasMoreTokens() && !objectTokenizer.nextToken().trim().equals("audio")) {
                    isAudio = false;
                }
            }
            this.addFileInput(objectName, isAudio);
        }
    }
    for (Iterator iter = cm.getStateData().values().iterator(); iter.hasNext(); ) {
        CeciliaObject element = (CeciliaObject) iter.next();
        if (element instanceof CFileIn) {
            CFileIn cfileIn = (CFileIn) element;
            CFilePanel cfPanel = (CFilePanel) interfaceObjectMap.get(cfileIn.getObjectName());
            cfPanel.setCFileIn(cfileIn);
        }
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) CeciliaObject(blue.soundObject.ceciliaModule.CeciliaObject) Iterator(java.util.Iterator) CFileIn(blue.soundObject.ceciliaModule.CFileIn)

Example 3 with CeciliaObject

use of blue.soundObject.ceciliaModule.CeciliaObject in project blue by kunstmusik.

the class Grapher method editCeciliaModule.

public void editCeciliaModule(CeciliaModule ceciliaModule) {
    this.ceciliaModule = ceciliaModule;
    HashMap map = ceciliaModule.getStateData();
    if (map.size() == 0) {
        return;
    }
    for (Iterator iter = map.values().iterator(); iter.hasNext(); ) {
        CeciliaObject element = (CeciliaObject) iter.next();
        if (element instanceof CGraph) {
            CGraph graph = (CGraph) element;
            graphs.put(graph.getObjectName(), graph);
            if (currentGraph == null) {
                currentGraph = graph;
            }
        }
    }
    repaint();
}
Also used : HashMap(java.util.HashMap) CeciliaObject(blue.soundObject.ceciliaModule.CeciliaObject) Iterator(java.util.Iterator) CGraph(blue.soundObject.ceciliaModule.CGraph)

Example 4 with CeciliaObject

use of blue.soundObject.ceciliaModule.CeciliaObject in project blue by kunstmusik.

the class CeciliaModuleEditor method createDefaultStateData.

/**
 * @param moduleDefinition
 * @return
 */
private HashMap createDefaultStateData(ModuleDefinition moduleDefinition) {
    String tk_interface = moduleDefinition.tk_interface;
    StringTokenizer st = new StringTokenizer(tk_interface, "\n");
    String line;
    HashMap stateData = new HashMap();
    while (st.hasMoreTokens()) {
        line = st.nextToken().trim();
        if (line.length() == 0) {
            continue;
        }
        String[] tokens = TextUtilities.splitStringWithQuotes(line);
        String objectType = tokens[0];
        if (!objectType.equals("csepar") && tokens.length == 1) {
            // show some error
            continue;
        }
        if (objectType.equals("csepar")) {
            continue;
        }
        String objectName = tokens[1];
        CeciliaObject cObj = null;
        switch(objectType) {
            case "cfilein":
                CeciliaObject fileIn = new CFileIn();
                cObj = fileIn;
                break;
            case "cpopup":
                CPopup popup = new CPopup();
                cObj = popup;
                break;
            case "ctoggle":
                CToggle toggle = new CToggle();
                cObj = toggle;
                break;
            case "cslider":
                CSlider slider = new CSlider();
                cObj = slider;
                break;
            case "cgraph":
                CGraph graph = new CGraph();
                cObj = graph;
                break;
            default:
                break;
        }
        cObj.initialize(tokens);
        stateData.put(objectName, cObj);
    // ObjectUtilities.printMembers(cObj);
    }
    return stateData;
}
Also used : StringTokenizer(java.util.StringTokenizer) CToggle(blue.soundObject.ceciliaModule.CToggle) CSlider(blue.soundObject.ceciliaModule.CSlider) HashMap(java.util.HashMap) CeciliaObject(blue.soundObject.ceciliaModule.CeciliaObject) CPopup(blue.soundObject.ceciliaModule.CPopup) CGraph(blue.soundObject.ceciliaModule.CGraph) CFileIn(blue.soundObject.ceciliaModule.CFileIn)

Example 5 with CeciliaObject

use of blue.soundObject.ceciliaModule.CeciliaObject in project blue by kunstmusik.

the class CeciliaModule method saveAsXML.

/*
     * (non-Javadoc)
     * 
     * @see blue.soundObject.SoundObject#saveAsXML()
     */
@Override
public Element saveAsXML(Map<Object, String> objRefMap) {
    Element retVal = SoundObjectUtilities.getBasicXML(this);
    retVal.addElement("orchestraVersion").setText(Integer.toString(this.getOrchestraVersion()));
    retVal.addElement("genSize").setText(this.getGenSize());
    retVal.addElement(moduleDefinition.saveAsXML());
    for (String key : stateData.keySet()) {
        CeciliaObject cObj = (CeciliaObject) stateData.get(key);
        Element elem = cObj.saveAsXML();
        elem.setAttribute("nameKey", key);
        retVal.addElement(elem);
    }
    return retVal;
}
Also used : CeciliaObject(blue.soundObject.ceciliaModule.CeciliaObject) Element(electric.xml.Element)

Aggregations

CeciliaObject (blue.soundObject.ceciliaModule.CeciliaObject)7 HashMap (java.util.HashMap)4 Iterator (java.util.Iterator)4 CFileIn (blue.soundObject.ceciliaModule.CFileIn)2 CGraph (blue.soundObject.ceciliaModule.CGraph)2 CSlider (blue.soundObject.ceciliaModule.CSlider)2 CToggle (blue.soundObject.ceciliaModule.CToggle)2 Element (electric.xml.Element)2 StringTokenizer (java.util.StringTokenizer)2 CPopup (blue.soundObject.ceciliaModule.CPopup)1 Elements (electric.xml.Elements)1 JCheckBox (javax.swing.JCheckBox)1