Search in sources :

Example 1 with ScoreObjectLayer

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;
}
Also used : ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ObservableArrayList(blue.util.ObservableArrayList) ArrayList(java.util.ArrayList) LayerGroup(blue.score.layers.LayerGroup) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer)

Example 2 with ScoreObjectLayer

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);
        }
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) SoundLayer(blue.SoundLayer) Element(electric.xml.Element) ScoreTimeCanvas(blue.ui.core.score.layers.soundObject.ScoreTimeCanvas) Document(electric.xml.Document) File(java.io.File) SoundLayer(blue.SoundLayer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Layer(blue.score.layers.Layer) Point(java.awt.Point)

Example 3 with ScoreObjectLayer

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);
}
Also used : ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ScoreObject(blue.score.ScoreObject) ArrayList(java.util.ArrayList) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer)

Example 4 with ScoreObjectLayer

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);
}
Also used : ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ScoreObject(blue.score.ScoreObject) ArrayList(java.util.ArrayList) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer)

Example 5 with ScoreObjectLayer

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);
}
Also used : Score(blue.score.Score) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ScoreObject(blue.score.ScoreObject) RemoveScoreObjectEdit(blue.ui.core.score.undo.RemoveScoreObjectEdit) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer)

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