Search in sources :

Example 1 with Attribute

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

the class UpgradeManager method performUpgrades.

public void performUpgrades(Element element) {
    Attribute versionAttribute = element.getAttribute("version");
    String versionString = "0.0.0";
    if (versionAttribute != null) {
        versionString = versionAttribute.getValue();
    }
    ProjectVersion version = ProjectVersion.parseVersion(versionString);
    for (ProjectUpgrader upgrader : upgraders) {
        if (version.lessThan(upgrader.getVersion())) {
            if (upgrader.performUpgrade(element)) {
                logger.info(String.format("Performed Upgrade for Version '%s'", upgrader.getVersion()));
            }
        }
    }
}
Also used : Attribute(electric.xml.Attribute)

Example 2 with Attribute

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

the class BlueData method loadFromXML.

public static BlueData loadFromXML(Element data) throws Exception {
    UpgradeManager.getInstance().performUpgrades(data);
    BlueData blueData = new BlueData();
    Map<String, Object> objRefMap = new HashMap<>();
    Elements nodes = data.getElements();
    Element instrumentLibraryNode = null;
    Element arrangementNode = null;
    Mixer m = null;
    Attribute versionAttribute = data.getAttribute("version");
    if (versionAttribute != null) {
        blueData.setVersion(versionAttribute.getValue());
    }
    BlueDataObjectManager bdoManager = Lookup.getDefault().lookup(BlueDataObjectManager.class);
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        switch(nodeName) {
            case "projectProperties":
                blueData.projectProperties = ProjectProperties.loadFromXML(node);
                break;
            case "instrumentLibrary":
                instrumentLibraryNode = node;
                break;
            case "arrangement":
                arrangementNode = node;
                break;
            case "mixer":
                m = Mixer.loadFromXML(node);
                break;
            case "tables":
                blueData.tableSet = Tables.loadFromXML(node);
                break;
            case "soundObjectLibrary":
                blueData.sObjLib = SoundObjectLibrary.loadFromXML(node, objRefMap);
                break;
            case "globalOrcSco":
                blueData.globalOrcSco = GlobalOrcSco.loadFromXML(node);
                break;
            case "udo":
                {
                    // blueData.setUserDefinedOpcodes(node.getTextString());
                    String udoText = node.getTextString();
                    if (udoText == null) {
                        udoText = "";
                    }
                    OpcodeList results = UDOUtilities.parseUDOText(udoText);
                    blueData.setOpcodeList(results);
                    break;
                }
            case "opcodeList":
                {
                    OpcodeList results = OpcodeList.loadFromXML(node);
                    blueData.setOpcodeList(results);
                    break;
                }
            case "liveData":
                blueData.liveData = LiveData.loadFromXML(node, objRefMap);
                break;
            case "score":
                blueData.score = Score.loadFromXML(node, objRefMap);
                break;
            case "scratchPadData":
                blueData.scratchData = ScratchPadData.loadFromXML(node);
                break;
            case "noteProcessorChainMap":
                blueData.noteProcessorChainMap = NoteProcessorChainMap.loadFromXML(node);
                break;
            case "renderStartTime":
                blueData.setRenderStartTime(Double.parseDouble(node.getTextString()));
                break;
            case "renderEndTime":
                blueData.setRenderEndTime(Double.parseDouble(node.getTextString()));
                break;
            case "markersList":
                blueData.setMarkersList(MarkersList.loadFromXML(node));
                break;
            case "loopRendering":
                blueData.setLoopRendering(node.getTextString().equalsIgnoreCase("true"));
                break;
            case "midiInputProcessor":
                blueData.midiInputProcessor = MidiInputProcessor.loadFromXML(node);
                break;
            case "pluginData":
                Elements pluginElems = node.getElements();
                while (pluginElems.hasMoreElements()) {
                    blueData.pluginData.add(bdoManager.loadFromXML(pluginElems.next()));
                }
                break;
        }
    }
    if (instrumentLibraryNode != null) {
        InstrumentLibrary instrumentLibrary = InstrumentLibrary.loadFromXML(instrumentLibraryNode);
        blueData.arrangement = Arrangement.loadFromXML(arrangementNode, instrumentLibrary);
    } else {
        blueData.arrangement = Arrangement.loadFromXML(arrangementNode);
    }
    if (m != null) {
        blueData.mixer = m;
    } else {
        blueData.mixer.setEnabled(false);
    }
    return blueData;
}
Also used : BlueDataObjectManager(blue.data.BlueDataObjectManager) Attribute(electric.xml.Attribute) OpcodeList(blue.udo.OpcodeList) Element(electric.xml.Element) Mixer(blue.mixer.Mixer) Elements(electric.xml.Elements)

Aggregations

Attribute (electric.xml.Attribute)2 BlueDataObjectManager (blue.data.BlueDataObjectManager)1 Mixer (blue.mixer.Mixer)1 OpcodeList (blue.udo.OpcodeList)1 Element (electric.xml.Element)1 Elements (electric.xml.Elements)1