diff --git a/src/cladeage/app/beauti/FossilPriorInputEditor.java b/src/cladeage/app/beauti/FossilPriorInputEditor.java index 5ede5ae..111e0ff 100644 --- a/src/cladeage/app/beauti/FossilPriorInputEditor.java +++ b/src/cladeage/app/beauti/FossilPriorInputEditor.java @@ -12,6 +12,7 @@ import beastfx.app.beauti.PriorInputEditor; import beastfx.app.inputeditor.TaxonSetDialog; import beastfx.app.util.FXUtils; +import javafx.geometry.Insets; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; import javafx.scene.control.Tooltip; @@ -57,7 +58,8 @@ public void init(Input input, BEASTInterface plugin, final int listItemNr, Ex this.itemNr= listItemNr; - HBox itemBox = FXUtils.newHBox(); + HBox itemBox = new HBox(); + itemBox.setSpacing(5); MRCAPrior prior = (MRCAPrior) plugin; String sText = prior.taxonsetInput.get().getID(); @@ -100,6 +102,7 @@ public void init(Input input, BEASTInterface plugin, final int listItemNr, Ex isMonophyleticdBox.setId(sText+".isMonophyletic"); isMonophyleticdBox.setSelected(prior.isMonophyleticInput.get()); isMonophyleticdBox.setTooltip(new Tooltip(prior.isMonophyleticInput.getTipText())); + isMonophyleticdBox.setPadding(new Insets(5)); isMonophyleticdBox.setOnAction(e->{ prior.isMonophyleticInput.setValue(isMonophyleticdBox.isSelected(), prior); }); diff --git a/src/cladeage/app/beauti/FossilPriorListInputEditor.java b/src/cladeage/app/beauti/FossilPriorListInputEditor.java index c24159d..6d74767 100644 --- a/src/cladeage/app/beauti/FossilPriorListInputEditor.java +++ b/src/cladeage/app/beauti/FossilPriorListInputEditor.java @@ -2,13 +2,13 @@ + import java.util.ArrayList; import java.util.List; import beastfx.app.inputeditor.BeautiDoc; import beastfx.app.inputeditor.BeautiSubTemplate; -import beastfx.app.inputeditor.ExpandActionListener; import beastfx.app.inputeditor.Expandable; import beastfx.app.inputeditor.InputEditor; import beastfx.app.inputeditor.SmallButton; @@ -16,13 +16,10 @@ import beast.base.parser.PartitionContext; import beastfx.app.beauti.PriorListInputEditor; import beastfx.app.inputeditor.TaxonSetDialog; -import beastfx.app.inputeditor.InputEditor.ExpandOption; -import beastfx.app.inputeditor.ListInputEditor.ActionListenerObject; import beastfx.app.util.Alert; import beastfx.app.util.FXUtils; import cladeage.app.ca.CAPanel; import cladeage.app.ca.CAPanelListener; -import beastfx.app.inputeditor.BEASTObjectInputEditor; import beastfx.app.inputeditor.BEASTObjectPanel; import beast.base.core.BEASTInterface; import beast.base.core.Input; @@ -35,9 +32,6 @@ import beast.base.evolution.tree.Tree; import cladeage.math.distributions.FossilCalibration; import cladeage.math.distributions.FossilPrior; -import javafx.event.ActionEvent; -import javafx.scene.Node; -import javafx.scene.control.Control; import javafx.scene.control.Tooltip; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; @@ -62,6 +56,7 @@ public Class baseType() { CAPanel caPanel; FossilCalibration calibration; + boolean topPanelPresent = false; @Override public void init(Input input, BEASTInterface plugin, int itemNr, ExpandOption bExpandOption, boolean bAddButtons) { @@ -70,26 +65,33 @@ public void init(Input input, BEASTInterface plugin, int itemNr, ExpandOption // add panel at end List list = (List) input.get(); if (list.size() > 0) { - calibration = ((FossilPrior) list.get(0)).calibrationDistr.get(); - caPanel = new CAPanel(CAPanel.MODE_BEAUTI_TOP); - caPanel.setMinDivRate(calibration.minDivRateInput.get().getValue()); - caPanel.setMinTurnoverRate(calibration.minTurnoverRateInput.get().getValue()); - caPanel.setMinSamplingRate(calibration.minSamplingRateInput.get().getValue()); - caPanel.setMaxDivRate(calibration.maxDivRateInput.get().getValue()); - caPanel.setMaxTurnoverRate(calibration.maxTurnoverRateInput.get().getValue()); - caPanel.setMaxSamplingRate(calibration.maxSamplingRateInput.get().getValue()); - caPanel.setMethod(calibration.cladeAgeMethodInput.get()); - caPanel.dataToGUI(); - caPanel.addChangeListener(this); - caPanel.setVisible(true); - caPanel.setPrefWidth(640); - Pane p = ((Pane)pane.getChildren().get(0)); - int pos = p.getChildren().size() - 1; - p.getChildren().add(pos, caPanel); + addTopCAPanel(((FossilPrior) list.get(0)).calibrationDistr.get()); } } - @Override + private void addTopCAPanel(FossilCalibration calibrationx) { + calibration = calibrationx; + caPanel = new CAPanel(CAPanel.MODE_BEAUTI_TOP); + caPanel.setMinDivRate(calibration.minDivRateInput.get().getValue()); + caPanel.setMinTurnoverRate(calibration.minTurnoverRateInput.get().getValue()); + caPanel.setMinSamplingRate(calibration.minSamplingRateInput.get().getValue()); + caPanel.setMaxDivRate(calibration.maxDivRateInput.get().getValue()); + caPanel.setMaxTurnoverRate(calibration.maxTurnoverRateInput.get().getValue()); + caPanel.setMaxSamplingRate(calibration.maxSamplingRateInput.get().getValue()); + caPanel.setMethod(calibration.cladeAgeMethodInput.get()); + caPanel.dataToGUI(); + caPanel.addChangeListener(this); + caPanel.setVisible(true); + caPanel.setPrefWidth(640); + if (pane.getChildren().size() > 0) { + Pane p = ((Pane)pane.getChildren().get(0)); + int pos = p.getChildren().size() - 1; + p.getChildren().add(pos, caPanel); + topPanelPresent = true; + } + } + + @Override public List pluginSelector(Input input, BEASTInterface parent, List sTabuList) { FossilPrior prior = new FossilPrior(); try { @@ -169,7 +171,8 @@ public List pluginSelector(Input input, BEASTInterface parent } List selectedPlugins = new ArrayList(); selectedPlugins.add(prior); - g_collapsedIDs.add(prior.getID()); + g_collapsedIDs.add(prior.getID()); + return selectedPlugins; } @@ -233,7 +236,7 @@ protected void addSingleItem(BEASTInterface beastObject) { expandBox.setMinHeight(400); expandBox.setVisible(true); expandBox.setManaged(true); - g_collapsedIDs.remove(m_beastObject.getID()); + g_collapsedIDs.remove(beastObject.getID()); } else { try { editButton.setImg(RIGHT_ICON); @@ -244,11 +247,11 @@ protected void addSingleItem(BEASTInterface beastObject) { expandBox.setMinHeight(0); expandBox.setVisible(false); expandBox.setManaged(false); - g_collapsedIDs.add(m_beastObject.getID()); + g_collapsedIDs.add(beastObject.getID()); } }); try { - if (!g_collapsedIDs.contains(m_beastObject.getID())) { + if (!g_collapsedIDs.contains(beastObject.getID())) { editButton.setImg(DOWN_ICON); } else { editButton.setImg(RIGHT_ICON); @@ -258,7 +261,17 @@ protected void addSingleItem(BEASTInterface beastObject) { } itemBox0.getChildren().add(expandBox); - m_listBox.getChildren().add(itemBox0); + int pos = 0; + if (topPanelPresent) { + pos = m_listBox.getChildren().size() - 2; + } + m_listBox.getChildren().add(pos, itemBox0); + + + if (!topPanelPresent) { + List list = (List) m_input.get(); + addTopCAPanel(((FossilPrior) list.get(0)).calibrationDistr.get()); + } } // addSingleItem @@ -270,7 +283,7 @@ private VBox createExpandBox(BEASTInterface beastObject, InputEditor editor, Sma expandBox.getChildren().clear(); expandBox.getChildren().add(fossilCalibrationEditor); - if (g_collapsedIDs.contains(m_beastObject.getID())) { + if (g_collapsedIDs.contains(beastObject.getID())) { expandBox.setPrefHeight(0); expandBox.setMinHeight(0); expandBox.setVisible(false); @@ -285,7 +298,7 @@ private VBox createExpandBox(BEASTInterface beastObject, InputEditor editor, Sma if (editor instanceof Expandable) { ((Expandable)editor).setExpandBox(expandBox); } - String id = m_beastObject.getID(); + String id = beastObject.getID(); expandBox.setVisible(!g_collapsedIDs.contains(id)); m_listBox.getChildren().add(expandBox); diff --git a/src/cladeage/app/ca/CAPanel.java b/src/cladeage/app/ca/CAPanel.java index ed43542..8c83b93 100644 --- a/src/cladeage/app/ca/CAPanel.java +++ b/src/cladeage/app/ca/CAPanel.java @@ -17,6 +17,7 @@ import beastfx.app.util.Alert; import beastfx.app.util.FXUtils; import javafx.application.Platform; +import javafx.geometry.Insets; import javafx.scene.Cursor; import javafx.scene.Node; import javafx.scene.chart.LineChart; @@ -256,6 +257,9 @@ public CAPanel(int mode) { //// setLayout(gridBagLayout); panel = new GridPane(); + panel.setHgap(5); + panel.setVgap(5); + panel.setPadding(new Insets(0,0,5,0)); //panel.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null), "Model parameters", TitledBorder.LEADING, TitledBorder.TOP, null, null)); // //gbc_panel.fill = GridBagConstraints.BOTH; // //gbc_panel.gridx = 0; @@ -308,7 +312,7 @@ public CAPanel(int mode) { //gbc_label.anchor = GridBagConstraints.EAST; //gbc_label.gridx = 2; //gbc_label.gridy = 1; - panel.add(label, 2 ,1 ,2, 1); //gbc_label); + panel.add(label, 2 ,1 ,1, 1); //gbc_label); textField_maxOccuranceAge = newTextField(); textField_maxOccuranceAge.setPrefColumnCount(10); @@ -317,7 +321,7 @@ public CAPanel(int mode) { //gbc_textField_1_1.fill = GridBagConstraints.HORIZONTAL; //gbc_textField_1_1.gridx = 3; //gbc_textField_1_1.gridy = 1; - panel.add(textField_maxOccuranceAge, 3, 1, 3, 1); //gbc_textField_1_1); + panel.add(textField_maxOccuranceAge, 3, 1, 1, 1); //gbc_textField_1_1); } // always create the combobox, even when it is not displayed @@ -338,7 +342,7 @@ public CAPanel(int mode) { panel.add(comboBox, 0, 0, 1, 1);//gbc_comboBox); comboBox.setOnAction(e->guiToData()); - Label lblNetDiversificationRate = new Label("Net diversification rate λ−μ:"); + Label lblNetDiversificationRate = new Label("Net diversification rate \u03BB-\u03BC:"); //GridBagConstraints //gbc_lblNetDiversificationRate = new GridBagConstraints(); //gbc_lblNetDiversificationRate.anchor = GridBagConstraints.EAST; //gbc_lblNetDiversificationRate.insets = new Insets(0, 0, 5, 5); @@ -371,7 +375,7 @@ public CAPanel(int mode) { //gbc_textField_2.gridy = 2; panel.add(textField_maxDivRate, 3, 2, 1, 1); //gbc_textField_2); - Label lblRurnoverRateDb = new Label("Turnover rate μ/λ:"); + Label lblRurnoverRateDb = new Label("Turnover rate \u03BC/\u03BB:"); //GridBagConstraints //gbc_lblRurnoverRateDb = new GridBagConstraints(); //gbc_lblRurnoverRateDb.anchor = GridBagConstraints.EAST; //gbc_lblRurnoverRateDb.insets = new Insets(0, 0, 5, 5); @@ -404,7 +408,7 @@ public CAPanel(int mode) { //gbc_textField_3.gridy = 3; panel.add(textField_maxTurnoverRate, 3, 3, 1, 1); //gbc_textField_3); - Label lblSamplingRate = new Label("Sampling rate ψ:"); + Label lblSamplingRate = new Label("Sampling rate \u03a8:"); //GridBagConstraints //gbc_lblSamplingRate = new GridBagConstraints(); //gbc_lblSamplingRate.anchor = GridBagConstraints.EAST; //gbc_lblSamplingRate.insets = new Insets(0, 0, 5, 5); @@ -467,12 +471,12 @@ public CAPanel(int mode) { //gbc_textField_11.gridy = 5; // panel.add(textField_minSamplingGap, //gbc_textField_11); - Label label_4 = new Label("-"); + //Label label_4 = new Label("-"); //GridBagConstraints //gbc_label_4 = new GridBagConstraints(); //gbc_label_4.insets = new Insets(0, 0, 0, 5); //gbc_label_4.gridx = 2; //gbc_label_4.gridy = 5; - panel.add(label_4, 2, 5, 1, 1); //gbc_label_4); + //panel.add(label_4, 2, 5, 1, 1); //gbc_label_4); // textField_maxSamplingGap = newTextField(); // textField_maxSamplingGap.addActionListener(new ActionListener() { @@ -491,7 +495,7 @@ public CAPanel(int mode) { //GridBagConstraints //gbc_btnNewButton = new GridBagConstraints(); //gbc_btnNewButton.gridx = 5; //gbc_btnNewButton.gridy = 1; - panel.add(btnHelpButtonFirstOccurance, 5, 1, 5, 10); //gbc_btnNewButton); + panel.add(btnHelpButtonFirstOccurance, 5, 1, 1, 1); //gbc_btnNewButton); btnHelpButtonFirstOccurance.setOnAction(e -> showHelp(OCCURRENCE_AGE_HELP) ); @@ -541,20 +545,22 @@ public CAPanel(int mode) { // }); // } - VBox panel2b = FXUtils.newVBox(); + HBox panel2b = FXUtils.newHBox(); // panel2b.setLayout(new BorderLayout()); - ImageView icon = FXUtils.getIcon(CA_ICON); + ImageView icon = FXUtils.getIcon(CA_ICON2); Label lblIcon = new Label(); lblIcon.setGraphic(icon); if (mode == MODE_BEAUTI_BOTTOM) { - lblIcon.setMinSize(84,84); + lblIcon.setMinSize(4,4); lblIcon.setPrefSize(84,84); + lblIcon.setMaxSize(4,4); + panel.add(lblIcon, 6, 2, 1, 1); } else { lblIcon.setMinSize(160,160); lblIcon.setPrefSize(160,160); + panel2b.getChildren().add(lblIcon); } - panel2b.getChildren().add(icon); btnCalculate = new Button("Run"); btnCalculate.setMinSize(128, 20); @@ -629,7 +635,11 @@ public void run() { // //gbc_btnCalculate.insets = new Insets(0, 0, 5, 0); // //gbc_btnCalculate.gridx = 0; // //gbc_btnCalculate.gridy = 4; - panel2b.getChildren().add(btnCalculate); + if (mode == MODE_BEAUTI_BOTTOM) { + panel.add(btnCalculate, 8, 1, 1, 1); + } else { + panel2b.getChildren().add(btnCalculate); + } //GridBagConstraints gbc_lblIcon = new GridBagConstraints(); //gbc_lblIcon.insets = new Insets(5, 0, 5, 5); @@ -792,7 +802,17 @@ public void run() { panel_1 = new GridPane();// { panel3.add(panel2b, 0, 2, 1, 1); - panel_1.add(chart, 0, 1, 1, 1); + if (mode == MODE_BEAUTI_BOTTOM) { + panel.add(chart, 0, 2, 6, 1); + chart.setOnMouseClicked(e->{ + String text = getFitParameters(); + text = text.replaceAll("\n", "
"); + showHelp("Distribution fit:
" + text + ""); + } + ); + } else { + panel_1.add(chart, 0, 1, 1, 1); + } // // // protected void paintComponent(java.awt.Graphics g) { @@ -990,7 +1010,9 @@ public void run() { //gbc_panel_1.fill = GridBagConstraints.BOTH; //gbc_panel_1.gridx = 0; //gbc_panel_1.gridy = 1; - panel3.getChildren().add(panel_1); //gbc_panel_1); + if (mode != MODE_BEAUTI_BOTTOM) { + panel3.getChildren().add(panel_1); //gbc_panel_1); + } // JPanel panel4 = new JPanel(); // panel4.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null), "Approximation", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(51, 51, 51))); // GridBagConstraints //gbc_panel4 = new GridBagConstraints(); diff --git a/src/cladeage/app/ca/CladeAgeProbabilities.java b/src/cladeage/app/ca/CladeAgeProbabilities.java index f497f6f..642c1b8 100644 --- a/src/cladeage/app/ca/CladeAgeProbabilities.java +++ b/src/cladeage/app/ca/CladeAgeProbabilities.java @@ -252,9 +252,7 @@ public CladeAgeDistribution run_standard_cladeage(double first_occurrence_age_mi } // Increment the progress indicator. if (dpb != null) { - Platform.runLater(() -> - dpb.setProgress(successful_simulations[successful_simulations.length-1]/100) - ); + dpb.progressProperty().set(successful_simulations[successful_simulations.length-1]/10000.0); } // Draw values for parameters ndr (net diversification rate, lambda - mu) and epsilon (turnover rate, mu/lambda) from uniform distributions, and calculate lambda and mu from them.