Search in sources :

Example 81 with Elements

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

the class Script method loadFromXML.

public static Script loadFromXML(Element data) {
    Script script = new Script();
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        switch(nodeName) {
            case "name":
                script.setName(node.getTextString());
                break;
            case "description":
                script.setDescription(node.getTextString());
                break;
            case "code":
                script.setCode(node.getTextString());
                break;
            case "comments":
                script.setComments(node.getTextString());
                break;
        }
    }
    return script;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 82 with Elements

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

the class PolyObject method loadFromXML.

/*
     * (non-Javadoc)
     * 
     * @see blue.soundObject.SoundObject#loadFromXML(electric.xml.Element)
     */
public static PolyObject loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
    PolyObject pObj = new PolyObject();
    SoundObjectUtilities.initBasicFromXML(data, pObj);
    Elements nodes = data.getElements();
    int heightIndex = -1;
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        switch(nodeName) {
            case "heightIndex":
                {
                    int index = Integer.parseInt(node.getTextString());
                    // checking if using old heightIndex values
                    String val = node.getAttributeValue("version");
                    if (val == null || val.length() == 0) {
                        index = index - 1;
                        index = index < 0 ? 0 : index;
                    }
                    heightIndex = index;
                    break;
                }
            case "defaultHeightIndex":
                {
                    int index = Integer.parseInt(node.getTextString());
                    pObj.setDefaultHeightIndex(index);
                    break;
                }
            case "soundLayer":
                pObj.add(SoundLayer.loadFromXML(node, objRefMap));
                break;
            case "timeState":
                pObj.timeState = TimeState.loadFromXML(node);
                break;
        }
    }
    if (heightIndex >= 0) {
        for (int i = 0; i < pObj.size(); i++) {
            SoundLayer layer = pObj.get(i);
            layer.setHeightIndex(heightIndex);
        }
        pObj.setDefaultHeightIndex(heightIndex);
    }
    return pObj;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 83 with Elements

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

the class BSBVSliderBank method loadFromXML.

public static BSBObject loadFromXML(Element data) {
    BSBVSliderBank sliderBank = new BSBVSliderBank();
    double minVal = 0;
    double maxVal = 1.0;
    BigDecimal resolution = new BigDecimal("0.1");
    initBasicFromXML(data, sliderBank);
    Elements nodes = data.getElements();
    sliderBank.getSliders().clear();
    List<BSBVSlider> 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 "sliderHeight":
                sliderBank.setSliderHeight(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":
                BSBVSlider hSlider = (BSBVSlider) BSBVSlider.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)

Example 84 with Elements

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

the class GridSettings method loadFromXML.

public static GridSettings loadFromXML(Element data) throws Exception {
    GridSettings gridSettings = new GridSettings();
    Elements giNodes = data.getElements();
    while (giNodes.hasMoreElements()) {
        Element node = giNodes.next();
        String name = node.getName();
        switch(name) {
            case "width":
                gridSettings.setWidth(XMLUtilities.readInt(node));
                break;
            case "height":
                gridSettings.setHeight(XMLUtilities.readInt(node));
                break;
            case "gridStyle":
                gridSettings.setGridStyle(GridStyle.valueOf(node.getTextString()));
                break;
            case "snapGridEnabled":
                gridSettings.setSnapEnabled(XMLUtilities.readBoolean(node));
                break;
        }
    }
    return gridSettings;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 85 with Elements

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

the class Score method loadFromXML.

public static Score loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
    Score score = new Score(false);
    Elements nodes = data.getElements();
    LayerGroupProviderManager manager = LayerGroupProviderManager.getInstance();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        switch(node.getName()) {
            case "tempo":
                score.tempo = Tempo.loadFromXML(node);
                break;
            case "timeState":
                score.timeState = TimeState.loadFromXML(node);
                break;
            case "noteProcessorChain":
                score.npc = NoteProcessorChain.loadFromXML(node);
                break;
            default:
                LayerGroup layerGroup = manager.loadFromXML(node, objRefMap);
                if (layerGroup == null) {
                    throw new RuntimeException("Unable to load Score LayerGroup of type: " + node.getName());
                }
                score.add(layerGroup);
                if (layerGroup instanceof PolyObject) {
                    ((PolyObject) layerGroup).setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
                }
                break;
        }
    }
    if (score.size() == 0) {
        PolyObject pObj = new PolyObject(true);
        score.add(pObj);
    }
    return score;
}
Also used : Element(electric.xml.Element) LayerGroup(blue.score.layers.LayerGroup) Elements(electric.xml.Elements) PolyObject(blue.soundObject.PolyObject) LayerGroupProviderManager(blue.score.layers.LayerGroupProviderManager)

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