X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPopupMenu.java;h=056a983afb3f9fb20d3783432426486c406b07df;hb=60f2d6c034560415fd0139c8bc7df0c19cae1186;hp=166ab731f85967f22ca646adc350f465bfa950a2;hpb=9eace25dceb7681fef7a9b414318450e66baf2f4;p=jalview.git diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 166ab73..056a983 100755 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -1,592 +1,1556 @@ -package jalview.gui; - -import jalview.datamodel.*; -import jalview.analysis.*; -import jalview.schemes.*; -import java.awt.*; -import javax.swing.*; -import java.awt.event.*; -import jalview.io.*; -import MCview.*; - -public class PopupMenu extends JPopupMenu -{ - JMenu groupMenu = new JMenu(); - JMenuItem analyze = new JMenuItem(); - JMenu defineMenu = new JMenu(); - JMenuItem groupName = new JMenuItem(); - JMenuItem groupAnnotation = new JMenuItem(); - protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem(); - protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem(); - protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem(); - JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem(); - protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem(); - - - AlignmentPanel ap; - JMenu sequenceMenu = new JMenu(); - JMenuItem sequenceName = new JMenuItem(); - JMenu residueMenu = new JMenu(); - JMenuItem annotateResidue = new JMenuItem(); - - Sequence sequence; - JMenuItem unGroupMenuItem = new JMenuItem(); - JMenuItem pdbMenuItem = new JMenuItem(); - JMenuItem outline = new JMenuItem(); - - public PopupMenu(AlignmentPanel ap, Sequence seq) - { - /////////////////////////////////////////////////////////// - // If this is activated from the sequence panel, the user may want to - // edit or annotate a particular residue. Therefore display the residue menu - // - // If from the IDPanel, we must display the sequence menu - ////////////////////////////////////////////////////////// - - this.ap = ap; - sequence = seq; - - ButtonGroup colours = new ButtonGroup(); - colours.add(noColourmenuItem); - colours.add(clustalColour); - colours.add(zappoColour); - colours.add(taylorColour); - colours.add(hydrophobicityColour); - colours.add(helixColour); - colours.add(strandColour); - colours.add(turnColour); - colours.add(buriedColour); - colours.add(abovePIDColour); - colours.add(userDefinedColour); - colours.add(PIDColour); - colours.add(BLOSUM62Colour); - - try - { jbInit(); } - catch(Exception e) - { e.printStackTrace(); } - - SequenceGroup sg = ap.av.getSelectionGroup(); - if(sg!=null) - { - groupName.setText(sg.getName()); - if(sg.cs instanceof ZappoColourScheme) - zappoColour.setSelected(true); - else if(sg.cs instanceof TaylorColourScheme) - taylorColour.setSelected(true); - else if (sg.cs instanceof PIDColourScheme) - PIDColour.setSelected(true); - else if (sg.cs instanceof Blosum62ColourScheme) - BLOSUM62Colour.setSelected(true); - else if (sg.cs instanceof UserColourScheme) - userDefinedColour.setSelected(true); - else if (sg.cs instanceof HydrophobicColourScheme) - hydrophobicityColour.setSelected(true); - else if (sg.cs instanceof HelixColourScheme) - helixColour.setSelected(true); - else if (sg.cs instanceof StrandColourScheme) - strandColour.setSelected(true); - else if (sg.cs instanceof TurnColourScheme) - turnColour.setSelected(true); - else if (sg.cs instanceof BuriedColourScheme) - buriedColour.setSelected(true); - else if (sg.cs instanceof ClustalxColourScheme) - clustalColour.setSelected(true); - else - noColourmenuItem.setSelected(true); - - if (sg.cs instanceof ConservationColourScheme) - conservationMenuItem.setSelected(true); - } - - - if(seq!=null) - residueMenu.setVisible(false); - else - sequenceMenu.setVisible(false); - - } - private void jbInit() throws Exception - { - groupMenu.setText("Group"); - analyze.setText("Analyze"); - analyze.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - analyze_actionPerformed(e); - } - }); - defineMenu.setText("Define"); - groupName.setText("Name"); - groupName.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - groupName_actionPerformed(e); - } - }); - groupAnnotation.setEnabled(false); - groupAnnotation.setText("Annotation"); - groupAnnotation.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - groupAnnotation_actionPerformed(e); - } - }); - sequenceMenu.setText("Sequence"); - sequenceName.setText("Edit name"); - sequenceName.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - sequenceName_actionPerformed(e); - } - }); - residueMenu.setText("Residue"); - annotateResidue.setEnabled(false); - annotateResidue.setActionCommand("annotate residue"); - annotateResidue.setText("annotate residue???"); - PIDColour.setFocusPainted(false); - unGroupMenuItem.setText("Remove Group"); - unGroupMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - unGroupMenuItem_actionPerformed(e); - } - }); - pdbMenuItem.setText("View PDB structure"); - pdbMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - pdbMenuItem_actionPerformed(e); - } - }); - outline.setText("Border colour"); - outline.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - outline_actionPerformed(e); - } - }); - add(groupMenu); - this.add(sequenceMenu); - this.add(residueMenu); - groupMenu.add(defineMenu); - groupMenu.add(unGroupMenuItem); - groupMenu.addSeparator(); - groupMenu.add(analyze); - defineMenu.add(groupName); - defineMenu.add(groupAnnotation); - defineMenu.addSeparator(); - defineMenu.add(outline); - defineMenu.addSeparator(); - defineMenu.add(noColourmenuItem); - defineMenu.add(clustalColour); - defineMenu.add(zappoColour); - defineMenu.add(taylorColour); - defineMenu.add(hydrophobicityColour); - defineMenu.add(helixColour); - defineMenu.add(strandColour); - defineMenu.add(turnColour); - defineMenu.add(buriedColour); - defineMenu.add(userDefinedColour); - defineMenu.add(PIDColour); - defineMenu.add(BLOSUM62Colour); - defineMenu.addSeparator(); - defineMenu.add(abovePIDColour); - defineMenu.add(conservationMenuItem); - - sequenceMenu.add(sequenceName); - sequenceMenu.add(pdbMenuItem); - residueMenu.add(annotateResidue); - - noColourmenuItem.setText("None"); - noColourmenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - noColourmenuItem_actionPerformed(e); - } - }); - - clustalColour.setText("Clustalx colours"); - clustalColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - clustalColour_actionPerformed(e); - } - }); - zappoColour.setText("Zappo colour scheme"); - zappoColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - zappoColour_actionPerformed(e); - } - }); - taylorColour.setText("Taylor colour scheme"); - taylorColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - taylorColour_actionPerformed(e); - } - }); - hydrophobicityColour.setText("By hydrophobicity"); - hydrophobicityColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - hydrophobicityColour_actionPerformed(e); - } - }); - helixColour.setText("Helix propensity"); - helixColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - helixColour_actionPerformed(e); - } - }); - strandColour.setText("Strand propensity"); - strandColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - strandColour_actionPerformed(e); - } - }); - turnColour.setText("Turn propensity"); - turnColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - turnColour_actionPerformed(e); - } - }); - buriedColour.setText("Buried index"); - buriedColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - buriedColour_actionPerformed(e); - } - }); - abovePIDColour.setText("Above PID threshold only"); - abovePIDColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - abovePIDColour_actionPerformed(e); - } - }); - userDefinedColour.setText("User defined colours"); - userDefinedColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - userDefinedColour_actionPerformed(e); - } - }); - PIDColour.setText("Percentage Identity"); - PIDColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - PIDColour_actionPerformed(e); - } - }); - BLOSUM62Colour.setText("BLOSUM62 score"); - BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - BLOSUM62Colour_actionPerformed(e); - } - }); - conservationMenuItem.setText("By conservation"); - conservationMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - conservationMenuItem_actionPerformed(e); - } - }); - - - - } - - void refresh() - { - SequenceGroup sg = getGroup(); - SuperGroup superG = ap.av.alignment.getSuperGroup( sg ); - if( superG !=null) - superG.setSuperGroupProperties( sg ); - - ap.seqPanel.seqCanvas.paintFlag=true; - ap.seqPanel.repaint(); - } - - protected void clustalColour_actionPerformed(ActionEvent e) - { - SequenceGroup sg = getGroup(); - sg.cs = new ClustalxColourScheme(sg.sequences, ap.av.alignment.getWidth()); - refresh(); - } - - protected void zappoColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new ZappoColourScheme(); - refresh(); - } - - protected void taylorColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new TaylorColourScheme(); - refresh(); - } - - - protected void hydrophobicityColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new HydrophobicColourScheme(); - refresh(); - } - - protected void helixColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new HelixColourScheme(); - refresh(); - } - - protected void strandColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new StrandColourScheme(); - refresh(); - } - - protected void turnColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new TurnColourScheme(); - refresh(); - } - - protected void buriedColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new BuriedColourScheme(); - refresh(); - } - - - protected void abovePIDColour_actionPerformed(ActionEvent e) - { - if(abovePIDColour.isSelected()) -{ - - Desktop.setPIDSliderSource(ap, getGroup().cs, getGroup().getName()); - refresh(); -} -else // remove PIDColouring -{ - ColourSchemeI cs = getGroup().cs; - ResidueColourScheme rcs = (ResidueColourScheme)cs; - rcs.setThreshold(0); - getGroup().cs = rcs; - refresh(); -} - - - - } - - - protected void userDefinedColour_actionPerformed(ActionEvent e) - { - JInternalFrame frame = new JInternalFrame(); - UserDefinedColours chooser = new UserDefinedColours( frame, ap, getGroup()); - frame.setContentPane(chooser); - Desktop.addInternalFrame(frame,"User defined colours ("+getGroup().getName()+")", 450,540 ); - frame.setResizable(false); - frame.setIconifiable(false); - frame.setMaximizable(false); - - } - - protected void PIDColour_actionPerformed(ActionEvent e) - { - - } - - protected void BLOSUM62Colour_actionPerformed(ActionEvent e) - { - getGroup().cs = new Blosum62ColourScheme(ap.av); - refresh(); - } - - - protected void noColourmenuItem_actionPerformed(ActionEvent e) - { - getGroup().cs = null; - refresh(); - } - - protected void conservationMenuItem_actionPerformed(ActionEvent e) - { - SequenceGroup sg = getGroup(); - - if(conservationMenuItem.isSelected()) - { - - Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, - sg.sequences, 0, - ap.av.alignment.getWidth()); - - c.calculate(); - c.verdict(false, 100); - ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs); - - - sg.cs = ccs; - - Desktop.setConservationSliderSource(ap, ccs, sg.getName()); - } - else // remove ConservationColouring - { - ConservationColourScheme ccs = (ConservationColourScheme)sg.cs; - sg.cs = ccs.cs; - } - - refresh(); - } - - protected void groupAnnotation_actionPerformed(ActionEvent e) - { - - } - - protected void groupName_actionPerformed(ActionEvent e) - { - SequenceGroup sg = getGroup(); - String reply = JOptionPane.showInternalInputDialog(Desktop.desktop, "Enter new group name", "Edit group name", JOptionPane.QUESTION_MESSAGE); - if(reply==null) - return; - - sg.setName(reply); - groupName.setText(reply); - } - - - protected void analyze_actionPerformed(ActionEvent e) - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(false); - JInternalFrame frame = new JInternalFrame(); - cap.formatForOutput(); - frame.setContentPane(cap); - Desktop.addInternalFrame(frame, "Analyze this - ", 400, 300); - SequenceGroup sg = getGroup(); - StringBuffer sb = new StringBuffer(); - - for(int i=0; i0) + { + java.util.Enumeration e = seq.getDatasetSequence().getPDBId(). + elements(); + + while (e.hasMoreElements()) + { + final PDBEntry pdb = (PDBEntry) e.nextElement(); + + menuItem = new JMenuItem(); + menuItem.setText(pdb.getId()); + menuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + Vector seqs = new Vector(); + for (int i = 0; i < ap.av.alignment.getHeight(); i++) + { + Vector pdbs = ap.av.alignment.getSequenceAt(i).getDatasetSequence().getPDBId(); + if(pdbs==null) + continue; + + for(int p=0; p 1) + { + menuItem = new JMenuItem("Represent Group with " + seq.getName()); + menuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + hideSequences(true); + } + }); + sequenceMenu.add(menuItem); + } + + if (ap.av.hasHiddenRows) + { + final int index = ap.av.alignment.findIndex(seq); + + if (ap.av.adjustForHiddenSeqs(index) - + ap.av.adjustForHiddenSeqs(index - 1) > 1) + { + menuItem = new JMenuItem("Reveal Sequences"); + menuItem.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + ap.av.showSequence(index); + if (ap.overviewPanel != null) + { + ap.overviewPanel.updateOverviewImage(); + } + } + }); + add(menuItem); + } + + menuItem = new JMenuItem("Reveal All"); + menuItem.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + ap.av.showAllHiddenSeqs(); + if (ap.overviewPanel != null) + { + ap.overviewPanel.updateOverviewImage(); + } + } + }); + + add(menuItem); + } + + } + + SequenceGroup sg = ap.av.getSelectionGroup(); + + if (sg != null) + { + groupName.setText(sg.getName()); + + if (sg.cs instanceof ZappoColourScheme) + { + zappoColour.setSelected(true); + } + else if (sg.cs instanceof TaylorColourScheme) + { + taylorColour.setSelected(true); + } + else if (sg.cs instanceof PIDColourScheme) + { + PIDColour.setSelected(true); + } + else if (sg.cs instanceof Blosum62ColourScheme) + { + BLOSUM62Colour.setSelected(true); + } + else if (sg.cs instanceof UserColourScheme) + { + userDefinedColour.setSelected(true); + } + else if (sg.cs instanceof HydrophobicColourScheme) + { + hydrophobicityColour.setSelected(true); + } + else if (sg.cs instanceof HelixColourScheme) + { + helixColour.setSelected(true); + } + else if (sg.cs instanceof StrandColourScheme) + { + strandColour.setSelected(true); + } + else if (sg.cs instanceof TurnColourScheme) + { + turnColour.setSelected(true); + } + else if (sg.cs instanceof BuriedColourScheme) + { + buriedColour.setSelected(true); + } + else if (sg.cs instanceof ClustalxColourScheme) + { + clustalColour.setSelected(true); + } + else + { + noColourmenuItem.setSelected(true); + } + + if (sg.cs != null && sg.cs.conservationApplied()) + { + conservationMenuItem.setSelected(true); + } + + showText.setSelected(sg.getDisplayText()); + showColourText.setSelected(sg.getColourText()); + showBoxes.setSelected(sg.getDisplayBoxes()); + } + else + { + groupMenu.setVisible(false); + editMenu.setVisible(false); + } + + if (!ap.av.alignment.getGroups().contains(sg)) + { + unGroupMenuItem.setVisible(false); + } + + if (seq == null) + { + sequenceMenu.setVisible(false); + structureMenu.setVisible(false); + } + + if (links != null && links.size() > 0) + { + JMenu linkMenu = new JMenu("Link"); + + for (int i = 0; i < links.size(); i++) + { + String link = links.elementAt(i).toString(); + UrlLink urlLink = null; + try { + urlLink = new UrlLink(link); + } catch (Exception foo) { + jalview.bin.Cache.log.error("Exception for URLLink '"+link+"'",foo); + continue; + }; + if (!urlLink.isValid()) + { + jalview.bin.Cache.log.error(urlLink.getInvalidMessage()); + continue; + } + final String label = urlLink.getLabel(); + if (urlLink.isDynamic()) + { + + // collect matching db-refs + DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new String[]{urlLink.getTarget()}); + // collect id string too + String id = seq.getName(); + if (dbr!=null) + { + for (int r=0;r -1) + { + JOptionPane.showMessageDialog(ap, + "Spaces have been converted to \"_\"", + "No spaces allowed in Sequence Name", + JOptionPane.WARNING_MESSAGE); + } + + sequence.setName(dialog.getName().replace(' ', '_')); + ap.paintAlignment(false); + } + + sequence.setDescription(dialog.getDescription()); + + ap.av.firePropertyChange("alignment", null, + ap.av.getAlignment().getSequences()); + + } + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + void unGroupMenuItem_actionPerformed() + { + SequenceGroup sg = ap.av.getSelectionGroup(); + ap.av.alignment.deleteGroup(sg); + ap.av.setSelectionGroup(null); + refresh(); + } + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void outline_actionPerformed() + { + SequenceGroup sg = getGroup(); + Color col = JColorChooser.showDialog(this, "Select Outline Colour", + Color.BLUE); + + if (col != null) + { + sg.setOutlineColour(col); + } + + refresh(); + } + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void showBoxes_actionPerformed() + { + getGroup().setDisplayBoxes(showBoxes.isSelected()); + refresh(); + } + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void showText_actionPerformed() + { + getGroup().setDisplayText(showText.isSelected()); + refresh(); + } + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void showColourText_actionPerformed() + { + getGroup().setColourText(showColourText.isSelected()); + refresh(); + } + + public void showLink(String url) + { + try + { + jalview.util.BrowserLauncher.openURL(url); + } + catch (Exception ex) + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, + "Unixers: Couldn't find default web browser." + + + "\nAdd the full path to your browser in Preferences.", + "Web browser not found", + JOptionPane.WARNING_MESSAGE); + + ex.printStackTrace(); + } + } + + void hideSequences(boolean representGroup) + { + SequenceGroup sg = ap.av.getSelectionGroup(); + if (sg == null || sg.getSize() < 1) + { + ap.av.hideSequence(new SequenceI[] + {sequence}); + return; + } + + ap.av.setSelectionGroup(null); + + if (representGroup) + { + ap.av.hideRepSequences(sequence, sg); + + return; + } + + int gsize = sg.getSize(); + SequenceI[] hseqs; + + hseqs = new SequenceI[gsize]; + + int index = 0; + for (int i = 0; i < gsize; i++) + { + hseqs[index++] = sg.getSequenceAt(i); + } + + ap.av.hideSequence(hseqs); + } + + public void copy_actionPerformed() + { + ap.alignFrame.copy_actionPerformed(null); + } + + public void cut_actionPerformed() + { + ap.alignFrame.cut_actionPerformed(null); + } + + void changeCase(ActionEvent e) + { + Object source = e.getSource(); + SequenceGroup sg = ap.av.getSelectionGroup(); + + if (sg != null) + { + int[][] startEnd = ap.av.getVisibleRegionBoundaries( + sg.getStartRes(), sg.getEndRes() + 1); + + String description; + int caseChange; + + if (source == toggle) + { + description = "Toggle Case"; + caseChange = ChangeCaseCommand.TOGGLE_CASE; + } + else if (source == upperCase) + { + description = "To Upper Case"; + caseChange = ChangeCaseCommand.TO_UPPER; + } + else + { + description = "To Lower Case"; + caseChange = ChangeCaseCommand.TO_LOWER; + } + + ChangeCaseCommand caseCommand = new ChangeCaseCommand( + description, sg.getSequencesAsArray(ap.av.hiddenRepSequences), + startEnd, caseChange + ); + + ap.alignFrame.addHistoryItem(caseCommand); + + ap.av.firePropertyChange("alignment", null, + ap.av.getAlignment().getSequences()); + + } + } + + public void outputText_actionPerformed(ActionEvent e) + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(); + cap.setForInput(null); + Desktop.addInternalFrame(cap, + "Alignment output - " + e.getActionCommand(), 600, + 500); + + String[] omitHidden = null; + + System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens or we simply trust the user wants wysiwig behaviour + SequenceGroup sg = ap.av.getSelectionGroup(); + ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection()); + omitHidden = ap.av.getViewAsString(true); + Alignment oal = new Alignment(ap.av.getSequenceSelection()); + AlignmentAnnotation[] nala = ap.av.alignment.getAlignmentAnnotation(); + for (int i=0; i 0) + { + PDBEntry entry = new PDBEntry(); + entry.setId(id.toUpperCase()); + sequence.getDatasetSequence() + .addPDBId(entry); + } + } + + public void discoverPDB_actionPerformed() + { + + final SequenceI[] sequences = + ((ap.av.selectionGroup == null) + ? new Sequence[]{sequence} + : ap.av.selectionGroup.getSequencesInOrder(ap.av.alignment)); + Thread discpdb = new Thread(new Runnable() { + public void run() + { + + new jalview.ws.DBRefFetcher(sequences, + ap.alignFrame).fetchDBRefs(false); + } + + }); + discpdb.start(); + } + + public void sequenceFeature_actionPerformed() + { + SequenceGroup sg = ap.av.getSelectionGroup(); + if (sg == null) + { + return; + } + + int gSize = sg.getSize(); + SequenceI[] seqs = new SequenceI[gSize]; + SequenceFeature[] features = new SequenceFeature[gSize]; + + for (int i = 0; i < gSize; i++) + { + seqs[i] = sg.getSequenceAt(i).getDatasetSequence(); + int start = sg.getSequenceAt(i).findPosition(sg.getStartRes()); + int end = sg.findEndRes(sg.getSequenceAt(i)); + features[i] = new SequenceFeature(null, null, null, start, end, "Jalview"); + } + + if (ap.seqPanel.seqCanvas.getFeatureRenderer() + .amendFeatures(seqs, features, true, ap)) + { + ap.alignFrame.showSeqFeatures.setSelected(true); + ap.av.setShowSequenceFeatures(true); + ap.highlightSearchResults(null); + } + } + + public void textColour_actionPerformed() + { + SequenceGroup sg = getGroup(); + if (sg != null) + { + new TextColourChooser().chooseColour(ap, sg); + } + } + + public void colourByStructure(String pdbid) + { + Annotation [] anots = jalview.structure.StructureSelectionManager.getStructureSelectionManager() + .colourSequenceFromStructure(sequence, pdbid); + + AlignmentAnnotation an = new AlignmentAnnotation( + "Structure", "Coloured by "+pdbid, anots); + + ap.av.alignment.addAnnotation(an); + an.createSequenceMapping(sequence, 0, true); + //an.adjustForAlignment(); + ap.av.alignment.setAnnotationIndex(an,0); + + ap.adjustAnnotationHeight(); + + sequence.addAlignmentAnnotation(an); + + } + + public void editSequence_actionPerformed(ActionEvent actionEvent) + { + SequenceGroup sg = ap.av.getSelectionGroup(); + + if(sg!=null) + { + if (sequence == null) + sequence = (Sequence) sg.getSequenceAt(0); + + EditNameDialog dialog = new EditNameDialog( + sequence.getSequenceAsString( + sg.getStartRes(), + sg.getEndRes() + 1), + null, + "Edit Sequence ", + null, + "Edit Sequence"); + + if (dialog.accept) + { + EditCommand editCommand = new EditCommand( + "Edit Sequences", EditCommand.REPLACE, + dialog.getName().replace(' ', ap.av.getGapCharacter()), + sg.getSequencesAsArray(ap.av.hiddenRepSequences), + sg.getStartRes(), sg.getEndRes() + 1, ap.av.alignment + ); + + ap.alignFrame.addHistoryItem(editCommand); + + ap.av.firePropertyChange("alignment", null, + ap.av.getAlignment().getSequences()); + } + } + } + + +}