use of electric.xml.Elements in project blue by kunstmusik.
the class BSBHSlider method loadFromXML.
public static BSBObject loadFromXML(Element data) {
BSBHSlider slider = new BSBHSlider();
double minVal = 0.0;
double maxVal = 1.0;
double val = 0.0;
BigDecimal res = new BigDecimal("0.1");
initBasicFromXML(data, slider);
String verString = data.getAttributeValue("version");
int version = (verString == null) ? 1 : Integer.parseInt(verString);
Elements nodes = data.getElements();
while (nodes.hasMoreElements()) {
Element node = nodes.next();
String nodeName = node.getName();
final String nodeText = node.getTextString();
switch(nodeName) {
case "minimum":
minVal = Double.parseDouble(nodeText);
break;
case "maximum":
maxVal = Double.parseDouble(nodeText);
break;
case "resolution":
res = new BigDecimal(Double.parseDouble(nodeText)).setScale(5, RoundingMode.HALF_UP).stripTrailingZeros();
break;
case "bdresolution":
res = new BigDecimal(nodeText);
break;
case "value":
val = Double.parseDouble(nodeText);
break;
case "sliderWidth":
slider.setSliderWidth(Integer.parseInt(nodeText));
break;
case "randomizable":
slider.setRandomizable(XMLUtilities.readBoolean(node));
break;
case "valueDisplayEnabled":
slider.setValueDisplayEnabled(XMLUtilities.readBoolean(node));
break;
}
}
slider.setValueProperty(new ClampedValue(minVal, maxVal, val, res));
return slider;
}
use of electric.xml.Elements in project blue by kunstmusik.
the class InstrumentCategory method loadFromXML.
public static InstrumentCategory loadFromXML(Element data) throws Exception {
InstrumentCategory instrCat = new InstrumentCategory();
instrCat.setCategoryName(data.getAttributeValue("categoryName"));
instrCat.setRoot(Boolean.valueOf(data.getAttributeValue("isRoot")).booleanValue());
Elements subCatNodes = data.getElements("instrumentCategory");
while (subCatNodes.hasMoreElements()) {
instrCat.addInstrumentCategory(InstrumentCategory.loadFromXML(subCatNodes.next()));
}
Elements instruments = data.getElements("instrument");
while (instruments.hasMoreElements()) {
instrCat.addInstrument((Instrument) ObjectUtilities.loadFromXML(instruments.next()));
}
return instrCat;
}
use of electric.xml.Elements in project blue by kunstmusik.
the class BSBDropdownItem method loadFromXML.
public static BSBDropdownItem loadFromXML(Element data) {
BSBDropdownItem item = new BSBDropdownItem();
String uniqueId = data.getAttributeValue("uniqueId");
if (uniqueId != null && uniqueId.length() > 0) {
item.uniqueId = uniqueId;
}
Elements nodes = data.getElements();
while (nodes.hasMoreElements()) {
Element elem = nodes.next();
String name = elem.getName();
switch(name) {
case "name":
item.setName(elem.getTextString());
break;
case "value":
item.setValue(elem.getTextString());
break;
}
}
return item;
}
use of electric.xml.Elements in project blue by kunstmusik.
the class BSBValue method loadFromXML.
public static BSBObject loadFromXML(Element data) {
BSBValue value = new BSBValue();
double minVal = 0.0;
double maxVal = 1.0;
double val = 0.0;
initBasicFromXML(data, value);
Elements nodes = data.getElements();
while (nodes.hasMoreElements()) {
Element node = nodes.next();
String nodeName = node.getName();
final String nodeText = node.getTextString();
switch(nodeName) {
case "minimum":
minVal = Double.parseDouble(nodeText);
break;
case "maximum":
maxVal = Double.parseDouble(nodeText);
break;
case "defaultValue":
val = Double.parseDouble(nodeText);
break;
}
}
value.setDefaultValueProperty(new ClampedValue(minVal, maxVal, val, new BigDecimal(-1.0)));
return value;
}
use of electric.xml.Elements 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;
}
Aggregations