public void removeSelection() { int[] selRows = dataTable.getSelectedRows(); Set<AbstractPartitionData> partitionsToRemove = new HashSet<AbstractPartitionData>(); for (int row : selRows) { partitionsToRemove.add(options.dataPartitions.get(row)); } boolean hasIdenticalTaxa = options.hasIdenticalTaxa(); // need to check this before removing partitions // TODO: would probably be a good idea to check if the user wants to remove the last partition options.dataPartitions.removeAll(partitionsToRemove); if (options.dataPartitions.size() == 0) { // all data partitions removed so reset the taxa options.reset(); useStarBEASTCheck.setSelected(false); frame.setupStarBEAST(false); frame.statusLabel.setText(""); frame.setAllOptions(); frame.getExportAction().setEnabled(false); } else if (!hasIdenticalTaxa) { options.updateTaxonList(); } dataTableModel.fireTableDataChanged(); fireDataChanged(); }
public void removeSelection() { int[] selRows = dataTable.getSelectedRows(); Set<PartitionData> partitionsToRemove = new HashSet<PartitionData>(); for (int row : selRows) { partitionsToRemove.add(options.dataPartitions.get(row)); } // TODO: would probably be a good idea to check if the user wants to remove the last partition options.dataPartitions.removeAll(partitionsToRemove); // if (options.allowDifferentTaxa && options.dataPartitions.size() < 2) { // uncheckAllowDifferentTaxa(); // } if (options.getNonTraitsDataList().size() == 0) { // all data partitions removed so reset the taxa options.reset(); useStarBEASTCheck.setSelected(false); frame.statusLabel.setText(""); frame.setAllOptions(); frame.getExportAction().setEnabled(false); } dataTableModel.fireTableDataChanged(); fireDataChanged(); }
public void setOptions(BeautiOptions options) { this.options = options; modelsChanged(); useStarBEASTCheck.setEnabled( options.getNonTraitsDataList().size() > 0); // single partition is allowed createImportTraitButton.setEnabled(options.getNonTraitsDataList().size() > 0); dataTableModel.fireTableDataChanged(); }
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(); }
public void unlinkTrees() { // reuse previous PartitionTreePrior int[] selRows = dataTable.getSelectedRows(); for (int row : selRows) { PartitionData partition = options.dataPartitions.get(row); PartitionTreeModel model = partition.getPartitionTreeModel(); if (!model.getName().equals(partition.getName()) && partition.getTraitType() == null) { // not a trait PartitionTreeModel newTree = new PartitionTreeModel(options, partition); // this prevents partition not broken, and used for unsharing tree prior only, // because sharing uses shareSameTreePrior, unsharing uses getPartitionTreePrior // newTree.setPartitionTreePrior(newPrior); // important partition.setPartitionTreeModel(newTree); } } options.linkTreePriors(frame.getCurrentPartitionTreePrior()); modelsChanged(); fireDataChanged(); options.taxonSets.clear(); options.taxonSetsMono.clear(); repaint(); }
public void linkClocks() { // 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); } Object[] modelArray = options.getPartitionClockModels(selectedPartitionData).toArray(); if (selectClockDialog == null) { selectClockDialog = new SelectClockDialog(frame); } int result = selectClockDialog.showDialog(modelArray); if (result != JOptionPane.CANCEL_OPTION) { PartitionClockModel model = selectClockDialog.getModel(); if (selectClockDialog.getMakeCopy()) { model.setName(selectClockDialog.getName()); } for (PartitionData partition : selectedPartitionData) { partition.setPartitionClockModel(model); } } modelsChanged(); fireDataChanged(); repaint(); }
public boolean createFromTraits(List<TraitData> traits) { int selRow = -1; if (selectTraitDialog == null) { selectTraitDialog = new SelectTraitDialog(frame); } if (traits == null || traits.size() == 0) { int result = selectTraitDialog.showDialog(options.traits, null); if (result != JOptionPane.CANCEL_OPTION) { TraitData trait = selectTraitDialog.getTrait(); String name = trait.getName(); if (selectTraitDialog.getMakeCopy()) { name = selectTraitDialog.getName(); } selRow = options.createPartitionForTraits(name, trait); } else { return false; } } else { if (traits.size() > 1) { // a set of traits have been passed to the function int result = selectTraitDialog.showDialog(null, null); if (result != JOptionPane.CANCEL_OPTION) { String name = selectTraitDialog.getName(); selRow = options.createPartitionForTraits(name, traits); } else { return false; } } else { selRow = options.createPartitionForTraits(traits.get(0).getName(), traits); } } modelsChanged(); dataTableModel.fireTableDataChanged(); if (selRow != -1) { dataTable.getSelectionModel().setSelectionInterval(selRow, selRow); } fireDataChanged(); repaint(); return true; }
private void modelsChanged() { TableColumn col = dataTable.getColumnModel().getColumn(5); col.setCellEditor(new ComboBoxCellEditor()); col = dataTable.getColumnModel().getColumn(6); col.setCellEditor(new ComboBoxCellEditor()); col = dataTable.getColumnModel().getColumn(7); col.setCellEditor( new DefaultCellEditor(new JComboBox(options.getNonTraitPartitionTreeModels().toArray()))); }
private void fireDataChanged() { // options.updateLinksBetweenPDPCMPSMPTMPTPP(); options.updatePartitionAllLinks(); if (!(options.clockModelOptions.getRateOptionClockModel() == FixRateType.TIP_CALIBRATED || options.clockModelOptions.getRateOptionClockModel() == FixRateType.NODE_CALIBRATED || options.clockModelOptions.getRateOptionClockModel() == FixRateType.RATE_CALIBRATED)) { // TODO correct? options.clockModelOptions.fixRateOfFirstClockPartition(); } frame.setDirty(); }
private void fireDataChanged() { options.updatePartitionAllLinks(); frame.setDirty(); }