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