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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations