Search in sources :

Example 86 with Elements

use of electric.xml.Elements in project blue by kunstmusik.

the class TimeState method loadFromXML.

/*
     * SERIALIZATION CODE
     */
public static TimeState loadFromXML(Element data) {
    TimeState timeState = new TimeState();
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element e = nodes.next();
        String nodeName = e.getName();
        final String nodeText = e.getTextString();
        switch(nodeName) {
            case "pixelSecond":
                timeState.pixelSecond = Integer.parseInt(nodeText);
                break;
            case "snapEnabled":
                timeState.snapEnabled = Boolean.valueOf(nodeText).booleanValue();
                break;
            case "snapValue":
                timeState.snapValue = Double.parseDouble(nodeText);
                break;
            case "timeDisplay":
                timeState.timeDisplay = Integer.parseInt(nodeText);
                break;
            case "timeUnit":
                timeState.timeUnit = Integer.parseInt(nodeText);
                break;
        }
    }
    return timeState;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 87 with Elements

use of electric.xml.Elements in project blue by kunstmusik.

the class Tempo method loadFromXML.

public static Tempo loadFromXML(Element data) {
    Tempo retVal = new Tempo();
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        switch(nodeName) {
            case "enabled":
                retVal.enabled = Boolean.valueOf(node.getTextString()).booleanValue();
                break;
            case "visible":
                retVal.visible = Boolean.valueOf(node.getTextString()).booleanValue();
                break;
            case "line":
                retVal.line = Line.loadFromXML(node);
                break;
        }
    }
    return retVal;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 88 with Elements

use of electric.xml.Elements in project blue by kunstmusik.

the class SoundLayer method loadFromXML.

public static SoundLayer loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
    SoundLayer sLayer = new SoundLayer();
    sLayer.setName(data.getAttributeValue("name"));
    sLayer.setMuted(Boolean.valueOf(data.getAttributeValue("muted")).booleanValue());
    sLayer.setSolo(Boolean.valueOf(data.getAttributeValue("solo")).booleanValue());
    String heightIndexStr = data.getAttributeValue("heightIndex");
    if (heightIndexStr != null) {
        sLayer.setHeightIndex(Integer.parseInt(heightIndexStr));
    }
    Element npcNode = data.getElement("noteProcessorChain");
    if (npcNode != null) {
        sLayer.setNoteProcessorChain(NoteProcessorChain.loadFromXML(npcNode));
    }
    Elements sObjects = data.getElements("soundObject");
    while (sObjects.hasMoreElements()) {
        Object obj = ObjectUtilities.loadFromXML(sObjects.next(), objRefMap);
        sLayer.add((SoundObject) obj);
    }
    Elements parameters = data.getElements("parameterId");
    while (parameters.hasMoreElements()) {
        String id = parameters.next().getTextString();
        sLayer.automationParameters.addParameterId(id);
    }
    return sLayer;
}
Also used : Element(electric.xml.Element) SoundObject(blue.soundObject.SoundObject) ScoreObject(blue.score.ScoreObject) Elements(electric.xml.Elements)

Example 89 with Elements

use of electric.xml.Elements in project blue by kunstmusik.

the class LiveData method loadFromXML.

public static LiveData loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
    LiveData liveData = new LiveData();
    Elements nodes = data.getElements();
    boolean doCommandLineUpgrade = true;
    ArrayList<LiveObject> oldFormat = new ArrayList<>();
    Element liveObjectSetsNode = null;
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String name = node.getName();
        switch(name) {
            case "commandLine":
                liveData.setCommandLine(node.getTextString());
                break;
            case "commandLineEnabled":
                liveData.setCommandLineEnabled(XMLUtilities.readBoolean(node));
                doCommandLineUpgrade = false;
                break;
            case "commandLineOverride":
                liveData.setCommandLineOverride(XMLUtilities.readBoolean(node));
                doCommandLineUpgrade = false;
                break;
            case "soundObject":
                SoundObject sObj = (SoundObject) ObjectUtilities.loadFromXML(node, objRefMap);
                LiveObject lObj = new LiveObject();
                lObj.setSObj(sObj);
                oldFormat.add(lObj);
                break;
            case "liveObject":
                oldFormat.add(LiveObject.loadFromXML(node, objRefMap));
                break;
            case "liveObjectBins":
                liveData.liveObjectBins = LiveObjectBins.loadFromXML(node, objRefMap);
                break;
            case "repeat":
                liveData.repeat = XMLUtilities.readInt(node);
                break;
            case "tempo":
                liveData.tempo = XMLUtilities.readInt(node);
                break;
            case "liveObjectSetList":
                liveObjectSetsNode = node;
                break;
            case "repeatEnabled":
                liveData.setRepeatEnabled(XMLUtilities.readBoolean(node));
                break;
            case "liveCodeText":
                liveData.setLiveCodeText(node.getTextString());
                break;
        }
    }
    if (oldFormat.size() > 0) {
        LiveObject[][] liveObjectBins = new LiveObject[1][oldFormat.size()];
        for (int i = 0; i < oldFormat.size(); i++) {
            liveObjectBins[0][i] = oldFormat.get(i);
        }
        liveData.liveObjectBins = new LiveObjectBins(liveObjectBins);
    }
    if (doCommandLineUpgrade) {
        liveData.setCommandLineEnabled(true);
        liveData.setCommandLineOverride(true);
    }
    if (liveObjectSetsNode != null) {
        liveData.liveObjectSets = LiveObjectSetList.loadFromXML(liveObjectSetsNode, liveData.liveObjectBins);
    }
    return liveData;
}
Also used : SoundObject(blue.soundObject.SoundObject) LiveObjectBins(blue.blueLive.LiveObjectBins) Element(electric.xml.Element) ArrayList(java.util.ArrayList) Elements(electric.xml.Elements) LiveObject(blue.blueLive.LiveObject)

Example 90 with Elements

use of electric.xml.Elements in project blue by kunstmusik.

the class Arrangement method loadFromXML.

// NEW SAVING AND LOADING METHODS
public static Arrangement loadFromXML(Element data) throws Exception {
    Arrangement arr = new Arrangement();
    Elements items = data.getElements("instrumentAssignment");
    while (items.hasMoreElements()) {
        Element elem = items.next();
        InstrumentAssignment ia = InstrumentAssignment.loadFromXML(elem);
        arr.getArrangement().add(ia);
    }
    return arr;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Aggregations

Elements (electric.xml.Elements)131 Element (electric.xml.Element)120 Document (electric.xml.Document)12 BigDecimal (java.math.BigDecimal)10 Vector (java.util.Vector)10 File (java.io.File)4 SoundObject (blue.soundObject.SoundObject)3 EffectOption (blue.tools.blueShare.effects.EffectOption)3 InstrumentOption (blue.tools.blueShare.instruments.InstrumentOption)3 SoundObjectOption (blue.tools.blueShare.soundObjects.SoundObjectOption)3 OpcodeList (blue.udo.OpcodeList)3 ParseException (electric.xml.ParseException)3 ArrayList (java.util.ArrayList)3 ParameterList (blue.automation.ParameterList)2 Line (blue.components.lines.Line)2 Color (java.awt.Color)2 IOException (java.io.IOException)2 Font (javafx.scene.text.Font)2 LiveObject (blue.blueLive.LiveObject)1 LiveObjectBins (blue.blueLive.LiveObjectBins)1