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);
}
}
}
}
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);
}
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);
}
}
Aggregations