Search in sources :

Example 26 with ScoreObject

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

the class ReplaceWithBufferSoundObjectAction method getReplacementObject.

protected SoundObject getReplacementObject(ScoreController.ScoreObjectBuffer buffer, List<Instance> instances) {
    if (buffer.scoreObjects.size() == 1) {
        SoundObject sObj = (SoundObject) buffer.scoreObjects.get(0).deepCopy();
        if (sObj instanceof Instance) {
            instances.add((Instance) sObj);
        }
        return sObj;
    }
    PolyObject pObj = new PolyObject();
    int minLayer = Integer.MAX_VALUE;
    int maxLayer = Integer.MIN_VALUE;
    for (Integer layerIndex : buffer.layerIndexes) {
        if (layerIndex < minLayer) {
            minLayer = layerIndex;
        }
        if (layerIndex > maxLayer) {
            maxLayer = layerIndex;
        }
    }
    int numLayers = maxLayer - minLayer + 1;
    for (int i = 0; i < numLayers; i++) {
        pObj.newLayerAt(-1);
    }
    for (int i = 0; i < buffer.scoreObjects.size(); i++) {
        ScoreObject scoreObj = buffer.scoreObjects.get(i);
        int layerIndex = buffer.layerIndexes.get(i);
        SoundLayer layer = pObj.get(layerIndex - minLayer);
        SoundObject clone = (SoundObject) scoreObj.deepCopy();
        layer.add(clone);
        if (clone instanceof Instance) {
            instances.add((Instance) clone);
        }
    }
    return pObj;
}
Also used : SoundObject(blue.soundObject.SoundObject) Instance(blue.soundObject.Instance) SoundLayer(blue.SoundLayer) ScoreObject(blue.score.ScoreObject) PolyObject(blue.soundObject.PolyObject) Point(java.awt.Point)

Example 27 with ScoreObject

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

the class ReverseAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (scoreObjects.size() < 2) {
        return;
    }
    double start = Double.MAX_VALUE;
    double end = Double.MIN_VALUE;
    for (ScoreObject scoreObject : scoreObjects) {
        double tempStart = scoreObject.getStartTime();
        double tempEnd = tempStart + scoreObject.getSubjectiveDuration();
        if (tempStart < start) {
            start = tempStart;
        }
        if (tempEnd > end) {
            end = tempEnd;
        }
    }
    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 < len; i++) {
        ScoreObject scoreObj = objects[i];
        double tempStart = scoreObj.getStartTime();
        double tempEnd = tempStart + scoreObj.getSubjectiveDuration();
        double newStart = start + (end - tempEnd);
        scoreObj.setStartTime(newStart);
        startTimes[i] = tempStart;
        endTimes[i] = newStart;
    }
    BlueUndoManager.setUndoManager("score");
    MoveScoreObjectsEdit edit = new MoveScoreObjectsEdit(objects, null, null, startTimes, endTimes);
    BlueUndoManager.setUndoManager("score");
    BlueUndoManager.addEdit(edit);
}
Also used : MoveScoreObjectsEdit(blue.ui.core.score.undo.MoveScoreObjectsEdit) ScoreObject(blue.score.ScoreObject)

Example 28 with ScoreObject

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

the class SetColorAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (scoreObjects.size() > 0) {
        Color retVal = JColorChooser.showDialog(WindowManager.getDefault().getMainWindow(), "Choose Color", scoreObjects.iterator().next().getBackgroundColor());
        SetColorEdit top = null;
        if (retVal != null) {
            for (ScoreObject sObj : scoreObjects) {
                Color old = sObj.getBackgroundColor();
                sObj.setBackgroundColor(retVal);
                SetColorEdit edit = new SetColorEdit(sObj, old, retVal);
                if (top == null) {
                    top = edit;
                } else {
                    top.addEdit(edit);
                }
            }
            BlueUndoManager.setUndoManager("score");
            BlueUndoManager.addEdit(top);
        }
    }
}
Also used : SetColorEdit(blue.ui.core.score.undo.SetColorEdit) Color(java.awt.Color) ScoreObject(blue.score.ScoreObject)

Example 29 with ScoreObject

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

the class AlignCenterAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent ev) {
    if (selected.size() < 2) {
        return;
    }
    double[] initialStartTimes = new double[selected.size()];
    double[] endingStartTimes = new double[selected.size()];
    double farLeft = Double.MAX_VALUE;
    double farRight = Double.MIN_VALUE;
    double end;
    int i = 0;
    for (ScoreObject scoreObj : selected) {
        initialStartTimes[i] = scoreObj.getStartTime();
        end = initialStartTimes[i] + scoreObj.getSubjectiveDuration();
        if (initialStartTimes[i] < farLeft) {
            farLeft = initialStartTimes[i];
        }
        if (end > farRight) {
            farRight = end;
        }
        i++;
    }
    double centerTime = ((farRight - farLeft) / 2) + farLeft;
    double newEndTime;
    i = 0;
    for (ScoreObject scoreObj : selected) {
        newEndTime = centerTime - (scoreObj.getSubjectiveDuration() / 2);
        scoreObj.setStartTime(newEndTime);
        endingStartTimes[i] = newEndTime;
        i++;
    }
    BlueUndoManager.setUndoManager("score");
    AlignEdit edit = new AlignEdit(selected.toArray(new ScoreObject[0]), initialStartTimes, endingStartTimes);
    edit.setPresentationName("Align Center");
    BlueUndoManager.addEdit(edit);
}
Also used : AlignEdit(blue.ui.core.score.undo.AlignEdit) ScoreObject(blue.score.ScoreObject)

Example 30 with ScoreObject

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

the class FollowTheLeaderAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    List<ScoreObject> scoreObjs = new ArrayList<>(selected);
    Collections.sort(scoreObjs, (ScoreObject o1, ScoreObject o2) -> {
        double diff = o1.getStartTime() - o2.getStartTime();
        if (diff > 0) {
            return 1;
        } else if (diff < 0) {
            return -1;
        }
        return 0;
    });
    double[] initialStartTimes = new double[scoreObjs.size()];
    double[] endStartTimes = new double[scoreObjs.size()];
    for (int i = 0; i < scoreObjs.size(); i++) {
        initialStartTimes[i] = scoreObjs.get(i).getStartTime();
    }
    ScoreObject initial = scoreObjs.get(0);
    double runningTotal = initial.getStartTime() + initial.getSubjectiveDuration();
    endStartTimes[0] = initial.getStartTime();
    for (int i = 1; i < scoreObjs.size(); i++) {
        ScoreObject current = scoreObjs.get(i);
        endStartTimes[i] = runningTotal;
        current.setStartTime(runningTotal);
        runningTotal += current.getSubjectiveDuration();
    }
    BlueUndoManager.setUndoManager("score");
    AlignEdit edit = new AlignEdit(scoreObjs.toArray(new ScoreObject[0]), initialStartTimes, endStartTimes);
    edit.setPresentationName("Follow the Leader");
    BlueUndoManager.addEdit(edit);
}
Also used : AlignEdit(blue.ui.core.score.undo.AlignEdit) ScoreObject(blue.score.ScoreObject) ArrayList(java.util.ArrayList)

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