X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAPopupMenu.java;h=5288fe4862f4bc090b3f6c2455a9758467ed711c;hb=6b71746c98f7c1118b474b0b920db3bd7b2a15c0;hp=7c1ea3f5d4afdff0926b87b2b8fefdd5a27db424;hpb=0ef6205b5b4caef00329b34d9ad118804e5b29be;p=jalview.git
diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java
index 7c1ea3f..5288fe4 100755
--- a/src/jalview/appletgui/APopupMenu.java
+++ b/src/jalview/appletgui/APopupMenu.java
@@ -1,22 +1,20 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
*/
-
package jalview.appletgui;
import java.util.*;
@@ -31,60 +29,99 @@ import jalview.schemes.*;
import jalview.util.UrlLink;
import jalview.io.AppletFormatAdapter;
-public class APopupMenu
- extends java.awt.PopupMenu implements ActionListener, ItemListener
+public class APopupMenu extends java.awt.PopupMenu implements
+ ActionListener, ItemListener
{
Menu groupMenu = new Menu();
+
MenuItem editGroupName = new MenuItem();
+
protected MenuItem clustalColour = new MenuItem();
+
protected MenuItem zappoColour = new MenuItem();
+
protected MenuItem taylorColour = new MenuItem();
+
protected MenuItem hydrophobicityColour = new MenuItem();
+
protected MenuItem helixColour = new MenuItem();
+
protected MenuItem strandColour = new MenuItem();
+
protected MenuItem turnColour = new MenuItem();
+
protected MenuItem buriedColour = new MenuItem();
+
protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem();
+
protected MenuItem userDefinedColour = new MenuItem();
+
protected MenuItem PIDColour = new MenuItem();
+
protected MenuItem BLOSUM62Colour = new MenuItem();
+
MenuItem noColourmenuItem = new MenuItem();
+
protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
final AlignmentPanel ap;
+
MenuItem unGroupMenuItem = new MenuItem();
+
MenuItem nucleotideMenuItem = new MenuItem();
+
Menu colourMenu = new Menu();
+
CheckboxMenuItem showBoxes = new CheckboxMenuItem();
+
CheckboxMenuItem showText = new CheckboxMenuItem();
+
CheckboxMenuItem showColourText = new CheckboxMenuItem();
+
+ CheckboxMenuItem displayNonconserved = new CheckboxMenuItem();
+
Menu editMenu = new Menu("Edit");
+
MenuItem copy = new MenuItem("Copy (Jalview Only)");
+
MenuItem cut = new MenuItem("Cut (Jalview Only)");
+
MenuItem toUpper = new MenuItem("To Upper Case");
+
MenuItem toLower = new MenuItem("To Lower Case");
+
MenuItem toggleCase = new MenuItem("Toggle Case");
+
Menu outputmenu = new Menu();
+
Menu seqMenu = new Menu();
+
MenuItem pdb = new MenuItem();
+
MenuItem hideSeqs = new MenuItem();
+
MenuItem repGroup = new MenuItem();
+
MenuItem sequenceName = new MenuItem("Edit Name/Description");
+
MenuItem sequenceFeature = new MenuItem("Create Sequence Feature");
+
MenuItem editSequence = new MenuItem("Edit Sequence");
Sequence seq;
+
MenuItem revealAll = new MenuItem();
+
Menu menu1 = new Menu();
public APopupMenu(AlignmentPanel apanel, final Sequence seq, Vector links)
{
- ///////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////
// 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 = apanel;
this.seq = seq;
@@ -92,17 +129,15 @@ public class APopupMenu
try
{
jbInit();
- }
- catch (Exception e)
+ } catch (Exception e)
{
e.printStackTrace();
}
- for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length;
- i++)
+ for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++)
{
- MenuItem item = new MenuItem(jalview.io.AppletFormatAdapter.
- WRITEABLE_FORMATS[i]);
+ MenuItem item = new MenuItem(
+ jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]);
item.addActionListener(this);
outputmenu.add(item);
@@ -116,6 +151,7 @@ public class APopupMenu
showText.setState(sg.getDisplayText());
showColourText.setState(sg.getColourText());
showBoxes.setState(sg.getDisplayBoxes());
+ displayNonconserved.setState(sg.getShowNonconserved());
if (!ap.av.alignment.getGroups().contains(sg))
{
groupMenu.remove(unGroupMenuItem);
@@ -128,7 +164,7 @@ public class APopupMenu
remove(groupMenu);
}
- if (links != null && links.size()>0)
+ if (links != null && links.size() > 0)
{
Menu linkMenu = new Menu("Link");
String link;
@@ -141,101 +177,114 @@ public class APopupMenu
System.err.println(urlLink.getInvalidMessage());
continue;
}
- final String target = urlLink.getTarget(); // link.substring(0, link.indexOf("|"));
+ final String target = urlLink.getTarget(); // link.substring(0,
+ // link.indexOf("|"));
final String label = urlLink.getLabel();
if (urlLink.isDynamic())
{
// collect matching db-refs
- DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new String[]{target});
+ DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
+ seq.getDBRef(), new String[]
+ { target });
// collect id string too
String id = seq.getName();
- if (dbr!=null)
+ String descr = seq.getDescription();
+ if (descr != null && descr.length() < 1)
{
- for (int r=0;r -1)
- {
- // Substitute SEQUENCE_ID string and any matching database reference accessions
- String url_pref = link.substring(link.indexOf("|") + 1,
- link.indexOf("$SEQUENCE_ID$"));
-
- String url_suff = link.substring(link.indexOf("$SEQUENCE_ID$") + 13);
-
- // collect matching db-refs
- DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new String[]{target});
- // collect id string too
- String id = seq.getName();
- if (id.indexOf("|") > -1)
+ // Now construct URLs from description but only try to do it for regex
+ // URL links
+ if (descr != null && urlLink.getRegexReplace() != null)
{
- id = id.substring(id.lastIndexOf("|") + 1);
- }
- if (dbr!=null)
- {
- for (int r=0;r -1) { // Substitute SEQUENCE_ID
+ * string and any matching database reference accessions String url_pref
+ * = link.substring(link.indexOf("|") + 1,
+ * link.indexOf("$SEQUENCE_ID$"));
+ *
+ * String url_suff = link.substring(link.indexOf("$SEQUENCE_ID$") + 13);
+ * // collect matching db-refs DBRefEntry[] dbr =
+ * jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new
+ * String[]{target}); // collect id string too String id =
+ * seq.getName(); if (id.indexOf("|") > -1) { id =
+ * id.substring(id.lastIndexOf("|") + 1); } if (dbr!=null) { for (int
+ * r=0;r 0)
{
- add(linkMenu);
+ if (seq != null)
+ {
+ seqMenu.add(linkMenu);
+ }
+ else
+ {
+ add(linkMenu);
+ }
}
}
+ // TODO: add group link menu entry here
if (seq != null)
{
seqMenu.setLabel(seq.getName());
@@ -251,24 +300,35 @@ public class APopupMenu
remove(revealAll);
}
}
+
/**
* add a show URL menu item to the given linkMenu
+ *
* @param linkMenu
- * @param target - menu label string
- * @param url - url to open
+ * @param target
+ * - menu label string
+ * @param url
+ * - url to open
*/
- private void addshowLink(Menu linkMenu, final String target, final String url)
+ private void addshowLink(Menu linkMenu, final String target,
+ final String url)
{
addshowLink(linkMenu, target, target, url);
}
+
/**
* add a show URL menu item to the given linkMenu
+ *
* @param linkMenu
- * @param target - URL target window
- * @param label - menu label string
- * @param url - url to open
+ * @param target
+ * - URL target window
+ * @param label
+ * - menu label string
+ * @param url
+ * - url to open
*/
- private void addshowLink(Menu linkMenu, final String target, final String label, final String url)
+ private void addshowLink(Menu linkMenu, final String target,
+ final String label, final String url)
{
MenuItem item = new MenuItem(label);
item.addActionListener(new java.awt.event.ActionListener()
@@ -280,7 +340,6 @@ public class APopupMenu
});
linkMenu.add(item);
}
-
public void itemStateChanged(ItemEvent evt)
{
@@ -300,6 +359,10 @@ public class APopupMenu
{
showBoxes_itemStateChanged();
}
+ else if (evt.getSource() == displayNonconserved)
+ {
+ this.showNonconserved_itemStateChanged();
+ }
}
public void actionPerformed(ActionEvent evt)
@@ -390,14 +453,10 @@ public class APopupMenu
else if (source == editGroupName)
{
- EditNameDialog dialog = new EditNameDialog(
- getGroup().getName(),
- getGroup().getDescription(),
- " Group Name",
- "Group Description",
- ap.alignFrame,
- "Edit Group Name / Description",
- 500,100, true);
+ EditNameDialog dialog = new EditNameDialog(getGroup().getName(),
+ getGroup().getDescription(), " Group Name",
+ "Group Description", ap.alignFrame,
+ "Edit Group Name / Description", 500, 100, true);
if (dialog.accept)
{
@@ -414,39 +473,33 @@ public class APopupMenu
{
ap.alignFrame.cut_actionPerformed();
}
- else if(source == editSequence)
+ else if (source == editSequence)
{
SequenceGroup sg = ap.av.getSelectionGroup();
- if(sg!=null)
+ if (sg != null)
{
if (seq == null)
seq = (Sequence) sg.getSequenceAt(0);
EditNameDialog dialog = new EditNameDialog(seq.getSequenceAsString(
- sg.getStartRes(),
- sg.getEndRes() + 1),
- null,
- "Edit Sequence ",
- null,
+ sg.getStartRes(), sg.getEndRes() + 1), null,
+ "Edit Sequence ", null,
- ap.alignFrame,
- "Edit Sequence",
- 500, 100, true);
+ ap.alignFrame, "Edit Sequence", 500, 100, true);
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
- );
+ 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());
+ ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
+ .getSequences());
}
}
}
@@ -480,15 +533,14 @@ public class APopupMenu
}
regions.addElement(new int[]
- {start, end});
+ { start, end });
if (ap.av.hasHiddenColumns)
{
start = ap.av.colSel.adjustForHiddenColumns(end);
start = ap.av.colSel.getHiddenBoundaryLeft(start) + 1;
}
- }
- while (end < sg.getEndRes());
+ } while (end < sg.getEndRes());
int[][] startEnd = new int[regions.size()][2];
for (int i = 0; i < regions.size(); i++)
@@ -515,19 +567,18 @@ public class APopupMenu
caseChange = ChangeCaseCommand.TO_LOWER;
}
- ChangeCaseCommand caseCommand = new ChangeCaseCommand(
- description, sg.getSequencesAsArray(ap.av.hiddenRepSequences),
- startEnd, caseChange
- );
+ 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());
+ ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
+ .getSequences());
}
}
- else if(source == sequenceFeature)
+ else if (source == sequenceFeature)
{
SequenceGroup sg = ap.av.getSelectionGroup();
if (sg == null)
@@ -535,21 +586,31 @@ public class APopupMenu
return;
}
- int gSize = sg.getSize();
- SequenceI[] seqs = new SequenceI[gSize];
- SequenceFeature[] features = new SequenceFeature[gSize];
+ int rsize = 0, gSize = sg.getSize();
+ SequenceI[] rseqs, seqs = new SequenceI[gSize];
+ SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
for (int i = 0; i < gSize; i++)
{
- seqs[i] = sg.getSequenceAt(i);
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 (start <= end)
+ {
+ seqs[rsize] = sg.getSequenceAt(i);
+ features[rsize] = new SequenceFeature(null, null, null, start,
+ end, "Jalview");
+ rsize++;
+ }
}
-
- if (ap.seqPanel.seqCanvas.getFeatureRenderer()
- .amendFeatures(seqs, features, true, ap))
+ rseqs = new SequenceI[rsize];
+ tfeatures = new SequenceFeature[rsize];
+ System.arraycopy(seqs, 0, rseqs, 0, rsize);
+ System.arraycopy(features, 0, tfeatures, 0, rsize);
+ features = tfeatures;
+ seqs = rseqs;
+
+ if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
+ features, true, ap))
{
ap.alignFrame.sequenceFeatures.setState(true);
ap.av.showSequenceFeatures(true);
@@ -570,26 +631,21 @@ public class APopupMenu
Frame frame = new Frame();
frame.add(cap);
jalview.bin.JalviewLite.addFrame(frame,
- "Selection output - " + e.getActionCommand(),
- 600, 500);
+ "Selection output - " + e.getActionCommand(), 600, 500);
cap.setText(new jalview.io.AppletFormatAdapter().formatSequences(
- e.getActionCommand(),
- new Alignment(ap.av.getSelectionAsNewSequence()),
- ap.av.showJVSuffix));
+ e.getActionCommand(),
+ new Alignment(ap.av.getSelectionAsNewSequence()),
+ ap.av.showJVSuffix));
}
void editName()
{
- EditNameDialog dialog = new EditNameDialog(
- seq.getName(),
- seq.getDescription(),
- " Sequence Name",
- "Sequence Description",
- ap.alignFrame,
- "Edit Sequence Name / Description",
- 500,100, true);
+ EditNameDialog dialog = new EditNameDialog(seq.getName(),
+ seq.getDescription(), " Sequence Name",
+ "Sequence Description", ap.alignFrame,
+ "Edit Sequence Name / Description", 500, 100, true);
if (dialog.accept)
{
@@ -601,22 +657,16 @@ public class APopupMenu
void addPDB()
{
- if(seq.getPDBId()!=null)
+ if (seq.getPDBId() != null)
{
- PDBEntry entry = (PDBEntry)seq.getPDBId().firstElement();
+ PDBEntry entry = (PDBEntry) seq.getPDBId().firstElement();
- if ( ap.av.applet.jmolAvailable )
- new jalview.appletgui.AppletJmol(entry,
- new Sequence[]{seq},
- null,
- ap,
- AppletFormatAdapter.URL);
- else
- new MCview.AppletPDBViewer(entry,
- new Sequence[]{seq},
- null,
- ap,
- AppletFormatAdapter.URL);
+ if (ap.av.applet.jmolAvailable)
+ new jalview.appletgui.AppletJmol(entry, new Sequence[]
+ { seq }, null, ap, AppletFormatAdapter.URL);
+ else
+ new MCview.AppletPDBViewer(entry, new Sequence[]
+ { seq }, null, ap, AppletFormatAdapter.URL);
}
else
@@ -630,8 +680,7 @@ public class APopupMenu
}
}
- private void jbInit()
- throws Exception
+ private void jbInit() throws Exception
{
groupMenu.setLabel("Group");
groupMenu.setLabel("Selection");
@@ -650,7 +699,9 @@ public class APopupMenu
showBoxes.setState(true);
showBoxes.addItemListener(this);
sequenceName.addActionListener(this);
-
+ displayNonconserved.setLabel("Show Nonconserved");
+ displayNonconserved.setState(false);
+ displayNonconserved.addItemListener(this);
showText.setLabel("Text");
showText.addItemListener(this);
showColourText.setLabel("Colour Text");
@@ -739,6 +790,7 @@ public class APopupMenu
menu1.add(showBoxes);
menu1.add(showText);
menu1.add(showColourText);
+ menu1.add(displayNonconserved);
toggleCase.addActionListener(this);
pdb.addActionListener(this);
hideSeqs.addActionListener(this);
@@ -754,8 +806,9 @@ public class APopupMenu
protected void clustalColour_actionPerformed()
{
SequenceGroup sg = getGroup();
- sg.cs = new ClustalxColourScheme(sg.getSequences(ap.av.hiddenRepSequences),
- ap.av.alignment.getWidth());
+ sg.cs = new ClustalxColourScheme(
+ sg.getSequences(ap.av.hiddenRepSequences),
+ ap.av.alignment.getWidth());
refresh();
}
@@ -817,18 +870,19 @@ public class APopupMenu
if (abovePIDColour.getState())
{
- sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av.
- hiddenRepSequences), 0,
- ap.av.alignment.getWidth()));
- int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs,
- getGroup().getName());
+ sg.cs.setConsensus(AAFrequency.calculate(
+ sg.getSequences(ap.av.hiddenRepSequences), 0,
+ ap.av.alignment.getWidth()));
+ int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
+ .getName());
sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
SliderPanel.showPIDSlider();
}
- else // remove PIDColouring
+ else
+ // remove PIDColouring
{
sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
}
@@ -846,9 +900,9 @@ public class APopupMenu
{
SequenceGroup sg = getGroup();
sg.cs = new PIDColourScheme();
- sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av.
- hiddenRepSequences), 0,
- ap.av.alignment.getWidth()));
+ sg.cs.setConsensus(AAFrequency.calculate(
+ sg.getSequences(ap.av.hiddenRepSequences), 0,
+ ap.av.alignment.getWidth()));
refresh();
}
@@ -858,9 +912,9 @@ public class APopupMenu
sg.cs = new Blosum62ColourScheme();
- sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av.
- hiddenRepSequences), 0,
- ap.av.alignment.getWidth()));
+ sg.cs.setConsensus(AAFrequency.calculate(
+ sg.getSequences(ap.av.hiddenRepSequences), 0,
+ ap.av.alignment.getWidth()));
refresh();
}
@@ -883,10 +937,9 @@ public class APopupMenu
{
Conservation c = new Conservation("Group",
- ResidueProperties.propHash, 3,
- sg.getSequences(ap.av.
- hiddenRepSequences), 0,
- ap.av.alignment.getWidth());
+ ResidueProperties.propHash, 3,
+ sg.getSequences(ap.av.hiddenRepSequences), 0,
+ ap.av.alignment.getWidth());
c.calculate();
c.verdict(false, ap.av.ConsPercGaps);
@@ -896,7 +949,8 @@ public class APopupMenu
SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
SliderPanel.showConservationSlider();
}
- else // remove ConservationColouring
+ else
+ // remove ConservationColouring
{
sg.cs.setConservation(null);
}
@@ -937,6 +991,12 @@ public class APopupMenu
refresh();
}
+ public void showNonconserved_itemStateChanged()
+ {
+ getGroup().setShowNonconserved(this.displayNonconserved.getState());
+ refresh();
+ }
+
public void showBoxes_itemStateChanged()
{
getGroup().setDisplayBoxes(showBoxes.getState());
@@ -949,7 +1009,7 @@ public class APopupMenu
if (sg == null || sg.getSize() < 1)
{
ap.av.hideSequence(new SequenceI[]
- {seq});
+ { seq });
return;
}