JAL-4159 sometimes the progress bar may not be available - null check
[jalview.git] / src / jalview / gui / PaSiMapPanel.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ 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.scoremodels.ScoreModels;
24 import jalview.api.AlignViewportI;
25 import jalview.api.analysis.ScoreModelI;
26 import jalview.api.analysis.SimilarityParamsI;
27 import jalview.bin.Console;
28 import jalview.datamodel.Alignment;
29 import jalview.datamodel.AlignmentI;
30 import jalview.datamodel.AlignmentView;
31 import jalview.datamodel.HiddenColumns;
32 import jalview.datamodel.SequenceI;
33 import jalview.gui.ImageExporter.ImageWriterI;
34 import jalview.gui.JalviewColourChooser.ColourChooserListener;
35 import jalview.jbgui.GPaSiMapPanel;
36 import jalview.math.RotatableMatrix.Axis;
37 import jalview.util.ImageMaker;
38 import jalview.util.MessageManager;
39 import jalview.viewmodel.AlignmentViewport;
40 import jalview.viewmodel.PaSiMapModel;
41
42 import java.awt.BorderLayout;
43 import java.awt.Color;
44 import java.awt.Dimension;
45 import java.awt.Graphics;
46 import java.awt.event.ActionEvent;
47 import java.awt.event.ActionListener;
48 import java.awt.print.PageFormat;
49 import java.awt.print.Printable;
50 import java.awt.print.PrinterException;
51 import java.awt.print.PrinterJob;
52 import java.beans.PropertyChangeEvent;
53 import java.beans.PropertyChangeListener;
54
55 import javax.swing.ButtonGroup;
56 import javax.swing.JMenuItem;
57 import javax.swing.JProgressBar;
58 import javax.swing.JRadioButtonMenuItem;
59 import javax.swing.event.InternalFrameAdapter;
60 import javax.swing.event.InternalFrameEvent;
61
62 /**
63  * The panel holding the Pairwise Similarity Map 3-D visualisation
64  */
65 public class PaSiMapPanel extends GPaSiMapPanel
66         implements Runnable, IProgressIndicator
67 {
68   private static final int MIN_WIDTH = 470;
69
70   private static final int MIN_HEIGHT = 250;
71
72   private final int GAP_OPEN_COST = 100;
73
74   private final int GAP_EXTEND_COST = 5;
75
76   private RotatableCanvas rc;
77
78   AlignmentPanel ap;
79
80   AlignmentViewport av;
81
82   private PaSiMapModel pasimapModel;
83
84   private int top = 0;
85
86   private IProgressIndicator progressBar;
87
88   private long progId;
89
90   private boolean working;
91
92   /**
93    * Constructor given sequence data, a similarity (or distance) score model
94    * name, and score calculation parameters
95    * 
96    * @param alignPanel
97    * @param modelName
98    * @param params
99    */
100   public PaSiMapPanel(AlignmentPanel alignPanel, String modelName,
101           SimilarityParamsI params)
102   {
103     super(8);   // dim = 8
104     this.av = alignPanel.av;
105     this.ap = alignPanel;
106     boolean nucleotide = av.getAlignment().isNucleotide();
107
108     //progressBar = new ProgressBar(statusPanel, statusBar);
109
110     addInternalFrameListener(new InternalFrameAdapter()
111     {
112       @Override
113       public void internalFrameClosed(InternalFrameEvent e)
114       {
115         close_actionPerformed();
116       }
117     });
118
119     boolean selected = av.getSelectionGroup() != null
120             && av.getSelectionGroup().getSize() > 0;
121     SequenceI[] seqs;
122     if (!selected)
123     {
124       seqs = av.getAlignment().getSequencesArray();
125     }
126     else
127     {
128       seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
129     }
130
131     ScoreModelI scoreModel = ScoreModels.getInstance()
132             .getScoreModel(modelName, ap);
133     setPasimapModel(
134             new PaSiMapModel(av, seqs, nucleotide, scoreModel));
135     PaintRefresher.Register(this, av.getSequenceSetId());
136
137     setRotatableCanvas(new RotatableCanvas(alignPanel));
138     this.getContentPane().add(getRotatableCanvas(), BorderLayout.CENTER);
139
140     addKeyListener(getRotatableCanvas());
141     validate();
142   }
143
144   /**
145    * Ensure references to potentially very large objects (the PaSiMap matrices) are
146    * nulled when the frame is closed
147    */
148   protected void close_actionPerformed()
149   {
150     setPasimapModel(null);
151     if (this.rc != null)
152     {
153       this.rc.sequencePoints = null;
154       this.rc.setAxisEndPoints(null);
155       this.rc = null;
156     }
157   }
158
159   @Override
160   protected void bgcolour_actionPerformed()
161   {
162     String ttl = MessageManager.getString("label.select_background_colour");
163     ColourChooserListener listener = new ColourChooserListener()
164     {
165       @Override
166       public void colourSelected(Color c)
167       {
168         rc.setBgColour(c);
169         rc.repaint();
170       }
171     };
172     JalviewColourChooser.showColourChooser(this, ttl, rc.getBgColour(),
173             listener);
174   }
175
176   /**
177    * Calculates the PaSiMap and displays the results
178    */
179   @Override
180   public void run()
181   {
182     working = true;
183     progId = System.currentTimeMillis();
184     progressBar = this;
185     String message = MessageManager.getString("label.pasimap_recalculating");
186     if (getParent() == null)
187     {
188       progressBar = ap.alignFrame;
189       message = MessageManager.getString("label.pasimap_calculating");
190     }
191     progressBar.setProgressBar(message, progId);
192     try
193     {
194       //&! remove big seqs
195       for (SequenceI seq : av.getAlignment().getSequencesArray())
196       {
197         if (seq.getLength() > 20000)
198         {
199           //TODO add warning dialog
200           av.getAlignment().deleteSequence(seq);
201         }
202       }
203
204       PairwiseAlignPanel pap = new PairwiseAlignPanel(av, true, GAP_OPEN_COST, GAP_EXTEND_COST, false);
205 System.out.println(pap != null);
206       setPairwiseAlignPanel(pap);
207       getPasimapModel().calculate(pap);
208
209       xCombobox.setSelectedIndex(0);
210       yCombobox.setSelectedIndex(1);
211       zCombobox.setSelectedIndex(2);
212
213       getPasimapModel().updateRc(getRotatableCanvas());
214       // rc.invalidate();
215       setTop(getPasimapModel().getTop());
216
217     } catch (OutOfMemoryError er)
218     {
219       new OOMWarning("calculating PaSiMap", er);
220       working = false;
221       return;
222     } finally
223     {
224       progressBar.setProgressBar("", progId);
225     }
226
227     repaint();
228     if (getParent() == null)
229     {
230       Desktop.addInternalFrame(this,
231               MessageManager.formatMessage("label.calc_title", "PaSiMap",
232                       getPasimapModel().getScoreModelName()),
233               475, 450);
234       this.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
235     }
236     working = false;
237   }
238
239   /**
240    * Updates the PaSiMap display after a change of component to use for x, y or z
241    * axis
242    */
243   @Override
244   protected void doDimensionChange()
245   {
246     if (getTop() == 0)
247     {
248       return;
249     }
250
251     int dim1 = getTop() - xCombobox.getSelectedIndex();
252     int dim2 = getTop() - yCombobox.getSelectedIndex();
253     int dim3 = getTop() - zCombobox.getSelectedIndex();
254     getPasimapModel().updateRcView(dim1, dim2, dim3);
255     getRotatableCanvas().resetView();
256   }
257
258   /**
259    * Sets the selected checkbox item index for PaSiMap dimension (1, 2, 3...) for
260    * the given axis (X/Y/Z)
261    * 
262    * @param index
263    * @param axis
264    */
265   public void setSelectedDimensionIndex(int index, Axis axis)
266   {
267     switch (axis)
268     {
269     case X:
270       xCombobox.setSelectedIndex(index);
271       break;
272     case Y:
273       yCombobox.setSelectedIndex(index);
274       break;
275     case Z:
276       zCombobox.setSelectedIndex(index);
277       break;
278     default:
279     }
280   }
281
282   @Override
283   protected void outputValues_actionPerformed()
284   {
285     CutAndPasteTransfer cap = new CutAndPasteTransfer();
286     try
287     {
288       cap.setText(getPasimapModel().getDetails());
289       Desktop.addInternalFrame(cap,
290               MessageManager.getString("label.pasimap_details"), 500, 500);
291     } catch (OutOfMemoryError oom)
292     {
293       new OOMWarning("opening PaSiMap details", oom);
294       cap.dispose();
295     }
296   }
297
298   @Override
299   protected void showLabels_actionPerformed()
300   {
301     getRotatableCanvas().showLabels(showLabels.getState());
302   }
303
304   @Override
305   protected void print_actionPerformed()
306   {
307     PaSiMapPrinter printer = new PaSiMapPrinter();
308     printer.start();
309   }
310
311   /**
312    * If available, shows the data which formed the inputs for the PaSiMap as a new
313    * alignment
314    */
315   @Override
316   public void originalSeqData_actionPerformed()
317   {
318     // JAL-2647 disabled after load from project (until save to project done)
319     if (getPasimapModel().getInputData() == null)
320     {
321       Console.info(
322               "Unexpected call to originalSeqData_actionPerformed - should have hidden this menu action.");
323       return;
324     }
325     // decide if av alignment is sufficiently different to original data to
326     // warrant a new window to be created
327     // create new alignment window with hidden regions (unhiding hidden regions
328     // yields unaligned seqs)
329     // or create a selection box around columns in alignment view
330     // test Alignment(SeqCigar[])
331     char gc = '-';
332     try
333     {
334       // we try to get the associated view's gap character
335       // but this may fail if the view was closed...
336       gc = av.getGapCharacter();
337     } catch (Exception ex)
338     {
339     }
340
341     Object[] alAndColsel = getPasimapModel().getInputData()
342             .getAlignmentView(false).getAlignmentAndHiddenColumns(gc);
343
344     if (alAndColsel != null && alAndColsel[0] != null)
345     {
346       // AlignmentOrder origorder = new AlignmentOrder(alAndColsel[0]);
347
348       AlignmentI al = new Alignment((SequenceI[]) alAndColsel[0]);
349       AlignmentI dataset = (av != null && av.getAlignment() != null)
350               ? av.getAlignment().getDataset()
351               : null;
352       if (dataset != null)
353       {
354         al.setDataset(dataset);
355       }
356
357       if (true)
358       {
359         // make a new frame!
360         AlignFrame af = new AlignFrame(al, (HiddenColumns) alAndColsel[1],
361                 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
362
363         // >>>This is a fix for the moment, until a better solution is
364         // found!!<<<
365         // af.getFeatureRenderer().transferSettings(alignFrame.getFeatureRenderer());
366
367         // af.addSortByOrderMenuItem(ServiceName + " Ordering",
368         // msaorder);
369
370         Desktop.addInternalFrame(af, MessageManager.formatMessage(
371                 "label.original_data_for_params", new String[]
372                 { this.title }), AlignFrame.DEFAULT_WIDTH,
373                 AlignFrame.DEFAULT_HEIGHT);
374       }
375     }
376     /*
377      * CutAndPasteTransfer cap = new CutAndPasteTransfer(); for (int i = 0; i <
378      * seqs.length; i++) { cap.appendText(new jalview.util.Format("%-" + 15 +
379      * "s").form( seqs[i].getName())); cap.appendText(" " + seqstrings[i] +
380      * "\n"); }
381      * 
382      * Desktop.addInternalFrame(cap, "Original Data", 400, 400);
383      */
384   }
385
386   class PaSiMapPrinter extends Thread implements Printable
387   {
388     @Override
389     public void run()
390     {
391       PrinterJob printJob = PrinterJob.getPrinterJob();
392       PageFormat defaultPage = printJob.defaultPage();
393       PageFormat pf = printJob.pageDialog(defaultPage);
394
395       if (defaultPage == pf)
396       {
397         /*
398          * user cancelled
399          */
400         return;
401       }
402
403       printJob.setPrintable(this, pf);
404
405       if (printJob.printDialog())
406       {
407         try
408         {
409           printJob.print();
410         } catch (Exception PrintException)
411         {
412           PrintException.printStackTrace();
413         }
414       }
415     }
416
417     @Override
418     public int print(Graphics pg, PageFormat pf, int pi)
419             throws PrinterException
420     {
421       pg.translate((int) pf.getImageableX(), (int) pf.getImageableY());
422
423       getRotatableCanvas().drawBackground(pg);
424       getRotatableCanvas().drawScene(pg);
425       if (getRotatableCanvas().drawAxes)
426       {
427         getRotatableCanvas().drawAxes(pg);
428       }
429
430       if (pi == 0)
431       {
432         return Printable.PAGE_EXISTS;
433       }
434       else
435       {
436         return Printable.NO_SUCH_PAGE;
437       }
438     }
439   }
440
441   public void makePaSiMapImage(ImageMaker.TYPE type)  throws Exception
442   {
443     int width = getRotatableCanvas().getWidth();
444     int height = getRotatableCanvas().getHeight();
445     ImageWriterI writer = new ImageWriterI()
446     {
447       @Override
448       public void exportImage(Graphics g) throws Exception
449       {
450         RotatableCanvas canvas = getRotatableCanvas();
451         canvas.drawBackground(g);
452         canvas.drawScene(g);
453         if (canvas.drawAxes)
454         {
455           canvas.drawAxes(g);
456         }
457       }
458     };
459     String pasimap = MessageManager.getString("label.pasimap");
460     ImageExporter exporter = new ImageExporter(writer, null, type, pasimap);
461     exporter.doExport(null, this, width, height, pasimap);
462   }
463
464   @Override
465   protected void viewMenu_menuSelected()
466   {
467     buildAssociatedViewMenu();
468   }
469
470   /**
471    * Builds the menu showing the choice of possible views (for the associated
472    * sequence data) to which the PaSiMap may be linked
473    */
474   void buildAssociatedViewMenu()
475   {
476     AlignmentPanel[] aps = PaintRefresher
477             .getAssociatedPanels(av.getSequenceSetId());
478     if (aps.length == 1 && getRotatableCanvas().av == aps[0].av)
479     {
480       associateViewsMenu.setVisible(false);
481       return;
482     }
483
484     associateViewsMenu.setVisible(true);
485
486     if ((viewMenu
487             .getItem(viewMenu.getItemCount() - 2) instanceof JMenuItem))
488     {
489       viewMenu.insertSeparator(viewMenu.getItemCount() - 1);
490     }
491
492     associateViewsMenu.removeAll();
493
494     JRadioButtonMenuItem item;
495     ButtonGroup buttonGroup = new ButtonGroup();
496     int iSize = aps.length;
497
498     for (int i = 0; i < iSize; i++)
499     {
500       final AlignmentPanel panel = aps[i];
501       item = new JRadioButtonMenuItem(panel.av.getViewName(),
502               panel.av == getRotatableCanvas().av);
503       buttonGroup.add(item);
504       item.addActionListener(new ActionListener()
505       {
506         @Override
507         public void actionPerformed(ActionEvent evt)
508         {
509           selectAssociatedView(panel);
510         }
511       });
512
513       associateViewsMenu.add(item);
514     }
515
516     final JRadioButtonMenuItem itemf = new JRadioButtonMenuItem(
517             "All Views");
518
519     buttonGroup.add(itemf);
520
521     itemf.setSelected(getRotatableCanvas().isApplyToAllViews());
522     itemf.addActionListener(new ActionListener()
523     {
524       @Override
525       public void actionPerformed(ActionEvent evt)
526       {
527         getRotatableCanvas().setApplyToAllViews(itemf.isSelected());
528       }
529     });
530     associateViewsMenu.add(itemf);
531
532   }
533
534   /*
535    * (non-Javadoc)
536    * 
537    * @see
538    * jalview.jbgui.GPaSiMapPanel#outputPoints_actionPerformed(java.awt.event.ActionEvent
539    * )
540    */
541   @Override
542   protected void outputPoints_actionPerformed()
543   {
544     CutAndPasteTransfer cap = new CutAndPasteTransfer();
545     try
546     {
547       cap.setText(getPasimapModel().getPointsasCsv(false,
548               xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(),
549               zCombobox.getSelectedIndex()));
550       Desktop.addInternalFrame(cap, MessageManager
551               .formatMessage("label.points_for_params", new String[]
552               { this.getTitle() }), 500, 500);
553     } catch (OutOfMemoryError oom)
554     {
555       new OOMWarning("exporting PaSiMap points", oom);
556       cap.dispose();
557     }
558   }
559
560   /*
561    * (non-Javadoc)
562    * 
563    * @see
564    * jalview.jbgui.GPaSiMapPanel#outputProjPoints_actionPerformed(java.awt.event
565    * .ActionEvent)
566    */
567   @Override
568   protected void outputProjPoints_actionPerformed()
569   {
570     CutAndPasteTransfer cap = new CutAndPasteTransfer();
571     try
572     {
573       cap.setText(getPasimapModel().getPointsasCsv(true,
574               xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(),
575               zCombobox.getSelectedIndex()));
576       Desktop.addInternalFrame(cap, MessageManager.formatMessage(
577               "label.transformed_points_for_params", new String[]
578               { this.getTitle() }), 500, 500);
579     } catch (OutOfMemoryError oom)
580     {
581       new OOMWarning("exporting transformed PaSiMap points", oom);
582       cap.dispose();
583     }
584   }
585
586   /*
587    * (non-Javadoc)
588    * 
589    * @see
590    * jalview.jbgui.GPaSiMapPanel#outputAlignment_actionPerformed(java.awt.event
591    * .ActionEvent)
592    */
593   @Override
594   protected void outputAlignment_actionPerformed()
595   {
596     CutAndPasteTransfer cap = new CutAndPasteTransfer();
597     try
598     {
599       cap.setText(getPasimapModel().getAlignmentOutput());
600       Desktop.addInternalFrame(cap, MessageManager.formatMessage(
601         "label.pairwise_alignment_for_params", new String[] { this.getTitle() }), 500, 500);
602     } catch (OutOfMemoryError oom)
603     {
604       new OOMWarning("exporting pairwise alignments", oom);
605       cap.dispose();
606     }
607   }
608
609   /*
610    * (non-Javadoc)
611    * 
612    * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
613    */
614   @Override
615   public void setProgressBar(String message, long id)
616   {
617     progressBar.setProgressBar(message, id);
618     // if (progressBars == null)
619     // {
620     // progressBars = new Hashtable();
621     // progressBarHandlers = new Hashtable();
622     // }
623     //
624     // JPanel progressPanel;
625     // Long lId = Long.valueOf(id);
626     // GridLayout layout = (GridLayout) statusPanel.getLayout();
627     // if (progressBars.get(lId) != null)
628     // {
629     // progressPanel = (JPanel) progressBars.get(Long.valueOf(id));
630     // statusPanel.remove(progressPanel);
631     // progressBars.remove(lId);
632     // progressPanel = null;
633     // if (message != null)
634     // {
635     // statusBar.setText(message);
636     // }
637     // if (progressBarHandlers.contains(lId))
638     // {
639     // progressBarHandlers.remove(lId);
640     // }
641     // layout.setRows(layout.getRows() - 1);
642     // }
643     // else
644     // {
645     // progressPanel = new JPanel(new BorderLayout(10, 5));
646     //
647     // JProgressBar progressBar = new JProgressBar();
648     // progressBar.setIndeterminate(true);
649     //
650     // progressPanel.add(new JLabel(message), BorderLayout.WEST);
651     // progressPanel.add(progressBar, BorderLayout.CENTER);
652     //
653     // layout.setRows(layout.getRows() + 1);
654     // statusPanel.add(progressPanel);
655     //
656     // progressBars.put(lId, progressPanel);
657     // }
658     // // update GUI
659     // // setMenusForViewport();
660     // validate();
661   }
662
663   /*
664    * make the progressBar determinate and update its progress
665   */
666   public void updateProgressBar(int lengthOfTask, int progress)
667   {
668     JProgressBar pBar = progressBar.getProgressBar(progId);
669     if (pBar.isIndeterminate())
670     {
671       pBar.setMaximum(lengthOfTask);
672       pBar.setValue(0);
673       pBar.setIndeterminate(false);
674     }
675     updateProgressBar(progress);
676   }
677   public void updateProgressBar(int progress)
678   {
679     JProgressBar pBar = progressBar.getProgressBar(progId);
680     pBar.setValue(progress);
681     pBar.repaint();
682   }
683
684   //&!
685   public void setPairwiseAlignPanel(PairwiseAlignPanel pap)
686   {
687     pap.addPropertyChangeListener(new PropertyChangeListener()
688     {
689       @Override
690       public void propertyChange(PropertyChangeEvent pcEvent)
691       {
692         if (PairwiseAlignPanel.PROGRESS.equals(pcEvent.getPropertyName()))
693         {
694           updateProgressBar((int) pcEvent.getNewValue());
695         } else if (PairwiseAlignPanel.TOTAL.equals(pcEvent.getPropertyName())) {
696           updateProgressBar((int) pcEvent.getNewValue(), 0);
697         }
698       }
699     });
700   }
701
702   @Override
703   public void registerHandler(final long id,
704           final IProgressIndicatorHandler handler)
705   {
706     progressBar.registerHandler(id, handler);
707     // if (progressBarHandlers == null ||
708     // !progressBars.contains(Long.valueOf(id)))
709     // {
710     // throw new
711     // Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler"));
712     // }
713     // progressBarHandlers.put(Long.valueOf(id), handler);
714     // final JPanel progressPanel = (JPanel) progressBars.get(Long.valueOf(id));
715     // if (handler.canCancel())
716     // {
717     // JButton cancel = new JButton(
718     // MessageManager.getString("action.cancel"));
719     // final IProgressIndicator us = this;
720     // cancel.addActionListener(new ActionListener()
721     // {
722     //
723     // @Override
724     // public void actionPerformed(ActionEvent e)
725     // {
726     // handler.cancelActivity(id);
727     // us.setProgressBar(MessageManager.formatMessage("label.cancelled_params",
728     // new String[]{((JLabel) progressPanel.getComponent(0)).getText()}), id);
729     // }
730     // });
731     // progressPanel.add(cancel, BorderLayout.EAST);
732     // }
733   }
734
735   /**
736    * 
737    * @return true if any progress bars are still active
738    */
739   @Override
740   public boolean operationInProgress()
741   {
742     return progressBar.operationInProgress();
743   }
744
745   @Override
746   protected void resetButton_actionPerformed()
747   {
748     int t = getTop();
749     setTop(0); // ugly - prevents dimensionChanged events from being processed
750     xCombobox.setSelectedIndex(0);
751     yCombobox.setSelectedIndex(1);
752     setTop(t);
753     zCombobox.setSelectedIndex(2);
754   }
755
756   /**
757    * Answers true if PaSiMap calculation is in progress, else false
758    * 
759    * @return
760    */
761   public boolean isWorking()
762   {
763     return working;
764   }
765
766   /**
767    * Answers the selected checkbox item index for PaSiMap dimension for the X, Y or
768    * Z axis of the display
769    * 
770    * @param axis
771    * @return
772    */
773   public int getSelectedDimensionIndex(Axis axis)
774   {
775     switch (axis)
776     {
777     case X:
778       return xCombobox.getSelectedIndex();
779     case Y:
780       return yCombobox.getSelectedIndex();
781     default:
782       return zCombobox.getSelectedIndex();
783     }
784   }
785
786   public void setShowLabels(boolean show)
787   {
788     showLabels.setSelected(show);
789   }
790
791   /**
792    * Sets the input data used to calculate the PaSiMap. This is provided for
793    * 'restore from project', which does not currently support this (AL-2647), so
794    * sets the value to null, and hides the menu option for "Input Data...". J
795    * 
796    * @param data
797    */
798   public void setInputData(AlignmentViewport data)
799   {
800     getPasimapModel().setInputData(data);
801     originalSeqData.setVisible(data != null);
802   }
803
804   public AlignViewportI getAlignViewport()
805   {
806     return av;
807   }
808
809   public PaSiMapModel getPasimapModel()
810   {
811     return pasimapModel;
812   }
813
814   public void setPasimapModel(PaSiMapModel pasimapModel)
815   {
816     this.pasimapModel = pasimapModel;
817   }
818
819   public RotatableCanvas getRotatableCanvas()
820   {
821     return rc;
822   }
823
824   public void setRotatableCanvas(RotatableCanvas rc)
825   {
826     this.rc = rc;
827   }
828
829   public int getTop()
830   {
831     return top;
832   }
833
834   public void setTop(int top)
835   {
836     this.top = top;
837   }
838
839   /**
840    * set the associated view for this PaSiMap.
841    * 
842    * @param panel
843    */
844   public void selectAssociatedView(AlignmentPanel panel)
845   {
846     getRotatableCanvas().setApplyToAllViews(false);
847
848     ap = panel;
849     av = panel.av;
850
851     getRotatableCanvas().av = panel.av;
852     getRotatableCanvas().ap = panel;
853     PaintRefresher.Register(PaSiMapPanel.this, panel.av.getSequenceSetId());
854   }
855
856   @Override
857   public JProgressBar getProgressBar(long id)
858   {
859     return progressBar.getProgressBar(id);
860   }
861 }