ST-MOTIF ac25a1
STARTGROUP uniprot
-<html><a href="http://pfam.xfam.org/family/PF00111">Pfam family</a></html> FER_CAPAA -1 0 0 Pfam
Iron-sulfur (2Fe-2S) FER_CAPAA -1 39 39 METAL
Iron-sulfur (2Fe-2S) FER_CAPAA -1 44 44 METAL
Iron-sulfur (2Fe-2S) FER_CAPAA -1 47 47 METAL
Iron-sulfur (2Fe-2S) FER_CAPAA -1 77 77 METAL
+<html><a href="http://pfam.xfam.org/family/PF00111">Pfam family</a></html> FER_CAPAA -1 0 0 Pfam
<html>Fer2 Status: True Positive <a href="http://pfam.xfam.org/family/PF00111">Pfam 8_8</a></html> FER_CAPAA -1 8 83 Pfam
Ferredoxin_fold Status: True Positive FER_CAPAA -1 3 93 Cath
Iron-sulfur (2Fe-2S) FER_CAPAN -1 86 86 METAL
@Override
public void mousePressed(MouseEvent evt)
{
- if (evt.isPopupTrigger())
+ if (evt.isPopupTrigger()) // Mac
{
- radioItem.removeActionListener(radioItem.getActionListeners()[0]);
-
- int option = JOptionPane.showInternalConfirmDialog(
- jalview.gui.Desktop.desktop,
- MessageManager
- .getString("label.remove_from_default_list"),
- MessageManager
- .getString("label.remove_user_defined_colour"),
- JOptionPane.YES_NO_OPTION);
- if (option == JOptionPane.YES_OPTION)
- {
- jalview.gui.UserDefinedColours
- .removeColourFromDefaults(radioItem.getText());
- coloursMenu.remove(radioItem);
- }
- else
+ offerRemoval(radioItem);
+ }
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent evt)
+ {
+ if (evt.isPopupTrigger()) // Windows
+ {
+ offerRemoval(radioItem);
+ }
+ }
+
+ /**
+ * @param radioItem
+ */
+ void offerRemoval(final JRadioButtonMenuItem radioItem)
+ {
+ radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+
+ int option = JOptionPane.showInternalConfirmDialog(
+ jalview.gui.Desktop.desktop,
+ MessageManager
+ .getString("label.remove_from_default_list"),
+ MessageManager
+ .getString("label.remove_user_defined_colour"),
+ JOptionPane.YES_NO_OPTION);
+ if (option == JOptionPane.YES_OPTION)
+ {
+ jalview.gui.UserDefinedColours
+ .removeColourFromDefaults(radioItem.getText());
+ coloursMenu.remove(radioItem);
+ }
+ else
+ {
+ radioItem.addActionListener(new ActionListener()
{
- radioItem.addActionListener(new ActionListener()
+ @Override
+ public void actionPerformed(ActionEvent evt)
{
- @Override
- public void actionPerformed(ActionEvent evt)
- {
- user_actionPerformed(evt);
- }
- });
- }
+ user_actionPerformed(evt);
+ }
+ });
}
}
});
*/
public class NJTree
{
- Vector cluster;
+ Vector<Cluster> cluster;
SequenceI[] sequence;
float rj;
- Vector groups = new Vector();
+ Vector<SequenceNode> groups = new Vector<SequenceNode>();
SequenceNode maxdist;
int ycount;
- Vector node;
+ Vector<SequenceNode> node;
String type;
Object found = null;
- Object leaves = null;
-
boolean hasDistances = true; // normal case for jalview trees
boolean hasBootstrap = false; // normal case for jalview trees
SequenceIdMatcher algnIds = new SequenceIdMatcher(seqs);
- Vector leaves = new Vector();
- findLeaves(top, leaves);
+ Vector<SequenceNode> leaves = findLeaves(top);
int i = 0;
int namesleft = seqs.length;
SequenceNode j;
SequenceI nam;
String realnam;
- Vector one2many = new Vector();
+ Vector<SequenceI> one2many = new Vector<SequenceI>();
int countOne2Many = 0;
while (i < leaves.size())
{
- j = (SequenceNode) leaves.elementAt(i++);
+ j = leaves.elementAt(i++);
realnam = j.getName();
nam = null;
String pwtype, ScoreModelI sm, int start, int end)
{
this.sequence = sequence;
- this.node = new Vector();
+ this.node = new Vector<SequenceNode>();
this.type = type;
this.pwtype = pwtype;
if (seqData != null)
*
* @return Newick File with all tree data available
*/
+ @Override
public String toString()
{
jalview.io.NewickFile fout = new jalview.io.NewickFile(getTopNode());
*/
public void UpdatePlaceHolders(List<SequenceI> list)
{
- Vector leaves = new Vector();
- findLeaves(top, leaves);
+ Vector<SequenceNode> leaves = findLeaves(top);
int sz = leaves.size();
SequenceIdMatcher seqmatcher = null;
while (i < sz)
{
- SequenceNode leaf = (SequenceNode) leaves.elementAt(i++);
+ SequenceNode leaf = leaves.elementAt(i++);
if (list.contains(leaf.element()))
{
{
@Override
- public void transform(BinaryNode node)
+ public void transform(BinaryNode nd)
{
- Object el = node.element();
+ Object el = nd.element();
if (el != null && el instanceof SequenceI)
{
- node.setName(((SequenceI) el).getName());
+ nd.setName(((SequenceI) el).getName());
}
}
});
}
joinClusters(one, two);
- top = (SequenceNode) (node.elementAt(one));
+ top = (node.elementAt(one));
reCount(top);
findHeight(top);
{
float dist = distance[i][j];
- int noi = ((Cluster) cluster.elementAt(i)).value.length;
- int noj = ((Cluster) cluster.elementAt(j)).value.length;
+ int noi = cluster.elementAt(i).value.length;
+ int noj = cluster.elementAt(j).value.length;
int[] value = new int[noi + noj];
for (int ii = 0; ii < noi; ii++)
{
- value[ii] = ((Cluster) cluster.elementAt(i)).value[ii];
+ value[ii] = cluster.elementAt(i).value[ii];
}
for (int ii = noi; ii < (noi + noj); ii++)
{
- value[ii] = ((Cluster) cluster.elementAt(j)).value[ii - noi];
+ value[ii] = cluster.elementAt(j).value[ii - noi];
}
Cluster c = new Cluster(value);
SequenceNode sn = new SequenceNode();
- sn.setLeft((SequenceNode) (node.elementAt(i)));
- sn.setRight((SequenceNode) (node.elementAt(j)));
+ sn.setLeft((node.elementAt(i)));
+ sn.setRight((node.elementAt(j)));
- SequenceNode tmpi = (SequenceNode) (node.elementAt(i));
- SequenceNode tmpj = (SequenceNode) (node.elementAt(j));
+ SequenceNode tmpi = (node.elementAt(i));
+ SequenceNode tmpj = (node.elementAt(j));
if (type.equals("NJ"))
{
*/
public void findClusterDistance(int i, int j)
{
- int noi = ((Cluster) cluster.elementAt(i)).value.length;
- int noj = ((Cluster) cluster.elementAt(j)).value.length;
+ int noi = cluster.elementAt(i).value.length;
+ int noj = cluster.elementAt(j).value.length;
// New distances from cluster to others
float[] newdist = new float[noseqs];
public float[][] findDistances(ScoreModelI _pwmatrix)
{
- float[][] distance = new float[noseqs][noseqs];
+ float[][] dist = new float[noseqs][noseqs];
if (_pwmatrix == null)
{
// Resolve substitution model
_pwmatrix = ResidueProperties.getScoreMatrix("BLOSUM62");
}
}
- distance = _pwmatrix.findDistances(seqData);
- return distance;
+ dist = _pwmatrix.findDistances(seqData);
+ return dist;
}
*/
public void makeLeaves()
{
- cluster = new Vector();
+ cluster = new Vector<Cluster>();
for (int i = 0; i < noseqs; i++)
{
}
/**
+ * Search for leaf nodes below (or at) the given node
+ *
+ * @param nd
+ * root node to search from
+ *
+ * @return
+ */
+ public Vector<SequenceNode> findLeaves(SequenceNode nd)
+ {
+ Vector<SequenceNode> leaves = new Vector<SequenceNode>();
+ findLeaves(nd, leaves);
+ return leaves;
+ }
+
+ /**
* Search for leaf nodes.
*
- * @param node
+ * @param nd
* root node to search from
* @param leaves
* Vector of leaves to add leaf node objects too.
*
* @return Vector of leaf nodes on binary tree
*/
- public Vector findLeaves(SequenceNode node, Vector leaves)
+ Vector<SequenceNode> findLeaves(SequenceNode nd,
+ Vector<SequenceNode> leaves)
{
- if (node == null)
+ if (nd == null)
{
return leaves;
}
- if ((node.left() == null) && (node.right() == null)) // Interior node
+ if ((nd.left() == null) && (nd.right() == null)) // Interior node
// detection
{
- leaves.addElement(node);
+ leaves.addElement(nd);
return leaves;
}
* TODO: Identify internal nodes... if (node.isSequenceLabel()) {
* leaves.addElement(node); }
*/
- findLeaves((SequenceNode) node.left(), leaves);
- findLeaves((SequenceNode) node.right(), leaves);
+ findLeaves((SequenceNode) nd.left(), leaves);
+ findLeaves((SequenceNode) nd.right(), leaves);
}
return leaves;
/**
* Find the leaf node with a particular ycount
*
- * @param node
+ * @param nd
* initial point on tree to search from
* @param count
* value to search for
*
* @return null or the node with ycound=count
*/
- public Object findLeaf(SequenceNode node, int count)
+ public Object findLeaf(SequenceNode nd, int count)
{
- found = _findLeaf(node, count);
+ found = _findLeaf(nd, count);
return found;
}
/*
* #see findLeaf(SequenceNode node, count)
*/
- public Object _findLeaf(SequenceNode node, int count)
+ public Object _findLeaf(SequenceNode nd, int count)
{
- if (node == null)
+ if (nd == null)
{
return null;
}
- if (node.ycount == count)
+ if (nd.ycount == count)
{
- found = node.element();
+ found = nd.element();
return found;
}
else
{
- _findLeaf((SequenceNode) node.left(), count);
- _findLeaf((SequenceNode) node.right(), count);
+ _findLeaf((SequenceNode) nd.left(), count);
+ _findLeaf((SequenceNode) nd.right(), count);
}
return found;
/**
* printNode is mainly for debugging purposes.
*
- * @param node
+ * @param nd
* SequenceNode
*/
- public void printNode(SequenceNode node)
+ public void printNode(SequenceNode nd)
{
- if (node == null)
+ if (nd == null)
{
return;
}
- if ((node.left() == null) && (node.right() == null))
+ if ((nd.left() == null) && (nd.right() == null))
{
System.out
- .println("Leaf = " + ((SequenceI) node.element()).getName());
- System.out.println("Dist " + node.dist);
- System.out.println("Boot " + node.getBootstrap());
+ .println("Leaf = " + ((SequenceI) nd.element()).getName());
+ System.out.println("Dist " + nd.dist);
+ System.out.println("Boot " + nd.getBootstrap());
}
else
{
- System.out.println("Dist " + node.dist);
- printNode((SequenceNode) node.left());
- printNode((SequenceNode) node.right());
+ System.out.println("Dist " + nd.dist);
+ printNode((SequenceNode) nd.left());
+ printNode((SequenceNode) nd.right());
}
}
/**
* DOCUMENT ME!
*
- * @param node
+ * @param nd
* DOCUMENT ME!
*/
- public void findMaxDist(SequenceNode node)
+ public void findMaxDist(SequenceNode nd)
{
- if (node == null)
+ if (nd == null)
{
return;
}
- if ((node.left() == null) && (node.right() == null))
+ if ((nd.left() == null) && (nd.right() == null))
{
- float dist = node.dist;
+ float dist = nd.dist;
if (dist > maxDistValue)
{
- maxdist = node;
+ maxdist = nd;
maxDistValue = dist;
}
}
else
{
- findMaxDist((SequenceNode) node.left());
- findMaxDist((SequenceNode) node.right());
+ findMaxDist((SequenceNode) nd.left());
+ findMaxDist((SequenceNode) nd.right());
}
}
*
* @return DOCUMENT ME!
*/
- public Vector getGroups()
+ public Vector<SequenceNode> getGroups()
{
return groups;
}
/**
* DOCUMENT ME!
*
- * @param node
+ * @param nd
* DOCUMENT ME!
* @param threshold
* DOCUMENT ME!
*/
- public void groupNodes(SequenceNode node, float threshold)
+ public void groupNodes(SequenceNode nd, float threshold)
{
- if (node == null)
+ if (nd == null)
{
return;
}
- if ((node.height / maxheight) > threshold)
+ if ((nd.height / maxheight) > threshold)
{
- groups.addElement(node);
+ groups.addElement(nd);
}
else
{
- groupNodes((SequenceNode) node.left(), threshold);
- groupNodes((SequenceNode) node.right(), threshold);
+ groupNodes((SequenceNode) nd.left(), threshold);
+ groupNodes((SequenceNode) nd.right(), threshold);
}
}
/**
* DOCUMENT ME!
*
- * @param node
+ * @param nd
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
- public float findHeight(SequenceNode node)
+ public float findHeight(SequenceNode nd)
{
- if (node == null)
+ if (nd == null)
{
return maxheight;
}
- if ((node.left() == null) && (node.right() == null))
+ if ((nd.left() == null) && (nd.right() == null))
{
- node.height = ((SequenceNode) node.parent()).height + node.dist;
+ nd.height = ((SequenceNode) nd.parent()).height + nd.dist;
- if (node.height > maxheight)
+ if (nd.height > maxheight)
{
- return node.height;
+ return nd.height;
}
else
{
}
else
{
- if (node.parent() != null)
+ if (nd.parent() != null)
{
- node.height = ((SequenceNode) node.parent()).height + node.dist;
+ nd.height = ((SequenceNode) nd.parent()).height + nd.dist;
}
else
{
maxheight = 0;
- node.height = (float) 0.0;
+ nd.height = (float) 0.0;
}
- maxheight = findHeight((SequenceNode) (node.left()));
- maxheight = findHeight((SequenceNode) (node.right()));
+ maxheight = findHeight((SequenceNode) (nd.left()));
+ maxheight = findHeight((SequenceNode) (nd.right()));
}
return maxheight;
/**
* DOCUMENT ME!
*
- * @param node
+ * @param nd
* DOCUMENT ME!
*/
- public void printN(SequenceNode node)
+ public void printN(SequenceNode nd)
{
- if (node == null)
+ if (nd == null)
{
return;
}
- if ((node.left() != null) && (node.right() != null))
+ if ((nd.left() != null) && (nd.right() != null))
{
- printN((SequenceNode) node.left());
- printN((SequenceNode) node.right());
+ printN((SequenceNode) nd.left());
+ printN((SequenceNode) nd.right());
}
else
{
System.out.println(" name = "
- + ((SequenceI) node.element()).getName());
+ + ((SequenceI) nd.element()).getName());
}
- System.out.println(" dist = " + node.dist + " " + node.count + " "
- + node.height);
+ System.out.println(" dist = " + nd.dist + " " + nd.count + " "
+ + nd.height);
}
/**
* DOCUMENT ME!
*
- * @param node
+ * @param nd
* DOCUMENT ME!
*/
- public void reCount(SequenceNode node)
+ public void reCount(SequenceNode nd)
{
ycount = 0;
_lycount = 0;
// _lylimit = this.node.size();
- _reCount(node);
+ _reCount(nd);
}
private long _lycount = 0, _lylimit = 0;
/**
* DOCUMENT ME!
*
- * @param node
+ * @param nd
* DOCUMENT ME!
*/
- public void _reCount(SequenceNode node)
+ public void _reCount(SequenceNode nd)
{
// if (_lycount<_lylimit)
// {
// System.err.println("Warning: depth of _recount greater than number of nodes.");
// }
- if (node == null)
+ if (nd == null)
{
return;
}
_lycount++;
- if ((node.left() != null) && (node.right() != null))
+ if ((nd.left() != null) && (nd.right() != null))
{
- _reCount((SequenceNode) node.left());
- _reCount((SequenceNode) node.right());
+ _reCount((SequenceNode) nd.left());
+ _reCount((SequenceNode) nd.right());
- SequenceNode l = (SequenceNode) node.left();
- SequenceNode r = (SequenceNode) node.right();
+ SequenceNode l = (SequenceNode) nd.left();
+ SequenceNode r = (SequenceNode) nd.right();
- node.count = l.count + r.count;
- node.ycount = (l.ycount + r.ycount) / 2;
+ nd.count = l.count + r.count;
+ nd.ycount = (l.ycount + r.ycount) / 2;
}
else
{
- node.count = 1;
- node.ycount = ycount++;
+ nd.count = 1;
+ nd.ycount = ycount++;
}
_lycount--;
}
/**
* DOCUMENT ME!
*
- * @param node
+ * @param nd
* DOCUMENT ME!
*/
- public void swapNodes(SequenceNode node)
+ public void swapNodes(SequenceNode nd)
{
- if (node == null)
+ if (nd == null)
{
return;
}
- SequenceNode tmp = (SequenceNode) node.left();
+ SequenceNode tmp = (SequenceNode) nd.left();
- node.setLeft(node.right());
- node.setRight(tmp);
+ nd.setLeft(nd.right());
+ nd.setRight(tmp);
}
/**
* DOCUMENT ME!
*
- * @param node
+ * @param nd
* DOCUMENT ME!
* @param dir
* DOCUMENT ME!
*/
- public void changeDirection(SequenceNode node, SequenceNode dir)
+ public void changeDirection(SequenceNode nd, SequenceNode dir)
{
- if (node == null)
+ if (nd == null)
{
return;
}
- if (node.parent() != top)
+ if (nd.parent() != top)
{
- changeDirection((SequenceNode) node.parent(), node);
+ changeDirection((SequenceNode) nd.parent(), nd);
- SequenceNode tmp = (SequenceNode) node.parent();
+ SequenceNode tmp = (SequenceNode) nd.parent();
- if (dir == node.left())
+ if (dir == nd.left())
{
- node.setParent(dir);
- node.setLeft(tmp);
+ nd.setParent(dir);
+ nd.setLeft(tmp);
}
- else if (dir == node.right())
+ else if (dir == nd.right())
{
- node.setParent(dir);
- node.setRight(tmp);
+ nd.setParent(dir);
+ nd.setRight(tmp);
}
}
else
{
- if (dir == node.left())
+ if (dir == nd.left())
{
- node.setParent(node.left());
+ nd.setParent(nd.left());
- if (top.left() == node)
+ if (top.left() == nd)
{
- node.setRight(top.right());
+ nd.setRight(top.right());
}
else
{
- node.setRight(top.left());
+ nd.setRight(top.left());
}
}
else
{
- node.setParent(node.right());
+ nd.setParent(nd.right());
- if (top.left() == node)
+ if (top.left() == nd)
{
- node.setLeft(top.right());
+ nd.setLeft(top.right());
}
else
{
- node.setLeft(top.left());
+ nd.setLeft(top.left());
}
}
}
*/
public void applyToNodes(NodeTransformI nodeTransformI)
{
- for (Enumeration nodes = node.elements(); nodes.hasMoreElements(); nodeTransformI
- .transform((BinaryNode) nodes.nextElement()))
+ for (Enumeration<SequenceNode> nodes = node.elements(); nodes
+ .hasMoreElements(); nodeTransformI
+ .transform(nodes.nextElement()))
{
;
}
tree.findHeight(tree.getTopNode());
// Now have to calculate longest name based on the leaves
- Vector leaves = tree.findLeaves(tree.getTopNode(), new Vector());
+ Vector<SequenceNode> leaves = tree.findLeaves(tree.getTopNode());
boolean has_placeholders = false;
longestName = "";
for (int i = 0; i < leaves.size(); i++)
{
- SequenceNode lf = (SequenceNode) leaves.elementAt(i);
+ SequenceNode lf = leaves.elementAt(i);
if (lf.isPlaceholder())
{
}
else
{
- Vector leaves = new Vector();
- tree.findLeaves(highlightNode, leaves);
+ Vector<SequenceNode> leaves = tree.findLeaves(highlightNode);
for (int i = 0; i < leaves.size(); i++)
{
- SequenceI seq = (SequenceI) ((SequenceNode) leaves.elementAt(i))
+ SequenceI seq = (SequenceI) leaves.elementAt(i)
.element();
treeSelectionChanged(seq);
}
(int) (Math.random() * 255), (int) (Math.random() * 255));
setColor((SequenceNode) tree.getGroups().elementAt(i), col.brighter());
- Vector l = tree.findLeaves(
- (SequenceNode) tree.getGroups().elementAt(i), new Vector());
+ Vector<SequenceNode> l = tree.findLeaves((SequenceNode) tree
+ .getGroups().elementAt(i));
- Vector sequences = new Vector();
+ Vector<SequenceI> sequences = new Vector<SequenceI>();
for (int j = 0; j < l.size(); j++)
{
- SequenceI s1 = (SequenceI) ((SequenceNode) l.elementAt(j))
+ SequenceI s1 = (SequenceI) l.elementAt(j)
.element();
if (!sequences.contains(s1))
{
// diff < 5 then mark as valid and update termination Atom
if (chainTerMap.containsKey(curAtomChId))
{
+ if (curAtom.getResno() < chainTerMap.get(curAtomChId).getResno())
+ {
+ return false;
+ }
if ((curAtom.getResno() - chainTerMap.get(curAtomChId).getResno()) < 5)
{
chainTerMap.put(curAtomChId, curAtom);
// atom with previously terminated chain encountered
else if (chainTerMap.containsKey(curAtomChId))
{
+ if (curAtom.getResno() < chainTerMap.get(curAtomChId).getResno())
+ {
+ return false;
+ }
if ((curAtom.getResno() - chainTerMap.get(curAtomChId).getResno()) < 5)
{
chainTerMap.put(curAtomChId, curAtom);
@Override
public void mousePressed(MouseEvent evt)
{
- if (evt.isPopupTrigger())
+ if (evt.isPopupTrigger()) // Mac
{
- radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+ offerRemoval(radioItem);
+ }
+ }
- int option = JOptionPane.showInternalConfirmDialog(
- jalview.gui.Desktop.desktop,
- MessageManager
- .getString("label.remove_from_default_list"),
- MessageManager
- .getString("label.remove_user_defined_colour"),
- JOptionPane.YES_NO_OPTION);
- if (option == JOptionPane.YES_OPTION)
- {
- jalview.gui.UserDefinedColours
- .removeColourFromDefaults(radioItem.getText());
- colourMenu.remove(radioItem);
- }
- else
+ @Override
+ public void mouseReleased(MouseEvent evt)
+ {
+ if (evt.isPopupTrigger()) // Windows
+ {
+ offerRemoval(radioItem);
+ }
+ }
+
+ /**
+ * @param radioItem
+ */
+ void offerRemoval(final JRadioButtonMenuItem radioItem)
+ {
+ radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+
+ int option = JOptionPane.showInternalConfirmDialog(
+ jalview.gui.Desktop.desktop,
+ MessageManager
+ .getString("label.remove_from_default_list"),
+ MessageManager
+ .getString("label.remove_user_defined_colour"),
+ JOptionPane.YES_NO_OPTION);
+ if (option == JOptionPane.YES_OPTION)
+ {
+ jalview.gui.UserDefinedColours
+ .removeColourFromDefaults(radioItem.getText());
+ colourMenu.remove(radioItem);
+ }
+ else
+ {
+ radioItem.addActionListener(new ActionListener()
{
- radioItem.addActionListener(new ActionListener()
+ @Override
+ public void actionPerformed(ActionEvent evt)
{
- @Override
- public void actionPerformed(ActionEvent evt)
- {
- userDefinedColour_actionPerformed(evt);
- }
- });
- }
+ userDefinedColour_actionPerformed(evt);
+ }
+ });
}
}
});
{
getSelectedRow(evt.getY() - getScrollOffset());
oldY = evt.getY();
- if (!evt.isPopupTrigger())
+ if (evt.isPopupTrigger())
{
- return;
+ showPopupMenu(evt);
}
+ }
+
+ /**
+ * Build and show the Pop-up menu at the right-click mouse position
+ *
+ * @param evt
+ */
+ void showPopupMenu(MouseEvent evt)
+ {
evt.consume();
- // handle popup menu event
final AlignmentAnnotation[] aa = ap.av.getAlignment()
.getAlignmentAnnotation();
}
}
pop.show(this, evt.getX(), evt.getY());
-
}
/**
@Override
public void mouseReleased(MouseEvent evt)
{
+ if (evt.isPopupTrigger())
+ {
+ showPopupMenu(evt);
+ return;
+ }
+
int start = selectedRow;
getSelectedRow(evt.getY() - getScrollOffset());
int end = selectedRow;
int height = 0;
activeRow = -1;
+ final int y = evt.getY();
for (int i = 0; i < aa.length; i++)
{
if (aa[i].visible)
height += aa[i].height;
}
- if (evt.getY() < height)
+ if (y < height)
{
if (aa[i].editable)
{
{
// Stretch Graph
graphStretch = i;
- graphStretchY = evt.getY();
+ graphStretchY = y;
}
break;
}
}
+ /*
+ * isPopupTrigger fires in mousePressed on Mac,
+ * not until mouseRelease on Windows
+ */
if (evt.isPopupTrigger() && activeRow != -1)
{
- if (av.getColumnSelection() == null
- || av.getColumnSelection().isEmpty())
- {
- return;
- }
+ showPopupMenu(y, evt.getX());
+ return;
+ }
- JPopupMenu pop = new JPopupMenu(
- MessageManager.getString("label.structure_type"));
- JMenuItem item;
- /*
- * Just display the needed structure options
- */
- if (av.getAlignment().isNucleotide())
- {
- item = new JMenuItem(STEM);
- item.addActionListener(this);
- pop.add(item);
- }
- else
- {
- item = new JMenuItem(HELIX);
- item.addActionListener(this);
- pop.add(item);
- item = new JMenuItem(SHEET);
- item.addActionListener(this);
- pop.add(item);
- }
- item = new JMenuItem(LABEL);
+ ap.getScalePanel().mousePressed(evt);
+ }
+
+ /**
+ * Construct and display a context menu at the right-click position
+ *
+ * @param y
+ * @param x
+ */
+ void showPopupMenu(final int y, int x)
+ {
+ if (av.getColumnSelection() == null
+ || av.getColumnSelection().isEmpty())
+ {
+ return;
+ }
+
+ JPopupMenu pop = new JPopupMenu(
+ MessageManager.getString("label.structure_type"));
+ JMenuItem item;
+ /*
+ * Just display the needed structure options
+ */
+ if (av.getAlignment().isNucleotide())
+ {
+ item = new JMenuItem(STEM);
item.addActionListener(this);
pop.add(item);
- item = new JMenuItem(COLOUR);
+ }
+ else
+ {
+ item = new JMenuItem(HELIX);
item.addActionListener(this);
pop.add(item);
- item = new JMenuItem(REMOVE);
+ item = new JMenuItem(SHEET);
item.addActionListener(this);
pop.add(item);
- pop.show(this, evt.getX(), evt.getY());
-
- return;
}
-
- ap.getScalePanel().mousePressed(evt);
-
+ item = new JMenuItem(LABEL);
+ item.addActionListener(this);
+ pop.add(item);
+ item = new JMenuItem(COLOUR);
+ item.addActionListener(this);
+ pop.add(item);
+ item = new JMenuItem(REMOVE);
+ item.addActionListener(this);
+ pop.add(item);
+ pop.show(this, x, y);
}
/**
graphStretchY = -1;
mouseDragging = false;
ap.getScalePanel().mouseReleased(evt);
+
+ /*
+ * isPopupTrigger is set in mouseReleased on Windows
+ * (in mousePressed on Mac)
+ */
+ if (evt.isPopupTrigger() && activeRow != -1)
+ {
+ showPopupMenu(evt.getY(), evt.getX());
+ }
+
}
/**
@Override
public void textarea_mousePressed(MouseEvent e)
{
+ // isPopupTrigger is on mousePressed (Mac) or mouseReleased (Windows)
if (e.isPopupTrigger())
{
JPopupMenu popup = new JPopupMenu(
@Override
public void textarea_mousePressed(MouseEvent e)
{
+ /*
+ * isPopupTrigger is checked in mousePressed on Mac,
+ * in mouseReleased on Windows
+ */
if (e.isPopupTrigger())
{
JPopupMenu popup = new JPopupMenu(
@Override
public void mousePressed(MouseEvent evt)
{
- if (evt.isPopupTrigger())
+ if (evt.isPopupTrigger()) // Mac
+ {
+ showPasteMenu(evt.getX(), evt.getY());
+ }
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent evt)
+ {
+ if (evt.isPopupTrigger()) // Windows
{
showPasteMenu(evt.getX(), evt.getY());
}
public void mousePressed(MouseEvent evt)
{
selectedRow = table.rowAtPoint(evt.getPoint());
- boolean ctrlDown = Platform.isControlDown(evt);
- if (SwingUtilities.isRightMouseButton(evt) && !ctrlDown)
+ if (evt.isPopupTrigger())
{
popupSort(selectedRow, (String) table.getValueAt(selectedRow, 0),
table.getValueAt(selectedRow, 1), fr.getMinMax(),
else if (evt.getClickCount() == 2)
{
boolean invertSelection = evt.isAltDown();
- boolean toggleSelection = ctrlDown;
+ boolean toggleSelection = Platform.isControlDown(evt);
boolean extendSelection = evt.isShiftDown();
fr.ap.alignFrame.avc.markColumnsContainingFeatures(
invertSelection, extendSelection, toggleSelection,
}
}
- // isPopupTrigger fires on mouseReleased on Mac
+ // isPopupTrigger fires on mouseReleased on Windows
@Override
public void mouseReleased(MouseEvent evt)
{
import jalview.datamodel.SequenceI;
import jalview.io.SequenceAnnotationReport;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import jalview.util.UrlLink;
import jalview.viewmodel.AlignmentViewport;
return;
}
- int seq = alignPanel.getSeqPanel().findSeq(e);
-
- if (e.isPopupTrigger())
+ if (e.isPopupTrigger()) // Mac reports this in mousePressed
{
- Sequence sq = (Sequence) av.getAlignment().getSequenceAt(seq);
- // build a new links menu based on the current links + any non-positional
- // features
- Vector<String> nlinks = new Vector<String>(
- Preferences.sequenceURLLinks);
- SequenceFeature sfs[] = sq == null ? null : sq.getSequenceFeatures();
- if (sfs != null)
- {
- for (SequenceFeature sf : sfs)
- {
- if (sf.begin == sf.end && sf.begin == 0)
- {
- if (sf.links != null && sf.links.size() > 0)
- {
- for (int l = 0, lSize = sf.links.size(); l < lSize; l++)
- {
- nlinks.addElement(sf.links.elementAt(l));
- }
- }
- }
- }
- }
-
- PopupMenu pop = new PopupMenu(alignPanel, sq, nlinks,
- Preferences.getGroupURLLinks());
- pop.show(this, e.getX(), e.getY());
+ showPopupMenu(e);
+ return;
+ }
+ /*
+ * defer right-mouse click handling to mouseReleased on Windows
+ * (where isPopupTrigger() will answer true)
+ * NB isRightMouseButton is also true for Cmd-click on Mac
+ */
+ if (SwingUtilities.isRightMouseButton(e) && !Platform.isAMac())
+ {
return;
}
+
if ((av.getSelectionGroup() == null)
|| (!jalview.util.Platform.isControlDown(e)
&& !e.isShiftDown() && av.getSelectionGroup() != null))
av.getSelectionGroup().setEndRes(av.getAlignment().getWidth() - 1);
}
+ int seq = alignPanel.getSeqPanel().findSeq(e);
if (e.isShiftDown() && (lastid != -1))
{
selectSeqs(lastid, seq);
}
/**
+ * Build and show the popup-menu at the right-click mouse position
+ *
+ * @param e
+ */
+ void showPopupMenu(MouseEvent e)
+ {
+ int seq2 = alignPanel.getSeqPanel().findSeq(e);
+ Sequence sq = (Sequence) av.getAlignment().getSequenceAt(seq2);
+ // build a new links menu based on the current links + any non-positional
+ // features
+ Vector<String> nlinks = new Vector<String>(
+ Preferences.sequenceURLLinks);
+ SequenceFeature sfs[] = sq == null ? null : sq.getSequenceFeatures();
+ if (sfs != null)
+ {
+ for (SequenceFeature sf : sfs)
+ {
+ if (sf.begin == sf.end && sf.begin == 0)
+ {
+ if (sf.links != null && sf.links.size() > 0)
+ {
+ for (int l = 0, lSize = sf.links.size(); l < lSize; l++)
+ {
+ nlinks.addElement(sf.links.elementAt(l));
+ }
+ }
+ }
+ }
+ }
+
+ PopupMenu pop = new PopupMenu(alignPanel, sq, nlinks,
+ Preferences.getGroupURLLinks());
+ pop.show(this, e.getX(), e.getY());
+ }
+
+ /**
* Toggle whether the sequence is part of the current selection group.
*
* @param seq
PaintRefresher.Refresh(this, av.getSequenceSetId());
// always send selection message when mouse is released
av.sendSelection();
+
+ if (e.isPopupTrigger()) // Windows reports this in mouseReleased
+ {
+ showPopupMenu(e);
+ }
}
/**
@Override
public void mouseClicked(MouseEvent e)
{
- if (e.isPopupTrigger())
+ if (e.isPopupTrigger()) // for Windows
{
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
}
@Override
public void mousePressed(MouseEvent e)
{
- // TODO Auto-generated method stub
-
+ if (e.isPopupTrigger()) // Mac
+ {
+ showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
+ }
}
@Override
public void mouseReleased(MouseEvent e)
{
- // TODO Auto-generated method stub
-
}
public void resetToDefault(boolean setDefaultParams)
@Override
public void mouseClicked(MouseEvent e)
{
- if (e.isPopupTrigger())
+ if (e.isPopupTrigger()) // for Windows
{
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
}
@Override
public void mousePressed(MouseEvent e)
{
- // TODO Auto-generated method stub
-
+ if (e.isPopupTrigger()) // for Mac
+ {
+ showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
+ }
}
@Override
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
+import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
/**
min = res;
max = res;
- if (evt.isPopupTrigger())
+ if (evt.isPopupTrigger()) // Mac: mousePressed
{
rightMouseButtonPressed(evt, res);
}
+ else if (SwingUtilities.isRightMouseButton(evt) && !Platform.isAMac())
+ {
+ /*
+ * defer right-mouse click handling to mouse up on Windows
+ * (where isPopupTrigger() will answer true)
+ * but accept Cmd-click on Mac which passes isRightMouseButton
+ */
+ return;
+ }
else
{
leftMouseButtonPressed(evt, res);
*/
protected void leftMouseButtonPressed(MouseEvent evt, final int res)
{
+ /*
+ * Ctrl-click/Cmd-click adds to the selection
+ * Shift-click extends the selection
+ */
+ // TODO Problem: right-click on Windows not reported until mouseReleased?!?
if (!Platform.isControlDown(evt) && !evt.isShiftDown())
{
av.getColumnSelection().clear();
if (!stretchingGroup)
{
- ap.paintAlignment(false);
-
+ if (evt.isPopupTrigger()) // Windows: mouseReleased
+ {
+ rightMouseButtonPressed(evt, res);
+ }
+ else
+ {
+ ap.paintAlignment(false);
+ }
return;
}
import jalview.util.Comparison;
import jalview.util.MappingUtils;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import jalview.viewmodel.AlignmentViewport;
import java.awt.BorderLayout;
mouseDragging = false;
mouseWheelPressed = false;
+ if (evt.isPopupTrigger()) // Windows: mouseReleased
+ {
+ showPopupMenu(evt);
+ evt.consume();
+ return;
+ }
+
if (!editingSeqs)
{
doMouseReleasedDefineMode(evt);
*/
public void doMousePressedDefineMode(MouseEvent evt)
{
- int res = findRes(evt);
- int seq = findSeq(evt);
+ final int res = findRes(evt);
+ final int seq = findSeq(evt);
oldSeq = seq;
needOverviewUpdate = false;
av.setSelectionGroup(stretchGroup);
}
- if (evt.isPopupTrigger())
+ if (evt.isPopupTrigger()) // Mac: mousePressed
{
- List<SequenceFeature> allFeatures = ap.getFeatureRenderer()
- .findFeaturesAtRes(sequence.getDatasetSequence(),
- sequence.findPosition(res));
- List<String> links = new ArrayList<String>();
- for (SequenceFeature sf : allFeatures)
- {
- if (sf.links != null)
- {
- for (String link : sf.links)
- {
- links.add(link);
- }
- }
- }
+ showPopupMenu(evt);
+ return;
+ }
- PopupMenu pop = new PopupMenu(ap, null, links);
- pop.show(this, evt.getX(), evt.getY());
+ /*
+ * defer right-mouse click handling to mouseReleased on Windows
+ * (where isPopupTrigger() will answer true)
+ * NB isRightMouseButton is also true for Cmd-click on Mac
+ */
+ if (SwingUtilities.isRightMouseButton(evt) && !Platform.isAMac())
+ {
return;
}
}
/**
+ * Build and show a pop-up menu at the right-click mouse position
+ *
+ * @param evt
+ * @param res
+ * @param sequence
+ */
+ void showPopupMenu(MouseEvent evt)
+ {
+ final int res = findRes(evt);
+ final int seq = findSeq(evt);
+ SequenceI sequence = av.getAlignment().getSequenceAt(seq);
+ List<SequenceFeature> allFeatures = ap.getFeatureRenderer()
+ .findFeaturesAtRes(sequence.getDatasetSequence(),
+ sequence.findPosition(res));
+ List<String> links = new ArrayList<String>();
+ for (SequenceFeature sf : allFeatures)
+ {
+ if (sf.links != null)
+ {
+ for (String link : sf.links)
+ {
+ links.add(link);
+ }
+ }
+ }
+
+ PopupMenu pop = new PopupMenu(ap, null, links);
+ pop.show(this, evt.getX(), evt.getY());
+ }
+
+ /**
* DOCUMENT ME!
*
* @param evt
import javax.swing.JColorChooser;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
/**
tree.findHeight(tree.getTopNode());
// Now have to calculate longest name based on the leaves
- Vector leaves = tree.findLeaves(tree.getTopNode(), new Vector());
+ Vector<SequenceNode> leaves = tree.findLeaves(tree.getTopNode());
boolean has_placeholders = false;
longestName = "";
for (int i = 0; i < leaves.size(); i++)
{
- SequenceNode lf = (SequenceNode) leaves.elementAt(i);
+ SequenceNode lf = leaves.elementAt(i);
if (lf.isPlaceholder())
{
}
/**
- * DOCUMENT ME!
+ * Empty method to satisfy the MouseListener interface
*
* @param e
- * DOCUMENT ME!
*/
@Override
public void mouseReleased(MouseEvent e)
{
+ /*
+ * isPopupTrigger is set on mouseReleased on Windows
+ */
+ if (e.isPopupTrigger())
+ {
+ chooseSubtreeColour();
+ e.consume(); // prevent mouseClicked happening
+ }
}
/**
- * DOCUMENT ME!
+ * Empty method to satisfy the MouseListener interface
*
* @param e
- * DOCUMENT ME!
*/
@Override
public void mouseEntered(MouseEvent e)
}
/**
- * DOCUMENT ME!
+ * Empty method to satisfy the MouseListener interface
*
* @param e
- * DOCUMENT ME!
*/
@Override
public void mouseExited(MouseEvent e)
}
/**
- * DOCUMENT ME!
+ * Handles a mouse click on a tree node (clicks elsewhere are handled in
+ * mousePressed). Click selects the sub-tree, double-click swaps leaf nodes
+ * order, right-click opens a dialogue to choose colour for the sub-tree.
*
* @param e
- * DOCUMENT ME!
*/
@Override
public void mouseClicked(MouseEvent evt)
{
- if (highlightNode != null)
+ if (highlightNode == null)
{
- if (evt.isPopupTrigger())
- {
- Color col = JColorChooser.showDialog(this,
- MessageManager.getString("label.select_subtree_colour"),
- highlightNode.color);
- if (col != null)
- {
- setColor(highlightNode, col);
- }
- }
- else if (evt.getClickCount() > 1)
+ return;
+ }
+
+ if (evt.getClickCount() > 1)
+ {
+ tree.swapNodes(highlightNode);
+ tree.reCount(tree.getTopNode());
+ tree.findHeight(tree.getTopNode());
+ }
+ else
+ {
+ Vector<SequenceNode> leaves = tree.findLeaves(highlightNode);
+
+ for (int i = 0; i < leaves.size(); i++)
{
- tree.swapNodes(highlightNode);
- tree.reCount(tree.getTopNode());
- tree.findHeight(tree.getTopNode());
+ SequenceI seq = (SequenceI) leaves.elementAt(i)
+ .element();
+ treeSelectionChanged(seq);
}
- else
- {
- Vector leaves = new Vector();
- tree.findLeaves(highlightNode, leaves);
+ av.sendSelection();
+ }
- for (int i = 0; i < leaves.size(); i++)
- {
- SequenceI seq = (SequenceI) ((SequenceNode) leaves.elementAt(i))
- .element();
- treeSelectionChanged(seq);
- }
- av.sendSelection();
- }
+ PaintRefresher.Refresh(tp, av.getSequenceSetId());
+ repaint();
+ }
- PaintRefresher.Refresh(tp, av.getSequenceSetId());
+ /**
+ * Offer the user the option to choose a colour for the highlighted node and
+ * its children; this colour is also applied to the corresponding sequence ids
+ * in the alignment
+ */
+ void chooseSubtreeColour()
+ {
+ Color col = JColorChooser.showDialog(this,
+ MessageManager.getString("label.select_subtree_colour"),
+ highlightNode.color);
+ if (col != null)
+ {
+ setColor(highlightNode, col);
+ PaintRefresher.Refresh(tp, ap.av.getSequenceSetId());
repaint();
}
}
}
/**
- * DOCUMENT ME!
+ * Handles a mouse press on a sequence name or the tree background canvas
+ * (click on a node is handled in mouseClicked). The action is to create
+ * groups by partitioning the tree at the mouse position. Colours for the
+ * groups (and sequence names) are generated randomly.
*
* @param e
- * DOCUMENT ME!
*/
@Override
public void mousePressed(MouseEvent e)
{
av.setCurrentTree(tree);
+ /*
+ * isPopupTrigger is set for mousePressed (Mac)
+ * or mouseReleased (Windows)
+ */
+ if (e.isPopupTrigger())
+ {
+ if (highlightNode != null)
+ {
+ chooseSubtreeColour();
+ }
+ return;
+ }
+
+ /*
+ * defer right-click handling on Windows to
+ * mouseClicked; note isRightMouseButton
+ * also matches Cmd-click on Mac which should do
+ * nothing here
+ */
+ if (SwingUtilities.isRightMouseButton(e))
+ {
+ return;
+ }
+
int x = e.getX();
int y = e.getY();
{
Color col = new Color((int) (Math.random() * 255),
(int) (Math.random() * 255), (int) (Math.random() * 255));
- setColor((SequenceNode) tree.getGroups().elementAt(i), col.brighter());
+ setColor(tree.getGroups().elementAt(i), col.brighter());
- Vector l = tree.findLeaves(
- (SequenceNode) tree.getGroups().elementAt(i), new Vector());
+ Vector<SequenceNode> l = tree.findLeaves(tree
+ .getGroups().elementAt(i));
- Vector sequences = new Vector();
+ Vector<SequenceI> sequences = new Vector<SequenceI>();
for (int j = 0; j < l.size(); j++)
{
- SequenceI s1 = (SequenceI) ((SequenceNode) l.elementAt(j))
+ SequenceI s1 = (SequenceI) l.elementAt(j)
.element();
if (!sequences.contains(s1))
.getCodingComplement();
if (codingComplement != null)
{
- if (codingComplement != null)
+ SequenceGroup mappedGroup = MappingUtils.mapSequenceGroup(sg, av,
+ codingComplement);
+ if (mappedGroup.getSequences().size() > 0)
{
- SequenceGroup mappedGroup = MappingUtils.mapSequenceGroup(sg,
- av, codingComplement);
- if (mappedGroup.getSequences().size() > 0)
+ codingComplement.getAlignment().addGroup(mappedGroup);
+ for (SequenceI seq : mappedGroup.getSequences())
{
- codingComplement.getAlignment().addGroup(mappedGroup);
- for (SequenceI seq : mappedGroup.getSequences())
- {
- codingComplement.setSequenceColour(seq, col.brighter());
- }
+ codingComplement.setSequenceColour(seq, col.brighter());
}
}
}
{
((AlignViewport) codingComplement).getAlignPanel()
.updateAnnotation();
-
}
-
}
-
}
/**
}
}
if (alsq.size() < sequences.length)
+ {
Cache.log
.warn("Not recovered all alignment sequences for given set of input sequence CIGARS");
+ }
return alsq;
}
public void UpdateSequenceTreeMap(TreePanel tp)
{
if (tp == null || tree == null)
+ {
return;
- Vector leaves = new Vector();
+ }
+
if (tp.getTree() == null)
{
Cache.log.warn("Not updating SequenceTreeMap for "
+ tree.getVorbaId());
return;
}
- tp.getTree().findLeaves(tp.getTree().getTopNode(), leaves);
+ Vector<SequenceNode> leaves = tp.getTree().findLeaves(
+ tp.getTree().getTopNode());
Treenode[] tn = tree.getTreenode(); // todo: select nodes for this
// particular tree
int sz = tn.length;
*/
public Treenode[] makeTreeNodes(NJTree ntree, Newick newick)
{
- Vector leaves = new Vector();
- ntree.findLeaves(ntree.getTopNode(), leaves);
+ Vector<SequenceNode> leaves = ntree.findLeaves(ntree.getTopNode());
Vector tnv = new Vector();
Enumeration l = leaves.elements();
Hashtable nodespecs = new Hashtable();
--occurence;
}
else
+ {
bn = null;
+ }
}
return bn;
}
@Override
public void mousePressed(MouseEvent evt)
{
- if (evt.isPopupTrigger())
+ if (evt.isPopupTrigger()) // Mac
{
- radioItem.removeActionListener(radioItem.getActionListeners()[0]);
-
- int option = JOptionPane.showInternalConfirmDialog(
- jalview.gui.Desktop.desktop,
- MessageManager
- .getString("label.remove_from_default_list"),
- MessageManager
- .getString("label.remove_user_defined_colour"),
- JOptionPane.YES_NO_OPTION);
- if (option == JOptionPane.YES_OPTION)
- {
- jalview.gui.UserDefinedColours
- .removeColourFromDefaults(radioItem.getText());
- colourMenu.remove(radioItem);
- }
- else
+ offerRemoval(radioItem);
+ }
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent evt)
+ {
+ if (evt.isPopupTrigger()) // Windows
+ {
+ offerRemoval(radioItem);
+ }
+ }
+
+ /**
+ * @param radioItem
+ */
+ void offerRemoval(final JRadioButtonMenuItem radioItem)
+ {
+ radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+
+ int option = JOptionPane.showInternalConfirmDialog(
+ jalview.gui.Desktop.desktop,
+ MessageManager
+ .getString("label.remove_from_default_list"),
+ MessageManager
+ .getString("label.remove_user_defined_colour"),
+ JOptionPane.YES_NO_OPTION);
+ if (option == JOptionPane.YES_OPTION)
+ {
+ jalview.gui.UserDefinedColours
+ .removeColourFromDefaults(radioItem.getText());
+ colourMenu.remove(radioItem);
+ }
+ else
+ {
+ radioItem.addActionListener(new ActionListener()
{
- radioItem.addActionListener(new ActionListener()
+ @Override
+ public void actionPerformed(ActionEvent evt)
{
- @Override
- public void actionPerformed(ActionEvent evt)
- {
- userDefinedColour_actionPerformed(evt);
- }
- });
- }
+ userDefinedColour_actionPerformed(evt);
+ }
+ });
}
}
});
@Override
public void mousePressed(MouseEvent e)
{
- tabbedPane_mousePressed(e);
+ if (e.isPopupTrigger()) // Mac
+ {
+ tabbedPane_mousePressed(e);
+ }
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e)
+ {
+ if (e.isPopupTrigger()) // Windows
+ {
+ tabbedPane_mousePressed(e);
+ }
}
});
tabbedPane.addFocusListener(new FocusAdapter()
ok.setText(MessageManager.getString("label.new_window"));
ok.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
ok_actionPerformed(e);
cancel.setText(MessageManager.getString("action.close"));
cancel.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
cancel_actionPerformed(e);
close.setText(MessageManager.getString("action.close"));
close.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
cancel_actionPerformed(e);
.getMenuShortcutKeyMask(), false));
selectAll.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
selectAll_actionPerformed(e);
.getMenuShortcutKeyMask(), false));
save.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
save_actionPerformed(e);
textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));
textarea.addMouseListener(new java.awt.event.MouseAdapter()
{
+ @Override
public void mousePressed(MouseEvent e)
{
textarea_mousePressed(e);
}
+
+ @Override
+ public void mouseReleased(MouseEvent e)
+ {
+ textarea_mousePressed(e);
+ }
});
editMenu.setText(MessageManager.getString("action.edit"));
copyItem.setText(MessageManager.getString("action.copy"));
copyItem.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
copyItem_actionPerformed(e);
ok.setText(MessageManager.getString("label.new_window"));
ok.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
ok_actionPerformed(e);
cancel.setText(MessageManager.getString("action.close"));
cancel.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
cancel_actionPerformed(e);
.getMenuShortcutKeyMask(), false));
selectAll.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
selectAll_actionPerformed(e);
.getMenuShortcutKeyMask(), false));
save.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
save_actionPerformed(e);
textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));
textarea.addMouseListener(new java.awt.event.MouseAdapter()
{
+ @Override
public void mousePressed(MouseEvent e)
{
- textarea_mousePressed(e);
+ textarea_mousePressed(e); // on Mac
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e)
+ {
+ textarea_mousePressed(e); // on Windows
}
});
editMenu.setText(MessageManager.getString("action.edit"));
pasteMenu.setText(MessageManager.getString("action.paste"));
pasteMenu.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
pasteMenu_actionPerformed(e);
copyItem.setText(MessageManager.getString("action.copy"));
copyItem.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
copyItem_actionPerformed(e);
}
/**
- * Answers true if the mouse event has Meta-down (on Mac) or Ctrl-down (on
- * other o/s)
+ * Answers true if the mouse event has Meta-down (Command key on Mac) or
+ * Ctrl-down (on other o/s). Note this answers _false_ if the Ctrl key is
+ * pressed instead of the Meta/Cmd key on Mac. To test for Ctrl-click on Mac,
+ * you can use e.isPopupTrigger().
*
* @param e
* @return
--- /dev/null
+package jalview.gui;
+
+/*
+ * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Oracle or the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+* MouseEventDemo.java
+*/
+
+import jalview.util.Platform;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.BorderFactory;
+import javax.swing.InputMap;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTextArea;
+import javax.swing.KeyStroke;
+import javax.swing.SwingUtilities;
+
+/**
+ * Sourced from Oracle and adapted
+ *
+ * @see https
+ * ://docs.oracle.com/javase/tutorial/uiswing/events/mouselistener.html
+ */
+public class MouseEventDemo extends JPanel implements MouseListener
+{
+ private class BlankArea extends JLabel
+ {
+ Dimension minSize = new Dimension(200, 100);
+
+ public BlankArea(Color color)
+ {
+ setBackground(color);
+ setOpaque(true);
+ setBorder(BorderFactory.createLineBorder(Color.black));
+ }
+
+ @Override
+ public Dimension getMinimumSize()
+ {
+ return minSize;
+ }
+
+ @Override
+ public Dimension getPreferredSize()
+ {
+ return minSize;
+ }
+ }
+
+ static int counter = 0;
+
+ BlankArea blankArea;
+
+ JTextArea textArea;
+
+ static final String NEWLINE = System.getProperty("line.separator");
+
+ public static void main(String[] args)
+ {
+ // Schedule a job for the event dispatch thread:
+ // creating and showing this application's GUI.
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ createAndShowGUI();
+ }
+ });
+ }
+
+ /**
+ * Create the GUI and show it. For thread safety, this method should be
+ * invoked from the event dispatch thread.
+ */
+ private static void createAndShowGUI()
+ {
+ // Create and set up the window.
+ JFrame frame = new JFrame("MouseEventDemo (C to clear)");
+ frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+
+ // Create and set up the content pane.
+ JComponent newContentPane = new MouseEventDemo();
+ newContentPane.setOpaque(true); // content panes must be opaque
+ frame.setContentPane(newContentPane);
+
+ // Display the window.
+ frame.pack();
+ frame.setVisible(true);
+ }
+
+ public MouseEventDemo()
+ {
+ super(new GridLayout(0, 1));
+
+ textArea = new JTextArea();
+ textArea.setEditable(false);
+ JScrollPane scrollPane = new JScrollPane(textArea);
+ scrollPane
+ .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ scrollPane.setPreferredSize(new Dimension(400, 75));
+
+ blankArea = new BlankArea(Color.YELLOW);
+ JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+ blankArea, scrollPane);
+ splitPane.setVisible(true);
+ splitPane.setDividerLocation(0.2d);
+ splitPane.setResizeWeight(0.5d);
+ add(splitPane);
+
+ addKeyBinding();
+
+ blankArea.addMouseListener(this);
+ addMouseListener(this);
+ setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
+ }
+
+ private void addKeyBinding()
+ {
+ addKeyBinding(KeyStroke.getKeyStroke('C'));
+ addKeyBinding(KeyStroke.getKeyStroke('c'));
+ }
+
+ /**
+ * @param ks
+ */
+ void addKeyBinding(final KeyStroke ks)
+ {
+ InputMap inputMap = this.getInputMap(JComponent.WHEN_FOCUSED);
+ inputMap.put(ks, ks);
+ this.getActionMap().put(ks, new AbstractAction()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ textArea.setText("");
+ log("");
+ }
+ });
+ }
+
+ void logEvent(String eventDescription, MouseEvent e)
+ {
+ log("------- " + counter++ + ": " + eventDescription);
+ log("e.isPopupTrigger: " + e.isPopupTrigger());
+ log("SwingUtilities.isRightMouseButton: "
+ + SwingUtilities.isRightMouseButton(e));
+ log("SwingUtilities.isLeftMouseButton: "
+ + SwingUtilities.isLeftMouseButton(e));
+ log("Platform.isControlDown: " + Platform.isControlDown(e));
+ log("e.isControlDown: " + e.isControlDown());
+ log("e.isAltDown: " + e.isAltDown());
+ log("e.isMetaDown: " + e.isMetaDown());
+ log("e.isShiftDown: " + e.isShiftDown());
+ log("e.getClickCount: " + e.getClickCount());
+ }
+
+ /**
+ * @param msg
+ */
+ void log(String msg)
+ {
+ textArea.append(msg + NEWLINE);
+ textArea.setCaretPosition(textArea.getDocument().getLength());
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e)
+ {
+ logEvent("Mouse pressed", e);
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e)
+ {
+ logEvent("Mouse released", e);
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e)
+ {
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e)
+ {
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e)
+ {
+ logEvent("Mouse clicked", e);
+ }
+}
\ No newline at end of file
AssertJUnit.assertTrue(stage + "Null Tree", tree_regen != null);
stage = "Compare original and generated tree" + treename;
- Vector oseqs, nseqs;
- oseqs = new NJTree(new SequenceI[0], nf).findLeaves(nf.getTree(),
- new Vector());
+ Vector<SequenceNode> oseqs, nseqs;
+ oseqs = new NJTree(new SequenceI[0], nf).findLeaves(nf.getTree());
AssertJUnit.assertTrue(stage + "No nodes in original tree.",
oseqs.size() > 0);
SequenceI[] olsqs = new SequenceI[oseqs.size()];
for (int i = 0, iSize = oseqs.size(); i < iSize; i++)
{
- olsqs[i] = (SequenceI) ((SequenceNode) oseqs.get(i)).element();
+ olsqs[i] = (SequenceI) oseqs.get(i).element();
}
- nseqs = new NJTree(new SequenceI[0], nf_regen).findLeaves(
- nf_regen.getTree(), new Vector());
+ nseqs = new NJTree(new SequenceI[0], nf_regen).findLeaves(nf_regen
+ .getTree());
AssertJUnit.assertTrue(stage + "No nodes in regerated tree.",
nseqs.size() > 0);
SequenceI[] nsqs = new SequenceI[nseqs.size()];
for (int i = 0, iSize = nseqs.size(); i < iSize; i++)
{
- nsqs[i] = (SequenceI) ((SequenceNode) nseqs.get(i)).element();
+ nsqs[i] = (SequenceI) nseqs.get(i).element();
}
AssertJUnit.assertTrue(stage
+ " Different number of leaves (original " + olsqs.length
<allow pkg="com.stevesoft.pat"/>
<subpackage name="appletgui">
+ <disallow pkg="javax.swing"/>
<disallow pkg="jalview.gui"/>
<disallow pkg="jalview.ws"/>
<allow pkg="org.jmol"/>