📄 newannotationcommand.java
字号:
aa = (AbstractAnnotation) tier.getAnnotationAtTime(dataRecord.getEndTime() - 1); } if (aa != null) { tier.removeAnnotation(aa); } } } // now recreate all annotations that have been deleted if (changedAnnotations.size() > 0) { for (int i = 0; i < changedAnnotations.size(); i++) { node = (DefaultMutableTreeNode) changedAnnotations.get(i); AnnotationRecreator.createAnnotationFromTree(transcription, node); } } if (removedAnnotations.size() > 0) { for (int i = 0; i < removedAnnotations.size(); i++) { node = (DefaultMutableTreeNode) removedAnnotations.get(i); AnnotationRecreator.createAnnotationFromTree(transcription, node); } } } // restore the time propagation mode transcription.setTimeChangePropagationMode(curPropMode); } /** * Stores information of all effected annotations in bulldozer time * propagation mode. Assumption: no annotations on parenttiers will be effected.<br> * On root tiers: <br> * if the selection begin is within the boundaries of an existing * annotation this annotation will be shifted to the left; all other * overlapped annotations will be shifted to the right. Information on * effected annotations is stored in this order: first the annotation * that is shifted to the left, then all other annotations on the left * side that will be bulldozered (descending), then all annotations that * will be shifted to the right in ascending order. */ private void storeBulldozer() { if (rootTier != null) { // creation of an annotation on a time-subdivision tier // same as normal mode storeNormal(); } else { // creation of an annotation on a root tier Vector effectedAnn = tier.getOverlappingAnnotations(begin, end); Vector allAnn = tier.getAnnotations(); int index; if (effectedAnn.size() > 0) { Annotation aa; // check for bulldozer shift on the left + right side aa = (Annotation) effectedAnn.get(0); index = allAnn.indexOf(aa); if ((aa.getBeginTimeBoundary() <= begin) && (aa.getEndTimeBoundary() > begin)) { leftOffset = (int) (begin - aa.getEndTimeBoundary()); if (end <= aa.getEndTimeBoundary()) { rightOffset = 0; } else { if (effectedAnn.size() >= 2) { aa = (Annotation) effectedAnn.get(1); rightOffset = (int) (end - aa.getBeginTimeBoundary()); } } } else { leftOffset = 0; rightOffset = (int) (end - aa.getBeginTimeBoundary()); } // store info, start on the left if (leftOffset < 0) { AbstractAnnotation cur = (AbstractAnnotation) allAnn.get(index); AbstractAnnotation prev; int gapToBridge = -leftOffset; int gapBridged = 0; changedAnnotations.add(new TimeShiftRecord( cur.getBeginTimeBoundary(), cur.getEndTimeBoundary(), leftOffset)); removedAnnotations.add(AnnotationRecreator.createTreeForAnnotation( cur)); for (int i = index - 1; i >= 0; i--) { prev = (AbstractAnnotation) allAnn.get(i); int dist = (int) (cur.getBeginTimeBoundary() - prev.getEndTimeBoundary()); gapBridged += dist; if (gapBridged < gapToBridge) { changedAnnotations.add(new TimeShiftRecord( prev.getBeginTimeBoundary(), prev.getEndTimeBoundary(), -(gapToBridge - gapBridged))); removedAnnotations.add(AnnotationRecreator.createTreeForAnnotation( prev)); cur = prev; } else { break; } } } if (rightOffset > 0) { if (leftOffset < 0) { index++; } AbstractAnnotation cur = (AbstractAnnotation) allAnn.get(index); AbstractAnnotation next; int gapToBridge = rightOffset; int gapBridged = 0; changedAnnotations.add(new TimeShiftRecord( cur.getBeginTimeBoundary(), cur.getEndTimeBoundary(), rightOffset)); removedAnnotations.add(AnnotationRecreator.createTreeForAnnotation( cur)); for (int i = index + 1; i < allAnn.size(); i++) { next = (AbstractAnnotation) allAnn.get(i); int dist = (int) (next.getBeginTimeBoundary() - cur.getEndTimeBoundary()); gapBridged += dist; if (gapBridged < gapToBridge) { changedAnnotations.add(new TimeShiftRecord( next.getBeginTimeBoundary(), next.getEndTimeBoundary(), gapToBridge - gapBridged)); removedAnnotations.add(AnnotationRecreator.createTreeForAnnotation( next)); cur = next; } else { break; } } } } } } /** * Restores information of all effected annotations in bulldozer time * propagation mode. First deletes the annotation that was originally * created by the user, next deletes the shifted annotations and then * recreates the original annotations. */ private void restoreBulldozer() { if (rootTier != null) { // creation of an annotation on a time-subdivision tier // same as normal mode restoreNormal(); } else { // creation of an annotation on a root tier int curPropMode = 0; curPropMode = transcription.getTimeChangePropagationMode(); if (curPropMode != Transcription.NORMAL) { transcription.setTimeChangePropagationMode(Transcription.NORMAL); } // work // delete the created annotation Annotation createdAnn = tier.getAnnotationAtTime(begin); if (createdAnn != null) { tier.removeAnnotation(createdAnn); } if (changedAnnotations.size() > 0) { TimeShiftRecord tsRecord; AlignableAnnotation aa; DefaultMutableTreeNode node; for (int i = 0; i < changedAnnotations.size(); i++) { tsRecord = (TimeShiftRecord) changedAnnotations.get(i); aa = (AlignableAnnotation) tier.getAnnotationAtTime(tsRecord.newBegin); node = (DefaultMutableTreeNode) removedAnnotations.get(i); if (aa != null) { tier.removeAnnotation(aa); AnnotationRecreator.createAnnotationFromTree(transcription, node); } } } // restore the time propagation mode transcription.setTimeChangePropagationMode(curPropMode); } } /** * Stores information on all effected annotations in shift propagation * mode. */ private void storeShift() { if (rootTier != null) { // time subdivision storeNormal(); } else { Vector effectedAnn = tier.getOverlappingAnnotations(begin, end); AbstractAnnotation aa; if (effectedAnn.size() > 0) { aa = (AbstractAnnotation) effectedAnn.get(0); if ((aa.getBeginTimeBoundary() < begin) && (aa.getEndTimeBoundary() > begin)) { changedAnnotations.add(AnnotationRecreator.createTreeForAnnotation( aa)); } } } } /** * Restores information of all effected annotations in shift time- * propagation mode. */ private void restoreShift() { int curPropMode = 0; curPropMode = transcription.getTimeChangePropagationMode(); if (curPropMode != Transcription.NORMAL) { transcription.setTimeChangePropagationMode(Transcription.NORMAL); } if (rootTier != null) { // shift the slots backward transcription.shiftBackward(begin, -(end - begin)); restoreNormal(); } else { DefaultMutableTreeNode node = null; if (changedAnnotations.size() > 0) { Annotation aa; node = (DefaultMutableTreeNode) changedAnnotations.get(0); AnnotationDataRecord annRecord = (AnnotationDataRecord) node.getUserObject(); long begin = annRecord.getBeginTime(); aa = tier.getAnnotationAtTime(begin); if (aa != null) { tier.removeAnnotation(aa); } } // shift the slots backward transcription.shiftBackward(begin, -(end - begin)); if (node != null) { AnnotationRecreator.createAnnotationFromTree(transcription, node); } } // restore the time propagation mode transcription.setTimeChangePropagationMode(curPropMode); } /** * Returns the name of the command. * * @return the name of the command */ public String getName() { return commandName; } /** * Changes the cursor to either a 'busy' cursor or the default cursor. * * @param showWaitCursor when <code>true</code> show the 'busy' cursor */ void setWaitCursor(boolean showWaitCursor) { if (showWaitCursor) { ELANCommandFactory.getRootFrame(transcription).getRootPane() .setCursor(Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR)); } else { ELANCommandFactory.getRootFrame(transcription).getRootPane() .setCursor(Cursor.getDefaultCursor()); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -