Search in sources :

Example 16 with ScoreObject

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);
}
Also used : SoundLayer(blue.SoundLayer) ArrayList(java.util.ArrayList) ScoreObject(blue.score.ScoreObject) GenericScore(blue.soundObject.GenericScore) SoundLayer(blue.SoundLayer) Layer(blue.score.layers.Layer) Test(org.junit.Test)

Example 17 with ScoreObject

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());
    }
}
Also used : AlignEdit(blue.ui.core.score.undo.AlignEdit) ScoreObject(blue.score.ScoreObject)

Example 18 with ScoreObject

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);
    }
}
Also used : ScorePath(blue.ui.core.score.ScorePath) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) ScoreObject(blue.score.ScoreObject)

Example 19 with ScoreObject

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);
    }
}
Also used : MoveScoreObjectsEdit(blue.ui.core.score.undo.MoveScoreObjectsEdit) ScorePath(blue.ui.core.score.ScorePath) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ScoreObject(blue.score.ScoreObject) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer)

Example 20 with ScoreObject

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));
}
Also used : ScoreObject(blue.score.ScoreObject)

Aggregations

ScoreObject (blue.score.ScoreObject)39 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)13 Layer (blue.score.layers.Layer)12 ArrayList (java.util.ArrayList)9 Point (java.awt.Point)8 BlueData (blue.BlueData)6 SoundObject (blue.soundObject.SoundObject)6 ScorePath (blue.ui.core.score.ScorePath)6 SoundLayer (blue.SoundLayer)5 AlignEdit (blue.ui.core.score.undo.AlignEdit)5 Instance (blue.soundObject.Instance)4 PolyObject (blue.soundObject.PolyObject)4 ScoreController (blue.ui.core.score.ScoreController)4 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)4 MoveScoreObjectsEdit (blue.ui.core.score.undo.MoveScoreObjectsEdit)4 SoundObjectLibrary (blue.SoundObjectLibrary)2 AlphaMarquee (blue.components.AlphaMarquee)2 Score (blue.score.Score)2 GenericScore (blue.soundObject.GenericScore)2 Test (org.junit.Test)2