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