use of blue.BlueData in project blue by kunstmusik.
the class CSDUtilityTest method testParseCsScore.
/**
* Test of convertOrcScoToBlue method, of class CSDUtility.
*/
// @Test
// public void testConvertOrcScoToBlue() {
// System.out.println("convertOrcScoToBlue");
// File orcFile = null;
// File scoFile = null;
// int importMode = 0;
// BlueData expResult = null;
// BlueData result = CSDUtility.convertOrcScoToBlue(orcFile, scoFile,
// importMode);
// assertEquals(expResult, result);
// // TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
// }
/**
* Test of convertCSDtoBlue method, of class CSDUtility.
*/
// @Test
// public void testConvertCSDtoBlue() {
// System.out.println("convertCSDtoBlue");
// File csdFile = null;
// int importMode = 0;
// BlueData expResult = null;
// BlueData result = CSDUtility.convertCSDtoBlue(csdFile, importMode);
// assertEquals(expResult, result);
// // TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
// }
/**
* Test of parseCsScore method, of class CSDUtility.
*/
@Test
public void testParseCsScore() {
BlueData data = new BlueData();
String score = "f1 0 10 1\n f2 0 10 .5 .3 .1\ni1 0 2 3 4 5\ni2 0 2 3 4 5";
int importMode = CSDUtility.IMPORT_GLOBAL;
CSDUtility.parseCsScore(data, score, importMode);
assertEquals("f1 0 10 1\n f2 0 10 .5 .3 .1\n", data.getTableSet().getTables());
}
use of blue.BlueData in project blue by kunstmusik.
the class CompileProcessor method process.
@Override
protected void process(Env env, Map<Option, String[]> optionValues) throws CommandException {
String compileFileName = null;
String outFileName = null;
if (optionValues.containsKey(c)) {
compileFileName = optionValues.get(c)[0];
}
if (optionValues.containsKey(o)) {
outFileName = optionValues.get(o)[0];
}
if (compileFileName == null && outFileName == null) {
return;
}
if (compileFileName == null && outFileName != null) {
throw new CommandException(1, ".blue project not given as argument");
}
File in = new File(compileFileName);
if (!in.exists() || !in.isFile()) {
throw new CommandException(1, "Could not open .blue file: " + in.getAbsolutePath());
}
if (outFileName == null) {
outFileName = compileFileName.substring(0, compileFileName.indexOf(".blue")) + ".csd";
}
OpenProjectAction.open(in);
PrintWriter out = null;
try {
BlueData tempData = BlueProjectManager.getInstance().getCurrentBlueData();
out = new PrintWriter(new BufferedWriter(new FileWriter(outFileName)));
CsdRenderResult renderResult = CSDRenderService.getDefault().generateCSD(tempData, 0.0F, -1.0F, false, false);
out.print(renderResult.getCsdText());
out.close();
throw new CommandException(0, compileFileName + " " + BlueSystem.getString("blue.compiledTo") + " " + outFileName);
} catch (IOException | ScoreGenerationException | CommandException e) {
if (out != null) {
out.close();
}
if (e instanceof CommandException) {
throw (CommandException) e;
}
throw new CommandException(1, BlueSystem.getString("message.errorLabel") + " " + BlueSystem.getString("blue.csdCompileError") + e.getMessage());
}
}
use of blue.BlueData in project blue by kunstmusik.
the class PolyObjectEditor method testSoundObject.
public final void testSoundObject() {
if (this.pObj == null) {
return;
}
BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
if (data == null) {
System.err.println("PolyObjectEditor::testSoundObject() - " + "Could not get reference to current BlueData object");
return;
}
Tables tables = new Tables(data.getTableSet());
Arrangement arrangement = new Arrangement(data.getArrangement());
PolyObject tempPObj = new PolyObject(this.pObj);
OpcodeList opcodeList = new OpcodeList(data.getOpcodeList());
GlobalOrcSco globalOrcSco = new GlobalOrcSco(data.getGlobalOrcSco());
// adding all compile-time instruments from soundObjects to arrangement
arrangement.generateFTables(tables);
CompileData compileData = new CompileData(arrangement, tables);
// grabbing all notes from soundObjects
NoteList generatedNotes = null;
try {
generatedNotes = tempPObj.generateForCSD(compileData, 0.0f, -1.0f);
} catch (Exception e) {
Exceptions.printStackTrace(e);
return;
}
if (generatedNotes != null) {
InfoDialog.showInformationDialog(SwingUtilities.getRoot(this), generatedNotes.toString(), BlueSystem.getString("soundObject.generatedScore"));
}
}
use of blue.BlueData in project blue by kunstmusik.
the class BlueProjectManager method saveAs.
public boolean saveAs() {
FileChooserManager fcm = FileChooserManager.getDefault();
if (getCurrentProject().getDataFile() != null) {
fcm.setSelectedFile(this.getClass(), getCurrentProject().getDataFile());
} else {
fcm.setSelectedFile(this.getClass(), new File(GeneralSettings.getInstance().getDefaultDirectory() + File.separator + "default.blue"));
}
File rValue = fcm.showSaveDialog(this.getClass(), WindowManager.getDefault().getMainWindow());
if (rValue != null) {
File temp = rValue;
if (!(temp.getName().trim().endsWith(".blue"))) {
temp = new File(temp.getAbsolutePath() + ".blue");
}
if (temp.exists()) {
NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation("Are you sure you would like to overwite the project file: " + temp.getAbsolutePath(), "Overwrite Project?");
Object retVal = DialogDisplayer.getDefault().notify(descriptor);
if (retVal != NotifyDescriptor.YES_OPTION) {
return false;
}
}
if (getCurrentProject().isOpenedFromTempFile()) {
getCurrentProject().getTempFile().delete();
getCurrentProject().setOpenedFromTempFile(false);
}
try (PrintWriter out = new PrintWriter(new FileWriter(temp))) {
BlueData data = getCurrentProject().getData();
out.print(data.saveAsXML().toString());
out.flush();
} catch (Exception e) {
NotifyDescriptor descriptor = new NotifyDescriptor.Message("Could not save file:\n\n" + e.getLocalizedMessage(), NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(descriptor);
}
StatusDisplayer.getDefault().setStatusText("File saved: " + temp.getName());
// ProgramOptions.addRecentFile(temp);
// blueMenuBar.resetRecentFiles();
// ProgramOptions.save();
//
RecentProjectsList.getInstance().addFile(temp.getAbsolutePath());
// fileName = temp;
getCurrentProject().setDataFile(temp);
BlueSystem.setCurrentProjectDirectory(temp.getParentFile());
temp = null;
fireProjectFileChanged();
// setRevertEnabled();
return true;
// }
// else if (rValue == JFileChooser.CANCEL_OPTION) {
// StatusBar.updateStatus(BlueSystem.getString(
// "message.actionCancelled"));
// return false;
} else {
return false;
}
}
use of blue.BlueData in project blue by kunstmusik.
the class ImportCsdAction method importCsdAction.
protected void importCsdAction() {
final Frame mainWindow = WindowManager.getDefault().getMainWindow();
List<File> rValue = FileChooserManager.getDefault().showOpenDialog(this.getClass(), mainWindow);
if (rValue.size() > 0) {
File temp = rValue.get(0);
if (!(temp.getName().trim().toLowerCase().endsWith(".csd"))) {
String errorMessage = BlueSystem.getString("message.file.incorrectEnding") + " .csd";
JOptionPane.showMessageDialog(mainWindow, errorMessage, "Error", JOptionPane.ERROR_MESSAGE);
}
/*
* if(!saveCheck()) { System.out.println("!saveCheck() in
* BlueMainFrame"); return;
*/
final Object[] values = { BlueSystem.getString("csd.import1"), BlueSystem.getString("csd.import2"), BlueSystem.getString("csd.import3") };
Object selectedValue = JOptionPane.showInputDialog(mainWindow, BlueSystem.getString("csd.importMethod.message"), BlueSystem.getString("csd.importMethod.title"), JOptionPane.INFORMATION_MESSAGE, null, values, values[0]);
if (selectedValue == null) {
return;
}
int modeType = 0;
for (int i = 0; i < values.length; i++) {
if (selectedValue == values[i]) {
modeType = i;
break;
}
}
BlueData tempData = CSDUtility.convertCSDtoBlue(temp, modeType);
if (tempData != null) {
BlueProject project = new BlueProject(tempData, null);
BlueProjectManager.getInstance().setCurrentProject(project);
} else {
JOptionPane.showMessageDialog(mainWindow, BlueSystem.getString("message.file.couldNotImport"), BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
}
}
// else if (rValue == JFileChooser.CANCEL_OPTION) {
// StatusDisplayer.getDefault().setStatusText(
// BlueSystem.getString("message.actionCancelled"));
// }
}
Aggregations