public void setValueAt(Object aValue, int row, int col) { AbstractPartitionData partition = options.dataPartitions.get(row); switch (col) { case 0: String name = ((String) aValue).trim(); if (options.hasPartitionData(name)) { JOptionPane.showMessageDialog( frame, "Duplicate partition name.", "Illegal Argument Exception", JOptionPane.ERROR_MESSAGE); return; } if (name.length() > 0) { options.renamePartition(partition, name); } break; case 5: // partition.setPloidyType((PloidyType) aValue); // break; // case 6: if (((PartitionSubstitutionModel) aValue).getDataType().equals(partition.getDataType())) { partition.setPartitionSubstitutionModel((PartitionSubstitutionModel) aValue); } break; case 6: partition.setPartitionClockModel((PartitionClockModel) aValue); break; case 7: partition.setPartitionTreeModel((PartitionTreeModel) aValue); break; } fireDataChanged(); }
public void linkTrees() { // keep previous PartitionTreePrior for reuse int[] selRows = dataTable.getSelectedRows(); List<AbstractPartitionData> selectedPartitionData = new ArrayList<AbstractPartitionData>(); for (int row : selRows) { AbstractPartitionData partition = options.dataPartitions.get(row); if (!selectedPartitionData.contains(partition)) selectedPartitionData.add(partition); } if (selectedPartitionData.size() > 1) { if (!options.hasIdenticalTaxa(selectedPartitionData)) { String errMsg = "To share a tree, partitions need to have identical taxa."; if (selectedPartitionData.get(0).getDataType().getType() == DataType.MICRO_SAT) errMsg += "\nThe data must be all diploid or all haploid when you want to link the tree."; JOptionPane.showMessageDialog( this, errMsg, "Illegal Configuration", JOptionPane.ERROR_MESSAGE); return; } } Object[] treeArray = options.getPartitionTreeModels(selectedPartitionData).toArray(); if (selectTreeDialog == null) { selectTreeDialog = new SelectTreeDialog(frame); } int result = selectTreeDialog.showDialog(treeArray); if (result != JOptionPane.CANCEL_OPTION) { PartitionTreeModel model = selectTreeDialog.getTree(); if (selectTreeDialog.getMakeCopy()) { model.setName(selectTreeDialog.getName()); } PartitionTreePrior prior = model.getPartitionTreePrior(); options.linkTreePriors(prior); for (AbstractPartitionData partition : selectedPartitionData) { partition.setPartitionTreeModel(model); } for (Taxa taxa : options.taxonSets) { // Issue 454: all the taxon sets are deleted when link/unlink tree PartitionTreeModel prevModel = options.taxonSetsTreeModel.get(taxa); if (prevModel != model) options.taxonSetsTreeModel.put(taxa, model); } } modelsChanged(); fireDataChanged(); repaint(); }
public void linkTrees() { // keep previous PartitionTreePrior for reuse int[] selRows = dataTable.getSelectedRows(); List<PartitionData> selectedPartitionData = new ArrayList<PartitionData>(); for (int row : selRows) { PartitionData partition = options.dataPartitions.get(row); if (!selectedPartitionData.contains(partition)) selectedPartitionData.add(partition); } if (options.allowDifferentTaxa) { // BEAST cannot handle multi <taxa> ref for 1 tree if (selectedPartitionData.size() > 1) { if (!options.validateDiffTaxa(selectedPartitionData)) { JOptionPane.showMessageDialog( this, "To accommodate different taxa for each partition trees cannot be linked.", "Illegal Configuration", JOptionPane.ERROR_MESSAGE); return; } } } Object[] treeArray = options.getPartitionTreeModels(selectedPartitionData).toArray(); if (selectTreeDialog == null) { selectTreeDialog = new SelectTreeDialog(frame); } int result = selectTreeDialog.showDialog(treeArray); if (result != JOptionPane.CANCEL_OPTION) { PartitionTreeModel model = selectTreeDialog.getTree(); if (selectTreeDialog.getMakeCopy()) { model.setName(selectTreeDialog.getName()); } PartitionTreePrior prior = model.getPartitionTreePrior(); options.linkTreePriors(prior); for (PartitionData partition : selectedPartitionData) { partition.setPartitionTreeModel(model); } } modelsChanged(); fireDataChanged(); options.taxonSets.clear(); options.taxonSetsMono.clear(); repaint(); }
public void linkModels() { int[] selRows = dataTable.getSelectedRows(); List<AbstractPartitionData> selectedPartitionData = new ArrayList<AbstractPartitionData>(); DataType dateType = null; for (int row : selRows) { AbstractPartitionData partition = options.dataPartitions.get(row); if (dateType == null) { dateType = partition.getDataType(); } else { if (partition.getDataType() != dateType) { JOptionPane.showMessageDialog( this, "Can only link the models for data partitions \n" + "of the same data type (e.g., nucleotides)", "Unable to link models", JOptionPane.ERROR_MESSAGE); return; } } if (!selectedPartitionData.contains(partition)) selectedPartitionData.add(partition); } Object[] modelArray = options.getPartitionSubstitutionModels(selectedPartitionData).toArray(); if (selectModelDialog == null) { selectModelDialog = new SelectModelDialog(frame); } int result = selectModelDialog.showDialog(modelArray); if (result != JOptionPane.CANCEL_OPTION) { PartitionSubstitutionModel model = selectModelDialog.getModel(); if (selectModelDialog.getMakeCopy()) { model.setName(selectModelDialog.getName()); } for (AbstractPartitionData partition : selectedPartitionData) { partition.setPartitionSubstitutionModel(model); } } if (options.getPartitionSubstitutionModels(Microsatellite.INSTANCE).size() <= 1) { options.shareMicroSat = true; } modelsChanged(); fireDataChanged(); repaint(); }
private void showAlignment() { int[] selRows = dataTable.getSelectedRows(); for (int row : selRows) { AbstractPartitionData partition = options.dataPartitions.get(row); Alignment alignment = null; if (partition instanceof PartitionData) alignment = ((PartitionData) partition).getAlignment(); // alignment == null if partition is trait or microsat // http://code.google.com/p/beast-mcmc/issues/detail?id=343 if (alignment == null) { JOptionPane.showMessageDialog( this, "Cannot display traits or microsatellite data currently.\nUse the traits panel to view and edit traits.", "Illegal Argument Exception", JOptionPane.ERROR_MESSAGE); return; } JFrame frame = new JFrame(); frame.setSize(800, 600); AlignmentViewer viewer = new AlignmentViewer(); if (alignment.getDataType().getType() == DataType.NUCLEOTIDES) { viewer.setCellDecorator(new StateCellDecorator(new NucleotideDecorator(), false)); } else if (alignment.getDataType().getType() == DataType.AMINO_ACIDS) { viewer.setCellDecorator(new StateCellDecorator(new AminoAcidDecorator(), false)); } else { // no colouring } viewer.setAlignmentBuffer(new BeautiAlignmentBuffer(alignment)); JPanel panel = new JPanel(new BorderLayout()); panel.setOpaque(false); panel.add(viewer, BorderLayout.CENTER); JPanel infoPanel = new JPanel(new BorderLayout()); infoPanel.setOpaque(false); panel.add(infoPanel, BorderLayout.SOUTH); frame.setContentPane(panel); frame.setVisible(true); } }