use of blue.score.ScoreObject in project blue by kunstmusik.
the class ResizeScoreObjectsListener method mousePressed.
@Override
public void mousePressed(MouseEvent e) {
Cursor c = scoreTC.getScorePanel().getCursor();
if (currentScoreObjectView == null || c == null || !(c.getType() == Cursor.E_RESIZE_CURSOR || c.getType() == Cursor.W_RESIZE_CURSOR)) {
return;
}
e.consume();
ScoreObject scoreObj = currentScoreObjectView.getScoreObject();
Collection<? extends ScoreObject> temp = ScoreController.getInstance().getSelectedScoreObjects();
if (temp.size() != 1) {
// revisit to do more than one in the future
return;
}
switch(c.getType()) {
case Cursor.W_RESIZE_CURSOR:
resizeMode = ResizeMode.RESIZE_RIGHT;
break;
case Cursor.E_RESIZE_CURSOR:
resizeMode = ResizeMode.RESIZE_LEFT;
break;
default:
throw new RuntimeException("Error: Unknown resize type: " + c.getType());
}
startPoint = e.getPoint();
selectedScoreObjects = temp.toArray(new ScoreObject[0]);
startTimes = new double[selectedScoreObjects.length];
endTimes = new double[selectedScoreObjects.length];
minDiffTime = Double.MAX_VALUE;
maxDiffTime = Double.MIN_VALUE;
for (int i = 0; i < selectedScoreObjects.length; i++) {
final ScoreObject sObj = selectedScoreObjects[i];
startTimes[i] = sObj.getStartTime();
endTimes[i] = startTimes[i] + sObj.getSubjectiveDuration();
if (sObj.getMaxResizeLeftDiff() < minDiffTime) {
minDiffTime = sObj.getMaxResizeLeftDiff();
}
if (sObj.getMaxResizeRightDiff() > maxDiffTime) {
maxDiffTime = sObj.getMaxResizeRightDiff();
}
}
}
use of blue.score.ScoreObject in project blue by kunstmusik.
the class AlignLeftAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (selected.size() < 2) {
return;
}
double[] initialStartTimes = new double[selected.size()];
double[] endingStartTimes = new double[selected.size()];
double farLeft = Double.MAX_VALUE;
int i = 0;
for (ScoreObject scoreObj : selected) {
initialStartTimes[i] = scoreObj.getStartTime();
if (initialStartTimes[i] < farLeft) {
farLeft = initialStartTimes[i];
}
i++;
}
i = 0;
for (ScoreObject scoreObj : selected) {
scoreObj.setStartTime(farLeft);
endingStartTimes[i] = farLeft;
i++;
}
BlueUndoManager.setUndoManager("score");
AlignEdit edit = new AlignEdit(selected.toArray(new ScoreObject[0]), initialStartTimes, endingStartTimes);
edit.setPresentationName("Align Left");
BlueUndoManager.addEdit(edit);
}
use of blue.score.ScoreObject in project blue by kunstmusik.
the class AlignRightAction 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 farRight = Double.MIN_VALUE;
int i = 0;
for (ScoreObject scoreObj : selected) {
initialStartTimes[i] = scoreObj.getStartTime();
double end = initialStartTimes[i] + scoreObj.getSubjectiveDuration();
if (end > farRight) {
farRight = end;
}
i++;
}
i = 0;
for (ScoreObject scoreObj : selected) {
double newTime = farRight - scoreObj.getSubjectiveDuration();
scoreObj.setStartTime(newTime);
endingStartTimes[i] = newTime;
i++;
}
BlueUndoManager.setUndoManager("score");
AlignEdit edit = new AlignEdit(selected.toArray(new ScoreObject[0]), initialStartTimes, endingStartTimes);
edit.setPresentationName("Align Right");
BlueUndoManager.addEdit(edit);
}
use of blue.score.ScoreObject in project blue by kunstmusik.
the class RealtimeRenderManager method auditionSoundObjects.
public void auditionSoundObjects(BlueData data, List<ScoreObject> scoreObjects) {
if (scoreObjects == null || scoreObjects.isEmpty()) {
return;
}
if (isRendering()) {
stopRendering();
}
BlueData tempData = new BlueData(data);
tempData.setLoopRendering(false);
List<PolyObject> path = null;
filterScore(tempData.getScore(), scoreObjects);
if (data.getScore().isEmpty()) {
throw new RuntimeException("Error: unable to find root LayerGroups for objects...");
}
double minTime = Double.MAX_VALUE;
double maxTime = Double.MIN_VALUE;
for (ScoreObject sObj : scoreObjects) {
double startTime = sObj.getStartTime();
double endTime = startTime + sObj.getSubjectiveDuration();
if (startTime < minTime) {
minTime = startTime;
}
if (endTime > maxTime) {
maxTime = endTime;
}
}
Mixer m = tempData.getMixer();
if (m.isEnabled()) {
maxTime += m.getExtraRenderTime();
}
tempData.setRenderStartTime(minTime);
tempData.setRenderEndTime(maxTime);
renderProject(tempData, true);
}
use of blue.score.ScoreObject in project blue by kunstmusik.
the class MoveScoreObjectsListenerTest method testGetMaxYAdjust.
/**
* Test of getMaxYAdjust method, of class MoveScoreObjectsListener.
*/
@Test
public void testGetMaxYAdjust() {
System.out.println("getMaxYAdjust");
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.getMaxYAdjust(layers, scoreObj, sObjLayerIndex);
assertEquals(1, result);
layers.add(0, new InvalidLayer());
layers.add(1, new SoundLayer());
layers.add(new InvalidLayer());
sObjLayerIndex = 3;
result = MoveScoreObjectsListener.getMaxYAdjust(layers, scoreObj, sObjLayerIndex);
assertEquals(1, result);
}
Aggregations