src/org/gel/mauve/color/ColorMenu.java

Go to the documentation of this file.
00001 package org.gel.mauve.color;
00002 
00003 import java.awt.event.ActionEvent;
00004 import java.awt.event.ActionListener;
00005 
00006 import javax.swing.ButtonGroup;
00007 import javax.swing.JMenu;
00008 import javax.swing.JRadioButtonMenuItem;
00009 
00010 import org.gel.mauve.BaseViewerModel;
00011 import org.gel.mauve.LcbViewerModel;
00012 import org.gel.mauve.XmfaViewerModel;
00013 
00014 public class ColorMenu extends JMenu implements ActionListener {
00015 
00016         BaseViewerModel model;
00017         
00018         JRadioButtonMenuItem bbLcbColor = new JRadioButtonMenuItem("LCB color");
00019         JRadioButtonMenuItem bbMultiplicityColor = new JRadioButtonMenuItem("Backbone color");
00020         JRadioButtonMenuItem lcbColor = new JRadioButtonMenuItem("LCB color");
00021         JRadioButtonMenuItem offsetColor = new JRadioButtonMenuItem("Offset color");
00022         JRadioButtonMenuItem normalizedOffsetColor = new JRadioButtonMenuItem("Normalized offset color");
00023         JRadioButtonMenuItem multiplicityColor = new JRadioButtonMenuItem("Multiplicity color");
00024         JRadioButtonMenuItem multiplicityTypeColor = new JRadioButtonMenuItem("Multiplicity type color");
00025         JRadioButtonMenuItem normalizedMultiplicityTypeColor = new JRadioButtonMenuItem("Normalized multiplicity type color");
00026 
00027     ButtonGroup bg = new ButtonGroup();
00028 
00029         BackboneLcbColor backboneLcbColor = new BackboneLcbColor();
00030         BackboneMultiplicityColor backboneMultiplicityColor = new BackboneMultiplicityColor();
00031         LCBColorScheme lcbColorScheme = new LCBColorScheme();
00032         MultiplicityColorScheme multiplicityColorScheme = new MultiplicityColorScheme();
00033         MultiplicityTypeColorScheme multiplicityTypeColorScheme = new MultiplicityTypeColorScheme();
00034         NormalizedMultiplicityTypeColorScheme normalizedMultiplicityTypeColorScheme = new NormalizedMultiplicityTypeColorScheme();
00035         NormalizedOffsetColorScheme normalizedOffsetColorScheme = new NormalizedOffsetColorScheme();
00036         OffsetColorScheme offsetColorScheme = new OffsetColorScheme();
00037         
00038         public ColorMenu()
00039         {
00040                 bbLcbColor.setActionCommand(bbLcbColor.getText());
00041                 bbMultiplicityColor.setActionCommand(bbMultiplicityColor.getText());
00042                 lcbColor.setActionCommand(lcbColor.getText());
00043                 offsetColor.setActionCommand(offsetColor.getText());
00044                 normalizedOffsetColor.setActionCommand(normalizedOffsetColor.getText());
00045                 multiplicityColor.setActionCommand(multiplicityColor.getText());
00046                 multiplicityTypeColor.setActionCommand(multiplicityTypeColor.getText());
00047                 normalizedMultiplicityTypeColor.setActionCommand(normalizedMultiplicityTypeColor.getText());
00048                 bbLcbColor.addActionListener(this);
00049                 bbMultiplicityColor.addActionListener(this);
00050                 lcbColor.addActionListener(this);
00051                 offsetColor.addActionListener(this);
00052                 normalizedOffsetColor.addActionListener(this);
00053                 multiplicityColor.addActionListener(this);
00054                 multiplicityTypeColor.addActionListener(this);
00055                 normalizedMultiplicityTypeColor.addActionListener(this);
00056         }
00057         
00058         public void build(BaseViewerModel model)
00059         {
00060                 bg = new ButtonGroup();
00061         bg.add(bbLcbColor);
00062         bg.add(bbMultiplicityColor);
00063         bg.add(lcbColor);
00064         bg.add(offsetColor);
00065         bg.add(normalizedOffsetColor);
00066         bg.add(multiplicityColor);
00067         bg.add(multiplicityTypeColor);
00068         bg.add(normalizedMultiplicityTypeColor);
00069 
00070         this.removeAll();
00071 
00072         this.model = model;
00073         if (model instanceof XmfaViewerModel)
00074         {
00075                 boolean have_bb = ((XmfaViewerModel)model).getBackboneList() != null;
00076                 if(have_bb)
00077                 {
00078                         add(bbLcbColor);
00079                         add(bbMultiplicityColor);
00080                         bbLcbColor.setSelected(true);
00081                 }else{
00082                         setEnabled(false);
00083                         JRadioButtonMenuItem lcbColor = new JRadioButtonMenuItem("LCB color");
00084                         add(lcbColor);
00085                 }
00086         }
00087         else
00088         {
00089                 if(model instanceof LcbViewerModel)
00090                         add(lcbColor);
00091                 add(offsetColor);
00092                 add(normalizedOffsetColor);
00093                 add(multiplicityColor);
00094                 add(multiplicityTypeColor);
00095 
00096                 if (model.getSequenceCount() < 62)
00097                         add(normalizedMultiplicityTypeColor);
00098 
00099                 if(model instanceof LcbViewerModel)
00100                         lcbColor.setSelected(true);
00101                 else
00102                         offsetColor.setSelected(true);
00103         }
00104                 
00105         }
00106 
00107         public void actionPerformed(ActionEvent e)
00108     {
00109         if (e.getActionCommand() == bbLcbColor.getText())
00110             model.setColorScheme(backboneLcbColor);
00111         if (e.getActionCommand() == bbMultiplicityColor.getText())
00112             model.setColorScheme(backboneMultiplicityColor);
00113         if (e.getActionCommand() == lcbColor.getText())
00114             model.setColorScheme(lcbColorScheme);
00115         if (e.getActionCommand() == offsetColor.getText())
00116             model.setColorScheme(offsetColorScheme);
00117         if (e.getActionCommand() == normalizedOffsetColor.getText())
00118             model.setColorScheme(normalizedOffsetColorScheme);
00119         if (e.getActionCommand() == multiplicityColor.getText())
00120             model.setColorScheme(multiplicityColorScheme);
00121         if (e.getActionCommand() == multiplicityTypeColor.getText())
00122             model.setColorScheme(multiplicityTypeColorScheme);
00123         if (e.getActionCommand() == normalizedMultiplicityTypeColor.getText())
00124             model.setColorScheme(normalizedMultiplicityTypeColorScheme);
00125     }
00126 }

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