import javax.swing.JSeparator;
import javax.swing.event.InternalFrameListener;
+import org.forester.archaeopteryx.Archaeopteryx;
+import org.forester.archaeopteryx.Configuration;
import org.forester.archaeopteryx.MainFrame;
+import org.forester.phylogeny.Phylogeny;
import org.jibble.epsgraphics.EpsGraphics2D;
public class AptxFrame implements ExternalTreeFrame
private ExternalTreeControlsI aptxControls;
+
+ public AptxFrame(Phylogeny tree, Configuration aptxConfig,
+ String treeTitle)
+ {
+ this(Archaeopteryx.createApplication(tree,
+ aptxConfig,
+ treeTitle));
+
+ }
+
+
public AptxFrame(MainFrame aptx)
{
+
aptxFrame = aptx;
aptxPanel = new AptxTreePanel(
aptxFrame.getMainPanel().getCurrentTreePanel());
adaptAptxGui(aptxFrame);
}
+
/**
* Hides certain redundant Archaeopteryx GUI elements such as the menu items
* for reading in trees and adds extra items related to Jalview such as the
- * tree sorting item.
+ * tree sorting menu item.
*
*
* @param aptxFrame
*/
- private void adaptAptxGui(MainFrame aptxFrame)
+ protected void adaptAptxGui(MainFrame aptxFrame)
{
JMenuBar frameBar = aptxFrame.getJMenuBar();
boolean epsAdded = false;
}
}
- aptxFrame.validate();
+ // aptxFrame.validate();
}
public void epsTree_actionPerformed(ActionEvent e)
return aptxApp;
}
+
/**
* Refactored from Archaeopteryx.main
*
}
String treeTitle = treeFile.getName() + "[" + i + "]";
aptxPhylogeny.setName(treeTitle);
- Tree aptxTree = new Tree(aptxPhylogeny);
- aptxFrames[i] = createAptxFrame(aptxTree, viewport, treeTitle);
+ aptxFrames[i] = createAptxFrame(aptxPhylogeny, viewport, treeTitle);
}
if (Desktop.instance != null)
for (int i = 0; i < trees.length; i++)
{
Phylogeny aptxTree = trees[i];
- Tree jalviewTree = new Tree(aptxTree);
- aptxFrames[i] = createAptxFrame(jalviewTree, viewport, treeTitle);
+ aptxFrames[i] = createAptxFrame(aptxTree, viewport, treeTitle);
}
if (Desktop.instance != null)
URL url = null;
Phylogeny[] trees = null;
+ ExternalTreeFrame[] aptxFrames = null;
if ((identifier != null) && (identifier.trim().length() > 0))
{
// _main_frame.getMainPanel().setWaitCursor();
// }
trees = ForesterUtil.readPhylogeniesFromUrl(url, parser);
+ aptxFrames = new ExternalTreeFrame[trees.length];
} catch (final MalformedURLException e)
{
exception = true;
}
if ((trees != null) && (trees.length > 0))
{
+ int i = 0;
for (final Phylogeny aptxTree : trees)
{
if (!aptxTree.isEmpty())
// _main_frame.getConfiguration(),
// new File(url.getFile()).getName(), url.toString());
- Tree jalviewTree = new Tree(aptxTree);
- ExternalTreeFrame aptxApp = createAptxFrame(jalviewTree,
+ ExternalTreeFrame aptxApp = createAptxFrame(aptxTree,
viewport,
url.getFile());
String my_name_for_file = "";
- if (!ForesterUtil.isEmpty(jalviewTree.getTreeName()))
+ if (!ForesterUtil.isEmpty(aptxTree.getName()))
{
- my_name_for_file = new String(jalviewTree.getTreeName())
+ my_name_for_file = new String(aptxTree.getName())
.replaceAll(" ", "_");
}
else if (aptxTree.getIdentifier() != null)
aptxApp.getTreeControls().displayEntireTree();
aptxApp.checkMultipleTrees();
+ aptxFrames[i++] = aptxApp;
}
}
}
{
Desktop.instance.stopLoading();
}
- return null;
+ return aptxFrames;
}
-
-
- public static ExternalTreeFrame createAptxFrame(
- final ExternalTreeI aptxTree,
- final AlignmentViewport jalviewAlignport, String treeTitle)
+ public static ExternalTreeFrame createAptxFrame(ExternalTreeI aptxTree,
+ AlignmentViewport jalviewAlignport, String treeTitle)
{
- if (APTX_CONFIG == null || APTX_CONFIG.isCouldReadConfigFile() == false)
- {
- int keepGoing = JvOptionPane.showConfirmDialog(Desktop.desktop,
- MessageManager.getString("label.aptx_config_not_found"),
- MessageManager.formatMessage("label.couldnt_locate",
- new String[]
- { "_aptx_jalview_configuration_file" }),
- JvOptionPane.YES_NO_CANCEL_OPTION);
+ validateConfig(APTX_CONFIG);
+ ExternalTreeFrame aptxApp = aptxTree
+ .createTreeViewerFromTree(treeTitle);
+ ExternalTreeI jalviewTree = aptxApp.getTree();
+ ExternalLoadedTreeAssociationI bindAptxNodes = new LoadedTreeSequenceAssociation(
+ jalviewAlignport.getAlignment().getSequencesArray(),
+ jalviewTree);
+ bindAptxNodes.associateLeavesToSequences();
- if (keepGoing == JvOptionPane.CANCEL_OPTION
- || keepGoing == JvOptionPane.CLOSED_OPTION
- || keepGoing == JvOptionPane.NO_OPTION)
- {
- return null;
- }
+ bindNodesToJalviewSequences(aptxApp, jalviewAlignport,
+ bindAptxNodes.getAlignmentWithNodes(),
+ bindAptxNodes.getNodesWithAlignment());
+ bindTreeViewFrameToJalview(aptxApp);
- }
- ExternalTreeFrame aptxApp = aptxTree.createInstanceFromTree(treeTitle);
+ // adaptAptxGui(aptxApp); //moved to AptxFrame
+ return aptxApp;
+ }
+
+ protected static ExternalTreeFrame createAptxFrame(
+ final Phylogeny aptxTree,
+ final AlignmentViewport jalviewAlignport, String treeTitle)
+ {
+ validateConfig(APTX_CONFIG);
+ ExternalTreeFrame aptxApp = new AptxFrame(aptxTree, APTX_CONFIG,
+ treeTitle);
+ ExternalTreeI jalviewTree = aptxApp.getTree();
ExternalLoadedTreeAssociationI bindAptxNodes = new LoadedTreeSequenceAssociation(
- jalviewAlignport.getAlignment().getSequencesArray(), aptxTree);
+ jalviewAlignport.getAlignment().getSequencesArray(),
+ jalviewTree);
bindAptxNodes.associateLeavesToSequences();
bindNodesToJalviewSequences(aptxApp, jalviewAlignport,
}
- public static ExternalTreeViewerBindingI bindNodesToJalviewSequences(
+ protected static ExternalTreeViewerBindingI bindNodesToJalviewSequences(
final ExternalTreeFrame aptxApp,
final AlignmentViewport jalviewAlignViewport,
final Map<SequenceI, ExternalTreeNodeI> alignMappedToNodes,
}
- public static ExternalTreeFrame bindTreeViewFrameToJalview(
+ protected static ExternalTreeFrame bindTreeViewFrameToJalview(
final ExternalTreeFrame aptxApp)
{
int width = 400;
}
+ private static boolean validateConfig(Configuration aptxConfig)
+ {
+ if (aptxConfig == null || aptxConfig.isCouldReadConfigFile() == false)
+ {
+ int keepGoing = JvOptionPane.showConfirmDialog(Desktop.desktop,
+ MessageManager.getString("label.aptx_config_not_found"),
+ MessageManager.formatMessage("label.couldnt_locate",
+ new String[]
+ { "_aptx_jalview_configuration_file" }),
+ JvOptionPane.YES_NO_CANCEL_OPTION);
+
+ if (keepGoing == JvOptionPane.CANCEL_OPTION
+ || keepGoing == JvOptionPane.CLOSED_OPTION
+ || keepGoing == JvOptionPane.NO_OPTION)
+ {
+ return false;
+ }
+
+ }
+ return true;
+ }
+
public static Map<ExternalTreeFrame, ExternalTreeViewerBindingI> getAllAptxFrames()