Search in sources :

Example 21 with ScoreObject

use of blue.score.ScoreObject 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 22 with ScoreObject

use of blue.score.ScoreObject in project blue by kunstmusik.

the class MoveScoreObjectsListener method mouseDragged.

@Override
public void mouseDragged(MouseEvent e) {
    ScoreController scoreController = ScoreController.getInstance();
    ScorePath scorePath = ScoreController.getInstance().getScorePath();
    List<Layer> allLayers = scorePath.getAllLayers();
    e.consume();
    if (initialDrag) {
        initialDrag = false;
        if ((e.getModifiers() & OS_CTRL_KEY) == OS_CTRL_KEY) {
            for (int i = 0; i < selectedScoreObjects.length; i++) {
                ScoreObject original = selectedScoreObjects[i];
                ScoreObject clone = original.deepCopy();
                ScoreObjectLayer layer = (ScoreObjectLayer) allLayers.get(startLayerIndices[i]);
                layer.add(clone);
                scoreController.removeSelectedScoreObject(original);
                scoreController.addSelectedScoreObject(clone);
                selectedScoreObjects[i] = clone;
            }
        }
    }
    double diffTime = e.getX() - startPoint.x;
    TimeState timeState = scoreTC.getTimeState();
    diffTime = diffTime / timeState.getPixelSecond();
    if (diffTime < minDiffTime) {
        diffTime = minDiffTime;
    }
    if (timeState.isSnapEnabled()) {
        double tempStart = -minDiffTime + diffTime;
        double snappedStart = ScoreUtilities.getSnapValueMove(tempStart, timeState.getSnapValue());
        diffTime = snappedStart + minDiffTime;
    }
    int newLayerIndex = scorePath.getGlobalLayerIndexForY(e.getY());
    int layerAdjust = newLayerIndex - startLayer;
    layerAdjust = Math.max(layerAdjust, minYAdjust);
    layerAdjust = Math.min(layerAdjust, maxYAdjust);
    boolean layerAdjusted = lastLayerAdjust != layerAdjust;
    if (layerAdjusted) {
        lastLayerAdjust = layerAdjust;
    }
    for (int i = 0; i < selectedScoreObjects.length; i++) {
        selectedScoreObjects[i].setStartTime(startTimes[i] + diffTime);
        if (layerAdjusted) {
            ScoreObject scoreObj = selectedScoreObjects[i];
            int startIndex = startLayerIndices[i];
            int curLayerIndex = currentLayerIndices[i];
            int newSObjLayerIndex = startIndex + layerAdjust;
            allLayers.get(curLayerIndex).remove(scoreObj);
            // Re-add moved scoreObject as selected
            scoreController.addSelectedScoreObject(scoreObj);
            ((ScoreObjectLayer) allLayers.get(newSObjLayerIndex)).add(scoreObj);
            currentLayerIndices[i] = newSObjLayerIndex;
        }
    }
}
Also used : ScoreController(blue.ui.core.score.ScoreController) ScorePath(blue.ui.core.score.ScorePath) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ScoreObject(blue.score.ScoreObject) TimeState(blue.score.TimeState) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Point(java.awt.Point)

Example 23 with ScoreObject

use of blue.score.ScoreObject in project blue by kunstmusik.

the class NudgeUpAction 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()];
        for (int i = 0; i < scoreObjects.length; i++) {
            int index = path.getGlobalLayerIndexForScoreObject(scoreObjects[i]);
            if (index < 1) {
                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 24 with ScoreObject

use of blue.score.ScoreObject in project blue by kunstmusik.

the class NudgeUtils method nudgeHorizontal.

// TODO - Respect snap values, Make Undoable
public static void nudgeHorizontal(double timeValue, Collection<? extends ScoreObject> scoreObjects) {
    if (scoreObjects == null || scoreObjects.size() == 0) {
        return;
    }
    double adjustedTime = timeValue;
    if (timeValue < 0.0f) {
        for (ScoreObject scoreObj : scoreObjects) {
            double start = scoreObj.getStartTime();
            if (start == 0.0) {
                return;
            }
            if (adjustedTime < -start) {
                adjustedTime = -start;
            }
        }
    }
    // FIXME - handle for translating automations
    // mBuffer.motionBufferObjects();
    // setSelectionDragRegions();
    int len = scoreObjects.size();
    ScoreObject[] objects = scoreObjects.<ScoreObject>toArray(new ScoreObject[scoreObjects.size()]);
    double[] startTimes = new double[len];
    double[] endTimes = new double[len];
    for (int i = 0; i < objects.length; i++) {
        ScoreObject scoreObj = objects[i];
        startTimes[i] = scoreObj.getStartTime();
        endTimes[i] = scoreObj.getStartTime() + adjustedTime;
        scoreObj.setStartTime(endTimes[i]);
    }
    MoveScoreObjectsEdit edit = new MoveScoreObjectsEdit(objects, null, null, startTimes, endTimes);
    BlueUndoManager.setUndoManager("score");
    BlueUndoManager.addEdit(edit);
// automationPanel.setMultiLineTranslation(timeValue);
// automationPanel.commitMultiLineDrag();
}
Also used : MoveScoreObjectsEdit(blue.ui.core.score.undo.MoveScoreObjectsEdit) ScoreObject(blue.score.ScoreObject)

Example 25 with ScoreObject

use of blue.score.ScoreObject in project blue by kunstmusik.

the class RepeatScoreObjectsAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    Collection<? extends ScoreObject> scoreObjects = ScoreController.getInstance().getSelectedScoreObjects();
    if (!scoreObjects.isEmpty()) {
        Object retVal = JOptionPane.showInputDialog(WindowManager.getDefault().getMainWindow(), "Enter number of times to repeat:", new Integer(1));
        if (retVal == null) {
            return;
        }
        int count = -1;
        try {
            count = Integer.parseInt((String) retVal);
        } catch (Exception exception) {
            JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Entry must be an integer value.", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (count < 1) {
            JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Value must be greater than 0.", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        ScorePath path = ScoreController.getInstance().getScorePath();
        AddScoreObjectEdit top = null;
        for (ScoreObject sObj : scoreObjects) {
            double start = sObj.getStartTime();
            ScoreObjectLayer layer = (ScoreObjectLayer) path.getLayerForScoreObject(sObj);
            for (int j = 0; j < count; j++) {
                ScoreObject temp = sObj.deepCopy();
                start += sObj.getSubjectiveDuration();
                temp.setStartTime(start);
                if (layer == null) {
                    JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Could not find SoundLayer for SoundObject", "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }
                layer.add(temp);
                AddScoreObjectEdit edit = new AddScoreObjectEdit(layer, temp);
                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) ScoreObject(blue.score.ScoreObject)

Aggregations

ScoreObject (blue.score.ScoreObject)39 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)13 Layer (blue.score.layers.Layer)12 ArrayList (java.util.ArrayList)9 Point (java.awt.Point)8 BlueData (blue.BlueData)6 SoundObject (blue.soundObject.SoundObject)6 ScorePath (blue.ui.core.score.ScorePath)6 SoundLayer (blue.SoundLayer)5 AlignEdit (blue.ui.core.score.undo.AlignEdit)5 Instance (blue.soundObject.Instance)4 PolyObject (blue.soundObject.PolyObject)4 ScoreController (blue.ui.core.score.ScoreController)4 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)4 MoveScoreObjectsEdit (blue.ui.core.score.undo.MoveScoreObjectsEdit)4 SoundObjectLibrary (blue.SoundObjectLibrary)2 AlphaMarquee (blue.components.AlphaMarquee)2 Score (blue.score.Score)2 GenericScore (blue.soundObject.GenericScore)2 Test (org.junit.Test)2