public final class JalviewBinding
implements ExternalTreeViewerBindingI<PhylogenyNode>
{
- private org.forester.archaeopteryx.TreePanel treeView;
+ private final MainFrame aptxFrame;
- private AlignmentViewport parentAvport;
+ private org.forester.archaeopteryx.TreePanel currentTreeView;
+
+ private final AlignmentViewport parentAvport;
private JTabbedPane treeTabs;
final Map<PhylogenyNode, SequenceI> nodesMappedToAlign)
{
// deal with/prohibit null values here as that will cause problems
+ aptxFrame = archaeopteryx;
parentAvport = jalviewAlignmentViewport;
sequencesBoundToNodes = alignMappedToNodes;
nodesBoundToSequences = nodesMappedToAlign;
- treeView = archaeopteryx.getMainPanel().getCurrentTreePanel();
- treeTabs = archaeopteryx.getMainPanel().getTabbedPane();
+ treeTabs = aptxFrame.getMainPanel().getTabbedPane();
ssm = parentAvport.getStructureSelectionManager();
// archaeopteryx.getMainPanel().getControlPanel().setColorBranches(true);
ssm.addSelectionListener(this);
- treeView.addMouseListener(this);
- PaintRefresher.Register(treeView, parentAvport.getSequenceSetId());
+
+ int tabCount = treeTabs.getTabCount();
+
+ for (int i = 0; i < tabCount; i++)
+ {
+ // roundabout way to select each tree because getComponentAt(i) requires
+ // casting to TreePanel which doesn't work
+ treeTabs.setSelectedIndex(i);
+ currentTreeView = aptxFrame.getMainPanel().getCurrentTreePanel();
+ currentTreeView.addMouseListener(this);
+ PaintRefresher.Register(currentTreeView,
+ parentAvport.getSequenceSetId());
+ }
treeTabs.addChangeListener(new ChangeListener()
*/
public void run()
{
+ currentTreeView = aptxFrame.getMainPanel()
+ .getCurrentTreePanel();
parentAvport.sendSelection();
- // PaintRefresher.Refresh(treeView,
- // parentAvport.getSequenceSetId());
}
});
*/
public void run()
{
- final PhylogenyNode node = treeView.findNode(e.getX(), e.getY());
+
+ final PhylogenyNode node = currentTreeView.findNode(e.getX(),
+ e.getY());
if (node != null)
{
if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) // clear previous
// selection if shift
// IS NOT pressed
{
+
parentAvport.setSelectionGroup(null);
}
if (source == parentAvport) // check if source is alignment from where the
// tree originates
{
- treeView.setFoundNodes0(
+ currentTreeView.setFoundNodes0(
new HashSet<Long>(seqsel.getSequences().size()));
for (SequenceI selectedSequence : seqsel.getSequences())
PhylogenyNode matchingNode = sequencesBoundToNodes.get(selectedSequence);
if (matchingNode != null)
{
- treeView.getFoundNodes0().add(matchingNode.getId());
+ currentTreeView.getFoundNodes0().add(matchingNode.getId());
}
}
- treeView.repaint();
+ aptxFrame.repaint();
}
public void partitionTree(final MouseEvent e)
{
int x = e.getX();
- int lineLength = treeView.getHeight();
+ int lineLength = currentTreeView.getHeight();
- Phylogeny tree = treeView.getPhylogeny();
+ Phylogeny tree = currentTreeView.getPhylogeny();
double treeHeight = tree.calculateHeight(true);
if (treeHeight != 0)
{
- int viewWidth = treeView.getWidth();
+ int viewWidth = currentTreeView.getWidth();
// treeView.validate();
if (matchingSequence != null)
{
long nodeId = nodeToMatch.getId();
- addOrRemoveInSet(treeView.getFoundNodes0(), nodeId);
+ addOrRemoveInSet(currentTreeView.getFoundNodes0(), nodeId);
treeSelectionChanged(matchingSequence);
parentAvport.sendSelection();
if (matchingSequence != null)
{
long nodeId = childNode.getId();
- addOrRemoveInSet(treeView.getFoundNodes0(), nodeId);
+ addOrRemoveInSet(currentTreeView.getFoundNodes0(), nodeId);
treeSelectionChanged(matchingSequence);
return parentAvport;
}
- public void setParentAvport(final AlignmentViewport parentAvport)
+ public org.forester.archaeopteryx.TreePanel getTreeView()
{
- this.parentAvport = parentAvport;
+ return currentTreeView;
}
+
}
+