📄 timelineviewer.java
字号:
g2d.translate(0, verticalScrollOffset); } g2d.setFont(font); /* don't paint the hoverTag for now if (hoverTag2D != null) { //System.out.println("tag: " + hoverTag2D); int x = xAt(hoverTag2D.getBeginTime()); int w = xAt(hoverTag2D.getEndTime()) - x; int y = (rulerHeight + hoverTierIndex * pixelsForTierHeight + pixelsForTierHeightMargin) - verticalScrollOffset; int he = pixelsForTierHeight - 2 * pixelsForTierHeightMargin; paintHoverTag2D(g2d, hoverTag2D, x, y, w, he); } */ if ((cursorTag2D != null) && visibleTiers.contains(cursorTag2D.getTier2D())) { //int x = xAt(cursorTag2D.getBeginTime()); //int w = xAt(cursorTag2D.getEndTime()) - x; int x = (int) ((cursorTag2D.getBeginTime() / msPerPixel) - (intervalBeginTime / msPerPixel)); int w = (int) ((cursorTag2D.getEndTime() - cursorTag2D.getBeginTime()) / msPerPixel); int y = (rulerHeight + (cursorTierIndex * pixelsForTierHeight) + pixelsForTierHeightMargin) - verticalScrollOffset; int he = pixelsForTierHeight - (2 * pixelsForTierHeightMargin); paintCursorTag2D(g2d, cursorTag2D, x, y, w, he); } //paint empty slots if (showEmptySlots) { for (int i = 0; i < visibleTiers.size(); i++) { TierImpl ti = ((Tier2D) visibleTiers.get(i)).getTier(); if (ti.getParentTier() == null) { continue; } else { if (!ti.isTimeAlignable()) { int y = (rulerHeight + (i * pixelsForTierHeight) + pixelsForTierHeightMargin) - verticalScrollOffset; int he = pixelsForTierHeight - (2 * pixelsForTierHeightMargin); paintEmptySlots(g2d, ti, y, he); } } } } // paint the dragEdit annotation if (dragEditTag2D != null) { //long newTime = pixelToTime(dragEditTag2D.getX()); //int x = (int) ((dragEditTag2D.getBeginTime() / msPerPixel) - // (intervalBeginTime / msPerPixel)); int x = (int) (dragEditTag2D.getX() - (intervalBeginTime / msPerPixel)); //int w = (int) ((dragEditTag2D.getEndTime() - //dragEditTag2D.getBeginTime()) / msPerPixel); int w = dragEditTag2D.getWidth(); int y = (rulerHeight + (cursorTierIndex * pixelsForTierHeight) + /*(getTierIndexForAnnotation(dragEditTag2D.getAnnotation()) * pixelsForTierHeight) +*/ pixelsForTierHeightMargin) - verticalScrollOffset; int he = pixelsForTierHeight - (2 * pixelsForTierHeightMargin); paintDragEditTag2D(g2d, x, y, w, he); } if (rulerAlwaysVisible && (bi != null)) { g2d.setClip(0, 0, imageWidth, rulerHeight); g2d.drawImage(bi, 0, 0, this); g2d.setClip(null); g2d.setColor(Constants.SELECTIONCOLOR); g2d.drawLine(0, rulerHeight, imageWidth, rulerHeight); } if ((crossHairPos >= 0) && (crossHairPos <= imageWidth)) { // prevents drawing outside the component on Mac g2d.setColor(Constants.CROSSHAIRCOLOR); g2d.drawLine(crossHairPos, 0, crossHairPos, h); } } private void paintUnbuffered(Graphics2D g2d) { // from paintBuffer int h = getHeight(); int w = getWidth(); // scrolling related fill g2d.setColor(Constants.DEFAULTBACKGROUNDCOLOR); g2d.fillRect(0, 0, w, h); // selection /* if (selectionBeginPos != selectionEndPos) { g2d.setColor(Constants.SELECTIONCOLOR); g2d.fillRect(selectionBeginPos, 0, (selectionEndPos - selectionBeginPos), h); } */ // paint a slightly dif. background color for every other tier int y = rulerHeight - verticalScrollOffset; g2d.setColor(Constants.LIGHTBACKGROUNDCOLOR); for (int i = 0; i < visibleTiers.size(); i++) { if ((i % 2) != 0) { g2d.fillRect(0, y + (i * pixelsForTierHeight), w, pixelsForTierHeight); } } // mark the area beyond the media time if (intervalEndTime > getMediaDuration()) { g2d.setColor(Color.LIGHT_GRAY); int xx = xAt(getMediaDuration()); g2d.drawLine(xx, 0, xx, h); g2d.setColor(UIManager.getColor("Panel.background")); g2d.fillRect(xx + 1, 0, w - xx, h); } //paint selection if (selectionBeginPos != selectionEndPos) { g2d.setColor(Constants.SELECTIONCOLOR); //g2d.setComposite(alpha04); //g2d.fillRect(selectionBeginPos, 0, (selectionEndPos - selectionBeginPos), rulerHeight); g2d.setComposite(AlphaComposite.Src); g2d.fillRect(selectionBeginPos, rulerHeight, (selectionEndPos - selectionBeginPos), w - rulerHeight); } // translate horizontally int ax = timeToPixels(intervalBeginTime); g2d.translate(-ax, 0); int ht = pixelsForTierHeight - (2 * pixelsForTierHeightMargin); Tier2D tier2d; Tag2D tag2d; synchronized (tierLock) { Iterator visIt = visibleTiers.iterator(); int count = 0; while (visIt.hasNext()) { tier2d = (Tier2D) visIt.next(); count++; if (tier2d.isActive()) { g2d.setColor(Constants.ACTIVETIERCOLOR); g2d.setComposite(alpha07); g2d.fillRect(ax, y, imageWidth, pixelsForTierHeight); g2d.setComposite(AlphaComposite.Src); } Iterator tagIt = tier2d.getTags(); while (tagIt.hasNext()) { tag2d = (Tag2D) tagIt.next(); if (tag2d.getEndTime() < intervalBeginTime) { continue; //don't paint } else if (tag2d.getBeginTime() > intervalEndTime) { break; // stop looping this tier } //x = timeToPixels(tag2d.getBeginTime()); //w = timeToPixels(tag2d.getEndTime()) - x; //paint tag at this position paintTag(g2d, tag2d, tag2d.getX(), y + pixelsForTierHeightMargin, tag2d.getWidth(), ht); } y += pixelsForTierHeight; } } /*paint time ruler */ g2d.setColor(Constants.DEFAULTBACKGROUNDCOLOR); g2d.fillRect(ax, 0, w, rulerHeight); g2d.setColor(Constants.DEFAULTFOREGROUNDCOLOR); ruler.paint(g2d, intervalBeginTime, w, msPerPixel, SwingConstants.TOP); g2d.setFont(font); // horizontally translate back g2d.translate(ax, 0); //paint selection over ruler if (selectionBeginPos != selectionEndPos) { g2d.setColor(Constants.SELECTIONCOLOR); g2d.setComposite(alpha04); g2d.fillRect(selectionBeginPos, 0, (selectionEndPos - selectionBeginPos), rulerHeight); g2d.setComposite(AlphaComposite.Src); g2d.drawLine(0, rulerHeight, w, rulerHeight); } // from paintComponent g2d.setFont(font); if ((cursorTag2D != null) && visibleTiers.contains(cursorTag2D.getTier2D())) { //int x = xAt(cursorTag2D.getBeginTime()); //int w = xAt(cursorTag2D.getEndTime()) - x; int x = (int) ((cursorTag2D.getBeginTime() / msPerPixel) - (intervalBeginTime / msPerPixel)); int ww = (int) ((cursorTag2D.getEndTime() - cursorTag2D.getBeginTime()) / msPerPixel); int yy = (rulerHeight + (cursorTierIndex * pixelsForTierHeight) + pixelsForTierHeightMargin) - verticalScrollOffset; int he = pixelsForTierHeight - (2 * pixelsForTierHeightMargin); paintCursorTag2D(g2d, cursorTag2D, x, yy, ww, he); } //paint empty slots if (showEmptySlots) { for (int i = 0; i < visibleTiers.size(); i++) { TierImpl ti = ((Tier2D) visibleTiers.get(i)).getTier(); if (ti.getParentTier() == null) { continue; } else { if (!ti.isTimeAlignable()) { int yy = (rulerHeight + (i * pixelsForTierHeight) + pixelsForTierHeightMargin) - verticalScrollOffset; int he = pixelsForTierHeight - (2 * pixelsForTierHeightMargin); paintEmptySlots(g2d, ti, yy, he); } } } } // paint the dragEdit annotation if (dragEditTag2D != null) { //long newTime = pixelToTime(dragEditTag2D.getX()); //int x = (int) ((dragEditTag2D.getBeginTime() / msPerPixel) - // (intervalBeginTime / msPerPixel)); int x = (int) (dragEditTag2D.getX() - (intervalBeginTime / msPerPixel)); //int w = (int) ((dragEditTag2D.getEndTime() - //dragEditTag2D.getBeginTime()) / msPerPixel); int ww = dragEditTag2D.getWidth(); int yy = (rulerHeight + (cursorTierIndex * pixelsForTierHeight) + /*(getTierIndexForAnnotation(dragEditTag2D.getAnnotation()) * pixelsForTierHeight) +*/ pixelsForTierHeightMargin) - verticalScrollOffset; int he = pixelsForTierHeight - (2 * pixelsForTierHeightMargin); paintDragEditTag2D(g2d, x, yy, ww, he); } if ((crossHairPos >= 0) && (crossHairPos <= w)) { // prevents drawing outside the component on Mac g2d.setColor(Constants.CROSSHAIRCOLOR); g2d.drawLine(crossHairPos, 0, crossHairPos, h); } } /** * Paint the given Tag2D to the specified Graphics2D object using the * specified location and dimension. * * @param g2d the graphics object to paint to * @param tag2d the tag to paint * @param x the x postion of the tag * @param y the y position of the tag * @param width the width of the tag * @param height the height of the tag */ private void paintTag(Graphics2D g2d, Tag2D tag2d, int x, int y, int width, int height) { if (tag2d.getAnnotation() instanceof AlignableAnnotation) { AlignableAnnotation a = (AlignableAnnotation) tag2d.getAnnotation(); TimeSlot b = a.getBegin(); TimeSlot e = a.getEnd(); //skip check cursor g2d.setColor(Constants.DEFAULTFOREGROUNDCOLOR); g2d.drawLine(x, y + (b.isTimeAligned() ? 0 : (height / 4)), x, y + (b.isTimeAligned() ? height : ((height * 3) / 4))); g2d.drawLine(x, y + (height / 2), x + width, y + (height / 2)); g2d.drawLine(x + width, y + (e.isTimeAligned() ? 0 : (height / 4)), x + width, y + (e.isTimeAligned() ? height : ((height * 3) / 4))); } else { //not alignable g2d.setColor(Constants.SHAREDCOLOR1); g2d.drawLine(x, y + (height / 4), x, y + ((height * 3) / 4)); g2d.drawLine(x, y + (height / 2), x + width, y + (height / 2)); g2d.drawLine(x + width, y + (height / 4), x + width, y + ((height * 3) / 4)); } g2d.setColor(Constants.DEFAULTFOREGROUNDCOLOR); int descent = g2d.getFontMetrics().getDescent(); g2d.drawString(tag2d.getTruncatedValue(), (float) (x + 4), (float) (y + ((height / 2) - descent + 1))); ///// /* if (tag2d.getAnnotation() instanceof AlignableAnnotation) { AlignableAnnotation aa = (AlignableAnnotation) tag2d.getAnnotation(); String vv = aa.getBegin().getIndex() + " - " + aa.getEnd().getIndex(); g2d.drawString(vv, (float) (x + 4), (float) (y + ((height) - descent + 1))); } */ } /** * Paint the mouseover highlight for a tag. * * @param g2d * @param tag2d * @param x * @param y * @param width * @param height */ /* private void paintHoverTag2D(Graphics2D g2d, Tag2D tag2d, int x, int y, int width, int height) { g2d.setColor(Constants.SHAREDCOLOR3); g2d.drawRect(x, y, width, height); g2d.setColor(Constants.SHAREDCOLOR4); g2d.fillRect(x, y, width - 1, height - 1); g2d.setColor(Constants.DEFAULTFOREGROUNDCOLOR); g2d.drawString(tag2d.getTruncatedValue(), x + 4, (int) (y + ((height / 2) - 1))); } */ /** * Paint the selected Tag. * * @param g2d * @param tag2d * @param x * @param y * @param width * @param height */ private void paintCursorTag2D(Graphics2D g2d, Tag2D tag2d, int x, int y, int width, int height) { if (tag2d.getAnnotation() instanceof AlignableAnnotation) { AlignableAnnotation a = (AlignableAnnotation) tag2d.getAnnotation(); TimeSlot b = a.getBegin(); TimeSlot e = a.getEnd(); g2d.setColor(Constants.ACTIVEANNOTATIONCOLOR); if (aaStrokeBold) { g2d.setStroke(stroke2); } int top = b.isTimeAligned() ? 0 : (height / 4); int bottom = b.isTimeAligned() ? height : ((height * 3) / 4); g2d.drawLine(x, y + top, x, y + bottom); top = height / 2; if (aaStrokeBold) { top++; } //g2d.drawLine(x, y + top + 1, x + width, y + top + 1); g2d.drawLine(x, y + top, x + width, y + top); top = e.isTimeAligned() ? 0 : (height / 4); bottom = e.isTimeAligned() ? height : ((height * 3) / 4); g2d.drawLine(x + width, y + top, x + width, y + bottom); g2d.setStroke(stroke); } else { //not alignable g2d.setColor(Constants.ACTIVEANNOTATIONCOLOR); if (aaStrokeBold) { g2d.setStroke(stroke2); } g2d.drawLine(x, y + (height / 4), x, y + ((height * 3) / 4)); g2d.drawLine(x, y + (height / 2), x + width, y + (height / 2)); g2d.drawLine(x + width, y + (height / 4), x + width,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -