X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignFrame.java;h=c4c2c5bf13fe9d20e6a92efb6e9c2817405d031d;hb=e30c8f0736f711e2dc7c32680ac57a28c77d567d;hp=cf4c40df44831919c95f4dd2c8b63e8272ca4347;hpb=55e2e9b22b133db8b9ff0979b0338a33081fc8fd;p=jalview.git
diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java
index cf4c40d..c4c2c5b 100755
--- a/src/jalview/appletgui/AlignFrame.java
+++ b/src/jalview/appletgui/AlignFrame.java
@@ -31,16 +31,20 @@ import java.io.BufferedReader;
import java.net.URL;
-public class AlignFrame extends Frame
+public class AlignFrame extends Frame implements ActionListener,
+ ItemListener, KeyListener, MouseListener
{
- final AlignmentPanel alignPanel;
- public final AlignViewport viewport;
+ public AlignmentPanel alignPanel;
+ public AlignViewport viewport;
int NEW_WINDOW_WIDTH = 700;
int NEW_WINDOW_HEIGHT = 500;
jalview.bin.JalviewLite applet;
- public AlignFrame(AlignmentI al, jalview.bin.JalviewLite applet, String title)
+ public AlignFrame(AlignmentI al,
+ jalview.bin.JalviewLite applet,
+ String title,
+ boolean embedded)
{
try{
jbInit();
@@ -48,45 +52,22 @@ public class AlignFrame extends Frame
{
ex.printStackTrace();
}
+
this.applet = applet;
viewport = new AlignViewport(al, applet);
alignPanel = new AlignmentPanel(this, viewport);
- add(alignPanel);
- alignPanel.validate();
+
+ annotationPanelMenuItem.setState(viewport.showAnnotation);
if(applet!=null)
{
- String treeFile = applet.getParameter("treeFile");
- if (treeFile != null)
- {
- try
- {
- jalview.io.NewickFile fin = new jalview.io.NewickFile(applet.
- getCodeBase() + treeFile, "URL");
- fin.parse();
-
- if (fin.getTree() != null)
- {
- TreePanel tp = null;
- tp = new TreePanel(viewport, viewport.getAlignment().getSequences(),
- fin, "FromFile", applet.getCodeBase() + treeFile);
- jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
- addTreeMenuItem(tp, treeFile);
- }
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
String param = applet.getParameter("sortBy");
if (param != null)
{
if (param.equalsIgnoreCase("Id"))
- sortIDMenuItem_actionPerformed(null);
+ sortIDMenuItem_actionPerformed();
else if (param.equalsIgnoreCase("Pairwise Identity"))
- sortPairwiseMenuItem_actionPerformed(null);
+ sortPairwiseMenuItem_actionPerformed();
}
param = applet.getParameter("wrap");
@@ -95,7 +76,7 @@ public class AlignFrame extends Frame
if (param.equalsIgnoreCase("true"))
{
wrapMenuItem.setState(true);
- wrapMenuItem_actionPerformed(null);
+ wrapMenuItem_actionPerformed();
}
}
@@ -119,13 +100,11 @@ public class AlignFrame extends Frame
}
- this.addWindowListener(new WindowAdapter()
- {
- public void windowClosing(WindowEvent e)
- {
- closeMenuItem_actionPerformed(null);
- }
- });
+ //Some JVMS send keyevents to Top frame or lowest panel,
+ //Havent worked out why yet. So add to both this frame and seqCanvas for now
+ this.addKeyListener(this);
+ alignPanel.seqPanel.seqCanvas.addKeyListener(this);
+ alignPanel.idPanel.idCanvas.addKeyListener(this);
viewport.addPropertyChangeListener(new java.beans.PropertyChangeListener()
{
@@ -138,13 +117,20 @@ public class AlignFrame extends Frame
}
});
- jalview.bin.JalviewLite.addFrame(this, title,
- NEW_WINDOW_WIDTH,
- NEW_WINDOW_HEIGHT);
-
+ if(embedded)
+ {
+ setEmbedded();
+ }
+ else
+ {
+ add(alignPanel, BorderLayout.CENTER);
+ jalview.bin.JalviewLite.addFrame(this, title, NEW_WINDOW_WIDTH,
+ NEW_WINDOW_HEIGHT);
+ }
+ alignPanel.validate();
+ alignPanel.repaint();
}
-
public AlignViewport getAlignViewport()
{
return viewport;
@@ -164,34 +150,76 @@ public class AlignFrame extends Frame
public void parseFeaturesFile(String file)
{
+ String line = null;
try
{
- URL url = new URL(file);
+ BufferedReader in = null;
+ java.io.InputStream is = getClass().getResourceAsStream("/" + file);
+ if (is != null)
+ {
+ in = new BufferedReader(new java.io.InputStreamReader(is));
+ }
+ else
+ {
+ URL url = new URL(file);
+ in = new BufferedReader(new InputStreamReader(url.openStream()));
+ }
- BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
SequenceI seq = null;
- String line, type, desc, token;
+ String type, desc, token;
int index, start, end;
StringTokenizer st;
SequenceFeature sf;
FeatureRenderer fr = alignPanel.seqPanel.seqCanvas.getFeatureRenderer();
- int lineNo = 0;
+ String featureGroup = null, groupLink = null;
+ Hashtable typeLink = new Hashtable();
+
while ( (line = in.readLine()) != null)
{
- lineNo++;
st = new StringTokenizer(line, "\t");
- if (st.countTokens() == 2)
+ if(!st.hasMoreTokens())
+ continue;
+
+ if (st.countTokens() < 4)
{
type = st.nextToken();
- UserColourScheme ucs = new UserColourScheme(st.nextToken());
- fr.setColour(type, ucs.findColour("A"));
+ if(type.equalsIgnoreCase("startgroup"))
+ {
+ featureGroup = st.nextToken();
+ if (st.hasMoreElements())
+ {
+ groupLink = st.nextToken();
+ fr.addFeatureLink(featureGroup, groupLink);
+ }
+ }
+ else if(type.equalsIgnoreCase("endgroup"))
+ {
+ //We should check whether this is the current group,
+ //but at present theres no way of showing more than 1 group
+ st.nextToken();
+ featureGroup = null;
+ groupLink = null;
+ }
+ else
+ {
+ UserColourScheme ucs = new UserColourScheme(st.nextToken());
+ fr.setColour(type, ucs.findColour("A"));
+ if (st.hasMoreElements())
+ {
+ String link = st.nextToken();
+ typeLink.put(type, link);
+ fr.addFeatureLink(type, link);
+ }
+
+ }
continue;
}
while (st.hasMoreElements())
{
desc = st.nextToken();
+
token = st.nextToken();
if (!token.equals("ID_NOT_SPECIFIED"))
{
@@ -208,8 +236,6 @@ public class AlignFrame extends Frame
end = Integer.parseInt(st.nextToken());
seq = viewport.alignment.getSequenceAt(index);
- start = seq.findIndex(start) - 1;
- end = seq.findIndex(end) - 1;
type = st.nextToken();
@@ -220,27 +246,370 @@ public class AlignFrame extends Frame
fr.setColour(type, ucs.findColour("A"));
}
- sf = new SequenceFeature(type, desc, "", start, end);
-
+ sf = new SequenceFeature(type, desc, start, end, 0f, featureGroup);
seq.addSequenceFeature(sf);
+
+ if(groupLink!=null)
+ {
+ sf.addLink(groupLink);
+ sf.description += "%LINK%";
+ }
+ if(typeLink.containsKey(type))
+ {
+ sf.addLink(typeLink.get(type).toString());
+ sf.description += "%LINK%";
+ }
+
+ parseDescriptionHTML(sf);
}
}
viewport.showSequenceFeatures = true;
+ sequenceFeatures.setState(true);
alignPanel.repaint();
}
catch (Exception ex)
{
- System.out.println("Error parsing groups file: " + ex);
+ ex.printStackTrace();
+ System.out.println("Error parsing groups file: " + ex +"\n"+line);
}
}
+ void parseDescriptionHTML(SequenceFeature sf)
+ {
+ StringBuffer sb = new StringBuffer();
+ StringTokenizer st = new StringTokenizer(sf.getDescription(), "<");
+ String token, link;
+ while(st.hasMoreElements())
+ {
+ token = st.nextToken("<>");
+ if(token.equalsIgnoreCase("html") || token.startsWith("/"))
+ continue;
+
+ if(token.startsWith("a href="))
+ {
+ link = token.substring(token.indexOf("\"")+1, token.length()-1);
+ String label = st.nextToken("<>");
+ sf.addLink(label+"|"+link);
+ sb.append(label+"%LINK%");
+ }
+ else if(token.equalsIgnoreCase("br"))
+ sb.append("\n");
+ else
+ sb.append(token);
+ }
+
+ sf.description = sb.toString();
+ }
- public void inputText_actionPerformed(ActionEvent e)
+ public void keyPressed(KeyEvent evt)
{
- CutAndPasteTransfer cap = new CutAndPasteTransfer(true, applet);
+ if (viewport.cursorMode
+ && evt.getKeyCode() >= KeyEvent.VK_0
+ && evt.getKeyCode() <= KeyEvent.VK_9)
+ {
+ alignPanel.seqPanel.numberPressed(evt.getKeyChar());
+ }
+
+ switch (evt.getKeyCode())
+ {
+ case 27: // escape key
+ deselectAllSequenceMenuItem_actionPerformed();
+ break;
+ case KeyEvent.VK_X:
+ if (evt.isControlDown() || evt.isMetaDown())
+ {
+ cut_actionPerformed();
+ }
+ break;
+ case KeyEvent.VK_C:
+ if (viewport.cursorMode)
+ {
+ alignPanel.seqPanel.setCursorColumn();
+ }
+ if (evt.isControlDown() || evt.isMetaDown())
+ {
+ copy_actionPerformed();
+ }
+ break;
+ case KeyEvent.VK_V:
+ if (evt.isControlDown() || evt.isMetaDown())
+ {
+ paste(true);
+ }
+ break;
+ case KeyEvent.VK_A:
+ if (evt.isControlDown() || evt.isMetaDown())
+ {
+ selectAllSequenceMenuItem_actionPerformed();
+ }
+ break;
+ case KeyEvent.VK_DOWN:
+ if(viewport.cursorMode)
+ {
+ alignPanel.seqPanel.moveCursor(0,1);
+ }
+ else
+ moveSelectedSequences(false);
+ break;
+
+ case KeyEvent.VK_UP:
+ if (viewport.cursorMode)
+ {
+ alignPanel.seqPanel.moveCursor(0,-1);
+ }
+ else
+ moveSelectedSequences(true);
+ break;
+
+ case KeyEvent.VK_LEFT:
+ if(viewport.cursorMode)
+ {
+ alignPanel.seqPanel.moveCursor(-1,0);
+ }
+ break;
+
+ case KeyEvent.VK_RIGHT:
+ if (viewport.cursorMode)
+ {
+ alignPanel.seqPanel.moveCursor(1,0);
+ }
+ break;
+ case KeyEvent.VK_SPACE:
+ if(viewport.cursorMode)
+ {
+ alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown());
+ }
+ break;
+
+ case KeyEvent.VK_DELETE:
+ case KeyEvent.VK_BACK_SPACE:
+ if(viewport.cursorMode)
+ {
+ alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown());
+ }
+ else
+ {
+ cut_actionPerformed();
+ alignPanel.seqPanel.seqCanvas.repaint();
+ }
+ break;
+
+ case KeyEvent.VK_S:
+ if(viewport.cursorMode)
+ {
+ alignPanel.seqPanel.setCursorRow();
+ }
+ break;
+ case KeyEvent.VK_P:
+ if(viewport.cursorMode)
+ {
+ alignPanel.seqPanel.setCursorPosition();
+ }
+ break;
+
+ case KeyEvent.VK_ENTER:
+ case KeyEvent.VK_COMMA:
+ if(viewport.cursorMode)
+ {
+ alignPanel.seqPanel.setCursorRowAndColumn();
+ }
+ break;
+
+ case KeyEvent.VK_Q:
+ if(viewport.cursorMode)
+ {
+ alignPanel.seqPanel.setSelectionAreaAtCursor(true);
+ }
+ break;
+ case KeyEvent.VK_M:
+ if(viewport.cursorMode)
+ {
+ alignPanel.seqPanel.setSelectionAreaAtCursor(false);
+ }
+ break;
+
+ case KeyEvent.VK_F2:
+ viewport.cursorMode = ! viewport.cursorMode;
+ statusBar.setText("Keyboard editing mode is "+
+ (viewport.cursorMode ? "on" : "off"));
+ if(viewport.cursorMode)
+ {
+ alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
+ alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
+ }
+ alignPanel.seqPanel.seqCanvas.repaint();
+ break;
+
+ case KeyEvent.VK_F:
+ if (evt.isControlDown())
+ {
+ findMenuItem_actionPerformed();
+ }
+ break;
+ }
+ }
+ public void keyReleased(KeyEvent evt)
+ {}
+ public void keyTyped(KeyEvent evt)
+ {}
+
+public void itemStateChanged(ItemEvent evt)
+ {
+ if(evt.getSource()==colourTextMenuItem)
+ colourTextMenuItem_actionPerformed();
+ else if(evt.getSource()==wrapMenuItem)
+ wrapMenuItem_actionPerformed();
+ else if(evt.getSource()==scaleAbove)
+ scaleAbove_actionPerformed();
+ else if(evt.getSource()==scaleLeft)
+ scaleLeft_actionPerformed();
+ else if(evt.getSource()==scaleRight)
+ scaleRight_actionPerformed();
+ else if(evt.getSource()==seqLimits)
+ seqLimits_itemStateChanged();
+ else if(evt.getSource()==viewBoxesMenuItem)
+ viewBoxesMenuItem_actionPerformed();
+ else if(evt.getSource()==viewTextMenuItem)
+ viewTextMenuItem_actionPerformed();
+ else if(evt.getSource()==renderGapsMenuItem)
+ renderGapsMenuItem_actionPerformed();
+ else if(evt.getSource()==annotationPanelMenuItem)
+ annotationPanelMenuItem_actionPerformed();
+ else if(evt.getSource()==sequenceFeatures)
+ {
+ viewport.showSequenceFeatures(sequenceFeatures.getState());
+ alignPanel.seqPanel.seqCanvas.repaint();
+ }
+ else if(evt.getSource()==conservationMenuItem)
+ conservationMenuItem_actionPerformed();
+ else if(evt.getSource()==abovePIDThreshold)
+ abovePIDThreshold_actionPerformed();
+ else if(evt.getSource()==applyToAllGroups)
+ applyToAllGroups_actionPerformed();
+ else if(evt.getSource()==autoCalculate)
+ viewport.autocalculateConsensus = autoCalculate.getState();
+ }
+ public void actionPerformed(ActionEvent evt)
+ {
+ if(evt.getSource()==inputText)
+ inputText_actionPerformed();
+ else if(evt.getSource()==loadTree)
+ loadTree_actionPerformed();
+ else if(evt.getSource()==closeMenuItem)
+ closeMenuItem_actionPerformed();
+ else if(evt.getSource()==copy)
+ copy_actionPerformed();
+ else if(evt.getSource()==undoMenuItem)
+ undoMenuItem_actionPerformed();
+ else if(evt.getSource()==redoMenuItem)
+ redoMenuItem_actionPerformed();
+ else if(evt.getSource()==inputText)
+ inputText_actionPerformed();
+ else if(evt.getSource()==closeMenuItem)
+ closeMenuItem_actionPerformed();
+ else if(evt.getSource()==undoMenuItem)
+ undoMenuItem_actionPerformed();
+ else if(evt.getSource()==redoMenuItem)
+ redoMenuItem_actionPerformed();
+ else if(evt.getSource()==copy)
+ copy_actionPerformed();
+ else if(evt.getSource()==pasteNew)
+ pasteNew_actionPerformed();
+ else if(evt.getSource()==pasteThis)
+ pasteThis_actionPerformed();
+ else if(evt.getSource()==cut)
+ cut_actionPerformed();
+ else if(evt.getSource()==delete)
+ delete_actionPerformed();
+ else if(evt.getSource()==deleteGroups)
+ deleteGroups_actionPerformed();
+ else if(evt.getSource()==selectAllSequenceMenuItem)
+ selectAllSequenceMenuItem_actionPerformed();
+ else if(evt.getSource()==deselectAllSequenceMenuItem)
+ deselectAllSequenceMenuItem_actionPerformed();
+ else if(evt.getSource()==invertSequenceMenuItem)
+ invertSequenceMenuItem_actionPerformed();
+ else if(evt.getSource()==remove2LeftMenuItem)
+ remove2LeftMenuItem_actionPerformed();
+ else if(evt.getSource()==remove2RightMenuItem)
+ remove2RightMenuItem_actionPerformed();
+ else if(evt.getSource()==removeGappedColumnMenuItem)
+ removeGappedColumnMenuItem_actionPerformed();
+ else if(evt.getSource()==removeAllGapsMenuItem)
+ removeAllGapsMenuItem_actionPerformed();
+ else if(evt.getSource()==findMenuItem)
+ findMenuItem_actionPerformed();
+ else if(evt.getSource()==font)
+ font_actionPerformed();
+ else if(evt.getSource()==featureSettings)
+ featureSettings_actionPerformed();
+ else if(evt.getSource()==overviewMenuItem)
+ overviewMenuItem_actionPerformed();
+ else if(evt.getSource()==noColourmenuItem)
+ noColourmenuItem_actionPerformed();
+ else if(evt.getSource()==clustalColour)
+ clustalColour_actionPerformed();
+ else if(evt.getSource()==zappoColour)
+ zappoColour_actionPerformed();
+ else if(evt.getSource()==taylorColour)
+ taylorColour_actionPerformed();
+ else if(evt.getSource()==hydrophobicityColour)
+ hydrophobicityColour_actionPerformed();
+ else if(evt.getSource()==helixColour)
+ helixColour_actionPerformed();
+ else if(evt.getSource()==strandColour)
+ strandColour_actionPerformed();
+ else if(evt.getSource()==turnColour)
+ turnColour_actionPerformed();
+ else if(evt.getSource()==buriedColour)
+ buriedColour_actionPerformed();
+ else if(evt.getSource()==nucleotideColour)
+ nucleotideColour_actionPerformed();
+ else if(evt.getSource()==modifyPID)
+ modifyPID_actionPerformed();
+ else if(evt.getSource()==modifyConservation)
+ modifyConservation_actionPerformed();
+ else if(evt.getSource()==userDefinedColour)
+ userDefinedColour_actionPerformed();
+ else if(evt.getSource()==PIDColour)
+ PIDColour_actionPerformed();
+ else if(evt.getSource()==BLOSUM62Colour)
+ BLOSUM62Colour_actionPerformed();
+ else if(evt.getSource()==annotationColour)
+ new AnnotationColourChooser(viewport, alignPanel);
+ else if(evt.getSource()==sortPairwiseMenuItem)
+ sortPairwiseMenuItem_actionPerformed();
+ else if(evt.getSource()==sortIDMenuItem)
+ sortIDMenuItem_actionPerformed();
+ else if(evt.getSource()==sortGroupMenuItem)
+ sortGroupMenuItem_actionPerformed();
+ else if(evt.getSource()==removeRedundancyMenuItem)
+ removeRedundancyMenuItem_actionPerformed();
+ else if(evt.getSource()==pairwiseAlignmentMenuItem)
+ pairwiseAlignmentMenuItem_actionPerformed();
+ else if(evt.getSource()==PCAMenuItem)
+ PCAMenuItem_actionPerformed();
+ else if(evt.getSource()==averageDistanceTreeMenuItem)
+ averageDistanceTreeMenuItem_actionPerformed();
+ else if(evt.getSource()==neighbourTreeMenuItem)
+ neighbourTreeMenuItem_actionPerformed();
+ else if(evt.getSource()==njTreeBlosumMenuItem)
+ njTreeBlosumMenuItem_actionPerformed();
+ else if(evt.getSource()==avDistanceTreeBlosumMenuItem)
+ avTreeBlosumMenuItem_actionPerformed();
+ else if(evt.getSource()==documentation)
+ documentation_actionPerformed();
+ else if(evt.getSource()==about)
+ about_actionPerformed();
+
+ }
+
+ public void inputText_actionPerformed()
+ {
+ CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
Frame frame = new Frame();
frame.add(cap);
jalview.bin.JalviewLite.addFrame(frame, "Cut & Paste Input", 500, 500);
@@ -248,7 +617,7 @@ public class AlignFrame extends Frame
protected void outputText_actionPerformed(ActionEvent e)
{
- CutAndPasteTransfer cap = new CutAndPasteTransfer(false, applet);
+ CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
Frame frame = new Frame();
frame.add(cap);
jalview.bin.JalviewLite.addFrame(frame,
@@ -259,11 +628,13 @@ public class AlignFrame extends Frame
viewport.showJVSuffix));
}
- public void closeMenuItem_actionPerformed(ActionEvent e)
+ public void closeMenuItem_actionPerformed()
{
PaintRefresher.components.remove(viewport.alignment);
if(PaintRefresher.components.size()==0 && applet==null)
System.exit(0);
+
+ this.dispose();
}
Stack historyList = new Stack();
@@ -302,7 +673,7 @@ public class AlignFrame extends Frame
updateEditMenuBar();
}
- protected void undoMenuItem_actionPerformed(ActionEvent e)
+ protected void undoMenuItem_actionPerformed()
{
HistoryItem hi = (HistoryItem) historyList.pop();
redoList.push(new HistoryItem(hi.getDescription(), viewport.alignment,
@@ -311,7 +682,7 @@ public class AlignFrame extends Frame
viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
}
- protected void redoMenuItem_actionPerformed(ActionEvent e)
+ protected void redoMenuItem_actionPerformed()
{
HistoryItem hi = (HistoryItem) redoList.pop();
restoreHistoryItem(hi);
@@ -322,41 +693,7 @@ public class AlignFrame extends Frame
// used by undo and redo
void restoreHistoryItem(HistoryItem hi)
{
- if (hi.getType() == HistoryItem.SORT)
- {
- for (int i = 0; i < hi.getSequences().size(); i++)
- {
- viewport.alignment.getSequences().setElementAt(hi.getSequences().
- elementAt(i), i);
- }
- }
- else
- {
- for (int i = 0; i < hi.getSequences().size(); i++)
- {
- SequenceI restore = (SequenceI) hi.getSequences().elementAt(i);
- if (restore.getLength() == 0)
- {
- // log.System.out.println(hi.getHidden().elementAt(i));
- restore.setSequence(hi.getHidden().elementAt(i).toString());
- viewport.alignment.getSequences().insertElementAt(
- restore,
- hi.getAlignIndex(i));
- }
- else
- {
- restore.setSequence(hi.getHidden().elementAt(i).toString());
- }
- }
- if (hi.getType() == HistoryItem.PASTE)
- {
- for (int i = viewport.alignment.getHeight() - 1;
- i > hi.getSequences().size() - 1; i--)
- {
- viewport.alignment.deleteSequence(i);
- }
- }
- }
+ hi.restore();
updateEditMenuBar();
@@ -416,7 +753,7 @@ public class AlignFrame extends Frame
}
StringBuffer copiedSequences;
- protected void copy_actionPerformed(ActionEvent e)
+ protected void copy_actionPerformed()
{
if (viewport.getSelectionGroup() == null)
{
@@ -486,12 +823,12 @@ public class AlignFrame extends Frame
}
- protected void pasteNew_actionPerformed(ActionEvent e)
+ protected void pasteNew_actionPerformed()
{
paste(true);
}
- protected void pasteThis_actionPerformed(ActionEvent e)
+ protected void pasteThis_actionPerformed()
{
addHistoryItem(new HistoryItem("Paste Sequences", viewport.alignment,
HistoryItem.PASTE));
@@ -543,7 +880,10 @@ public class AlignFrame extends Frame
{
newtitle = newtitle.concat("- from " + getTitle());
}
- AlignFrame af = new AlignFrame(new Alignment(newSeqs), applet, newtitle);
+ AlignFrame af = new AlignFrame(new Alignment(newSeqs),
+ applet,
+ newtitle,
+ false);
jalview.bin.JalviewLite.addFrame(af, newtitle, NEW_WINDOW_WIDTH,
NEW_WINDOW_HEIGHT);
@@ -561,13 +901,13 @@ public class AlignFrame extends Frame
}
- protected void cut_actionPerformed(ActionEvent e)
+ protected void cut_actionPerformed()
{
- copy_actionPerformed(null);
- delete_actionPerformed(null);
+ copy_actionPerformed();
+ delete_actionPerformed();
}
- protected void delete_actionPerformed(ActionEvent e)
+ protected void delete_actionPerformed()
{
addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment,
HistoryItem.HIDE));
@@ -622,7 +962,7 @@ public class AlignFrame extends Frame
}
- protected void deleteGroups_actionPerformed(ActionEvent e)
+ protected void deleteGroups_actionPerformed()
{
viewport.alignment.deleteAllGroups();
viewport.setSelectionGroup(null);
@@ -630,7 +970,7 @@ public class AlignFrame extends Frame
alignPanel.repaint();
}
- public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
+ public void selectAllSequenceMenuItem_actionPerformed()
{
SequenceGroup sg = new SequenceGroup();
for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
@@ -643,17 +983,23 @@ public class AlignFrame extends Frame
PaintRefresher.Refresh(null, viewport.alignment);
}
- public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
+ public void deselectAllSequenceMenuItem_actionPerformed()
{
+ if(viewport.cursorMode)
+ {
+ alignPanel.seqPanel.keyboardNo1=null;
+ alignPanel.seqPanel.keyboardNo2=null;
+ }
viewport.setSelectionGroup(null);
viewport.getColumnSelection().clear();
viewport.setSelectionGroup(null);
+ alignPanel.idPanel.idCanvas.searchResults = null;
alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
alignPanel.repaint();
PaintRefresher.Refresh(null, viewport.alignment);
}
- public void invertSequenceMenuItem_actionPerformed(ActionEvent e)
+ public void invertSequenceMenuItem_actionPerformed()
{
SequenceGroup sg = viewport.getSelectionGroup();
for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
@@ -664,7 +1010,7 @@ public class AlignFrame extends Frame
PaintRefresher.Refresh(null, viewport.alignment);
}
- public void remove2LeftMenuItem_actionPerformed(ActionEvent e)
+ public void remove2LeftMenuItem_actionPerformed()
{
ColumnSelection colSel = viewport.getColumnSelection();
if (colSel.size() > 0)
@@ -693,7 +1039,7 @@ public class AlignFrame extends Frame
}
}
- public void remove2RightMenuItem_actionPerformed(ActionEvent e)
+ public void remove2RightMenuItem_actionPerformed()
{
ColumnSelection colSel = viewport.getColumnSelection();
if (colSel.size() > 0)
@@ -721,7 +1067,7 @@ public class AlignFrame extends Frame
}
- public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
+ public void removeGappedColumnMenuItem_actionPerformed()
{
addHistoryItem(new HistoryItem("Remove Gapped Columns",
viewport.alignment,
@@ -739,7 +1085,7 @@ public class AlignFrame extends Frame
viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
}
- public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
+ public void removeAllGapsMenuItem_actionPerformed()
{
addHistoryItem(new HistoryItem("Remove Gaps", viewport.alignment,
HistoryItem.HIDE));
@@ -818,11 +1164,18 @@ public class AlignFrame extends Frame
public void alignmentChanged()
{
- viewport.updateConsensus();
- viewport.updateConservation ();
+ viewport.alignment.padGaps();
+ if(viewport.autocalculateConsensus)
+ {
+ viewport.updateConsensus();
+ viewport.updateConservation();
+ }
+
resetAllColourSchemes();
if(alignPanel.overviewPanel!=null)
alignPanel.overviewPanel.updateOverviewImage();
+
+ viewport.alignment.adjustSequenceAnnotations();
alignPanel.repaint();
}
@@ -867,18 +1220,18 @@ public class AlignFrame extends Frame
- public void findMenuItem_actionPerformed(ActionEvent e)
+ public void findMenuItem_actionPerformed()
{
new Finder(alignPanel);
}
- public void font_actionPerformed(ActionEvent e)
+ public void font_actionPerformed()
{
new FontChooser(alignPanel);
}
- public void seqLimits_itemStateChanged(ItemEvent e)
+ public void seqLimits_itemStateChanged()
{
viewport.setShowJVSuffix(seqLimits.getState());
alignPanel.fontChanged();
@@ -886,13 +1239,13 @@ public class AlignFrame extends Frame
}
- protected void colourTextMenuItem_actionPerformed(ActionEvent e)
+ protected void colourTextMenuItem_actionPerformed()
{
viewport.setColourText(colourTextMenuItem.getState());
alignPanel.repaint();
}
- protected void wrapMenuItem_actionPerformed(ActionEvent e)
+ protected void wrapMenuItem_actionPerformed()
{
viewport.setWrapAlignment(wrapMenuItem.getState());
alignPanel.setWrapAlignment(wrapMenuItem.getState());
@@ -902,49 +1255,54 @@ public class AlignFrame extends Frame
alignPanel.repaint();
}
- protected void scaleAbove_actionPerformed(ActionEvent e)
+ protected void scaleAbove_actionPerformed()
{
viewport.setScaleAboveWrapped(scaleAbove.getState());
alignPanel.repaint();
}
- protected void scaleLeft_actionPerformed(ActionEvent e)
+ protected void scaleLeft_actionPerformed()
{
viewport.setScaleLeftWrapped(scaleLeft.getState());
alignPanel.repaint();
}
- protected void scaleRight_actionPerformed(ActionEvent e)
+ protected void scaleRight_actionPerformed()
{
viewport.setScaleRightWrapped(scaleRight.getState());
alignPanel.repaint();
}
- public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
+ public void viewBoxesMenuItem_actionPerformed()
{
viewport.setShowBoxes(viewBoxesMenuItem.getState());
alignPanel.repaint();
}
- public void viewTextMenuItem_actionPerformed(ActionEvent e)
+ public void viewTextMenuItem_actionPerformed()
{
viewport.setShowText(viewTextMenuItem.getState());
alignPanel.repaint();
}
- protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
+ protected void renderGapsMenuItem_actionPerformed()
{
viewport.setRenderGaps(renderGapsMenuItem.getState());
alignPanel.repaint();
}
- public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
+ public void annotationPanelMenuItem_actionPerformed()
{
viewport.setShowAnnotation(annotationPanelMenuItem.getState());
alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState());
}
- public void overviewMenuItem_actionPerformed(ActionEvent e)
+ public void featureSettings_actionPerformed()
+ {
+ new FeatureSettings(viewport, alignPanel);
+ }
+
+ public void overviewMenuItem_actionPerformed()
{
if (alignPanel.overviewPanel != null)
{
@@ -972,59 +1330,59 @@ public class AlignFrame extends Frame
}
- protected void noColourmenuItem_actionPerformed(ActionEvent e)
+ protected void noColourmenuItem_actionPerformed()
{
changeColour(null);
}
- public void clustalColour_actionPerformed(ActionEvent e)
+ public void clustalColour_actionPerformed()
{
abovePIDThreshold.setState(false);
changeColour(new ClustalxColourScheme(viewport.alignment.getSequences(),
viewport.alignment.getWidth()));
}
- public void zappoColour_actionPerformed(ActionEvent e)
+ public void zappoColour_actionPerformed()
{
changeColour(new ZappoColourScheme());
}
- public void taylorColour_actionPerformed(ActionEvent e)
+ public void taylorColour_actionPerformed()
{
changeColour(new TaylorColourScheme());
}
- public void hydrophobicityColour_actionPerformed(ActionEvent e)
+ public void hydrophobicityColour_actionPerformed()
{
changeColour(new HydrophobicColourScheme());
}
- public void helixColour_actionPerformed(ActionEvent e)
+ public void helixColour_actionPerformed()
{
changeColour(new HelixColourScheme());
}
- public void strandColour_actionPerformed(ActionEvent e)
+ public void strandColour_actionPerformed()
{
changeColour(new StrandColourScheme());
}
- public void turnColour_actionPerformed(ActionEvent e)
+ public void turnColour_actionPerformed()
{
changeColour(new TurnColourScheme());
}
- public void buriedColour_actionPerformed(ActionEvent e)
+ public void buriedColour_actionPerformed()
{
changeColour(new BuriedColourScheme());
}
- public void nucleotideColour_actionPerformed(ActionEvent e)
+ public void nucleotideColour_actionPerformed()
{
changeColour(new NucleotideColourScheme());
}
- protected void applyToAllGroups_actionPerformed(ActionEvent e)
+ protected void applyToAllGroups_actionPerformed()
{
viewport.setColourAppliesToAllGroups(applyToAllGroups.getState());
}
@@ -1145,7 +1503,7 @@ public class AlignFrame extends Frame
- protected void modifyPID_actionPerformed(ActionEvent e)
+ protected void modifyPID_actionPerformed()
{
if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme!=null)
{
@@ -1155,7 +1513,7 @@ public class AlignFrame extends Frame
}
}
- protected void modifyConservation_actionPerformed(ActionEvent e)
+ protected void modifyConservation_actionPerformed()
{
if (viewport.getConservationSelected() && viewport.globalColourScheme!=null)
{
@@ -1165,7 +1523,7 @@ public class AlignFrame extends Frame
}
}
- protected void conservationMenuItem_actionPerformed(ActionEvent e)
+ protected void conservationMenuItem_actionPerformed()
{
viewport.setConservationSelected(conservationMenuItem.getState());
@@ -1174,10 +1532,10 @@ public class AlignFrame extends Frame
changeColour(viewport.getGlobalColourScheme());
- modifyConservation_actionPerformed(null);
+ modifyConservation_actionPerformed();
}
- public void abovePIDThreshold_actionPerformed(ActionEvent e)
+ public void abovePIDThreshold_actionPerformed()
{
viewport.setAbovePIDThreshold(abovePIDThreshold.getState());
@@ -1186,25 +1544,25 @@ public class AlignFrame extends Frame
changeColour(viewport.getGlobalColourScheme());
- modifyPID_actionPerformed(null);
+ modifyPID_actionPerformed();
}
- public void userDefinedColour_actionPerformed(ActionEvent e)
+ public void userDefinedColour_actionPerformed()
{
new UserDefinedColours(alignPanel, null);
}
- public void PIDColour_actionPerformed(ActionEvent e)
+ public void PIDColour_actionPerformed()
{
changeColour(new PIDColourScheme());
}
- public void BLOSUM62Colour_actionPerformed(ActionEvent e)
+ public void BLOSUM62Colour_actionPerformed()
{
changeColour(new Blosum62ColourScheme());
}
- public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
+ public void sortPairwiseMenuItem_actionPerformed()
{
addHistoryItem(new HistoryItem("Pairwise Sort", viewport.alignment,
HistoryItem.SORT));
@@ -1213,7 +1571,7 @@ public class AlignFrame extends Frame
alignPanel.repaint();
}
- public void sortIDMenuItem_actionPerformed(ActionEvent e)
+ public void sortIDMenuItem_actionPerformed()
{
addHistoryItem(new HistoryItem("ID Sort", viewport.alignment,
HistoryItem.SORT));
@@ -1221,7 +1579,7 @@ public class AlignFrame extends Frame
alignPanel.repaint();
}
- public void sortGroupMenuItem_actionPerformed(ActionEvent e)
+ public void sortGroupMenuItem_actionPerformed()
{
addHistoryItem(new HistoryItem("Group Sort", viewport.alignment,
HistoryItem.SORT));
@@ -1230,7 +1588,7 @@ public class AlignFrame extends Frame
}
- public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
+ public void removeRedundancyMenuItem_actionPerformed()
{
RedundancyPanel sp = new RedundancyPanel(alignPanel);
Frame frame = new Frame();
@@ -1240,7 +1598,7 @@ public class AlignFrame extends Frame
}
- public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
+ public void pairwiseAlignmentMenuItem_actionPerformed()
{
if (viewport.getSelectionGroup().getSize() > 1)
{
@@ -1250,7 +1608,7 @@ public class AlignFrame extends Frame
}
}
- public void PCAMenuItem_actionPerformed(ActionEvent e)
+ public void PCAMenuItem_actionPerformed()
{
//are the sequences aligned?
if (!viewport.alignment.isAligned())
@@ -1289,22 +1647,22 @@ public class AlignFrame extends Frame
}
- public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)
+ public void averageDistanceTreeMenuItem_actionPerformed()
{
NewTreePanel("AV", "PID", "Average distance tree using PID");
}
- public void neighbourTreeMenuItem_actionPerformed(ActionEvent e)
+ public void neighbourTreeMenuItem_actionPerformed()
{
NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
}
- protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e)
+ protected void njTreeBlosumMenuItem_actionPerformed()
{
NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
}
- protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)
+ protected void avTreeBlosumMenuItem_actionPerformed()
{
NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62PID");
}
@@ -1350,13 +1708,34 @@ public class AlignFrame extends Frame
jalview.bin.JalviewLite.addFrame(tp, title, 600, 500);
}
+ void loadTree_actionPerformed()
+ {
+ TreePanel tp = null;
+
+ CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
+ cap.setText("Paste your Newick tree file here.");
+ cap.treeImport = true;
+ Frame frame = new Frame();
+ frame.add(cap);
+ jalview.bin.JalviewLite.addFrame(frame, "Paste Newick file ", 400, 300);
+ }
+
+ public void loadTree(jalview.io.NewickFile tree, String treeFile)
+ {
+ TreePanel tp = new TreePanel(viewport,
+ viewport.getAlignment().getSequences(),
+ tree, "From File - ", treeFile);
+ jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
+ addTreeMenuItem(tp, treeFile);
+ }
+
void addTreeMenuItem(final TreePanel treePanel, String title)
{
final MenuItem item = new MenuItem(title);
sortByTreeMenu.add(item);
item.addActionListener(new java.awt.event.ActionListener()
{
- public void actionPerformed(ActionEvent e)
+ public void actionPerformed(ActionEvent evt)
{
addHistoryItem(new HistoryItem("Sort", viewport.alignment,
HistoryItem.SORT));
@@ -1374,12 +1753,12 @@ public class AlignFrame extends Frame
});
}
- protected void documentation_actionPerformed(ActionEvent e)
+ protected void documentation_actionPerformed()
{
- showURL("http://www.jalview.org/help.html");
+ showURL("http://www.jalview.org/help.html", "HELP");
}
- protected void about_actionPerformed(ActionEvent e)
+ protected void about_actionPerformed()
{
class AboutPanel extends Canvas
@@ -1410,7 +1789,7 @@ public class AlignFrame extends Frame
g.drawString("If you use JalView, please cite:", x, y += fh + 8);
g.drawString("\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"",
x, y += fh);
- g.drawString("Bioinformatics, 2004 12;426-7.", x, y += fh);
+ g.drawString("Bioinformatics, 2004 20;426-7.", x, y += fh);
}
}
@@ -1444,17 +1823,6 @@ public class AlignFrame extends Frame
}
- /**
- * Displays the given URL in a new browser window
- *
- * @param url URL to display in browser window.
- *
New window will be named "HELP_WINDOW"
- */
- public void showURL(String url)
- {
- showURL(url, "HELP");
- }
-
public void showURL(String url, String target)
{
if (applet == null)
@@ -1480,15 +1848,16 @@ public class AlignFrame extends Frame
//JBuilder Graphics here
protected MenuBar alignFrameMenuBar = new MenuBar();
- protected Menu fileMenu = new Menu();
- protected MenuItem closeMenuItem = new MenuItem();
- protected Menu editMenu = new Menu();
- protected Menu viewMenu = new Menu();
- protected Menu colourMenu = new Menu();
- protected Menu calculateMenu = new Menu();
- protected MenuItem selectAllSequenceMenuItem = new MenuItem();
- protected MenuItem deselectAllSequenceMenuItem = new MenuItem();
- protected MenuItem invertSequenceMenuItem = new MenuItem();
+ protected Menu fileMenu = new Menu("File");
+ protected MenuItem loadTree = new MenuItem("Load Associated Tree");
+ protected MenuItem closeMenuItem = new MenuItem("Close");
+ protected Menu editMenu = new Menu("Edit");
+ protected Menu viewMenu = new Menu("View");
+ protected Menu colourMenu = new Menu("Colour");
+ protected Menu calculateMenu = new Menu("Calculate");
+ protected MenuItem selectAllSequenceMenuItem = new MenuItem("Select all");
+ protected MenuItem deselectAllSequenceMenuItem = new MenuItem("Deselect All");
+ protected MenuItem invertSequenceMenuItem = new MenuItem("Invert Selection");
protected MenuItem remove2LeftMenuItem = new MenuItem();
protected MenuItem remove2RightMenuItem = new MenuItem();
protected MenuItem removeGappedColumnMenuItem = new MenuItem();
@@ -1536,7 +1905,7 @@ public class AlignFrame extends Frame
MenuItem delete = new MenuItem();
MenuItem copy = new MenuItem();
MenuItem cut = new MenuItem();
- Menu Menu1 = new Menu();
+ Menu pasteMenu = new Menu();
MenuItem pasteNew = new MenuItem();
MenuItem pasteThis = new MenuItem();
protected CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem();
@@ -1546,6 +1915,8 @@ public class AlignFrame extends Frame
protected CheckboxMenuItem scaleRight = new CheckboxMenuItem();
MenuItem modifyPID = new MenuItem();
MenuItem modifyConservation = new MenuItem();
+ protected CheckboxMenuItem autoCalculate
+ = new CheckboxMenuItem("Autocalculate Consensus", true);
protected Menu sortByTreeMenu = new Menu();
Menu sort = new Menu();
Menu calculate = new Menu();
@@ -1554,8 +1925,17 @@ public class AlignFrame extends Frame
MenuItem documentation = new MenuItem();
MenuItem about = new MenuItem();
protected CheckboxMenuItem seqLimits = new CheckboxMenuItem();
-
- private void jbInit() throws Exception {
+ Panel embeddedMenu;
+ Label embeddedEdit;
+ Label embeddedSearch;
+ Label embeddedView;
+ Label embeddedColour;
+ Label embeddedFile;
+ Label embeddedHelp;
+ Label embeddedCalculate;
+ FlowLayout flowLayout1;
+
+ private void jbInit() throws Exception {
setMenuBar(alignFrameMenuBar);
@@ -1578,124 +1958,43 @@ public class AlignFrame extends Frame
outputTextboxMenu.add(item);
}
+ closeMenuItem.addActionListener(this);
-
- fileMenu.setLabel("File");
- closeMenuItem.setLabel("Close");
- closeMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- closeMenuItem_actionPerformed(e);
- }
- });
- editMenu.setLabel("Edit");
- viewMenu.setLabel("View");
- colourMenu.setLabel("Colour");
- calculateMenu.setLabel("Calculate");
- selectAllSequenceMenuItem.setLabel("Select all");
- selectAllSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- selectAllSequenceMenuItem_actionPerformed(e);
- }
- });
- deselectAllSequenceMenuItem.setLabel("Deselect All");
- deselectAllSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- deselectAllSequenceMenuItem_actionPerformed(e);
- }
- });
- invertSequenceMenuItem.setLabel("Invert Selection");
- invertSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- invertSequenceMenuItem_actionPerformed(e);
- }
- });
+ loadTree.addActionListener(this);
+ selectAllSequenceMenuItem.addActionListener(this);
+ deselectAllSequenceMenuItem.addActionListener(this);
+ invertSequenceMenuItem.addActionListener(this);
remove2LeftMenuItem.setLabel("Remove Left");
- remove2LeftMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- remove2LeftMenuItem_actionPerformed(e);
- }
- });
+ remove2LeftMenuItem.addActionListener(this);
remove2RightMenuItem.setLabel("Remove Right");
- remove2RightMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- remove2RightMenuItem_actionPerformed(e);
- }
- });
+ remove2RightMenuItem.addActionListener(this);
removeGappedColumnMenuItem.setLabel("Remove Empty Columns");
- removeGappedColumnMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- removeGappedColumnMenuItem_actionPerformed(e);
- }
- });
+ removeGappedColumnMenuItem.addActionListener(this);
removeAllGapsMenuItem.setLabel("Remove All Gaps");
- removeAllGapsMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- removeAllGapsMenuItem_actionPerformed(e);
- }
- });
+ removeAllGapsMenuItem.addActionListener(this);
viewBoxesMenuItem.setLabel("Boxes");
viewBoxesMenuItem.setState(true);
- viewBoxesMenuItem.addItemListener(new java.awt.event.ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- viewBoxesMenuItem_actionPerformed(null);
- }
- });
+ viewBoxesMenuItem.addItemListener(this);
viewTextMenuItem.setLabel("Text");
viewTextMenuItem.setState(true);
- viewTextMenuItem.addItemListener(new java.awt.event.ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- viewTextMenuItem_actionPerformed(null);
- }
- });
+ viewTextMenuItem.addItemListener(this);
sortPairwiseMenuItem.setLabel("by Pairwise Identity");
- sortPairwiseMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- sortPairwiseMenuItem_actionPerformed(e);
- }
- });
+ sortPairwiseMenuItem.addActionListener(this);
sortIDMenuItem.setLabel("by ID");
- sortIDMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- sortIDMenuItem_actionPerformed(e);
- }
- });
+ sortIDMenuItem.addActionListener(this);
sortGroupMenuItem.setLabel("by Group");
- sortGroupMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- sortGroupMenuItem_actionPerformed(e);
- }
- });
+ sortGroupMenuItem.addActionListener(this);
removeRedundancyMenuItem.setLabel("Remove Redundancy...");
- removeRedundancyMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- removeRedundancyMenuItem_actionPerformed(e);
- }
- });
+ removeRedundancyMenuItem.addActionListener(this);
pairwiseAlignmentMenuItem.setLabel("Pairwise Alignments...");
- pairwiseAlignmentMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- pairwiseAlignmentMenuItem_actionPerformed(e);
- }
- });
+ pairwiseAlignmentMenuItem.addActionListener(this);
PCAMenuItem.setLabel("Principal Component Analysis");
- PCAMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- PCAMenuItem_actionPerformed(e);
- }
- });
+ PCAMenuItem.addActionListener(this);
averageDistanceTreeMenuItem.setLabel(
"Average Distance Using % Identity");
- averageDistanceTreeMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- averageDistanceTreeMenuItem_actionPerformed(e);
- }
- });
+ averageDistanceTreeMenuItem.addActionListener(this);
neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity");
- neighbourTreeMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- neighbourTreeMenuItem_actionPerformed(e);
- }
- });
+ neighbourTreeMenuItem.addActionListener(this);
alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11));
statusBar.setBackground(Color.white);
statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
@@ -1703,281 +2002,118 @@ public class AlignFrame extends Frame
outputTextboxMenu.setLabel("Output to Textbox");
clustalColour.setLabel("Clustalx");
- clustalColour.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- clustalColour_actionPerformed(e);
- }
- });
+ clustalColour.addActionListener(this);
zappoColour.setLabel("Zappo");
- zappoColour.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- zappoColour_actionPerformed(e);
- }
- });
+ zappoColour.addActionListener(this);
taylorColour.setLabel("Taylor");
- taylorColour.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- taylorColour_actionPerformed(e);
- }
- });
+ taylorColour.addActionListener(this);
hydrophobicityColour.setLabel("Hydrophobicity");
- hydrophobicityColour.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- hydrophobicityColour_actionPerformed(e);
- }
- });
+ hydrophobicityColour.addActionListener(this);
helixColour.setLabel("Helix Propensity");
- helixColour.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- helixColour_actionPerformed(e);
- }
- });
+ helixColour.addActionListener(this);
strandColour.setLabel("Strand Propensity");
- strandColour.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- strandColour_actionPerformed(e);
- }
- });
+ strandColour.addActionListener(this);
turnColour.setLabel("Turn Propensity");
- turnColour.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- turnColour_actionPerformed(e);
- }
- });
+ turnColour.addActionListener(this);
buriedColour.setLabel("Buried Index");
- buriedColour.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- buriedColour_actionPerformed(e);
- }
- });
+ buriedColour.addActionListener(this);
userDefinedColour.setLabel("User Defined...");
- userDefinedColour.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- userDefinedColour_actionPerformed(e);
- }
- });
+ userDefinedColour.addActionListener(this);
PIDColour.setLabel("Percentage Identity");
- PIDColour.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- PIDColour_actionPerformed(e);
- }
- });
+ PIDColour.addActionListener(this);
BLOSUM62Colour.setLabel("BLOSUM62 Score");
- BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- BLOSUM62Colour_actionPerformed(e);
- }
- });
+ BLOSUM62Colour.addActionListener(this);
avDistanceTreeBlosumMenuItem.setLabel(
"Average Distance Using BLOSUM62");
- avDistanceTreeBlosumMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- avTreeBlosumMenuItem_actionPerformed(e);
- }
- });
+ avDistanceTreeBlosumMenuItem.addActionListener(this);
njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62");
- njTreeBlosumMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- njTreeBlosumMenuItem_actionPerformed(e);
- }
- });
- annotationPanelMenuItem.setActionCommand("");
- annotationPanelMenuItem.setState(true);
+ njTreeBlosumMenuItem.addActionListener(this);
annotationPanelMenuItem.setLabel("Show Annotations");
- annotationPanelMenuItem.addItemListener(new java.awt.event.ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- annotationPanelMenuItem_actionPerformed(null);
- }
- });
+ annotationPanelMenuItem.addItemListener(this);
colourTextMenuItem.setLabel("Colour Text");
- colourTextMenuItem.addItemListener(new java.awt.event.ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- colourTextMenuItem_actionPerformed(null);
- }
- });
+ colourTextMenuItem.addItemListener(this);
overviewMenuItem.setLabel("Overview Window");
- overviewMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- overviewMenuItem_actionPerformed(e);
- }
- });
+ overviewMenuItem.addActionListener(this);
undoMenuItem.setEnabled(false);
undoMenuItem.setLabel("Undo");
- undoMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- undoMenuItem_actionPerformed(e);
- }
- });
+ undoMenuItem.addActionListener(this);
redoMenuItem.setEnabled(false);
redoMenuItem.setLabel("Redo");
- redoMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- redoMenuItem_actionPerformed(e);
- }
- });
+ redoMenuItem.addActionListener(this);
conservationMenuItem.setLabel("by Conservation");
- conservationMenuItem.addItemListener(new java.awt.event.ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- conservationMenuItem_actionPerformed(null);
- }
- });
+ conservationMenuItem.addItemListener(this);
noColourmenuItem.setLabel("None");
- noColourmenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- noColourmenuItem_actionPerformed(e);
- }
- });
+ noColourmenuItem.addActionListener(this);
wrapMenuItem.setLabel("Wrap");
- wrapMenuItem.addItemListener(new java.awt.event.ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- wrapMenuItem_actionPerformed(null);
- }
- });
+ wrapMenuItem.addItemListener(this);
renderGapsMenuItem.setLabel("Show Gaps");
renderGapsMenuItem.setState(true);
- renderGapsMenuItem.addItemListener(new java.awt.event.ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- renderGapsMenuItem_actionPerformed(null);
- }
- });
+ renderGapsMenuItem.addItemListener(this);
findMenuItem.setLabel("Find...");
- findMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- findMenuItem_actionPerformed(e);
- }
- });
+ findMenuItem.addActionListener(this);
searchMenu.setLabel("Search");
abovePIDThreshold.setLabel("Above Identity Threshold");
- abovePIDThreshold.addItemListener(new java.awt.event.ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- abovePIDThreshold_actionPerformed(null);
- }
- });
+ abovePIDThreshold.addItemListener(this);
nucleotideColour.setLabel("Nucleotide");
- nucleotideColour.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- nucleotideColour_actionPerformed(e);
- }
- });
+ nucleotideColour.addActionListener(this);
deleteGroups.setLabel("Undefine Groups");
- deleteGroups.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- deleteGroups_actionPerformed(e);
- }
- });
+ deleteGroups.addActionListener(this);
copy.setLabel("Copy");
- copy.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- copy_actionPerformed(e);
- }
- });
+ copy.addActionListener(this);
cut.setLabel("Cut");
- cut.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- cut_actionPerformed(e);
- }
- });
+ cut.addActionListener(this);
delete.setLabel("Delete");
- delete.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- delete_actionPerformed(e);
- }
- });
- Menu1.setLabel("Paste");
+ delete.addActionListener(this);
+ pasteMenu.setLabel("Paste");
pasteNew.setLabel("To New Alignment");
- pasteNew.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- pasteNew_actionPerformed(e);
- }
- });
+ pasteNew.addActionListener(this);
pasteThis.setLabel("Add To This Alignment");
- pasteThis.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- pasteThis_actionPerformed(e);
- }
- });
+ pasteThis.addActionListener(this);
applyToAllGroups.setLabel("Apply Colour To All Groups");
applyToAllGroups.setState(true);
- applyToAllGroups.addItemListener(new java.awt.event.ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- applyToAllGroups_actionPerformed(null);
- }
- });
+ applyToAllGroups.addItemListener(this);
font.setLabel("Font...");
- font.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- font_actionPerformed(e);
- }
- });
+ font.addActionListener(this);
scaleAbove.setLabel("Scale Above");
scaleAbove.setState(true);
- scaleAbove.addItemListener(new java.awt.event.ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- scaleAbove_actionPerformed(null);
- }
- });
+ scaleAbove.setEnabled(false);
+ scaleAbove.addItemListener(this);
scaleLeft.setEnabled(false);
scaleLeft.setState(true);
scaleLeft.setLabel("Scale Left");
- scaleLeft.addItemListener(new java.awt.event.ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- scaleLeft_actionPerformed(null);
- }
- });
+ scaleLeft.addItemListener(this);
scaleRight.setEnabled(false);
scaleRight.setState(true);
scaleRight.setLabel("Scale Right");
- scaleRight.addItemListener(new java.awt.event.ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- scaleRight_actionPerformed(null);
- }
- });
+ scaleRight.addItemListener(this);
modifyPID.setLabel("Modify Identity Threshold...");
- modifyPID.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- modifyPID_actionPerformed(e);
- }
- });
+ modifyPID.addActionListener(this);
modifyConservation.setLabel("Modify Conservation Threshold...");
- modifyConservation.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- modifyConservation_actionPerformed(e);
- }
- });
+ modifyConservation.addActionListener(this);
sortByTreeMenu.setLabel("By Tree Order");
sort.setLabel("Sort");
calculate.setLabel("Calculate Tree");
+ autoCalculate.addItemListener(this);
inputText.setLabel("Input from textbox");
- inputText.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- inputText_actionPerformed(e);
- }
- });
+ inputText.addActionListener(this);
helpMenu.setLabel("Help");
documentation.setLabel("Documentation");
- documentation.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- documentation_actionPerformed(e);
- }
- });
+ documentation.addActionListener(this);
about.setLabel("About...");
- about.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(ActionEvent e) {
- about_actionPerformed(e);
- }
- });
+ about.addActionListener(this);
seqLimits.setState(true);
seqLimits.setLabel("Show Sequence Limits");
- seqLimits.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e)
- {
- seqLimits_itemStateChanged(e);
- }
- });
+ seqLimits.addItemListener(this);
+ featureSettings.setLabel("Feature Settings...");
+ featureSettings.addActionListener(this);
+ sequenceFeatures.setLabel("Sequence Features");
+ sequenceFeatures.addItemListener(this);
+ sequenceFeatures.setState(false);
+ annotationColour.setLabel("by Annotation...");
+ annotationColour.addActionListener(this);
alignFrameMenuBar.add(fileMenu);
alignFrameMenuBar.add(editMenu);
@@ -1989,12 +2125,13 @@ public class AlignFrame extends Frame
fileMenu.add(inputText);
fileMenu.add(outputTextboxMenu);
fileMenu.addSeparator();
+ fileMenu.add(loadTree);
fileMenu.add(closeMenuItem);
editMenu.add(undoMenuItem);
editMenu.add(redoMenuItem);
editMenu.add(cut);
editMenu.add(copy);
- editMenu.add(Menu1);
+ editMenu.add(pasteMenu);
editMenu.add(delete);
editMenu.addSeparator();
editMenu.add(selectAllSequenceMenuItem);
@@ -2010,7 +2147,7 @@ public class AlignFrame extends Frame
searchMenu.add(findMenuItem);
viewMenu.add(font);
viewMenu.addSeparator();
- viewMenu.add(seqLimits);
+ viewMenu.add(seqLimits);
viewMenu.addSeparator();
viewMenu.add(wrapMenuItem);
viewMenu.add(scaleAbove);
@@ -2022,7 +2159,10 @@ public class AlignFrame extends Frame
viewMenu.add(colourTextMenuItem);
viewMenu.add(renderGapsMenuItem);
viewMenu.add(annotationPanelMenuItem);
- viewMenu.addSeparator();
+ viewMenu.addSeparator();
+ viewMenu.add(sequenceFeatures);
+ viewMenu.add(featureSettings);
+ viewMenu.addSeparator();
viewMenu.add(overviewMenuItem);
colourMenu.add(applyToAllGroups);
colourMenu.addSeparator();
@@ -2044,14 +2184,16 @@ public class AlignFrame extends Frame
colourMenu.add(modifyConservation);
colourMenu.add(abovePIDThreshold);
colourMenu.add(modifyPID);
- calculateMenu.add(sort);
+ colourMenu.add(annotationColour);
+ calculateMenu.add(sort);
calculateMenu.add(calculate);
calculateMenu.addSeparator();
calculateMenu.add(pairwiseAlignmentMenuItem);
calculateMenu.add(PCAMenuItem);
+ calculateMenu.add(autoCalculate);
this.add(statusBar, BorderLayout.SOUTH);
- Menu1.add(pasteNew);
- Menu1.add(pasteThis);
+ pasteMenu.add(pasteNew);
+ pasteMenu.add(pasteThis);
sort.add(sortIDMenuItem);
sort.add(sortByTreeMenu);
sort.add(sortGroupMenuItem);
@@ -2062,6 +2204,143 @@ public class AlignFrame extends Frame
calculate.add(njTreeBlosumMenuItem);
helpMenu.add(documentation);
helpMenu.add(about);
+ }
+
+ public void setEmbedded()
+ {
+
+ embeddedMenu = new Panel();
+ embeddedEdit = new Label();
+ embeddedSearch = new Label();
+ embeddedView = new Label();
+ embeddedColour = new Label();
+ embeddedFile = new Label();
+ embeddedHelp = new Label();
+ embeddedCalculate = new Label();
+ flowLayout1 = new FlowLayout();
+ embeddedMenu.setBackground(Color.lightGray);
+ embeddedMenu.setLayout(flowLayout1);
+ embeddedEdit.setText("Edit");
+ embeddedEdit.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
+ embeddedSearch.setText("Search");
+ embeddedSearch.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
+ embeddedView.setText("View");
+ embeddedView.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
+ embeddedColour.setText("Colour");
+ embeddedColour.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
+ embeddedFile.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
+ embeddedFile.setText("File");
+ embeddedHelp.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
+ embeddedHelp.setText("Help");
+ embeddedCalculate.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
+ embeddedCalculate.setText("Calculate");
+ embeddedMenu.add(embeddedFile);
+ embeddedMenu.add(embeddedEdit);
+ embeddedMenu.add(embeddedSearch);
+ embeddedMenu.add(embeddedView);
+ embeddedMenu.add(embeddedColour);
+ embeddedMenu.add(embeddedCalculate);
+ embeddedMenu.add(embeddedHelp);
+ flowLayout1.setAlignment(FlowLayout.LEFT);
+ flowLayout1.setHgap(2);
+ flowLayout1.setVgap(0);
+ embeddedFile.addMouseListener(this);
+ embeddedEdit.addMouseListener(this);
+ embeddedSearch.addMouseListener(this);
+ embeddedView.addMouseListener(this);
+ embeddedColour.addMouseListener(this);
+ embeddedCalculate.addMouseListener(this);
+ embeddedHelp.addMouseListener(this);
+
+ // setVisible(false);
+ fileMenu.remove(closeMenuItem);
+ fileMenu.remove(2); // Seperator
+
+ applet.setLayout(new BorderLayout());
+ applet.add(embeddedMenu, BorderLayout.NORTH);
+ applet.add(statusBar, BorderLayout.SOUTH);
+ // applet.validate();
+
+ alignPanel.setSize(applet.size().width, applet.size().height
+ - embeddedMenu.HEIGHT - statusBar.HEIGHT);
+
+ applet.add(alignPanel, BorderLayout.CENTER);
+ applet.validate();
+
+ }
+
+
+
+ PopupMenu filePopup, editPopup, searchPopup,
+ viewPopup, colourPopup, calculatePopup, helpPopup;
+ MenuItem featureSettings = new MenuItem();
+ CheckboxMenuItem sequenceFeatures = new CheckboxMenuItem();
+ MenuItem annotationColour = new MenuItem();
+
+ public void mousePressed(MouseEvent evt)
+ {
+ PopupMenu popup = null;
+ Label source = (Label)evt.getSource();
+ if(source==embeddedFile)
+ {
+ popup = filePopup = genPopupMenu(filePopup, fileMenu);
}
+ else if(source==embeddedEdit)
+ {
+ popup = editPopup = genPopupMenu(editPopup, editMenu);
+ }
+ else if(source==embeddedSearch)
+ {
+ popup = searchPopup = genPopupMenu(searchPopup, searchMenu);
+ }
+ else if(source==embeddedView)
+ {
+ popup = viewPopup = genPopupMenu(viewPopup, viewMenu);
+ }
+ else if(source==embeddedColour)
+ {
+ popup = colourPopup = genPopupMenu(colourPopup, colourMenu);
+ }
+ else if(source==embeddedCalculate)
+ {
+ popup = calculatePopup = genPopupMenu(calculatePopup, calculateMenu);
+ }
+ else if(source==embeddedHelp)
+ {
+ popup = helpPopup = genPopupMenu(helpPopup, helpMenu);
+ }
+
+ embeddedMenu.add(popup);
+ popup.show(embeddedMenu,
+ source.getBounds().x,
+ source.getBounds().y + source.getBounds().getSize().height);
+ }
+
+ PopupMenu genPopupMenu(PopupMenu popup, Menu original)
+ {
+ if(popup!=null)
+ {
+ return popup;
+ }
+ popup = new PopupMenu();
+ int m, mSize = original.getItemCount();
+ for(m=0; m