use of electric.xml.Element in project blue by kunstmusik.
the class BSBCheckBox method saveAsXML.
@Override
public Element saveAsXML() {
Element retVal = getBasicXML(this);
retVal.addElement("label").setText(getLabel());
retVal.addElement("selected").setText(Boolean.toString(isSelected()));
retVal.addElement(XMLUtilities.writeBoolean("randomizable", isRandomizable()));
return retVal;
}
use of electric.xml.Element in project blue by kunstmusik.
the class BSBCheckBox method loadFromXML.
public static BSBObject loadFromXML(Element data) {
BSBCheckBox checkBox = new BSBCheckBox();
initBasicFromXML(data, checkBox);
Elements nodes = data.getElements();
while (nodes.hasMoreElements()) {
Element node = nodes.next();
String nodeName = node.getName();
switch(nodeName) {
case "label":
checkBox.setLabel(node.getTextString());
break;
case "selected":
checkBox.setSelected(node.getTextString().equals("true"));
break;
case "randomizable":
checkBox.setRandomizable(XMLUtilities.readBoolean(node));
break;
}
}
return checkBox;
}
use of electric.xml.Element in project blue by kunstmusik.
the class BSBDropdownItemList method loadFromXML.
public static BSBDropdownItemList loadFromXML(Element data) {
BSBDropdownItemList list = new BSBDropdownItemList();
Elements nodes = data.getElements();
while (nodes.hasMoreElements()) {
Element elem = nodes.next();
String name = elem.getName();
if (name.equals("bsbDropdownItem")) {
list.add(BSBDropdownItem.loadFromXML(elem));
}
}
return list;
}
use of electric.xml.Element in project blue by kunstmusik.
the class BSBGraphicInterface method loadFromXML.
public static BSBGraphicInterface loadFromXML(Element data) throws Exception {
BSBGraphicInterface graphicInterface = new BSBGraphicInterface();
Elements giNodes = data.getElements();
String editEnabledStr = data.getAttributeValue("editEnabled");
if (editEnabledStr != null) {
graphicInterface.setEditEnabled(Boolean.valueOf(editEnabledStr).booleanValue());
}
GridSettings gridSettings = null;
while (giNodes.hasMoreElements()) {
Element node = giNodes.next();
String name = node.getName();
switch(name) {
case "bsbObject":
BSBObject obj = (BSBObject) ObjectUtilities.loadFromXML(node);
if (obj instanceof BSBGroup) {
graphicInterface.setRootGroup((BSBGroup) obj);
} else {
// legacy reading of BSBObjects stored here pre-2.7.0
graphicInterface.getRootGroup().addBSBObject(obj);
}
break;
case "gridSettings":
gridSettings = GridSettings.loadFromXML(node);
break;
}
}
if (gridSettings == null) {
// preserve behavior of older projects (before 2.5.8)
graphicInterface.getGridSettings().setGridStyle(GridStyle.NONE);
graphicInterface.getGridSettings().setSnapEnabled(false);
} else {
graphicInterface.setGridSettings(gridSettings);
}
return graphicInterface;
}
use of electric.xml.Element in project blue by kunstmusik.
the class BSBGroup method loadFromXML.
public static BSBGroup loadFromXML(Element data) throws Exception {
BSBGroup bsbGroup = new BSBGroup();
initBasicFromXML(data, bsbGroup);
// left in to work with 2.7.0 dev releases that used attributes for
// groupName
String groupName = data.getAttributeValue("groupName");
if (groupName != null) {
bsbGroup.setGroupName(groupName);
}
Elements elems = data.getElements();
while (elems.hasMoreElements()) {
Element node = elems.next();
String name = node.getName();
switch(name) {
case "groupName":
bsbGroup.setGroupName(node.getTextString());
break;
case "backgroundColor":
bsbGroup.setBackgroundColor(Color.valueOf(node.getTextString()));
break;
case "borderColor":
bsbGroup.setBorderColor(Color.valueOf(node.getTextString()));
break;
case "labelTextColor":
bsbGroup.setLabelTextColor(Color.valueOf(node.getTextString()));
break;
case "bsbObject":
Object obj = ObjectUtilities.loadFromXML(node);
// FIXME
bsbGroup.addBSBObject((BSBObject) obj);
break;
case "titleEnabled":
bsbGroup.setTitleEnabled(XMLUtilities.readBoolean(node));
break;
case "width":
bsbGroup.setWidth(Integer.parseInt(node.getTextString()));
break;
case "height":
bsbGroup.setHeight(Integer.parseInt(node.getTextString()));
break;
}
}
return bsbGroup;
}
Aggregations