src/org/gel/mauve/gui/StyleMenu.java

Go to the documentation of this file.
00001 package org.gel.mauve.gui;
00002 
00003 import java.awt.event.ActionEvent;
00004 import java.awt.event.ActionListener;
00005 
00006 import javax.swing.JCheckBoxMenuItem;
00007 import javax.swing.JMenu;
00008 
00009 import org.gel.mauve.BaseViewerModel;
00010 import org.gel.mauve.LcbViewerModel;
00011 import org.gel.mauve.XmfaViewerModel;
00012 
00013 public class StyleMenu extends JMenu implements ActionListener {
00014 
00015     JCheckBoxMenuItem jMenuViewStyleSimilarityRanges = new JCheckBoxMenuItem();
00016     JCheckBoxMenuItem jMenuViewStyleLcbOutlines = new JCheckBoxMenuItem();
00017     JCheckBoxMenuItem jMenuViewStyleSimilarityPlot = new JCheckBoxMenuItem();
00018     JCheckBoxMenuItem jMenuViewStyleSolidBlocks = new JCheckBoxMenuItem();
00019     JCheckBoxMenuItem jMenuViewStyleLcbStrikethroughLines = new JCheckBoxMenuItem();
00020     JCheckBoxMenuItem jMenuViewStyleLcbConnectingLines = new JCheckBoxMenuItem();
00021     JCheckBoxMenuItem jMenuViewStyleChromosomeBoundaries = new JCheckBoxMenuItem();
00022     JCheckBoxMenuItem jMenuViewStyleMouseHighlighting = new JCheckBoxMenuItem();
00023     JCheckBoxMenuItem jMenuViewStyleDrawAttributes = new JCheckBoxMenuItem();
00024     
00025     BaseViewerModel model;
00026     RearrangementPanel rrpanel;
00027 
00028     public StyleMenu()
00029     {
00030         jMenuViewStyleSimilarityRanges.setToolTipText("Draw sequence similarity values as a range with mean value darkened");
00031         jMenuViewStyleSimilarityRanges.setVisible(true);
00032         jMenuViewStyleSimilarityRanges.setText("Similarity ranges");
00033         jMenuViewStyleSimilarityRanges.setMnemonic('i');
00034         jMenuViewStyleSimilarityRanges.setActionCommand("ToggleSimilarityRanges");
00035         jMenuViewStyleSimilarityRanges.addActionListener(this);
00036 
00037         jMenuViewStyleLcbOutlines.setToolTipText("Draw outlines around each Locally Collinear Block");
00038         jMenuViewStyleLcbOutlines.setVisible(true);
00039         jMenuViewStyleLcbOutlines.setText("LCB outlines");
00040         jMenuViewStyleLcbOutlines.setMnemonic('o');
00041         jMenuViewStyleLcbOutlines.setActionCommand("ToggleLcbBounds");
00042         jMenuViewStyleLcbOutlines.addActionListener(this);
00043 
00044         jMenuViewStyleSimilarityPlot.setToolTipText("Draw a similarity plot indicating average similarity of each region");
00045         jMenuViewStyleSimilarityPlot.setVisible(true);
00046         jMenuViewStyleSimilarityPlot.setText("Similarity plot");
00047         jMenuViewStyleSimilarityPlot.setMnemonic('S');
00048         jMenuViewStyleSimilarityPlot.setActionCommand("ToggleDrawMatches");
00049         jMenuViewStyleSimilarityPlot.addActionListener(this);
00050 
00051         jMenuViewStyleSolidBlocks.setToolTipText("Draw solid colors for each locally collinear block");
00052         jMenuViewStyleSolidBlocks.setVisible(true);
00053         jMenuViewStyleSolidBlocks.setText("Solid LCB coloring");
00054         jMenuViewStyleSolidBlocks.setMnemonic('L');
00055         jMenuViewStyleSolidBlocks.setActionCommand("ToggleFillBoxes");
00056         jMenuViewStyleSolidBlocks.addActionListener(this);
00057 
00058         jMenuViewStyleLcbStrikethroughLines.setToolTipText("Draw connecting lines that strike through LCBs");
00059         jMenuViewStyleLcbStrikethroughLines.setVisible(true);
00060         jMenuViewStyleLcbStrikethroughLines.setText("LCB strikethrough lines");
00061         jMenuViewStyleLcbStrikethroughLines.setMnemonic('t');
00062         jMenuViewStyleLcbStrikethroughLines.setActionCommand("ToggleStrikethrough");
00063         jMenuViewStyleLcbStrikethroughLines.addActionListener(this);
00064 
00065         jMenuViewStyleLcbConnectingLines.setToolTipText("Draw lines connecting homologous LCBs across genomes");
00066         jMenuViewStyleLcbConnectingLines.setVisible(true);
00067         jMenuViewStyleLcbConnectingLines.setText("LCB connecting lines");
00068         jMenuViewStyleLcbConnectingLines.setMnemonic('l');
00069         jMenuViewStyleLcbConnectingLines.setActionCommand("ToggleLCBlines");
00070         jMenuViewStyleLcbConnectingLines.addActionListener(this);
00071         
00072         jMenuViewStyleChromosomeBoundaries.setToolTipText("Draw red lines at chromosome or contig boundaries");
00073         jMenuViewStyleChromosomeBoundaries.setVisible(true);
00074         jMenuViewStyleChromosomeBoundaries.setText("Chromosome/contig boundaries");
00075         jMenuViewStyleChromosomeBoundaries.setMnemonic('c');
00076         jMenuViewStyleChromosomeBoundaries.setActionCommand("ToggleChromosomeBoundaries");
00077         jMenuViewStyleChromosomeBoundaries.addActionListener(this);
00078 
00079         jMenuViewStyleMouseHighlighting.setToolTipText("Define whether the mouse cursor should show orthologous regions");
00080         jMenuViewStyleMouseHighlighting.setVisible(true);
00081         jMenuViewStyleMouseHighlighting.setText("Show mouse highlighting");
00082         jMenuViewStyleMouseHighlighting.setMnemonic('m');
00083         jMenuViewStyleMouseHighlighting.setActionCommand("ToggleMouseCursor");
00084         jMenuViewStyleMouseHighlighting.addActionListener(this);
00085         
00086         jMenuViewStyleDrawAttributes.setToolTipText("Should attributes such as genome-wide histograms be drawn");
00087         jMenuViewStyleDrawAttributes.setVisible(true);
00088         jMenuViewStyleDrawAttributes.setText("Draw attributes (histograms)");
00089         jMenuViewStyleDrawAttributes.setMnemonic('a');
00090         jMenuViewStyleDrawAttributes.setActionCommand("ToggleDrawAttributes");
00091         jMenuViewStyleDrawAttributes.addActionListener(this);
00092 
00093         add(jMenuViewStyleLcbOutlines);
00094         add(jMenuViewStyleSimilarityPlot);
00095         add(jMenuViewStyleSimilarityRanges);
00096         add(jMenuViewStyleSolidBlocks);
00097         add(jMenuViewStyleLcbStrikethroughLines);
00098         add(jMenuViewStyleLcbConnectingLines);
00099         add(jMenuViewStyleChromosomeBoundaries);
00100         add(jMenuViewStyleMouseHighlighting);
00101         add(jMenuViewStyleDrawAttributes);
00102     }
00103     
00111     public void setTarget(BaseViewerModel model, RearrangementPanel rrpanel)
00112     {
00113         this.model = model;
00114         this.rrpanel = rrpanel;
00115         if( model instanceof LcbViewerModel || model instanceof XmfaViewerModel )
00116         {
00117                 setEnabled(true);
00118             rrpanel.addKeyMapping("typed r", "ToggleStrikethrough", this);
00119             rrpanel.addKeyMapping("typed L", "ToggleLCBlines", this);
00120             rrpanel.addKeyMapping("typed q", "ToggleLcbBounds", this);
00121             rrpanel.addKeyMapping("typed w", "ToggleFillBoxes", this);
00122             rrpanel.addKeyMapping("typed e", "ToggleDrawMatches", this);
00123 
00124             jMenuViewStyleSimilarityRanges.setSelected(true);
00125             jMenuViewStyleLcbConnectingLines.setSelected(true);
00126             jMenuViewStyleLcbOutlines.setSelected(false);
00127             jMenuViewStyleLcbStrikethroughLines.setSelected(true);
00128             jMenuViewStyleSimilarityPlot.setSelected(true);
00129             jMenuViewStyleSolidBlocks.setSelected(false);
00130             jMenuViewStyleChromosomeBoundaries.setSelected(true);
00131             jMenuViewStyleMouseHighlighting.setSelected(true);
00132         }else
00133                 setEnabled(false);
00134         rrpanel.addKeyMapping("typed h", "ToggleDrawAttributes", this);
00135         jMenuViewStyleDrawAttributes.setSelected(model.getDrawAttributes());
00136     }
00137     
00138     public void actionPerformed(ActionEvent e)
00139     {
00140         if (e.getActionCommand().equals("ToggleSimilarityRanges"))
00141         {
00142             if (model != null && model instanceof XmfaViewerModel)
00143             {
00144                 XmfaViewerModel xm = (XmfaViewerModel)model;
00145                 xm.setDrawSimilarityRanges(!xm.getDrawSimilarityRanges());
00146                 jMenuViewStyleDrawAttributes.setSelected(xm.getDrawSimilarityRanges());
00147             }
00148         }
00149         if (e.getActionCommand().equals("ToggleLCBlines"))
00150         {
00151                 if(rrpanel != null)
00152                 {
00153                         rrpanel.lcbLinePanel.setHidden(!rrpanel.lcbLinePanel.getHidden());
00154                         jMenuViewStyleLcbConnectingLines.setSelected(!rrpanel.lcbLinePanel.getHidden());
00155                 }
00156         }
00157         else if (e.getActionCommand().equals("ToggleStrikethrough"))
00158         {
00159                 if(rrpanel != null)
00160                 {
00161                         rrpanel.lcbLinePanel.draw_strikethrough = !rrpanel.lcbLinePanel.draw_strikethrough;
00162                         rrpanel.lcbLinePanel.repaint();
00163                         jMenuViewStyleLcbStrikethroughLines.setSelected(rrpanel.lcbLinePanel.draw_strikethrough);
00164                 }
00165         }
00166         else if (e.getActionCommand().equals("ToggleLcbBounds"))
00167         {
00168             if (model instanceof LcbViewerModel)
00169             {
00170                 LcbViewerModel lv = (LcbViewerModel) model;
00171                 lv.setDrawLcbBounds(!lv.getDrawLcbBounds());
00172                 jMenuViewStyleLcbOutlines.setSelected(lv.getDrawLcbBounds());
00173             }
00174         }
00175         else if (e.getActionCommand().equals("ToggleFillBoxes"))
00176         {
00177             if (model != null)
00178             {
00179                 if (model instanceof LcbViewerModel)
00180                 {
00181                     LcbViewerModel lv = (LcbViewerModel) model;
00182                     lv.setFillLcbBoxes(!lv.getFillLcbBoxes());
00183                     jMenuViewStyleSolidBlocks.setSelected(lv.getFillLcbBoxes());
00184                 }
00185             }
00186         }
00187         else if (e.getActionCommand().equals("ToggleDrawMatches"))
00188         {
00189             if (model != null)
00190             {
00191                 model.setDrawMatches(!model.getDrawMatches());
00192                 jMenuViewStyleSimilarityPlot.setSelected(model.getDrawMatches());
00193             }
00194         }
00195         else if (e.getActionCommand().equals("ToggleChromosomeBoundaries"))
00196         {
00197             if (model != null)
00198             {
00199                 model.setDrawChromosomeBoundaries(!model.getDrawChromosomeBoundaries());
00200                 jMenuViewStyleChromosomeBoundaries.setSelected(model.getDrawChromosomeBoundaries());
00201             }
00202         }
00203         else if (e.getActionCommand().equals("ToggleMouseCursor"))
00204         {
00205             if (model != null)
00206             {
00207                 model.setDrawMouseCursor(!model.getDrawMouseHighlighting());
00208                 jMenuViewStyleMouseHighlighting.setSelected(model.getDrawMouseHighlighting());
00209             }
00210         }
00211         else if (e.getActionCommand().equals("ToggleDrawAttributes"))
00212         {
00213             if (model != null)
00214             {
00215                 model.setDrawAttributes(!model.getDrawAttributes());
00216                 jMenuViewStyleDrawAttributes.setSelected(model.getDrawAttributes());
00217             }
00218         }
00219         
00220     }
00221 }

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