use of blue.ui.core.score.ScoreController in project blue by kunstmusik.
the class PatternLayerPanel method setSObjFromBufferMenuItemActionPerformed.
// GEN-LAST:event_editSObjMenuItemActionPerformed
private void setSObjFromBufferMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_setSObjFromBufferMenuItemActionPerformed
ScoreController controller = ScoreController.getInstance();
ScoreController.ScoreObjectBuffer buffer = controller.getScoreObjectBuffer();
if (buffer.scoreObjects.size() == 1) {
ScoreObject scoreObj = buffer.scoreObjects.get(0);
if (!(scoreObj instanceof SoundObject)) {
return;
}
SoundObject sObj = (SoundObject) scoreObj;
SoundObject copy = sObj.deepCopy();
copy.setStartTime(0.0f);
copy.setSubjectiveDuration(4);
copy.setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
patternLayer.setSoundObject(copy);
editSoundObject();
}
}
use of blue.ui.core.score.ScoreController in project blue by kunstmusik.
the class PatternLayerPanel method otherMenuButtonActionPerformed.
// GEN-LAST:event_soloToggleButtonActionPerformed
@SuppressWarnings("unchecked")
private void otherMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_otherMenuButtonActionPerformed
Class<? extends SoundObject> current = patternLayer.getSoundObject().getClass();
for (Component c : changeSObjMenu.getMenuComponents()) {
JMenuItem menuItem = (JMenuItem) c;
Class<? extends SoundObject> clazz = (Class<? extends SoundObject>) menuItem.getClientProperty("sObjClass");
menuItem.setEnabled(!current.equals(clazz));
}
ScoreController controller = ScoreController.getInstance();
Collection<? extends ScoreObject> selected = controller.getSelectedScoreObjects();
setSObjFromBufferMenuItem.setEnabled(selected.size() == 1 && selected.iterator().next() instanceof SoundObject);
jPopupMenu1.show(otherMenuButton, 0, otherMenuButton.getHeight());
}
use of blue.ui.core.score.ScoreController 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;
}
}
}
Aggregations