Search in sources :

Example 51 with Elements

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

the class LiveObjectSetList method loadFromXML.

public static LiveObjectSetList loadFromXML(Element data, LiveObjectBins liveObjectBins) {
    LiveObjectSetList retVal = new LiveObjectSetList();
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String name = node.getName();
        if (name.equals("liveObjectSet")) {
            retVal.add(LiveObjectSet.loadFromXML(node, liveObjectBins));
        }
    }
    return retVal;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 52 with Elements

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

the class LiveObjectSet method loadFromXML.

public static LiveObjectSet loadFromXML(Element data, LiveObjectBins bins) {
    LiveObjectSet retVal = new LiveObjectSet();
    String val = data.getAttributeValue("name");
    if (val != null && val.length() > 0) {
        retVal.name = val;
    }
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        if (nodeName.equals("liveObjectRef")) {
            String uniqueId = node.getTextString();
            LiveObject lObj = bins.getLiveObjectByUniqueId(uniqueId);
            if (lObj != null) {
                retVal.add(lObj);
            }
        }
    }
    return retVal;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 53 with Elements

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

the class Line method loadFromXML.

public static Line loadFromXML(Element data) {
    Line line = new Line(false, false);
    switch(data.getName()) {
        case "line":
            line.varName = data.getAttributeValue("name");
            line.setZak(false);
            break;
        case "zakline":
            line.channel = Integer.parseInt(data.getAttributeValue("channel"));
            line.setZak(true);
            break;
    }
    int version = 1;
    String versionStr = data.getAttributeValue("version");
    if (versionStr != null) {
        version = Integer.parseInt(versionStr);
    }
    line.max = Double.parseDouble(data.getAttributeValue("max"));
    line.min = Double.parseDouble(data.getAttributeValue("min"));
    if (data.getAttributeValue("resolution") != null) {
        line.resolution = new BigDecimal(Double.parseDouble(data.getAttributeValue("resolution"))).setScale(5, RoundingMode.HALF_UP).stripTrailingZeros();
    }
    if (data.getAttributeValue("bdresolution") != null) {
        line.resolution = new BigDecimal(data.getAttributeValue("bdresolution"));
    }
    String colorStr = data.getAttributeValue("color");
    if (colorStr != null && colorStr.length() > 0) {
        line.color = new Color(Integer.parseInt(colorStr));
    } else {
        // some older project files may not have a color associated with
        // their Line objects. However, a color IS required in the
        // LineCanvas
        // implementation, so we makeup a color.
        line.color = new Color(128, 128, 128);
    }
    String rBound = data.getAttributeValue("rightBound");
    if (rBound != null && rBound.length() > 0) {
        line.rightBound = Boolean.valueOf(rBound).booleanValue();
    }
    String endLinked = data.getAttributeValue("endPointsLinked");
    if (endLinked != null && endLinked.length() > 0) {
        line.endPointsLinked = Boolean.valueOf(endLinked).booleanValue();
    }
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        LinePoint lp = LinePoint.loadFromXML(node);
        line.addLinePoint(lp);
        if (version == 1) {
            lp.setLocation(lp.getX(), migrateYValue(lp.getY(), line.max, line.min));
        }
    }
    return line;
}
Also used : Color(java.awt.Color) Element(electric.xml.Element) Elements(electric.xml.Elements) BigDecimal(java.math.BigDecimal)

Example 54 with Elements

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

the class Library method loadLibraryItem.

private static <T extends SoundObject> TreeItem<LibraryItem<T>> loadLibraryItem(Element elem, Function<Element, T> loader) {
    TreeItem<LibraryItem<T>> item;
    if (FOLDER_NAMES.contains(elem.getName())) {
        item = new LibraryTreeItem<>(new LibraryItem<>(elem.getAttributeValue("categoryName")));
        Elements children = elem.getElements();
        while (children.hasMoreElements()) {
            item.getChildren().add(loadLibraryItem(children.next(), loader));
        }
    } else {
        item = new LibraryTreeItem<>(new LibraryItem<>(loader.apply(elem)));
    }
    return item;
}
Also used : Elements(electric.xml.Elements)

Example 55 with Elements

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

the class ChannelList method loadFromXML.

public static ChannelList loadFromXML(Element data) throws Exception {
    ChannelList channels = new ChannelList();
    Elements nodes = data.getElements();
    String associationVal = data.getAttributeValue("association");
    if (associationVal != null && !"null".equals(associationVal)) {
        channels.setAssociation(data.getAttributeValue("association"));
    }
    String listName = data.getAttributeValue("listName");
    if (listName != null && !"null".equals(listName)) {
        channels.setListName(listName);
    }
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        if (nodeName.equals("channel")) {
            channels.add(Channel.loadFromXML(node));
        }
    }
    return channels;
}
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