Merge branch 'features/JAL-845splitPaneMergeDevelop' into merge_JAL-845_JAL-1640
[jalview.git] / src / jalview / gui / AlignmentPanel.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3  * Copyright (C) 2014 The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.gui;
22
23 import jalview.analysis.AnnotationSorter;
24 import jalview.api.AlignViewportI;
25 import jalview.api.AlignmentViewPanel;
26 import jalview.bin.Cache;
27 import jalview.datamodel.AlignmentI;
28 import jalview.datamodel.SearchResults;
29 import jalview.datamodel.SequenceFeature;
30 import jalview.datamodel.SequenceGroup;
31 import jalview.datamodel.SequenceI;
32 import jalview.jbgui.GAlignmentPanel;
33 import jalview.math.AlignmentDimension;
34 import jalview.schemes.ResidueProperties;
35 import jalview.structure.StructureSelectionManager;
36 import jalview.util.MessageManager;
37
38 import java.awt.BorderLayout;
39 import java.awt.Color;
40 import java.awt.Container;
41 import java.awt.Dimension;
42 import java.awt.Font;
43 import java.awt.FontMetrics;
44 import java.awt.Graphics;
45 import java.awt.event.AdjustmentEvent;
46 import java.awt.event.AdjustmentListener;
47 import java.awt.print.PageFormat;
48 import java.awt.print.Printable;
49 import java.awt.print.PrinterException;
50 import java.beans.PropertyChangeEvent;
51 import java.beans.PropertyChangeListener;
52 import java.io.File;
53 import java.io.FileWriter;
54 import java.io.PrintWriter;
55
56 import javax.swing.SwingUtilities;
57
58 /**
59  * DOCUMENT ME!
60  * 
61  * @author $author$
62  * @version $Revision: 1.161 $
63  */
64 public class AlignmentPanel extends GAlignmentPanel implements
65         AdjustmentListener, Printable, AlignmentViewPanel
66 {
67   public AlignViewport av;
68
69   OverviewPanel overviewPanel;
70
71   private SeqPanel seqPanel;
72
73   private IdPanel idPanel;
74
75   private boolean headless;
76   IdwidthAdjuster idwidthAdjuster;
77
78   /** DOCUMENT ME!! */
79   public AlignFrame alignFrame;
80
81   private ScalePanel scalePanel;
82
83   private AnnotationPanel annotationPanel;
84
85   private AnnotationLabels alabels;
86
87   // this value is set false when selection area being dragged
88   boolean fastPaint = true;
89
90   int hextent = 0;
91
92   int vextent = 0;
93
94   /**
95    * Creates a new AlignmentPanel object.
96    * 
97    * @param af
98    * @param av
99    */
100   public AlignmentPanel(AlignFrame af, final AlignViewport av)
101   {
102     alignFrame = af;
103     this.av = av;
104     setSeqPanel(new SeqPanel(av, this));
105     setIdPanel(new IdPanel(av, this));
106
107     setScalePanel(new ScalePanel(av, this));
108
109     idPanelHolder.add(getIdPanel(), BorderLayout.CENTER);
110     idwidthAdjuster = new IdwidthAdjuster(this);
111     idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
112
113     setAnnotationPanel(new AnnotationPanel(this));
114     setAlabels(new AnnotationLabels(this));
115
116     annotationScroller.setViewportView(getAnnotationPanel());
117     annotationSpaceFillerHolder.add(getAlabels(), BorderLayout.CENTER);
118
119     scalePanelHolder.add(getScalePanel(), BorderLayout.CENTER);
120     seqPanelHolder.add(getSeqPanel(), BorderLayout.CENTER);
121
122     setScrollValues(0, 0);
123
124     hscroll.addAdjustmentListener(this);
125     vscroll.addAdjustmentListener(this);
126
127     final AlignmentPanel ap = this;
128     av.addPropertyChangeListener(new PropertyChangeListener()
129     {
130       public void propertyChange(PropertyChangeEvent evt)
131       {
132         if (evt.getPropertyName().equals("alignment"))
133         {
134           PaintRefresher.Refresh(ap, av.getSequenceSetId(), true, true);
135           alignmentChanged();
136         }
137       }
138     });
139     fontChanged();
140     adjustAnnotationHeight();
141     updateLayout();
142   }
143
144   @Override
145   public AlignViewportI getAlignViewport()
146   {
147     return av;
148   }
149   public void alignmentChanged()
150   {
151     av.alignmentChanged(this);
152
153     alignFrame.updateEditMenuBar();
154
155     paintAlignment(true);
156
157   }
158
159   /**
160    * DOCUMENT ME!
161    */
162   public void fontChanged()
163   {
164     // set idCanvas bufferedImage to null
165     // to prevent drawing old image
166     FontMetrics fm = getFontMetrics(av.getFont());
167
168     scalePanelHolder.setPreferredSize(new Dimension(10, av.getCharHeight()
169             + fm.getDescent()));
170     idSpaceFillerPanel1.setPreferredSize(new Dimension(10, av
171             .getCharHeight()
172             + fm.getDescent()));
173
174     getIdPanel().getIdCanvas().gg = null;
175     getSeqPanel().seqCanvas.img = null;
176     getAnnotationPanel().adjustPanelHeight();
177
178     Dimension d = calculateIdWidth();
179
180     d.setSize(d.width + 4, d.height);
181     getIdPanel().getIdCanvas().setPreferredSize(d);
182     hscrollFillerPanel.setPreferredSize(d);
183
184     if (overviewPanel != null)
185     {
186       overviewPanel.setBoxPosition();
187     }
188
189     repaint();
190   }
191
192   /**
193    * Calculate the width of the alignment labels based on the displayed names
194    * and any bounds on label width set in preferences.
195    * 
196    * @return Dimension giving the maximum width of the alignment label panel
197    *         that should be used.
198    */
199   public Dimension calculateIdWidth()
200   {
201     // calculate sensible default width when no preference is available
202     Dimension r = null;
203     if (av.getIdWidth() < 0)
204     {
205       int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300);
206       int maxwidth = Math.max(20, Math.min(afwidth - 200, 2 * afwidth / 3));
207       r = calculateIdWidth(maxwidth);
208       av.setIdWidth(r.width);
209     }
210     else
211     {
212       r = new Dimension();
213       r.width = av.getIdWidth();
214       r.height = 0;
215     }
216     return r;
217   }
218
219   /**
220    * Calculate the width of the alignment labels based on the displayed names
221    * and any bounds on label width set in preferences.
222    * 
223    * @param maxwidth
224    *          -1 or maximum width allowed for IdWidth
225    * @return Dimension giving the maximum width of the alignment label panel
226    *         that should be used.
227    */
228   public Dimension calculateIdWidth(int maxwidth)
229   {
230     Container c = new Container();
231
232     FontMetrics fm = c.getFontMetrics(new Font(av.font.getName(),
233             Font.ITALIC, av.font.getSize()));
234
235     AlignmentI al = av.getAlignment();
236     int i = 0;
237     int idWidth = 0;
238     String id;
239
240     while ((i < al.getHeight()) && (al.getSequenceAt(i) != null))
241     {
242       SequenceI s = al.getSequenceAt(i);
243
244       id = s.getDisplayId(av.getShowJVSuffix());
245
246       if (fm.stringWidth(id) > idWidth)
247       {
248         idWidth = fm.stringWidth(id);
249       }
250
251       i++;
252     }
253
254     // Also check annotation label widths
255     i = 0;
256
257     if (al.getAlignmentAnnotation() != null)
258     {
259       fm = c.getFontMetrics(getAlabels().getFont());
260
261       while (i < al.getAlignmentAnnotation().length)
262       {
263         String label = al.getAlignmentAnnotation()[i].label;
264
265         if (fm.stringWidth(label) > idWidth)
266         {
267           idWidth = fm.stringWidth(label);
268         }
269
270         i++;
271       }
272     }
273
274     return new Dimension(maxwidth < 0 ? idWidth : Math.min(maxwidth,
275             idWidth), 12);
276   }
277
278   /**
279    * Highlight the given results on the alignment.
280    * 
281    */
282   public void highlightSearchResults(SearchResults results)
283   {
284     scrollToPosition(results);
285     getSeqPanel().seqCanvas.highlightSearchResults(results);
286   }
287
288   /**
289    * scroll the view to show the position of the highlighted region in results
290    * (if any) and redraw the overview
291    * 
292    * @param results
293    */
294   public boolean scrollToPosition(SearchResults results)
295   {
296     return scrollToPosition(results, true);
297   }
298
299   /**
300    * scroll the view to show the position of the highlighted region in results
301    * (if any)
302    * 
303    * @param results
304    * @param redrawOverview
305    *          - when set, the overview will be recalculated (takes longer)
306    * @return false if results were not found
307    */
308   public boolean scrollToPosition(SearchResults results,
309           boolean redrawOverview)
310   {
311     int startv, endv, starts, ends, width;
312     // TODO: properly locate search results in view when large numbers of hidden
313     // columns exist before highlighted region
314     // do we need to scroll the panel?
315     // TODO: tons of nullpointereexceptions raised here.
316     if (results != null && results.getSize() > 0 && av != null
317             && av.getAlignment() != null)
318     {
319       int seqIndex = av.getAlignment().findIndex(results);
320       if (seqIndex == -1)
321       {
322         return false;
323       }
324       SequenceI seq = av.getAlignment().getSequenceAt(seqIndex);
325
326       int[] r = results.getResults(seq, 0, av.getAlignment().getWidth());
327       if (r == null)
328       {
329         return false;
330       }
331       int start = r[0];
332       int end = r[1];
333       // System.err.println("Seq : "+seqIndex+" Scroll to "+start+","+end); //
334       // DEBUG
335       if (start < 0)
336       {
337         return false;
338       }
339       if (end == seq.getEnd())
340       {
341         return false;
342       }
343       if (av.hasHiddenColumns())
344       {
345         start = av.getColumnSelection().findColumnPosition(start);
346         end = av.getColumnSelection().findColumnPosition(end);
347         if (start == end)
348         {
349           if (!av.getColumnSelection().isVisible(r[0]))
350           {
351             // don't scroll - position isn't visible
352             return false;
353           }
354         }
355       }
356       if (!av.getWrapAlignment())
357       {
358         if ((startv = av.getStartRes()) >= start)
359         {
360           setScrollValues(start - 1, seqIndex);
361         }
362         else if ((endv = av.getEndRes()) <= end)
363         {
364           setScrollValues(startv + 1 + end - endv, seqIndex);
365         }
366         else if ((starts = av.getStartSeq()) > seqIndex)
367         {
368           setScrollValues(av.getStartRes(), seqIndex);
369         }
370         else if ((ends = av.getEndSeq()) <= seqIndex)
371         {
372           setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1);
373         }
374       }
375       else
376       {
377         scrollToWrappedVisible(start);
378       }
379     }
380     if (redrawOverview && overviewPanel != null)
381     {
382       overviewPanel.setBoxPosition();
383     }
384     paintAlignment(redrawOverview);
385     return true;
386   }
387
388   void scrollToWrappedVisible(int res)
389   {
390     int cwidth = getSeqPanel().seqCanvas
391             .getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
392     if (res < av.getStartRes() || res >= (av.getStartRes() + cwidth))
393     {
394       vscroll.setValue((res / cwidth));
395       av.startRes = vscroll.getValue() * cwidth;
396     }
397
398   }
399
400   /**
401    * DOCUMENT ME!
402    * 
403    * @return DOCUMENT ME!
404    */
405   public OverviewPanel getOverviewPanel()
406   {
407     return overviewPanel;
408   }
409
410   /**
411    * DOCUMENT ME!
412    * 
413    * @param op
414    *          DOCUMENT ME!
415    */
416   public void setOverviewPanel(OverviewPanel op)
417   {
418     overviewPanel = op;
419   }
420
421   /**
422    * 
423    * @param b
424    *          Hide or show annotation panel
425    * 
426    */
427   public void setAnnotationVisible(boolean b)
428   {
429     if (!av.getWrapAlignment())
430     {
431       annotationSpaceFillerHolder.setVisible(b);
432       annotationScroller.setVisible(b);
433     }
434     repaint();
435   }
436
437   /**
438    * automatically adjust annotation panel height for new annotation whilst
439    * ensuring the alignment is still visible.
440    */
441   public void adjustAnnotationHeight()
442   {
443     // TODO: display vertical annotation scrollbar if necessary
444     // this is called after loading new annotation onto alignment
445     if (alignFrame.getHeight() == 0)
446     {
447       System.out.println("NEEDS FIXING");
448     }
449     validateAnnotationDimensions(true);
450     addNotify();
451     paintAlignment(true);
452   }
453
454   /**
455    * calculate the annotation dimensions and refresh slider values accordingly.
456    * need to do repaints/notifys afterwards.
457    */
458   protected void validateAnnotationDimensions(boolean adjustPanelHeight)
459   {
460     int height = getAnnotationPanel().adjustPanelHeight();
461
462     int theight = av.getCharHeight()
463             * (av.getAlignment().getHeight() + (!av.hasHiddenRows() ? 0
464                     : av.getAlignment().getHiddenSequences().getSize()));
465     float sscaling = (float) (theight / (1.0 * theight + height));
466     float ascaling = (float) (height * 1.0 / alignFrame.getHeight());
467     int rheight = alignFrame.getHeight() - height - av.getCharHeight();
468     if (adjustPanelHeight)
469     {
470       // NOTE: this logic is different in the applet. Need a better algorithm to
471       // define behaviour
472       // try and set height according to alignment
473       if (ascaling > 0 && sscaling < 0.5)
474       {
475         // if the alignment is too big then
476         // default is 0.5 split
477         height = alignFrame.getHeight() / 2;
478       }
479       else
480       {
481         // if space for more than one sequence row left when annotation is fully
482         // displayed then set height to annotation height
483         // otherwise, leave at least two lines of sequence shown.
484         height = (rheight > av.getCharHeight()) ? height
485                 : (-av.getCharHeight() * 3 + (int) (alignFrame.getHeight() * (1 - sscaling)));
486       }
487     }
488     else
489     {
490       // maintain same window layout whilst updating sliders
491       height = annotationScroller.getSize().height;
492     }
493     hscroll.addNotify();
494
495     annotationScroller.setPreferredSize(new Dimension(annotationScroller
496             .getWidth(), height));
497
498     annotationSpaceFillerHolder.setPreferredSize(new Dimension(
499             annotationSpaceFillerHolder.getWidth(), height));
500     annotationScroller.validate();// repaint();
501     annotationScroller.addNotify();
502   }
503
504   /**
505    * update alignment layout for viewport settings
506    * 
507    * @param wrap
508    *          DOCUMENT ME!
509    */
510   public void updateLayout()
511   {
512     fontChanged();
513     setAnnotationVisible(av.isShowAnnotation());
514     boolean wrap = av.getWrapAlignment();
515     av.startSeq = 0;
516     scalePanelHolder.setVisible(!wrap);
517     hscroll.setVisible(!wrap);
518     idwidthAdjuster.setVisible(!wrap);
519
520     if (wrap)
521     {
522       annotationScroller.setVisible(false);
523       annotationSpaceFillerHolder.setVisible(false);
524     }
525     else if (av.isShowAnnotation())
526     {
527       annotationScroller.setVisible(true);
528       annotationSpaceFillerHolder.setVisible(true);
529     }
530
531     idSpaceFillerPanel1.setVisible(!wrap);
532
533     repaint();
534   }
535
536   // return value is true if the scroll is valid
537   public boolean scrollUp(boolean up)
538   {
539     if (up)
540     {
541       if (vscroll.getValue() < 1)
542       {
543         return false;
544       }
545
546       fastPaint = false;
547       vscroll.setValue(vscroll.getValue() - 1);
548     }
549     else
550     {
551       if ((vextent + vscroll.getValue()) >= av.getAlignment().getHeight())
552       {
553         return false;
554       }
555
556       fastPaint = false;
557       vscroll.setValue(vscroll.getValue() + 1);
558     }
559
560     fastPaint = true;
561
562     return true;
563   }
564
565   /**
566    * DOCUMENT ME!
567    * 
568    * @param right
569    *          DOCUMENT ME!
570    * 
571    * @return DOCUMENT ME!
572    */
573   public boolean scrollRight(boolean right)
574   {
575     if (!right)
576     {
577       if (hscroll.getValue() < 1)
578       {
579         return false;
580       }
581
582       fastPaint = false;
583       hscroll.setValue(hscroll.getValue() - 1);
584     }
585     else
586     {
587       if ((hextent + hscroll.getValue()) >= av.getAlignment().getWidth())
588       {
589         return false;
590       }
591
592       fastPaint = false;
593       hscroll.setValue(hscroll.getValue() + 1);
594     }
595
596     fastPaint = true;
597
598     return true;
599   }
600
601   /**
602    * Adjust row/column scrollers to show a visible position in the alignment.
603    * 
604    * @param x
605    *          visible column to scroll to DOCUMENT ME!
606    * @param y
607    *          visible row to scroll to
608    * 
609    */
610   public void setScrollValues(int x, int y)
611   {
612     // System.err.println("Scroll to "+x+","+y);
613     if (av == null || av.getAlignment() == null)
614     {
615       return;
616     }
617     int width = av.getAlignment().getWidth();
618     int height = av.getAlignment().getHeight();
619
620     if (av.hasHiddenColumns())
621     {
622       width = av.getColumnSelection().findColumnPosition(width);
623     }
624
625     av.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av
626             .getCharWidth())) - 1);
627
628     hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
629     vextent = getSeqPanel().seqCanvas.getHeight() / av.getCharHeight();
630
631     if (hextent > width)
632     {
633       hextent = width;
634     }
635
636     if (vextent > height)
637     {
638       vextent = height;
639     }
640
641     if ((hextent + x) > width)
642     {
643       x = width - hextent;
644     }
645
646     if ((vextent + y) > height)
647     {
648       y = height - vextent;
649     }
650
651     if (y < 0)
652     {
653       y = 0;
654     }
655
656     if (x < 0)
657     {
658       x = 0;
659     }
660
661     hscroll.setValues(x, hextent, 0, width);
662     vscroll.setValues(y, vextent, 0, height);
663   }
664
665   /**
666    * DOCUMENT ME!
667    * 
668    * @param evt
669    *          DOCUMENT ME!
670    */
671   public void adjustmentValueChanged(AdjustmentEvent evt)
672   {
673     int oldX = av.getStartRes();
674     int oldY = av.getStartSeq();
675
676     if (evt.getSource() == hscroll)
677     {
678       int x = hscroll.getValue();
679       av.setStartRes(x);
680       av.setEndRes((x + (getSeqPanel().seqCanvas.getWidth() / av.getCharWidth())) - 1);
681     }
682
683     if (evt.getSource() == vscroll)
684     {
685       int offy = vscroll.getValue();
686
687       if (av.getWrapAlignment())
688       {
689         if (offy > -1)
690         {
691           int rowSize = getSeqPanel().seqCanvas
692                   .getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
693           av.setStartRes(offy * rowSize);
694           av.setEndRes((offy + 1) * rowSize);
695         }
696         else
697         {
698           // This is only called if file loaded is a jar file that
699           // was wrapped when saved and user has wrap alignment true
700           // as preference setting
701           SwingUtilities.invokeLater(new Runnable()
702           {
703             public void run()
704             {
705               setScrollValues(av.getStartRes(), av.getStartSeq());
706             }
707           });
708         }
709       }
710       else
711       {
712         av.setStartSeq(offy);
713         av.setEndSeq(offy
714                 + (getSeqPanel().seqCanvas.getHeight() / av.getCharHeight()));
715       }
716     }
717
718     if (overviewPanel != null)
719     {
720       overviewPanel.setBoxPosition();
721     }
722
723     int scrollX = av.startRes - oldX;
724     int scrollY = av.startSeq - oldY;
725
726     if (av.getWrapAlignment() || !fastPaint)
727     {
728       repaint();
729     }
730     else
731     {
732       // Make sure we're not trying to draw a panel
733       // larger than the visible window
734       if (scrollX > av.endRes - av.startRes)
735       {
736         scrollX = av.endRes - av.startRes;
737       }
738       else if (scrollX < av.startRes - av.endRes)
739       {
740         scrollX = av.startRes - av.endRes;
741       }
742
743       if (scrollX != 0 || scrollY != 0)
744       {
745         getIdPanel().getIdCanvas().fastPaint(scrollY);
746         getSeqPanel().seqCanvas.fastPaint(scrollX, scrollY);
747         getScalePanel().repaint();
748
749         if (av.isShowAnnotation() && scrollX != 0)
750         {
751           getAnnotationPanel().fastPaint(scrollX);
752         }
753       }
754     }
755   }
756
757   /**
758    * Repaint the alignment including the annotations and overview panels (if
759    * shown).
760    */
761   public void paintAlignment(boolean updateOverview)
762   {
763     final AnnotationSorter sorter = new AnnotationSorter(getAlignment(),
764             av.isShowAutocalculatedAbove());
765     sorter.sort(getAlignment()
766             .getAlignmentAnnotation(),
767             av.getSortAnnotationsBy());
768     repaint();
769
770     if (updateOverview)
771     {
772       av.getStructureSelectionManager().sequenceColoursChanged(this);
773
774       if (overviewPanel != null)
775       {
776         overviewPanel.updateOverviewImage();
777       }
778     }
779   }
780
781   /**
782    * DOCUMENT ME!
783    * 
784    * @param g
785    *          DOCUMENT ME!
786    */
787   public void paintComponent(Graphics g)
788   {
789     invalidate();
790
791     Dimension d = getIdPanel().getIdCanvas().getPreferredSize();
792     idPanelHolder.setPreferredSize(d);
793     hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));
794     validate();
795
796     if (av.getWrapAlignment())
797     {
798       int maxwidth = av.getAlignment().getWidth();
799
800       if (av.hasHiddenColumns())
801       {
802         maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
803       }
804
805       int canvasWidth = getSeqPanel().seqCanvas
806               .getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
807       if (canvasWidth > 0)
808       {
809         int max = maxwidth
810                 / getSeqPanel().seqCanvas
811                         .getWrappedCanvasWidth(getSeqPanel().seqCanvas
812                                 .getWidth()) + 1;
813         vscroll.setMaximum(max);
814         vscroll.setUnitIncrement(1);
815         vscroll.setVisibleAmount(1);
816       }
817     }
818     else
819     {
820       setScrollValues(av.getStartRes(), av.getStartSeq());
821     }
822   }
823
824   /**
825    * DOCUMENT ME!
826    * 
827    * @param pg
828    *          DOCUMENT ME!
829    * @param pf
830    *          DOCUMENT ME!
831    * @param pi
832    *          DOCUMENT ME!
833    * 
834    * @return DOCUMENT ME!
835    * 
836    * @throws PrinterException
837    *           DOCUMENT ME!
838    */
839   public int print(Graphics pg, PageFormat pf, int pi)
840           throws PrinterException
841   {
842     pg.translate((int) pf.getImageableX(), (int) pf.getImageableY());
843
844     int pwidth = (int) pf.getImageableWidth();
845     int pheight = (int) pf.getImageableHeight();
846
847     if (av.getWrapAlignment())
848     {
849       return printWrappedAlignment(pg, pwidth, pheight, pi);
850     }
851     else
852     {
853       return printUnwrapped(pg, pwidth, pheight, pi);
854     }
855   }
856
857   /**
858    * DOCUMENT ME!
859    * 
860    * @param pg
861    *          DOCUMENT ME!
862    * @param pwidth
863    *          DOCUMENT ME!
864    * @param pheight
865    *          DOCUMENT ME!
866    * @param pi
867    *          DOCUMENT ME!
868    * 
869    * @return DOCUMENT ME!
870    * 
871    * @throws PrinterException
872    *           DOCUMENT ME!
873    */
874   public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi)
875           throws PrinterException
876   {
877     int idWidth = getVisibleIdWidth(false);
878     FontMetrics fm = getFontMetrics(av.getFont());
879     int scaleHeight = av.getCharHeight() + fm.getDescent();
880
881     pg.setColor(Color.white);
882     pg.fillRect(0, 0, pwidth, pheight);
883     pg.setFont(av.getFont());
884
885     // //////////////////////////////////
886     // / How many sequences and residues can we fit on a printable page?
887     int totalRes = (pwidth - idWidth) / av.getCharWidth();
888
889     int totalSeq = (pheight - scaleHeight) / av.getCharHeight() - 1;
890
891     int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;
892
893     // ///////////////////////////
894     // / Only print these sequences and residues on this page
895     int startRes;
896
897     // ///////////////////////////
898     // / Only print these sequences and residues on this page
899     int endRes;
900
901     // ///////////////////////////
902     // / Only print these sequences and residues on this page
903     int startSeq;
904
905     // ///////////////////////////
906     // / Only print these sequences and residues on this page
907     int endSeq;
908     startRes = (pi % pagesWide) * totalRes;
909     endRes = (startRes + totalRes) - 1;
910
911     if (endRes > (av.getAlignment().getWidth() - 1))
912     {
913       endRes = av.getAlignment().getWidth() - 1;
914     }
915
916     startSeq = (pi / pagesWide) * totalSeq;
917     endSeq = startSeq + totalSeq;
918
919     if (endSeq > av.getAlignment().getHeight())
920     {
921       endSeq = av.getAlignment().getHeight();
922     }
923
924     int pagesHigh = ((av.getAlignment().getHeight() / totalSeq) + 1)
925             * pheight;
926
927     if (av.isShowAnnotation())
928     {
929       pagesHigh += getAnnotationPanel().adjustPanelHeight() + 3;
930     }
931
932     pagesHigh /= pheight;
933
934     if (pi >= (pagesWide * pagesHigh))
935     {
936       return Printable.NO_SUCH_PAGE;
937     }
938
939     // draw Scale
940     pg.translate(idWidth, 0);
941     getScalePanel().drawScale(pg, startRes, endRes, pwidth - idWidth,
942             scaleHeight);
943     pg.translate(-idWidth, scaleHeight);
944
945     // //////////////
946     // Draw the ids
947     Color currentColor = null;
948     Color currentTextColor = null;
949
950     pg.setFont(getIdPanel().getIdCanvas().getIdfont());
951
952     SequenceI seq;
953     for (int i = startSeq; i < endSeq; i++)
954     {
955       seq = av.getAlignment().getSequenceAt(i);
956       if ((av.getSelectionGroup() != null)
957               && av.getSelectionGroup().getSequences(null).contains(seq))
958       {
959         currentColor = Color.gray;
960         currentTextColor = Color.black;
961       }
962       else
963       {
964         currentColor = av.getSequenceColour(seq);
965         currentTextColor = Color.black;
966       }
967
968       pg.setColor(currentColor);
969       pg.fillRect(0, (i - startSeq) * av.getCharHeight(), idWidth,
970               av.getCharHeight());
971
972       pg.setColor(currentTextColor);
973
974       int xPos = 0;
975       if (av.isRightAlignIds())
976       {
977         fm = pg.getFontMetrics();
978         xPos = idWidth
979                 - fm.stringWidth(seq.getDisplayId(av.getShowJVSuffix()))
980                 - 4;
981       }
982
983       pg.drawString(
984               seq.getDisplayId(av.getShowJVSuffix()),
985               xPos,
986               (((i - startSeq) * av.getCharHeight()) + av.getCharHeight())
987                       - (av.getCharHeight() / 5));
988     }
989
990     pg.setFont(av.getFont());
991
992     // draw main sequence panel
993     pg.translate(idWidth, 0);
994     getSeqPanel().seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, 0);
995
996     if (av.isShowAnnotation() && (endSeq == av.getAlignment().getHeight()))
997     {
998       // draw annotation - need to offset for current scroll position
999       int offset = -getAlabels().getScrollOffset();
1000       pg.translate(0, offset);
1001       pg.translate(-idWidth - 3, (endSeq - startSeq) * av.getCharHeight()
1002               + 3);
1003       getAlabels().drawComponent(pg, idWidth);
1004       pg.translate(idWidth + 3, 0);
1005       getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av,
1006               pg, -1, startRes, endRes + 1);
1007       pg.translate(0, -offset);
1008     }
1009
1010     return Printable.PAGE_EXISTS;
1011   }
1012
1013   /**
1014    * DOCUMENT ME!
1015    * 
1016    * @param pg
1017    *          DOCUMENT ME!
1018    * @param pwidth
1019    *          DOCUMENT ME!
1020    * @param pheight
1021    *          DOCUMENT ME!
1022    * @param pi
1023    *          DOCUMENT ME!
1024    * 
1025    * @return DOCUMENT ME!
1026    * 
1027    * @throws PrinterException
1028    *           DOCUMENT ME!
1029    */
1030   public int printWrappedAlignment(Graphics pg, int pwidth, int pheight,
1031           int pi) throws PrinterException
1032   {
1033     int annotationHeight = 0;
1034     AnnotationLabels labels = null;
1035     if (av.isShowAnnotation())
1036     {
1037       annotationHeight = getAnnotationPanel().adjustPanelHeight();
1038       labels = new AnnotationLabels(av);
1039     }
1040
1041     int hgap = av.getCharHeight();
1042     if (av.getScaleAboveWrapped())
1043     {
1044       hgap += av.getCharHeight();
1045     }
1046
1047     int cHeight = av.getAlignment().getHeight() * av.getCharHeight() + hgap
1048             + annotationHeight;
1049
1050     int idWidth = getVisibleIdWidth(false);
1051
1052     int maxwidth = av.getAlignment().getWidth();
1053     if (av.hasHiddenColumns())
1054     {
1055       maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
1056     }
1057
1058     int resWidth = getSeqPanel().seqCanvas.getWrappedCanvasWidth(pwidth
1059             - idWidth);
1060
1061     int totalHeight = cHeight * (maxwidth / resWidth + 1);
1062
1063     pg.setColor(Color.white);
1064     pg.fillRect(0, 0, pwidth, pheight);
1065     pg.setFont(av.getFont());
1066
1067     // //////////////
1068     // Draw the ids
1069     pg.setColor(Color.black);
1070
1071     pg.translate(0, -pi * pheight);
1072
1073     pg.setClip(0, pi * pheight, pwidth, pheight);
1074
1075     int ypos = hgap;
1076
1077     do
1078     {
1079       for (int i = 0; i < av.getAlignment().getHeight(); i++)
1080       {
1081         pg.setFont(getIdPanel().getIdCanvas().getIdfont());
1082         SequenceI s = av.getAlignment().getSequenceAt(i);
1083         String string = s.getDisplayId(av.getShowJVSuffix());
1084         int xPos = 0;
1085         if (av.isRightAlignIds())
1086         {
1087           FontMetrics fm = pg.getFontMetrics();
1088           xPos = idWidth - fm.stringWidth(string) - 4;
1089         }
1090         pg.drawString(string, xPos,
1091                 ((i * av.getCharHeight()) + ypos + av.getCharHeight())
1092                         - (av.getCharHeight() / 5));
1093       }
1094       if (labels != null)
1095       {
1096         pg.translate(-3, ypos
1097  + (av.getAlignment().getHeight() * av.getCharHeight()));
1098
1099         pg.setFont(av.getFont());
1100         labels.drawComponent(pg, idWidth);
1101         pg.translate(+3, -ypos
1102                         - (av.getAlignment().getHeight() * av
1103                                 .getCharHeight()));
1104       }
1105
1106       ypos += cHeight;
1107     } while (ypos < totalHeight);
1108
1109     pg.translate(idWidth, 0);
1110
1111     getSeqPanel().seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight,
1112             0);
1113
1114     if ((pi * pheight) < totalHeight)
1115     {
1116       return Printable.PAGE_EXISTS;
1117
1118     }
1119     else
1120     {
1121       return Printable.NO_SUCH_PAGE;
1122     }
1123   }
1124
1125   /**
1126    * get current sequence ID panel width, or nominal value if panel were to be
1127    * displayed using default settings
1128    * 
1129    * @return
1130    */
1131   public int getVisibleIdWidth()
1132   {
1133     return getVisibleIdWidth(true);
1134   }
1135
1136   /**
1137    * get current sequence ID panel width, or nominal value if panel were to be
1138    * displayed using default settings
1139    * 
1140    * @param onscreen
1141    *          indicate if the Id width for onscreen or offscreen display should
1142    *          be returned
1143    * @return
1144    */
1145   public int getVisibleIdWidth(boolean onscreen)
1146   {
1147     // see if rendering offscreen - check preferences and calc width accordingly
1148     if (!onscreen && Cache.getDefault("FIGURE_AUTOIDWIDTH", false))
1149     {
1150       return calculateIdWidth(-1).width + 4;
1151     }
1152     Integer idwidth = null;
1153     if (onscreen
1154             || (idwidth = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH")) == null)
1155     {
1156       return (getIdPanel().getWidth() > 0 ? getIdPanel().getWidth()
1157               : calculateIdWidth().width + 4);
1158     }
1159     return idwidth.intValue() + 4;
1160   }
1161
1162   void makeAlignmentImage(jalview.util.ImageMaker.TYPE type, File file)
1163   {
1164     long progress = System.currentTimeMillis();
1165     headless = (System.getProperty("java.awt.headless") != null && System
1166             .getProperty("java.awt.headless").equals("true"));
1167     if (alignFrame != null && !headless)
1168     {
1169       alignFrame.setProgressBar(MessageManager.formatMessage(
1170               "status.saving_file", new Object[]
1171               { type.getLabel() }), progress);
1172     }
1173     try
1174     {
1175       AlignmentDimension aDimension = getAlignmentDimension();
1176       try
1177       {
1178         jalview.util.ImageMaker im;
1179         final String imageAction, imageTitle;
1180         if (type == jalview.util.ImageMaker.TYPE.PNG)
1181         {
1182           imageAction = "Create PNG image from alignment";
1183           imageTitle = null;
1184         }
1185         else if (type == jalview.util.ImageMaker.TYPE.EPS)
1186         {
1187           imageAction = "Create EPS file from alignment";
1188           imageTitle = alignFrame.getTitle();
1189         }
1190         else
1191         {
1192           imageAction = "Create SVG file from alignment";
1193           imageTitle = alignFrame.getTitle();
1194         }
1195
1196         im = new jalview.util.ImageMaker(this, type, imageAction,
1197                 aDimension.getWidth(), aDimension.getHeight(), file,
1198                 imageTitle);
1199         if (av.getWrapAlignment())
1200         {
1201           if (im.getGraphics() != null)
1202           {
1203             printWrappedAlignment(im.getGraphics(), aDimension.getWidth(),
1204                     aDimension.getHeight(), 0);
1205             im.writeImage();
1206           }
1207         }
1208         else
1209         {
1210           if (im.getGraphics() != null)
1211           {
1212             printUnwrapped(im.getGraphics(), aDimension.getWidth(),
1213                     aDimension.getHeight(), 0);
1214             im.writeImage();
1215           }
1216         }
1217       } catch (OutOfMemoryError err)
1218       {
1219         // Be noisy here.
1220         System.out.println("########################\n" + "OUT OF MEMORY "
1221                 + file + "\n" + "########################");
1222         new OOMWarning("Creating Image for " + file, err);
1223         // System.out.println("Create IMAGE: " + err);
1224       } catch (Exception ex)
1225       {
1226         ex.printStackTrace();
1227       }
1228     } finally
1229     {
1230       if (alignFrame != null && !headless)
1231       {
1232         alignFrame.setProgressBar(MessageManager.getString("status.export_complete"), progress);
1233       }
1234     }
1235   }
1236
1237   public AlignmentDimension getAlignmentDimension()
1238   {
1239     int maxwidth = av.getAlignment().getWidth();
1240     if (av.hasHiddenColumns())
1241     {
1242       maxwidth = av.getColumnSelection().findColumnPosition(maxwidth);
1243     }
1244
1245     int height = ((av.getAlignment().getHeight() + 1) * av.getCharHeight())
1246             + getScalePanel().getHeight();
1247     int width = getVisibleIdWidth(false) + (maxwidth * av.getCharWidth());
1248
1249     if (av.getWrapAlignment())
1250     {
1251       height = getWrappedHeight();
1252       if (headless)
1253       {
1254         // need to obtain default alignment width and then add in any
1255         // additional allowance for id margin
1256         // this duplicates the calculation in getWrappedHeight but adjusts for
1257         // offscreen idWith
1258         width = alignFrame.getWidth() - vscroll.getPreferredSize().width
1259                 - alignFrame.getInsets().left
1260                 - alignFrame.getInsets().right - getVisibleIdWidth()
1261                 + getVisibleIdWidth(false);
1262       }
1263       else
1264       {
1265         width = getSeqPanel().getWidth() + getVisibleIdWidth(false);
1266       }
1267
1268     }
1269     else if (av.isShowAnnotation())
1270     {
1271       height += getAnnotationPanel().adjustPanelHeight() + 3;
1272     }
1273     return new AlignmentDimension(width, height);
1274
1275   }
1276
1277   /**
1278    * DOCUMENT ME!
1279    */
1280   public void makeEPS(File epsFile)
1281   {
1282     makeAlignmentImage(jalview.util.ImageMaker.TYPE.EPS, epsFile);
1283   }
1284
1285   /**
1286    * DOCUMENT ME!
1287    */
1288   public void makePNG(File pngFile)
1289   {
1290     makeAlignmentImage(jalview.util.ImageMaker.TYPE.PNG, pngFile);
1291   }
1292
1293   public void makeSVG(File svgFile)
1294   {
1295     makeAlignmentImage(jalview.util.ImageMaker.TYPE.SVG, svgFile);
1296   }
1297   public void makePNGImageMap(File imgMapFile, String imageName)
1298   {
1299     // /////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS
1300     // ////////////////////////////////////////////
1301     int idWidth = getVisibleIdWidth(false);
1302     FontMetrics fm = getFontMetrics(av.getFont());
1303     int scaleHeight = av.getCharHeight() + fm.getDescent();
1304
1305     // Gen image map
1306     // ////////////////////////////////
1307     if (imgMapFile != null)
1308     {
1309       try
1310       {
1311         int s, sSize = av.getAlignment().getHeight(), res, alwidth = av
1312                 .getAlignment().getWidth(), g, gSize, f, fSize, sy;
1313         StringBuffer text = new StringBuffer();
1314         PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));
1315         out.println(jalview.io.HTMLOutput.getImageMapHTML());
1316         out.println("<img src=\"" + imageName
1317                 + "\" border=\"0\" usemap=\"#Map\" >"
1318                 + "<map name=\"Map\">");
1319
1320         for (s = 0; s < sSize; s++)
1321         {
1322           sy = s * av.getCharHeight() + scaleHeight;
1323
1324           SequenceI seq = av.getAlignment().getSequenceAt(s);
1325           SequenceFeature[] features = seq.getDatasetSequence()
1326                   .getSequenceFeatures();
1327           SequenceGroup[] groups = av.getAlignment().findAllGroups(seq);
1328           for (res = 0; res < alwidth; res++)
1329           {
1330             text = new StringBuffer();
1331             Object obj = null;
1332             if (av.getAlignment().isNucleotide())
1333             {
1334               obj = ResidueProperties.nucleotideName.get(seq.getCharAt(res)
1335                       + "");
1336             }
1337             else
1338             {
1339               obj = ResidueProperties.aa2Triplet.get(seq.getCharAt(res)
1340                       + "");
1341             }
1342
1343             if (obj == null)
1344             {
1345               continue;
1346             }
1347
1348             String triplet = obj.toString();
1349             int alIndex = seq.findPosition(res);
1350             gSize = groups.length;
1351             for (g = 0; g < gSize; g++)
1352             {
1353               if (text.length() < 1)
1354               {
1355                 text.append("<area shape=\"rect\" coords=\""
1356                         + (idWidth + res * av.getCharWidth()) + "," + sy
1357                         + "," + (idWidth + (res + 1) * av.getCharWidth())
1358                         + ","
1359                         + (av.getCharHeight() + sy) + "\""
1360                         + " onMouseOver=\"toolTip('" + alIndex + " "
1361                         + triplet);
1362               }
1363
1364               if (groups[g].getStartRes() < res
1365                       && groups[g].getEndRes() > res)
1366               {
1367                 text.append("<br><em>" + groups[g].getName() + "</em>");
1368               }
1369             }
1370
1371             if (features != null)
1372             {
1373               if (text.length() < 1)
1374               {
1375                 text.append("<area shape=\"rect\" coords=\""
1376                         + (idWidth + res * av.getCharWidth()) + "," + sy
1377                         + "," + (idWidth + (res + 1) * av.getCharWidth())
1378                         + ","
1379                         + (av.getCharHeight() + sy) + "\""
1380                         + " onMouseOver=\"toolTip('" + alIndex + " "
1381                         + triplet);
1382               }
1383               fSize = features.length;
1384               for (f = 0; f < fSize; f++)
1385               {
1386
1387                 if ((features[f].getBegin() <= seq.findPosition(res))
1388                         && (features[f].getEnd() >= seq.findPosition(res)))
1389                 {
1390                   if (features[f].getType().equals("disulfide bond"))
1391                   {
1392                     if (features[f].getBegin() == seq.findPosition(res)
1393                             || features[f].getEnd() == seq
1394                                     .findPosition(res))
1395                     {
1396                       text.append("<br>disulfide bond "
1397                               + features[f].getBegin() + ":"
1398                               + features[f].getEnd());
1399                     }
1400                   }
1401                   else
1402                   {
1403                     text.append("<br>");
1404                     text.append(features[f].getType());
1405                     if (features[f].getDescription() != null
1406                             && !features[f].getType().equals(
1407                                     features[f].getDescription()))
1408                     {
1409                       text.append(" " + features[f].getDescription());
1410                     }
1411
1412                     if (features[f].getValue("status") != null)
1413                     {
1414                       text.append(" (" + features[f].getValue("status")
1415                               + ")");
1416                     }
1417                   }
1418                 }
1419
1420               }
1421             }
1422             if (text.length() > 1)
1423             {
1424               text.append("')\"; onMouseOut=\"toolTip()\";  href=\"#\">");
1425               out.println(text.toString());
1426             }
1427           }
1428         }
1429         out.println("</map></body></html>");
1430         out.close();
1431
1432       } catch (Exception ex)
1433       {
1434         ex.printStackTrace();
1435       }
1436     } // /////////END OF IMAGE MAP
1437
1438   }
1439
1440   int getWrappedHeight()
1441   {
1442     int seqPanelWidth = getSeqPanel().seqCanvas.getWidth();
1443
1444     if (System.getProperty("java.awt.headless") != null
1445             && System.getProperty("java.awt.headless").equals("true"))
1446     {
1447       seqPanelWidth = alignFrame.getWidth() - getVisibleIdWidth()
1448               - vscroll.getPreferredSize().width
1449               - alignFrame.getInsets().left - alignFrame.getInsets().right;
1450     }
1451
1452     int chunkWidth = getSeqPanel().seqCanvas
1453             .getWrappedCanvasWidth(seqPanelWidth);
1454
1455     int hgap = av.getCharHeight();
1456     if (av.getScaleAboveWrapped())
1457     {
1458       hgap += av.getCharHeight();
1459     }
1460
1461     int annotationHeight = 0;
1462     if (av.isShowAnnotation())
1463     {
1464       annotationHeight = getAnnotationPanel().adjustPanelHeight();
1465     }
1466
1467     int cHeight = av.getAlignment().getHeight() * av.getCharHeight() + hgap
1468             + annotationHeight;
1469
1470     int maxwidth = av.getAlignment().getWidth();
1471     if (av.hasHiddenColumns())
1472     {
1473       maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
1474     }
1475
1476     int height = ((maxwidth / chunkWidth) + 1) * cHeight;
1477
1478     return height;
1479   }
1480
1481   /**
1482    * close the panel - deregisters all listeners and nulls any references to
1483    * alignment data.
1484    */
1485   public void closePanel()
1486   {
1487     PaintRefresher.RemoveComponent(getSeqPanel().seqCanvas);
1488     PaintRefresher.RemoveComponent(getIdPanel().getIdCanvas());
1489     PaintRefresher.RemoveComponent(this);
1490     if (av != null)
1491     {
1492       jalview.structure.StructureSelectionManager ssm = av
1493               .getStructureSelectionManager();
1494       ssm.removeStructureViewerListener(getSeqPanel(), null);
1495       ssm.removeSelectionListener(getSeqPanel());
1496       ssm.removeEditListener(av);
1497       ssm.removeStructureViewerListener(getSeqPanel(), null);
1498       ssm.removeSelectionListener(getSeqPanel());
1499       av.setAlignment(null);
1500       av = null;
1501     }
1502     else
1503     {
1504       if (Cache.log.isDebugEnabled())
1505       {
1506         Cache.log.warn("Closing alignment panel which is already closed.");
1507       }
1508     }
1509   }
1510
1511   /**
1512    * hides or shows dynamic annotation rows based on groups and av state flags
1513    */
1514   public void updateAnnotation()
1515   {
1516     updateAnnotation(false, false);
1517   }
1518
1519   public void updateAnnotation(boolean applyGlobalSettings)
1520   {
1521     updateAnnotation(applyGlobalSettings, false);
1522   }
1523
1524   public void updateAnnotation(boolean applyGlobalSettings,
1525           boolean preserveNewGroupSettings)
1526   {
1527     av.updateGroupAnnotationSettings(applyGlobalSettings,
1528             preserveNewGroupSettings);
1529     adjustAnnotationHeight();
1530   }
1531
1532   @Override
1533   public AlignmentI getAlignment()
1534   {
1535     return av.getAlignment();
1536   }
1537
1538
1539   @Override
1540   public String getViewName()
1541   {
1542     return av.viewName;
1543   }
1544
1545   /**
1546    * Make/Unmake this alignment panel the current input focus
1547    * 
1548    * @param b
1549    */
1550   public void setSelected(boolean b)
1551   {
1552     try
1553     {
1554       alignFrame.setSelected(b);
1555     } catch (Exception ex)
1556     {
1557     }
1558     ;
1559
1560     if (b)
1561     {
1562       alignFrame.setDisplayedView(this);
1563     }
1564   }
1565
1566   @Override
1567   public StructureSelectionManager getStructureSelectionManager()
1568   {
1569     return av.getStructureSelectionManager();
1570   }
1571
1572   @Override
1573   public void raiseOOMWarning(String string, OutOfMemoryError error)
1574   {
1575     new OOMWarning(string, error, this);
1576   }
1577
1578   @Override
1579   public jalview.api.FeatureRenderer cloneFeatureRenderer()
1580   {
1581
1582     return new FeatureRenderer(this);
1583   }
1584   @Override 
1585   public jalview.api.FeatureRenderer getFeatureRenderer()
1586   {
1587     return seqPanel.seqCanvas.getFeatureRenderer();
1588   }
1589   public void updateFeatureRenderer(jalview.renderer.seqfeatures.FeatureRenderer fr)
1590   {
1591     fr.transferSettings(getSeqPanel().seqCanvas.getFeatureRenderer());
1592   }
1593
1594   public void updateFeatureRendererFrom(jalview.api.FeatureRenderer fr)
1595   {
1596     if (getSeqPanel().seqCanvas.getFeatureRenderer() != null)
1597     {
1598       getSeqPanel().seqCanvas.getFeatureRenderer().transferSettings(fr);
1599     }
1600   }
1601
1602   public ScalePanel getScalePanel()
1603   {
1604     return scalePanel;
1605   }
1606
1607   public void setScalePanel(ScalePanel scalePanel)
1608   {
1609     this.scalePanel = scalePanel;
1610   }
1611
1612   public SeqPanel getSeqPanel()
1613   {
1614     return seqPanel;
1615   }
1616
1617   public void setSeqPanel(SeqPanel seqPanel)
1618   {
1619     this.seqPanel = seqPanel;
1620   }
1621
1622   public AnnotationPanel getAnnotationPanel()
1623   {
1624     return annotationPanel;
1625   }
1626
1627   public void setAnnotationPanel(AnnotationPanel annotationPanel)
1628   {
1629     this.annotationPanel = annotationPanel;
1630   }
1631
1632   public AnnotationLabels getAlabels()
1633   {
1634     return alabels;
1635   }
1636
1637   public void setAlabels(AnnotationLabels alabels)
1638   {
1639     this.alabels = alabels;
1640   }
1641
1642   public IdPanel getIdPanel()
1643   {
1644     return idPanel;
1645   }
1646
1647   public void setIdPanel(IdPanel idPanel)
1648   {
1649     this.idPanel = idPanel;
1650   }
1651 }