use of electric.xml.Elements in project blue by kunstmusik.
the class Script method loadFromXML.
public static Script loadFromXML(Element data) {
Script script = new Script();
Elements nodes = data.getElements();
while (nodes.hasMoreElements()) {
Element node = nodes.next();
String nodeName = node.getName();
switch(nodeName) {
case "name":
script.setName(node.getTextString());
break;
case "description":
script.setDescription(node.getTextString());
break;
case "code":
script.setCode(node.getTextString());
break;
case "comments":
script.setComments(node.getTextString());
break;
}
}
return script;
}
use of electric.xml.Elements in project blue by kunstmusik.
the class PolyObject method loadFromXML.
/*
* (non-Javadoc)
*
* @see blue.soundObject.SoundObject#loadFromXML(electric.xml.Element)
*/
public static PolyObject loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
PolyObject pObj = new PolyObject();
SoundObjectUtilities.initBasicFromXML(data, pObj);
Elements nodes = data.getElements();
int heightIndex = -1;
while (nodes.hasMoreElements()) {
Element node = nodes.next();
String nodeName = node.getName();
switch(nodeName) {
case "heightIndex":
{
int index = Integer.parseInt(node.getTextString());
// checking if using old heightIndex values
String val = node.getAttributeValue("version");
if (val == null || val.length() == 0) {
index = index - 1;
index = index < 0 ? 0 : index;
}
heightIndex = index;
break;
}
case "defaultHeightIndex":
{
int index = Integer.parseInt(node.getTextString());
pObj.setDefaultHeightIndex(index);
break;
}
case "soundLayer":
pObj.add(SoundLayer.loadFromXML(node, objRefMap));
break;
case "timeState":
pObj.timeState = TimeState.loadFromXML(node);
break;
}
}
if (heightIndex >= 0) {
for (int i = 0; i < pObj.size(); i++) {
SoundLayer layer = pObj.get(i);
layer.setHeightIndex(heightIndex);
}
pObj.setDefaultHeightIndex(heightIndex);
}
return pObj;
}
use of electric.xml.Elements in project blue by kunstmusik.
the class BSBVSliderBank method loadFromXML.
public static BSBObject loadFromXML(Element data) {
BSBVSliderBank sliderBank = new BSBVSliderBank();
double minVal = 0;
double maxVal = 1.0;
BigDecimal resolution = new BigDecimal("0.1");
initBasicFromXML(data, sliderBank);
Elements nodes = data.getElements();
sliderBank.getSliders().clear();
List<BSBVSlider> childSliders = new ArrayList<>();
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 "resolution":
resolution = new BigDecimal(Double.parseDouble(node.getTextString())).setScale(5, RoundingMode.HALF_UP).stripTrailingZeros();
break;
case "bdresolution":
resolution = new BigDecimal(node.getTextString());
break;
case "sliderHeight":
sliderBank.setSliderHeight(Integer.parseInt(node.getTextString()));
break;
case "gap":
sliderBank.setGap(Integer.parseInt(node.getTextString()));
break;
case "randomizable":
sliderBank.setRandomizable(XMLUtilities.readBoolean(node));
break;
case "valueDisplayEnabled":
sliderBank.setValueDisplayEnabled(XMLUtilities.readBoolean(node));
break;
case "bsbObject":
BSBVSlider hSlider = (BSBVSlider) BSBVSlider.loadFromXML(node);
childSliders.add(hSlider);
break;
}
}
sliderBank.setValueProperty(new ClampedValue(minVal, maxVal, 0.0, resolution));
sliderBank.getSliders().addAll(childSliders);
return sliderBank;
}
use of electric.xml.Elements in project blue by kunstmusik.
the class GridSettings method loadFromXML.
public static GridSettings loadFromXML(Element data) throws Exception {
GridSettings gridSettings = new GridSettings();
Elements giNodes = data.getElements();
while (giNodes.hasMoreElements()) {
Element node = giNodes.next();
String name = node.getName();
switch(name) {
case "width":
gridSettings.setWidth(XMLUtilities.readInt(node));
break;
case "height":
gridSettings.setHeight(XMLUtilities.readInt(node));
break;
case "gridStyle":
gridSettings.setGridStyle(GridStyle.valueOf(node.getTextString()));
break;
case "snapGridEnabled":
gridSettings.setSnapEnabled(XMLUtilities.readBoolean(node));
break;
}
}
return gridSettings;
}
use of electric.xml.Elements in project blue by kunstmusik.
the class Score method loadFromXML.
public static Score loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
Score score = new Score(false);
Elements nodes = data.getElements();
LayerGroupProviderManager manager = LayerGroupProviderManager.getInstance();
while (nodes.hasMoreElements()) {
Element node = nodes.next();
switch(node.getName()) {
case "tempo":
score.tempo = Tempo.loadFromXML(node);
break;
case "timeState":
score.timeState = TimeState.loadFromXML(node);
break;
case "noteProcessorChain":
score.npc = NoteProcessorChain.loadFromXML(node);
break;
default:
LayerGroup layerGroup = manager.loadFromXML(node, objRefMap);
if (layerGroup == null) {
throw new RuntimeException("Unable to load Score LayerGroup of type: " + node.getName());
}
score.add(layerGroup);
if (layerGroup instanceof PolyObject) {
((PolyObject) layerGroup).setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
}
break;
}
}
if (score.size() == 0) {
PolyObject pObj = new PolyObject(true);
score.add(pObj);
}
return score;
}
Aggregations