2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 import java.awt.event.*;
26 import java.awt.print.*;
29 import jalview.datamodel.*;
30 import jalview.jbgui.*;
31 import jalview.schemes.*;
32 import jalview.structure.SelectionSource;
40 public class AlignmentPanel extends GAlignmentPanel implements
41 AdjustmentListener, Printable
43 public AlignViewport av;
45 OverviewPanel overviewPanel;
51 IdwidthAdjuster idwidthAdjuster;
54 public AlignFrame alignFrame;
56 ScalePanel scalePanel;
58 AnnotationPanel annotationPanel;
60 AnnotationLabels alabels;
62 // this value is set false when selection area being dragged
63 boolean fastPaint = true;
70 * Creates a new AlignmentPanel object.
77 public AlignmentPanel(AlignFrame af, final AlignViewport av)
81 seqPanel = new SeqPanel(av, this);
82 idPanel = new IdPanel(av, this);
84 scalePanel = new ScalePanel(av, this);
86 idPanelHolder.add(idPanel, BorderLayout.CENTER);
87 idwidthAdjuster = new IdwidthAdjuster(this);
88 idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
90 annotationPanel = new AnnotationPanel(this);
91 alabels = new AnnotationLabels(this);
93 annotationScroller.setViewportView(annotationPanel);
94 annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);
96 scalePanelHolder.add(scalePanel, BorderLayout.CENTER);
97 seqPanelHolder.add(seqPanel, BorderLayout.CENTER);
99 setScrollValues(0, 0);
101 setAnnotationVisible(av.getShowAnnotation());
103 hscroll.addAdjustmentListener(this);
104 vscroll.addAdjustmentListener(this);
106 final AlignmentPanel ap = this;
107 av.addPropertyChangeListener(new PropertyChangeListener()
109 public void propertyChange(PropertyChangeEvent evt)
111 if (evt.getPropertyName().equals("alignment"))
113 PaintRefresher.Refresh(ap, av.getSequenceSetId(), true, true);
119 adjustAnnotationHeight();
123 public void alignmentChanged()
125 av.alignmentChanged(this);
127 alignFrame.updateEditMenuBar();
129 paintAlignment(true);
136 public void fontChanged()
138 // set idCanvas bufferedImage to null
139 // to prevent drawing old image
140 FontMetrics fm = getFontMetrics(av.getFont());
142 scalePanelHolder.setPreferredSize(new Dimension(10, av.charHeight
144 idSpaceFillerPanel1.setPreferredSize(new Dimension(10, av.charHeight
147 idPanel.idCanvas.gg = null;
148 seqPanel.seqCanvas.img = null;
149 annotationPanel.adjustPanelHeight();
151 Dimension d = calculateIdWidth();
152 d.setSize(d.width + 4, d.height);
153 idPanel.idCanvas.setPreferredSize(d);
154 hscrollFillerPanel.setPreferredSize(d);
156 if (overviewPanel != null)
158 overviewPanel.setBoxPosition();
165 * Calculate the width of the alignment labels based on the displayed names
166 * and any bounds on label width set in preferences.
168 * @return Dimension giving the maximum width of the alignment label panel
169 * that should be used.
171 public Dimension calculateIdWidth()
173 Container c = new Container();
175 FontMetrics fm = c.getFontMetrics(new Font(av.font.getName(),
176 Font.ITALIC, av.font.getSize()));
178 AlignmentI al = av.getAlignment();
179 int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300);
180 int maxwidth = Math.max(20, Math.min(afwidth - 200, (int) 2 * afwidth
186 while ((i < al.getHeight()) && (al.getSequenceAt(i) != null))
188 SequenceI s = al.getSequenceAt(i);
190 id = s.getDisplayId(av.getShowJVSuffix());
192 if (fm.stringWidth(id) > idWidth)
194 idWidth = fm.stringWidth(id);
200 // Also check annotation label widths
203 if (al.getAlignmentAnnotation() != null)
205 fm = c.getFontMetrics(alabels.getFont());
207 while (i < al.getAlignmentAnnotation().length)
209 String label = al.getAlignmentAnnotation()[i].label;
211 if (fm.stringWidth(label) > idWidth)
213 idWidth = fm.stringWidth(label);
220 return new Dimension(Math.min(maxwidth, idWidth), 12);
229 public void highlightSearchResults(SearchResults results)
231 scrollToPosition(results);
232 seqPanel.seqCanvas.highlightSearchResults(results);
235 * scroll the view to show the position of the highlighted
236 * region in results (if any) and redraw the overview
239 public boolean scrollToPosition(SearchResults results) {
240 return scrollToPosition(results, true);
243 * scroll the view to show the position of the highlighted
244 * region in results (if any)
246 * @param redrawOverview - when set, the overview will be recalculated (takes longer)
247 * @return false if results were not found
249 public boolean scrollToPosition(SearchResults results, boolean redrawOverview) {
250 // TODO: properly locate search results in view when large numbers of hidden columns exist before highlighted region
251 // do we need to scroll the panel?
252 if (results != null && results.getSize()>0)
254 int seqIndex = av.alignment.findIndex(results);
259 SequenceI seq = av.alignment.getSequenceAt(seqIndex);
261 int [] r = results.getResults(seq, seq.getStart(), seq.getEnd());
272 if (end==seq.getEnd())
276 if (!av.wrapAlignment)
278 if ((av.getStartRes() >= start)
279 || (av.getEndRes() <= end))
281 setScrollValues(start-1, seqIndex);
282 } else if ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex))
284 setScrollValues(av.getStartRes(), seqIndex);
289 scrollToWrappedVisible(start);
292 if (!redrawOverview && overviewPanel!=null)
294 overviewPanel.setBoxPosition();
296 paintAlignment(!redrawOverview);
300 void scrollToWrappedVisible(int res)
302 int cwidth = seqPanel.seqCanvas
303 .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
304 if (res < av.getStartRes() || res >= (av.getStartRes()+cwidth))
306 vscroll.setValue((res / cwidth));
307 av.startRes = vscroll.getValue() * cwidth;
315 * @return DOCUMENT ME!
317 public OverviewPanel getOverviewPanel()
319 return overviewPanel;
328 public void setOverviewPanel(OverviewPanel op)
339 public void setAnnotationVisible(boolean b)
341 if (!av.wrapAlignment)
343 annotationSpaceFillerHolder.setVisible(b);
344 annotationScroller.setVisible(b);
349 public void adjustAnnotationHeight()
351 // TODO: display vertical annotation scrollbar if necessary
352 // this is called after loading new annotation onto alignment
353 if (alignFrame.getHeight() == 0)
355 System.out.println("NEEDS FIXING");
358 int height = annotationPanel.adjustPanelHeight();
360 if (hscroll.isVisible())
362 height += hscroll.getPreferredSize().height;
364 if (height > alignFrame.getHeight() / 2)
366 height = alignFrame.getHeight() / 2;
371 annotationScroller.setPreferredSize(new Dimension(annotationScroller
372 .getWidth(), height));
374 annotationSpaceFillerHolder.setPreferredSize(new Dimension(
375 annotationSpaceFillerHolder.getWidth(), height));
376 annotationScroller.validate();// repaint();
386 public void setWrapAlignment(boolean wrap)
389 scalePanelHolder.setVisible(!wrap);
390 hscroll.setVisible(!wrap);
391 idwidthAdjuster.setVisible(!wrap);
395 annotationScroller.setVisible(false);
396 annotationSpaceFillerHolder.setVisible(false);
398 else if (av.showAnnotation)
400 annotationScroller.setVisible(true);
401 annotationSpaceFillerHolder.setVisible(true);
404 idSpaceFillerPanel1.setVisible(!wrap);
409 // return value is true if the scroll is valid
410 public boolean scrollUp(boolean up)
414 if (vscroll.getValue() < 1)
420 vscroll.setValue(vscroll.getValue() - 1);
424 if ((vextent + vscroll.getValue()) >= av.getAlignment().getHeight())
430 vscroll.setValue(vscroll.getValue() + 1);
444 * @return DOCUMENT ME!
446 public boolean scrollRight(boolean right)
450 if (hscroll.getValue() < 1)
456 hscroll.setValue(hscroll.getValue() - 1);
460 if ((hextent + hscroll.getValue()) >= av.getAlignment().getWidth())
466 hscroll.setValue(hscroll.getValue() + 1);
482 public void setScrollValues(int x, int y)
484 if (av==null || av.alignment==null)
488 int width = av.alignment.getWidth();
489 int height = av.alignment.getHeight();
491 if (av.hasHiddenColumns)
493 width = av.getColumnSelection().findColumnPosition(width);
496 av.setEndRes((x + (seqPanel.seqCanvas.getWidth() / av.charWidth)) - 1);
498 hextent = seqPanel.seqCanvas.getWidth() / av.charWidth;
499 vextent = seqPanel.seqCanvas.getHeight() / av.charHeight;
506 if (vextent > height)
511 if ((hextent + x) > width)
516 if ((vextent + y) > height)
518 y = height - vextent;
531 hscroll.setValues(x, hextent, 0, width);
532 vscroll.setValues(y, vextent, 0, height);
541 public void adjustmentValueChanged(AdjustmentEvent evt)
544 int oldX = av.getStartRes();
545 int oldY = av.getStartSeq();
547 if (evt.getSource() == hscroll)
549 int x = hscroll.getValue();
552 .setEndRes((x + (seqPanel.seqCanvas.getWidth() / av
553 .getCharWidth())) - 1);
556 if (evt.getSource() == vscroll)
558 int offy = vscroll.getValue();
560 if (av.getWrapAlignment())
564 int rowSize = seqPanel.seqCanvas
565 .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
566 av.setStartRes(offy * rowSize);
567 av.setEndRes((offy + 1) * rowSize);
571 // This is only called if file loaded is a jar file that
572 // was wrapped when saved and user has wrap alignment true
573 // as preference setting
574 SwingUtilities.invokeLater(new Runnable()
578 setScrollValues(av.getStartRes(), av.getStartSeq());
585 av.setStartSeq(offy);
587 + (seqPanel.seqCanvas.getHeight() / av.getCharHeight()));
591 if (overviewPanel != null)
593 overviewPanel.setBoxPosition();
596 int scrollX = av.startRes - oldX;
597 int scrollY = av.startSeq - oldY;
599 if (av.getWrapAlignment() || !fastPaint)
605 // Make sure we're not trying to draw a panel
606 // larger than the visible window
607 if (scrollX > av.endRes - av.startRes)
609 scrollX = av.endRes - av.startRes;
611 else if (scrollX < av.startRes - av.endRes)
613 scrollX = av.startRes - av.endRes;
616 if (scrollX != 0 || scrollY != 0)
618 idPanel.idCanvas.fastPaint(scrollY);
619 seqPanel.seqCanvas.fastPaint(scrollX, scrollY);
620 scalePanel.repaint();
622 if (av.getShowAnnotation())
624 annotationPanel.fastPaint(scrollX);
630 public void paintAlignment(boolean updateOverview)
636 jalview.structure.StructureSelectionManager
637 .getStructureSelectionManager().sequenceColoursChanged(this);
639 if (overviewPanel != null)
641 overviewPanel.updateOverviewImage();
652 public void paintComponent(Graphics g)
656 Dimension d = idPanel.idCanvas.getPreferredSize();
657 idPanelHolder.setPreferredSize(d);
658 hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));
661 if (av.getWrapAlignment())
663 int maxwidth = av.alignment.getWidth();
665 if (av.hasHiddenColumns)
667 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
670 int canvasWidth = seqPanel.seqCanvas
671 .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
676 .getWrappedCanvasWidth(seqPanel.seqCanvas
678 vscroll.setMaximum(max);
679 vscroll.setUnitIncrement(1);
680 vscroll.setVisibleAmount(1);
685 setScrollValues(av.getStartRes(), av.getStartSeq());
699 * @return DOCUMENT ME!
701 * @throws PrinterException
704 public int print(Graphics pg, PageFormat pf, int pi)
705 throws PrinterException
707 pg.translate((int) pf.getImageableX(), (int) pf.getImageableY());
709 int pwidth = (int) pf.getImageableWidth();
710 int pheight = (int) pf.getImageableHeight();
712 if (av.getWrapAlignment())
714 return printWrappedAlignment(pg, pwidth, pheight, pi);
718 return printUnwrapped(pg, pwidth, pheight, pi);
734 * @return DOCUMENT ME!
736 * @throws PrinterException
739 public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi)
740 throws PrinterException
742 int idWidth = getVisibleIdWidth();
743 FontMetrics fm = getFontMetrics(av.getFont());
744 int scaleHeight = av.charHeight + fm.getDescent();
746 pg.setColor(Color.white);
747 pg.fillRect(0, 0, pwidth, pheight);
748 pg.setFont(av.getFont());
750 // //////////////////////////////////
751 // / How many sequences and residues can we fit on a printable page?
752 int totalRes = (pwidth - idWidth) / av.getCharWidth();
754 int totalSeq = (int) ((pheight - scaleHeight) / av.getCharHeight()) - 1;
756 int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;
758 // ///////////////////////////
759 // / Only print these sequences and residues on this page
762 // ///////////////////////////
763 // / Only print these sequences and residues on this page
766 // ///////////////////////////
767 // / Only print these sequences and residues on this page
770 // ///////////////////////////
771 // / Only print these sequences and residues on this page
773 startRes = (pi % pagesWide) * totalRes;
774 endRes = (startRes + totalRes) - 1;
776 if (endRes > (av.getAlignment().getWidth() - 1))
778 endRes = av.getAlignment().getWidth() - 1;
781 startSeq = (pi / pagesWide) * totalSeq;
782 endSeq = startSeq + totalSeq;
784 if (endSeq > av.getAlignment().getHeight())
786 endSeq = av.getAlignment().getHeight();
789 int pagesHigh = ((av.alignment.getHeight() / totalSeq) + 1) * pheight;
791 if (av.showAnnotation)
793 pagesHigh += annotationPanel.adjustPanelHeight() + 3;
796 pagesHigh /= pheight;
798 if (pi >= (pagesWide * pagesHigh))
800 return Printable.NO_SUCH_PAGE;
804 pg.translate(idWidth, 0);
805 scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth,
807 pg.translate(-idWidth, scaleHeight);
811 Color currentColor = null;
812 Color currentTextColor = null;
814 pg.setFont(idPanel.idCanvas.idfont);
817 for (int i = startSeq; i < endSeq; i++)
819 seq = av.getAlignment().getSequenceAt(i);
820 if ((av.getSelectionGroup() != null)
821 && av.getSelectionGroup().getSequences(null).contains(seq))
823 currentColor = Color.gray;
824 currentTextColor = Color.black;
828 currentColor = av.getSequenceColour(seq);
829 currentTextColor = Color.black;
832 pg.setColor(currentColor);
833 pg.fillRect(0, (i - startSeq) * av.charHeight, idWidth, av
836 pg.setColor(currentTextColor);
839 if (av.rightAlignIds)
841 fm = pg.getFontMetrics();
843 - fm.stringWidth(seq.getDisplayId(av.getShowJVSuffix()))
847 pg.drawString(seq.getDisplayId(av.getShowJVSuffix()), xPos,
848 (((i - startSeq) * av.charHeight) + av.getCharHeight())
849 - (av.getCharHeight() / 5));
852 pg.setFont(av.getFont());
854 // draw main sequence panel
855 pg.translate(idWidth, 0);
856 seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, 0);
858 if (av.showAnnotation && (endSeq == av.alignment.getHeight()))
860 pg.translate(-idWidth - 3, (endSeq - startSeq) * av.charHeight + 3);
861 alabels.drawComponent((Graphics2D) pg, idWidth);
862 pg.translate(idWidth + 3, 0);
863 annotationPanel.drawComponent((Graphics2D) pg, startRes, endRes + 1);
866 return Printable.PAGE_EXISTS;
881 * @return DOCUMENT ME!
883 * @throws PrinterException
886 public int printWrappedAlignment(Graphics pg, int pwidth, int pheight,
887 int pi) throws PrinterException
890 int annotationHeight = 0;
891 AnnotationLabels labels = null;
892 if (av.showAnnotation)
894 annotationHeight = annotationPanel.adjustPanelHeight();
895 labels = new AnnotationLabels(av);
898 int hgap = av.charHeight;
899 if (av.scaleAboveWrapped)
901 hgap += av.charHeight;
904 int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap
907 int idWidth = getVisibleIdWidth();
909 int maxwidth = av.alignment.getWidth();
910 if (av.hasHiddenColumns)
912 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
915 int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth
918 int totalHeight = cHeight * (maxwidth / resWidth + 1);
920 pg.setColor(Color.white);
921 pg.fillRect(0, 0, pwidth, pheight);
922 pg.setFont(av.getFont());
926 pg.setColor(Color.black);
928 pg.translate(0, -pi * pheight);
930 pg.setClip(0, pi * pheight, pwidth, pheight);
936 for (int i = 0; i < av.alignment.getHeight(); i++)
938 pg.setFont(idPanel.idCanvas.idfont);
939 SequenceI s = av.alignment.getSequenceAt(i);
940 String string = s.getDisplayId(av.getShowJVSuffix());
942 if (av.rightAlignIds)
944 FontMetrics fm = pg.getFontMetrics();
945 xPos = idWidth - fm.stringWidth(string) - 4;
947 pg.drawString(string, xPos,
948 ((i * av.charHeight) + ypos + av.charHeight)
949 - (av.charHeight / 5));
953 pg.translate(-3, ypos
954 + (av.getAlignment().getHeight() * av.charHeight));
956 pg.setFont(av.getFont());
957 labels.drawComponent(pg, idWidth);
958 pg.translate(+3, -ypos
959 - (av.getAlignment().getHeight() * av.charHeight));
963 } while (ypos < totalHeight);
965 pg.translate(idWidth, 0);
967 seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight,
970 if ((pi * pheight) < totalHeight)
972 return Printable.PAGE_EXISTS;
977 return Printable.NO_SUCH_PAGE;
981 int getVisibleIdWidth()
983 return idPanel.getWidth() > 0 ? idPanel.getWidth()
984 : calculateIdWidth().width + 4;
987 void makeAlignmentImage(int type, File file)
989 int maxwidth = av.alignment.getWidth();
990 if (av.hasHiddenColumns)
992 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth);
995 int height = ((av.alignment.getHeight() + 1) * av.charHeight)
996 + scalePanel.getHeight();
997 int width = getVisibleIdWidth() + (maxwidth * av.charWidth);
999 if (av.getWrapAlignment())
1001 height = getWrappedHeight();
1002 if (System.getProperty("java.awt.headless") != null
1003 && System.getProperty("java.awt.headless").equals("true"))
1005 width = alignFrame.getWidth() - vscroll.getPreferredSize().width
1006 - alignFrame.getInsets().left
1007 - alignFrame.getInsets().right;
1011 width = seqPanel.getWidth() + getVisibleIdWidth();
1015 else if (av.getShowAnnotation())
1017 height += annotationPanel.adjustPanelHeight() + 3;
1023 jalview.util.ImageMaker im;
1024 if (type == jalview.util.ImageMaker.PNG)
1026 im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
1027 "Create PNG image from alignment", width, height, file,
1032 im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
1033 "Create EPS file from alignment", width, height, file,
1034 alignFrame.getTitle());
1037 if (av.getWrapAlignment())
1039 if (im.getGraphics() != null)
1041 printWrappedAlignment(im.getGraphics(), width, height, 0);
1047 if (im.getGraphics() != null)
1049 printUnwrapped(im.getGraphics(), width, height, 0);
1053 } catch (OutOfMemoryError err)
1056 System.out.println("########################\n" + "OUT OF MEMORY "
1057 + file + "\n" + "########################");
1058 new OOMWarning("Creating Image for " + file, err);
1059 // System.out.println("Create IMAGE: " + err);
1060 } catch (Exception ex)
1062 ex.printStackTrace();
1069 public void makeEPS(File epsFile)
1071 makeAlignmentImage(jalview.util.ImageMaker.EPS, epsFile);
1077 public void makePNG(File pngFile)
1079 makeAlignmentImage(jalview.util.ImageMaker.PNG, pngFile);
1082 public void makePNGImageMap(File imgMapFile, String imageName)
1084 // /////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS
1085 // ////////////////////////////////////////////
1086 int idWidth = getVisibleIdWidth();
1087 FontMetrics fm = getFontMetrics(av.getFont());
1088 int scaleHeight = av.charHeight + fm.getDescent();
1091 // ////////////////////////////////
1092 if (imgMapFile != null)
1096 int s, sSize = av.alignment.getHeight(), res, alwidth = av.alignment
1097 .getWidth(), g, gSize, f, fSize, sy;
1098 StringBuffer text = new StringBuffer();
1099 PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));
1100 out.println(jalview.io.HTMLOutput.getImageMapHTML());
1101 out.println("<img src=\"" + imageName
1102 + "\" border=\"0\" usemap=\"#Map\" >"
1103 + "<map name=\"Map\">");
1105 for (s = 0; s < sSize; s++)
1107 sy = s * av.charHeight + scaleHeight;
1109 SequenceI seq = av.alignment.getSequenceAt(s);
1110 SequenceFeature[] features = seq.getDatasetSequence()
1111 .getSequenceFeatures();
1112 SequenceGroup[] groups = av.alignment.findAllGroups(seq);
1113 for (res = 0; res < alwidth; res++)
1115 text = new StringBuffer();
1117 if (av.alignment.isNucleotide())
1119 obj = ResidueProperties.nucleotideName.get(seq.getCharAt(res)
1124 obj = ResidueProperties.aa2Triplet.get(seq.getCharAt(res)
1133 String triplet = obj.toString();
1134 int alIndex = seq.findPosition(res);
1135 gSize = groups.length;
1136 for (g = 0; g < gSize; g++)
1138 if (text.length() < 1)
1140 text.append("<area shape=\"rect\" coords=\""
1141 + (idWidth + res * av.charWidth) + "," + sy + ","
1142 + (idWidth + (res + 1) * av.charWidth) + ","
1143 + (av.charHeight + sy) + "\""
1144 + " onMouseOver=\"toolTip('" + alIndex + " "
1148 if (groups[g].getStartRes() < res
1149 && groups[g].getEndRes() > res)
1151 text.append("<br><em>" + groups[g].getName() + "</em>");
1155 if (features != null)
1157 if (text.length() < 1)
1159 text.append("<area shape=\"rect\" coords=\""
1160 + (idWidth + res * av.charWidth) + "," + sy + ","
1161 + (idWidth + (res + 1) * av.charWidth) + ","
1162 + (av.charHeight + sy) + "\""
1163 + " onMouseOver=\"toolTip('" + alIndex + " "
1166 fSize = features.length;
1167 for (f = 0; f < fSize; f++)
1170 if ((features[f].getBegin() <= seq.findPosition(res))
1171 && (features[f].getEnd() >= seq.findPosition(res)))
1173 if (features[f].getType().equals("disulfide bond"))
1175 if (features[f].getBegin() == seq.findPosition(res)
1176 || features[f].getEnd() == seq
1179 text.append("<br>disulfide bond "
1180 + features[f].getBegin() + ":"
1181 + features[f].getEnd());
1186 text.append("<br>");
1187 text.append(features[f].getType());
1188 if (features[f].getDescription() != null
1189 && !features[f].getType().equals(
1190 features[f].getDescription()))
1192 text.append(" " + features[f].getDescription());
1195 if (features[f].getValue("status") != null)
1197 text.append(" (" + features[f].getValue("status")
1205 if (text.length() > 1)
1207 text.append("')\"; onMouseOut=\"toolTip()\"; href=\"#\">");
1208 out.println(text.toString());
1212 out.println("</map></body></html>");
1215 } catch (Exception ex)
1217 ex.printStackTrace();
1219 } // /////////END OF IMAGE MAP
1223 int getWrappedHeight()
1225 int seqPanelWidth = seqPanel.seqCanvas.getWidth();
1227 if (System.getProperty("java.awt.headless") != null
1228 && System.getProperty("java.awt.headless").equals("true"))
1230 seqPanelWidth = alignFrame.getWidth() - getVisibleIdWidth()
1231 - vscroll.getPreferredSize().width
1232 - alignFrame.getInsets().left - alignFrame.getInsets().right;
1235 int chunkWidth = seqPanel.seqCanvas
1236 .getWrappedCanvasWidth(seqPanelWidth);
1238 int hgap = av.charHeight;
1239 if (av.scaleAboveWrapped)
1241 hgap += av.charHeight;
1244 int annotationHeight = 0;
1245 if (av.showAnnotation)
1247 annotationHeight = annotationPanel.adjustPanelHeight();
1250 int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap
1253 int maxwidth = av.alignment.getWidth();
1254 if (av.hasHiddenColumns)
1256 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
1259 int height = ((maxwidth / chunkWidth) + 1) * cHeight;