Search in sources :

Example 26 with Element

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

the class BSBXYController method saveAsXML.

@Override
public Element saveAsXML() {
    Element retVal = super.getBasicXML(this);
    retVal.setAttribute("version", "2");
    retVal.addElement("width").setText(Integer.toString(getWidth()));
    retVal.addElement("height").setText(Integer.toString(getHeight()));
    retVal.addElement("xMin").setText(Double.toString(xValue.getMin()));
    retVal.addElement("xMax").setText(Double.toString(xValue.getMax()));
    retVal.addElement("yMin").setText(Double.toString(yValue.getMin()));
    retVal.addElement("yMax").setText(Double.toString(yValue.getMax()));
    retVal.addElement("xValue").setText(Double.toString(xValue.getValue()));
    retVal.addElement("yValue").setText(Double.toString(yValue.getValue()));
    retVal.addElement(XMLUtilities.writeBoolean("randomizable", isRandomizable()));
    retVal.addElement(XMLUtilities.writeBoolean("valueDisplayEnabled", isValueDisplayEnabled()));
    return retVal;
}
Also used : Element(electric.xml.Element)

Example 27 with Element

use of electric.xml.Element 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)

Example 28 with Element

use of electric.xml.Element 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 29 with Element

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

the class Preset method saveAsXML.

public Element saveAsXML() {
    Element retVal = new Element("preset");
    retVal.setAttribute("name", presetName);
    retVal.setAttribute("uniqueId", uniqueId);
    String[] keys = valuesMap.keySet().toArray(new String[0]);
    Arrays.sort(keys);
    for (String key : keys) {
        String val = valuesMap.get(key);
        retVal.addElement("setting").setAttribute("name", key).setText(val);
    }
    return retVal;
}
Also used : Element(electric.xml.Element)

Example 30 with Element

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

the class BSBFileSelector method saveAsXML.

@Override
public Element saveAsXML() {
    Element retVal = getBasicXML(this);
    retVal.addElement("fileName").setText(getFileName());
    retVal.addElement("textFieldWidth").setText(Integer.toString(getTextFieldWidth()));
    retVal.addElement(XMLUtilities.writeBoolean("stringChannelEnabled", isStringChannelEnabled()));
    return retVal;
}
Also used : Element(electric.xml.Element)

Aggregations

Element (electric.xml.Element)310 Elements (electric.xml.Elements)120 Document (electric.xml.Document)22 Vector (java.util.Vector)14 Iterator (java.util.Iterator)12 File (java.io.File)10 BigDecimal (java.math.BigDecimal)10 IOException (java.io.IOException)8 SoundObject (blue.soundObject.SoundObject)7 ParseException (electric.xml.ParseException)7 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 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 Test (org.junit.Test)3 ParameterList (blue.automation.ParameterList)2 LiveObject (blue.blueLive.LiveObject)2 LiveObjectBins (blue.blueLive.LiveObjectBins)2 Line (blue.components.lines.Line)2