📄 interlinearviewer.java
字号:
} } } /** * If the mofified annotation is within the current segment and the tier is * visible re-extract the current segment.<br> * * @param tier the Tier the annotation belongs to * @param annotation the new annotation */ private void annotationChanged(TierImpl tier, Annotation annotation) { sbl.getRefTierOrder(); extractCurrentSegment(); /* if (activeAnnotation != null) { setSelection(activeAnnotation.getBeginTimeBoundary(), activeAnnotation.getEndTimeBoundary()); }*/ /* if (annotation.getBeginTimeBoundary() >= sbl.getCurrentRefStartTime() && annotation.getEndTimeBoundary() <= sbl.getCurrentRefEndTime()) { for (int i = 0; i < visibleTiers.size(); i++) { if (((Tier2D)visibleTiers.get(i)).getTier() == tier) { extractCurrentSegment(); return; } } } */ } /** * This is called when an ACMEditEvent is received with operation * REMOVE_ANNOTATION or CHANGE_ANNOTATIONS and the transcription as * invalidated object.<br> * It is undefined which tiers and annotations have been effected, so the * transcription is simply re-processed. Store state as much as possible. * Assume no tiers have been deleted or added. */ private void transcriptionChanged() { sbl.getRefTierOrder(); extractCurrentSegment(); /* if (activeAnnotation != null) { setSelection(activeAnnotation.getBeginTimeBoundary(), activeAnnotation.getEndTimeBoundary()); }*/ } private void annotationRemoved(Annotation annotation) { if ((annotation.getBeginTimeBoundary() >= sbl.getCurrentRefStartTime()) && (annotation.getEndTimeBoundary() <= sbl.getCurrentRefEndTime())) { sbl.getRefTierOrder(); extractCurrentSegment(); /* if (activeAnnotation != null) { setSelection(activeAnnotation.getBeginTimeBoundary(), activeAnnotation.getEndTimeBoundary()); }*/ } } /** * Set a new Transcription for this viewer.<br> * We should receive a setVisibleTiers() and a setActiveTier() call after * this. Faking it here. * * @param transcription the new transcription. */ public void setTranscription(Transcription transcription) { this.transcription = transcription; curSBSelection = null; activeAnnotation = null; if (transcription == null) { allTiers.clear(); visibleTiers.clear(); tierYPositions = new int[0]; setVisibleTiers(new Vector()); sbl = new SBLayout(null); return; } // Vector oldVisibles = new Vector(visibleTiers.size()); for (int i = 0; i < visibleTiers.size(); i++) { Tier2D tier2d = (Tier2D) visibleTiers.get(i); oldVisibles.add(tier2d.getTier()); } String activeTierName = ""; for (int i = 0; i < allTiers.size(); i++) { Tier2D tier2d = (Tier2D) allTiers.get(i); if (tier2d.isActive()) { activeTierName = tier2d.getName(); break; } } // sbl = new SBLayout(transcription); sbl.getSegOrder(); sbl.getPrevRef(); sbl.setWorkingSegmentsRange(1, 0); initTiers(); if (sbl.setBlocksVisibleAtTime(getMediaTime() + 1)) { extractCurrentSegment(); updateScrollBar(); } // for (int i = 0; i < allTiers.size(); i++) { Tier2D tier2d = (Tier2D) allTiers.get(i); if (tier2d.getName().equals(activeTierName)) { tier2d.setActive(true); break; } } setVisibleTiers(oldVisibles); } //***** end of initial editing and data changed methods **************************************// /** * Implements ElanLocaleListener.<br> Update tooltips and label. */ public void updateLocale() { prevButton.setText(ElanLocale.getString( "InterlinearViewer.PrevButton.Text")); nextButton.setText(ElanLocale.getString( "InterlinearViewer.NextButton.Text")); prevButton.setToolTipText(ElanLocale.getString( "InterlinearViewer.PrevButton.Tooltip")); nextButton.setToolTipText(ElanLocale.getString( "InterlinearViewer.NextButton.Tooltip")); if (popup != null) { //createPopupMenu(); fontMenu.setText(ElanLocale.getString("Menu.View.FontSize")); activeTierMI.setText(ElanLocale.getString("Menu.Tier.ActiveTier")); deleteTierMI.setText(ElanLocale.getString("Menu.Tier.DeleteTier")); changeTierMI.setText(ElanLocale.getString("Menu.Tier.ChangeTier")); newAnnoMI.setText(ElanLocale.getString( "Menu.Annotation.NewAnnotation")); newAnnoBeforeMI.setText(ElanLocale.getString( "Menu.Annotation.NewAnnotationBefore")); newAnnoAfterMI.setText(ElanLocale.getString( "Menu.Annotation.NewAnnotationAfter")); modifyAnnoMI.setText(ElanLocale.getString( "Menu.Annotation.ModifyAnnotation")); deleteAnnoMI.setText(ElanLocale.getString( "Menu.Annotation.DeleteAnnotation")); } revalidate(); if (editBox != null) { editBox.updateLocale(); } } /** * Updates the font that is used in the visualization of the annotations<br> * Does not change the font in the time ruler. * * @param f the new Font */ public void updateFont(Font f) { int oldSize = getFont().getSize(); setFont(f); currentMetrics = getFontMetrics(getFont()); //pixelsForTierHeight = getFont().getSize() * 3; pixelsForTierHeight = getFont().getSize() + 24; if (oldSize != f.getSize()) { notifyMultiTierControlPanel(); extractCurrentSegment(); vScrollBar.setBlockIncrement(pixelsForTierHeight); updateScrollBar(); } else { extractCurrentSegment(); } } /** * Sets the font size. * * @param fontSize the new font size */ public void setFontSize(int fontSize) { updateFont(getFont().deriveFont((float) fontSize)); if (popup != null) { Enumeration en = fontSizeBG.getElements(); JMenuItem item; String value; while (en.hasMoreElements()) { item = (JMenuItem) en.nextElement(); value = item.getText(); try { int v = Integer.parseInt(value); if (v == fontSize) { item.setSelected(true); //updateFont(getFont().deriveFont((float) fontSize)); break; } } catch (NumberFormatException nfe) { //// do nothing } } } } /** * Returns the current font size. * * @return the current font size */ public int getFontSize() { return getFont().getSize(); } /** * DOCUMENT ME! * * @param ce DOCUMENT ME! */ public void controllerUpdate(ControllerEvent ce) { if (sbl.setBlocksVisibleAtTime(getMediaTime())) { extractCurrentSegment(); updateScrollBar(); //buildLayout(); } else { if (shouldPaint() && !playerIsPlaying()) { repaint(); } } } /** * Implements MouseMotionListener * * @param e DOCUMENT ME! */ public void mouseDragged(MouseEvent e) { } /** * Implements MouseMotionListener * * @param e DOCUMENT ME! */ public void mouseMoved(MouseEvent e) { /* if (e.isShiftDown()) { showEmptySlots = true; } else { showEmptySlots = false; } repaint(); */ /* //hoover behavior Point pt = e.getPoint(); if (pt.y <= VER_MARGIN) { curSBSelection = null; return; } pt.x += horizontalScrollOffset; pt.y += verticalScrollOffset; int size = _vTiers.size(); int curtier = ((pt.y + (pixelsForTierHeight/2))/(pixelsForTierHeight)) - 1 ; //System.out.println("Curtier: " + curtier); if (curtier >= size || curtier < 0) return; // get current tier Vector v = (Vector) _vTiers.elementAt(curtier); // itor thru the rects and find match SBTime sb = null; int pos = -1; if ((pos = Collections.binarySearch(v,pt))>= 0) { sb = (SBTime) v.elementAt(pos); String tt = "Tag: " + sb.value + " anno: " + sb.annotation + " st: " + sb.startt + " et: " + sb.endt; setToolTipText(tt); curSBSelection = sb; repaint(); return; } curSBSelection = null; */ } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void mouseReleased(MouseEvent e) { } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void mousePressed(MouseEvent e) { // HS nov 04: e.isPopupTrigger always returns false on my PC... // HS jun 2006: change to discriminate Ctrl-click and Command-click on Mac // isRightMouseButton() returns true for both, isMetaDown() returns true for Command only // but on Windows isMetaDown() returns true when the right mouse button (BUTTON3) has been pressed if ((SwingUtilities.isRightMouseButton(e) && ((e.getButton() == MouseEvent.BUTTON1) ^ e.isMetaDown())) || e.isPopupTrigger()) { if (e.getPoint().y < VER_MARGIN) { return; } Point pp = e.getPoint(); if (popup == null) { createPopupMenu(); } updatePopup(pp); if ((popup.getWidth() == 0) || (popup.getHeight() == 0)) { popup.show(this, pp.x, pp.y); } else { popup.show(this, pp.x, pp.y); SwingUtilities.convertPointToScreen(pp, this); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); Window w = SwingUtilities.windowForComponent(this); if ((pp.x + popup.getWidth()) > d.width) { pp.x -= popup.getWidth(); } //this does not account for a desktop taskbar if ((pp.y + popup.getHeight()) > d.height) { pp.y -= popup.getHeight(); } //keep it in the window then if ((pp.y + popup.getHeight()) > (w.getLocationOnScreen().y + w.getHeight())) { pp.y -= popup.getHeight(); } popup.setLocation(pp); } return; } dismissEditBox(); curSBSelection = getTagAtPoint(e.getPoint()); if (curSBSelection != null) { cursorTag = curSBSelection; refAnnotation = sbl.getRefAnn(); activeAnnotation = cursorTag.annotation; } else { cursorTag = null; refAnnotation = null; activeAnnotation = null; } setActiveAnnotation(activeAnnotation); repaint(); } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void mouseClicked(MouseEvent e) { // grab keyboard focus requestFocus(); if (e.getPoint().y <= VER_MARGIN) { return; } else if (e.getClickCount() == 2) { d
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -