Search in sources :

Example 31 with Element

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

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

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

the class BSBLineObject method saveAsXML.

@Override
public Element saveAsXML() {
    Element retVal = getBasicXML(this);
    retVal.addElement(XMLUtilities.writeInt("canvasWidth", getCanvasWidth()));
    retVal.addElement(XMLUtilities.writeInt("canvasHeight", getCanvasHeight()));
    retVal.addElement(XMLUtilities.writeDouble("xMax", getXMax()));
    retVal.addElement(XMLUtilities.writeBoolean("relativeXValues", isRelativeXValues()));
    retVal.addElement("separatorType").setText(getSeparatorType().name());
    retVal.addElement(XMLUtilities.writeBoolean("leadingZero", isLeadingZero()));
    retVal.addElement(XMLUtilities.writeBoolean("locked", isLocked()));
    retVal.addElement(lines.saveAsXML());
    return retVal;
}
Also used : Element(electric.xml.Element)

Example 34 with Element

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

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

the class BSBObject method getBasicXML.

public static Element getBasicXML(BSBObject bsbObj) {
    Element retVal = new Element("bsbObject");
    retVal.setAttribute("type", bsbObj.getClass().getName());
    retVal.addElement("objectName").setText(bsbObj.getObjectName());
    retVal.addElement("x").setText(Integer.toString(bsbObj.getX()));
    retVal.addElement("y").setText(Integer.toString(bsbObj.getY()));
    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