private MooTrackView mtv;
private MooNote note;
private JPopupMenu popup;
- private JMenuItem popupRemove, popupProp, popupTransposeOctUp, popupTransposeOctDown;
+ private JMenuItem popupRemove, popupProp, popupTranspOctUp, popupTranspOctDown;
private Rectangle pitchRect, veloRect;
private String notePitch, noteVelocity;
private boolean selected = false;
/**
* Creates a new note element.
* @param parent The MooTrackView that this element will be painted on.
- * @param mn the note that will be graphically represented
+ * @param mn the note that will be graphically represented
*/
public MooNoteElement (MooTrackView parent, MooNote mn) {
mtv = parent;
popupRemove = new JMenuItem("Remove");
popupRemove.addActionListener(pList);
popup.add(popupRemove);
- popupTransposeOctUp = new JMenuItem("Transpose one octave up");
- popupTransposeOctUp.addActionListener(pList);
- popup.add(popupTransposeOctUp);
- popupTransposeOctDown = new JMenuItem("Transpose one octave down");
- popupTransposeOctDown.addActionListener(pList);
- popup.add(popupTransposeOctDown);
+ popupTranspOctUp = new JMenuItem("Transpose one octave up");
+ popupTranspOctUp.addActionListener(pList);
+ popup.add(popupTranspOctUp);
+ popupTranspOctDown = new JMenuItem("Transpose one octave down");
+ popupTranspOctDown.addActionListener(pList);
+ popup.add(popupTranspOctDown);
}
/**
*/
public void select() {
selected = true;
- mtv.addSelected(this);
+ mtv.selectNote(this);
setBackground(invBgColor);
textColor = Color.white;
repaint();
*/
public void deselect() {
selected = false;
- // mtv.removeSelected(this);
+ // mtv.deselectNote(this);
setBackground(bgColor);
textColor = Color.black;
repaint();
case 10: notePitch = "A#"; break;
case 11: notePitch = "B"; break;
}
- notePitch += pitch / 12;
+ notePitch += pitch / 12 - 1;
noteVelocity = ""+note.getVelocity();
}
mtv.removeNote(this);
}
+ /**
+ * Updates the graphical content of the element and repaints it.
+ */
+ public void update() {
+ calculateString();
+ repaint();
+ }
+
/**
* layout this changed elemnt
*/
if (e.isControlDown()) {
if (pitchRect.contains(e.getPoint())) {
if (SwingUtilities.isRightMouseButton(e)) {
- note.setPitch(note.getPitch() + 1);
+ note.transpose(1);
} else if (SwingUtilities.isLeftMouseButton(e)) {
- note.setPitch(note.getPitch() - 1);
+ note.transpose(-1);
}
Moosique.setEdited();
calculateString();
newLayout();
} else if (source == popupRemove) {
remove();
- } else if (source == popupTransposeOctUp) {
- note.setPitch(note.getPitch() + 12);
+ } else if (source == popupTranspOctUp) {
+ note.transpose(12);
update();
- } else if (source == popupTransposeOctDown) {
- note.setPitch(note.getPitch() - 12);
+ } else if (source == popupTranspOctDown) {
+ note.transpose(-12);
update();
}
}
-
- private void update() {
- calculateString();
- repaint();
- }
-
}
}