+++ /dev/null
-package jalview.gui;\r
-\r
-import jalview.jbgui.GGroupEditor;\r
-import jalview.datamodel.*;\r
-import jalview.schemes.*;\r
-import java.awt.event.*;\r
-import java.util.*;\r
-import javax.swing.*;\r
-\r
-\r
-public class GroupEditor extends GGroupEditor\r
-{\r
- AlignViewport av;\r
- AlignmentPanel ap;\r
- Vector groups;\r
- Vector unassignedVector;\r
- Vector assignedVector=new Vector();\r
- boolean updating=false;\r
- int selectedGroupIndex = 0;\r
- Hashtable sequenceHash = new Hashtable();\r
-\r
- public GroupEditor(AlignViewport av, AlignmentPanel ap)\r
- {\r
- this.av = av;\r
- this.ap = ap;\r
- groups = av.getAlignment().getGroups();\r
-\r
- updateUnassigned();\r
- for (int i=0; i < ColourProperties.getColourSchemeNames().size(); i++)\r
- colourCombo.addItem(ColourProperties.getColourSchemeNames().elementAt(i));\r
-\r
- if(groups.size()>0)\r
- {\r
- showGroup();\r
- updateGroupcombo();\r
- }\r
-\r
- assignedList.addMouseListener( new MouseAdapter()\r
- {\r
- public void mouseClicked(MouseEvent e)\r
- {\r
- if (e.getClickCount() == 2)\r
- { remove_actionPerformed(null); }\r
- }\r
- });\r
-\r
- unassignedList.addMouseListener( new MouseAdapter()\r
- {\r
- public void mouseClicked(MouseEvent e)\r
- {\r
- if (e.getClickCount() == 2)\r
- { add_actionPerformed(null); }\r
- }\r
- });\r
- }\r
-\r
-\r
- void updateGui()\r
- {\r
- unassignedList.setListData(unassignedVector);\r
- assignedList.setListData(assignedVector);\r
- updateGroupcombo();\r
- ap.RefreshPanels();\r
- }\r
-\r
-\r
- void updateGroupcombo()\r
- {\r
- updating=true;\r
-\r
- if(groupsCombo.getItemCount()>0)\r
- groupsCombo.removeAllItems();\r
-\r
- for (int i = 0; i < groups.size(); i++) {\r
- SequenceGroup sg = (SequenceGroup)groups.elementAt(i);\r
- groupsCombo.addItem( sg.getName() + " (" + sg.getSize() + " sequences)");\r
- }\r
- groupsCombo.setSelectedIndex(selectedGroupIndex);\r
- updating=false;\r
- }\r
-\r
- void updateUnassigned()\r
- {\r
- unassignedVector=new Vector();\r
- AlignmentI align = av.getAlignment();\r
-\r
- for (int i = 0; i < align.getHeight();i++)\r
- {\r
- sequenceHash.put( align.getSequenceAt(i).getDisplayId(), align.getSequenceAt(i) );\r
- boolean assigned = false;\r
- for(int j=0; j<groups.size(); j++)\r
- {\r
- SequenceGroup sg = (SequenceGroup)groups.elementAt(j);\r
- for(int k=0; k<sg.getSize(); k++)\r
- {\r
- if(sg.getSequenceAt(k).getDisplayId().equals( align.getSequenceAt(i).getDisplayId() ) )\r
- {\r
- assigned = true; break;\r
- }\r
- }\r
-\r
- if(assigned)\r
- break;\r
- }\r
-\r
- if(!assigned)\r
- unassignedVector.add(align.getSequenceAt(i).getDisplayId());\r
-\r
- }\r
-\r
- unassignedList.setListData(unassignedVector);\r
- }\r
-\r
-\r
- void showGroup()\r
- {\r
- if(groups.size()<1)\r
- return;\r
-\r
- assignedVector = new Vector();\r
- if(selectedGroupIndex!=-1)\r
- {\r
- SequenceGroup sg = (SequenceGroup) groups.elementAt(selectedGroupIndex);\r
- for (int j = 0; j < sg.getSize(); j++)\r
- {\r
- Sequence s = (Sequence) sg.getSequenceAt(j);\r
- assignedVector.addElement(s.getDisplayId());\r
- }\r
- int num = ColourProperties.indexOfClass(sg.cs);\r
- colourCombo.setSelectedIndex(num);\r
-\r
- boxesCheck.setSelected(sg.getDisplayBoxes());\r
- textCheck.setSelected(sg.getDisplayText());\r
- colourTextCheck.setSelected(sg.getColourText());\r
- }\r
-\r
-\r
- assignedList.setListData( assignedVector );\r
- }\r
-\r
-\r
- protected void groupsCombo_actionPerformed(ActionEvent e)\r
- {\r
- if( !updating )\r
- {\r
- selectedGroupIndex = groupsCombo.getSelectedIndex();\r
- showGroup();\r
- }\r
- }\r
-\r
- protected void groupName_actionPerformed(ActionEvent e)\r
- {\r
- String reply = JOptionPane.showInternalInputDialog(this, "Enter new group name", "Edit group name", JOptionPane.QUESTION_MESSAGE);\r
- if(reply==null)\r
- return;\r
-\r
- SequenceGroup sg = (SequenceGroup)groups.elementAt(selectedGroupIndex);\r
- sg.setName(reply);\r
- updateGroupcombo();\r
- }\r
-\r
- protected void colourCombo_actionPerformed(ActionEvent e)\r
- {\r
- if(groups.size()<1)\r
- return;\r
-\r
- SequenceGroup sg = (SequenceGroup)groups.elementAt(selectedGroupIndex);\r
-\r
- sg.cs = ColourSchemeFactory.get( (String)colourCombo.getSelectedItem() );\r
- //ColourProperties.getColourScheme( colourCombo.getSelectedIndex() );\r
- ap.RefreshPanels();\r
- }\r
-\r
- protected void boxesCheck_actionPerformed(ActionEvent e)\r
- {\r
- SequenceGroup sg = (SequenceGroup)groups.elementAt(selectedGroupIndex);\r
- sg.setDisplayBoxes( boxesCheck.isSelected());\r
- ap.RefreshPanels();\r
- }\r
-\r
- protected void textCheck_actionPerformed(ActionEvent e)\r
- {\r
- SequenceGroup sg = (SequenceGroup)groups.elementAt(selectedGroupIndex);\r
- sg.setDisplayText( textCheck.isSelected() );\r
- ap.RefreshPanels();\r
- }\r
-\r
- protected void colourTextCheck_actionPerformed(ActionEvent e)\r
- {\r
- SequenceGroup sg = (SequenceGroup)groups.elementAt(selectedGroupIndex);\r
- sg.setColourText( colourTextCheck.isSelected());\r
- ap.RefreshPanels();\r
- }\r
-\r
- protected void addSelectedIds_actionPerformed(ActionEvent e)\r
- {\r
- if(selectedGroupIndex==-1)\r
- return;\r
-\r
- SequenceGroup sg = (SequenceGroup)groups.elementAt(selectedGroupIndex);\r
-\r
- for(int i=0; i<av.getSelectionGroup().getSize(); i++)\r
- {\r
- int index = unassignedVector.indexOf( av.getSelectionGroup().getSequenceAt(i).getDisplayId() );\r
- if(index!=-1)\r
- {\r
- sg.addSequence( (SequenceI) sequenceHash.get( unassignedVector.elementAt(index) ));\r
- assignedVector.addElement( unassignedVector.elementAt(index));\r
- unassignedVector.removeElementAt( index );\r
- }\r
-\r
- }\r
- updateGui();\r
- }\r
-\r
- protected void add_actionPerformed(ActionEvent e)\r
- {\r
- if(selectedGroupIndex==-1)\r
- return;\r
-\r
- int [] indices = unassignedList.getSelectedIndices();\r
- if(indices.length<1)\r
- return;\r
-\r
- SequenceGroup sg = (SequenceGroup)groups.elementAt(selectedGroupIndex);\r
-\r
- for(int i=0; i<indices.length; i++)\r
- {\r
- assignedVector.addElement(unassignedVector.elementAt(indices[i]-i));\r
- sg.addSequence( (SequenceI)sequenceHash.get( unassignedVector.elementAt(indices[i]-i) ));\r
- unassignedVector.removeElementAt(indices[i]-i);\r
- }\r
- updateGui();\r
- }\r
-\r
- protected void addAll_actionPerformed(ActionEvent e)\r
- {\r
- if(selectedGroupIndex==-1)\r
- return;\r
-\r
- SequenceGroup sg = (SequenceGroup)groups.elementAt(selectedGroupIndex);\r
- Enumeration enum = unassignedVector.elements();\r
- while(enum.hasMoreElements())\r
- {\r
- String id = (String)enum.nextElement();\r
- assignedVector.addElement( id );\r
- sg.addSequence( (SequenceI)sequenceHash.get( id ));\r
- }\r
-\r
- unassignedVector.clear();\r
- updateGui();\r
- }\r
-\r
- protected void remove_actionPerformed(ActionEvent e)\r
- {\r
- if(selectedGroupIndex==-1)\r
- return;\r
-\r
- SequenceGroup sg = (SequenceGroup)groups.elementAt(selectedGroupIndex);\r
-\r
- int [] indices = assignedList.getSelectedIndices();\r
- if(indices.length<1)\r
- return;\r
-\r
- for(int i=0; i<indices.length; i++)\r
- {\r
-\r
- unassignedVector.addElement(assignedVector.elementAt(indices[i]-i));\r
- SequenceI removeSequence = (SequenceI)sequenceHash.get( assignedVector.elementAt(indices[i]-i) );\r
- av.getSelectionGroup().deleteSequence( removeSequence );\r
- sg.deleteSequence( removeSequence );\r
- assignedVector.removeElementAt(indices[i]-i);\r
-\r
- }\r
-\r
- updateGui();\r
- }\r
-\r
- protected void removeAll_actionPerformed(ActionEvent e)\r
- {\r
- if(selectedGroupIndex==-1)\r
- return;\r
-\r
- SequenceGroup sg = (SequenceGroup)groups.elementAt(selectedGroupIndex);\r
- Enumeration enum = assignedVector.elements();\r
- while(enum.hasMoreElements())\r
- {\r
- String id = (String)enum.nextElement();\r
- unassignedVector.addElement( id );\r
- SequenceI removeSequence = (SequenceI)sequenceHash.get( id );\r
- av.getSelectionGroup().deleteSequence( removeSequence );\r
- sg.deleteSequence( removeSequence );\r
- }\r
-\r
- assignedVector.clear();\r
- updateGui();\r
- }\r
-\r
- protected void addGroup_actionPerformed(ActionEvent e)\r
- {\r
-\r
- ColourSchemeI cs = ColourSchemeFactory.get( (String)colourCombo.getSelectedItem() );\r
- // ColourProperties.getColourScheme( colourCombo.getSelectedIndex() );\r
-\r
- groups.add(\r
- new SequenceGroup("Group "+(groups.size()+1),\r
- cs,\r
- boxesCheck.isSelected(),\r
- textCheck.isSelected(),\r
- colourTextCheck.isSelected(),\r
- 0, av.alignment.getWidth()\r
- ) );\r
-\r
- updateGroupcombo();\r
- groupsCombo.setSelectedIndex( groupsCombo.getItemCount()-1 );\r
- showGroup();\r
- }\r
-\r
- protected void deleteGroup_actionPerformed(ActionEvent e)\r
- {\r
- removeAll_actionPerformed(null);\r
- groups.remove( selectedGroupIndex );\r
- selectedGroupIndex=-1;\r
- updateGroupcombo();\r
- groupsCombo.setSelectedIndex( groupsCombo.getItemCount()-1 );\r
- showGroup();\r
- }\r
-\r
-}\r
+++ /dev/null
-package jalview.jbgui;
-
-import java.awt.*;
-import javax.swing.*;
-import java.awt.event.*;
-import javax.swing.border.*;
-
-public class GGroupEditor extends JPanel
-{
- protected JList assignedList = new JList();
- protected JComboBox groupsCombo = new JComboBox();
- protected JList unassignedList = new JList();
- JButton add = new JButton();
- JButton addAll = new JButton();
- JButton remove = new JButton();
- JButton removeAll = new JButton();
- JPanel jPanel1 = new JPanel();
- GridLayout gridLayout1 = new GridLayout();
- TitledBorder titledBorder1;
- TitledBorder titledBorder2;
- JPanel jPanel2 = new JPanel();
- BorderLayout borderLayout1 = new BorderLayout();
- JButton addGroup = new JButton();
- JButton deleteGroup = new JButton();
- JButton addSelectedIds = new JButton();
- protected JCheckBox textCheck = new JCheckBox();
- protected JCheckBox colourTextCheck = new JCheckBox();
- protected JCheckBox boxesCheck = new JCheckBox();
- protected JComboBox colourCombo = new JComboBox();
- JPanel jPanel3 = new JPanel();
- GridLayout gridLayout2 = new GridLayout();
- JScrollPane jScrollPane1 = new JScrollPane();
- JScrollPane jScrollPane2 = new JScrollPane();
- JButton groupName = new JButton();
-
- public GGroupEditor()
- {
- try
- {
- jbInit();
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- private void jbInit() throws Exception
- {
- titledBorder1 = new TitledBorder("Unassigned Sequences");
- titledBorder2 = new TitledBorder("Current Groups");
- this.setLayout(null);
- unassignedList.setFont(new java.awt.Font("Verdana", 0, 10));
- unassignedList.setBorder(titledBorder1);
- add.setFont(new java.awt.Font("Verdana", 0, 10));
- add.setText("Add to group");
- add.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- add_actionPerformed(e);
- }
- });
- addAll.setFont(new java.awt.Font("Verdana", 0, 10));
- addAll.setText("Add all to group");
- addAll.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- addAll_actionPerformed(e);
- }
- });
- remove.setFont(new java.awt.Font("Verdana", 0, 10));
- remove.setText("Remove from group");
- remove.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- remove_actionPerformed(e);
- }
- });
- removeAll.setFont(new java.awt.Font("Verdana", 0, 10));
- removeAll.setMargin(new Insets(0, 0, 0, 0));
- removeAll.setText("Remove all from group");
- removeAll.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- removeAll_actionPerformed(e);
- }
- });
- jPanel1.setBounds(new Rectangle(265, 82, 169, 108));
- jPanel1.setLayout(gridLayout1);
- gridLayout1.setRows(4);
- jPanel2.setFont(new java.awt.Font("Verdana", 0, 10));
- jPanel2.setBorder(titledBorder2);
- jPanel2.setBounds(new Rectangle(4, 3, 257, 369));
- jPanel2.setLayout(borderLayout1);
- addGroup.setBounds(new Rectangle(265, 259, 166, 25));
- addGroup.setFont(new java.awt.Font("Verdana", 0, 10));
- addGroup.setText("Add new group");
- addGroup.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- addGroup_actionPerformed(e);
- }
- });
- deleteGroup.setBounds(new Rectangle(266, 285, 163, 25));
- deleteGroup.setFont(new java.awt.Font("Verdana", 0, 10));
- deleteGroup.setText("Delete selected group");
- deleteGroup.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- deleteGroup_actionPerformed(e);
- }
- });
- addSelectedIds.setBounds(new Rectangle(268, 37, 160, 25));
- addSelectedIds.setFont(new java.awt.Font("Verdana", 0, 10));
- addSelectedIds.setText("Add selected ids");
- addSelectedIds.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- addSelectedIds_actionPerformed(e);
- }
- });
- textCheck.setFont(new java.awt.Font("Verdana", 0, 10));
- textCheck.setText("Display text");
- textCheck.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- textCheck_actionPerformed(e);
- }
- });
- colourTextCheck.setFont(new java.awt.Font("Verdana", 0, 10));
- colourTextCheck.setText("Colour text");
- colourTextCheck.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- colourTextCheck_actionPerformed(e);
- }
- });
- boxesCheck.setFont(new java.awt.Font("Verdana", 0, 10));
- boxesCheck.setText("Display boxes");
- boxesCheck.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- boxesCheck_actionPerformed(e);
- }
- });
- jPanel3.setLayout(gridLayout2);
- gridLayout2.setRows(4);
- colourCombo.setFont(new java.awt.Font("Verdana", 0, 10));
- colourCombo.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- colourCombo_actionPerformed(e);
- }
- });
- assignedList.setFont(new java.awt.Font("Verdana", 0, 10));
- groupsCombo.setFont(new java.awt.Font("Verdana", 0, 10));
- groupsCombo.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- groupsCombo_actionPerformed(e);
- }
- });
- this.setBackground(Color.lightGray);
- jScrollPane1.setBounds(new Rectangle(437, 6, 257, 367));
- groupName.setBounds(new Rectangle(266, 232, 166, 25));
- groupName.setFont(new java.awt.Font("Verdana", 0, 10));
- groupName.setVerifyInputWhenFocusTarget(true);
- groupName.setText("Edit group name");
- groupName.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- groupName_actionPerformed(e);
- }
- });
- jPanel1.add(add, null);
- jPanel1.add(addAll, null);
- jPanel1.add(remove, null);
- jPanel1.add(removeAll, null);
- this.add(addSelectedIds, null);
- this.add(jPanel1, null);
- this.add(jPanel2, null);
- jPanel3.add(colourCombo, null);
- jPanel3.add(boxesCheck, null);
- jPanel3.add(textCheck, null);
- jPanel3.add(colourTextCheck, null);
- this.add(jScrollPane1, null);
- this.add(addGroup, null);
- this.add(deleteGroup, null);
- this.add(groupName, null);
- jScrollPane1.getViewport().add(unassignedList, null);
- jPanel2.add(jScrollPane2, BorderLayout.CENTER);
- jPanel2.add(groupsCombo, BorderLayout.NORTH);
- jPanel2.add(jPanel3, BorderLayout.SOUTH);
- jScrollPane2.getViewport().add(assignedList, null);
- }
-
- protected void add_actionPerformed(ActionEvent e)
- {
-
- }
-
- protected void groupsCombo_actionPerformed(ActionEvent e)
- {
-
- }
-
- protected void colourCombo_actionPerformed(ActionEvent e)
- {
-
- }
-
- protected void boxesCheck_actionPerformed(ActionEvent e)
- {
-
- }
-
- protected void textCheck_actionPerformed(ActionEvent e)
- {
-
- }
-
- protected void colourTextCheck_actionPerformed(ActionEvent e)
- {
-
- }
-
- protected void addSelectedIds_actionPerformed(ActionEvent e)
- {
-
- }
-
- protected void addAll_actionPerformed(ActionEvent e)
- {
-
- }
-
- protected void remove_actionPerformed(ActionEvent e)
- {
-
- }
-
- protected void removeAll_actionPerformed(ActionEvent e)
- {
-
- }
-
- protected void addGroup_actionPerformed(ActionEvent e)
- {
-
- }
-
- protected void deleteGroup_actionPerformed(ActionEvent e)
- {
-
- }
-
-
- protected void groupName_actionPerformed(ActionEvent e)
- {
-
- }
-}