Search in sources :

Example 1 with LayerGroupProviderManager

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;
}
Also used : Element(electric.xml.Element) LayerGroup(blue.score.layers.LayerGroup) Elements(electric.xml.Elements) PolyObject(blue.soundObject.PolyObject) LayerGroupProviderManager(blue.score.layers.LayerGroupProviderManager)

Example 2 with LayerGroupProviderManager

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;
}
Also used : LayerGroupProvider(blue.score.layers.LayerGroupProvider) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) LayerGroup(blue.score.layers.LayerGroup) LayerGroupProviderManager(blue.score.layers.LayerGroupProviderManager)

Aggregations

LayerGroup (blue.score.layers.LayerGroup)2 LayerGroupProviderManager (blue.score.layers.LayerGroupProviderManager)2 LayerGroupProvider (blue.score.layers.LayerGroupProvider)1 PolyObject (blue.soundObject.PolyObject)1 Element (electric.xml.Element)1 Elements (electric.xml.Elements)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1