📄 modifyannotationtimecommand.java
字号:
// 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. */ private void storeBulldozer() { // in case the annotation is on a time-subdivision tier // store the whole tree with the parent annotation as root if (rootTier != null) { storeNormal(); return; } if ((leftOffset > 0) || (rightOffset < 0)) { // children could have been destroyed rootNode = AnnotationRecreator.createTreeForAnnotation(annotation); } // annotations will only be shifted; store the times... // store annotations in the order they need to be restored // check left side.... Vector annos = tier.getAnnotations(); if (annos == null) { return; } if (leftOffset < 0) { AbstractAnnotation cur = annotation; AbstractAnnotation prev; int index = annos.indexOf(annotation); int gapToBridge = -leftOffset; int gapBridged = 0; for (int i = index - 1; i >= 0; i--) { prev = (AbstractAnnotation) annos.get(i); int dist = (int) (cur.getBeginTimeBoundary() - prev.getEndTimeBoundary()); gapBridged += dist; if (gapBridged < gapToBridge) { // check if the new begintime will be less than zero: annotations could be lost removedAnnotations.add(AnnotationRecreator.createTreeForAnnotation( prev)); changedAnnotations.add(new TimeShiftRecord( prev.getBeginTimeBoundary(), prev.getEndTimeBoundary(), -(gapToBridge - gapBridged))); cur = prev; } else { break; } } } // check right side if (rightOffset > 0) { AbstractAnnotation cur = annotation; AbstractAnnotation next; int index = annos.indexOf(annotation); int gapToBridge = rightOffset; int gapBridged = 0; for (int i = index + 1; i < annos.size(); i++) { next = (AbstractAnnotation) annos.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 restore the annotation that was originally * changed by the user, next shift the annotations to the left and to the * right back to their original locations. */ private void restoreBulldozer() { if (tier == null) { return; //warn?? } int curPropMode = 0; curPropMode = transcription.getTimeChangePropagationMode(); if (curPropMode != Transcription.NORMAL) { transcription.setTimeChangePropagationMode(Transcription.NORMAL); } // in case the annotation is on a time-subdivision tier, first remove the root annotation // and then restore it. if (rootTier != null) { restoreNormal(); } else { AlignableAnnotation actAnnotation = (AlignableAnnotation) tier.getAnnotationAtTime(newBeginTime); if ((leftOffset > 0) || (rightOffset < 0)) { // children could have been destroyed if (actAnnotation != null) { tier.removeAnnotation(actAnnotation); AnnotationRecreator.createAnnotationFromTree(transcription, rootNode); } } else { // restore the original, edited annotation if (actAnnotation != null) { actAnnotation.updateTimeInterval(oldBeginTime, oldEndTime); } } 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. On a time subdivision tier shift mode is identical to normal * mode. On root tiers the changes on the left side are treated the same * way as in normal mode, changes on the right side shift all time slots * on the right side of the selection to the right. */ private void storeShift() { // in case the annotation is on a time-subdivision tier // store the whole tree with the parent annotation as root if (rootTier != null) { storeNormal(); return; } // we are on a root tier if ((leftOffset > 0) || (rightOffset < 0)) { // children could have been destroyed rootNode = AnnotationRecreator.createTreeForAnnotation(annotation); } // copy from storeNormal for the left side if (leftOffset < 0) { Vector v = tier.getOverlappingAnnotations(newBeginTime, oldBeginTime); if (v.size() > 0) { AbstractAnnotation ann = (AbstractAnnotation) v.get(0); if (ann.getBeginTimeBoundary() < newBeginTime) { // this one will be changed, children might be deleted // so store the whole tree with this annotation as root changedAnnotations.add(AnnotationRecreator.createTreeForAnnotation( ann)); } else { removedAnnotations.add(AnnotationRecreator.createTreeForAnnotation( ann)); } for (int i = 1; i < v.size(); i++) { removedAnnotations.add(AnnotationRecreator.createTreeForAnnotation( (AbstractAnnotation) v.get(i))); } } } } /** * Restores information of all effected annotations in shift time * propagation mode. On root tiers first delete all changed annotations, * then shift the time slots back and finally recreate/restore any * removed annotations. */ private void restoreShift() { if (tier == null) { return; //warn?? } int curPropMode = 0; curPropMode = transcription.getTimeChangePropagationMode(); if (curPropMode != Transcription.NORMAL) { transcription.setTimeChangePropagationMode(Transcription.NORMAL); } // in case the annotation is on a time-subdivision tier, first remove the root annotation // and then restore it. if (rootTier != null) { restoreNormal(); } else { // we are on a root tier AlignableAnnotation actAnnotation = (AlignableAnnotation) tier.getAnnotationAtTime(newBeginTime); // first delete changed annotations on the left side of the current annotation DefaultMutableTreeNode node; AnnotationDataRecord dataRecord; AbstractAnnotation aa; if (changedAnnotations.size() > 0) { for (int i = 0; i < changedAnnotations.size(); i++) { node = (DefaultMutableTreeNode) changedAnnotations.get(i); dataRecord = (AnnotationDataRecord) node.getUserObject(); aa = (AbstractAnnotation) tier.getAnnotationAtTime(dataRecord.getBeginTime()); if (aa != null) { tier.removeAnnotation(aa); } } } if ((leftOffset > 0) || (rightOffset < 0)) { // children could have been destroyed if (actAnnotation != null) { tier.removeAnnotation(actAnnotation); } } if (rightOffset > 0) { // shift the slots backward transcription.shiftBackward(oldEndTime, -rightOffset); } if ((leftOffset > 0) || (rightOffset < 0)) { AnnotationRecreator.createAnnotationFromTree(transcription, rootNode); } else { // restore/update the original, edited annotation if (actAnnotation != null) { actAnnotation.updateTimeInterval(oldBeginTime, oldEndTime); } } // now recreate removed and shifted annotations 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); } /** * 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 */ private 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 + -