static private NoteAbstract transpose_Note(NoteAbstract original,
			Note noneTranspKeyNote, KeySignature noneTranspKey,
			Note lastKeyNote, KeySignature lastKey) {
		NoteAbstract transp = null;
		if (original instanceof Note) {
			float microtonalOffset = ((Note)original).getAccidental().getMicrotonalOffset();
			Interval interval = new Interval(noneTranspKeyNote, (Note) original,
					noneTranspKey);
			// Note transp = Note.transpose(original, semitones, lastKey);
			Note transpHeight = interval.calculateSecondNote(lastKeyNote, lastKey);
			try {
				transp = (Note) original.clone();
			} catch (CloneNotSupportedException never) {
				never.printStackTrace();
                return null;
			}
			((Note) transp).setHeight(transpHeight.getHeight());
			((Note) transp).setOctaveTransposition(transpHeight.getOctaveTransposition());
			if (microtonalOffset == 0)
				((Note) transp).setAccidental(transpHeight.getAccidental());
			else
				((Note) transp).setAccidental(transpHeight.getAccidental().getValue()+microtonalOffset);
		} else if (original instanceof MultiNote) {
			try {
				transp = (MultiNote) original.clone();
			} catch (CloneNotSupportedException never) {
				never.printStackTrace();
                return null;
			}
			Note[] notes = ((MultiNote) transp).toArray();
			for (int k = 0; k < notes.length; k++) {
				notes[k] = (Note) transpose_Note(notes[k], noneTranspKeyNote,
						noneTranspKey, lastKeyNote, lastKey);
			}
			((MultiNote) transp).setNotes(notes);
		}
//		TieDefinition tie = original.getTieDefinition();
//		if (tie != null) {
//			if (tie.getStart() == original)
//				tie.setStart(transp);
//			else if (tie.getEnd() == original)
//				tie.setEnd(transp);
//		}
//		Vector slurs = original.getSlurDefinitions();
//		for (Iterator it = slurs.iterator(); it.hasNext();) {
//			SlurDefinition slur = (SlurDefinition) it.next();
//			if (slur.getStart() == original)
//				slur.setStart(transp);
//			else if (slur.getEnd() == original)
//				slur.setEnd(transp);
//		}
		transpose_Chord(transp, noneTranspKeyNote, noneTranspKey,
				lastKeyNote, lastKey);
        assert transp != null;
        if (transp.hasGracingNotes()) {
			NoteAbstract[] graces = transp.getGracingNotes();
			for (int k = 0; k < graces.length; k++) {
				graces[k] = transpose_Note(graces[k], noneTranspKeyNote,
						noneTranspKey, lastKeyNote, lastKey);
			}
		}
		return transp;
	}
static private NoteAbstract transpose_Note ( NoteAbstract original , Note noneTranspKeyNote , KeySignature noneTranspKey , Note lastKeyNote , KeySignature lastKey ) { NoteAbstract transp = null ; if ( original instanceof Note ) { float microtonalOffset = ( ( Note ) original ) . getAccidental ( ) . getMicrotonalOffset ( ) ; Interval interval = new Interval ( noneTranspKeyNote , ( Note ) original , noneTranspKey ) ; Note transpHeight = interval . calculateSecondNote ( lastKeyNote , lastKey ) ; try { transp = ( Note ) original . clone ( ) ; } catch ( CloneNotSupportedException never ) { never . printStackTrace ( ) ; return null ; } ( ( Note ) transp ) . setHeight ( transpHeight . getHeight ( ) ) ; ( ( Note ) transp ) . setOctaveTransposition ( transpHeight . getOctaveTransposition ( ) ) ; if ( microtonalOffset == 0 ) ( ( Note ) transp ) . setAccidental ( transpHeight . getAccidental ( ) ) ; else ( ( Note ) transp ) . setAccidental ( transpHeight . getAccidental ( ) . getValue ( ) + microtonalOffset ) ; } else if ( original instanceof MultiNote ) { try { transp = ( MultiNote ) original . clone ( ) ; } catch ( CloneNotSupportedException never ) { never . printStackTrace ( ) ; return null ; } Note [ ] notes = ( ( MultiNote ) transp ) . toArray ( ) ; for ( int k = 0 ; k < notes . length ; k ++ ) { notes [ k ] = ( Note ) transpose_Note ( notes [ k ] , noneTranspKeyNote , noneTranspKey , lastKeyNote , lastKey ) ; } ( ( MultiNote ) transp ) . setNotes ( notes ) ; } transpose_Chord ( transp , noneTranspKeyNote , noneTranspKey , lastKeyNote , lastKey ) ; assert transp != null ; if ( transp . hasGracingNotes ( ) ) { NoteAbstract [ ] graces = transp . getGracingNotes ( ) ; for ( int k = 0 ; k < graces . length ; k ++ ) { graces [ k ] = transpose_Note ( graces [ k ] , noneTranspKeyNote , noneTranspKey , lastKeyNote , lastKey ) ; } } return transp ; }
Subfunction of {@link #transpose(Tune, int)} which transpose
a Note, its graces notes (recursively)