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