📄 sblayout.java
字号:
* * @return DOCUMENT ME! */ /* public void rebuildTiers() { createTimeSegHash(); calcuateTierWidths(); } */ /** * have the objects in the tier image been added/removed * * @return boolean */ /* public boolean isNewImage() { boolean b = _recal; _recal = false; return b; } */ /** * returns a vector of SBTags that will be inserted into the scrollpane * * @return Vector of SBTag * * @see SBTag */ public Vector getSBTags() { return _vSBTags; } /** * returns current reference segement start time * * @return long time value */ public long getCurrentRefStartTime() { if (_ref_tag == null) { return 0; } return (_ref_tag.getBeginTimeBoundary()); } /** * returns current reference segement end time * * @return long time value */ public long getCurrentRefEndTime() { if (_ref_tag == null) { return 0; } return (_ref_tag.getEndTimeBoundary()); } /** * sets reference tier to the prev Annotation based on the current _ref_tag * * @return true for is next otherwise false */ public boolean getPrevRef() { Annotation an = null; if (_ref_tier == null) { return false; } an = ((TierImpl) _ref_tier).getAnnotationBefore(_ref_tag); if (an == null) { return false; } return true; } /** * this is WRONG it breaks the ability to return more then one block in a * view it is here for a quick hack to get the new layout stuff working * * @return DOCUMENT ME! */ public Annotation getRefAnn() { Annotation refann = (Annotation) _vBlockOrder.elementAt(_nBlockPos); return refann; } /** * Very temporary method to avoid ArrayIndexOutOfBoundsExceptions in Elan * 2.0 without introducing NullPointerExceptions (in older and current * Elan version). This is no good... * * @return whether it is save or not to call getRefAnn() */ public boolean isRefAnnAvailable() { if (_vBlockOrder == null) { return false; } return ((_nBlockPos < _vBlockOrder.size()) && !(_nBlockPos < 0)); } /** * DOCUMENT ME! * * @param filename DOCUMENT ME! * @param header DOCUMENT ME! */ public void exportAll(String filename, String header) { try { openWriter(filename); // open fp for writting getSegOrder(); // get all segments or blocks write(header + "\r\r\n"); for (int i = 0; i < _vBlockOrder.size(); i++) { Annotation refann = (Annotation) _vBlockOrder.elementAt(i); AnnotationSize as = new AnnotationSize(_transcription, refann); Vector vtiers = as.getTiers(); Enumeration e = vtiers.elements(); while (e.hasMoreElements()) { Tier tier = (Tier) e.nextElement(); // write tier name write(chopAtChar(tier.getName()) + " "); boolean isSILIPAcharacterset = (_sbxtf != null) && _sbxtf.isIPAtier(chopAtChar(tier.getName())); //Vector tieranns = as.getTierLayoutInChar(tier); //Enumeration ee = tieranns.elements(); // changed HS 19-01-2004 ArrayList tierAnn = as.getTierLayoutInPixels(tier, null); Iterator it = tierAnn.iterator(); String wstr = ""; while (it.hasNext()) { AnnotationSizeContainer asc = (AnnotationSizeContainer) it.next(); Annotation a = asc.getAnnotation(); if (a == null) { wstr = (padString("", asc.getSize() + 1)); } else { String trimedValueofa = a.getValue().trim(); if (isSILIPAcharacterset) { trimedValueofa = _simpleConverter.toBinary(trimedValueofa); } wstr = (padString(trimedValueofa, asc.getSize() + 1)); } // write annotation write(padString(wstr, asc.getSize())); // write the tier speaker and // time stamp block when the // current annotation is the // ref annotation writeBlockStamp(a, refann); } write("\r\n"); } write("\r\n"); } _writer.flush(); _writer.close(); } catch (Exception ex) { ex.printStackTrace(); } } /* public StringBuffer exportAll2(String filename,String header) { try { openWriter(filename); getSegOrder(); // get all segments or blocks write(header+"\n"); setWorkingSegmentsRange(1,0); // set to load 1 block at a time at n block exportSeg(); for (int i = 0 ; i < _vBlockOrder.size()-1; i++) { setWorkingSegmentsRange(1,1); // set to load 1 block at a time at n block exportSeg(); write("\r\r\n"); } _writer.flush(); _writer.close(); } catch(Exception e) {} return null; } private StringBuffer exportSeg() { try { Vector v = buildAllTiers(); // get all tiers for current block Enumeration e = v.elements(); // get enumeration of current tier/block while(e.hasMoreElements()) { Enumeration eVisTier = null; Hashtable ht = (Hashtable) e.nextElement(); // get next tier in block eVisTier = _transcription.getTiers(null).elements(); // get all the tiers while(eVisTier.hasMoreElements()) { Tier tiercurrent = (Tier)eVisTier.nextElement(); Vector vTier = (Vector) ht.get(tiercurrent); // get all tags at tiercurrent if (vTier != null) { // write the tier name write(chopAtChar(tiercurrent.getName())+" "); // make enum of tier elements Enumeration eTier = vTier.elements(); String wkstr = ""; int sz = 0; Annotation last = null; // loop thu all the elements while(eTier.hasMoreElements()) { Annotation a = null; Object obj = (Object)eTier.nextElement(); if (obj instanceof Annotation) { a = (Annotation) obj; // get spacing of tag sz = _annSize.getAnnotationGroupSpacing(_transcription,a)+1; wkstr = a.getValue(); last = a; } else if( obj instanceof Long) { Long l = (Long) obj; sz = (_annSize.getSpacingForTime(_transcription,last,l.longValue()))+1; // get spacing of blank item wkstr = ""; } // write annotation write(padString(wkstr,sz)); // write the tier speaker and // time stamp block when the // current annotation is the // ref annotation //writeBlockStamp(a); } } write("\r\r\n"); } } } catch (Exception ex) { ex.printStackTrace(); return null; } return null; } */ private String padString(String orig, int totallen) { orig.trim(); int len = totallen - orig.length(); if (len < 0) { return orig; } for (int i = 0; i < len; i++) orig += " "; return orig; } private String chopAtChar(String str) { int in = str.indexOf("@"); if (in == -1) { return addSlash(str); } return addSlash(str.substring(0, in)); } private String addSlash(String str) { int in = str.indexOf("\\"); if (in == -1) { str = "\\" + str; } return str; } private String getSpeakerFormat(String str) { int in = str.indexOf("@"); if (in == -1) { return "\\EUDICOp unknown"; } return "\\EUDICOp " + str.substring(in + 1); } private void writeBlockStamp(Annotation a, Annotation refann) throws IOException { if (a == null) { return; } if (a.equals(refann)) { String wkstr = "\r\n"; try { Tier t = a.getTier(); wkstr += (getSpeakerFormat(t.getName()) + "\r\n"); } catch (Exception e) { } wkstr += ("\\EUDICOt0 " + (a.getBeginTimeBoundary() * .001) + "\r\n\\EUDICOt1 " + (a.getEndTimeBoundary() * .001)); write(wkstr + "\r\n"); } return; } private void openWriter(String file) throws IOException { try { FileOutputStream fos = new FileOutputStream(file); _writer = new OutputStreamWriter(fos, "ISO-8859-1"); } catch (IOException ioe) { throw ioe; } } private void write(String text) throws IOException { try { _writer.write(text); } catch (IOException ioe) { throw ioe; } } /** * DOCUMENT ME! * $Id: SBLayout.java,v 1.4 2006/05/30 12:50:11 hasloe Exp $ * @author $Author: hasloe $ * @version $Revision: 1.4 $ */ public class AnnotationContainer implements Comparable { /** Holds value of property DOCUMENT ME! */ Annotation _ann; /** * Creates a new AnnotationContainer instance * * @param a DOCUMENT ME! */ public AnnotationContainer(Annotation a) { _ann = a; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public Annotation getAnnotation() { return _ann; } /** * DOCUMENT ME! * * @param obj DOCUMENT ME! * * @return DOCUMENT ME! */ public int compareTo(Object obj) { AnnotationContainer ac = (AnnotationContainer) obj; Annotation a = ac.getAnnotation(); if (_ann.getBeginTimeBoundary() > a.getBeginTimeBoundary()) { return 1; } if (_ann.getBeginTimeBoundary() < a.getBeginTimeBoundary()) { return -1; } return 0; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -