2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 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.bin.Cache;
30 import jalview.datamodel.*;
31 import jalview.jbgui.*;
32 import jalview.schemes.*;
33 import jalview.structure.SelectionSource;
41 public class AlignmentPanel extends GAlignmentPanel implements
42 AdjustmentListener, Printable
44 public AlignViewport av;
46 OverviewPanel overviewPanel;
52 IdwidthAdjuster idwidthAdjuster;
55 public AlignFrame alignFrame;
57 ScalePanel scalePanel;
59 AnnotationPanel annotationPanel;
61 AnnotationLabels alabels;
63 // this value is set false when selection area being dragged
64 boolean fastPaint = true;
71 * Creates a new AlignmentPanel object.
78 public AlignmentPanel(AlignFrame af, final AlignViewport av)
82 seqPanel = new SeqPanel(av, this);
83 idPanel = new IdPanel(av, this);
85 scalePanel = new ScalePanel(av, this);
87 idPanelHolder.add(idPanel, BorderLayout.CENTER);
88 idwidthAdjuster = new IdwidthAdjuster(this);
89 idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
91 annotationPanel = new AnnotationPanel(this);
92 alabels = new AnnotationLabels(this);
94 annotationScroller.setViewportView(annotationPanel);
95 annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);
97 scalePanelHolder.add(scalePanel, BorderLayout.CENTER);
98 seqPanelHolder.add(seqPanel, BorderLayout.CENTER);
100 setScrollValues(0, 0);
102 setAnnotationVisible(av.getShowAnnotation());
104 hscroll.addAdjustmentListener(this);
105 vscroll.addAdjustmentListener(this);
107 final AlignmentPanel ap = this;
108 av.addPropertyChangeListener(new PropertyChangeListener()
110 public void propertyChange(PropertyChangeEvent evt)
112 if (evt.getPropertyName().equals("alignment"))
114 PaintRefresher.Refresh(ap, av.getSequenceSetId(), true, true);
120 adjustAnnotationHeight();
124 public void alignmentChanged()
126 av.alignmentChanged(this);
128 alignFrame.updateEditMenuBar();
130 paintAlignment(true);
137 public void fontChanged()
139 // set idCanvas bufferedImage to null
140 // to prevent drawing old image
141 FontMetrics fm = getFontMetrics(av.getFont());
143 scalePanelHolder.setPreferredSize(new Dimension(10, av.charHeight
145 idSpaceFillerPanel1.setPreferredSize(new Dimension(10, av.charHeight
148 idPanel.idCanvas.gg = null;
149 seqPanel.seqCanvas.img = null;
150 annotationPanel.adjustPanelHeight();
152 Dimension d = calculateIdWidth();
153 d.setSize(d.width + 4, d.height);
154 idPanel.idCanvas.setPreferredSize(d);
155 hscrollFillerPanel.setPreferredSize(d);
157 if (overviewPanel != null)
159 overviewPanel.setBoxPosition();
166 * Calculate the width of the alignment labels based on the displayed names
167 * and any bounds on label width set in preferences.
169 * @return Dimension giving the maximum width of the alignment label panel
170 * that should be used.
172 public Dimension calculateIdWidth()
174 Container c = new Container();
176 FontMetrics fm = c.getFontMetrics(new Font(av.font.getName(),
177 Font.ITALIC, av.font.getSize()));
179 AlignmentI al = av.getAlignment();
180 int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300);
181 int maxwidth = Math.max(20, Math.min(afwidth - 200, (int) 2 * afwidth
187 while ((i < al.getHeight()) && (al.getSequenceAt(i) != null))
189 SequenceI s = al.getSequenceAt(i);
191 id = s.getDisplayId(av.getShowJVSuffix());
193 if (fm.stringWidth(id) > idWidth)
195 idWidth = fm.stringWidth(id);
201 // Also check annotation label widths
204 if (al.getAlignmentAnnotation() != null)
206 fm = c.getFontMetrics(alabels.getFont());
208 while (i < al.getAlignmentAnnotation().length)
210 String label = al.getAlignmentAnnotation()[i].label;
212 if (fm.stringWidth(label) > idWidth)
214 idWidth = fm.stringWidth(label);
221 return new Dimension(Math.min(maxwidth, idWidth), 12);
230 public void highlightSearchResults(SearchResults results)
232 scrollToPosition(results);
233 seqPanel.seqCanvas.highlightSearchResults(results);
236 * scroll the view to show the position of the highlighted
237 * region in results (if any) and redraw the overview
240 public boolean scrollToPosition(SearchResults results) {
241 return scrollToPosition(results, true);
244 * scroll the view to show the position of the highlighted
245 * region in results (if any)
247 * @param redrawOverview - when set, the overview will be recalculated (takes longer)
248 * @return false if results were not found
250 public boolean scrollToPosition(SearchResults results, boolean redrawOverview) {
251 int startv,endv,starts,ends,width;
252 // TODO: properly locate search results in view when large numbers of hidden columns exist before highlighted region
253 // do we need to scroll the panel?
254 // TODO: tons of nullpointereexceptions raised here.
255 if (results != null && results.getSize()>0 && av!=null && av.alignment!=null)
257 int seqIndex = av.alignment.findIndex(results);
262 SequenceI seq = av.alignment.getSequenceAt(seqIndex);
264 int [] r = results.getResults(seq, 0, av.alignment.getWidth()); // results.getResults(seq, seq.getStart(), seq.getEnd());
265 // TODO: VAMSAS: fix hidden column issue where scroll to left from C terminus is not visible
276 if (end==seq.getEnd())
280 if (!av.wrapAlignment)
282 if ((startv=av.getStartRes()) >= start)
284 setScrollValues(start-1, seqIndex);
286 ((endv=av.getEndRes()) <= end)
288 setScrollValues(startv+1+end-endv, seqIndex);
289 } else if ((starts=av.getStartSeq()) > seqIndex) {
290 setScrollValues(av.getStartRes(), seqIndex);
291 } else if ((ends=av.getEndSeq()) <= seqIndex)
293 setScrollValues(av.getStartRes(), starts+seqIndex-ends+1);
298 scrollToWrappedVisible(start);
301 if (!redrawOverview && overviewPanel!=null)
303 overviewPanel.setBoxPosition();
305 paintAlignment(!redrawOverview);
309 void scrollToWrappedVisible(int res)
311 int cwidth = seqPanel.seqCanvas
312 .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
313 if (res < av.getStartRes() || res >= (av.getStartRes()+cwidth))
315 vscroll.setValue((res / cwidth));
316 av.startRes = vscroll.getValue() * cwidth;
324 * @return DOCUMENT ME!
326 public OverviewPanel getOverviewPanel()
328 return overviewPanel;
337 public void setOverviewPanel(OverviewPanel op)
348 public void setAnnotationVisible(boolean b)
350 if (!av.wrapAlignment)
352 annotationSpaceFillerHolder.setVisible(b);
353 annotationScroller.setVisible(b);
358 public void adjustAnnotationHeight()
360 // TODO: display vertical annotation scrollbar if necessary
361 // this is called after loading new annotation onto alignment
362 if (alignFrame.getHeight() == 0)
364 System.out.println("NEEDS FIXING");
367 int height = annotationPanel.adjustPanelHeight();
369 if (hscroll.isVisible())
371 height += hscroll.getPreferredSize().height;
373 if (height > alignFrame.getHeight() / 2)
375 height = alignFrame.getHeight() / 2;
380 annotationScroller.setPreferredSize(new Dimension(annotationScroller
381 .getWidth(), height));
383 annotationSpaceFillerHolder.setPreferredSize(new Dimension(
384 annotationSpaceFillerHolder.getWidth(), height));
385 annotationScroller.validate();// repaint();
395 public void setWrapAlignment(boolean wrap)
398 scalePanelHolder.setVisible(!wrap);
399 hscroll.setVisible(!wrap);
400 idwidthAdjuster.setVisible(!wrap);
404 annotationScroller.setVisible(false);
405 annotationSpaceFillerHolder.setVisible(false);
407 else if (av.showAnnotation)
409 annotationScroller.setVisible(true);
410 annotationSpaceFillerHolder.setVisible(true);
413 idSpaceFillerPanel1.setVisible(!wrap);
418 // return value is true if the scroll is valid
419 public boolean scrollUp(boolean up)
423 if (vscroll.getValue() < 1)
429 vscroll.setValue(vscroll.getValue() - 1);
433 if ((vextent + vscroll.getValue()) >= av.getAlignment().getHeight())
439 vscroll.setValue(vscroll.getValue() + 1);
453 * @return DOCUMENT ME!
455 public boolean scrollRight(boolean right)
459 if (hscroll.getValue() < 1)
465 hscroll.setValue(hscroll.getValue() - 1);
469 if ((hextent + hscroll.getValue()) >= av.getAlignment().getWidth())
475 hscroll.setValue(hscroll.getValue() + 1);
491 public void setScrollValues(int x, int y)
493 // System.err.println("Scroll to "+x+","+y);
494 if (av==null || av.alignment==null)
498 int width = av.alignment.getWidth();
499 int height = av.alignment.getHeight();
501 if (av.hasHiddenColumns)
503 width = av.getColumnSelection().findColumnPosition(width);
506 av.setEndRes((x + (seqPanel.seqCanvas.getWidth() / av.charWidth)) - 1);
508 hextent = seqPanel.seqCanvas.getWidth() / av.charWidth;
509 vextent = seqPanel.seqCanvas.getHeight() / av.charHeight;
516 if (vextent > height)
521 if ((hextent + x) > width)
526 if ((vextent + y) > height)
528 y = height - vextent;
541 hscroll.setValues(x, hextent, 0, width);
542 vscroll.setValues(y, vextent, 0, height);
551 public void adjustmentValueChanged(AdjustmentEvent evt)
554 int oldX = av.getStartRes();
555 int oldY = av.getStartSeq();
557 if (evt.getSource() == hscroll)
559 int x = hscroll.getValue();
562 .setEndRes((x + (seqPanel.seqCanvas.getWidth() / av
563 .getCharWidth())) - 1);
566 if (evt.getSource() == vscroll)
568 int offy = vscroll.getValue();
570 if (av.getWrapAlignment())
574 int rowSize = seqPanel.seqCanvas
575 .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
576 av.setStartRes(offy * rowSize);
577 av.setEndRes((offy + 1) * rowSize);
581 // This is only called if file loaded is a jar file that
582 // was wrapped when saved and user has wrap alignment true
583 // as preference setting
584 SwingUtilities.invokeLater(new Runnable()
588 setScrollValues(av.getStartRes(), av.getStartSeq());
595 av.setStartSeq(offy);
597 + (seqPanel.seqCanvas.getHeight() / av.getCharHeight()));
601 if (overviewPanel != null)
603 overviewPanel.setBoxPosition();
606 int scrollX = av.startRes - oldX;
607 int scrollY = av.startSeq - oldY;
609 if (av.getWrapAlignment() || !fastPaint)
615 // Make sure we're not trying to draw a panel
616 // larger than the visible window
617 if (scrollX > av.endRes - av.startRes)
619 scrollX = av.endRes - av.startRes;
621 else if (scrollX < av.startRes - av.endRes)
623 scrollX = av.startRes - av.endRes;
626 if (scrollX != 0 || scrollY != 0)
628 idPanel.idCanvas.fastPaint(scrollY);
629 seqPanel.seqCanvas.fastPaint(scrollX, scrollY);
630 scalePanel.repaint();
632 if (av.getShowAnnotation())
634 annotationPanel.fastPaint(scrollX);
640 public void paintAlignment(boolean updateOverview)
646 jalview.structure.StructureSelectionManager
647 .getStructureSelectionManager().sequenceColoursChanged(this);
649 if (overviewPanel != null)
651 overviewPanel.updateOverviewImage();
662 public void paintComponent(Graphics g)
666 Dimension d = idPanel.idCanvas.getPreferredSize();
667 idPanelHolder.setPreferredSize(d);
668 hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));
671 if (av.getWrapAlignment())
673 int maxwidth = av.alignment.getWidth();
675 if (av.hasHiddenColumns)
677 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
680 int canvasWidth = seqPanel.seqCanvas
681 .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
686 .getWrappedCanvasWidth(seqPanel.seqCanvas
688 vscroll.setMaximum(max);
689 vscroll.setUnitIncrement(1);
690 vscroll.setVisibleAmount(1);
695 setScrollValues(av.getStartRes(), av.getStartSeq());
709 * @return DOCUMENT ME!
711 * @throws PrinterException
714 public int print(Graphics pg, PageFormat pf, int pi)
715 throws PrinterException
717 pg.translate((int) pf.getImageableX(), (int) pf.getImageableY());
719 int pwidth = (int) pf.getImageableWidth();
720 int pheight = (int) pf.getImageableHeight();
722 if (av.getWrapAlignment())
724 return printWrappedAlignment(pg, pwidth, pheight, pi);
728 return printUnwrapped(pg, pwidth, pheight, pi);
744 * @return DOCUMENT ME!
746 * @throws PrinterException
749 public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi)
750 throws PrinterException
752 int idWidth = getVisibleIdWidth();
753 FontMetrics fm = getFontMetrics(av.getFont());
754 int scaleHeight = av.charHeight + fm.getDescent();
756 pg.setColor(Color.white);
757 pg.fillRect(0, 0, pwidth, pheight);
758 pg.setFont(av.getFont());
760 // //////////////////////////////////
761 // / How many sequences and residues can we fit on a printable page?
762 int totalRes = (pwidth - idWidth) / av.getCharWidth();
764 int totalSeq = (int) ((pheight - scaleHeight) / av.getCharHeight()) - 1;
766 int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;
768 // ///////////////////////////
769 // / Only print these sequences and residues on this page
772 // ///////////////////////////
773 // / Only print these sequences and residues on this page
776 // ///////////////////////////
777 // / Only print these sequences and residues on this page
780 // ///////////////////////////
781 // / Only print these sequences and residues on this page
783 startRes = (pi % pagesWide) * totalRes;
784 endRes = (startRes + totalRes) - 1;
786 if (endRes > (av.getAlignment().getWidth() - 1))
788 endRes = av.getAlignment().getWidth() - 1;
791 startSeq = (pi / pagesWide) * totalSeq;
792 endSeq = startSeq + totalSeq;
794 if (endSeq > av.getAlignment().getHeight())
796 endSeq = av.getAlignment().getHeight();
799 int pagesHigh = ((av.alignment.getHeight() / totalSeq) + 1) * pheight;
801 if (av.showAnnotation)
803 pagesHigh += annotationPanel.adjustPanelHeight() + 3;
806 pagesHigh /= pheight;
808 if (pi >= (pagesWide * pagesHigh))
810 return Printable.NO_SUCH_PAGE;
814 pg.translate(idWidth, 0);
815 scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth,
817 pg.translate(-idWidth, scaleHeight);
821 Color currentColor = null;
822 Color currentTextColor = null;
824 pg.setFont(idPanel.idCanvas.idfont);
827 for (int i = startSeq; i < endSeq; i++)
829 seq = av.getAlignment().getSequenceAt(i);
830 if ((av.getSelectionGroup() != null)
831 && av.getSelectionGroup().getSequences(null).contains(seq))
833 currentColor = Color.gray;
834 currentTextColor = Color.black;
838 currentColor = av.getSequenceColour(seq);
839 currentTextColor = Color.black;
842 pg.setColor(currentColor);
843 pg.fillRect(0, (i - startSeq) * av.charHeight, idWidth, av
846 pg.setColor(currentTextColor);
849 if (av.rightAlignIds)
851 fm = pg.getFontMetrics();
853 - fm.stringWidth(seq.getDisplayId(av.getShowJVSuffix()))
857 pg.drawString(seq.getDisplayId(av.getShowJVSuffix()), xPos,
858 (((i - startSeq) * av.charHeight) + av.getCharHeight())
859 - (av.getCharHeight() / 5));
862 pg.setFont(av.getFont());
864 // draw main sequence panel
865 pg.translate(idWidth, 0);
866 seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, 0);
868 if (av.showAnnotation && (endSeq == av.alignment.getHeight()))
870 pg.translate(-idWidth - 3, (endSeq - startSeq) * av.charHeight + 3);
871 alabels.drawComponent((Graphics2D) pg, idWidth);
872 pg.translate(idWidth + 3, 0);
873 annotationPanel.drawComponent((Graphics2D) pg, startRes, endRes + 1);
876 return Printable.PAGE_EXISTS;
891 * @return DOCUMENT ME!
893 * @throws PrinterException
896 public int printWrappedAlignment(Graphics pg, int pwidth, int pheight,
897 int pi) throws PrinterException
900 int annotationHeight = 0;
901 AnnotationLabels labels = null;
902 if (av.showAnnotation)
904 annotationHeight = annotationPanel.adjustPanelHeight();
905 labels = new AnnotationLabels(av);
908 int hgap = av.charHeight;
909 if (av.scaleAboveWrapped)
911 hgap += av.charHeight;
914 int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap
917 int idWidth = getVisibleIdWidth();
919 int maxwidth = av.alignment.getWidth();
920 if (av.hasHiddenColumns)
922 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
925 int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth
928 int totalHeight = cHeight * (maxwidth / resWidth + 1);
930 pg.setColor(Color.white);
931 pg.fillRect(0, 0, pwidth, pheight);
932 pg.setFont(av.getFont());
936 pg.setColor(Color.black);
938 pg.translate(0, -pi * pheight);
940 pg.setClip(0, pi * pheight, pwidth, pheight);
946 for (int i = 0; i < av.alignment.getHeight(); i++)
948 pg.setFont(idPanel.idCanvas.idfont);
949 SequenceI s = av.alignment.getSequenceAt(i);
950 String string = s.getDisplayId(av.getShowJVSuffix());
952 if (av.rightAlignIds)
954 FontMetrics fm = pg.getFontMetrics();
955 xPos = idWidth - fm.stringWidth(string) - 4;
957 pg.drawString(string, xPos,
958 ((i * av.charHeight) + ypos + av.charHeight)
959 - (av.charHeight / 5));
963 pg.translate(-3, ypos
964 + (av.getAlignment().getHeight() * av.charHeight));
966 pg.setFont(av.getFont());
967 labels.drawComponent(pg, idWidth);
968 pg.translate(+3, -ypos
969 - (av.getAlignment().getHeight() * av.charHeight));
973 } while (ypos < totalHeight);
975 pg.translate(idWidth, 0);
977 seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight,
980 if ((pi * pheight) < totalHeight)
982 return Printable.PAGE_EXISTS;
987 return Printable.NO_SUCH_PAGE;
991 int getVisibleIdWidth()
993 return idPanel.getWidth() > 0 ? idPanel.getWidth()
994 : calculateIdWidth().width + 4;
997 void makeAlignmentImage(int type, File file)
999 int maxwidth = av.alignment.getWidth();
1000 if (av.hasHiddenColumns)
1002 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth);
1005 int height = ((av.alignment.getHeight() + 1) * av.charHeight)
1006 + scalePanel.getHeight();
1007 int width = getVisibleIdWidth() + (maxwidth * av.charWidth);
1009 if (av.getWrapAlignment())
1011 height = getWrappedHeight();
1012 if (System.getProperty("java.awt.headless") != null
1013 && System.getProperty("java.awt.headless").equals("true"))
1015 width = alignFrame.getWidth() - vscroll.getPreferredSize().width
1016 - alignFrame.getInsets().left
1017 - alignFrame.getInsets().right;
1021 width = seqPanel.getWidth() + getVisibleIdWidth();
1025 else if (av.getShowAnnotation())
1027 height += annotationPanel.adjustPanelHeight() + 3;
1033 jalview.util.ImageMaker im;
1034 if (type == jalview.util.ImageMaker.PNG)
1036 im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
1037 "Create PNG image from alignment", width, height, file,
1042 im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
1043 "Create EPS file from alignment", width, height, file,
1044 alignFrame.getTitle());
1047 if (av.getWrapAlignment())
1049 if (im.getGraphics() != null)
1051 printWrappedAlignment(im.getGraphics(), width, height, 0);
1057 if (im.getGraphics() != null)
1059 printUnwrapped(im.getGraphics(), width, height, 0);
1063 } catch (OutOfMemoryError err)
1066 System.out.println("########################\n" + "OUT OF MEMORY "
1067 + file + "\n" + "########################");
1068 new OOMWarning("Creating Image for " + file, err);
1069 // System.out.println("Create IMAGE: " + err);
1070 } catch (Exception ex)
1072 ex.printStackTrace();
1079 public void makeEPS(File epsFile)
1081 makeAlignmentImage(jalview.util.ImageMaker.EPS, epsFile);
1087 public void makePNG(File pngFile)
1089 makeAlignmentImage(jalview.util.ImageMaker.PNG, pngFile);
1092 public void makePNGImageMap(File imgMapFile, String imageName)
1094 // /////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS
1095 // ////////////////////////////////////////////
1096 int idWidth = getVisibleIdWidth();
1097 FontMetrics fm = getFontMetrics(av.getFont());
1098 int scaleHeight = av.charHeight + fm.getDescent();
1101 // ////////////////////////////////
1102 if (imgMapFile != null)
1106 int s, sSize = av.alignment.getHeight(), res, alwidth = av.alignment
1107 .getWidth(), g, gSize, f, fSize, sy;
1108 StringBuffer text = new StringBuffer();
1109 PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));
1110 out.println(jalview.io.HTMLOutput.getImageMapHTML());
1111 out.println("<img src=\"" + imageName
1112 + "\" border=\"0\" usemap=\"#Map\" >"
1113 + "<map name=\"Map\">");
1115 for (s = 0; s < sSize; s++)
1117 sy = s * av.charHeight + scaleHeight;
1119 SequenceI seq = av.alignment.getSequenceAt(s);
1120 SequenceFeature[] features = seq.getDatasetSequence()
1121 .getSequenceFeatures();
1122 SequenceGroup[] groups = av.alignment.findAllGroups(seq);
1123 for (res = 0; res < alwidth; res++)
1125 text = new StringBuffer();
1127 if (av.alignment.isNucleotide())
1129 obj = ResidueProperties.nucleotideName.get(seq.getCharAt(res)
1134 obj = ResidueProperties.aa2Triplet.get(seq.getCharAt(res)
1143 String triplet = obj.toString();
1144 int alIndex = seq.findPosition(res);
1145 gSize = groups.length;
1146 for (g = 0; g < gSize; g++)
1148 if (text.length() < 1)
1150 text.append("<area shape=\"rect\" coords=\""
1151 + (idWidth + res * av.charWidth) + "," + sy + ","
1152 + (idWidth + (res + 1) * av.charWidth) + ","
1153 + (av.charHeight + sy) + "\""
1154 + " onMouseOver=\"toolTip('" + alIndex + " "
1158 if (groups[g].getStartRes() < res
1159 && groups[g].getEndRes() > res)
1161 text.append("<br><em>" + groups[g].getName() + "</em>");
1165 if (features != null)
1167 if (text.length() < 1)
1169 text.append("<area shape=\"rect\" coords=\""
1170 + (idWidth + res * av.charWidth) + "," + sy + ","
1171 + (idWidth + (res + 1) * av.charWidth) + ","
1172 + (av.charHeight + sy) + "\""
1173 + " onMouseOver=\"toolTip('" + alIndex + " "
1176 fSize = features.length;
1177 for (f = 0; f < fSize; f++)
1180 if ((features[f].getBegin() <= seq.findPosition(res))
1181 && (features[f].getEnd() >= seq.findPosition(res)))
1183 if (features[f].getType().equals("disulfide bond"))
1185 if (features[f].getBegin() == seq.findPosition(res)
1186 || features[f].getEnd() == seq
1189 text.append("<br>disulfide bond "
1190 + features[f].getBegin() + ":"
1191 + features[f].getEnd());
1196 text.append("<br>");
1197 text.append(features[f].getType());
1198 if (features[f].getDescription() != null
1199 && !features[f].getType().equals(
1200 features[f].getDescription()))
1202 text.append(" " + features[f].getDescription());
1205 if (features[f].getValue("status") != null)
1207 text.append(" (" + features[f].getValue("status")
1215 if (text.length() > 1)
1217 text.append("')\"; onMouseOut=\"toolTip()\"; href=\"#\">");
1218 out.println(text.toString());
1222 out.println("</map></body></html>");
1225 } catch (Exception ex)
1227 ex.printStackTrace();
1229 } // /////////END OF IMAGE MAP
1233 int getWrappedHeight()
1235 int seqPanelWidth = seqPanel.seqCanvas.getWidth();
1237 if (System.getProperty("java.awt.headless") != null
1238 && System.getProperty("java.awt.headless").equals("true"))
1240 seqPanelWidth = alignFrame.getWidth() - getVisibleIdWidth()
1241 - vscroll.getPreferredSize().width
1242 - alignFrame.getInsets().left - alignFrame.getInsets().right;
1245 int chunkWidth = seqPanel.seqCanvas
1246 .getWrappedCanvasWidth(seqPanelWidth);
1248 int hgap = av.charHeight;
1249 if (av.scaleAboveWrapped)
1251 hgap += av.charHeight;
1254 int annotationHeight = 0;
1255 if (av.showAnnotation)
1257 annotationHeight = annotationPanel.adjustPanelHeight();
1260 int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap
1263 int maxwidth = av.alignment.getWidth();
1264 if (av.hasHiddenColumns)
1266 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
1269 int height = ((maxwidth / chunkWidth) + 1) * cHeight;
1275 * close the panel - deregisters all listeners and nulls any references to alignment data.
1277 public void closePanel()
1279 jalview.structure.StructureSelectionManager ssm =
1280 jalview.structure.StructureSelectionManager
1281 .getStructureSelectionManager();
1282 ssm.removeStructureViewerListener(seqPanel, null);
1283 ssm.removeSelectionListener(seqPanel);
1284 PaintRefresher.RemoveComponent(seqPanel.seqCanvas);
1285 PaintRefresher.RemoveComponent(idPanel.idCanvas);
1286 PaintRefresher.RemoveComponent(this);
1288 av.alignment = null;
1291 if (Cache.log.isDebugEnabled()) {
1292 Cache.log.warn("Closing alignment panel which is already closed.");