src/org/gel/mauve/gui/sequence/RRSequencePanel.java

Go to the documentation of this file.
00001 package org.gel.mauve.gui.sequence;
00002 
00003 import java.awt.Color;
00004 import java.awt.Dimension;
00005 import java.awt.Panel;
00006 import java.util.HashSet;
00007 import java.util.Iterator;
00008 import java.util.List;
00009 
00010 import javax.swing.JLayeredPane;
00011 
00012 import org.gel.mauve.BaseViewerModel;
00013 import org.gel.mauve.Genome;
00014 import org.gel.mauve.ModelEvent;
00015 import org.gel.mauve.ModelListener;
00016 import org.gel.mauve.ViewerMode;
00017 import org.gel.mauve.XmfaViewerModel;
00018 import org.gel.mauve.gui.FillLayout;
00019 import org.gel.mauve.gui.RearrangementPanel;
00020 import org.gel.mauve.histogram.ZoomHistogram;
00021 
00022 public class RRSequencePanel extends JLayeredPane implements ModelListener
00023 {
00024     private MatchPanel matchPanel;
00025     private HighlightPanel highlightPanel;
00026     public RangeHighlightPanel rangeHighlightPanel;
00027     public Panel[] otherPanels = null;
00028     HashSet<ZoomHistogram> histograms = new HashSet<ZoomHistogram>();
00029 
00030     public RRSequencePanel(RearrangementPanel rrpanel, BaseViewerModel model, Genome genome)
00031     {
00032         setLayout(new FillLayout());
00033         matchPanel = new MatchPanel(rrpanel, model, genome);
00034         add(matchPanel, new Integer(1));
00035         highlightPanel = new HighlightPanel(model, genome);
00036         add(highlightPanel, new Integer(2));
00037         rangeHighlightPanel = new RangeHighlightPanel(model, genome);
00038         add(rangeHighlightPanel, new Integer(3));
00039         setMinimumSize( new Dimension( 10000, 100 ) );
00040         setMaximumSize( new Dimension( 10000, 175 ) );
00041         addMouseListener(matchPanel);
00042         addMouseListener(rangeHighlightPanel);
00043         addMouseMotionListener(highlightPanel);
00044         addMouseMotionListener(rangeHighlightPanel);
00045         model.addModelListener(this);
00046     }
00047     
00048     public MatchPanel getMatchPanel(){ return matchPanel; }
00049     
00055     public int goTo (long position) {
00056         return matchPanel.goTo (position);
00057     }
00058     
00065     public boolean isForGenome (Genome genome) {
00066         return matchPanel.isForGenome (genome);
00067     }
00068     
00069     public void setBackground(Color bg)
00070     {
00071         super.setBackground(bg);
00072         if(matchPanel != null)
00073                 matchPanel.setBackground(bg);
00074     }
00075     
00076     public int boxHeight()
00077     {
00078         return matchPanel.boxHeight();
00079     }
00080     
00081     public int boxTop()
00082     {
00083         return matchPanel.boxTop();
00084     }
00085     
00086     public int sequenceCoordinateToCenterPixel(long coord)
00087     {
00088         return matchPanel.sequenceCoordinateToCenterPixel(coord);
00089     }
00090 
00091     public void colorChanged(ModelEvent event)
00092     {
00093         // Ignored
00094     }
00095 
00096     public void weightChanged(ModelEvent event)
00097     {
00098         // Ignored.
00099     }
00100     
00101     public void referenceChanged(ModelEvent event)
00102     {
00103         // Ignored.
00104     }
00105 
00106     public void drawingSettingsChanged(ModelEvent event)
00107     {
00108         // Ignored.
00109     }
00110 
00111     public void modeChanged(ModelEvent event)
00112     {
00113         BaseViewerModel model = (BaseViewerModel) event.getSource();
00114         
00115         if (model.getMode() == ViewerMode.NORMAL)
00116         {
00117             addMouseListener(matchPanel);
00118             addMouseListener(rangeHighlightPanel);
00119             addMouseMotionListener(highlightPanel);
00120             addMouseMotionListener(rangeHighlightPanel);
00121         }
00122         else
00123         {
00124             removeMouseListener(matchPanel);
00125             removeMouseListener(rangeHighlightPanel);
00126             removeMouseMotionListener(highlightPanel);
00127             removeMouseMotionListener(rangeHighlightPanel);
00128         }
00129     }
00130 
00131     public void viewableRangeChanged(ModelEvent event)
00132     {
00133         // Ignored.
00134     }
00135 
00136     public void viewableRangeChangeStart(ModelEvent event)
00137     {
00138         // Ignored.
00139     }
00140 
00141     public void viewableRangeChangeEnd(ModelEvent event)
00142     {
00143         // Ignored.
00144     }
00145 
00146     public void modelReloadStart(ModelEvent event)
00147     {
00148         // Ignored.
00149     }
00150     
00151     public void modelReloadEnd(ModelEvent event)
00152     {
00153         // Ignored
00154     }
00155 
00156     public void genomesReordered(ModelEvent event)
00157     {
00158         // Ignored
00159     }
00160 
00161     public void genomeVisibilityChanged(ModelEvent event)
00162     {
00163         // Ignored.
00164     }
00165     public void printingStart(ModelEvent event)
00166     {
00167         // Ignored.
00168     }
00169     public void printingEnd(ModelEvent event)
00170     {
00171         // Ignored.
00172     }
00173 
00174     public void attributesChanged(ModelEvent event) 
00175     {
00176         // find other panels for the data
00177         BaseViewerModel model = (BaseViewerModel)(event.getSource());
00178         List attribs = model.getGenomeAttributes(matchPanel.getGenome());
00179         Iterator iter = attribs == null ? null : attribs.iterator();
00180         while(iter != null && iter.hasNext()){
00181                 Object o = iter.next();
00182                 if(o instanceof ZoomHistogram){
00183                         // have we already added this ZoomHistogram?
00184                         if(histograms.contains(o))
00185                                 continue;
00186                         HistogramPanel hp = new HistogramPanel(model, matchPanel.getGenome(), (ZoomHistogram)o);
00187                         add(hp,new Integer(4));
00188                         histograms.add((ZoomHistogram)o);
00189                 }
00190         }
00191     }
00192 } 
00193 

Generated on Mon Aug 19 06:03:43 2013 for Mauve by doxygen 1.3.6