📄 annotationsfromoverlapscommand.java
字号:
} /** * @see mpi.eudico.client.annotator.commands.Command#getName() */ 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()); } } /** * Adds a ProgressListener to the list of ProgressListeners. * * @param pl the new ProgressListener */ public synchronized void addProgressListener(ProgressListener pl) { if (listeners == null) { listeners = new ArrayList(2); } listeners.add(pl); } /** * Removes the specified ProgressListener from the list of listeners. * * @param pl the ProgressListener to remove */ public synchronized void removeProgressListener(ProgressListener pl) { if ((pl != null) && (listeners != null)) { listeners.remove(pl); } } /** * Notifies any listeners of a progress update. * * @param percent the new progress percentage, [0 - 100] * @param message a descriptive message */ private void progressUpdate(int percent, String message) { if (listeners != null) { for (int i = 0; i < listeners.size(); i++) { ((ProgressListener) listeners.get(i)).progressUpdated(this, percent, message); } } } /** * Notifies any listeners that the process has completed. * * @param message a descriptive message */ private void progressComplete(String message) { if (listeners != null) { for (int i = 0; i < listeners.size(); i++) { ((ProgressListener) listeners.get(i)).progressCompleted(this, message); } } } /** * Notifies any listeners that the process has been interrupted. * * @param message a descriptive message */ private void progressInterrupt(String message) { if (listeners != null) { for (int i = 0; i < listeners.size(); i++) { ((ProgressListener) listeners.get(i)).progressInterrupted(this, message); } } } /** * A thread class that compares the annotations of two tiers, detects the * ovelaps and creates a new annotation on a third tier, with the * duration of the overlap. */ private class CalcOverLapsThread extends Thread { /** * Creates a new thread to calculate the overlaps. */ public CalcOverLapsThread() { super(); } /** * Creates a new thread to calculate the overlaps. * * @param name the name of the thread */ public CalcOverLapsThread(String name) { super(name); } /** * Interrupts the current calculation process. */ public void interrupt() { super.interrupt(); progressInterrupt("Operation interrupted..."); } /** * The actual action of this thread. * * @see java.lang.Runnable#run() */ public void run() { transcription.setNotifying(false); int curPropMode = 0; curPropMode = transcription.getTimeChangePropagationMode(); if (curPropMode != Transcription.NORMAL) { transcription.setTimeChangePropagationMode(Transcription.NORMAL); } // take the number of annotations on the first source tier as the indicator for // progress updates int annCount = sourceTier1.getNumberOfAnnotations(); float perAnn = 60 / (float) annCount; // two counters or two loops: one for both source tiers int j = 0; ArrayList sourceAnns1 = new ArrayList(sourceTier1.getAnnotations()); int numAnns1 = sourceAnns1.size(); ArrayList sourceAnns2 = new ArrayList(sourceTier2.getAnnotations()); int numAnns2 = sourceAnns2.size(); AlignableAnnotation ann1 = null; AlignableAnnotation ann2 = null; long bt1; long bt2; long et1; long et2; long obt; long oet; progressUpdate(10, "Calculating overlaps..."); // loop over the annotations of the first tier for (int i = 0; i < numAnns1; i++) { ann1 = (AlignableAnnotation) sourceAnns1.get(i); bt1 = ann1.getBeginTimeBoundary(); et1 = ann1.getEndTimeBoundary(); // find overlapping annotations on second tier for (; j < numAnns2; j++) { ann2 = (AlignableAnnotation) sourceAnns2.get(j); bt2 = ann2.getBeginTimeBoundary(); et2 = ann2.getEndTimeBoundary(); if (et2 <= bt1) { continue; } else if (bt2 >= et1) { if (j > 0) { j--; } break; } else { if (bt1 <= bt2) { obt = bt2; } else { obt = bt1; } if (et1 <= et2) { oet = et1; } else { oet = et2; } overlaps.add(new long[] { obt, oet }); } } progressUpdate((int) (10 + (i * perAnn)), null); } perAnn = 25 / (float) overlaps.size(); annRecords = new ArrayList(overlaps.size()); long[] ol; Annotation ann; progressUpdate(70, "Creating annotations..."); for (int i = 0; i < overlaps.size(); i++) { ol = (long[]) overlaps.get(i); ann = destTier.createAnnotation(ol[0], ol[1]); if ((ann != null) && addContent) { switch (timeFormat) { case Constants.MS: ann.setValue(String.valueOf(ol[1] - ol[0])); break; case Constants.SSMS: ann.setValue(TimeFormatter.toSSMSString(ol[1] - ol[0])); break; case Constants.HHMMSSMS: ann.setValue(TimeFormatter.toString(ol[1] - ol[0])); default:} } if (ann != null) { annRecords.add(new AnnotationDataRecord(ann)); } progressUpdate((int) (70 + (i * perAnn)), null); } // restore the time propagation mode transcription.setTimeChangePropagationMode(curPropMode); transcription.setNotifying(true); progressComplete("Operation complete..."); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -