use of blue.score.layers.ScoreObjectLayer in project blue by kunstmusik.
the class Score method getLayerGroupsForScoreObjects.
public List<LayerGroup> getLayerGroupsForScoreObjects(Collection<? extends ScoreObject> scoreObjects) {
List<LayerGroup> retVal = new ArrayList<>();
for (LayerGroup<? extends Layer> layerGroup : this) {
for (Layer layer : layerGroup) {
boolean found = false;
if (layer instanceof ScoreObjectLayer) {
ScoreObjectLayer scoreLayer = (ScoreObjectLayer) layer;
if (!Collections.disjoint(scoreLayer, scoreObjects)) {
retVal.add(layerGroup);
found = true;
}
}
if (found) {
break;
}
}
}
return retVal;
}
use of blue.score.layers.ScoreObjectLayer in project blue by kunstmusik.
the class ImportSoundObjectAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
ScoreTimeCanvas sCanvas = (ScoreTimeCanvas) lGroupPanel;
List<File> retVal = FileChooserManager.getDefault().showOpenDialog(IMPORT_DIALOG, WindowManager.getDefault().getMainWindow());
if (!retVal.isEmpty()) {
File f = retVal.get(0);
Document doc;
try {
doc = new Document(f);
Element root = doc.getRoot();
if (root.getName().equals("soundObject")) {
SoundObject tempSobj = (SoundObject) ObjectUtilities.loadFromXML(root, null);
int start = p.x;
Layer layer = scorePath.getGlobalLayerForY(p.y);
if (timeState.isSnapEnabled()) {
int snapPixels = (int) (timeState.getSnapValue() * timeState.getPixelSecond());
start = start - (start % snapPixels);
}
float startTime = (float) start / timeState.getPixelSecond();
tempSobj.setStartTime(startTime);
((SoundLayer) layer).add(tempSobj);
AddScoreObjectEdit edit = new AddScoreObjectEdit((ScoreObjectLayer) layer, tempSobj);
BlueUndoManager.setUndoManager("score");
BlueUndoManager.addEdit(edit);
} else {
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: File did not contain Sound Object", "Error", JOptionPane.ERROR_MESSAGE);
}
} catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: Could not read Sound Object from file", "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
use of blue.score.layers.ScoreObjectLayer in project blue by kunstmusik.
the class SelectAllAfterAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
// FIXME -
// if (p.y < 0 || p.y > comp.getHeight()) {
// return;
// }
float pointTime = (float) p.x / timeState.getPixelSecond();
List<ScoreObject> newSelected = new ArrayList<>();
List<Layer> allLayers = scorePath.getAllLayers();
for (Layer layer : allLayers) {
if (layer instanceof ScoreObjectLayer) {
ScoreObjectLayer<ScoreObject> sLayer = (ScoreObjectLayer) layer;
for (ScoreObject scoreObject : sLayer) {
if (scoreObject.getStartTime() >= pointTime) {
newSelected.add(scoreObject);
}
}
}
}
ScoreController.getInstance().setSelectedScoreObjects(newSelected);
}
use of blue.score.layers.ScoreObjectLayer in project blue by kunstmusik.
the class SelectAllBeforeAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
// FIXME
// JComponent comp = ((JComponent) lgPanel);
//
// if (p.y < 0 || p.y > comp.getHeight()) {
// return;
// }
float pointTime = (float) p.x / timeState.getPixelSecond();
List<ScoreObject> newSelected = new ArrayList<>();
List<Layer> allLayers = scorePath.getAllLayers();
for (Layer layer : allLayers) {
if (layer instanceof ScoreObjectLayer) {
ScoreObjectLayer<ScoreObject> sLayer = (ScoreObjectLayer) layer;
for (ScoreObject scoreObject : sLayer) {
if (scoreObject.getStartTime() + scoreObject.getSubjectiveDuration() <= pointTime) {
newSelected.add(scoreObject);
}
}
}
}
ScoreController.getInstance().setSelectedScoreObjects(newSelected);
}
use of blue.score.layers.ScoreObjectLayer in project blue by kunstmusik.
the class ScoreController method deleteScoreObjects.
public void deleteScoreObjects() {
if (lookup == null || content == null) {
return;
}
Collection<? extends ScoreObject> scoreObjects = ScoreController.getInstance().getSelectedScoreObjects();
Score score = lookup.lookup(Score.class);
if (score == null) {
throw new RuntimeException("Score object not set in ScoreController: internal error");
}
if (scoreObjects.isEmpty()) {
return;
}
List<Layer> layers = getScorePath().getAllLayers();
RemoveScoreObjectEdit top = null;
for (ScoreObject scoreObj : scoreObjects) {
RemoveScoreObjectEdit edit = null;
for (Layer layer : layers) {
if (layer.remove(scoreObj)) {
edit = new RemoveScoreObjectEdit((ScoreObjectLayer) layer, scoreObj);
break;
}
}
if (edit == null) {
throw new RuntimeException("Error: Unable to find Layer to remove ScoreObject: Internal Error");
}
if (top == null) {
top = edit;
} else {
top.appendNextEdit(edit);
}
content.remove(scoreObj);
}
BlueUndoManager.setUndoManager("score");
BlueUndoManager.addEdit(top);
}
Aggregations