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

📄 interlinearblock.java

📁 编辑视频文件
💻 JAVA
字号:
/* * File:     InterlinearBlock.java * Project:  MPI Linguistic Application * Date:     02 May 2007 * * Copyright (C) 2001-2007  Max Planck Institute for Psycholinguistics * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package mpi.eudico.client.annotator.interlinear;import java.util.ArrayList;/** * A class that represents a block of positioned printable, interlinear * annotations.  It is in fact a group of interlinear tiers, occupying an area * that spans from the left border to the right border of the output area and * that optionally includes a margin for tier labels. * * @author HS * @version 1.0 */public class InterlinearBlock {    private ArrayList printTiers;    private int occBlockWidth;    /**     * Creates a new InterlinearBlock instance     *     * @param printTiers a list of InterlinearTiers that can receive     *        InterlinearAnnotations     */    public InterlinearBlock(ArrayList printTiers) {        this.printTiers = printTiers;    }    /**     * Returns the InterlinearTier of the specified name.     *     * @param tierName the name of the tier     *     * @return the <code>InterlinearTier</code> for the specified tier     */    public InterlinearTier getPrintTier(String tierName) {        InterlinearTier pt;        for (int i = 0; i < printTiers.size(); i++) {            pt = (InterlinearTier) printTiers.get(i);            if (pt.getTierName().equals(tierName)) {                return pt;            }        }        return null;    }    /**     * Returns a list of the InterlinearTiers in this block.     *     * @return a list of the InterlinearTiers in this block     */    public ArrayList getPrintTiers() {        return printTiers;    }    /**     * Returns the total numbers of lines on the tiers in this block.     *     * @return the total numbers of lines on the tiers in this block     */    public int getNumberOfLines() {        int lines = 0;        InterlinearTier pt;        for (int i = 0; i < printTiers.size(); i++) {            pt = (InterlinearTier) printTiers.get(i);            lines += pt.getNumLines();        }        return lines;    }    /**     * Invokes the removal of tiers that contain no annotations.     */    public void removeEmptyTiers() {        InterlinearTier pt;        for (int i = printTiers.size() - 1; i >= 0; i--) {            pt = (InterlinearTier) printTiers.get(i);            if (pt.getAnnotations().size() == 0) {                printTiers.remove(i);            } else {                // if all annotations have empty strings as value, remove the tier                InterlinearAnnotation ia = null;                int size = pt.getAnnotations().size();                boolean empty = true;                for (int j = 0; j < size; j++) {                    ia = (InterlinearAnnotation) pt.getAnnotations().get(j);                    if (!ia.getValue().equals("")) {                        empty = false;                        break;                    }                }                if (empty) {                    printTiers.remove(i);                }            }        }    }    /**     * Removes the tiers that only contain empty annotations (value = "").     */    public void removeEmptySlotOnlyTiers() {        InterlinearTier pt;        InterlinearAnnotation ia = null;        for (int i = printTiers.size() - 1; i >= 0; i--) {            pt = (InterlinearTier) printTiers.get(i);            int size = pt.getAnnotations().size();            boolean empty = true;            for (int j = 0; j < size; j++) {                ia = (InterlinearAnnotation) pt.getAnnotations().get(j);                if (!ia.getValue().equals("")) {                    empty = false;                    break;                }            }            if (empty) {                printTiers.remove(i);            }        }    }    /**     * Returns the width currently occupied by the annotations in the tiers.     *     * @return the width     */    public int getOccupiedBlockWidth() {        return occBlockWidth;    }    /**     * The occupied block width can be set explicitely from the outside world,     * irrespective of the annotations present on the tiers.     *     * @param occBlockWidth the new block width     */    public void setOccupiedBlockWidth(int occBlockWidth) {        this.occBlockWidth = occBlockWidth;        for (int i = 0; i < printTiers.size(); i++) {            ((InterlinearTier) printTiers.get(i)).setPrintWidth(occBlockWidth);        }    }    /**     * Calculates the current max. occupied horizontal space by any annotation     * on  any tier in the block.     *     * @return the current occupied horizontal space     */    public int calculateOccupiedBlockWidth() {        int curWidth = 0;        for (int i = 0; i < printTiers.size(); i++) {            int tWidth = ((InterlinearTier) printTiers.get(i)).getPrintAdvance();            if (tWidth > curWidth) {                curWidth = tWidth;            }        }        return curWidth;    }}

⌨️ 快捷键说明

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