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

Go to the documentation of this file.
00001 package org.gel.mauve.gui.sequence;
00002 
00003 import java.awt.MenuItem;
00004 import java.awt.PopupMenu;
00005 import java.awt.event.ActionEvent;
00006 import java.awt.event.ActionListener;
00007 import java.awt.event.ItemEvent;
00008 import java.awt.event.ItemListener;
00009 import java.util.LinkedList;
00010 
00011 import javax.swing.JCheckBoxMenuItem;
00012 
00013 import org.gel.mauve.BaseViewerModel;
00014 import org.gel.mauve.Genome;
00015 import org.gel.mauve.Match;
00016 import org.gel.mauve.gui.RearrangementPanel;
00017 
00023 class MatchPopupMenu extends PopupMenu implements ActionListener, ItemListener {
00024         LinkedList match_list;
00025 
00026         RearrangementPanel rrpanel;
00027 
00028         Genome g;
00029 
00030         BaseViewerModel model;
00031 
00032         int lcb_id;
00033 
00034         int remove_item = Integer.MAX_VALUE;
00035 
00036         int keep_item = Integer.MAX_VALUE;
00037 
00038         static final String remove_string = "Remove this LCB";
00039 
00040         static final String keep_string = "Keep this LCB";
00041 
00042         public MatchPopupMenu (RearrangementPanel rrpanel, BaseViewerModel model,
00043                         Genome g) {
00044                 this.rrpanel = rrpanel;
00045                 this.g = g;
00046                 match_list = new LinkedList ();
00047                 addActionListener (this);
00048         }
00049 
00050         public void addLCBOptions (int lcb_id) {
00051                 // remove_item = getItemCount();
00052                 // add( new MenuItem( remove_string ) );
00053                 keep_item = getItemCount ();
00054                 JCheckBoxMenuItem keep_checkbox = new JCheckBoxMenuItem (keep_string);
00055                 keep_checkbox.setState (false);
00056                 keep_checkbox.addItemListener (this);
00057                 // add( keep_checkbox );
00058         }
00059 
00060         public void addMatch (Match m) {
00061                 add (new MenuItem ("Align display to " + m.toString ()));
00062                 // add( new MenuItem( new String( "Show annotation between " ) +
00063                 // m.starts[ sequence ] + new String(" and ") + (m.starts[ sequence ] +
00064                 // m.lengths[ sequence ] - 1) ) );
00065                 match_list.addLast (m);
00066         }
00067 
00068         public void actionPerformed (ActionEvent e) {
00069                 String act_command = e.getActionCommand ();
00070                 int itemI = 0;
00071                 for (; itemI < getItemCount (); itemI++) {
00072                         if (getItem (itemI).getActionCommand () == act_command)
00073                                 break;
00074                 }
00075                 if (itemI == remove_item) {
00076                         // rrpanel.removeLCB( lcb_id );
00077                 } else if (itemI == keep_item) {
00078                         // rrpanel.keepLCB( lcb_id );
00079                 } else {
00080                         if (itemI > keep_item) {
00081                                 itemI -= 1;
00082                         }
00083                         int matchI = itemI;
00084                         Match selected_match = (Match) match_list.get (matchI);
00085                         model.alignView (selected_match, g);
00086                 }
00087         }
00088 
00090         public void itemStateChanged (ItemEvent e) {
00091                 // rrpanel.toggleKeepLCB( lcb_id );
00092         }
00093 
00094 }

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