From 5e9a8519d84c8f2b6fa6adec6620f2ccf87cf4a4 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Tue, 16 Nov 2004 15:16:41 +0000 Subject: [PATCH] New Class --- src/jalview/gui/GroupEditor.java | 316 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 316 insertions(+) create mode 100755 src/jalview/gui/GroupEditor.java diff --git a/src/jalview/gui/GroupEditor.java b/src/jalview/gui/GroupEditor.java new file mode 100755 index 0000000..3c58df3 --- /dev/null +++ b/src/jalview/gui/GroupEditor.java @@ -0,0 +1,316 @@ +package jalview.gui; + +import jalview.jbgui.GGroupEditor; +import jalview.datamodel.*; +import jalview.schemes.*; +import java.awt.event.*; +import java.util.*; +import javax.swing.*; + + +public class GroupEditor extends GGroupEditor +{ + AlignViewport av; + AlignmentPanel ap; + Vector groups; + Vector unassignedVector; + Vector assignedVector=new Vector(); + boolean updating=false; + int selectedGroupIndex = 0; + Hashtable sequenceHash = new Hashtable(); + + public GroupEditor(AlignViewport av, AlignmentPanel ap) + { + this.av = av; + this.ap = ap; + groups = av.getAlignment().getGroups(); + + updateUnassigned(); + for (int i=0; i < ColourProperties.getColourSchemeNames().size(); i++) + colourCombo.addItem(ColourProperties.getColourSchemeNames().elementAt(i)); + + showGroup(); + updateGroupcombo(); + + assignedList.addMouseListener( new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + if (e.getClickCount() == 2) + { remove_actionPerformed(null); } + } + }); + + unassignedList.addMouseListener( new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + if (e.getClickCount() == 2) + { add_actionPerformed(null); } + } + }); + } + + + void updateGui() + { + unassignedList.setListData(unassignedVector); + assignedList.setListData(assignedVector); + updateGroupcombo(); + ap.RefreshPanels(); + } + + + void updateGroupcombo() + { + updating=true; + + if(groupsCombo.getItemCount()>0) + groupsCombo.removeAllItems(); + + for (int i = 0; i < groups.size(); i++) { + SequenceGroup sg = (SequenceGroup)groups.elementAt(i); + groupsCombo.addItem( sg.getName() + " (" + sg.getSize() + " sequences)"); + } + groupsCombo.setSelectedIndex(selectedGroupIndex); + updating=false; + } + + void updateUnassigned() + { + unassignedVector=new Vector(); + AlignmentI align = av.getAlignment(); + + for (int i = 0; i < align.getHeight();i++) + { + sequenceHash.put( align.getSequenceAt(i).getDisplayId(), align.getSequenceAt(i) ); + boolean assigned = false; + for(int j=0; j