Search in sources :

Example 16 with PolyObject

use of blue.soundObject.PolyObject in project blue by kunstmusik.

the class ReplaceWithBufferSoundObjectAction method getReplacementObject.

protected SoundObject getReplacementObject(ScoreController.ScoreObjectBuffer buffer, List<Instance> instances) {
    if (buffer.scoreObjects.size() == 1) {
        SoundObject sObj = (SoundObject) buffer.scoreObjects.get(0).deepCopy();
        if (sObj instanceof Instance) {
            instances.add((Instance) sObj);
        }
        return sObj;
    }
    PolyObject pObj = new PolyObject();
    int minLayer = Integer.MAX_VALUE;
    int maxLayer = Integer.MIN_VALUE;
    for (Integer layerIndex : buffer.layerIndexes) {
        if (layerIndex < minLayer) {
            minLayer = layerIndex;
        }
        if (layerIndex > maxLayer) {
            maxLayer = layerIndex;
        }
    }
    int numLayers = maxLayer - minLayer + 1;
    for (int i = 0; i < numLayers; i++) {
        pObj.newLayerAt(-1);
    }
    for (int i = 0; i < buffer.scoreObjects.size(); i++) {
        ScoreObject scoreObj = buffer.scoreObjects.get(i);
        int layerIndex = buffer.layerIndexes.get(i);
        SoundLayer layer = pObj.get(layerIndex - minLayer);
        SoundObject clone = (SoundObject) scoreObj.deepCopy();
        layer.add(clone);
        if (clone instanceof Instance) {
            instances.add((Instance) clone);
        }
    }
    return pObj;
}
Also used : SoundObject(blue.soundObject.SoundObject) Instance(blue.soundObject.Instance) SoundLayer(blue.SoundLayer) ScoreObject(blue.score.ScoreObject) PolyObject(blue.soundObject.PolyObject) Point(java.awt.Point)

Example 17 with PolyObject

use of blue.soundObject.PolyObject in project blue by kunstmusik.

the class ExportAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (scoreObjects.size() == 1 && soundObjects.size() == 1) {
        File retVal = FileChooserManager.getDefault().showSaveDialog(EXPORT_DIALOG, WindowManager.getDefault().getMainWindow());
        if (retVal != null) {
            File f = retVal;
            if (f.exists()) {
                int overWrite = JOptionPane.showConfirmDialog(SwingUtilities.getRoot(WindowManager.getDefault().getMainWindow()), "Please confirm you would like to overwrite this file.");
                if (overWrite != JOptionPane.OK_OPTION) {
                    return;
                }
            }
            SoundObject sObj = soundObjects.iterator().next();
            if ((sObj instanceof Instance) || ((sObj instanceof PolyObject) && containsInstance((PolyObject) sObj))) {
                JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: Export of Instance or " + "PolyObjects containing Instance " + "is not allowed.", "Error", JOptionPane.ERROR_MESSAGE);
                return;
            }
            Element node = sObj.saveAsXML(null);
            PrintWriter out;
            try {
                out = new PrintWriter(new FileWriter(f));
                out.print(node.toString());
                out.flush();
                out.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) Instance(blue.soundObject.Instance) Element(electric.xml.Element) FileWriter(java.io.FileWriter) IOException(java.io.IOException) File(java.io.File) PolyObject(blue.soundObject.PolyObject) PrintWriter(java.io.PrintWriter)

Example 18 with PolyObject

use of blue.soundObject.PolyObject in project blue by kunstmusik.

the class ScoreControllerTest method testDeleteScoreObjects.

/**
 * Test of deleteScoreObjects method, of class ScoreController.
 */
@Test
public void testDeleteScoreObjects() {
    Score score = scoreController.getScore();
    PolyObject pObj = (PolyObject) score.get(0);
    Lookup lookup = scoreController.getLookup();
    assertEquals(0, buffer.scoreObjects.size());
    assertEquals(2, pObj.get(1).size());
    assertEquals(2, lookup.lookupAll(ScoreObject.class).size());
    scoreController.deleteScoreObjects();
    assertEquals(0, buffer.scoreObjects.size());
    assertEquals(0, pObj.get(1).size());
    assertEquals(0, lookup.lookupAll(ScoreObject.class).size());
}
Also used : Score(blue.score.Score) GenericScore(blue.soundObject.GenericScore) Lookup(org.openide.util.Lookup) AbstractLookup(org.openide.util.lookup.AbstractLookup) PolyObject(blue.soundObject.PolyObject) Test(org.junit.Test)

Example 19 with PolyObject

use of blue.soundObject.PolyObject in project blue by kunstmusik.

the class ScoreControllerTest method testCutScoreObjects.

/**
 * Test of cutScoreObjects method, of class ScoreController.
 */
@Test
public void testCutScoreObjects() {
    System.out.println("cut score objects");
    Score score = scoreController.getScore();
    PolyObject pObj = (PolyObject) score.get(0);
    Lookup lookup = scoreController.getLookup();
    assertEquals(0, buffer.scoreObjects.size());
    assertEquals(2, pObj.get(1).size());
    assertEquals(2, lookup.lookupAll(ScoreObject.class).size());
    scoreController.cutScoreObjects();
    assertEquals(2, buffer.scoreObjects.size());
    assertEquals(0, pObj.get(1).size());
    assertEquals(0, lookup.lookupAll(ScoreObject.class).size());
}
Also used : Score(blue.score.Score) GenericScore(blue.soundObject.GenericScore) Lookup(org.openide.util.Lookup) AbstractLookup(org.openide.util.lookup.AbstractLookup) PolyObject(blue.soundObject.PolyObject) Test(org.junit.Test)

Example 20 with PolyObject

use of blue.soundObject.PolyObject 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);
    }
}
Also used : TimeState(blue.score.TimeState) PolyObject(blue.soundObject.PolyObject)

Aggregations

PolyObject (blue.soundObject.PolyObject)29 SoundLayer (blue.SoundLayer)10 SoundObject (blue.soundObject.SoundObject)10 BlueData (blue.BlueData)8 Score (blue.score.Score)8 Instance (blue.soundObject.Instance)6 ScoreObject (blue.score.ScoreObject)5 GenericScore (blue.soundObject.GenericScore)5 Point (java.awt.Point)4 ArrayList (java.util.ArrayList)4 SoundObjectLibrary (blue.SoundObjectLibrary)3 Layer (blue.score.layers.Layer)3 LayerGroup (blue.score.layers.LayerGroup)3 AudioFile (blue.soundObject.AudioFile)3 File (java.io.File)3 IOException (java.io.IOException)3 Test (org.junit.Test)3 AbstractLookup (org.openide.util.lookup.AbstractLookup)3 Mixer (blue.mixer.Mixer)2 TimeState (blue.score.TimeState)2