Search in sources :

Example 11 with ScoreObjectLayer

use of blue.score.layers.ScoreObjectLayer 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;
        }
    }
}
Also used : ScoreController(blue.ui.core.score.ScoreController) ScorePath(blue.ui.core.score.ScorePath) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ScoreObject(blue.score.ScoreObject) TimeState(blue.score.TimeState) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Point(java.awt.Point)

Example 12 with ScoreObjectLayer

use of blue.score.layers.ScoreObjectLayer in project blue by kunstmusik.

the class MultiLineSelectionMouseProcessor method mousePressed.

@Override
public void mousePressed(MouseEvent e) {
    if (!isMultiLineMode()) {
        return;
    }
    AlphaMarquee marquee = scoreTC.getMarquee();
    Point p = SwingUtilities.convertPoint(scoreTC.getScorePanel(), e.getPoint(), marquee);
    if (marquee.isVisible() && marquee.contains(p)) {
        return;
    }
    e.consume();
    RealtimeRenderManager.getInstance().stopAuditioning();
    timeState = scoreTC.getTimeState();
    SoundObjectView sObjView;
    ScorePath scorePath = ScoreController.getInstance().getScorePath();
    Layer layer = scorePath.getGlobalLayerForY(e.getY());
    if (layer == null || !(layer instanceof ScoreObjectLayer)) {
        marquee.setVisible(false);
        return;
    }
    startLayer = lastLayer = layer;
    allLayers = scorePath.getAllLayers();
    if (UiUtilities.isRightMouseButton(e)) {
    // showPopup(comp, e);
    } else if (SwingUtilities.isLeftMouseButton(e)) {
        startX = Math.max(e.getX(), 0);
        double startTime = startX / (double) timeState.getPixelSecond();
        if (timeState.isSnapEnabled()) {
            startTime = ScoreUtilities.getSnapValueStart(startTime, timeState.getSnapValue());
            startX = (int) (startTime * timeState.getPixelSecond());
        }
        startTopBottom = getTopBottomForLayer(layer, scorePath.getScore());
        scoreTC.getMarquee().setStart(new Point(startX, startTopBottom[0]));
        scoreTC.getMarquee().setVisible(true);
        ScoreController.getInstance().setSelectedScoreObjects(null);
        selection.reset();
        selection.startSelection(startTime, startTime);
    }
}
Also used : ScorePath(blue.ui.core.score.ScorePath) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Point(java.awt.Point) AlphaMarquee(blue.components.AlphaMarquee) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer)

Example 13 with ScoreObjectLayer

use of blue.score.layers.ScoreObjectLayer in project blue by kunstmusik.

the class MultiLineSelectionMouseProcessor method mouseDragged.

@Override
public void mouseDragged(MouseEvent e) {
    if (!isMultiLineMode()) {
        return;
    }
    e.consume();
    AlphaMarquee marquee = scoreTC.getMarquee();
    if (SwingUtilities.isLeftMouseButton(e)) {
        int x = Math.max(e.getX(), 0);
        double mouseDragTime = x / (double) timeState.getPixelSecond();
        if (timeState.isSnapEnabled()) {
            mouseDragTime = ScoreUtilities.getSnapValueMove(mouseDragTime, timeState.getSnapValue());
            x = (int) (mouseDragTime * timeState.getPixelSecond());
        }
        ScorePath scorePath = ScoreController.getInstance().getScorePath();
        Layer layer = scorePath.getGlobalLayerForY(e.getY());
        if (layer != null && (layer instanceof ScoreObjectLayer)) {
            lastLayer = layer;
        }
        // if (!(layer instanceof ScoreObjectLayer)) {
        // return;
        // }
        int[] topBottom = getTopBottomForLayer(lastLayer, scorePath.getScore());
        int leftX, rightX, topY, bottomY;
        int startLayerIndex, endLayerIndex;
        if (x < startX) {
            leftX = x;
            rightX = startX;
        } else {
            leftX = startX;
            rightX = x;
        }
        if (topBottom[0] < startTopBottom[0]) {
            topY = topBottom[0];
            bottomY = startTopBottom[1];
            startLayerIndex = allLayers.indexOf(lastLayer);
            endLayerIndex = allLayers.indexOf(startLayer);
        } else {
            topY = startTopBottom[0];
            bottomY = topBottom[1];
            startLayerIndex = allLayers.indexOf(startLayer);
            endLayerIndex = allLayers.indexOf(lastLayer);
        }
        leftX = Math.max(leftX, 0);
        topY = Math.max(topY, 0);
        marquee.setStart(new Point(leftX, topY));
        marquee.setDragPoint(new Point(rightX, bottomY));
        double start = leftX / (double) timeState.getPixelSecond();
        double end = rightX / (double) timeState.getPixelSecond();
        marquee.startTime = start;
        marquee.endTime = end;
        List<Layer> currentLayers = allLayers.subList(startLayerIndex, endLayerIndex + 1);
        selection.updateSelection(start, end, currentLayers);
    }
    checkScroll(e);
}
Also used : ScorePath(blue.ui.core.score.ScorePath) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Point(java.awt.Point) AlphaMarquee(blue.components.AlphaMarquee) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Point(java.awt.Point)

Example 14 with ScoreObjectLayer

use of blue.score.layers.ScoreObjectLayer 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);
    }
}
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 15 with ScoreObjectLayer

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

Aggregations

ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)18 Layer (blue.score.layers.Layer)15 ScoreObject (blue.score.ScoreObject)11 Point (java.awt.Point)8 ScorePath (blue.ui.core.score.ScorePath)7 ArrayList (java.util.ArrayList)7 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)5 SoundLayer (blue.SoundLayer)4 ScoreController (blue.ui.core.score.ScoreController)4 BlueData (blue.BlueData)3 SoundObjectLibrary (blue.SoundObjectLibrary)3 Instance (blue.soundObject.Instance)3 SoundObject (blue.soundObject.SoundObject)3 MoveScoreObjectsEdit (blue.ui.core.score.undo.MoveScoreObjectsEdit)3 AlphaMarquee (blue.components.AlphaMarquee)2 Score (blue.score.Score)1 TimeState (blue.score.TimeState)1 LayerGroup (blue.score.layers.LayerGroup)1 PolyObject (blue.soundObject.PolyObject)1 ScoreTimeCanvas (blue.ui.core.score.layers.soundObject.ScoreTimeCanvas)1