2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2007 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.*;
39 public class AlignmentPanel
40 extends GAlignmentPanel implements AdjustmentListener, Printable
42 public AlignViewport av;
43 OverviewPanel overviewPanel;
46 IdwidthAdjuster idwidthAdjuster;
49 public AlignFrame alignFrame;
50 ScalePanel scalePanel;
51 AnnotationPanel annotationPanel;
52 AnnotationLabels alabels;
54 // this value is set false when selection area being dragged
55 boolean fastPaint = true;
60 * Creates a new AlignmentPanel object.
62 * @param af DOCUMENT ME!
63 * @param av DOCUMENT ME!
65 public AlignmentPanel(AlignFrame af, final AlignViewport av)
69 seqPanel = new SeqPanel(av, this);
70 idPanel = new IdPanel(av, this);
72 scalePanel = new ScalePanel(av, this);
74 idPanelHolder.add(idPanel, BorderLayout.CENTER);
75 idwidthAdjuster = new IdwidthAdjuster(this);
76 idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
78 annotationPanel = new AnnotationPanel(this);
79 alabels = new AnnotationLabels(this);
81 annotationScroller.setViewportView(annotationPanel);
82 annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);
84 scalePanelHolder.add(scalePanel, BorderLayout.CENTER);
85 seqPanelHolder.add(seqPanel, BorderLayout.CENTER);
87 setScrollValues(0, 0);
89 setAnnotationVisible(av.getShowAnnotation());
91 hscroll.addAdjustmentListener(this);
92 vscroll.addAdjustmentListener(this);
94 final AlignmentPanel ap = this;
95 av.addPropertyChangeListener(new PropertyChangeListener()
97 public void propertyChange(PropertyChangeEvent evt)
99 if (evt.getPropertyName().equals("alignment"))
101 PaintRefresher.Refresh(ap,
102 av.getSequenceSetId(),
111 adjustAnnotationHeight();
115 public void alignmentChanged()
117 av.alignmentChanged(this);
119 alignFrame.updateEditMenuBar();
121 paintAlignment(true);
128 public void fontChanged()
130 // set idCanvas bufferedImage to null
131 // to prevent drawing old image
132 FontMetrics fm = getFontMetrics(av.getFont());
134 scalePanelHolder.setPreferredSize(new Dimension(10,
135 av.charHeight + fm.getDescent()));
136 idSpaceFillerPanel1.setPreferredSize(new Dimension(10,
137 av.charHeight + fm.getDescent()));
139 idPanel.idCanvas.gg = null;
140 seqPanel.seqCanvas.img = null;
141 annotationPanel.adjustPanelHeight();
143 Dimension d = calculateIdWidth();
144 d.setSize(d.width + 4, d.height);
145 idPanel.idCanvas.setPreferredSize(d);
146 hscrollFillerPanel.setPreferredSize(d);
148 if (overviewPanel != null)
150 overviewPanel.setBoxPosition();
157 * Calculate the width of the alignment labels based on the displayed names and any bounds on label width set in preferences.
159 * @return Dimension giving the maximum width of the alignment label panel that should be used.
161 public Dimension calculateIdWidth()
163 Container c = new Container();
165 FontMetrics fm = c.getFontMetrics(
166 new Font(av.font.getName(), Font.ITALIC, av.font.getSize()));
168 AlignmentI al = av.getAlignment();
169 int afwidth = (alignFrame!=null ? alignFrame.getWidth() : 300);
170 int maxwidth = Math.max(20,Math.min(afwidth-200,(int) 2*afwidth/3));
175 while ( (i < al.getHeight()) && (al.getSequenceAt(i) != null))
177 SequenceI s = al.getSequenceAt(i);
179 id = s.getDisplayId(av.getShowJVSuffix());
181 if (fm.stringWidth(id) > idWidth)
183 idWidth = fm.stringWidth(id);
189 // Also check annotation label widths
192 if (al.getAlignmentAnnotation() != null)
194 fm = c.getFontMetrics(alabels.getFont());
196 while (i < al.getAlignmentAnnotation().length)
198 String label = al.getAlignmentAnnotation()[i].label;
200 if (fm.stringWidth(label) > idWidth)
202 idWidth = fm.stringWidth(label);
209 return new Dimension(Math.min(maxwidth, idWidth), 12);
215 * @param results DOCUMENT ME!
217 public void highlightSearchResults(SearchResults results)
219 seqPanel.seqCanvas.highlightSearchResults(results);
221 // do we need to scroll the panel?
224 SequenceI seq = results.getResultSequence(0);
225 int seqIndex = av.alignment.findIndex(seq);
226 int start = seq.findIndex(results.getResultStart(0)) - 1;
227 int end = seq.findIndex(results.getResultEnd(0)) - 1;
229 if (!av.wrapAlignment)
231 if ( (av.getStartRes() > end) || (av.getEndRes() < start) ||
232 ( (av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex)))
234 setScrollValues(start, seqIndex);
239 scrollToWrappedVisible(start);
243 paintAlignment(true);
246 void scrollToWrappedVisible(int res)
248 int cwidth = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.
250 if (res <= av.getStartRes() || res >= (av.getStartRes() + cwidth))
252 vscroll.setValue(res / cwidth);
253 av.startRes = vscroll.getValue() * cwidth;
260 * @return DOCUMENT ME!
262 public OverviewPanel getOverviewPanel()
264 return overviewPanel;
270 * @param op DOCUMENT ME!
272 public void setOverviewPanel(OverviewPanel op)
280 * @param b DOCUMENT ME!
282 public void setAnnotationVisible(boolean b)
284 if (!av.wrapAlignment)
286 annotationSpaceFillerHolder.setVisible(b);
287 annotationScroller.setVisible(b);
292 public void adjustAnnotationHeight()
294 //TODO: display vertical annotation scrollbar if necessary
295 // this is called after loading new annotation onto alignment
296 if (alignFrame.getHeight() == 0)
298 System.out.println("NEEDS FIXING");
301 int height = annotationPanel.adjustPanelHeight();
303 if (hscroll.isVisible())
305 height += hscroll.getPreferredSize().height;
307 if (height > alignFrame.getHeight() / 2)
309 height = alignFrame.getHeight() / 2;
314 annotationScroller.setPreferredSize(
315 new Dimension(annotationScroller.getWidth(), height));
318 annotationSpaceFillerHolder.setPreferredSize(new Dimension(
319 annotationSpaceFillerHolder.getWidth(),
321 annotationScroller.validate();// repaint();
328 * @param wrap DOCUMENT ME!
330 public void setWrapAlignment(boolean wrap)
333 scalePanelHolder.setVisible(!wrap);
334 hscroll.setVisible(!wrap);
335 idwidthAdjuster.setVisible(!wrap);
339 annotationScroller.setVisible(false);
340 annotationSpaceFillerHolder.setVisible(false);
342 else if (av.showAnnotation)
344 annotationScroller.setVisible(true);
345 annotationSpaceFillerHolder.setVisible(true);
348 idSpaceFillerPanel1.setVisible(!wrap);
353 // return value is true if the scroll is valid
354 public boolean scrollUp(boolean up)
358 if (vscroll.getValue() < 1)
364 vscroll.setValue(vscroll.getValue() - 1);
368 if ( (vextent + vscroll.getValue()) >= av.getAlignment().getHeight())
374 vscroll.setValue(vscroll.getValue() + 1);
385 * @param right DOCUMENT ME!
387 * @return DOCUMENT ME!
389 public boolean scrollRight(boolean right)
393 if (hscroll.getValue() < 1)
399 hscroll.setValue(hscroll.getValue() - 1);
403 if ( (hextent + hscroll.getValue()) >= av.getAlignment().getWidth())
409 hscroll.setValue(hscroll.getValue() + 1);
420 * @param x DOCUMENT ME!
421 * @param y DOCUMENT ME!
423 public void setScrollValues(int x, int y)
426 int width = av.alignment.getWidth();
427 int height = av.alignment.getHeight();
429 if (av.hasHiddenColumns)
431 width = av.getColumnSelection().findColumnPosition(width);
434 av.setEndRes( (x + (seqPanel.seqCanvas.getWidth() / av.charWidth)) - 1);
436 hextent = seqPanel.seqCanvas.getWidth() / av.charWidth;
437 vextent = seqPanel.seqCanvas.getHeight() / av.charHeight;
444 if (vextent > height)
449 if ( (hextent + x) > width)
454 if ( (vextent + y) > height)
456 y = height - vextent;
469 hscroll.setValues(x, hextent, 0, width);
470 vscroll.setValues(y, vextent, 0, height);
476 * @param evt DOCUMENT ME!
478 public void adjustmentValueChanged(AdjustmentEvent evt)
481 int oldX = av.getStartRes();
482 int oldY = av.getStartSeq();
484 if (evt.getSource() == hscroll)
486 int x = hscroll.getValue();
489 (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - 1);
492 if (evt.getSource() == vscroll)
494 int offy = vscroll.getValue();
496 if (av.getWrapAlignment())
500 int rowSize = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.
501 seqCanvas.getWidth());
502 av.setStartRes(offy * rowSize);
503 av.setEndRes( (offy + 1) * rowSize);
507 //This is only called if file loaded is a jar file that
508 //was wrapped when saved and user has wrap alignment true
509 //as preference setting
510 SwingUtilities.invokeLater(new Runnable()
514 setScrollValues(av.getStartRes(), av.getStartSeq());
521 av.setStartSeq(offy);
523 (seqPanel.seqCanvas.getHeight() / av.getCharHeight()));
527 if (overviewPanel != null)
529 overviewPanel.setBoxPosition();
532 int scrollX = av.startRes - oldX;
533 int scrollY = av.startSeq - oldY;
535 if (av.getWrapAlignment() || !fastPaint)
541 // Make sure we're not trying to draw a panel
542 // larger than the visible window
543 if (scrollX > av.endRes - av.startRes)
545 scrollX = av.endRes - av.startRes;
547 else if (scrollX < av.startRes - av.endRes)
549 scrollX = av.startRes - av.endRes;
552 if (scrollX != 0 || scrollY != 0)
554 idPanel.idCanvas.fastPaint(scrollY);
555 seqPanel.seqCanvas.fastPaint(scrollX,
557 scalePanel.repaint();
559 if (av.getShowAnnotation())
561 annotationPanel.fastPaint(scrollX);
567 public void paintAlignment(boolean updateOverview)
573 jalview.structure.StructureSelectionManager.getStructureSelectionManager()
574 .sequenceColoursChanged(this);
576 if (overviewPanel != null)
578 overviewPanel.updateOverviewImage();
586 * @param g DOCUMENT ME!
588 public void paintComponent(Graphics g)
592 Dimension d = idPanel.idCanvas.getPreferredSize();
593 idPanelHolder.setPreferredSize(d);
594 hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));
597 if (av.getWrapAlignment())
599 int maxwidth = av.alignment.getWidth();
601 if (av.hasHiddenColumns)
603 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
606 int canvasWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.
607 seqCanvas.getWidth());
611 seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.
614 vscroll.setMaximum(max);
615 vscroll.setUnitIncrement(1);
616 vscroll.setVisibleAmount(1);
621 setScrollValues(av.getStartRes(), av.getStartSeq());
628 * @param pg DOCUMENT ME!
629 * @param pf DOCUMENT ME!
630 * @param pi DOCUMENT ME!
632 * @return DOCUMENT ME!
634 * @throws PrinterException DOCUMENT ME!
636 public int print(Graphics pg, PageFormat pf, int pi)
637 throws PrinterException
639 pg.translate( (int) pf.getImageableX(), (int) pf.getImageableY());
641 int pwidth = (int) pf.getImageableWidth();
642 int pheight = (int) pf.getImageableHeight();
644 if (av.getWrapAlignment())
646 return printWrappedAlignment(pg, pwidth, pheight, pi);
650 return printUnwrapped(pg, pwidth, pheight, pi);
657 * @param pg DOCUMENT ME!
658 * @param pwidth DOCUMENT ME!
659 * @param pheight DOCUMENT ME!
660 * @param pi DOCUMENT ME!
662 * @return DOCUMENT ME!
664 * @throws PrinterException DOCUMENT ME!
666 public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi)
667 throws PrinterException
669 int idWidth = getVisibleIdWidth();
670 FontMetrics fm = getFontMetrics(av.getFont());
671 int scaleHeight = av.charHeight + fm.getDescent();
673 pg.setColor(Color.white);
674 pg.fillRect(0, 0, pwidth, pheight);
675 pg.setFont(av.getFont());
677 ////////////////////////////////////
678 /// How many sequences and residues can we fit on a printable page?
679 int totalRes = (pwidth - idWidth) / av.getCharWidth();
681 int totalSeq = (int) ( (pheight - scaleHeight) / av.getCharHeight()) -
684 int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;
686 /////////////////////////////
687 /// Only print these sequences and residues on this page
690 /////////////////////////////
691 /// Only print these sequences and residues on this page
694 /////////////////////////////
695 /// Only print these sequences and residues on this page
698 /////////////////////////////
699 /// Only print these sequences and residues on this page
701 startRes = (pi % pagesWide) * totalRes;
702 endRes = (startRes + totalRes) - 1;
704 if (endRes > (av.getAlignment().getWidth() - 1))
706 endRes = av.getAlignment().getWidth() - 1;
709 startSeq = (pi / pagesWide) * totalSeq;
710 endSeq = startSeq + totalSeq;
712 if (endSeq > av.getAlignment().getHeight())
714 endSeq = av.getAlignment().getHeight();
717 int pagesHigh = ( (av.alignment.getHeight() / totalSeq) + 1) * pheight;
719 if (av.showAnnotation)
721 pagesHigh += annotationPanel.adjustPanelHeight() + 3;
724 pagesHigh /= pheight;
726 if (pi >= (pagesWide * pagesHigh))
728 return Printable.NO_SUCH_PAGE;
732 pg.translate(idWidth, 0);
733 scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth, scaleHeight);
734 pg.translate( -idWidth, scaleHeight);
738 Color currentColor = null;
739 Color currentTextColor = null;
741 pg.setFont(idPanel.idCanvas.idfont);
744 for (int i = startSeq; i < endSeq; i++)
746 seq = av.getAlignment().getSequenceAt(i);
747 if ( (av.getSelectionGroup() != null) &&
748 av.getSelectionGroup().getSequences(null).contains(seq))
750 currentColor = Color.gray;
751 currentTextColor = Color.black;
755 currentColor = av.getSequenceColour(seq);
756 currentTextColor = Color.black;
759 pg.setColor(currentColor);
760 pg.fillRect(0, (i - startSeq) * av.charHeight, idWidth,
763 pg.setColor(currentTextColor);
766 if (av.rightAlignIds)
768 fm = pg.getFontMetrics();
769 xPos = idWidth - fm.stringWidth(
770 seq.getDisplayId(av.getShowJVSuffix())
774 pg.drawString(seq.getDisplayId(av.getShowJVSuffix()),
776 ( ( (i - startSeq) * av.charHeight) + av.getCharHeight()) -
777 (av.getCharHeight() / 5));
780 pg.setFont(av.getFont());
782 // draw main sequence panel
783 pg.translate(idWidth, 0);
784 seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, 0);
786 if (av.showAnnotation && (endSeq == av.alignment.getHeight()))
788 pg.translate( -idWidth - 3, (endSeq - startSeq) * av.charHeight + 3);
789 alabels.drawComponent( (Graphics2D) pg, idWidth);
790 pg.translate(idWidth + 3, 0);
791 annotationPanel.drawComponent( (Graphics2D) pg, startRes, endRes +
795 return Printable.PAGE_EXISTS;
801 * @param pg DOCUMENT ME!
802 * @param pwidth DOCUMENT ME!
803 * @param pheight DOCUMENT ME!
804 * @param pi DOCUMENT ME!
806 * @return DOCUMENT ME!
808 * @throws PrinterException DOCUMENT ME!
810 public int printWrappedAlignment(Graphics pg, int pwidth, int pheight,
812 throws PrinterException
815 int annotationHeight = 0;
816 AnnotationLabels labels = null;
817 if (av.showAnnotation)
819 annotationHeight = annotationPanel.adjustPanelHeight();
820 labels = new AnnotationLabels(av);
823 int hgap = av.charHeight;
824 if (av.scaleAboveWrapped)
826 hgap += av.charHeight;
829 int cHeight = av.getAlignment().getHeight() * av.charHeight
833 int idWidth = getVisibleIdWidth();
835 int maxwidth = av.alignment.getWidth();
836 if (av.hasHiddenColumns)
838 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
841 int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth -
844 int totalHeight = cHeight * (maxwidth / resWidth + 1);
846 pg.setColor(Color.white);
847 pg.fillRect(0, 0, pwidth, pheight);
848 pg.setFont(av.getFont());
852 pg.setColor(Color.black);
854 pg.translate(0, -pi * pheight);
856 pg.setClip(0, pi * pheight, pwidth, pheight);
862 for (int i = 0; i < av.alignment.getHeight(); i++)
864 pg.setFont(idPanel.idCanvas.idfont);
865 SequenceI s = av.alignment.getSequenceAt(i);
866 String string = s.getDisplayId(av.getShowJVSuffix());
868 if (av.rightAlignIds)
870 FontMetrics fm = pg.getFontMetrics();
871 xPos = idWidth - fm.stringWidth(string) - 4;
873 pg.drawString(string, xPos,
874 ( (i * av.charHeight) + ypos + av.charHeight) -
875 (av.charHeight / 5));
881 (av.getAlignment().getHeight() * av.charHeight));
883 pg.setFont(av.getFont());
884 labels.drawComponent(pg, idWidth);
887 (av.getAlignment().getHeight() * av.charHeight));
892 while (ypos < totalHeight);
894 pg.translate(idWidth, 0);
896 seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight, 0);
898 if ( (pi * pheight) < totalHeight)
900 return Printable.PAGE_EXISTS;
905 return Printable.NO_SUCH_PAGE;
909 int getVisibleIdWidth()
912 idPanel.getWidth() > 0 ? idPanel.getWidth() :
913 calculateIdWidth().width + 4;
916 void makeAlignmentImage(int type, File file)
918 int maxwidth = av.alignment.getWidth();
919 if (av.hasHiddenColumns)
921 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth);
924 int height = ( (av.alignment.getHeight() + 1) * av.charHeight)
925 + scalePanel.getHeight();
926 int width = getVisibleIdWidth() + (maxwidth * av.charWidth);
928 if (av.getWrapAlignment())
930 height = getWrappedHeight();
931 if (System.getProperty("java.awt.headless") != null
932 && System.getProperty("java.awt.headless").equals("true"))
934 width = alignFrame.getWidth()
935 - vscroll.getPreferredSize().width
936 - alignFrame.getInsets().left
937 - alignFrame.getInsets().right;
941 width = seqPanel.getWidth() + getVisibleIdWidth();
945 else if (av.getShowAnnotation())
947 height += annotationPanel.adjustPanelHeight() + 3;
953 jalview.util.ImageMaker im;
954 if (type == jalview.util.ImageMaker.PNG)
956 im = new jalview.util.ImageMaker(this,
957 jalview.util.ImageMaker.PNG,
958 "Create PNG image from alignment",
959 width, height, file, null);
963 im = new jalview.util.ImageMaker(this,
964 jalview.util.ImageMaker.EPS,
965 "Create EPS file from alignment",
967 alignFrame.getTitle());
970 if (av.getWrapAlignment())
972 if (im.getGraphics() != null)
974 printWrappedAlignment(im.getGraphics(), width, height, 0);
980 if (im.getGraphics() != null)
982 printUnwrapped(im.getGraphics(), width, height, 0);
987 catch (OutOfMemoryError err)
989 System.out.println("########################\n"
990 + "OUT OF MEMORY " + file + "\n"
991 + "########################");
993 JOptionPane.showInternalMessageDialog(Desktop.desktop,
994 "Out of Memory Creating Image!!"
996 "\nSee help files for increasing Java Virtual Machine memory."
998 JOptionPane.WARNING_MESSAGE);
999 System.out.println("Create IMAGE: " + err);
1003 catch (Exception ex)
1005 ex.printStackTrace();
1012 public void makeEPS(File epsFile)
1014 makeAlignmentImage(jalview.util.ImageMaker.EPS, epsFile);
1020 public void makePNG(File pngFile)
1022 makeAlignmentImage(jalview.util.ImageMaker.PNG, pngFile);
1025 public void makePNGImageMap(File imgMapFile, String imageName)
1027 ///////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS
1028 //////////////////////////////////////////////
1029 int idWidth = getVisibleIdWidth();
1030 FontMetrics fm = getFontMetrics(av.getFont());
1031 int scaleHeight = av.charHeight + fm.getDescent();
1034 //////////////////////////////////
1035 if (imgMapFile != null)
1039 int s, sSize = av.alignment.getHeight(),
1040 res, alwidth = av.alignment.getWidth(), g, gSize, f, fSize, sy;
1041 StringBuffer text = new StringBuffer();
1042 PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));
1043 out.println(jalview.io.HTMLOutput.getImageMapHTML());
1044 out.println("<img src=\"" + imageName +
1045 "\" border=\"0\" usemap=\"#Map\" >"
1046 + "<map name=\"Map\">");
1048 for (s = 0; s < sSize; s++)
1050 sy = s * av.charHeight + scaleHeight;
1052 SequenceI seq = av.alignment.getSequenceAt(s);
1053 SequenceFeature[] features = seq.getDatasetSequence().
1054 getSequenceFeatures();
1055 SequenceGroup[] groups = av.alignment.findAllGroups(seq);
1056 for (res = 0; res < alwidth; res++)
1058 text = new StringBuffer();
1060 if (av.alignment.isNucleotide())
1062 obj = ResidueProperties.nucleotideName.get(seq.getCharAt(res) +
1067 obj = ResidueProperties.aa2Triplet.get(
1068 seq.getCharAt(res) + "");
1076 String triplet = obj.toString();
1077 int alIndex = seq.findPosition(res);
1078 gSize = groups.length;
1079 for (g = 0; g < gSize; g++)
1081 if (text.length() < 1)
1083 text.append("<area shape=\"rect\" coords=\""
1084 + (idWidth + res * av.charWidth) + ","
1086 + (idWidth + (res + 1) * av.charWidth) + ","
1087 + (av.charHeight + sy) + "\""
1088 + " onMouseOver=\"toolTip('"
1089 + alIndex + " " + triplet);
1092 if (groups[g].getStartRes() < res && groups[g].getEndRes() > res)
1094 text.append("<br><em>" + groups[g].getName() + "</em>");
1098 if (features != null)
1100 if (text.length() < 1)
1102 text.append("<area shape=\"rect\" coords=\""
1103 + (idWidth + res * av.charWidth) + ","
1105 + (idWidth + (res + 1) * av.charWidth) + ","
1106 + (av.charHeight + sy) + "\""
1107 + " onMouseOver=\"toolTip('"
1108 + alIndex + " " + triplet);
1110 fSize = features.length;
1111 for (f = 0; f < fSize; f++)
1114 if ( (features[f].getBegin() <= seq.findPosition(res)) &&
1115 (features[f].getEnd() >= seq.findPosition(res)))
1117 if (features[f].getType().equals("disulfide bond"))
1119 if (features[f].getBegin() == seq.findPosition(res)
1120 || features[f].getEnd() == seq.findPosition(res))
1122 text.append("<br>disulfide bond " + features[f].getBegin() +
1124 features[f].getEnd());
1129 text.append("<br>");
1130 text.append(features[f].getType());
1131 if (features[f].getDescription() != null &&
1133 getType().equals(features[f].getDescription()))
1135 text.append(" " + features[f].getDescription());
1138 if (features[f].getValue("status") != null)
1140 text.append(" (" + features[f].getValue("status") + ")");
1147 if (text.length() > 1)
1149 text.append("')\"; onMouseOut=\"toolTip()\"; href=\"#\">");
1150 out.println(text.toString());
1154 out.println("</map></body></html>");
1158 catch (Exception ex)
1160 ex.printStackTrace();
1162 } ///////////END OF IMAGE MAP
1166 int getWrappedHeight()
1168 int seqPanelWidth = seqPanel.seqCanvas.getWidth();
1170 if (System.getProperty("java.awt.headless") != null
1171 && System.getProperty("java.awt.headless").equals("true"))
1173 seqPanelWidth = alignFrame.getWidth()
1174 - getVisibleIdWidth()
1175 - vscroll.getPreferredSize().width
1176 - alignFrame.getInsets().left
1177 - alignFrame.getInsets().right;
1180 int chunkWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(
1184 int hgap = av.charHeight;
1185 if (av.scaleAboveWrapped)
1187 hgap += av.charHeight;
1190 int annotationHeight = 0;
1191 if (av.showAnnotation)
1193 annotationHeight = annotationPanel.adjustPanelHeight();
1196 int cHeight = av.getAlignment().getHeight() * av.charHeight
1200 int maxwidth = av.alignment.getWidth();
1201 if (av.hasHiddenColumns)
1203 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
1206 int height = ( (maxwidth / chunkWidth) + 1) * cHeight;