use of blue.score.ScoreObject in project blue by kunstmusik.
the class MoveScoreObjectsListenerTest method testGetMinYAdjust.
/**
* Test of getMinYAdjust method, of class MoveScoreObjectsListener.
*/
@Test
public void testGetMinYAdjust() {
System.out.println("getMinYAdjust");
List<Layer> layers = new ArrayList<>();
final SoundLayer soundLayer = new SoundLayer();
ScoreObject scoreObj = new GenericScore();
soundLayer.add((SoundObject) scoreObj);
layers.add(new SoundLayer());
layers.add(soundLayer);
layers.add(new SoundLayer());
int sObjLayerIndex = 1;
int result = MoveScoreObjectsListener.getMinYAdjust(layers, scoreObj, sObjLayerIndex);
assertEquals(-1, result);
layers.add(0, new InvalidLayer());
layers.add(1, new SoundLayer());
layers.add(new InvalidLayer());
sObjLayerIndex = 3;
result = MoveScoreObjectsListener.getMinYAdjust(layers, scoreObj, sObjLayerIndex);
assertEquals(-2, result);
}
use of blue.score.ScoreObject in project blue by kunstmusik.
the class ShiftAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (selected == null || selected.size() <= 0) {
return;
}
String value = JOptionPane.showInputDialog(null, BlueSystem.getString("scoreGUI.action.shift.message"));
try {
double val = Double.parseDouble(value);
for (ScoreObject scoreObj : selected) {
if ((scoreObj.getStartTime() + val) < 0) {
JOptionPane.showMessageDialog(null, BlueSystem.getString("scoreGUI.action.shift.error"));
return;
}
}
int len = selected.size();
ScoreObject[] objects = selected.<ScoreObject>toArray(new ScoreObject[selected.size()]);
double[] startTimes = new double[len];
double[] endTimes = new double[len];
for (int i = 0; i < len; i++) {
ScoreObject scoreObj = objects[i];
startTimes[i] = scoreObj.getStartTime();
endTimes[i] = startTimes[i] + val;
scoreObj.setStartTime(endTimes[i]);
}
AlignEdit edit = new AlignEdit(objects, startTimes, endTimes);
BlueUndoManager.setUndoManager("score");
BlueUndoManager.addEdit(edit);
} catch (NumberFormatException nfe) {
System.err.println(nfe.getMessage());
}
}
use of blue.score.ScoreObject 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.ScoreObject 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.ScoreObject in project blue by kunstmusik.
the class PatternLayerPanel method copySObjToBufferMenuItemActionPerformed.
// GEN-LAST:event_setSObjFromBufferMenuItemActionPerformed
private void copySObjToBufferMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_copySObjToBufferMenuItemActionPerformed
ScoreObject copy = patternLayer.getSoundObject().deepCopy();
ScoreController.getInstance().setSelectedScoreObjects(Collections.singleton(copy));
}
Aggregations