Search in sources :

Example 6 with LayerGroup

use of blue.score.layers.LayerGroup 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)

Example 7 with LayerGroup

use of blue.score.layers.LayerGroup in project blue by kunstmusik.

the class ScoreManagerDialog method layerGroupsTableMouseClicked.

// GEN-LAST:event_layersMinusButtonActionPerformed
private void layerGroupsTableMouseClicked(java.awt.event.MouseEvent evt) {
    // GEN-FIRST:event_layerGroupsTableMouseClicked
    if (layerGroupsTable.isEditing()) {
        return;
    }
    int rowIndex = layerGroupsTable.getSelectedRow();
    if (rowIndex < 0) {
        layersTable.setModel(emptyList);
        propertiesScrollPane.setViewportView(null);
    } else {
        final LayerGroup layerGroup = score.get(rowIndex);
        layersTable.setModel(new LayersTableModel(layerGroup));
        TableColumn col = layersTable.getTableHeader().getColumnModel().getColumn(0);
        col.setMaxWidth(50);
        col.setMinWidth(50);
        col.setPreferredWidth(50);
        propertiesScrollPane.setViewportView(null);
        LayerGroupUIProviderManager manager = LayerGroupUIProviderManager.getInstance();
        JComponent comp = manager.getLayerGroupPropertiesPanel(layerGroup);
        if (comp != null) {
            propertiesScrollPane.setViewportView(comp);
        }
    }
// if (UiUtilities.isRightMouseButton(e)) {
// convertPopup.show(arrangementTable, e.getX(), e.getY());
// }
}
Also used : LayerGroupUIProviderManager(blue.ui.core.score.layers.LayerGroupUIProviderManager) LayerGroup(blue.score.layers.LayerGroup) TableColumn(javax.swing.table.TableColumn) Point(java.awt.Point)

Example 8 with LayerGroup

use of blue.score.layers.LayerGroup in project blue by kunstmusik.

the class ScoreTopComponent method listChanged.

@Override
public void listChanged(ObservableListEvent<LayerGroup<? extends Layer>> evt) {
    if (evt.getType() == ObservableListEvent.DATA_ADDED) {
        Score score = data.getScore();
        for (int i = evt.getStartIndex(); i <= evt.getEndIndex(); i++) {
            addPanelsForLayerGroup(i, score.get(i), score.getTimeState());
        }
        layerHeaderPanel.revalidate();
        checkSize();
    } else if (evt.getType() == ObservableListEvent.DATA_REMOVED) {
        removePanelsForLayerGroups(evt.getStartIndex(), evt.getEndIndex());
    } else if (evt.getType() == ObservableListEvent.DATA_CHANGED) {
        List<LayerGroup<? extends Layer>> layerGroups = evt.getAffectedItems();
        JComponent c = (JComponent) layerPanel.getComponent(evt.getStartIndex());
        LayerGroup lGroup = (LayerGroup) c.getClientProperty("layerGroup");
        if (layerGroups.get(1) == lGroup) {
            // handle push down
            Component comp = layerPanel.getComponent(evt.getEndIndex());
            layerPanel.remove(comp);
            layerPanel.add(comp, evt.getStartIndex());
            Component comp2 = layerHeaderPanel.getComponent(evt.getEndIndex());
            layerHeaderPanel.remove(comp2);
            layerHeaderPanel.add(comp2, evt.getStartIndex());
            layerPanel.revalidate();
            layerHeaderPanel.revalidate();
            layerPanel.repaint();
            layerHeaderPanel.repaint();
        } else {
            // handle push up
            Component comp = layerPanel.getComponent(evt.getStartIndex());
            layerPanel.remove(comp);
            layerPanel.add(comp, evt.getEndIndex());
            Component comp2 = layerHeaderPanel.getComponent(evt.getStartIndex());
            layerHeaderPanel.remove(comp2);
            layerHeaderPanel.add(comp2, evt.getEndIndex());
            layerPanel.revalidate();
            layerHeaderPanel.revalidate();
            layerPanel.repaint();
            layerHeaderPanel.repaint();
        }
    }
}
Also used : Score(blue.score.Score) LayerGroup(blue.score.layers.LayerGroup) TopComponent(org.openide.windows.TopComponent) Layer(blue.score.layers.Layer)

Example 9 with LayerGroup

use of blue.score.layers.LayerGroup in project blue by kunstmusik.

the class ScoreObjectBar method scorePathChanged.

@Override
public void scorePathChanged(ScorePath path) {
    if (path != currentPath) {
        for (int i = 0; i < getComponentCount(); i++) {
            LayerGroupButton btn = (LayerGroupButton) getComponent(i);
            btn.removeActionListener(this);
            btn.removeMouseListener(popupListener);
        }
        this.removeAll();
        LayerGroupButton btn = new LayerGroupButton(path.getScore());
        btn.addActionListener(this);
        btn.addMouseListener(popupListener);
        this.add(btn);
        for (LayerGroup layerGroup : path.getLayerGroups()) {
            btn = new LayerGroupButton(layerGroup);
            btn.addActionListener(this);
            btn.addMouseListener(popupListener);
            this.add(btn);
        }
    } else {
        int layerGroupsCount = getComponentCount() - 1;
        List<LayerGroup> layerGroups = path.getLayerGroups();
        int pathSize = layerGroups.size();
        if (layerGroupsCount > pathSize) {
            while ((getComponentCount() - 1) > pathSize) {
                this.remove(getComponentCount() - 1);
            }
        } else if (layerGroupsCount < pathSize) {
            for (int i = layerGroupsCount; i < pathSize; i++) {
                LayerGroupButton btn = new LayerGroupButton(layerGroups.get(i));
                btn.addActionListener(this);
                btn.addMouseListener(popupListener);
                this.add(btn);
            }
        }
    }
    currentPath = path;
    repaint();
}
Also used : LayerGroup(blue.score.layers.LayerGroup)

Example 10 with LayerGroup

use of blue.score.layers.LayerGroup in project blue by kunstmusik.

the class SoundObjectLibraryUtils method removeLibrarySoundObject.

public static void removeLibrarySoundObject(BlueData data, SoundObject sObj) {
    SoundObjectLibrary library = data.getSoundObjectLibrary();
    library.removeSoundObject(sObj);
    for (SoundObject tempObj : library) {
        if (tempObj instanceof PolyObject) {
            removeSoundObjectInstances((PolyObject) tempObj, sObj);
        }
    }
    Score score = data.getScore();
    for (LayerGroup layerGroup : score) {
        if (layerGroup instanceof PolyObject) {
            PolyObject pObj = (PolyObject) layerGroup;
            removeSoundObjectInstances(pObj, sObj);
        }
    }
}
Also used : Score(blue.score.Score) SoundObject(blue.soundObject.SoundObject) SoundObjectLibrary(blue.SoundObjectLibrary) LayerGroup(blue.score.layers.LayerGroup) PolyObject(blue.soundObject.PolyObject)

Aggregations

LayerGroup (blue.score.layers.LayerGroup)10 Score (blue.score.Score)2 Layer (blue.score.layers.Layer)2 LayerGroupProviderManager (blue.score.layers.LayerGroupProviderManager)2 PolyObject (blue.soundObject.PolyObject)2 Element (electric.xml.Element)2 SoundObjectLibrary (blue.SoundObjectLibrary)1 NoteProcessorException (blue.noteProcessor.NoteProcessorException)1 TimeState (blue.score.TimeState)1 LayerGroupProvider (blue.score.layers.LayerGroupProvider)1 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)1 NoteList (blue.soundObject.NoteList)1 SoundObject (blue.soundObject.SoundObject)1 LayerGroupUIProviderManager (blue.ui.core.score.layers.LayerGroupUIProviderManager)1 ObservableArrayList (blue.util.ObservableArrayList)1 Elements (electric.xml.Elements)1 Point (java.awt.Point)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ArrayList (java.util.ArrayList)1