use of blue.score.layers.Layer in project blue by kunstmusik.
the class PolyObject method newLayerAt.
/* LAYER GROUP INTERFACE */
@Override
public SoundLayer newLayerAt(int index) {
SoundLayer sLayer = new SoundLayer();
sLayer.setHeightIndex(getDefaultHeightIndex());
int insertIndex = index;
if (index < 0 || index >= this.size()) {
insertIndex = this.size();
this.add(sLayer);
} else {
this.add(index, sLayer);
}
ArrayList<Layer> layers = new ArrayList<>();
layers.add(sLayer);
LayerGroupDataEvent lde = new LayerGroupDataEvent(this, LayerGroupDataEvent.DATA_ADDED, insertIndex, insertIndex, layers);
fireLayerGroupDataEvent(lde);
return sLayer;
}
use of blue.score.layers.Layer in project blue by kunstmusik.
the class Score method getGlobalLayerIndexForY.
public int getGlobalLayerIndexForY(int y) {
int runningY = 0;
int runningIndex = 0;
for (LayerGroup<? extends Layer> layerGroup : this) {
for (Layer layer : layerGroup) {
if (y <= runningY + layer.getLayerHeight()) {
return runningIndex;
}
runningY += layer.getLayerHeight();
runningIndex += 1;
}
if (y <= runningY + SPACER) {
return runningIndex;
}
runningY += SPACER;
}
return runningIndex - 1;
}
use of blue.score.layers.Layer in project blue by kunstmusik.
the class Score method getLayerGroupsForScoreObjects.
public List<LayerGroup> getLayerGroupsForScoreObjects(Collection<? extends ScoreObject> scoreObjects) {
List<LayerGroup> retVal = new ArrayList<>();
for (LayerGroup<? extends Layer> layerGroup : this) {
for (Layer layer : layerGroup) {
boolean found = false;
if (layer instanceof ScoreObjectLayer) {
ScoreObjectLayer scoreLayer = (ScoreObjectLayer) layer;
if (!Collections.disjoint(scoreLayer, scoreObjects)) {
retVal.add(layerGroup);
found = true;
}
}
if (found) {
break;
}
}
}
return retVal;
}
use of blue.score.layers.Layer in project blue by kunstmusik.
the class AudioLayersPanel method layerGroupChanged.
@Override
public void layerGroupChanged(final LayerGroupDataEvent event) {
final ArrayList<Layer> layers = event.getLayers();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (event.getType() == LayerGroupDataEvent.DATA_ADDED) {
for (Layer layer : layers) {
((AudioLayer) layer).addPropertyChangeListener(heightListener);
((AudioLayer) layer).addAudioLayerListener(AudioLayersPanel.this);
for (AudioClip clip : (AudioLayer) layer) {
addClipPanel(clip, timeState, 0, 0);
}
}
} else if (event.getType() == LayerGroupDataEvent.DATA_REMOVED) {
for (Layer layer : layers) {
((AudioLayer) layer).removePropertyChangeListener(heightListener);
((AudioLayer) layer).removeAudioLayerListener(AudioLayersPanel.this);
for (AudioClip clip : (AudioLayer) layer) {
removeClipPanel(clip);
}
}
}
updateAudioClipYandHeight();
checkSize();
repaint();
}
});
}
use of blue.score.layers.Layer in project blue by kunstmusik.
the class AudioLayerGroup method removeLayers.
@Override
public void removeLayers(int startIndex, int endIndex) {
ArrayList<Layer> layers = new ArrayList<>();
for (int i = endIndex; i >= startIndex; i--) {
AudioLayer audioLayer = this.get(i);
audioLayer.clearListeners();
this.remove(i);
layers.add(audioLayer);
}
LayerGroupDataEvent lde = new LayerGroupDataEvent(this, LayerGroupDataEvent.DATA_REMOVED, startIndex, endIndex, layers);
fireLayerGroupDataEvent(lde);
}
Aggregations