Search in sources :

Example 6 with ScoreObjectLayer

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

the class DuplicateScoreObjectsAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    // FIXME - this needs to work with ScoreObjects...
    Collection<? extends ScoreObject> scoreObjects = ScoreController.getInstance().getSelectedScoreObjects();
    if (!scoreObjects.isEmpty()) {
        ScorePath path = ScoreController.getInstance().getScorePath();
        AddScoreObjectEdit top = null;
        for (ScoreObject sObj : scoreObjects) {
            ScoreObject clone = sObj.deepCopy();
            clone.setStartTime(clone.getStartTime() + clone.getSubjectiveDuration());
            ScoreObjectLayer layer = (ScoreObjectLayer) path.getLayerForScoreObject(sObj);
            if (layer == null) {
                JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Could not find Layer for ScoreObject", "Error", JOptionPane.ERROR_MESSAGE);
                return;
            }
            layer.add(clone);
            AddScoreObjectEdit edit = new AddScoreObjectEdit(layer, clone);
            if (top == null) {
                top = edit;
            } else {
                top.addSubEdit(edit);
            }
        }
        BlueUndoManager.setUndoManager("score");
        BlueUndoManager.addEdit(top);
    }
}
Also used : ScorePath(blue.ui.core.score.ScorePath) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) ScoreObject(blue.score.ScoreObject)

Example 7 with ScoreObjectLayer

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

the class NudgeDownAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    Collection<? extends ScoreObject> selected = ScoreController.getInstance().getSelectedScoreObjects();
    if (!selected.isEmpty()) {
        ScorePath path = ScoreController.getInstance().getScorePath();
        ScoreObject[] scoreObjects = selected.<ScoreObject>toArray(new ScoreObject[selected.size()]);
        List<Layer> layers = path.getAllLayers();
        int[] indexes = new int[selected.size()];
        int lastIndex = layers.size() - 1;
        for (int i = 0; i < scoreObjects.length; i++) {
            int index = path.getGlobalLayerIndexForScoreObject(scoreObjects[i]);
            if (index >= lastIndex) {
                return;
            }
            Layer layer = layers.get(index + 1);
            if (!layer.accepts(scoreObjects[i])) {
                return;
            }
            indexes[i] = index;
        }
        int len = scoreObjects.length;
        ScoreObjectLayer[] startLayers = new ScoreObjectLayer[len];
        ScoreObjectLayer[] endLayers = new ScoreObjectLayer[len];
        for (int i = 0; i < scoreObjects.length; i++) {
            startLayers[i] = (ScoreObjectLayer) layers.get(indexes[i]);
            endLayers[i] = (ScoreObjectLayer) layers.get(indexes[i] + 1);
            startLayers[i].remove(scoreObjects[i]);
            endLayers[i].add(scoreObjects[i]);
        }
        MoveScoreObjectsEdit edit = new MoveScoreObjectsEdit(scoreObjects, startLayers, endLayers, null, null);
        BlueUndoManager.setUndoManager("score");
        BlueUndoManager.addEdit(edit);
    }
}
Also used : MoveScoreObjectsEdit(blue.ui.core.score.undo.MoveScoreObjectsEdit) ScorePath(blue.ui.core.score.ScorePath) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ScoreObject(blue.score.ScoreObject) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer)

Example 8 with ScoreObjectLayer

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

the class ReplaceWithBufferSoundObjectAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    ScoreController.ScoreObjectBuffer buffer = ScoreController.getInstance().getScoreObjectBuffer();
    List<Layer> layers = scorePath.getAllLayers();
    BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
    SoundObjectLibrary sObjLib = data.getSoundObjectLibrary();
    List<Instance> instances = new ArrayList<>();
    ReplaceScoreObjectEdit top = null;
    for (SoundObject sObj : soundObjects) {
        SoundObject replacement = getReplacementObject(buffer, instances);
        replacement.setStartTime(sObj.getStartTime());
        replacement.setSubjectiveDuration(sObj.getSubjectiveDuration());
        ScoreObjectLayer layer = (ScoreObjectLayer) findLayerForSoundObject(layers, sObj);
        layer.remove(sObj);
        layer.add(replacement);
        ReplaceScoreObjectEdit edit = new ReplaceScoreObjectEdit(layer, sObj, replacement);
        if (top == null) {
            top = edit;
        } else {
            top.addEdit(edit);
        }
    }
    // FIXME - this part is not undoable...
    sObjLib.checkAndAddInstanceSoundObjects(instances);
    BlueUndoManager.setUndoManager("score");
    BlueUndoManager.addEdit(top);
}
Also used : ScoreController(blue.ui.core.score.ScoreController) BlueData(blue.BlueData) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) SoundObject(blue.soundObject.SoundObject) Instance(blue.soundObject.Instance) ReplaceScoreObjectEdit(blue.ui.core.score.undo.ReplaceScoreObjectEdit) ArrayList(java.util.ArrayList) SoundObjectLibrary(blue.SoundObjectLibrary) SoundLayer(blue.SoundLayer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Layer(blue.score.layers.Layer)

Example 9 with ScoreObjectLayer

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

the class SelectLayerAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    Layer layer = scorePath.getGlobalLayerForY(p.y);
    if (layer != null && layer instanceof ScoreObjectLayer) {
        ArrayList<ScoreObject> newSelected = new ArrayList<>((ScoreObjectLayer) layer);
        ScoreController.getInstance().setSelectedScoreObjects(newSelected);
    }
}
Also used : ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ScoreObject(blue.score.ScoreObject) ArrayList(java.util.ArrayList) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer)

Example 10 with ScoreObjectLayer

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

the class MoveScoreObjectsListener method mouseReleased.

@Override
public void mouseReleased(MouseEvent e) {
    e.consume();
    if (!initialDrag) {
        List<Layer> allLayers = ScoreController.getInstance().getScorePath().getAllLayers();
        int len = startTimes.length;
        double[] endTimes = new double[len];
        ScoreObjectLayer[] startLayers = new ScoreObjectLayer[len];
        ScoreObjectLayer[] endLayers = new ScoreObjectLayer[len];
        for (int i = 0; i < selectedScoreObjects.length; i++) {
            endTimes[i] = selectedScoreObjects[i].getStartTime();
            startLayers[i] = (ScoreObjectLayer) allLayers.get(startLayerIndices[i]);
            endLayers[i] = (ScoreObjectLayer) allLayers.get(currentLayerIndices[i]);
        }
        MoveScoreObjectsEdit edit = new MoveScoreObjectsEdit(selectedScoreObjects, startLayers, endLayers, startTimes, endTimes);
        BlueUndoManager.setUndoManager("score");
        BlueUndoManager.addEdit(edit);
    }
    selectedScoreObjects = null;
    startTimes = null;
    startLayerIndices = null;
    currentLayerIndices = null;
}
Also used : MoveScoreObjectsEdit(blue.ui.core.score.undo.MoveScoreObjectsEdit) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Point(java.awt.Point)

Aggregations

ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)18 Layer (blue.score.layers.Layer)15 ScoreObject (blue.score.ScoreObject)11 Point (java.awt.Point)8 ScorePath (blue.ui.core.score.ScorePath)7 ArrayList (java.util.ArrayList)7 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)5 SoundLayer (blue.SoundLayer)4 ScoreController (blue.ui.core.score.ScoreController)4 BlueData (blue.BlueData)3 SoundObjectLibrary (blue.SoundObjectLibrary)3 Instance (blue.soundObject.Instance)3 SoundObject (blue.soundObject.SoundObject)3 MoveScoreObjectsEdit (blue.ui.core.score.undo.MoveScoreObjectsEdit)3 AlphaMarquee (blue.components.AlphaMarquee)2 Score (blue.score.Score)1 TimeState (blue.score.TimeState)1 LayerGroup (blue.score.layers.LayerGroup)1 PolyObject (blue.soundObject.PolyObject)1 ScoreTimeCanvas (blue.ui.core.score.layers.soundObject.ScoreTimeCanvas)1