2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.datamodel.AlignmentI;
24 import jalview.datamodel.HiddenColumns;
25 import jalview.datamodel.SearchResultsI;
26 import jalview.datamodel.SequenceGroup;
27 import jalview.datamodel.SequenceI;
28 import jalview.renderer.ScaleRenderer;
29 import jalview.renderer.ScaleRenderer.ScaleMark;
30 import jalview.viewmodel.ViewportListenerI;
31 import jalview.viewmodel.ViewportRanges;
33 import java.awt.AlphaComposite;
34 import java.awt.BasicStroke;
35 import java.awt.BorderLayout;
36 import java.awt.Color;
37 import java.awt.FontMetrics;
38 import java.awt.Graphics;
39 import java.awt.Graphics2D;
40 import java.awt.RenderingHints;
41 import java.awt.Shape;
42 import java.awt.image.BufferedImage;
43 import java.beans.PropertyChangeEvent;
44 import java.util.List;
46 import javax.swing.JComponent;
54 public class SeqCanvas extends JComponent implements ViewportListenerI
56 final FeatureRenderer fr;
58 final SequenceRenderer sr;
66 boolean fastPaint = false;
77 * Creates a new SeqCanvas object.
82 public SeqCanvas(AlignmentPanel ap)
86 fr = new FeatureRenderer(ap);
87 sr = new SequenceRenderer(av);
88 setLayout(new BorderLayout());
89 PaintRefresher.Register(this, av.getSequenceSetId());
90 setBackground(Color.white);
92 av.getRanges().addPropertyChangeListener(this);
95 public SequenceRenderer getSequenceRenderer()
100 public FeatureRenderer getFeatureRenderer()
105 int charHeight = 0, charWidth = 0;
107 private void updateViewport()
109 charHeight = av.getCharHeight();
110 charWidth = av.getCharWidth();
125 private void drawNorthScale(Graphics g, int startx, int endx, int ypos)
128 for (ScaleMark mark : new ScaleRenderer().calculateMarks(av, startx,
131 int mpos = mark.column; // (i - startx - 1)
136 String mstring = mark.text;
142 g.drawString(mstring, mpos * charWidth, ypos - (charHeight / 2));
144 g.drawLine((mpos * charWidth) + (charWidth / 2), (ypos + 2)
145 - (charHeight / 2), (mpos * charWidth) + (charWidth / 2),
163 void drawWestScale(Graphics g, int startx, int endx, int ypos)
165 FontMetrics fm = getFontMetrics(av.getFont());
168 if (av.hasHiddenColumns())
170 startx = av.getAlignment().getHiddenColumns()
171 .adjustForHiddenColumns(startx);
172 endx = av.getAlignment().getHiddenColumns()
173 .adjustForHiddenColumns(endx);
176 int maxwidth = av.getAlignment().getWidth();
177 if (av.hasHiddenColumns())
179 maxwidth = av.getAlignment().getHiddenColumns()
180 .findColumnPosition(maxwidth) - 1;
184 for (int i = 0; i < av.getAlignment().getHeight(); i++)
186 SequenceI seq = av.getAlignment().getSequenceAt(i);
192 if (jalview.util.Comparison.isGap(seq.getCharAt(index)))
199 value = av.getAlignment().getSequenceAt(i).findPosition(index);
206 int x = LABEL_WEST - fm.stringWidth(String.valueOf(value))
208 g.drawString(value + "", x, (ypos + (i * charHeight))
226 void drawEastScale(Graphics g, int startx, int endx, int ypos)
230 if (av.hasHiddenColumns())
232 endx = av.getAlignment().getHiddenColumns()
233 .adjustForHiddenColumns(endx);
238 for (int i = 0; i < av.getAlignment().getHeight(); i++)
240 seq = av.getAlignment().getSequenceAt(i);
244 while (index > startx)
246 if (jalview.util.Comparison.isGap(seq.getCharAt(index)))
253 value = seq.findPosition(index);
260 g.drawString(String.valueOf(value), 0, (ypos + (i * charHeight))
266 boolean fastpainting = false;
269 * need to make this thread safe move alignment rendering in response to
275 * shift up or down in repaint
277 public void fastPaint(int horizontal, int vertical)
279 if (fastpainting || gg == null)
287 ViewportRanges ranges = av.getRanges();
288 int sr = ranges.getStartRes();
289 int er = ranges.getEndRes();
290 int ss = ranges.getStartSeq();
291 int es = ranges.getEndSeq();
295 gg.copyArea(horizontal * charWidth, vertical * charHeight,
296 img.getWidth(), img.getHeight(), -horizontal * charWidth,
297 -vertical * charHeight);
299 if (horizontal > 0) // scrollbar pulled right, image to the left
301 transX = (er - sr - horizontal) * charWidth;
302 sr = er - horizontal;
304 else if (horizontal < 0)
306 er = sr - horizontal;
308 else if (vertical > 0) // scroll down
312 if (ss < ranges.getStartSeq())
313 { // ie scrolling too fast, more than a page at a time
314 ss = ranges.getStartSeq();
318 transY = img.getHeight() - ((vertical + 1) * charHeight);
321 else if (vertical < 0)
325 if (es > ranges.getEndSeq())
327 es = ranges.getEndSeq();
331 gg.translate(transX, transY);
332 drawPanel(gg, sr, er, ss, es, 0);
333 gg.translate(-transX, -transY);
336 fastpainting = false;
340 * Definitions of startx and endx (hopefully): SMJS This is what I'm working
341 * towards! startx is the first residue (starting at 0) to display. endx is
342 * the last residue to display (starting at 0). starty is the first sequence
343 * to display (starting at 0). endy is the last sequence to display (starting
344 * at 0). NOTE 1: The av limits are set in setFont in this class and in the
345 * adjustment listener in SeqPanel when the scrollbars move.
348 // Set this to false to force a full panel paint
350 public void paintComponent(Graphics g)
352 super.paintComponent(g);
356 // img is a cached version of the last view we drew
357 // selectImage will hold any selection we have
358 // lcimg is a local *copy* of img which we'll draw selectImage on top of
360 ViewportRanges ranges = av.getRanges();
361 BufferedImage selectImage = drawSelectionGroup(
362 av.getRanges().getStartRes(), av.getRanges().getEndRes(),
363 ranges.getStartSeq(), ranges.getEndSeq());
365 if (fastPaint || (getVisibleRect().width != g.getClipBounds().width)
366 || (getVisibleRect().height != g.getClipBounds().height))
368 BufferedImage lcimg = buildLocalImage(selectImage);
369 g.drawImage(lcimg, 0, 0, this);
375 int width = getWidth();
376 int height = getHeight();
378 width -= (width % charWidth);
379 height -= (height % charHeight);
381 if ((width < 1) || (height < 1))
386 if (img == null || width != img.getWidth() || height != img.getHeight())
389 gg = (Graphics2D) img.getGraphics();
390 gg.setFont(av.getFont());
400 gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
401 RenderingHints.VALUE_ANTIALIAS_ON);
404 gg.setColor(Color.white);
405 gg.fillRect(0, 0, img.getWidth(), img.getHeight());
407 if (av.getWrapAlignment())
409 drawWrappedPanel(gg, getWidth(), getHeight(), ranges.getStartRes());
413 drawPanel(gg, ranges.getStartRes(), ranges.getEndRes(),
414 ranges.getStartSeq(), ranges.getEndSeq(), 0);
417 BufferedImage lcimg = buildLocalImage(selectImage);
418 g.drawImage(lcimg, 0, 0, this);
422 * Make a local image by combining the cached image img
425 private BufferedImage buildLocalImage(BufferedImage selectImage)
427 // clone the cached image
428 BufferedImage lcimg = new BufferedImage(img.getWidth(), img.getHeight(),
430 Graphics2D g2d = lcimg.createGraphics();
431 g2d.drawImage(img, 0, 0, null);
433 // overlay selection group on lcimg
434 if (selectImage != null)
437 AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
438 g2d.drawImage(selectImage, 0, 0, this);
445 private void paintSeqGroup()
451 private BufferedImage setupImage()
453 BufferedImage lcimg = null;
455 int width = getWidth();
456 int height = getHeight();
458 width -= (width % charWidth);
459 height -= (height % charHeight);
461 if ((width < 1) || (height < 1))
468 lcimg = new BufferedImage(width, height,
469 BufferedImage.TYPE_INT_ARGB); // ARGB so alpha compositing works
470 } catch (OutOfMemoryError er)
474 "Selection Group image OutOfMemory Redraw Error.\n" + er);
475 new OOMWarning("Creating alignment image for display", er);
489 * @return DOCUMENT ME!
491 public int getWrappedCanvasWidth(int cwidth)
493 FontMetrics fm = getFontMetrics(av.getFont());
498 if (av.getScaleRightWrapped())
500 LABEL_EAST = fm.stringWidth(getMask());
503 if (av.getScaleLeftWrapped())
505 LABEL_WEST = fm.stringWidth(getMask());
508 return (cwidth - LABEL_EAST - LABEL_WEST) / charWidth;
512 * Generates a string of zeroes.
521 for (int i = 0; i < av.getAlignment().getHeight(); i++)
523 tmp = av.getAlignment().getSequenceAt(i).getEnd();
530 for (int i = maxWidth; i > 0; i /= 10)
544 * @param canvasHeight
549 public void drawWrappedPanel(Graphics g, int canvasWidth,
550 int canvasHeight, int startRes)
553 AlignmentI al = av.getAlignment();
555 FontMetrics fm = getFontMetrics(av.getFont());
560 if (av.getScaleRightWrapped())
562 LABEL_EAST = fm.stringWidth(getMask());
565 if (av.getScaleLeftWrapped())
567 LABEL_WEST = fm.stringWidth(getMask());
570 int hgap = charHeight;
571 if (av.getScaleAboveWrapped())
576 int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / charWidth;
577 int cHeight = av.getAlignment().getHeight() * charHeight;
579 av.setWrappedWidth(cWidth);
581 av.getRanges().setViewportStartAndWidth(startRes, cWidth);
585 int maxwidth = av.getAlignment().getWidth();
587 if (av.hasHiddenColumns())
589 maxwidth = av.getAlignment().getHiddenColumns()
590 .findColumnPosition(maxwidth);
593 while ((ypos <= canvasHeight) && (startRes < maxwidth))
595 endx = startRes + cWidth - 1;
602 g.setFont(av.getFont());
603 g.setColor(Color.black);
605 if (av.getScaleLeftWrapped())
607 drawWestScale(g, startRes, endx, ypos);
610 if (av.getScaleRightWrapped())
612 g.translate(canvasWidth - LABEL_EAST, 0);
613 drawEastScale(g, startRes, endx, ypos);
614 g.translate(-(canvasWidth - LABEL_EAST), 0);
617 g.translate(LABEL_WEST, 0);
619 if (av.getScaleAboveWrapped())
621 drawNorthScale(g, startRes, endx, ypos);
624 if (av.hasHiddenColumns() && av.getShowHiddenMarkers())
626 g.setColor(Color.blue);
628 HiddenColumns hidden = av.getAlignment().getHiddenColumns();
629 List<Integer> positions = hidden.findHiddenRegionPositions();
630 for (int pos : positions)
632 res = pos - startRes;
634 if (res < 0 || res > endx - startRes)
640 new int[] { res * charWidth - charHeight / 4,
641 res * charWidth + charHeight / 4, res * charWidth },
642 new int[] { ypos - (charHeight / 2),
643 ypos - (charHeight / 2), ypos - (charHeight / 2) + 8 },
649 // When printing we have an extra clipped region,
650 // the Printable page which we need to account for here
651 Shape clip = g.getClip();
655 g.setClip(0, 0, cWidth * charWidth, canvasHeight);
659 g.setClip(0, (int) clip.getBounds().getY(), cWidth * charWidth,
660 (int) clip.getBounds().getHeight());
663 drawPanel(g, startRes, endx, 0, al.getHeight() - 1, ypos);
665 if (av.isShowAnnotation())
667 g.translate(0, cHeight + ypos + 3);
668 if (annotations == null)
670 annotations = new AnnotationPanel(av);
673 annotations.renderer.drawComponent(annotations, av, g, -1,
675 g.translate(0, -cHeight - ypos - 3);
678 g.translate(-LABEL_WEST, 0);
680 ypos += cHeight + getAnnotationHeight() + hgap;
686 AnnotationPanel annotations;
688 int getAnnotationHeight()
690 if (!av.isShowAnnotation())
695 if (annotations == null)
697 annotations = new AnnotationPanel(av);
700 return annotations.adjustPanelHeight();
719 public void drawPanel(Graphics g1, int startRes, int endRes,
720 int startSeq, int endSeq, int offset)
723 if (!av.hasHiddenColumns())
725 draw(g1, startRes, endRes, startSeq, endSeq, offset);
730 int blockStart = startRes;
731 int blockEnd = endRes;
733 for (int[] region : av.getAlignment().getHiddenColumns()
734 .getHiddenColumnsCopy())
736 int hideStart = region[0];
737 int hideEnd = region[1];
739 if (hideStart <= blockStart)
741 blockStart += (hideEnd - hideStart) + 1;
745 blockEnd = hideStart - 1;
747 g1.translate(screenY * charWidth, 0);
749 draw(g1, blockStart, blockEnd, startSeq, endSeq, offset);
751 if (av.getShowHiddenMarkers())
753 g1.setColor(Color.blue);
755 g1.drawLine((blockEnd - blockStart + 1) * charWidth - 1,
756 0 + offset, (blockEnd - blockStart + 1) * charWidth - 1,
757 (endSeq - startSeq + 1) * charHeight + offset);
760 g1.translate(-screenY * charWidth, 0);
761 screenY += blockEnd - blockStart + 1;
762 blockStart = hideEnd + 1;
764 if (screenY > (endRes - startRes))
766 // already rendered last block
771 if (screenY <= (endRes - startRes))
773 // remaining visible region to render
774 blockEnd = blockStart + (endRes - startRes) - screenY;
775 g1.translate(screenY * charWidth, 0);
776 draw(g1, blockStart, blockEnd, startSeq, endSeq, offset);
778 g1.translate(-screenY * charWidth, 0);
784 // int startRes, int endRes, int startSeq, int endSeq, int x, int y,
785 // int x1, int x2, int y1, int y2, int startx, int starty,
786 private void draw(Graphics g, int startRes, int endRes, int startSeq,
787 int endSeq, int offset)
789 g.setFont(av.getFont());
790 sr.prepare(g, av.isRenderGaps());
794 // / First draw the sequences
795 // ///////////////////////////
796 for (int i = startSeq; i <= endSeq; i++)
798 nextSeq = av.getAlignment().getSequenceAt(i);
801 // occasionally, a race condition occurs such that the alignment row is
805 sr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq),
806 startRes, endRes, offset + ((i - startSeq) * charHeight));
808 if (av.isShowSequenceFeatures())
810 fr.drawSequence(g, nextSeq, startRes, endRes, offset
811 + ((i - startSeq) * charHeight), false);
814 // / Highlight search Results once all sequences have been drawn
815 // ////////////////////////////////////////////////////////
816 if (av.hasSearchResults())
818 int[] visibleResults = av.getSearchResults().getResults(nextSeq,
820 if (visibleResults != null)
822 for (int r = 0; r < visibleResults.length; r += 2)
824 sr.drawHighlightedText(nextSeq, visibleResults[r],
825 visibleResults[r + 1], (visibleResults[r] - startRes)
827 + ((i - startSeq) * charHeight));
832 if (av.cursorMode && cursorY == i && cursorX >= startRes
833 && cursorX <= endRes)
835 sr.drawCursor(nextSeq, cursorX, (cursorX - startRes) * charWidth,
836 offset + ((i - startSeq) * charHeight));
840 if (av.getSelectionGroup() != null
841 || av.getAlignment().getGroups().size() > 0)
843 drawGroupsBoundaries(g, startRes, endRes, startSeq, endSeq, offset);
848 void drawGroupsBoundaries(Graphics g1, int startRes, int endRes,
849 int startSeq, int endSeq, int offset)
851 Graphics2D g = (Graphics2D) g1;
853 // ///////////////////////////////////
854 // Now outline any areas if necessary
855 // ///////////////////////////////////
857 SequenceGroup group = null;
863 int visWidth = (endRes - startRes + 1) * charWidth;
865 if (av.getAlignment().getGroups().size() > 0)
867 group = av.getAlignment().getGroups().get(0);
877 boolean inGroup = false;
881 for (i = startSeq; i <= endSeq; i++)
883 // position of start residue of group relative to startRes, in pixels
884 sx = (group.getStartRes() - startRes) * charWidth;
885 sy = offset + ((i - startSeq) * charHeight);
886 // width of group in pixels
887 ex = (((group.getEndRes() + 1) - group.getStartRes()) * charWidth) - 1;
889 if (sx + ex < 0 || sx > visWidth)
894 if ((sx <= (endRes - startRes) * charWidth)
895 && group.getSequences(null).contains(
896 av.getAlignment().getSequenceAt(i)))
899 && !group.getSequences(null).contains(
900 av.getAlignment().getSequenceAt(i + 1)))
902 bottom = sy + charHeight;
907 if (((top == -1) && (i == 0))
908 || !group.getSequences(null).contains(
909 av.getAlignment().getSequenceAt(i - 1)))
917 g.setStroke(new BasicStroke());
918 g.setColor(group.getOutlineColour());
925 // if start position is visible, draw vertical line to left of
927 if (sx >= 0 && sx < visWidth)
929 g.drawLine(sx, oldY, sx, sy);
932 // if end position is visible, draw vertical line to right of
934 if (sx + ex < visWidth)
936 g.drawLine(sx + ex, oldY, sx + ex, sy);
945 if (sx + ex > visWidth)
950 else if (sx + ex >= (endRes - startRes + 1) * charWidth)
952 ex = (endRes - startRes + 1) * charWidth;
955 // draw horizontal line at top of group
958 g.drawLine(sx, top, sx + ex, top);
962 // draw horizontal line at bottom of group
965 g.drawLine(sx, bottom, sx + ex, bottom);
976 sy = offset + ((i - startSeq) * charHeight);
977 if (sx >= 0 && sx < visWidth)
979 g.drawLine(sx, oldY, sx, sy);
982 if (sx + ex < visWidth)
984 g.drawLine(sx + ex, oldY, sx + ex, sy);
993 if (sx + ex > visWidth)
997 else if (sx + ex >= (endRes - startRes + 1) * charWidth)
999 ex = (endRes - startRes + 1) * charWidth;
1004 g.drawLine(sx, top, sx + ex, top);
1010 g.drawLine(sx, bottom - 1, sx + ex, bottom - 1);
1019 g.setStroke(new BasicStroke());
1021 if (groupIndex >= av.getAlignment().getGroups().size())
1026 group = av.getAlignment().getGroups().get(groupIndex);
1028 } while (groupIndex < av.getAlignment().getGroups().size());
1036 * Draw the selection group as a separate image and overlay
1038 private BufferedImage drawSelectionGroup(int startRes, int endRes,
1039 int startSeq, int endSeq)
1041 // get a new image of the correct size
1042 BufferedImage selectionImage = setupImage();
1044 if (selectionImage == null)
1049 SequenceGroup group = av.getSelectionGroup();
1056 // set up drawing colour
1057 Graphics2D g = (Graphics2D) selectionImage.getGraphics();
1058 g.translate(LABEL_WEST, 0);
1059 // set background to transparent
1060 g.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
1061 g.fillRect(0, 0, selectionImage.getWidth(), selectionImage.getHeight());
1063 g.setComposite(AlphaComposite.Src);
1064 g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT,
1065 BasicStroke.JOIN_ROUND, 3f, new float[]
1067 g.setColor(Color.RED);
1069 if (!av.hasHiddenColumns())
1071 drawSelectionGroupPart(g, group, startRes, endRes, startSeq, endSeq);
1075 // package into blocks of visible columns
1076 // Graphics2D g = (Graphics2D) selectionImage.getGraphics();
1077 // Graphics g1 = selectionImage.getGraphics();
1080 int blockStart = startRes;
1081 int blockEnd = endRes;
1083 for (int[] region : av.getAlignment().getHiddenColumns()
1084 .getHiddenColumnsCopy())
1086 int hideStart = region[0];
1087 int hideEnd = region[1];
1089 if (hideStart <= blockStart)
1091 blockStart += (hideEnd - hideStart) + 1;
1095 blockEnd = hideStart - 1;
1097 g.translate(screenY * charWidth, 0);
1099 drawSelectionGroupPart(g, group,
1100 blockStart, blockEnd, startSeq, endSeq);
1102 g.translate(-screenY * charWidth, 0);
1103 screenY += blockEnd - blockStart + 1;
1104 blockStart = hideEnd + 1;
1106 if (screenY > (endRes - startRes))
1108 // already rendered last block
1113 if (screenY <= (endRes - startRes))
1115 // remaining visible region to render
1116 blockEnd = blockStart + (endRes - startRes) - screenY;
1117 g.translate(screenY * charWidth, 0);
1118 drawSelectionGroupPart(g, group,
1119 blockStart, blockEnd, startSeq, endSeq);
1121 g.translate(-screenY * charWidth, 0);
1124 g.translate(-LABEL_WEST, 0);
1125 return selectionImage;
1129 * Draw the selection group as a separate image and overlay
1131 private void drawSelectionGroupPart(Graphics2D g, SequenceGroup group,
1132 int startRes, int endRes, int startSeq, int endSeq)
1134 // set up values in case the alignment is wrapped
1135 int verticalOffset = 0;
1136 int horizontalOffset = 0;
1137 if (av.getWrapAlignment())
1139 int hgap = charHeight;
1140 if (av.getScaleAboveWrapped())
1145 // get the start res of the group and work out the offsets for it in the wrapped alignment
1146 int groupstart = group.getStartRes();
1147 int cWidth = (getWidth() - LABEL_EAST - LABEL_WEST) / charWidth;
1149 // group is in which slice of alignment? res position / width in residues
1150 int slice = groupstart / cWidth;
1151 // vertical offset is increased by slice number * number of sequences * height of each sequence
1152 verticalOffset = slice * (av.getAlignment().getHeight() * charHeight
1153 + getAnnotationHeight() + hgap) + hgap;
1155 // horizontal offset is number of residues to subtract from group residue
1157 horizontalOffset = (slice * cWidth);
1160 int visWidth = av.getRanges().getViewportWidth() * charWidth;
1162 // set x start and end positions of group
1163 int startx = (group.getStartRes() - startRes - horizontalOffset)
1165 int endx = (group.getEndRes() - startRes + 1 - horizontalOffset)
1170 boolean inGroup = false;
1174 // get sequences to determine y positions of group
1175 for (i = startSeq; i <= endSeq; ++i)
1177 int sy = verticalOffset + (i - startSeq) * charHeight;
1179 if (group.getSequences(null)
1180 .contains(av.getAlignment().getSequenceAt(i)))
1182 if ((bottom == -1) && !group.getSequences(null)
1183 .contains(av.getAlignment().getSequenceAt(i + 1)))
1185 bottom = sy + charHeight;
1190 if (((top == -1) && (i == 0)) || !group.getSequences(null)
1191 .contains(av.getAlignment().getSequenceAt(i - 1)))
1204 // if start position is visible, draw vertical line to left of
1206 if (startx >= 0 && startx < visWidth * charWidth)
1208 g.drawLine(startx, oldY, startx, sy);
1211 // if end position is visible, draw vertical line to right of
1213 if (endx <= visWidth * charWidth)
1215 g.drawLine(endx, oldY, endx, sy);
1218 if (endx > visWidth * charWidth)
1220 endx = visWidth * charWidth;
1223 // draw horizontal line at top of group
1226 g.drawLine(startx, top, endx, top);
1230 // draw horizontal line at bottom of group
1233 g.drawLine(startx, bottom, endx, bottom);
1243 int sy = verticalOffset + (i - startSeq) * charHeight;
1244 if (startx >= 0 && startx < visWidth)
1246 g.drawLine(startx, oldY, startx, sy);
1249 if (endx < visWidth)
1251 g.drawLine(endx, oldY, endx, sy);
1254 if (endx > visWidth)
1261 g.drawLine(startx, top, endx, top);
1267 g.drawLine(startx, bottom - 1, endx, bottom - 1);
1281 public void highlightSearchResults(SearchResultsI results)
1285 av.setSearchResults(results);
1291 public void propertyChange(PropertyChangeEvent evt)
1293 String eventName = evt.getPropertyName();
1295 if (eventName.equals(SequenceGroup.SEQ_GROUP_CHANGED))
1299 else if (av.getWrapAlignment())
1301 if (eventName.equals(ViewportRanges.STARTRES))
1309 if (eventName.equals(ViewportRanges.STARTRES))
1311 // Make sure we're not trying to draw a panel
1312 // larger than the visible window
1313 ViewportRanges vpRanges = av.getRanges();
1314 scrollX = (int) evt.getNewValue() - (int) evt.getOldValue();
1315 int range = vpRanges.getEndRes() - vpRanges.getStartRes();
1316 if (scrollX > range)
1320 else if (scrollX < -range)
1326 // Both scrolling and resizing change viewport ranges: scrolling changes
1327 // both start and end points, but resize only changes end values.
1328 // Here we only want to fastpaint on a scroll, with resize using a normal
1329 // paint, so scroll events are identified as changes to the horizontal or
1330 // vertical start value.
1331 if (eventName.equals(ViewportRanges.STARTRES))
1333 // scroll - startres and endres both change
1334 fastPaint(scrollX, 0);
1336 else if (eventName.equals(ViewportRanges.STARTSEQ))
1339 fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue());