Search in sources :

Example 76 with Element

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

the class Weibull method saveAsXML.

@Override
public Element saveAsXML() {
    Element retVal = new Element("probabilityGenerator");
    retVal.setAttribute("type", getClass().getName());
    retVal.addElement(XMLUtilities.writeDouble("s", s));
    retVal.addElement(XMLUtilities.writeDouble("t", t));
    retVal.addElement(XMLUtilities.writeBoolean("sTableEnabled", sTableEnabled));
    retVal.addElement(XMLUtilities.writeBoolean("tTableEnabled", tTableEnabled));
    Element sTableNode = sTable.saveAsXML();
    sTableNode.setAttribute("tableId", "sTable");
    Element tTableNode = tTable.saveAsXML();
    tTableNode.setAttribute("tableId", "tTable");
    retVal.addElement(sTableNode);
    retVal.addElement(tTableNode);
    return retVal;
}
Also used : Element(electric.xml.Element)

Example 77 with Element

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

the class Weibull method loadFromXML.

public static ProbabilityGenerator loadFromXML(Element data) {
    Weibull retVal = new Weibull();
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        switch(nodeName) {
            case "s":
                retVal.s = XMLUtilities.readDouble(node);
                break;
            case "t":
                retVal.t = XMLUtilities.readDouble(node);
                break;
            case "sTableEnabled":
                retVal.sTableEnabled = XMLUtilities.readBoolean(node);
                break;
            case "tTableEnabled":
                retVal.tTableEnabled = XMLUtilities.readBoolean(node);
                break;
            case "table":
                String tableId = node.getAttributeValue("tableId");
                switch(tableId) {
                    case "sTable":
                        retVal.sTable = Table.loadFromXML(node);
                        break;
                    case "tTable":
                        retVal.tTable = Table.loadFromXML(node);
                        break;
                }
                break;
        }
    }
    return retVal;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 78 with Element

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

the class LiveObjectTest method testSerialization.

/**
 * Test of getSoundObject method, of class blue.blueLive.LiveObject.
 */
public void testSerialization() {
    LiveObject liveObj = new LiveObject();
    liveObj.setSObj(new GenericScore());
    Element elem1 = liveObj.saveAsXML(null);
    Element elem2;
    try {
        elem2 = liveObj.loadFromXML(elem1, null).saveAsXML(null);
        assertEquals(elem1.toString(), elem2.toString());
    } catch (Exception ex) {
        ex.printStackTrace();
        fail("Did not load from xml");
    }
}
Also used : Element(electric.xml.Element) GenericScore(blue.soundObject.GenericScore)

Example 79 with Element

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

the class ProjectUpgrader_2_3_0 method upgradeTempo.

protected boolean upgradeTempo(Element data) {
    Element element = data.getElement("soundObject");
    Element tempoNode = data.getElement("tempo");
    if (element == null && tempoNode == null) {
        return false;
    }
    Element score = data.addElement("score");
    if (element != null) {
        Element elem = data.removeElement("soundObject");
        TimeState timeState = TimeState.loadFromXML(elem);
        score.addElement(timeState.saveAsXML());
        score.addElement((Element) elem.clone());
    }
    if (tempoNode != null) {
        Element elem = data.removeElement("tempo");
        score.addElement((Element) elem.clone());
    }
    return true;
}
Also used : Element(electric.xml.Element) TimeState(blue.score.TimeState)

Example 80 with Element

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

the class JMask method loadFromXML.

public static SoundObject loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
    JMask jmask = new JMask();
    SoundObjectUtilities.initBasicFromXML(data, jmask);
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        switch(nodeName) {
            case "field":
                jmask.setField(Field.loadFromXML(node));
                break;
            case "seed":
                jmask.setSeed(Long.parseLong(node.getTextString()));
                break;
            case "seedUsed":
                jmask.setSeedUsed(Boolean.parseBoolean(node.getTextString()));
                break;
        }
    }
    return jmask;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Aggregations

Element (electric.xml.Element)310 Elements (electric.xml.Elements)120 Document (electric.xml.Document)22 Vector (java.util.Vector)14 Iterator (java.util.Iterator)12 File (java.io.File)10 BigDecimal (java.math.BigDecimal)10 IOException (java.io.IOException)8 SoundObject (blue.soundObject.SoundObject)7 ParseException (electric.xml.ParseException)7 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 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 Test (org.junit.Test)3 ParameterList (blue.automation.ParameterList)2 LiveObject (blue.blueLive.LiveObject)2 LiveObjectBins (blue.blueLive.LiveObjectBins)2 Line (blue.components.lines.Line)2