Search in sources :

Example 21 with Elements

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

the class BSBTextField method loadFromXML.

public static BSBObject loadFromXML(Element data) {
    BSBTextField bsbText = new BSBTextField();
    initBasicFromXML(data, bsbText);
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        switch(node.getName()) {
            case "value":
                bsbText.setValue(node.getTextString());
                if (bsbText.getValue() == null) {
                    bsbText.setValue("");
                }
                break;
            case "textFieldWidth":
                bsbText.setTextFieldWidth(Integer.parseInt(node.getTextString()));
                break;
        }
    }
    return bsbText;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 22 with Elements

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

the class BSBVSlider method loadFromXML.

public static BSBObject loadFromXML(Element data) {
    BSBVSlider slider = new BSBVSlider();
    double minVal = 0.0;
    double maxVal = 1.0;
    double val = 0.0;
    BigDecimal res = new BigDecimal("0.1");
    initBasicFromXML(data, slider);
    String verString = data.getAttributeValue("version");
    int version = (verString == null) ? 1 : Integer.parseInt(verString);
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        final String nodeText = node.getTextString();
        switch(nodeName) {
            case "minimum":
                minVal = parseNum(nodeText, version);
                break;
            case "maximum":
                maxVal = parseNum(nodeText, version);
                break;
            case "resolution":
                res = new BigDecimal(Double.parseDouble(nodeText)).setScale(5, RoundingMode.HALF_UP).stripTrailingZeros();
                break;
            case "bdresolution":
                res = new BigDecimal(nodeText);
                break;
            case "value":
                val = Double.parseDouble(nodeText);
                break;
            case "sliderHeight":
                slider.setSliderHeight(Integer.parseInt(node.getTextString()));
                break;
            case "randomizable":
                slider.setRandomizable(XMLUtilities.readBoolean(node));
                break;
            case "valueDisplayEnabled":
                slider.setValueDisplayEnabled(XMLUtilities.readBoolean(node));
                break;
        }
    }
    slider.setValueProperty(new ClampedValue(minVal, maxVal, val, res));
    return slider;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements) BigDecimal(java.math.BigDecimal)

Example 23 with Elements

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

the class NoteProcessorChainMap method loadFromXML.

public static NoteProcessorChainMap loadFromXML(Element data) throws Exception {
    NoteProcessorChainMap map = new NoteProcessorChainMap();
    Elements npcNodes = data.getElements("npc");
    while (npcNodes.hasMoreElements()) {
        Element elem = npcNodes.next();
        String name = elem.getAttributeValue("name");
        NoteProcessorChain npc = NoteProcessorChain.loadFromXML(elem.getElement("noteProcessorChain"));
        map.put(name, npc);
    }
    return map;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 24 with Elements

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

the class RandomAddProcessor method loadFromXML.

public static NoteProcessor loadFromXML(Element data) {
    RandomAddProcessor rap = new RandomAddProcessor();
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        switch(node.getName()) {
            case "pfield":
                rap.setPfield(node.getTextString());
                break;
            case "min":
                rap.setMin(node.getTextString());
                break;
            case "max":
                rap.setMax(node.getTextString());
                break;
            case "seedUsed":
                rap.setSeedUsed(node.getTextString());
                break;
            case "seed":
                rap.setSeed(node.getTextString());
                break;
        }
    }
    return rap;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 25 with Elements

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

the class BSBHSliderBank method loadFromXML.

public static BSBObject loadFromXML(Element data) {
    BSBHSliderBank sliderBank = new BSBHSliderBank();
    double minVal = 0;
    double maxVal = 1.0;
    BigDecimal resolution = new BigDecimal("0.1");
    initBasicFromXML(data, sliderBank);
    Elements nodes = data.getElements();
    sliderBank.getSliders().clear();
    List<BSBHSlider> childSliders = new ArrayList<>();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        switch(nodeName) {
            case "minimum":
                minVal = Double.parseDouble(node.getTextString());
                break;
            case "maximum":
                maxVal = Double.parseDouble(node.getTextString());
                break;
            case "resolution":
                resolution = new BigDecimal(Double.parseDouble(node.getTextString())).setScale(5, RoundingMode.HALF_UP).stripTrailingZeros();
                break;
            case "bdresolution":
                resolution = new BigDecimal(node.getTextString());
                break;
            case "sliderWidth":
                sliderBank.setSliderWidth(Integer.parseInt(node.getTextString()));
                break;
            case "gap":
                sliderBank.setGap(Integer.parseInt(node.getTextString()));
                break;
            case "randomizable":
                sliderBank.setRandomizable(XMLUtilities.readBoolean(node));
                break;
            case "valueDisplayEnabled":
                sliderBank.setValueDisplayEnabled(XMLUtilities.readBoolean(node));
                break;
            case "bsbObject":
                BSBHSlider hSlider = (BSBHSlider) BSBHSlider.loadFromXML(node);
                childSliders.add(hSlider);
                break;
        }
    }
    sliderBank.setValueProperty(new ClampedValue(minVal, maxVal, 0.0, resolution));
    sliderBank.getSliders().addAll(childSliders);
    return sliderBank;
}
Also used : Element(electric.xml.Element) ArrayList(java.util.ArrayList) Elements(electric.xml.Elements) BigDecimal(java.math.BigDecimal)

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