Search in sources :

Example 16 with Elements

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

the class Preset method loadFromXML.

public static Preset loadFromXML(Element data) {
    Preset p = new Preset();
    p.setPresetName(data.getAttributeValue("name"));
    String uniqueId = data.getAttributeValue("uniqueId");
    if (uniqueId != null && uniqueId.length() > 0) {
        p.uniqueId = uniqueId;
    }
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        if (node.getName().equals("setting")) {
            String name = node.getAttributeValue("name");
            String val = node.getTextString();
            p.addSetting(name, val);
        }
    }
    return p;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 17 with Elements

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

the class BSBFileSelector method loadFromXML.

public static BSBObject loadFromXML(Element data) {
    BSBFileSelector selector = new BSBFileSelector();
    initBasicFromXML(data, selector);
    Elements nodes = data.getElements();
    // false by default for legacy projects
    boolean stringChannelEnabled = false;
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        switch(node.getName()) {
            case "fileName":
                selector.setFileName(node.getTextString());
                break;
            case "textFieldWidth":
                selector.setTextFieldWidth(Integer.parseInt(node.getTextString()));
                break;
            case "stringChannelEnabled":
                stringChannelEnabled = XMLUtilities.readBoolean(node);
                break;
        }
    }
    selector.setStringChannelEnabled(stringChannelEnabled);
    return selector;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 18 with Elements

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

the class BSBKnob method loadFromXML.

public static BSBObject loadFromXML(Element data) {
    BSBKnob knob = new BSBKnob();
    double minVal = 0;
    double maxVal = 0;
    double value = 0;
    initBasicFromXML(data, knob);
    // set false by default when loading for backwards compatibility with
    // Blue versions < 2.7.2
    knob.setLabelEnabled(false);
    int version = 1;
    String versionStr = data.getAttributeValue("version");
    if (versionStr != null) {
        version = Integer.parseInt(versionStr);
    }
    Elements nodes = data.getElements();
    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 "value":
                value = Double.parseDouble(node.getTextString());
                break;
            case "knobWidth":
                knob.setKnobWidth(Integer.parseInt(node.getTextString()));
                break;
            case "randomizable":
                knob.setRandomizable(XMLUtilities.readBoolean(node));
                break;
            case "valueDisplayEnabled":
                knob.setValueDisplayEnabled(XMLUtilities.readBoolean(node));
                break;
            case "label":
                knob.setLabel(node.getTextString());
                break;
            case "labelEnabled":
                knob.setLabelEnabled(XMLUtilities.readBoolean(node));
                break;
            case "font":
                knob.setLabelFont(BSBFontUtil.loadFromXML(node));
                break;
        }
    }
    // convert from relative to absolute values (0.110.0)
    if (version == 1) {
        double range = maxVal - minVal;
        value = (value * range) + minVal;
    }
    knob.setKnobValueProperty(new ClampedValue(minVal, maxVal, value, new BigDecimal(-1.0)));
    return knob;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements) BigDecimal(java.math.BigDecimal)

Example 19 with Elements

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

the class BSBLineObject method loadFromXML.

public static BSBObject loadFromXML(Element data) {
    BSBLineObject lineObj = new BSBLineObject();
    initBasicFromXML(data, lineObj);
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        switch(nodeName) {
            case "canvasWidth":
                lineObj.setCanvasWidth(XMLUtilities.readInt(node));
                break;
            case "canvasHeight":
                lineObj.setCanvasHeight(XMLUtilities.readInt(node));
                break;
            case "xMax":
                lineObj.setXMax(XMLUtilities.readDouble(node));
                break;
            case "commaSeparated":
                boolean val = XMLUtilities.readBoolean(node);
                if (val) {
                    lineObj.setSeparatorType(SeparatorType.COMMA);
                }
                break;
            case "separatorType":
                lineObj.setSeparatorType(SeparatorType.fromString(node.getTextString()));
                break;
            case "relativeXValues":
                lineObj.setRelativeXValues(XMLUtilities.readBoolean(node));
                break;
            case "lines":
                lineObj.setLines(LineList.loadFromXML(node));
                break;
            case "leadingZero":
                lineObj.setLeadingZero(XMLUtilities.readBoolean(node));
                break;
            case "locked":
                lineObj.setLocked(XMLUtilities.readBoolean(node));
                break;
        }
    }
    return lineObj;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 20 with Elements

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

the class BSBSubChannelDropdown method loadFromXML.

public static BSBObject loadFromXML(Element data) {
    BSBSubChannelDropdown dropDown = new BSBSubChannelDropdown();
    initBasicFromXML(data, dropDown);
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element elem = nodes.next();
        String name = elem.getName();
        if (name.equals("channelOutput")) {
            dropDown.setChannelOutput(elem.getTextString());
        }
    }
    return dropDown;
}
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