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;
}
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);
}
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);
}
}
}
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);
}
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);
}
Aggregations