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 // TODO: properly locate search results in view when large numbers of hidden columns exist before highlighted region
252 // do we need to scroll the panel?
253 // TODO: tons of nullpointereexceptions raised here.
254 if (results != null && results.getSize()>0 && av!=null && av.alignment!=null)
256 int seqIndex = av.alignment.findIndex(results);
261 SequenceI seq = av.alignment.getSequenceAt(seqIndex);
263 int [] r = results.getResults(seq, 0, av.alignment.getWidth()); // results.getResults(seq, seq.getStart(), seq.getEnd());
274 if (end==seq.getEnd())
278 if (!av.wrapAlignment)
280 if ((av.getStartRes() >= start)
281 || (av.getEndRes() <= end))
283 setScrollValues(start-1, seqIndex);
284 } else if ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex))
286 setScrollValues(av.getStartRes(), seqIndex);
291 scrollToWrappedVisible(start);
294 if (!redrawOverview && overviewPanel!=null)
296 overviewPanel.setBoxPosition();
298 paintAlignment(!redrawOverview);
302 void scrollToWrappedVisible(int res)
304 int cwidth = seqPanel.seqCanvas
305 .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
306 if (res < av.getStartRes() || res >= (av.getStartRes()+cwidth))
308 vscroll.setValue((res / cwidth));
309 av.startRes = vscroll.getValue() * cwidth;
317 * @return DOCUMENT ME!
319 public OverviewPanel getOverviewPanel()
321 return overviewPanel;
330 public void setOverviewPanel(OverviewPanel op)
341 public void setAnnotationVisible(boolean b)
343 if (!av.wrapAlignment)
345 annotationSpaceFillerHolder.setVisible(b);
346 annotationScroller.setVisible(b);
351 public void adjustAnnotationHeight()
353 // TODO: display vertical annotation scrollbar if necessary
354 // this is called after loading new annotation onto alignment
355 if (alignFrame.getHeight() == 0)
357 System.out.println("NEEDS FIXING");
360 int height = annotationPanel.adjustPanelHeight();
362 if (hscroll.isVisible())
364 height += hscroll.getPreferredSize().height;
366 if (height > alignFrame.getHeight() / 2)
368 height = alignFrame.getHeight() / 2;
373 annotationScroller.setPreferredSize(new Dimension(annotationScroller
374 .getWidth(), height));
376 annotationSpaceFillerHolder.setPreferredSize(new Dimension(
377 annotationSpaceFillerHolder.getWidth(), height));
378 annotationScroller.validate();// repaint();
388 public void setWrapAlignment(boolean wrap)
391 scalePanelHolder.setVisible(!wrap);
392 hscroll.setVisible(!wrap);
393 idwidthAdjuster.setVisible(!wrap);
397 annotationScroller.setVisible(false);
398 annotationSpaceFillerHolder.setVisible(false);
400 else if (av.showAnnotation)
402 annotationScroller.setVisible(true);
403 annotationSpaceFillerHolder.setVisible(true);
406 idSpaceFillerPanel1.setVisible(!wrap);
411 // return value is true if the scroll is valid
412 public boolean scrollUp(boolean up)
416 if (vscroll.getValue() < 1)
422 vscroll.setValue(vscroll.getValue() - 1);
426 if ((vextent + vscroll.getValue()) >= av.getAlignment().getHeight())
432 vscroll.setValue(vscroll.getValue() + 1);
446 * @return DOCUMENT ME!
448 public boolean scrollRight(boolean right)
452 if (hscroll.getValue() < 1)
458 hscroll.setValue(hscroll.getValue() - 1);
462 if ((hextent + hscroll.getValue()) >= av.getAlignment().getWidth())
468 hscroll.setValue(hscroll.getValue() + 1);
484 public void setScrollValues(int x, int y)
486 if (av==null || av.alignment==null)
490 int width = av.alignment.getWidth();
491 int height = av.alignment.getHeight();
493 if (av.hasHiddenColumns)
495 width = av.getColumnSelection().findColumnPosition(width);
498 av.setEndRes((x + (seqPanel.seqCanvas.getWidth() / av.charWidth)) - 1);
500 hextent = seqPanel.seqCanvas.getWidth() / av.charWidth;
501 vextent = seqPanel.seqCanvas.getHeight() / av.charHeight;
508 if (vextent > height)
513 if ((hextent + x) > width)
518 if ((vextent + y) > height)
520 y = height - vextent;
533 hscroll.setValues(x, hextent, 0, width);
534 vscroll.setValues(y, vextent, 0, height);
543 public void adjustmentValueChanged(AdjustmentEvent evt)
546 int oldX = av.getStartRes();
547 int oldY = av.getStartSeq();
549 if (evt.getSource() == hscroll)
551 int x = hscroll.getValue();
554 .setEndRes((x + (seqPanel.seqCanvas.getWidth() / av
555 .getCharWidth())) - 1);
558 if (evt.getSource() == vscroll)
560 int offy = vscroll.getValue();
562 if (av.getWrapAlignment())
566 int rowSize = seqPanel.seqCanvas
567 .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
568 av.setStartRes(offy * rowSize);
569 av.setEndRes((offy + 1) * rowSize);
573 // This is only called if file loaded is a jar file that
574 // was wrapped when saved and user has wrap alignment true
575 // as preference setting
576 SwingUtilities.invokeLater(new Runnable()
580 setScrollValues(av.getStartRes(), av.getStartSeq());
587 av.setStartSeq(offy);
589 + (seqPanel.seqCanvas.getHeight() / av.getCharHeight()));
593 if (overviewPanel != null)
595 overviewPanel.setBoxPosition();
598 int scrollX = av.startRes - oldX;
599 int scrollY = av.startSeq - oldY;
601 if (av.getWrapAlignment() || !fastPaint)
607 // Make sure we're not trying to draw a panel
608 // larger than the visible window
609 if (scrollX > av.endRes - av.startRes)
611 scrollX = av.endRes - av.startRes;
613 else if (scrollX < av.startRes - av.endRes)
615 scrollX = av.startRes - av.endRes;
618 if (scrollX != 0 || scrollY != 0)
620 idPanel.idCanvas.fastPaint(scrollY);
621 seqPanel.seqCanvas.fastPaint(scrollX, scrollY);
622 scalePanel.repaint();
624 if (av.getShowAnnotation())
626 annotationPanel.fastPaint(scrollX);
632 public void paintAlignment(boolean updateOverview)
638 jalview.structure.StructureSelectionManager
639 .getStructureSelectionManager().sequenceColoursChanged(this);
641 if (overviewPanel != null)
643 overviewPanel.updateOverviewImage();
654 public void paintComponent(Graphics g)
658 Dimension d = idPanel.idCanvas.getPreferredSize();
659 idPanelHolder.setPreferredSize(d);
660 hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));
663 if (av.getWrapAlignment())
665 int maxwidth = av.alignment.getWidth();
667 if (av.hasHiddenColumns)
669 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
672 int canvasWidth = seqPanel.seqCanvas
673 .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
678 .getWrappedCanvasWidth(seqPanel.seqCanvas
680 vscroll.setMaximum(max);
681 vscroll.setUnitIncrement(1);
682 vscroll.setVisibleAmount(1);
687 setScrollValues(av.getStartRes(), av.getStartSeq());
701 * @return DOCUMENT ME!
703 * @throws PrinterException
706 public int print(Graphics pg, PageFormat pf, int pi)
707 throws PrinterException
709 pg.translate((int) pf.getImageableX(), (int) pf.getImageableY());
711 int pwidth = (int) pf.getImageableWidth();
712 int pheight = (int) pf.getImageableHeight();
714 if (av.getWrapAlignment())
716 return printWrappedAlignment(pg, pwidth, pheight, pi);
720 return printUnwrapped(pg, pwidth, pheight, pi);
736 * @return DOCUMENT ME!
738 * @throws PrinterException
741 public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi)
742 throws PrinterException
744 int idWidth = getVisibleIdWidth();
745 FontMetrics fm = getFontMetrics(av.getFont());
746 int scaleHeight = av.charHeight + fm.getDescent();
748 pg.setColor(Color.white);
749 pg.fillRect(0, 0, pwidth, pheight);
750 pg.setFont(av.getFont());
752 // //////////////////////////////////
753 // / How many sequences and residues can we fit on a printable page?
754 int totalRes = (pwidth - idWidth) / av.getCharWidth();
756 int totalSeq = (int) ((pheight - scaleHeight) / av.getCharHeight()) - 1;
758 int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;
760 // ///////////////////////////
761 // / Only print these sequences and residues on this page
764 // ///////////////////////////
765 // / Only print these sequences and residues on this page
768 // ///////////////////////////
769 // / Only print these sequences and residues on this page
772 // ///////////////////////////
773 // / Only print these sequences and residues on this page
775 startRes = (pi % pagesWide) * totalRes;
776 endRes = (startRes + totalRes) - 1;
778 if (endRes > (av.getAlignment().getWidth() - 1))
780 endRes = av.getAlignment().getWidth() - 1;
783 startSeq = (pi / pagesWide) * totalSeq;
784 endSeq = startSeq + totalSeq;
786 if (endSeq > av.getAlignment().getHeight())
788 endSeq = av.getAlignment().getHeight();
791 int pagesHigh = ((av.alignment.getHeight() / totalSeq) + 1) * pheight;
793 if (av.showAnnotation)
795 pagesHigh += annotationPanel.adjustPanelHeight() + 3;
798 pagesHigh /= pheight;
800 if (pi >= (pagesWide * pagesHigh))
802 return Printable.NO_SUCH_PAGE;
806 pg.translate(idWidth, 0);
807 scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth,
809 pg.translate(-idWidth, scaleHeight);
813 Color currentColor = null;
814 Color currentTextColor = null;
816 pg.setFont(idPanel.idCanvas.idfont);
819 for (int i = startSeq; i < endSeq; i++)
821 seq = av.getAlignment().getSequenceAt(i);
822 if ((av.getSelectionGroup() != null)
823 && av.getSelectionGroup().getSequences(null).contains(seq))
825 currentColor = Color.gray;
826 currentTextColor = Color.black;
830 currentColor = av.getSequenceColour(seq);
831 currentTextColor = Color.black;
834 pg.setColor(currentColor);
835 pg.fillRect(0, (i - startSeq) * av.charHeight, idWidth, av
838 pg.setColor(currentTextColor);
841 if (av.rightAlignIds)
843 fm = pg.getFontMetrics();
845 - fm.stringWidth(seq.getDisplayId(av.getShowJVSuffix()))
849 pg.drawString(seq.getDisplayId(av.getShowJVSuffix()), xPos,
850 (((i - startSeq) * av.charHeight) + av.getCharHeight())
851 - (av.getCharHeight() / 5));
854 pg.setFont(av.getFont());
856 // draw main sequence panel
857 pg.translate(idWidth, 0);
858 seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, 0);
860 if (av.showAnnotation && (endSeq == av.alignment.getHeight()))
862 pg.translate(-idWidth - 3, (endSeq - startSeq) * av.charHeight + 3);
863 alabels.drawComponent((Graphics2D) pg, idWidth);
864 pg.translate(idWidth + 3, 0);
865 annotationPanel.drawComponent((Graphics2D) pg, startRes, endRes + 1);
868 return Printable.PAGE_EXISTS;
883 * @return DOCUMENT ME!
885 * @throws PrinterException
888 public int printWrappedAlignment(Graphics pg, int pwidth, int pheight,
889 int pi) throws PrinterException
892 int annotationHeight = 0;
893 AnnotationLabels labels = null;
894 if (av.showAnnotation)
896 annotationHeight = annotationPanel.adjustPanelHeight();
897 labels = new AnnotationLabels(av);
900 int hgap = av.charHeight;
901 if (av.scaleAboveWrapped)
903 hgap += av.charHeight;
906 int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap
909 int idWidth = getVisibleIdWidth();
911 int maxwidth = av.alignment.getWidth();
912 if (av.hasHiddenColumns)
914 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
917 int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth
920 int totalHeight = cHeight * (maxwidth / resWidth + 1);
922 pg.setColor(Color.white);
923 pg.fillRect(0, 0, pwidth, pheight);
924 pg.setFont(av.getFont());
928 pg.setColor(Color.black);
930 pg.translate(0, -pi * pheight);
932 pg.setClip(0, pi * pheight, pwidth, pheight);
938 for (int i = 0; i < av.alignment.getHeight(); i++)
940 pg.setFont(idPanel.idCanvas.idfont);
941 SequenceI s = av.alignment.getSequenceAt(i);
942 String string = s.getDisplayId(av.getShowJVSuffix());
944 if (av.rightAlignIds)
946 FontMetrics fm = pg.getFontMetrics();
947 xPos = idWidth - fm.stringWidth(string) - 4;
949 pg.drawString(string, xPos,
950 ((i * av.charHeight) + ypos + av.charHeight)
951 - (av.charHeight / 5));
955 pg.translate(-3, ypos
956 + (av.getAlignment().getHeight() * av.charHeight));
958 pg.setFont(av.getFont());
959 labels.drawComponent(pg, idWidth);
960 pg.translate(+3, -ypos
961 - (av.getAlignment().getHeight() * av.charHeight));
965 } while (ypos < totalHeight);
967 pg.translate(idWidth, 0);
969 seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight,
972 if ((pi * pheight) < totalHeight)
974 return Printable.PAGE_EXISTS;
979 return Printable.NO_SUCH_PAGE;
983 int getVisibleIdWidth()
985 return idPanel.getWidth() > 0 ? idPanel.getWidth()
986 : calculateIdWidth().width + 4;
989 void makeAlignmentImage(int type, File file)
991 int maxwidth = av.alignment.getWidth();
992 if (av.hasHiddenColumns)
994 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth);
997 int height = ((av.alignment.getHeight() + 1) * av.charHeight)
998 + scalePanel.getHeight();
999 int width = getVisibleIdWidth() + (maxwidth * av.charWidth);
1001 if (av.getWrapAlignment())
1003 height = getWrappedHeight();
1004 if (System.getProperty("java.awt.headless") != null
1005 && System.getProperty("java.awt.headless").equals("true"))
1007 width = alignFrame.getWidth() - vscroll.getPreferredSize().width
1008 - alignFrame.getInsets().left
1009 - alignFrame.getInsets().right;
1013 width = seqPanel.getWidth() + getVisibleIdWidth();
1017 else if (av.getShowAnnotation())
1019 height += annotationPanel.adjustPanelHeight() + 3;
1025 jalview.util.ImageMaker im;
1026 if (type == jalview.util.ImageMaker.PNG)
1028 im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
1029 "Create PNG image from alignment", width, height, file,
1034 im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
1035 "Create EPS file from alignment", width, height, file,
1036 alignFrame.getTitle());
1039 if (av.getWrapAlignment())
1041 if (im.getGraphics() != null)
1043 printWrappedAlignment(im.getGraphics(), width, height, 0);
1049 if (im.getGraphics() != null)
1051 printUnwrapped(im.getGraphics(), width, height, 0);
1055 } catch (OutOfMemoryError err)
1058 System.out.println("########################\n" + "OUT OF MEMORY "
1059 + file + "\n" + "########################");
1060 new OOMWarning("Creating Image for " + file, err);
1061 // System.out.println("Create IMAGE: " + err);
1062 } catch (Exception ex)
1064 ex.printStackTrace();
1071 public void makeEPS(File epsFile)
1073 makeAlignmentImage(jalview.util.ImageMaker.EPS, epsFile);
1079 public void makePNG(File pngFile)
1081 makeAlignmentImage(jalview.util.ImageMaker.PNG, pngFile);
1084 public void makePNGImageMap(File imgMapFile, String imageName)
1086 // /////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS
1087 // ////////////////////////////////////////////
1088 int idWidth = getVisibleIdWidth();
1089 FontMetrics fm = getFontMetrics(av.getFont());
1090 int scaleHeight = av.charHeight + fm.getDescent();
1093 // ////////////////////////////////
1094 if (imgMapFile != null)
1098 int s, sSize = av.alignment.getHeight(), res, alwidth = av.alignment
1099 .getWidth(), g, gSize, f, fSize, sy;
1100 StringBuffer text = new StringBuffer();
1101 PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));
1102 out.println(jalview.io.HTMLOutput.getImageMapHTML());
1103 out.println("<img src=\"" + imageName
1104 + "\" border=\"0\" usemap=\"#Map\" >"
1105 + "<map name=\"Map\">");
1107 for (s = 0; s < sSize; s++)
1109 sy = s * av.charHeight + scaleHeight;
1111 SequenceI seq = av.alignment.getSequenceAt(s);
1112 SequenceFeature[] features = seq.getDatasetSequence()
1113 .getSequenceFeatures();
1114 SequenceGroup[] groups = av.alignment.findAllGroups(seq);
1115 for (res = 0; res < alwidth; res++)
1117 text = new StringBuffer();
1119 if (av.alignment.isNucleotide())
1121 obj = ResidueProperties.nucleotideName.get(seq.getCharAt(res)
1126 obj = ResidueProperties.aa2Triplet.get(seq.getCharAt(res)
1135 String triplet = obj.toString();
1136 int alIndex = seq.findPosition(res);
1137 gSize = groups.length;
1138 for (g = 0; g < gSize; g++)
1140 if (text.length() < 1)
1142 text.append("<area shape=\"rect\" coords=\""
1143 + (idWidth + res * av.charWidth) + "," + sy + ","
1144 + (idWidth + (res + 1) * av.charWidth) + ","
1145 + (av.charHeight + sy) + "\""
1146 + " onMouseOver=\"toolTip('" + alIndex + " "
1150 if (groups[g].getStartRes() < res
1151 && groups[g].getEndRes() > res)
1153 text.append("<br><em>" + groups[g].getName() + "</em>");
1157 if (features != null)
1159 if (text.length() < 1)
1161 text.append("<area shape=\"rect\" coords=\""
1162 + (idWidth + res * av.charWidth) + "," + sy + ","
1163 + (idWidth + (res + 1) * av.charWidth) + ","
1164 + (av.charHeight + sy) + "\""
1165 + " onMouseOver=\"toolTip('" + alIndex + " "
1168 fSize = features.length;
1169 for (f = 0; f < fSize; f++)
1172 if ((features[f].getBegin() <= seq.findPosition(res))
1173 && (features[f].getEnd() >= seq.findPosition(res)))
1175 if (features[f].getType().equals("disulfide bond"))
1177 if (features[f].getBegin() == seq.findPosition(res)
1178 || features[f].getEnd() == seq
1181 text.append("<br>disulfide bond "
1182 + features[f].getBegin() + ":"
1183 + features[f].getEnd());
1188 text.append("<br>");
1189 text.append(features[f].getType());
1190 if (features[f].getDescription() != null
1191 && !features[f].getType().equals(
1192 features[f].getDescription()))
1194 text.append(" " + features[f].getDescription());
1197 if (features[f].getValue("status") != null)
1199 text.append(" (" + features[f].getValue("status")
1207 if (text.length() > 1)
1209 text.append("')\"; onMouseOut=\"toolTip()\"; href=\"#\">");
1210 out.println(text.toString());
1214 out.println("</map></body></html>");
1217 } catch (Exception ex)
1219 ex.printStackTrace();
1221 } // /////////END OF IMAGE MAP
1225 int getWrappedHeight()
1227 int seqPanelWidth = seqPanel.seqCanvas.getWidth();
1229 if (System.getProperty("java.awt.headless") != null
1230 && System.getProperty("java.awt.headless").equals("true"))
1232 seqPanelWidth = alignFrame.getWidth() - getVisibleIdWidth()
1233 - vscroll.getPreferredSize().width
1234 - alignFrame.getInsets().left - alignFrame.getInsets().right;
1237 int chunkWidth = seqPanel.seqCanvas
1238 .getWrappedCanvasWidth(seqPanelWidth);
1240 int hgap = av.charHeight;
1241 if (av.scaleAboveWrapped)
1243 hgap += av.charHeight;
1246 int annotationHeight = 0;
1247 if (av.showAnnotation)
1249 annotationHeight = annotationPanel.adjustPanelHeight();
1252 int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap
1255 int maxwidth = av.alignment.getWidth();
1256 if (av.hasHiddenColumns)
1258 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
1261 int height = ((maxwidth / chunkWidth) + 1) * cHeight;
1267 * close the panel - deregisters all listeners and nulls any references to alignment data.
1269 public void closePanel()
1271 jalview.structure.StructureSelectionManager ssm =
1272 jalview.structure.StructureSelectionManager
1273 .getStructureSelectionManager();
1274 ssm.removeStructureViewerListener(seqPanel, null);
1275 ssm.removeSelectionListener(seqPanel);
1276 PaintRefresher.RemoveComponent(seqPanel.seqCanvas);
1277 PaintRefresher.RemoveComponent(idPanel.idCanvas);
1278 PaintRefresher.RemoveComponent(this);
1280 av.alignment = null;
1283 if (Cache.log.isDebugEnabled()) {
1284 Cache.log.warn("Closing alignment panel which is already closed.");