use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class ConvertToPolyObjectAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
int retVal = JOptionPane.showConfirmDialog(null, "This operation can not be undone.\nAre you sure?");
if (retVal != JOptionPane.OK_OPTION) {
return;
}
List<Layer> allLayers = scorePath.getAllLayers();
List<SoundObject> sObjList = new ArrayList<>();
List<Integer> layerIndexes = new ArrayList<>();
int layerMin = Integer.MAX_VALUE;
int layerMax = Integer.MIN_VALUE;
double start = Double.POSITIVE_INFINITY;
for (SoundObject sObj : soundObjects) {
sObjList.add(sObj);
double sObjStart = sObj.getStartTime();
if (sObj.getStartTime() < start) {
start = sObj.getStartTime();
}
for (int i = 0; i < allLayers.size(); i++) {
if (allLayers.get(i).contains(sObj)) {
layerIndexes.add(i);
if (i < layerMin) {
layerMin = i;
}
if (i > layerMax) {
layerMax = i;
}
break;
}
}
if (sObjList.size() != layerIndexes.size()) {
throw new RuntimeException("Error: Unable to find layer for SoundObject.");
}
}
int numLayers = layerMax - layerMin + 1;
for (int i = 0; i < numLayers; i++) {
pObj.newLayerAt(-1);
}
for (int i = 0; i < sObjList.size(); i++) {
SoundObject sObj = sObjList.get(i);
int layerNum = layerIndexes.get(i);
SoundLayer layer = (SoundLayer) allLayers.get(layerNum);
layer.remove(sObj);
// don't need to clone here...
pObj.get(layerNum - layerMin).add(sObj);
}
pObj.normalizeSoundObjects();
pObj.setStartTime(start);
((SoundLayer) scorePath.getGlobalLayerForY(p.y)).add(pObj);
ScoreController.getInstance().setSelectedScoreObjects(Collections.singleton(pObj));
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class GenericRenderer method render.
@Override
public void render(Graphics graphics, SoundObjectView sObjView, int pixelSeconds) {
Graphics2D g = (Graphics2D) graphics;
int w = sObjView.getSize().width;
int h = sObjView.getSize().height;
Color bgColor;
Color border1;
Color border2;
Color fontColor;
SoundObject sObj = sObjView.getSoundObject();
if (sObjView.isSelected()) {
bgColor = selectedBgColor;
border1 = selectedBorder1;
border2 = selectedBorder2;
fontColor = selectedFontColor;
} else {
bgColor = sObj.getBackgroundColor();
border1 = bgColor.brighter().brighter();
border2 = bgColor.darker().darker();
int total = bgColor.getRed() + bgColor.getGreen() + bgColor.getBlue();
if (total > 128 * 3) {
fontColor = Color.black;
} else {
fontColor = Color.white;
}
}
g.setPaint(BlueGradientFactory.getGradientPaint(bgColor));
g.fillRect(0, 2, w, h - 4);
// DRAW BORDERS
// if (ProgramOptions.getGeneralSettings().isDrawFlatSObjBorders()) {
// g.setColor(Color.LIGHT_GRAY);
// g.drawRect(0, 2, w - 1, h - 4);
//
// } else {
g.setColor(border1);
g.drawLine(0, 2, w - 1, 2);
g.drawLine(0, 2, 0, h - 4);
g.setColor(border2);
g.drawLine(0, h - 3, w, h - 3);
g.drawLine(w - 1, h - 3, w - 1, 2);
// }
// paint repeat
double repeatPoint = sObj.getRepeatPoint();
if (sObj.getTimeBehavior() == SoundObject.TIME_BEHAVIOR_REPEAT && repeatPoint > 0.0f) {
double lineTime = repeatPoint;
double dur = sObj.getSubjectiveDuration();
int[] x = new int[3];
int[] y = new int[3];
while (lineTime <= dur) {
g.setColor(border2);
int lineX = (int) (lineTime * pixelSeconds);
// g.drawLine(lineX, 3, lineX, h - 4);
x[0] = lineX - 5;
x[1] = lineX;
x[2] = lineX;
y[0] = 3;
y[1] = 8;
y[2] = 3;
g.fillPolygon(x, y, 3);
y[0] = h - 3;
y[1] = h - 8;
y[2] = h - 3;
g.fillPolygon(x, y, 3);
lineTime += repeatPoint;
}
}
g.setPaint(fontColor);
if (h >= 20) {
g.setComposite(AlphaComposite.Src);
g.setFont(renderFont);
String[] parts = sObjView.getSoundObject().getName().split("\\\\[n]");
for (int i = 0; i < parts.length; i++) {
int y = 15 + (i * Layer.LAYER_HEIGHT);
g.drawString(parts[i], labelOffset, y);
}
}
// EMPTY OUT CORNERS
// g.setColor(Color.BLACK);
// g.drawLine(0, 2, 0, 2);
// g.drawLine(0, h - 3, 0, h - 3);
// g.drawLine(w - 1, 2, w - 1, 2);
// g.drawLine(w - 1, h - 3, w - 1, h - 3);
}
use of blue.soundObject.SoundObject 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.SoundObject in project blue by kunstmusik.
the class FreezeUnfreezeAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
List<Layer> allLayers = scorePath.getAllLayers();
List<SoundObject> sObjList = new ArrayList<>(soundObjects);
List<Layer> layers = new ArrayList<>();
for (SoundObject sObj : sObjList) {
for (Layer layer : allLayers) {
if (layer.contains(sObj)) {
layers.add(layer);
break;
}
}
}
if (layers.size() != sObjList.size()) {
throw new RuntimeException("Error: Could not find layers for selected SoundObjects");
}
ProgressUtils.showProgressDialogAndRun(new FreezeRunnable(sObjList, layers), "Freeze/Unfreeze SoundObjects", true);
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class RealtimeRenderManager method getPolyObjectPath.
private List<PolyObject> getPolyObjectPath(PolyObject pObj, SoundObject soundObject) {
List<SoundObject> allSObj = pObj.getSoundObjects(true);
List<PolyObject> retVal = null;
if (allSObj.contains(soundObject)) {
retVal = new ArrayList<>();
retVal.add(pObj);
} else {
List<SoundObject> pObjs = allSObj.stream().filter(a -> a instanceof PolyObject).collect(Collectors.toList());
for (SoundObject obj : pObjs) {
PolyObject tempPObj = (PolyObject) obj;
retVal = getPolyObjectPath(tempPObj, soundObject);
if (retVal != null) {
retVal.add(0, pObj);
break;
}
}
}
return retVal;
}
Aggregations