use of blue.orchestra.BlueSynthBuilder in project blue by kunstmusik.
the class SubChannelListPanel method reconcileNameChangeInBlueArrangement.
/**
* A hack to explicitly walk the current blue orchestra to find any
* BlueSynthBuilder's that contain BSBSubChannelDropdown's and to reconcile
* the name change.
*
* @param oldName
* @param newName
*/
private void reconcileNameChangeInBlueArrangement(String oldName, String newName) {
BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
if (data == null) {
return;
}
Arrangement arr = data.getArrangement();
for (int i = 0; i < arr.size(); i++) {
Instrument instr = arr.getInstrument(i);
if (instr instanceof BlueSynthBuilder) {
BlueSynthBuilder bsb = (BlueSynthBuilder) instr;
BSBGraphicInterface bsbInterface = bsb.getGraphicInterface();
for (BSBObject bsbObj : bsbInterface.getAllSet()) {
if (bsbObj instanceof BSBSubChannelDropdown) {
BSBSubChannelDropdown bsbSubDrop = (BSBSubChannelDropdown) bsbObj;
if (bsbSubDrop.getChannelOutput().equals(oldName)) {
bsbSubDrop.setChannelOutput(newName);
}
}
}
}
}
}
use of blue.orchestra.BlueSynthBuilder in project blue by kunstmusik.
the class BlueSynthBuilderEditor method editInstrument.
@Override
public void editInstrument(Instrument instr) {
if (instr == null) {
this.bsb = null;
return;
}
if (!(instr instanceof BlueSynthBuilder)) {
this.bsb = null;
return;
}
this.bsb = (BlueSynthBuilder) instr;
PresetGroup presetGroup = bsb.getPresetGroup();
BSBGraphicInterface graphicInterface = bsb.getGraphicInterface();
Platform.runLater(() -> interfaceEditor.editInterface(graphicInterface, presetGroup));
this.codeEditor.editBlueSynthBuilder(bsb);
this.udoPanel.editOpcodeList(bsb.getOpcodeList());
}
use of blue.orchestra.BlueSynthBuilder in project blue by kunstmusik.
the class ArrangementEditPanel method pasteInstrument.
public void pasteInstrument() {
Object obj = CopyBuffer.getBufferedObject(CopyBuffer.INSTRUMENT);
if (obj == null || !(obj instanceof Instrument)) {
return;
}
Instrument instr = (Instrument) obj;
Instrument clone = (Instrument) instr.deepCopy();
if (clone instanceof BlueSynthBuilder) {
((BlueSynthBuilder) clone).clearParameters();
}
addInstrument(clone);
}
use of blue.orchestra.BlueSynthBuilder in project blue by kunstmusik.
the class ArrangementEditPanel method convertToBSB.
public void convertToBSB() {
int selectedRow = arrangementTable.getSelectedRow();
if (selectedRow < 0) {
return;
}
String instrumentId = (String) arrangement.getValueAt(selectedRow, 1);
Instrument instr = arrangement.getInstrument(selectedRow);
if (instr instanceof GenericInstrument) {
GenericInstrument genInstr = (GenericInstrument) instr;
BlueSynthBuilder bsb = new BlueSynthBuilder();
bsb.setName(genInstr.getName());
bsb.setComment(genInstr.getComment());
bsb.setGlobalOrc(genInstr.getGlobalOrc());
bsb.setGlobalSco(genInstr.getGlobalSco());
bsb.setInstrumentText(genInstr.getText());
bsb.setOpcodeList(genInstr.getOpcodeList());
arrangement.replaceInstrument(instrumentId, bsb);
}
}
use of blue.orchestra.BlueSynthBuilder in project blue by kunstmusik.
the class InstrumentTreeDropTarget method drop.
@Override
public void drop(DropTargetDropEvent dtde) {
Point pt = dtde.getLocation();
DropTargetContext dtc = dtde.getDropTargetContext();
JTree tree = (JTree) dtc.getComponent();
TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y);
Object node = parentpath.getLastPathComponent();
if (dtde.isDataFlavorSupported(TransferableInstrument.INSTR_CAT_FLAVOR)) {
if (!(node instanceof InstrumentCategory)) {
dtde.rejectDrop();
return;
}
if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) {
dtde.acceptDrop(dtde.getDropAction());
Transferable tr = dtde.getTransferable();
try {
Object transferNode = tr.getTransferData(TransferableInstrument.INSTR_CAT_FLAVOR);
InstrumentLibrary iLibrary = (InstrumentLibrary) tree.getModel();
InstrumentCategory parentNode = (InstrumentCategory) node;
InstrumentCategory instrumentCategory = (InstrumentCategory) transferNode;
// iLibrary.removeCategory(instrumentCategory);
iLibrary.addCategory(parentNode, instrumentCategory);
dtde.dropComplete(true);
} catch (UnsupportedFlavorException | IOException e) {
dtde.dropComplete(false);
}
} else {
dtde.rejectDrop();
}
} else if (dtde.isDataFlavorSupported(TransferableInstrument.INSTR_FLAVOR)) {
dtde.acceptDrop(dtde.getDropAction());
try {
Transferable tr = dtde.getTransferable();
Object transferNode = tr.getTransferData(TransferableInstrument.INSTR_FLAVOR);
Instrument instrument = (Instrument) transferNode;
InstrumentLibrary iLibrary = (InstrumentLibrary) tree.getModel();
if (instrument instanceof BlueSynthBuilder) {
((BlueSynthBuilder) instrument).clearParameters();
}
// iLibrary.removeInstrument(instrument);
if (node instanceof InstrumentCategory) {
InstrumentCategory parentNode = (InstrumentCategory) node;
iLibrary.addInstrument(parentNode, instrument);
} else if (node instanceof Instrument) {
InstrumentCategory parentNode = (InstrumentCategory) parentpath.getPathComponent(parentpath.getPathCount() - 2);
int index = ListUtil.indexOfByRef(parentNode.getInstruments(), node);
int closestRow = tree.getClosestRowForLocation(pt.x, pt.y);
Rectangle bounds = tree.getRowBounds(closestRow);
if (pt.y > bounds.y + bounds.height) {
iLibrary.addInstrument(parentNode, instrument);
} else {
iLibrary.addInstrument(parentNode, index, instrument);
}
}
dtde.dropComplete(true);
} catch (UnsupportedFlavorException | IOException e) {
dtde.dropComplete(false);
}
} else {
dtde.rejectDrop();
}
}
Aggregations