protected void hit(float x, float y) { if (!TuxGuitar.instance().getPlayer().isRunning()) { TGMeasure measure = getMeasure(); Caret caret = getCaret(); int value = getValueAt(y); long start = getStartAt(x); if (start >= measure.getStart() && start < (measure.getStart() + measure.getLength())) { caret.update(caret.getTrack().getNumber(), start, caret.getStringNumber()); TuxGuitar.instance().updateCache(true); } if (value >= this.minNote || value <= this.maxNote) { if (start >= measure.getStart()) { TGVoice voice = TuxGuitar.instance() .getSongManager() .getMeasureManager() .getVoiceIn(measure, start, caret.getVoice()); if (voice != null) { if (!removeNote(voice.getBeat(), value)) { addNote(voice.getBeat(), start, value); } } } else { play(value); } } } }
private boolean removeNote(TGBeat beat, int value) { Caret caret = TuxGuitar.instance().getTablatureEditor().getTablature().getCaret(); TGMeasure measure = getMeasure(); for (int v = 0; v < beat.countVoices(); v++) { TGVoice voice = beat.getVoice(v); Iterator it = voice.getNotes().iterator(); while (it.hasNext()) { TGNoteImpl note = (TGNoteImpl) it.next(); if (note.getRealValue() == value) { caret.update(measure.getTrack().getNumber(), beat.getStart(), note.getString()); // comienza el undoable UndoableMeasureGeneric undoable = UndoableMeasureGeneric.startUndo(); TGSongManager manager = TuxGuitar.instance().getSongManager(); manager.getMeasureManager().removeNote(note); // termia el undoable TuxGuitar.instance().getUndoableManager().addEdit(undoable.endUndo()); TuxGuitar.instance().getFileHistory().setUnsavedFile(); this.afterAction(); return true; } } } return false; }
private void moveToNext() { if (TuxGuitar.instance().getPlayer().isRunning()) { TuxGuitar.instance().getTransport().gotoNext(); } else { Caret caret = getEditor().getTablature().getCaret(); TGTrackImpl track = caret.getTrack(); TGMeasure measure = getSongManager().getTrackManager().getNextMeasure(caret.getMeasure()); if (track != null && measure != null) { caret.update(track.getNumber(), measure.getStart(), caret.getSelectedString().getNumber()); } } }