Search in sources :

Example 11 with Elements

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

the class BSBHSlider method loadFromXML.

public static BSBObject loadFromXML(Element data) {
    BSBHSlider slider = new BSBHSlider();
    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 = Double.parseDouble(nodeText);
                break;
            case "maximum":
                maxVal = Double.parseDouble(nodeText);
                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 "sliderWidth":
                slider.setSliderWidth(Integer.parseInt(nodeText));
                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 12 with Elements

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

the class InstrumentCategory method loadFromXML.

public static InstrumentCategory loadFromXML(Element data) throws Exception {
    InstrumentCategory instrCat = new InstrumentCategory();
    instrCat.setCategoryName(data.getAttributeValue("categoryName"));
    instrCat.setRoot(Boolean.valueOf(data.getAttributeValue("isRoot")).booleanValue());
    Elements subCatNodes = data.getElements("instrumentCategory");
    while (subCatNodes.hasMoreElements()) {
        instrCat.addInstrumentCategory(InstrumentCategory.loadFromXML(subCatNodes.next()));
    }
    Elements instruments = data.getElements("instrument");
    while (instruments.hasMoreElements()) {
        instrCat.addInstrument((Instrument) ObjectUtilities.loadFromXML(instruments.next()));
    }
    return instrCat;
}
Also used : Elements(electric.xml.Elements)

Example 13 with Elements

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

the class BSBDropdownItem method loadFromXML.

public static BSBDropdownItem loadFromXML(Element data) {
    BSBDropdownItem item = new BSBDropdownItem();
    String uniqueId = data.getAttributeValue("uniqueId");
    if (uniqueId != null && uniqueId.length() > 0) {
        item.uniqueId = uniqueId;
    }
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element elem = nodes.next();
        String name = elem.getName();
        switch(name) {
            case "name":
                item.setName(elem.getTextString());
                break;
            case "value":
                item.setValue(elem.getTextString());
                break;
        }
    }
    return item;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 14 with Elements

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

the class BSBValue method loadFromXML.

public static BSBObject loadFromXML(Element data) {
    BSBValue value = new BSBValue();
    double minVal = 0.0;
    double maxVal = 1.0;
    double val = 0.0;
    initBasicFromXML(data, value);
    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 = Double.parseDouble(nodeText);
                break;
            case "maximum":
                maxVal = Double.parseDouble(nodeText);
                break;
            case "defaultValue":
                val = Double.parseDouble(nodeText);
                break;
        }
    }
    value.setDefaultValueProperty(new ClampedValue(minVal, maxVal, val, new BigDecimal(-1.0)));
    return value;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements) BigDecimal(java.math.BigDecimal)

Example 15 with Elements

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

the class BSBXYController method loadFromXML.

public static BSBObject loadFromXML(Element data) {
    BSBXYController xyController = new BSBXYController();
    initBasicFromXML(data, xyController);
    int version = 1;
    String versionStr = data.getAttributeValue("version");
    if (versionStr != null) {
        version = Integer.parseInt(versionStr);
    }
    double xmin = 0.0, xmax = 1.0, xval = 0.0;
    double ymin = 0.0, ymax = 1.0, yval = 0.0;
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        final String nodeText = node.getTextString();
        switch(nodeName) {
            case "width":
                xyController.setWidth(Integer.parseInt(nodeText));
                break;
            case "height":
                xyController.setHeight(Integer.parseInt(nodeText));
                break;
            case "xMin":
                xmin = Double.parseDouble(nodeText);
                break;
            case "xMax":
                xmax = Double.parseDouble(nodeText);
                break;
            case "yMin":
                ymin = Double.parseDouble(nodeText);
                break;
            case "yMax":
                ymax = Double.parseDouble(nodeText);
                break;
            case "xValue":
                xval = Double.parseDouble(nodeText);
                break;
            case "yValue":
                yval = Double.parseDouble(nodeText);
                break;
            case "randomizable":
                xyController.setRandomizable(XMLUtilities.readBoolean(node));
                break;
            case "valueDisplayEnabled":
                xyController.setValueDisplayEnabled(XMLUtilities.readBoolean(node));
                break;
        }
    }
    // convert from relative to absolute values (0.110.0)
    if (version == 1) {
        double xrange = xmax - xmin;
        xval = (xrange * xval) + xmin;
        double yrange = ymax - ymin;
        yval = (yrange * yval) + ymin;
    }
    xyController.setXValueProperty(new ClampedValue(xmin, xmax, xval, new BigDecimal(-1.0)));
    xyController.setYValueProperty(new ClampedValue(ymin, ymax, yval, new BigDecimal(-1.0)));
    return xyController;
}
Also used : Element(electric.xml.Element) 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