Search in sources :

Example 6 with TimeState

use of blue.score.TimeState in project blue by kunstmusik.

the class ScoreTopComponent method propertyChange.

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getSource() == renderTimeManager) {
        // if (this.pObj.isRoot()) {
        if (evt.getPropertyName().equals(RenderTimeManager.RENDER_START)) {
            this.renderStart = ((Double) evt.getNewValue()).doubleValue();
            this.timePointer = -1.0f;
            updateRenderTimePointer();
        }
    /* else if (prop.equals(RenderTimeManager.TIME_POINTER)) {
             this.timePointer = ((Double) evt.getNewValue()).doubleValue();
             updateRenderTimePointer();
             } */
    // } else {
    // this.timePointer = -1.0f;
    // updateRenderTimePointer();
    // }
    } else if (evt.getSource() == currentTimeState) {
        if (evt.getPropertyName().equals("pixelSecond")) {
            double val = data.getRenderStartTime();
            int newX = (int) (val * currentTimeState.getPixelSecond());
            updateRenderStartPointerX(newX, true);
            val = data.getRenderEndTime();
            newX = (int) (val * currentTimeState.getPixelSecond());
            updateRenderLoopPointerX(newX);
        }
    } else if (evt.getSource() == data) {
        boolean isRenderStartTime = evt.getPropertyName().equals("renderStartTime");
        boolean isRenderLoopTime = evt.getPropertyName().equals("renderLoopTime");
        if (isRenderStartTime || isRenderLoopTime) {
            if (data.getScore() == null) {
                return;
            }
            double val = ((Double) evt.getNewValue()).doubleValue();
            // FIXME
            TimeState timeState = data.getScore().getTimeState();
            int newX = (int) (val * timeState.getPixelSecond());
            if (isRenderStartTime) {
                updateRenderStartPointerX(newX, true);
            } else if (isRenderLoopTime) {
                updateRenderLoopPointerX(newX);
            }
        }
    }
}
Also used : TimeState(blue.score.TimeState)

Example 7 with TimeState

use of blue.score.TimeState in project blue by kunstmusik.

the class ResizeScoreObjectsListener method resizeScoreObjectLeft.

private void resizeScoreObjectLeft(MouseEvent e) {
    if (selectedScoreObjects == null) {
        return;
    }
    TimeState timeState = scoreTC.getTimeState();
    int xVal = e.getX();
    double newStart;
    if (timeState.isSnapEnabled()) {
        double snapValue = timeState.getSnapValue();
        double endTime = ScoreUtilities.getSnapValueMove(endTimes[0] - (snapValue * .5001f), snapValue);
        newStart = ScoreUtilities.getSnapValueMove(xVal / (double) timeState.getPixelSecond(), snapValue);
        newStart = (newStart < 0.0f) ? 0.0f : newStart;
        if (newStart > endTime) {
            newStart = endTime;
        }
    } else {
        double maxTime = endTimes[0] - ((double) EDGE / timeState.getPixelSecond());
        if (xVal < 0) {
            xVal = 0;
        }
        newStart = (double) xVal / timeState.getPixelSecond();
        if (newStart > maxTime) {
            newStart = maxTime;
        }
    }
    if (newStart < startTimes[0] + minDiffTime) {
        newStart = startTimes[0] + minDiffTime;
    }
    selectedScoreObjects[0].resizeLeft(newStart);
// selectedScoreObjects[0].setStartTime(newStart);
// selectedScoreObjects[0].setSubjectiveDuration(endTimes[0] - newStart);
}
Also used : TimeState(blue.score.TimeState) Point(java.awt.Point)

Example 8 with TimeState

use of blue.score.TimeState in project blue by kunstmusik.

the class AddSoundObjectActionsPresenter method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (pRef == null || sTimeCanvasRef == null) {
        return;
    }
    ScoreTimeCanvas sTimeCanvas = sTimeCanvasRef.get();
    Point p = pRef.get();
    int sLayerIndex = sTimeCanvas.getPolyObject().getLayerNumForY((int) p.getY());
    ScoreTopComponent stc = (ScoreTopComponent) WindowManager.getDefault().findTopComponent("ScoreTopComponent");
    LazyPlugin<SoundObject> plugin = (LazyPlugin<SoundObject>) ((JMenuItem) e.getSource()).getClientProperty("plugin");
    try {
        SoundObject sObj = (SoundObject) plugin.getInstance().getClass().newInstance();
        if (sObj instanceof PolyObject) {
            ((PolyObject) sObj).newLayerAt(0);
        }
        TimeState timeState = stc.getTimeState();
        double start = (double) p.getX() / timeState.getPixelSecond();
        if (timeState.isSnapEnabled()) {
            start = ScoreUtilities.getSnapValueStart(start, timeState.getSnapValue());
        }
        sObj.setStartTime(start);
        sTimeCanvas.getPolyObject().addSoundObject(sLayerIndex, sObj);
        BlueUndoManager.setUndoManager("score");
        BlueUndoManager.addEdit(new AddScoreObjectEdit(sTimeCanvas.getPolyObject().get(sLayerIndex), sObj));
    } catch (InstantiationException | IllegalAccessException ex) {
        Exceptions.printStackTrace(ex);
    }
}
Also used : Point(java.awt.Point) Point(java.awt.Point) LazyPlugin(blue.ui.nbutilities.lazyplugin.LazyPlugin) ScoreTopComponent(blue.ui.core.score.ScoreTopComponent) SoundObject(blue.soundObject.SoundObject) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) ScoreTimeCanvas(blue.ui.core.score.layers.soundObject.ScoreTimeCanvas) TimeState(blue.score.TimeState) PolyObject(blue.soundObject.PolyObject)

Aggregations

TimeState (blue.score.TimeState)8 Point (java.awt.Point)4 PolyObject (blue.soundObject.PolyObject)2 ScoreObject (blue.score.ScoreObject)1 Layer (blue.score.layers.Layer)1 LayerGroup (blue.score.layers.LayerGroup)1 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)1 SoundObject (blue.soundObject.SoundObject)1 ScoreController (blue.ui.core.score.ScoreController)1 ScorePath (blue.ui.core.score.ScorePath)1 ScoreTopComponent (blue.ui.core.score.ScoreTopComponent)1 ScoreTimeCanvas (blue.ui.core.score.layers.soundObject.ScoreTimeCanvas)1 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)1 LazyPlugin (blue.ui.nbutilities.lazyplugin.LazyPlugin)1 Element (electric.xml.Element)1