use of blue.score.TimeState in project blue by kunstmusik.
the class ProjectUpgrader_2_3_0 method upgradeTempo.
protected boolean upgradeTempo(Element data) {
Element element = data.getElement("soundObject");
Element tempoNode = data.getElement("tempo");
if (element == null && tempoNode == null) {
return false;
}
Element score = data.addElement("score");
if (element != null) {
Element elem = data.removeElement("soundObject");
TimeState timeState = TimeState.loadFromXML(elem);
score.addElement(timeState.saveAsXML());
score.addElement((Element) elem.clone());
}
if (tempoNode != null) {
Element elem = data.removeElement("tempo");
score.addElement((Element) elem.clone());
}
return true;
}
use of blue.score.TimeState in project blue by kunstmusik.
the class ScoreTopComponent method scoreBarScoreSelected.
/* SCORE BAR LISTENER METHODS */
// @Override
public void scoreBarScoreSelected(Score score, int scrollX, int scrollY) {
if (this.currentTimeState != null) {
this.currentTimeState.removePropertyChangeListener(this);
}
ScoreController.getInstance().setSelectedScoreObjects(null);
this.clearAll();
if (score != null) {
layerPanel.removeAll();
layerHeaderPanel.removeAll();
for (LayerGroup layerGroup : score) {
addPanelsForLayerGroup(-1, layerGroup, score.getTimeState());
}
checkSize();
layerPanel.revalidate();
layerHeaderPanel.revalidate();
TimeState timeState = score.getTimeState();
tempoEditor.setTimeState(timeState);
tempoEditor.setVisible(true);
tempoControlPanel.setVisible(true);
timeBar.setRootTimeline(true);
timeBar.setTimeState(timeState);
timeProperties.setTimeState(timeState);
mouseWheelListener.setTimeState(timeState);
this.currentTimeState = timeState;
timeState.addPropertyChangeListener(this);
scrollPane.repaint();
ModeManager.getInstance().setMode(ModeManager.getInstance().getMode());
int startTime = (int) (data.getRenderStartTime() * timeState.getPixelSecond());
int endTime = (int) (data.getRenderEndTime() * timeState.getPixelSecond());
renderStartPointer.setVisible(true);
renderLoopPointer.setVisible(true);
renderTimePointer.setVisible(true);
scorePanel.add(marquee, new Integer(500));
marquee.setVisible(false);
updateRenderStartPointerX(startTime, false);
updateRenderLoopPointerX(endTime);
renderTimePointer.setLocation(-1, 0);
updateRenderTimePointer();
layerHeaderPanel.repaint();
setHorizontalScrollValue(scrollX);
setVerticalScrollValue(scrollY);
}
}
use of blue.score.TimeState in project blue by kunstmusik.
the class ResizeScoreObjectsListener method resizeScoreObjectRight.
private void resizeScoreObjectRight(MouseEvent e) {
if (selectedScoreObjects == null) {
return;
}
TimeState timeState = scoreTC.getTimeState();
int xVal = e.getX();
double newEnd;
if (timeState.isSnapEnabled()) {
final double snapValue = timeState.getSnapValue();
double endTime = ScoreUtilities.getSnapValueMove(xVal / (double) timeState.getPixelSecond(), snapValue);
double minTime = ScoreUtilities.getSnapValueMove(startTimes[0] + snapValue / 2, snapValue);
newEnd = (endTime < minTime) ? minTime : endTime;
} else {
double endTime = (double) xVal / timeState.getPixelSecond();
double minTime = startTimes[0] + ((double) EDGE / timeState.getPixelSecond());
newEnd = (endTime < minTime) ? minTime : endTime;
}
if (newEnd > endTimes[0] + maxDiffTime) {
newEnd = endTimes[0] + maxDiffTime;
}
selectedScoreObjects[0].resizeRight(newEnd);
}
use of blue.score.TimeState 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;
}
}
}
use of blue.score.TimeState in project blue by kunstmusik.
the class ScoreTopComponent method scoreBarLayerGroupSelected.
// @Override
public void scoreBarLayerGroupSelected(LayerGroup layerGroup, int scrollX, int scrollY) {
if (!(layerGroup instanceof PolyObject)) {
return;
}
ScoreController.getInstance().setSelectedScoreObjects(null);
PolyObject pObj = (PolyObject) layerGroup;
tempoEditor.setVisible(false);
tempoControlPanel.setVisible(false);
if (this.currentTimeState != null) {
this.currentTimeState.removePropertyChangeListener(this);
}
this.clearAll();
if (layerGroup != null) {
layerPanel.removeAll();
layerHeaderPanel.removeAll();
addPanelsForLayerGroup(-1, layerGroup, pObj.getTimeState());
checkSize();
layerPanel.revalidate();
layerHeaderPanel.revalidate();
TimeState timeState = pObj.getTimeState();
tempoEditor.setTimeState(timeState);
tempoEditor.setVisible(true);
tempoControlPanel.setVisible(true);
timeBar.setRootTimeline(false);
timeBar.setTimeState(timeState);
timeProperties.setTimeState(timeState);
mouseWheelListener.setTimeState(timeState);
this.currentTimeState = timeState;
timeState.addPropertyChangeListener(this);
scrollPane.repaint();
ModeManager.getInstance().setMode(ModeManager.getInstance().getMode());
renderStartPointer.setVisible(false);
renderLoopPointer.setVisible(false);
renderTimePointer.setVisible(false);
layerHeaderPanel.repaint();
setHorizontalScrollValue(scrollX);
setVerticalScrollValue(scrollY);
}
}
Aggregations