-Subproject commit 835739d782b7099677aadf653ecc682cf74fc87f
+Subproject commit 20ce9361380c461b8a7053100207034314e56e23
+++ /dev/null
-package jalview.ext.archaeopteryx;
-
-import org.forester.archaeopteryx.Configuration;
-
-public class AptxConfig
-{
- private final Configuration config;
-
- public AptxConfig(Configuration aptxConfig)
- {
- config = aptxConfig;
- }
-
-}
{
ControlPanel aptxCp;
- public AptxControlPanel(ControlPanel aptxControlPanel)
+ protected AptxControlPanel(ControlPanel aptxControlPanel)
{
aptxCp = aptxControlPanel;
import jalview.ext.treeviewer.ExternalTreeFrame;
import jalview.ext.treeviewer.ExternalTreeI;
import jalview.ext.treeviewer.ExternalTreePanel;
+import jalview.gui.Desktop;
import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Event;
+import java.awt.Font;
+import java.awt.Image;
+import java.awt.MenuComponent;
+import javax.accessibility.AccessibleContext;
+import javax.swing.JLayeredPane;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
+import javax.swing.JRootPane;
import javax.swing.JSeparator;
+import javax.swing.event.InternalFrameListener;
import org.forester.archaeopteryx.MainFrame;
-public class AptxFrame extends ExternalTreeFrame
+public class AptxFrame implements ExternalTreeFrame
{
private final MainFrame aptxFrame;
+ private ExternalTreePanel aptxPanel;
+
+ private ExternalTreeControlsI aptxControls;
+
public AptxFrame(MainFrame aptx)
{
aptxFrame = aptx;
+ aptxPanel = new AptxTreePanel(
+ aptxFrame.getMainPanel().getCurrentTreePanel());
+ aptxControls = new AptxControlPanel(
+ aptxFrame.getMainPanel().getControlPanel());
adaptAptxGui(aptxFrame);
}
@Override
public ExternalTreePanel getTreePanel()
{
- ExternalTreePanel aptxPanel = new AptxTreePanel(
- aptxFrame.getMainPanel().getCurrentTreePanel());
return aptxPanel;
}
@Override
- public void switchTreePanel(int panelIndex)
- {
- aptxFrame.getMainPanel().getTabbedPane().getTabComponentAt(panelIndex);
-
- }
-
- @Override
public ExternalTreeI getTree()
{
- return new Tree(
- aptxFrame.getMainPanel().getCurrentTreePanel().getPhylogeny());
+ return aptxPanel.getTree();
}
@Override
@Override
public ExternalTreeControlsI getTreeControls()
{
- return new AptxControlPanel(aptxFrame.getMainPanel().getControlPanel());
+ return aptxControls;
+ }
+
+ @Override
+ public AccessibleContext getAccessibleContext()
+ {
+ return aptxFrame.getAccessibleContext();
+ }
+
+ @Override
+ public JRootPane getRootPane()
+ {
+ return aptxFrame.getRootPane();
+ }
+
+ @Override
+ public void setContentPane(Container contentPane)
+ {
+ aptxFrame.setContentPane(contentPane);
+
+ }
+
+ @Override
+ public Container getContentPane()
+ {
+ return aptxFrame.getContentPane();
+ }
+
+ @Override
+ public void setLayeredPane(JLayeredPane layeredPane)
+ {
+ aptxFrame.setLayeredPane(layeredPane);
+
+ }
+
+ @Override
+ public JLayeredPane getLayeredPane()
+ {
+ return aptxFrame.getLayeredPane();
+ }
+
+ @Override
+ public void setGlassPane(Component glassPane)
+ {
+ aptxFrame.setGlassPane(glassPane);
+
+ }
+
+ @Override
+ public Component getGlassPane()
+ {
+ return aptxFrame.getGlassPane();
+ }
+
+ @Override
+ public boolean imageUpdate(Image img, int infoflags, int x, int y,
+ int width, int height)
+ {
+ return aptxFrame.imageUpdate(img, infoflags, x, y, width, height);
+ }
+
+ @Override
+ public Font getFont()
+ {
+ return aptxFrame.getFont();
+ }
+
+ @Override
+ public void remove(MenuComponent comp)
+ {
+ aptxFrame.remove(comp);
+
+ }
+
+ @Deprecated
+ @Override
+ public boolean postEvent(Event evt)
+ {
+ return aptxFrame.postEvent(evt);
+ }
+
+ @Override
+ public void addFrameListener(InternalFrameListener listener)
+ {
+ aptxFrame.addInternalFrameListener(listener);
+
+ }
+
+ @Override
+ public void removeFrameListener(InternalFrameListener listener)
+ {
+ aptxFrame.removeInternalFrameListener(listener);
+
+ }
+
+ @Override
+ public InternalFrameListener[] getFrameListeners()
+ {
+ return aptxFrame.getInternalFrameListeners();
+
}
+
+ @Override
+ public void repaint()
+ {
+ aptxFrame.repaint();
+
+ }
+
+ @Override
+ public void setMinimumSize(Dimension dimension)
+ {
+ aptxFrame.setMinimumSize(dimension);
+
+ }
+
+ @Override
+ public boolean isShowing()
+ {
+ return aptxFrame.isShowing();
+ }
+
+ @Override
+ public Container getTopLevelAncestor()
+ {
+ return aptxFrame.getTopLevelAncestor();
+ }
+
+ @Override
+ public void addFrameToJalview(String title, boolean makeVisible,
+ int width, int height, boolean resizable, boolean ignoreMinSize)
+ {
+ Desktop.addInternalFrame(aptxFrame, title, makeVisible, width, height,
+ resizable, ignoreMinSize);
+
+ }
+
}
\ No newline at end of file
import jalview.analysis.TreeBuilder;
import jalview.datamodel.SequenceI;
+import jalview.ext.forester.UtilityMethods;
import jalview.ext.treeviewer.ExternalLoadedTreeAssociationI;
import jalview.ext.treeviewer.ExternalTreeBuilderI;
import jalview.ext.treeviewer.ExternalTreeFrame;
import jalview.ext.treeviewer.ExternalTreeI;
import jalview.ext.treeviewer.ExternalTreeNodeI;
import jalview.ext.treeviewer.ExternalTreeViewerBindingI;
+import jalview.ext.treeviewer.LoadedTreeSequenceAssociation;
import jalview.gui.Desktop;
import jalview.gui.JvOptionPane;
import jalview.util.MessageManager;
+
public static ExternalTreeFrame createInstanceFromCalculation(
final TreeBuilder calculatedTree)
{
throws FileNotFoundException, IOException
{
File treeFile = new File(filePath);
- final String err = ForesterUtil.isReadableFile(treeFile);
- if (!ForesterUtil.isEmpty(err))
+ ExternalTreeFrame[] aptxFrames = null;
+ if (UtilityMethods.canForesterReadFile(treeFile))
{
- JvOptionPane.showMessageDialog(Desktop.desktop, err,
- MessageManager.getString("label.problem_reading_tree_file"),
- JvOptionPane.WARNING_MESSAGE);
- }
if (Desktop.instance != null)
{
}
Phylogeny[] trees = PhylogenyMethods.readPhylogenies(parser,
treeFile);
- ExternalTreeFrame[] aptxFrames = new ExternalTreeFrame[trees.length];
+ aptxFrames = new ExternalTreeFrame[trees.length];
for (int i = 0; i < trees.length; i++)
if (Desktop.instance != null)
{
Desktop.instance.stopLoading();
+ }
}
return aptxFrames;
}
final Map<SequenceI, ExternalTreeNodeI> alignMappedToNodes,
final Map<ExternalTreeNodeI, SequenceI> nodesMappedToAlign)
{
- JalviewBinding treeBinding = new JalviewBinding(aptxApp,
+ ExternalTreeViewerBindingI treeBinding = new JalviewBinding(aptxApp,
jalviewAlignViewport,
alignMappedToNodes, nodesMappedToAlign);
activeAptx.put(aptxApp, treeBinding);
new String[]
{ treeFile.getAbsolutePath() });
}
- Desktop.addInternalFrame(aptxApp, frameTitle, true, width, height, true,
+ aptxApp.addFrameToJalview(frameTitle, true, width, height, true,
true);
return aptxApp;
jalviewTree.getDistances(), sequences);
aptxTree = new Tree(new Phylogeny());
- rootNode = new TreeNode(new PhylogenyNode());
+ rootNode = TreeNode.getUniqueWrapper(new PhylogenyNode());
int amountOfSequences = distances.getSize();
alignmentWithNodes = new HashMap<>(amountOfSequences);
for (SequenceI sequence : sequences)
{
- ExternalTreeNodeI sequenceNode = new TreeNode(
+ ExternalTreeNodeI sequenceNode = TreeNode
+ .getUniqueWrapper(
new PhylogenyNode(sequence.getName()));
sequenceNode.setSequence(sequence);
import jalview.ext.treeviewer.ExternalTreeI;
import jalview.ext.treeviewer.ExternalTreeNodeI;
import jalview.ext.treeviewer.ExternalTreePanel;
+import jalview.gui.PaintRefresher;
+import java.awt.Event;
+import java.awt.Font;
+import java.awt.MenuComponent;
+import java.awt.event.MouseListener;
import java.io.File;
import java.util.Set;
-public class AptxTreePanel extends ExternalTreePanel
+import javax.accessibility.AccessibleContext;
+
+public class AptxTreePanel implements ExternalTreePanel
{
private final org.forester.archaeopteryx.TreePanel treeView;
- public AptxTreePanel(org.forester.archaeopteryx.TreePanel aptxTreePanel)
+ private final Tree tree;
+
+ private String sequenceSetId;
+
+ protected AptxTreePanel(
+ org.forester.archaeopteryx.TreePanel aptxTreePanel)
{
treeView = aptxTreePanel;
-
+ tree = new Tree(treeView.getPhylogeny());
}
@Override
@Override
public ExternalTreeI getTree()
{
- return new Tree(treeView.getPhylogeny());
+ return tree;
}
@Override
@Override
public ExternalTreeNodeI findNode(int x, int y)
{
- return new TreeNode(treeView.findNode(x, y));
+ return TreeNode.getUniqueWrapper(treeView.findNode(x, y));
}
@Override
{
return treeView.getFoundNodes0();
}
+
+ @Override
+ public AccessibleContext getAccessibleContext()
+ {
+ return treeView.getAccessibleContext();
+ }
+
+ @Override
+ public Font getFont()
+ {
+ return treeView.getFont();
+ }
+
+ @Override
+ public void remove(MenuComponent comp)
+ {
+ treeView.remove(comp);
+
+ }
+
+ @Deprecated
+ @Override
+ public boolean postEvent(Event evt)
+ {
+ return treeView.postEvent(evt);
+ }
+
+ @Override
+ public void addMouseListener(MouseListener listener)
+ {
+ treeView.addMouseListener(listener);
+ }
+
+ @Override
+ public void removeMouseListener(MouseListener listener)
+ {
+ treeView.removeMouseListener(listener);
+
+ }
+
+ @Override
+ public MouseListener[] getMouseListeners()
+ {
+ return treeView.getMouseListeners();
+ }
+
+ @Override
+ public void repaint()
+ {
+ treeView.repaint();
+
+ }
+
+ @Override
+ public void registerWithPaintRefresher(String sequenceSetIdentifier)
+ {
+ sequenceSetId = sequenceSetIdentifier;
+ PaintRefresher.Register(treeView, sequenceSetIdentifier);
+
+ }
+
+ @Override
+ public void notifyPaintRefresher(String sequenceSetIdentifier,
+ boolean alignmentChanged, boolean validateSequences)
+ {
+ PaintRefresher.Refresh(treeView, sequenceSetIdentifier,
+ alignmentChanged, validateSequences);
+
+ }
+
+ @Override
+ public void notifyPaintRefresher(boolean alignmentChanged,
+ boolean validateSequences)
+ {
+ if (sequenceSetId != null)
+ {
+ PaintRefresher.Refresh(treeView, sequenceSetId, alignmentChanged,
+ validateSequences);
+ }
+ else
+ {
+ // throw some kind of exception
+ }
+
+ }
}
-package jalview.ext.forester;
+package jalview.ext.archaeopteryx;
import jalview.datamodel.SequenceI;
-import jalview.ext.archaeopteryx.TreeNode;
-import jalview.ext.treeviewer.ExternalTreeNodeI;
+import jalview.ext.forester.ForesterMatrix;
import jalview.math.MatrixI;
-import java.util.ArrayList;
-import java.util.List;
-
import org.forester.evoinference.matrix.distance.DistanceMatrix;
import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException;
-import org.forester.phylogeny.PhylogenyNode;
public final class DataConversions
{
{
foresterSeq.setName(jalviewSequence.getDescription());
}
- foresterSeq.setMolecularSequenceAligned(sequenceIsAligned); // all tree
- // sequences
- // should
- // be aligned
- // already
+
+ // all tree sequences should be aligned already
+ foresterSeq.setMolecularSequenceAligned(sequenceIsAligned);
+
foresterSeq.setMolecularSequence(jalviewSequence.getSequenceAsString());
- if (jalviewSequence.isProtein()) // add checks for DNA or RNA (infer from
- // forester itself?)
+
+ // add checks for DNA or RNA (infer from forester itself?)
+ if (jalviewSequence.isProtein())
{
try
{
}
- public static List<ExternalTreeNodeI> getConvertedTreeNodes(
- List<PhylogenyNode> aptxNodes)
- {
- List<ExternalTreeNodeI> jalviewNodes = new ArrayList<>();
- for (PhylogenyNode aptxNode : aptxNodes)
- {
- jalviewNodes.add(new TreeNode(aptxNode));
- }
- return jalviewNodes;
- }
+
}
ssm.addSelectionListener(this);
treeView.addMouseListener(this);
-
- PaintRefresher.Register(treeView, parentAvport.getSequenceSetId());
+ treeView.registerWithPaintRefresher(
+ parentAvport.getSequenceSetId());
associatedPanels = PaintRefresher
.getAssociatedPanels(parentAvport.getSequenceSetId());
- aptxFrame.addInternalFrameListener(new InternalFrameAdapter()
+ aptxFrame.addFrameListener(new InternalFrameAdapter()
{
@Override
partitionTree(e.getX());
}
- PaintRefresher.Refresh(treeView, parentAvport.getSequenceSetId());
+ treeView.notifyPaintRefresher(parentAvport.getSequenceSetId(),
+ false, false);
treeView.repaint();
{
private final Phylogeny tree;
+ public Tree()
+ {
+ tree = new Phylogeny();
+ }
public Tree(Phylogeny aptxTree)
{
tree = aptxTree;
+ wrapAllTreeNodes();
+
}
+ private void wrapAllTreeNodes()
+ {
+ for (Iterator<PhylogenyNode> iterator = tree
+ .iteratorPostorder(); iterator.hasNext();)
+ {
+ PhylogenyNode foresterNode = iterator.next();
+ ExternalTreeNodeI treeNode = TreeNode
+ .getUniqueWrapper(foresterNode);
+
+ }
+ }
@Override
public ExternalTreeNodeI getRoot()
{
- ExternalTreeNodeI root = new TreeNode(tree.getRoot());
+ ExternalTreeNodeI root = TreeNode.getUniqueWrapper(tree.getRoot());
return root;
}
@Override
public ExternalTreeNodeI getNodeWithName(String name)
{
- return new TreeNode(tree.getNode(name));
+ return TreeNode.getUniqueWrapper(tree.getNode(name));
}
@Override
public void setRoot(ExternalTreeNodeI rootNode)
{
- PhylogenyNode treeRoot = new PhylogenyNode(rootNode.getNodeName());
- // expand this
+ PhylogenyNode treeRoot = TreeNode.unwrapNode(rootNode);
tree.setRoot(treeRoot);
+ wrapAllTreeNodes();
}
{
PhylogenyNode furthestNode = PhylogenyMethods
.calculateNodeWithMaxDistanceToRoot(tree);
- return new TreeNode(furthestNode);
+ return TreeNode.getUniqueWrapper(furthestNode);
}
@Override
AptxInit.APTX_CONFIG,
instanceTitle));
}
+
+
}
@Override
public ExternalTreeNodeI next()
{
- ExternalTreeNodeI node = new TreeNode(iter.next());
+ ExternalTreeNodeI node = TreeNode.getUniqueWrapper(iter.next());
return node;
}
package jalview.ext.archaeopteryx;
import jalview.datamodel.SequenceI;
-import jalview.ext.forester.DataConversions;
import jalview.ext.treeviewer.ExternalTreeNodeI;
import java.awt.Color;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.PhylogenyNode;
private SequenceI nodeSeq;
- public TreeNode(PhylogenyNode aptxNode)
+ private static Map<PhylogenyNode, ExternalTreeNodeI> originalNodes = new HashMap<>(
+ 500); // prolly make this size dynamic
+
+ private static Map<ExternalTreeNodeI, PhylogenyNode> wrappedNodes = new HashMap<>(
+ 500);
+
+ private TreeNode(PhylogenyNode aptxNode)
{
node = aptxNode;
+ originalNodes.put(aptxNode, this);
+ wrappedNodes.put(this, aptxNode);
}
return node.getName();
}
+
@Override
public List<ExternalTreeNodeI> getAllDescendants()
{
+
List<PhylogenyNode> descNodes = PhylogenyMethods
.getAllDescendants(node);
- return DataConversions.getConvertedTreeNodes(descNodes);
+ return getUniqueWrappers(descNodes);
+
}
public List<ExternalTreeNodeI> getExternalDescendants()
{
List<PhylogenyNode> extDescNodes = node.getAllExternalDescendants();
- return DataConversions.getConvertedTreeNodes(extDescNodes);
+ return getUniqueWrappers(extDescNodes);
}
public List<ExternalTreeNodeI> getDirectChildren()
{
List<PhylogenyNode> childNodes = node.getDescendants();
- return DataConversions.getConvertedTreeNodes(childNodes);
+ return getUniqueWrappers(childNodes);
+
+
}
@Override
public void addAsChild(ExternalTreeNodeI childNode)
{
- PhylogenyNode aptxNode = new PhylogenyNode(childNode.getNodeName());
+ PhylogenyNode aptxNode = unwrapNode(childNode);
- // expand on this
node.addAsChild(aptxNode);
}
return node.isInternal();
}
+ public static List<ExternalTreeNodeI> getUniqueWrappers(
+ List<PhylogenyNode> aptxNodes)
+ {
+ List<ExternalTreeNodeI> wrappedNodes = new ArrayList<>(
+ aptxNodes.size());
+
+ for (PhylogenyNode aptxNode : aptxNodes)
+ {
+ wrappedNodes.add(getUniqueWrapper(aptxNode));
+ }
+ return wrappedNodes;
+ }
+
+ /**
+ * This method should be used to create new wrappers as there is a possibility
+ * the Archaeopteryx node was already introduced to Jalview previously so this
+ * avoids giving one node duplicate wrappers
+ *
+ * @param aptxNode
+ * @return
+ */
+ public static ExternalTreeNodeI getUniqueWrapper(
+ PhylogenyNode aptxNode)
+ {
+ ExternalTreeNodeI wrappedNode = originalNodes.get(aptxNode);
+ if (wrappedNode == null)
+ {
+ wrappedNode = new TreeNode(aptxNode);
+ }
+
+ return wrappedNode;
+ }
+
+ /**
+ * Attempts to unwrap the given node, if the unwrapped node already exists it
+ * is simply returned as is. If it is not however, the wrapper will be used to
+ * create a new Archaeopteryx node. This way it becomes possible to construct
+ * new Archaeopteryx nodes from different tree viewers, as long as they
+ * implement the interface.
+ *
+ * @param wrappedNode
+ * @return
+ */
+ protected static PhylogenyNode unwrapNode(ExternalTreeNodeI wrappedNode)
+ {
+ PhylogenyNode aptxNode = wrappedNodes.get(wrappedNode);
+ if (aptxNode == null)
+ {
+ // expand this
+ aptxNode = new PhylogenyNode(wrappedNode.getNodeName());
+ }
+ return aptxNode;
+
+ }
+
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((node == null) ? 0 : node.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ TreeNode other = (TreeNode) obj;
+ if (node == null)
+ {
+ if (other.node != null)
+ {
+ return false;
+ }
+ }
+ else if (!node.equals(other.node))
+ {
+ return false;
+ }
+ return true;
+ }
+
+
}
--- /dev/null
+package jalview.ext.archaeopteryx;
+
+import jalview.ext.treeviewer.ExternalTreeI;
+import jalview.ext.treeviewer.ExternalTreeParserI;
+
+import java.io.IOException;
+
+import org.forester.io.parsers.PhylogenyParser;
+import org.forester.phylogeny.Phylogeny;
+
+public class TreeParser implements ExternalTreeParserI
+{
+ private final PhylogenyParser parser;
+
+ public TreeParser(PhylogenyParser foresterParser)
+ {
+ parser = foresterParser;
+ }
+
+ @Override
+ public ExternalTreeI[] parse() throws IOException
+ {
+ Phylogeny[] foresterTrees = parser.parse();
+ ExternalTreeI[] jalviewTrees = new ExternalTreeI[foresterTrees.length];
+
+ for (int i = 0; i < foresterTrees.length; i++)
+ {
+ jalviewTrees[i] = new Tree(foresterTrees[i]);
+ }
+ return jalviewTrees;
+
+ }
+
+ @Override
+ public void setSource(Object source) throws IOException
+ {
+ parser.setSource(source);
+
+ }
+
+ @Override
+ public String getName()
+ {
+ return parser.getName();
+ }
+
+}
package jalview.ext.forester;
import jalview.datamodel.SequenceI;
+import jalview.ext.archaeopteryx.DataConversions;
import jalview.math.MatrixI;
import jalview.util.MessageManager;
--- /dev/null
+package jalview.ext.forester;
+
+import jalview.gui.Desktop;
+import jalview.gui.JvOptionPane;
+import jalview.util.MessageManager;
+
+import java.io.File;
+
+import org.forester.util.ForesterUtil;
+
+public class UtilityMethods
+{
+ public static boolean canForesterReadFile(File treeFile)
+ {
+ final String err = ForesterUtil.isReadableFile(treeFile);
+ if (!ForesterUtil.isEmpty(err))
+ {
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop, err,
+ MessageManager.getString("label.problem_reading_tree_file"),
+ JvOptionPane.WARNING_MESSAGE);
+ return false;
+ }
+ return true;
+ }
+}
//import jalview.ext.treeviewer.ExternalTreeParserI;
import jalview.gui.Desktop;
import jalview.gui.JvOptionPane;
-import jalview.io.DataSourceType;
import jalview.io.NewickFile;
import jalview.util.MessageManager;
{
AptxInit.createInstancesFromFile(filePath, viewport);
- fin = new NewickFile(filePath, DataSourceType.FILE);
- viewport.setCurrentTree(viewport.getAlignPanel().alignFrame
- .showNewickTree(fin, filePath).getTree());
+ // fin = new NewickFile(filePath, DataSourceType.FILE);
+ // viewport.setCurrentTree(viewport.getAlignPanel().alignFrame
+ // .showNewickTree(fin, filePath).getTree());
} catch (Exception ex)
{
JvOptionPane.WARNING_MESSAGE);
ex.printStackTrace();
}
- if (fin != null && fin.hasWarningMessage())
- {
- JvOptionPane.showMessageDialog(Desktop.desktop,
- fin.getWarningMessage(),
- MessageManager
- .getString("label.possible_problem_with_tree_file"),
- JvOptionPane.WARNING_MESSAGE);
- }
+ // if (fin != null && fin.hasWarningMessage())
+ // {
+ // JvOptionPane.showMessageDialog(Desktop.desktop,
+ // fin.getWarningMessage(),
+ // MessageManager
+ // .getString("label.possible_problem_with_tree_file"),
+ // JvOptionPane.WARNING_MESSAGE);
+ // }
}
}
package jalview.ext.treeviewer;
-import javax.swing.JInternalFrame;
-
-public abstract class ExternalTreeFrame extends JInternalFrame
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.MenuContainer;
+import java.awt.image.ImageObserver;
+
+import javax.accessibility.Accessible;
+import javax.swing.RootPaneContainer;
+import javax.swing.WindowConstants;
+import javax.swing.event.InternalFrameListener;
+
+public interface ExternalTreeFrame
+ extends Accessible, WindowConstants, RootPaneContainer,
+ ImageObserver, MenuContainer
{
public abstract ExternalTreePanel getTreePanel();
- public abstract void switchTreePanel(int panelIndex);
-
public abstract ExternalTreeI getTree();
public abstract void checkMultipleTrees();
public abstract int getNumberOfTrees();
- public abstract ExternalTreeControlsI getTreeControls();
+ public ExternalTreeControlsI getTreeControls();
+
+ public void addFrameListener(InternalFrameListener listener);
+
+ public void removeFrameListener(InternalFrameListener listener);
+
+ public InternalFrameListener[] getFrameListeners();
+
+ public void repaint();
+
+ public void setMinimumSize(Dimension dimension);
+
+ public boolean isShowing();
+
+ public Container getTopLevelAncestor();
+
+ public void addFrameToJalview(String title, boolean makeVisible,
+ int width, int height, boolean resizable, boolean ignoreMinSize);
+
}
public ExternalTreeFrame createInstanceFromTree(String instanceTitle);
+
}
+++ /dev/null
-package jalview.ext.treeviewer;
-
-public interface ExternalTreeIteratorI
-{
-
-}
package jalview.ext.treeviewer;
+import java.awt.MenuContainer;
+import java.awt.event.MouseListener;
import java.io.File;
import java.util.Set;
-import javax.swing.JPanel;
+import javax.accessibility.Accessible;
-public abstract class ExternalTreePanel extends JPanel
+public interface ExternalTreePanel extends Accessible, MenuContainer
{
public abstract void setTreeFile(File file);
public abstract void setMatchingNodes(Set<Long> matchingNodes);
public abstract Set<Long> getMatchingNodes();
+
+ public void addMouseListener(MouseListener listener);
+
+ public void removeMouseListener(MouseListener listener);
+
+ public MouseListener[] getMouseListeners();
+
+ public void repaint();
+
+ public void registerWithPaintRefresher(String sequenceSetIdentifier);
+
+ public void notifyPaintRefresher(boolean alignmentChanged,
+ boolean validateSequences);
+
+ public void notifyPaintRefresher(String newSeqSetIdentifier,
+ boolean alignmentChanged, boolean validateSequences);
+
}
-// package jalview.ext.treeviewer;
-//
-// import jalview.viewmodel.AlignmentViewport;
-//
-/// **
-// *
-// * Interface for loading in existing trees to an external tree viewer.
-// *
-// * @author kjvanderheide
-// *
-// */
-// public interface ExternalTreeParserI
-// {
-// public ExternalTreeI loadTreeFile(AlignmentViewport viewport);
-//
-// public ExternalTreeI loadTreeUrl(AlignmentViewport viewport);
-//
-// }
+package jalview.ext.treeviewer;
+
+import java.io.IOException;
+
+public interface ExternalTreeParserI
+ {
+ public ExternalTreeI[] parse() throws IOException;
+
+ public void setSource(Object source) throws IOException;
+
+ public String getName();
+
+ }
-package jalview.ext.archaeopteryx;
+package jalview.ext.treeviewer;
import jalview.analysis.SequenceIdMatcher;
import jalview.datamodel.SequenceI;
-import jalview.ext.treeviewer.ExternalLoadedTreeAssociationI;
-import jalview.ext.treeviewer.ExternalTreeI;
-import jalview.ext.treeviewer.ExternalTreeNodeI;
import jalview.util.MappingUtils;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-
public class LoadedTreeSequenceAssociation
implements ExternalLoadedTreeAssociationI
{
Map<ExternalTreeNodeI, SequenceI> nodesWithAlignment;
public LoadedTreeSequenceAssociation(SequenceI[] alignmentSequences,
- ExternalTreeI aptxTree)
+ ExternalTreeI extTree)
{
alignSequences = alignmentSequences;
- tree = aptxTree;
+ tree = extTree;
alignmentWithNodes = new HashMap<>(alignSequences.length);
nodesWithAlignment = new HashMap<>(alignSequences.length);
}
-
-
/**
* Tries to match sequences from Jalview with tree nodes in Archaeopteryx and
* fills in the tree node with sequence data if a match is found.
+ @Override
public Map<SequenceI, ExternalTreeNodeI> getAlignmentWithNodes()
{
return alignmentWithNodes;
}
+ @Override
public Map<ExternalTreeNodeI, SequenceI> getNodesWithAlignment()
{
return nodesWithAlignment;
-package jalview.ext.archaeopteryx;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import jalview.gui.Desktop;
-
-import org.forester.archaeopteryx.Archaeopteryx;
-import org.forester.archaeopteryx.MainFrame;
-import org.forester.archaeopteryx.TreePanel;
-import org.forester.phylogeny.Phylogeny;
-import org.forester.phylogeny.PhylogenyNode;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-public class AptxPhylogenyTreeTest extends TreeViewTest
-{
- final Phylogeny inputTree = new Phylogeny();
-
- final PhylogenyNode rootNode = new PhylogenyNode("root");
-
- final PhylogenyNode ancestor1Node = new PhylogenyNode("ancestor 1");
-
- final PhylogenyNode ancestor2Node = new PhylogenyNode("leaf 2");
-
- final PhylogenyNode leaf1aNode = new PhylogenyNode("leaf 1a");
-
- final PhylogenyNode leaf1bNode = new PhylogenyNode("leaf 1b");
-
- final PhylogenyNode leaf1cNode = new PhylogenyNode("leaf 1c");
-
- Phylogeny tree;
-
- TreePanel treePanel;
-
- MainFrame aptx;
-
-
- @Override
- @BeforeClass(alwaysRun = true)
- public void setUpTree()
- {
- ancestor1Node.addAsChild(leaf1aNode);
- ancestor1Node.addAsChild(leaf1bNode);
- ancestor1Node.addAsChild(leaf1cNode);
-
- rootNode.addAsChild(ancestor1Node);
- rootNode.addAsChild(ancestor2Node);
-
- leaf1aNode.setDistanceToParent(2);
- leaf1bNode.setDistanceToParent(3);
- leaf1cNode.setDistanceToParent(4);
-
- ancestor1Node.setDistanceToParent(36);
- ancestor2Node.setDistanceToParent(42);
-
- inputTree.setName("test");
- inputTree.setRoot(rootNode);
- inputTree.setRooted(true);
-
- }
-
- @Override
- @BeforeClass(dependsOnMethods = { "setUpJalview", "setUpTree" })
- public void createTreeView()
- {
- treeView = Archaeopteryx.createApplication(inputTree);
- aptx = (MainFrame) treeView; // pretty ugly
- treePanel = aptx.getMainPanel().getCurrentTreePanel();
- tree = treePanel.getPhylogeny();
-
- Desktop.addInternalFrame(aptx, "Archaeopteryx", 500, 500);
-
- }
-
-
-
- @Test(groups = "Functional")
- public void testMainPanelExists()
- {
- assertTrue(aptx.getMainPanel() != null);
- }
-
- @Test(groups = "Functional")
- public void testTreePanelExists()
- {
- assertTrue(treePanel != null);
- }
-
- @Override
- public void testTreeTitle()
- {
- assertTrue(tree.getName().equals("test"));
-
- }
-
- @Test(
- groups = "Functional",
- expectedExceptions = IllegalArgumentException.class)
- public void testInvalidBranchName()
- {
- tree.getNode("I shouldn't exist");
-
- }
-
- @Override
- public void testExistingBranchName()
- {
- tree.getNode("leaf 2");
-
- }
-
- @Override
- public void testTreeLoaded()
- {
- assertTrue(tree != null);
- }
-
- @Override
- public void testChildNodesCount()
- {
- assertEquals(tree.getNode("ancestor 1").getNumberOfExternalNodes(), 3);
-
- }
-
- @Override
- public void testChildToParentBranchLength()
- {
- assertEquals(tree.getNode("leaf 1a").getDistanceToParent(), 2.0);
-
- }
-
- @Override
- public void testNodeToRootBranchLength()
- {
- assertEquals(tree.getNode("leaf 2").getDistanceToParent(), 42.0);
-
- }
-
- @Override
- public void testDistantNodeToRootBranchLength()
- {
- assertEquals(tree.getNode("leaf 1c").calculateDistanceToRoot(),
- 4.0 + 36.0);
-
- }
-
-
-
-
-
-
-
-}
+// package jalview.ext.archaeopteryx;
+//
+// import static org.testng.Assert.assertEquals;
+// import static org.testng.Assert.assertTrue;
+//
+// import jalview.gui.Desktop;
+//
+// import org.forester.archaeopteryx.Archaeopteryx;
+// import org.forester.archaeopteryx.MainFrame;
+// import org.forester.archaeopteryx.TreePanel;
+// import org.forester.phylogeny.Phylogeny;
+// import org.forester.phylogeny.PhylogenyNode;
+// import org.testng.annotations.BeforeClass;
+// import org.testng.annotations.Test;
+//
+// public class AptxPhylogenyTreeTest extends TreeViewTest
+// {
+// final Phylogeny inputTree = new Phylogeny();
+//
+// final PhylogenyNode rootNode = new PhylogenyNode("root");
+//
+// final PhylogenyNode ancestor1Node = new PhylogenyNode("ancestor 1");
+//
+// final PhylogenyNode ancestor2Node = new PhylogenyNode("leaf 2");
+//
+// final PhylogenyNode leaf1aNode = new PhylogenyNode("leaf 1a");
+//
+// final PhylogenyNode leaf1bNode = new PhylogenyNode("leaf 1b");
+//
+// final PhylogenyNode leaf1cNode = new PhylogenyNode("leaf 1c");
+//
+// Phylogeny tree;
+//
+// TreePanel treePanel;
+//
+// MainFrame aptx;
+//
+//
+// @Override
+// @BeforeClass(alwaysRun = true)
+// public void setUpTree()
+// {
+// ancestor1Node.addAsChild(leaf1aNode);
+// ancestor1Node.addAsChild(leaf1bNode);
+// ancestor1Node.addAsChild(leaf1cNode);
+//
+// rootNode.addAsChild(ancestor1Node);
+// rootNode.addAsChild(ancestor2Node);
+//
+// leaf1aNode.setDistanceToParent(2);
+// leaf1bNode.setDistanceToParent(3);
+// leaf1cNode.setDistanceToParent(4);
+//
+// ancestor1Node.setDistanceToParent(36);
+// ancestor2Node.setDistanceToParent(42);
+//
+// inputTree.setName("test");
+// inputTree.setRoot(rootNode);
+// inputTree.setRooted(true);
+//
+// }
+//
+// @Override
+// @BeforeClass(dependsOnMethods = { "setUpJalview", "setUpTree" })
+// public void createTreeView()
+// {
+// treeView = Archaeopteryx.createApplication(inputTree);
+// aptx = (MainFrame) treeView; // pretty ugly
+// treePanel = aptx.getMainPanel().getCurrentTreePanel();
+// tree = treePanel.getPhylogeny();
+//
+// Desktop.addInternalFrame(aptx, "Archaeopteryx", 500, 500);
+//
+// }
+//
+//
+//
+// @Test(groups = "Functional")
+// public void testMainPanelExists()
+// {
+// assertTrue(aptx.getMainPanel() != null);
+// }
+//
+// @Test(groups = "Functional")
+// public void testTreePanelExists()
+// {
+// assertTrue(treePanel != null);
+// }
+//
+// @Override
+// public void testTreeTitle()
+// {
+// assertTrue(tree.getName().equals("test"));
+//
+// }
+//
+// @Test(
+// groups = "Functional",
+// expectedExceptions = IllegalArgumentException.class)
+// public void testInvalidBranchName()
+// {
+// tree.getNode("I shouldn't exist");
+//
+// }
+//
+// @Override
+// public void testExistingBranchName()
+// {
+// tree.getNode("leaf 2");
+//
+// }
+//
+// @Override
+// public void testTreeLoaded()
+// {
+// assertTrue(tree != null);
+// }
+//
+// @Override
+// public void testChildNodesCount()
+// {
+// assertEquals(tree.getNode("ancestor 1").getNumberOfExternalNodes(), 3);
+//
+// }
+//
+// @Override
+// public void testChildToParentBranchLength()
+// {
+// assertEquals(tree.getNode("leaf 1a").getDistanceToParent(), 2.0);
+//
+// }
+//
+// @Override
+// public void testNodeToRootBranchLength()
+// {
+// assertEquals(tree.getNode("leaf 2").getDistanceToParent(), 42.0);
+//
+// }
+//
+// @Override
+// public void testDistantNodeToRootBranchLength()
+// {
+// assertEquals(tree.getNode("leaf 1c").calculateDistanceToRoot(),
+// 4.0 + 36.0);
+//
+// }
+//
+//
+//
+//
+//
+//
+//
+// }
import static org.testng.Assert.assertTrue;
import jalview.bin.Jalview;
+import jalview.ext.treeviewer.ExternalTreeFrame;
import jalview.gui.Desktop;
import jalview.gui.JvOptionPane;
-import javax.swing.JInternalFrame;
-
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
{
Jalview jalview;
- JInternalFrame treeView;
+ ExternalTreeFrame treeView;
@BeforeClass(alwaysRun = true)
public void setUpJvOptionPane()