use of blue.score.layers.LayerGroupProviderManager 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;
}
use of blue.score.layers.LayerGroupProviderManager in project blue by kunstmusik.
the class ScoreManagerDialog method getAddLayerGroupMenu.
private JPopupMenu getAddLayerGroupMenu() {
if (addLayerGroupMenu == null) {
addLayerGroupMenu = new JPopupMenu();
ActionListener listener = (ActionEvent e) -> {
JMenuItem menuItem = (JMenuItem) e.getSource();
LayerGroupProvider provider = (LayerGroupProvider) menuItem.getClientProperty("provider");
LayerGroup layerGroup = provider.createLayerGroup();
LayerGroupTableModel model = getLayerGroupListModel();
int index = (layerGroupsTable.getSelectionModel().getMaxSelectionIndex());
if (index < 0 || index > model.getRowCount()) {
index = model.getRowCount();
model.addLayerGroup(index, layerGroup);
} else {
model.addLayerGroup(index, layerGroup);
}
ListSelectionModel selection = layerGroupsTable.getSelectionModel();
selection.setSelectionInterval(index, index);
};
LayerGroupProviderManager manager = LayerGroupProviderManager.getInstance();
for (LayerGroupProvider provider : manager) {
JMenuItem item = new JMenuItem("Add " + provider.getLayerGroupName() + " Layer Group");
item.putClientProperty("provider", provider);
item.addActionListener(listener);
addLayerGroupMenu.add(item);
}
}
return addLayerGroupMenu;
}
Aggregations