Search in sources :

Example 1 with LiveObject

use of blue.blueLive.LiveObject in project blue by kunstmusik.

the class LiveDataTest method testSerialization.

public void testSerialization() {
    LiveData liveData = new LiveData();
    final LiveObjectBins liveObjectBins = liveData.getLiveObjectBins();
    liveObjectBins.setLiveObject(0, 0, new LiveObject(new GenericScore()));
    liveObjectBins.setLiveObject(0, 2, new LiveObject(new GenericScore()));
    liveObjectBins.setLiveObject(0, 4, new LiveObject(new GenericScore()));
    liveObjectBins.setLiveObject(0, 6, new LiveObject(new GenericScore()));
    Element elem1 = liveData.saveAsXML(null);
    Element elem2;
    try {
        elem2 = LiveData.loadFromXML(elem1, null).saveAsXML(null);
        System.out.println(elem1.toString() + "\n\n" + elem2.toString());
        assertEquals(elem1.toString(), elem2.toString());
    } catch (Exception ex) {
        ex.printStackTrace();
        fail("Did not load from xml");
    }
}
Also used : LiveObjectBins(blue.blueLive.LiveObjectBins) Element(electric.xml.Element) GenericScore(blue.soundObject.GenericScore) LiveObject(blue.blueLive.LiveObject)

Example 2 with LiveObject

use of blue.blueLive.LiveObject in project blue by kunstmusik.

the class BlueLiveTopComponent method addSoundObject.

protected void addSoundObject(int column, int row, SoundObject sObj) {
    model.setValueAt(new LiveObject(sObj), row, column);
    liveObjectsTable.setRowSelectionInterval(row, row);
    liveObjectsTable.setColumnSelectionInterval(column, column);
}
Also used : LiveObject(blue.blueLive.LiveObject)

Example 3 with LiveObject

use of blue.blueLive.LiveObject in project blue by kunstmusik.

the class LiveObjectsTableModel method scoreObjectChanged.

@Override
public void scoreObjectChanged(ScoreObjectEvent event) {
    if (event.getPropertyChanged() == ScoreObjectEvent.NAME) {
        LiveObject lObj = getLiveObjectForSoundObject((SoundObject) event.getScoreObject());
        if (lObj != null) {
            int row = bins.getRowForObject(lObj);
            int column = bins.getColumnForObject(lObj);
            fireTableDataChanged(new TableModelEvent(this, row, row, column, TableModelEvent.UPDATE));
        }
    }
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) LiveObject(blue.blueLive.LiveObject)

Example 4 with LiveObject

use of blue.blueLive.LiveObject in project blue by kunstmusik.

the class LiveObjectsTableModel method setLiveObjectBins.

public void setLiveObjectBins(LiveObjectBins bins) {
    if (this.bins != null) {
        for (int i = 0; i < this.bins.getColumnCount(); i++) {
            for (int j = 0; j < this.bins.getRowCount(); j++) {
                LiveObject lObj = this.bins.getLiveObject(i, j);
                if (lObj != null && lObj.getSoundObject() != null) {
                    lObj.getSoundObject().removeScoreObjectListener(this);
                }
            }
        }
        bins.removePropertyChangeListener(this);
    }
    this.bins = bins;
    for (int i = 0; i < bins.getColumnCount(); i++) {
        for (int j = 0; j < bins.getRowCount(); j++) {
            LiveObject lObj = bins.getLiveObject(i, j);
            if (lObj != null && lObj.getSoundObject() != null) {
                lObj.getSoundObject().addScoreObjectListener(this);
            }
        }
    }
    fireTableDataChanged(new TableModelEvent(this, TableModelEvent.HEADER_ROW));
    bins.addPropertyChangeListener(this);
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) LiveObject(blue.blueLive.LiveObject)

Example 5 with LiveObject

use of blue.blueLive.LiveObject in project blue by kunstmusik.

the class LiveObjectsTableModel method setValueAt.

@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    if (rowIndex >= 0 && rowIndex < bins.getRowCount() && columnIndex >= 0 && columnIndex < bins.getColumnCount()) {
        LiveObject oldLiveObj = bins.getLiveObject(columnIndex, rowIndex);
        LiveObject newObj = (LiveObject) aValue;
        if (oldLiveObj != null && oldLiveObj.getSoundObject() != null) {
            oldLiveObj.getSoundObject().removeScoreObjectListener(this);
        }
        bins.setLiveObject(columnIndex, rowIndex, newObj);
        if (newObj != null && newObj.getSoundObject() != null) {
            newObj.getSoundObject().addScoreObjectListener(this);
        }
        fireTableDataChanged();
    }
}
Also used : LiveObject(blue.blueLive.LiveObject)

Aggregations

LiveObject (blue.blueLive.LiveObject)8 SoundObject (blue.soundObject.SoundObject)3 LiveObjectBins (blue.blueLive.LiveObjectBins)2 LiveObjectSet (blue.blueLive.LiveObjectSet)2 NoteList (blue.soundObject.NoteList)2 Element (electric.xml.Element)2 TableModelEvent (javax.swing.event.TableModelEvent)2 GenericScore (blue.soundObject.GenericScore)1 Elements (electric.xml.Elements)1 ArrayList (java.util.ArrayList)1 BadLocationException (javax.swing.text.BadLocationException)1