if ((!button1Down) || (!theApp.editable))
return;
//theApp.dragNote(e.getX(), e.getY());
if (selectedNote >= 0) {
Phrase phr = theApp.getPhrase();
Note n = phr.getNote(selectedNote);
// move note down
if (e.getY() + theApp.staveDelta > clickedPosY + 2 && theApp.getPhrase().getNote(selectedNote).getPitch() != REST) {
n.setPitch(n.getPitch() - 1);
if (n.getPitch() < theApp.getMinPitch()) n.setPitch(theApp.getMinPitch());
// update the current mouse location
clickedPosY += 2;
// update the visual display
theApp.repaint();
// keep pitch to reinstate it after displaying a rest
storedPitch = n.getPitch();
}
// move note up
if (e.getY() + theApp.staveDelta < clickedPosY - 2 && theApp.getPhrase().getNote(selectedNote).getPitch() != REST) {
n.setPitch(n.getPitch() + 1);
if (n.getPitch() > theApp.getMaxPitch()) n.setPitch(theApp.getMaxPitch());
//theApp.playCurrentNote(selectedNote);
clickedPosY -= 2;
theApp.repaint();
storedPitch = n.getPitch();
}
// move note right - increase RV
if (e.getX() > clickedPosX + 6) {
double tempRV = n.getRhythmValue();
int tempPitch = n.getPitch();
// use +100 numbers for rests
if (tempPitch == REST) tempRV = tempRV + 100;
int currRVindex = rhythmValues.length;
// find current rhythm value and update RV
for (int i = 0; i < rhythmValues.length - 1; i++) {
if (tempRV == rhythmValues[i]) {
n.setRhythmValue(rhythmValues[i + 1]);
// update duration value
n.setDuration(n.getRhythmValue() * 0.9);
}
}
clickedPosX = e.getX();
// update pitch
if (n.getRhythmValue() > 100.0) {
n.setPitch(REST);
n.setRhythmValue(n.getRhythmValue() - 100);
// update duration value
n.setDuration(n.getRhythmValue() * 0.9);
} else {
if (tempPitch == REST) n.setPitch(storedPitch);
}
theApp.repaint();
}
// move note left - decrease RV
if (e.getX() < clickedPosX - 6) {
double tempRV = n.getRhythmValue();
int tempPitch = n.getPitch();
// use +100 numbers for rests
if (tempPitch == REST) tempRV = tempRV + 100;
// find current rhythm value position in the array
int currRVindex = 0;
for (int i = 0; i < rhythmValues.length; i++) {
if (tempRV == rhythmValues[i]) currRVindex = i;
}
// update rv
if (currRVindex > 0) {
n.setRhythmValue(rhythmValues[currRVindex - 1]);
// update duration value
n.setDuration(n.getRhythmValue() * 0.9);
clickedPosX = e.getX();
// update pitch
if (n.getRhythmValue() > 100.0) {
n.setPitch(REST);
n.setRhythmValue(n.getRhythmValue() - 100);
// update duration value
n.setDuration(n.getRhythmValue() * 0.9);
} else {
if (tempPitch == REST) n.setPitch(storedPitch);
}
theApp.repaint();
}
}
}