use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class AddSoundObjectActionsPresenter method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (pRef == null || sTimeCanvasRef == null) {
return;
}
ScoreTimeCanvas sTimeCanvas = sTimeCanvasRef.get();
Point p = pRef.get();
int sLayerIndex = sTimeCanvas.getPolyObject().getLayerNumForY((int) p.getY());
ScoreTopComponent stc = (ScoreTopComponent) WindowManager.getDefault().findTopComponent("ScoreTopComponent");
LazyPlugin<SoundObject> plugin = (LazyPlugin<SoundObject>) ((JMenuItem) e.getSource()).getClientProperty("plugin");
try {
SoundObject sObj = (SoundObject) plugin.getInstance().getClass().newInstance();
if (sObj instanceof PolyObject) {
((PolyObject) sObj).newLayerAt(0);
}
TimeState timeState = stc.getTimeState();
double start = (double) p.getX() / timeState.getPixelSecond();
if (timeState.isSnapEnabled()) {
start = ScoreUtilities.getSnapValueStart(start, timeState.getSnapValue());
}
sObj.setStartTime(start);
sTimeCanvas.getPolyObject().addSoundObject(sLayerIndex, sObj);
BlueUndoManager.setUndoManager("score");
BlueUndoManager.addEdit(new AddScoreObjectEdit(sTimeCanvas.getPolyObject().get(sLayerIndex), sObj));
} catch (InstantiationException | IllegalAccessException ex) {
Exceptions.printStackTrace(ex);
}
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class PasteAsPolyObjectAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
SoundObjectLibrary sObjLib = data.getSoundObjectLibrary();
List<Instance> instanceSoundObjects = new ArrayList<>();
ScoreController.ScoreObjectBuffer buffer = ScoreController.getInstance().getScoreObjectBuffer();
double start = (double) p.x / timeState.getPixelSecond();
if (timeState.isSnapEnabled()) {
start = ScoreUtilities.getSnapValueStart(start, timeState.getSnapValue());
}
int minLayer = Integer.MAX_VALUE;
int maxLayer = Integer.MIN_VALUE;
for (Integer layerIndex : 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 < scoreObjects.size(); i++) {
ScoreObject scoreObj = scoreObjects.get(i);
int layerIndex = layerIndexes.get(i);
SoundLayer layer = pObj.get(layerIndex - minLayer);
SoundObject clone = (SoundObject) scoreObj.deepCopy();
layer.add(clone);
if (clone instanceof Instance) {
instanceSoundObjects.add((Instance) clone);
}
}
sObjLib.checkAndAddInstanceSoundObjects(instanceSoundObjects);
pObj.normalizeSoundObjects();
pObj.setStartTime(start);
final ScoreObjectLayer layer = (ScoreObjectLayer) scorePath.getGlobalLayerForY(p.y);
layer.add(pObj);
AddScoreObjectEdit edit = new AddScoreObjectEdit(layer, pObj);
BlueUndoManager.setUndoManager("score");
BlueUndoManager.addEdit(edit);
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class PasteSoundObjectAction method getInstancesFromPolyObject.
private void getInstancesFromPolyObject(List<Instance> instanceSoundObjects, PolyObject pObj) {
for (SoundLayer layer : pObj) {
for (SoundObject sObj : layer) {
if (sObj instanceof Instance) {
Instance instance = (Instance) sObj;
instanceSoundObjects.add(instance);
} else if (sObj instanceof PolyObject) {
getInstancesFromPolyObject(instanceSoundObjects, (PolyObject) sObj);
}
}
}
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class ScoreTimeCanvas method getToolTipText.
@Override
public String getToolTipText(MouseEvent e) {
String tip = null;
Object obj = this.getComponentAt(e.getPoint());
if (obj instanceof SoundObjectView) {
SoundObject sObj = ((SoundObjectView) obj).getSoundObject();
double subjectiveDuration = sObj.getSubjectiveDuration();
double startTime = sObj.getStartTime();
Object[] args = { sObj.getName(), ObjectUtilities.getShortClassName(sObj), new Double(startTime), new Double(subjectiveDuration), new Double(startTime + subjectiveDuration) };
tip = toolTipFormat.format(args);
}
return tip;
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class ScoreTimeCanvas method setPolyObject.
public void setPolyObject(PolyObject pObj, TimeState timeState) {
Component[] components = sObjPanel.getComponents();
for (int i = 0; i < components.length; i++) {
Component c = components[i];
if (c instanceof SoundObjectView) {
SoundObjectView sObjView = (SoundObjectView) c;
sObjView.cleanup();
}
}
sObjPanel.removeAll();
this.soundObjectToViewMap.clear();
marquee.setVisible(false);
if (this.getPolyObject() != null) {
this.timeState.removePropertyChangeListener(this);
this.getPolyObject().removeLayerGroupListener(this);
SoundLayer tempLayer;
for (int i = 0; i < pObj.size(); i++) {
tempLayer = pObj.get(i);
tempLayer.removePropertyChangeListener(heightListener);
tempLayer.removeSoundLayerListener(this);
}
}
this.pObj = pObj;
this.timeState = timeState;
dropTargetListener.setTimeState(timeState);
if (this.getPolyObject() != null) {
timeState.addPropertyChangeListener(this);
pObj.addLayerGroupListener(this);
}
this.automationPanel.setLayerGroup(pObj, timeState);
// content.set(Collections.emptyList(), null);
// TODO - REFACTOR THIS OUT TO POLY OBJECT CONTROLLER
SoundLayer tempLayer;
List<SoundObject> sObjects;
int size = pObj.size();
if (size != 0) {
for (int i = 0; i < size; i++) {
tempLayer = pObj.get(i);
tempLayer.addPropertyChangeListener(heightListener);
tempLayer.addSoundLayerListener(this);
for (SoundObject tempSObj : tempLayer) {
addSoundObjectView(i, tempSObj);
}
}
} else {
JOptionPane.showMessageDialog(null, "ScoreTimeCanvas: setPObj found size == 0");
}
this.checkSize(true);
this.revalidate();
this.repaint();
}
Aggregations