⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interlinear.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            if (outputMode == INTERLINEAR_TEXT) {                Preferences.set(prefInsertTab, new Boolean(insertTabs), null);            }        }    }    /**     * Load stored preferences.     */    void loadPreferences() {        Object curPref;        curPref = Preferences.get(prefSelectionOnly, transcription);        if (curPref instanceof Boolean) {            setSelectionOnly(((Boolean) curPref).booleanValue());        }        curPref = Preferences.get(prefBlockWrapStyle, null);        if (curPref instanceof Integer) {            setBlockWrapStyle(((Integer) curPref).intValue());        }        curPref = Preferences.get(prefLineWrapStyle, null);        if (curPref instanceof Integer) {            setLineWrapStyle(((Integer) curPref).intValue());        }        curPref = Preferences.get(prefLabelsShown, null);        if (curPref instanceof Boolean) {            setTierLabelsShown(((Boolean) curPref).booleanValue());        }        curPref = Preferences.get(prefTimeCodeShown, null);        if (curPref instanceof Boolean) {            setTimeCodeShown(((Boolean) curPref).booleanValue());        }        curPref = Preferences.get(prefTimeCodeType, null);        if (curPref instanceof Integer) {            setTimeCodeType(((Integer) curPref).intValue());        }        curPref = Preferences.get(prefVisibleTiers, transcription);        if (curPref instanceof String[]) {            // setVisibleTiers((String[]) curPref);            String[] vis = (String[]) curPref;            String name = null;            TierImpl t = null;            ArrayList allVis = new ArrayList();            for (int i = 0; i < vis.length; i++) {                name = vis[i];                t = (TierImpl) transcription.getTierWithId(name);                if (t != null) {                    allVis.add(t);                }            }            Object allOrdered = Preferences.get(prefTierOrder, transcription);            ArrayList at = new ArrayList();            if (allOrdered instanceof ArrayList) {                at = (ArrayList) allOrdered; // saved ordered list of tiers            }            // add new tiers to the list of visible tiers            Vector v = transcription.getTiers();            for (int j = 0; j < v.size(); j++) {                t = (TierImpl) v.get(j);                name = t.getName();                if (!allVis.contains(t) && !at.contains(name)) {                    allVis.add(t);                }            }            setVisibleTiers(allVis);        }        if ((outputMode == PRINT) || (outputMode == HTML)) {            curPref = Preferences.get(prefFontSizes, transcription);            if (curPref instanceof HashMap) {                fontSizes = (HashMap) curPref;                Iterator keysIt = fontSizes.keySet().iterator();                String tierName;                Object size;                while (keysIt.hasNext()) {                    tierName = (String) keysIt.next();                    size = fontSizes.get(tierName);                    if (size instanceof Integer) {                        setFontSize(tierName, ((Integer) size).intValue());                    }                }            }            curPref = Preferences.get(prefLineSpacing, null);            if (curPref instanceof Integer) {                setLineSpacing(((Integer) curPref).intValue());            }            curPref = Preferences.get(prefBlockSpacing, null);            if (curPref instanceof Integer) {                setBlockSpacing(((Integer) curPref).intValue());            }        }        if (outputMode == HTML) {            curPref = Preferences.get(prefHTMLPixWidth, null);            if (curPref instanceof Integer) {                setWidth(((Integer) curPref).intValue());            }            curPref = Preferences.get(prefBlockSpacingTextOut, null);            if (curPref instanceof Integer) {                setBlockSpacing(((Integer) curPref).intValue());            }        } else if (outputMode != PRINT) {            curPref = Preferences.get(prefNumCharPerLine, null);            if (curPref instanceof Integer) {                setWidth(((Integer) curPref).intValue());            }            curPref = Preferences.get(prefBlockSpacingTextOut, null);            if (curPref instanceof Integer) {                setBlockSpacing(((Integer) curPref).intValue());            }        }        if (outputMode == INTERLINEAR_TEXT) {            curPref = Preferences.get(prefInsertTab, null);            if (curPref instanceof Boolean) {                setInsertTabs(((Boolean) curPref).booleanValue());            }        }    }    /**     * Initialises a reset and recalculation of the annotation blocks and     * pages, using the graphics of the specified BufferedImage.     *     * @param bi the BufferedImage object, provided by a preview renderer     */    public void renderView(BufferedImage bi) {        calculateMetrics(bi.getGraphics());    }    /**     * Initialises a reset and recalculation of the annotation blocks,  based     * on character alignment.     */    public void renderView() {        calculateMetrics();    }    /**     * Calls a suitable renderer to render the contents of the specified page     * to the specified Graphics object.     *     * @param g the Graphics object     * @param pageIndex the page to render     *     * @return true if the page was successfully rendered     */    public boolean renderPage(Graphics g, int pageIndex) {        if (alignmentUnit == PIXELS) { // call to renderView should be consistent with params            PixelRenderer.render(this, g, pageIndex);            return true;        }        return false;    }    /**     * Calculate annotation widths in blocks (including dependent annotations),     * calculate print blocks, a combination of annotation blocks that fit     * (partially) on a block line and calculate pages / page breaks.     *     * @param graphics the graphics object to use for the calculations     */    protected void calculateMetrics(Graphics graphics) {        resetMetrics();        metrics.calculateAnnotationBlocks(graphics);        metrics.calculatePrintBlocks();        metrics.calculatePageBreaks();        setHeight(pageHeight * metrics.getPageBreaks().size());    }    /**     * Calculates metrics based on byte-wise or character wise alignment.     */    protected void calculateMetrics() {        resetMetrics();        metrics.calculateAnnotationBlocks(null);        metrics.calculatePrintBlocks();        // this creates a single page breaks object        metrics.calculatePageBreaks();    }    /**     * Renders the view to the specifeid BufferedImage using the specied     * offsets. In case of a character based interlinearization the     * <code>PixelRenderer</code> converts the character positions to pixel     * based  positions in order to create a preview of the final text output.     *     * @param bi the BufferedImage object to render to     * @param offset the hor. and vert. offset     */    public void drawViewOnImage(BufferedImage bi, int[] offset) {        if (alignmentUnit == PIXELS) { // call to renderView should be consistent with params            PixelRenderer.render(this, bi, offset);        } else {            PixelRenderer.renderCharacterPreview(this, bi, offset);        }    }    // getters and setters    /**     * Returns the active annotation     *     * @return the active annotation     */    public Annotation getActiveAnnotation() {        return activeAnnotation;    }    /**     * Returns the alignment unit type.     *     * @return the alignment unit type, one of <code>PIXELS</code>,     *         <code>BYTES</code> or <code>CHARACTERS</code>     */    public int getAlignmentUnit() {        return alignmentUnit;    }    /**     * Returns the block wrap style type.     *     * @return the block wrap style type, one of <code>NO_WRAP</code>,     *         <code>EACH_BLOCK</code>,  <code>BLOCK_BOUNDARIES</code> or     *         <code>WITHIN_BLOCKS</code>     */    public int getBlockWrapStyle() {        return blockWrapStyle;    }    /**     * Returns whether empty slots are shown.     *     * @return true when empty slot are painted, false otherwise     */    public boolean isEmptySlotsShown() {        return emptySlotsShown;    }    /**     * Returns the Font to use for the specified tier.     *     * @param tierName the name of the tier     *     * @return the font for printing or preview     */    public Font getFont(String tierName) {        Font f = (Font) fonts.get(tierName);        if (f == null) { // use default font            f = DEFAULTFONT;        }        return f;    }    /**     * Returns the font size used for the specified tier     *     * @param tierName the name of the tier     *     * @return the size of the font for this tier     */    public int getFontSize(String tierName) {        int size = 0;        Integer sizeInt = (Integer) fontSizes.get(tierName);        if (sizeInt != null) {            size = sizeInt.intValue();        } else {            size = DEFAULT_FONT_SIZE;        }        return size;    }    /**     * Returns the total height necessary for rendering     *     * @return the total height     */    public int getHeight() {        if (height > 0) {            return height;        } else {            return 0;        }    }    /**     * Returns the number of pixels to add between lines.     *     * @return the number of pixels to add between lines     */    public int getLineSpacing() {        return lineSpacing;    }    /**     * Returns the number of pixels to add between blocks.     *     * @return the number of pixels to add between blocks.     */    public int getBlockSpacing() {        if (blockSpacing < 0) { // default: derived from line spacing            if (outputMode == PRINT) {                return 20 + (3 * getLineSpacing());            } else {                return DEFAULT_TEXT_BLOCK_SPACING;            }        } else {            return blockSpacing;        }    }    /**     * Set the number of pixels to add between blocks.     *     * @param blockSpacing the number of pixels to add between blocks.     */    public void setBlockSpacing(int blockSpacing) {        this.blockSpacing = blockSpacing;    }    /**     * Returns the line wrap style.     *     * @return either <code>NO_WRAP</code> or <code>NEXT_LINE</code>     */    public int getLineWrapStyle() {        return lineWrapStyle;    }    /**     * Returns the current media time.     *     * @return the current media time     */    public long getMediaTime() {        return mediaTime;    }    /**     * Returns the selection begin and end time.     *     * @return the selection begin and end time     */    public long[] getSelection() {        return selection;    }    /**     * Returns whether or not the tier labels should be included in the output.     *     * @return true if the tier labels are included in the left margin, false     *         otherwise     */    public boolean isTierLabelsShown() {        return tierLabelsShown;    }    /**     * Returns whether or not time information of each block should be included     * in the  output.     *     * @return true if time information is included in the output, false     *         otherwise     */    public boolean isTimeCodeShown() {        return timeCodeShown;    }    /**     * Returns the type of time codes to use.     *     * @return the timecode type, one of <code>HHMMSSMS</code>, or     *         <code>SSMS</code>     */    public int getTimeCodeType() {        return timeCodeType;    }    /**     * Returns a list of the currently visible tiers.     *     * @return a sorted list of the visible tier objects

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -