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

📄 interlinearviewer.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    int tagWidth = asc.getSize() + HOR_TAG_SURPLUS;                    if (tagWidth < MIN_TAG_SIZE) {                        tagWidth = MIN_TAG_SIZE;                    }                    int tagHeight = (pixelsForTierHeight -                        (2 * pixelsForTierHeightMargin));                    if (((TierImpl) tier).getLinguisticType().getConstraints() != null) {                        stereo = ((TierImpl) tier).getLinguisticType()                                  .getConstraints().getStereoType();                    } else {                        stereo = -1;                    }                    if (a == null) {                        // hack to stop "clickable" null SBTags from showing up                        // BEGIN HACK ALERT                        time = asc.getStartTime();                        // gng: 24 Oct 2002; added more specific logic , to which tiers are                        // not editable (freetranslation tier was not showing up as editable)                        if ((((TierImpl) tier).getParentTier() == ((TierImpl) tier).getRootTier()) &&                                ((stereo != Constraint.SYMBOLIC_ASSOCIATION) ||                                symbassflag)) {                            if (asc != tieranns.get(0)) {                                time = -1;                                //System.out.println("Time -1 added (" + tier + ", " + a + ")");                            }                        }                        //System.out.println("ADD NULL TAG:"+xPos+" "+yPos+"time:"+time);                        rect = new Rectangle();                        rect.x = xPos;                        rect.y = yPos + pixelsForTierHeightMargin;                        rect.height = tagHeight;                        rect.width = tagWidth;                        // END HACK ALERT                    } else {                        rect = new Rectangle();                        rect.x = xPos;                        rect.y = yPos + pixelsForTierHeightMargin;                        rect.height = tagHeight;                        rect.width = tagWidth;                    }                    //asc.setRect(new Rectangle(xPos,yPos,tagWidth,tagHeight));                    if (stereo == Constraint.SYMBOLIC_ASSOCIATION) {                        symbassflag = true;                    }                    SBTime sbt = null;                    if (null != a) {                        sbt = new SBTime(a, a.getBeginTimeBoundary(),                                a.getEndTimeBoundary(), rect, a.getValue());                        //ht.add(new SBTime(a.getBeginTimeBoundary(), a.getEndTimeBoundary(), rect, a.getValue()));                    } else {                        sbt = new SBTime(null, time, time, rect, "");                        //sbt = new SBTime(null, time, time + HOR_TAG_GAP, rect, "");                        //ht.add(new SBTime(time, time + HOR_TAG_GAP, rect, ""));                    }                    ht.add(sbt);                    if ((a != null) && (a == activeAnnotation)) {                        refAnnotation = sbl.getRefAnn();                        cursorTag = sbt;                    }                    if ((xPos + tagWidth) > segWidth) {                        segWidth = xPos + tagWidth;                    }                    xPos += (tagWidth + HOR_TAG_GAP);                }                _vTiers.add(ht);            } else {                _vTiers.add(new Vector());            }            yPos += pixelsForTierHeight;        }        //end while loop        currentSegmentWidth = segWidth + HOR_TAG_GAP;        buildLayout();    }    /**     * For each segment that is to be displayed a new canvas width is     * calculated and the scrollbars have to be updated accordingly.     */    private void updateScrollBar() {        // vertical first        int vValue = vScrollBar.getValue();        int max = VER_MARGIN + (visibleTiers.size() * pixelsForTierHeight);        // before changing scrollbar values do a setValue(0), otherwise        // setMaxiimum and/or setVisibleAmount will not be accurate        vScrollBar.setValue(0);        vScrollBar.setMaximum(max);        vScrollBar.setVisibleAmount(getHeight() - defBarWidth);        if (((vValue + getHeight()) - defBarWidth) > max) {            vValue = max - getHeight() - defBarWidth;        }        vScrollBar.setValue(vValue);        // horizontal next        int hValue = hScrollBar.getValue();        /* because in the BorderLayout the horizontal scrollbar         * includes the space occupied by the vertical scrollbar */        int hBarWidth = 2 * defBarWidth;        hScrollBar.setValue(0);        hScrollBar.setMaximum(currentSegmentWidth);        hScrollBar.setVisibleAmount(getWidth() - hBarWidth);        if (((hValue + getWidth()) - hBarWidth) > currentSegmentWidth) {            hValue = currentSegmentWidth - getWidth() - hBarWidth;        }        hScrollBar.setValue(hValue);        vScrollBar.revalidate();        hScrollBar.revalidate();    }    /**     * The tiers present in a document can be manipulated in a MultiTierViewer,     * i.g. the ordering of the tiers and their visibility can be changed.     * This viewer updates its state after such a change.     *     * @param tiers DOCUMENT ME!     */    public void setVisibleTiers(Vector tiers) {        visibleTiers.clear();        Tier2D t2d;        Tier tier;        Enumeration en = tiers.elements();        while (en.hasMoreElements()) {            tier = (Tier) en.nextElement();            Iterator it = allTiers.iterator();            while (it.hasNext()) {                t2d = (Tier2D) it.next();                if (t2d.getTier() == tier) {                    visibleTiers.add(t2d);                    break;                }            }        }        extractCurrentSegment();        updateScrollBar();        notifyMultiTierControlPanel();    }    /**     * Sets the active tier for this viewer.<br>     * The active tier is marked by a colored background bar.     *     * @param tier DOCUMENT ME!     */    public void setActiveTier(Tier tier) {        Iterator it = allTiers.iterator();        Tier2D t2d;        String name = tier.getName();        while (it.hasNext()) {            t2d = (Tier2D) it.next();            if (t2d.getName().equals(name)) {                t2d.setActive(true);            } else {                t2d.setActive(false);            }        }        buildLayout();    }    /**     * Sets the MultiTierControlPanel for this viewer.<br>     * This controller gets notified of when the (vertical) positions of the     * tiers have been changed (scrolling).     *     * @param controller DOCUMENT ME!     */    public void setMultiTierControlPanel(MultiTierControlPanel controller) {        multiTierControlPanel = controller;        notifyMultiTierControlPanel();    }    /**     * Calculates the y positions of the vertical middle of all visible tiers     * and passes them to the MultiTierControlPanel.     */    private void notifyMultiTierControlPanel() {        if (multiTierControlPanel == null) {            return;        }        if (tierYPositions.length > 0) {            tierYPositions[0] = (VER_MARGIN + (pixelsForTierHeight / 2)) -                verticalScrollOffset;            for (int i = 1; i < visibleTiers.size(); i++) {                tierYPositions[i] = tierYPositions[0] +                    (i * pixelsForTierHeight);            }        }        multiTierControlPanel.setTierPositions(tierYPositions);    }    /**     * If the selection has been changed in some other viewer or controller     * this viewer is updated to reflect that change.<br>     */    public void updateSelection() {        selSTime = getSelectionBeginTime();        selETime = getSelectionEndTime();        repaint();    }    /**     * AR heeft dit hier neergezet, zie abstract viewer voor get en set     * methodes van ActiveAnnotation. Update method from ActiveAnnotationUser     */    public void updateActiveAnnotation() {        activeAnnotation = getActiveAnnotation();        extractCurrentSegment();    }    /**     * Implements ACMEditListener.<br>     * The ACMEditEvent that is received contains information about the kind     * of modification and the objects effected by that modification.     *     * @param e the event object     *     * @see ACMEditEvent     */    public void ACMEdited(ACMEditEvent e) {        //System.out.println("ACMEdited:: operation: " + e.getOperation() + ", invalidated: " + e.getInvalidatedObject());        //System.out.println("\tmodification: " + e.getModification() + ", source: " + e.getSource());        switch (e.getOperation()) {        case ACMEditEvent.ADD_TIER:            if (e.getModification() instanceof TierImpl) {                tierAdded((TierImpl) e.getModification());                if (multiTierControlPanel != null) {                    multiTierControlPanel.tierAdded((TierImpl) e.getModification());                }            }            break;        case ACMEditEvent.REMOVE_TIER:            if (e.getModification() instanceof TierImpl) {                tierRemoved((TierImpl) e.getModification());                if (multiTierControlPanel != null) {                    multiTierControlPanel.tierRemoved((TierImpl) e.getModification());                }            }            break;        case ACMEditEvent.CHANGE_TIER:            if (e.getInvalidatedObject() instanceof TierImpl) {                tierChanged((TierImpl) e.getInvalidatedObject());                if (multiTierControlPanel != null) {                    multiTierControlPanel.tierChanged((TierImpl) e.getInvalidatedObject());                }            }            break;        // if i'm right for the next three operations the event's        // invalidated Object should be a tier        // and the modification object the new annotation...        case ACMEditEvent.ADD_ANNOTATION_HERE:            if (e.getInvalidatedObject() instanceof TierImpl &&                    e.getModification() instanceof Annotation) {                annotationChanged((TierImpl) e.getInvalidatedObject(),                    (Annotation) e.getModification());                // setActiveAnnotation((Annotation) e.getModification());                showEditBoxForAnnotation((Annotation) e.getModification());                if (editBox.isVisible()) {                    editBox.requestFocus();                }            }            break;        case ACMEditEvent.ADD_ANNOTATION_BEFORE:        // fall through        //break;        case ACMEditEvent.ADD_ANNOTATION_AFTER:            if (e.getInvalidatedObject() instanceof TierImpl &&                    e.getModification() instanceof Annotation) {                annotationChanged((TierImpl) e.getInvalidatedObject(),                    (Annotation) e.getModification());                // setActiveAnnotation((Annotation) e.getModification());                showEditBoxForAnnotation((Annotation) e.getModification());                if (editBox.isVisible()) {                    editBox.requestFocus();                }            }            break;        case ACMEditEvent.CHANGE_ANNOTATIONS:            if (e.getInvalidatedObject() instanceof Transcription) {                transcriptionChanged();            }            break;        case ACMEditEvent.REMOVE_ANNOTATION:            if (e.getModification() instanceof Annotation) {                annotationRemoved((Annotation) e.getModification());            } else if (e.getInvalidatedObject() instanceof Transcription) {                //System.out.println("Operation == REMOVE_ANNOTATION");                transcriptionChanged();            }            break;        case ACMEditEvent.CHANGE_ANNOTATION_TIME:        // fall through...        //break;        case ACMEditEvent.CHANGE_ANNOTATION_VALUE:            if (e.getInvalidatedObject() instanceof Annotation) {                Annotation a = (Annotation) e.getInvalidatedObject();                if (a.getTier() instanceof TierImpl) {                    annotationChanged((TierImpl) a.getTier(), a);                }            }            break;        default:            break;        }    }    /**     * Paints the tiers to a Buffered Image.<br>     * This is necessary when a new segment needs to be displayed, or after a     * change in the visibility and/or ordering of the tiers.     * Mar 2006: a maximum to the buffer's size is introduced to prevent OutOfMemoryErrors.     * If the complete interlinear block does not fit in the buffer, the horizontal scroll offset     * is used when painting in the buffer. Consequently a new buffer image has to be painted with     * every horizontal scroll event.     */    protected void buildLayout() {        if ((getWidth() <= 0) || (getHeight() <= 0)) {            return;        }        if (getWidth() > MAX_BUF_WIDTH) {            MAX_BUF_WIDTH = getWidth();        }        /*           int barWidth = vScrollBar.getWidth();           if (barWidth <= 0) {               if (UIManager.getDefaults().get("ScrollBar.width") != null) {

⌨️ 快捷键说明

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