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