📄 transcriptionimpl.java
字号:
// deal with these older files now by creating a LinkedFileDescriptor if (svgFile == null) { String test = this.fileName.substring(0, this.fileName.length() - 3) + "svg"; if (test.startsWith("file:")) { test = test.substring(5); } if ((new File(test)).exists()) { setSVGFile(test); } } } /* * This method should be in a Utility class or a URL class * Convert a path to a file URL string. Takes care of Samba related problems * file:///path works for all files except for samba file systems, there we need file://machine/path, * i.e. 2 slashes insteda of 3 * * What's with relative paths? */ private String pathToURLString(String path) { // replace all back slashes by forward slashes path = path.replace('\\', '/'); // remove leading slashes and count them int n = 0; while (path.charAt(0) == '/') { path = path.substring(1); n++; } // add the file:// or file:/// prefix if (n == 2) { return "file://" + path; } else { return "file:///" + path; } } /** * Returns the name of the Transcription * * @return name of Transcription */ public String getName() { return name; } /** * DOCUMENT ME! * * @param theName DOCUMENT ME! */ public void setName(String theName) { name = theName; } /** * MK:02/06/19 implementing method from interface Transcription * * @return locatorManager */ public LocatorManager getLocatorManager() { return locatorManager; } /** * Returns the url of the Transcription * * @return url string of Transcription */ public String getFullPath() { return url; } /** * getContentType() * @returns The (semi) mime-type for the content of the resource * * default impl returns "text/plain" */ public String getContentType() { return content_type; } /** * getContentStream() * @returns The InputStream for the content of the resource */ public InputStream getContentStream() { InputStream is = null; if (url != null) { try { is = (new URL(url)).openStream(); } catch (Exception e) { is = null; } } return is; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public String getOwner() { return owner; } /** * Returns a list of all Tags in theTiers, sorted according to MetaTime ordering. * * @param theTiers list of Tiers whose Tags should be returned. * @return an ordered list of Tags. */ public Vector getTagsForTiers(Vector theTiers) { Vector tagList = null; Vector tierTags = null; TreeSet allTags = new TreeSet(); Vector tagsToCompare = null; loadTags(); Iterator tierIter = theTiers.iterator(); while (tierIter.hasNext()) { Tier t = (Tier) tierIter.next(); tierTags = t.getTags(); allTags.addAll(tierTags); } tagList = new Vector(allTags); return tagList; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public MediaObject getMediaObject() { return mediaObject; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public Vector getMediaDescriptors() { return mediaDescriptors; } /** * DOCUMENT ME! * * @param theMediaDescriptors DOCUMENT ME! */ public void setMediaDescriptors(Vector theMediaDescriptors) { mediaDescriptors = theMediaDescriptors; } /** * Returns the collection of linked file descriptors * @return the linked file descriptors */ public Vector getLinkedFileDescriptors() { return linkedFileDescriptors; } /** * Sets the collection of linked files descriptors. * NB: could check for null here * @param descriptors the new descriptors */ public void setLinkedFileDescriptors(Vector descriptors) { linkedFileDescriptors = descriptors; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public MetaTime getMetaTime() { return metaTime; } /** * DOCUMENT ME! */ public void printStatistics() { System.out.println(""); System.out.println(">>> Name: " + name); System.out.println(">>> Number of tiers: " + tiers.size()); } // TreeViewable interface methods public String getNodeName() { return getName(); } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public boolean isTreeViewableLeaf() { return true; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public Vector getChildren() { return new Vector(); } // SharedDataObject interface method(s), via Transcription interface // Unreferenced interface method public void unreferenced() { // corpus should store the only reference to transcription, so // removing this reference results in deletion by GC getParent().removeChild(this); } // ToolAdministrator interface method public Vector getAvailableTools() { return ToolDatabaseImpl.Instance().getAvailableTools(this); } /** * Returns the parent object in the hierarchy of Corpus data objects. * * @return the parent DataTreeNode or null, if no parent exists */ public DataTreeNode getParent() { return parent; } /** * Removes a child in the Corpus data hierarchy by deleting the reference * to the child. The garbage collector will then do the actual deletion. * Children for GestureTranscription are Tiers. Removing Tiers is not yet * implemented, therefore removeChild does nothing yet. * * @param theChild the child to be deleted */ public void removeChild(DataTreeNode theChild) { removeTier((Tier) theChild); } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public Object getConcreteData() { return null; } // HB, 17-oct-01, migrated methods from DobesTranscription to here. public boolean isLoaded() { return isLoaded; } /** * DOCUMENT ME! * * @param loaded DOCUMENT ME! */ public void setLoaded(boolean loaded) { isLoaded = loaded; // jul 2005: useless here: tiers and annotations have not yet been added // at this point /* if (loaded) { timeProposer.correctProposedTimes(this, null, ACMEditEvent.CHANGE_ANNOTATIONS, null); } */ } /** * DOCUMENT ME! * * @param theTier DOCUMENT ME! */ public void addTier(Tier theTier) { tiers.add(theTier); if (isLoaded()) { modified(ACMEditEvent.ADD_TIER, theTier); } } /** * DOCUMENT ME! * * @param theTier DOCUMENT ME! */ public void removeTier(Tier theTier) { ((TierImpl) theTier).removeAllAnnotations(); Vector deletedTiers = new Vector(); deletedTiers.add(theTier); // loop over tiers, remove all tiers where: // - number of annotations is 0 // - and tier.hasAncestor(theTier) Iterator tierIter = tiers.iterator(); while (tierIter.hasNext()) { TierImpl t = (TierImpl) tierIter.next(); if ((t.getNumberOfAnnotations() == 0) && (t.hasAncestor((TierImpl) theTier))) { deletedTiers.add(t); } } tiers.removeAll(deletedTiers); modified(ACMEditEvent.REMOVE_TIER, theTier); } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public TimeOrder getTimeOrder() { return timeOrder; } /** * DOCUMENT ME! */ public void pruneAnnotations() { // remove all annotations that are marked deleted Iterator tierIter = tiers.iterator(); while (tierIter.hasNext()) { ((TierImpl) tierIter.next()).pruneAnnotations(); } timeOrder.pruneTimeSlots(); // HB, 9 aug 02: moved from tier to transcription to because delete // usually concerns more than one tier. modified(ACMEditEvent.REMOVE_ANNOTATION, null); } /** * Refined prune method; only the 'source' tier and its dependent tiers will * be asked to prune their annotations. * * @param fromTier the tier that might have ben changed */ public void pruneAnnotations(Tier fromTier) { if (fromTier instanceof TierImpl) { Vector depTiers = ((TierImpl) fromTier).getDependentTiers(); depTiers.add(0, fromTier); Iterator tierIter = depTiers.iterator(); while (tierIter.hasNext()) { ((TierImpl) tierIter.next()).pruneAnnotations(); } timeOrder.pruneTimeSlots(); modified(ACMEditEvent.REMOVE_ANNOTATION, null); } } /** * DOCUMENT ME! * * @param theAuthor DOCUMENT ME! */ public void setAuthor(String theAuthor) { author = theAuthor; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public String getAuthor() { return author; } /** * DOCUMENT ME! * * @param theTypes DOCUMENT ME! */ public void setLinguisticTypes(Vector theTypes) { linguisticTypes = theTypes; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public Vector getLinguisticTypes() { return linguisticTypes; } /** * DOCUMENT ME! * * @param name DOCUMENT ME! * * @return DOCUMENT ME! */ public LinguisticType getLinguisticTypeByName(String name) { LinguisticType lt = null; if (linguisticTypes != null) { Iterator typeIt = linguisticTypes.iterator(); LinguisticType ct = null; while (typeIt.hasNext()) { ct = (LinguisticType) typeIt.next();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -