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; }
protected void paintBeat( TGPainter painter, TGMeasure measure, TGBeat beat, float fromX, float fromY) { if (this.clientArea != null) { int minimumY = BORDER_HEIGHT; int maximumY = (this.clientArea.height - BORDER_HEIGHT); for (int v = 0; v < beat.countVoices(); v++) { TGVoice voice = beat.getVoice(v); for (int i = 0; i < voice.countNotes(); i++) { TGNoteImpl note = (TGNoteImpl) voice.getNote(i); float x1 = (fromX + this.leftSpacing + (((beat.getStart() - measure.getStart()) * (this.timeWidth * measure.getTimeSignature().getNumerator())) / measure.getLength()) + 1); float y1 = (fromY + (((this.maxNote - this.minNote) - (note.getRealValue() - this.minNote)) * this.lineHeight) + 1); float x2 = (x1 + ((voice.getDuration().getTime() * this.timeWidth) / measure.getTimeSignature().getDenominator().getTime()) - 2); float y2 = (y1 + this.lineHeight - 2); if (y1 >= maximumY || y2 <= minimumY) { continue; } y1 = (y1 < minimumY ? minimumY : y1); y2 = (y2 > maximumY ? maximumY : y2); if ((x2 - x1) > 0 && (y2 - y1) > 0) { painter.setBackground( new TGColorImpl( (note.getBeatImpl() .isPlaying( TuxGuitar.instance() .getTablatureEditor() .getTablature() .getViewLayout()) ? this.config.getColorPlay() : this.config.getColorNote()))); painter.initPath(TGPainter.PATH_FILL); painter.setAntialias(false); painter.addRectangle(x1, y1, (x2 - x1), (y2 - y1)); painter.closePath(); } } } } }