📄 interlinearizer.java
字号:
/** * DOCUMENT ME! * * @return DOCUMENT ME! */ public int getBlockSpacing() { if (blockSpacing < 0) { // default: derived from line spacing return 20 + (3 * getLineSpacing()); } else { return blockSpacing; } } /** * DOCUMENT ME! * * @param blockSpacing DOCUMENT ME! */ public void setBlockSpacing(int blockSpacing) { this.blockSpacing = blockSpacing; } /** * DOCUMENT ME! * * @return */ public int getLineWrapStyle() { return lineWrapStyle; } /** * DOCUMENT ME! * * @return */ public long getMediaTime() { return mediaTime; } /** * DOCUMENT ME! * * @return */ public long[] getSelection() { return selection; } /** * DOCUMENT ME! * * @return */ public boolean isTierLabelsShown() { return tierLabelsShown; } /** * DOCUMENT ME! * * @return */ public boolean isTimeCodeShown() { return timeCodeShown; } /** * DOCUMENT ME! * * @return */ public int getTimeCodeType() { return timeCodeType; } /** * DOCUMENT ME! * * @return */ public String[] getVisibleTiers() { if (sorted) { return visibleTiers; } if (sortingStyle == TIER_HIERARCHY) { visibleTiers = sortByHierarchy(visibleTiers); } else if (sortingStyle == BY_LINGUISTIC_TYPE) { visibleTiers = sortByLinguisticType(visibleTiers); } else if (sortingStyle == BY_PARTICIPANT) { visibleTiers = sortByParticipant(visibleTiers); } sorted = true; return visibleTiers; } /** * Sorts according to tier hierarchy. * * @param visibleTiers * * @return */ private String[] sortByHierarchy(String[] visibleTiers) { Vector sortedTiers = new Vector(); String[] sortedTierNames = new String[visibleTiers.length]; List vTierList = Arrays.asList(visibleTiers); Vector topTiers = ((TranscriptionImpl) transcription.getTranscription()).getTopTiers(); for (int i = 0; i < topTiers.size(); i++) { TierImpl topTier = (TierImpl) topTiers.elementAt(i); sortedTiers.addAll(transcription.getTierTree(topTier)); } int arrayIndex = 0; for (int j = 0; j < sortedTiers.size(); j++) { TierImpl t = (TierImpl) sortedTiers.elementAt(j); if (vTierList.contains(t.getName())) { sortedTierNames[arrayIndex++] = t.getName(); } } return sortedTierNames; } private String[] sortByLinguisticType(String[] visibleTiers) { Hashtable typesHash = new Hashtable(); LinguisticType notSpecifiedLT = new LinguisticType("NOT_SPECIFIED"); LinguisticType tcLT = new LinguisticType(TimeCodedTranscription.TC_LING_TYPE); for (int i = 0; i < visibleTiers.length; i++) { String tierName = visibleTiers[i]; LinguisticType lt = notSpecifiedLT; TierImpl tier = ((TierImpl) transcription.getTranscription() .getTierWithId(tierName)); if (tier != null) { lt = tier.getLinguisticType(); if (lt == null) { lt = notSpecifiedLT; } } else if (tierName.startsWith( TimeCodedTranscription.TC_TIER_PREFIX)) { lt = tcLT; } Vector tiersOfType = (Vector) typesHash.get(lt); if (tiersOfType == null) { tiersOfType = new Vector(); typesHash.put(lt, tiersOfType); } tiersOfType.add(tierName); } Vector sortedTierNames = new Vector(); Enumeration typeEnum = typesHash.keys(); while (typeEnum.hasMoreElements()) { LinguisticType type = (LinguisticType) typeEnum.nextElement(); sortedTierNames.addAll((Vector) typesHash.get(type)); } String[] sortedNameStrings = new String[visibleTiers.length]; for (int j = 0; j < sortedTierNames.size(); j++) { sortedNameStrings[j] = (String) sortedTierNames.elementAt(j); } return sortedNameStrings; } private String[] sortByParticipant(String[] visibleTiers) { Hashtable participantHash = new Hashtable(); String notSpecifiedParticipant = "NOT_SPECIFIED"; for (int i = 0; i < visibleTiers.length; i++) { String tierName = visibleTiers[i]; String participant = notSpecifiedParticipant; TierImpl tier = ((TierImpl) transcription.getTranscription() .getTierWithId(tierName)); if (tier != null) { participant = tier.getParticipant(); if (participant == null) { participant = notSpecifiedParticipant; } } Vector tiersOfParticipant = (Vector) participantHash.get(participant); if (tiersOfParticipant == null) { tiersOfParticipant = new Vector(); participantHash.put(participant, tiersOfParticipant); } tiersOfParticipant.add(tierName); } Vector sortedTierNames = new Vector(); Enumeration participantEnum = participantHash.keys(); while (participantEnum.hasMoreElements()) { String part = (String) participantEnum.nextElement(); sortedTierNames.addAll((Vector) participantHash.get(part)); } String[] sortedNameStrings = new String[visibleTiers.length]; for (int j = 0; j < sortedTierNames.size(); j++) { sortedNameStrings[j] = (String) sortedTierNames.elementAt(j); } return sortedNameStrings; } /** * DOCUMENT ME! * * @return */ public long[] getVisibleTimeInterval() { return visibleTimeInterval; } /** * DOCUMENT ME! * * @return */ public int getWidth() { if (width > 0) { return width; } else { // find width from max horizontally used space return metrics.getMaxHorizontallyUsedWidth(); } } /** * DOCUMENT ME! * * @param annotation */ public void setActiveAnnotation(Annotation annotation) { activeAnnotation = annotation; } /** * DOCUMENT ME! * * @param i */ public void setAlignmentUnit(int i) { alignmentUnit = i; } /** * DOCUMENT ME! * * @param i */ public void setBlockWrapStyle(int i) { blockWrapStyle = i; } /** * DOCUMENT ME! * * @param b */ public void setEmptySlotsShown(boolean b) { emptySlotsShown = b; } /** * DOCUMENT ME! * * @param i */ public void setHeight(int i) { height = i; } /** * DOCUMENT ME! * * @param i */ public void setLineSpacing(int i) { lineSpacing = i; } /** * DOCUMENT ME! * * @param i */ public void setLineWrapStyle(int i) { lineWrapStyle = i; } /** * DOCUMENT ME! * * @param l */ public void setMediaTime(long l) { mediaTime = l; } /** * DOCUMENT ME! * * @param ls */ public void setSelection(long[] ls) { selection = ls; } /** * DOCUMENT ME! * * @param show */ public void setTierLabelsShown(boolean show) { tierLabelsShown = show; metrics.showLeftMargin(show); } /** * DOCUMENT ME! * * @param b */ public void setTimeCodeShown(boolean b) { timeCodeShown = b; } /** * DOCUMENT ME! * * @param i */ public void setTimeCodeType(int i) { timeCodeType = i; } /** * DOCUMENT ME! * * @param strings */ public void setVisibleTiers(String[] strings) { visibleTiers = strings; } /** * DOCUMENT ME! * * @param ls */ public void setVisibleTimeInterval(long[] ls) { visibleTimeInterval = ls; } /** * DOCUMENT ME! * * @param i */ public void setWidth(int i) { width = i; } /** * */ public void setFont(String tierName, Font f) { int fontSize = getFontSize(tierName); f = f.deriveFont((float) fontSize); fonts.put(tierName, f); } /** * DOCUMENT ME! * * @param tierName DOCUMENT ME! * @param size DOCUMENT ME! */ public void setFontSize(String tierName, int size) { fontSizes.put(tierName, new Integer(size)); fonts.put(tierName, getFont(tierName).deriveFont((float) size)); } /** * DOCUMENT ME! * * @return */ public int getEmptyLineStyle() { return emptyLineStyle; } /** * DOCUMENT ME! * * @param i */ public void setEmptyLineStyle(int i) { emptyLineStyle = i; } /** * DOCUMENT ME! * * @return */ public int getSortingStyle() { return sortingStyle; } /** * DOCUMENT ME! * * @param i */ public void setSortingStyle(int i) { sortingStyle = i; sorted = false; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public TimeCodedTranscription getTranscription() { return transcription; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public boolean forPrinting() { return forPrinting; } /** * DOCUMENT ME! * * @param forPrinting DOCUMENT ME! */ public void setForPrinting(boolean forPrinting) { this.forPrinting = forPrinting; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public int getPageHeight() { return pageHeight; } /** * DOCUMENT ME! * * @param height DOCUMENT ME! */ public void setPageHeight(int height) { pageHeight = height; } /** * DOCUMENT ME! * * @param tierName DOCUMENT ME! * * @return DOCUMENT ME! */ public int getCharEncoding(String tierName) { int encoding = UTF8; if (tierName == null) { return encoding; // UTF8 is always the default } if (!charEncodings.containsKey(tierName)) { return encoding; } Integer encodingInt = (Integer) charEncodings.get(tierName); if (encodingInt != null) { encoding = encodingInt.intValue(); } return encoding; } /** * DOCUMENT ME! * * @param tierName DOCUMENT ME! * @param charEncoding DOCUMENT ME! */ public void setCharEncoding(String tierName, int charEncoding) { charEncodings.put(tierName, new Integer(charEncoding)); } /** * Empty horizontal space between neightbouring annotations. * * @return DOCUMENT ME! */ public int getEmptySpace() { int emptySpace = 10; // 10 pixels in case of image if (getAlignmentUnit() == BYTES) { emptySpace = 1; } return emptySpace; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public Metrics getMetrics() { return metrics; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public boolean getCorrectAnnotationTimes() { return correctAnnotationTimes; } /** * DOCUMENT ME! * * @param correctAnnotationTimes DOCUMENT ME! */ public void setCorrectAnnotationTimes(boolean correctAnnotationTimes) { this.correctAnnotationTimes = correctAnnotationTimes; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -