Search in sources :

Example 1 with LiveObjectBins

use of blue.blueLive.LiveObjectBins in project blue by kunstmusik.

the class LiveDataTest method testSerialization.

public void testSerialization() {
    LiveData liveData = new LiveData();
    final LiveObjectBins liveObjectBins = liveData.getLiveObjectBins();
    liveObjectBins.setLiveObject(0, 0, new LiveObject(new GenericScore()));
    liveObjectBins.setLiveObject(0, 2, new LiveObject(new GenericScore()));
    liveObjectBins.setLiveObject(0, 4, new LiveObject(new GenericScore()));
    liveObjectBins.setLiveObject(0, 6, new LiveObject(new GenericScore()));
    Element elem1 = liveData.saveAsXML(null);
    Element elem2;
    try {
        elem2 = LiveData.loadFromXML(elem1, null).saveAsXML(null);
        System.out.println(elem1.toString() + "\n\n" + elem2.toString());
        assertEquals(elem1.toString(), elem2.toString());
    } catch (Exception ex) {
        ex.printStackTrace();
        fail("Did not load from xml");
    }
}
Also used : LiveObjectBins(blue.blueLive.LiveObjectBins) Element(electric.xml.Element) GenericScore(blue.soundObject.GenericScore) LiveObject(blue.blueLive.LiveObject)

Example 2 with LiveObjectBins

use of blue.blueLive.LiveObjectBins 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 3 with LiveObjectBins

use of blue.blueLive.LiveObjectBins in project blue by kunstmusik.

the class BlueLiveTopComponent method buttonAddActionPerformed.

// GEN-LAST:event_buttonDownActionPerformed
private void buttonAddActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_buttonAddActionPerformed
    if (data != null) {
        LiveData liveData = data.getLiveData();
        LiveObjectBins bins = liveData.getLiveObjectBins();
        LiveObjectSetList sets = liveData.getLiveObjectSets();
        LiveObjectSet set = bins.getEnabledLiveObjectSet();
        if (set != null && set.size() > 0) {
            setModel.addLiveObjectSet(set);
        }
    }
}
Also used : LiveObjectSetList(blue.blueLive.LiveObjectSetList) LiveObjectBins(blue.blueLive.LiveObjectBins) LiveObjectSet(blue.blueLive.LiveObjectSet)

Aggregations

LiveObjectBins (blue.blueLive.LiveObjectBins)3 LiveObject (blue.blueLive.LiveObject)2 Element (electric.xml.Element)2 LiveObjectSet (blue.blueLive.LiveObjectSet)1 LiveObjectSetList (blue.blueLive.LiveObjectSetList)1 GenericScore (blue.soundObject.GenericScore)1 SoundObject (blue.soundObject.SoundObject)1 Elements (electric.xml.Elements)1 ArrayList (java.util.ArrayList)1