Skip to content

Commit

Permalink
gui polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouckaert committed Dec 15, 2022
1 parent e826a5f commit f443d0e
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/cladeage/app/beauti/FossilCalibrationInputEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void init(Input<?> input, BEASTInterface plugin, int itemNr, ExpandOption
panel.addChangeListener(this);
Dimension2D size = new Dimension2D(panel.getPrefWidth() - 40, panel.getPrefHeight());

size = new Dimension2D(1024 - 40, panel.getPrefHeight());
panel.setPrefSize(size.getWidth(), size.getHeight());
panel.setMinSize(size.getWidth(), size.getHeight());
panel.setMaxSize(size.getWidth(), size.getHeight());
Expand Down
21 changes: 20 additions & 1 deletion src/cladeage/app/beauti/FossilPriorInputEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@


import beastfx.app.inputeditor.BeautiDoc;
import beastfx.app.inputeditor.Expandable;
import beastfx.app.inputeditor.ListInputEditor;
import beastfx.app.inputeditor.MRCAPriorInputEditor;
import beastfx.app.beauti.PriorInputEditor;
import beastfx.app.inputeditor.TaxonSetDialog;
Expand All @@ -14,6 +16,7 @@
import javafx.scene.control.CheckBox;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import beast.base.core.BEASTInterface;
import beast.base.core.Input;
import beast.base.evolution.alignment.Taxon;
Expand All @@ -24,7 +27,7 @@
import beast.base.inference.distribution.OneOnX;


public class FossilPriorInputEditor extends MRCAPriorInputEditor {
public class FossilPriorInputEditor extends MRCAPriorInputEditor implements Expandable {

public FossilPriorInputEditor(BeautiDoc doc) {
super(doc);
Expand Down Expand Up @@ -52,6 +55,7 @@ public void init(Input<?> input, BEASTInterface plugin, final int listItemNr, Ex
m_input = input;
m_beastObject = plugin;
this.itemNr= listItemNr;


HBox itemBox = FXUtils.newHBox();

Expand Down Expand Up @@ -103,6 +107,8 @@ public void init(Input<?> input, BEASTInterface plugin, final int listItemNr, Ex
//itemBox.getChildren().add(Box.createGlue());

getChildren().add(itemBox);
setPrefHeight(20);
setMaxHeight(20);
}

Set<Taxon> getTaxonCandidates(FossilPrior prior) {
Expand All @@ -125,4 +131,17 @@ Set<Taxon> getTaxonCandidates(FossilPrior prior) {
return candidates;
}

VBox expandBox = null;
public void setExpandBox(VBox expandBox) {
this.expandBox = expandBox;
}

@Override
public void refreshPanel() {
if (expandBox != null) {
ListInputEditor.updateExpandBox(doc, expandBox, m_beastObject, this);
}
super.refreshPanel();
}

}
110 changes: 110 additions & 0 deletions src/cladeage/app/beauti/FossilPriorListInputEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@

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;
import beastfx.app.inputeditor.SmallLabel;
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;
Expand All @@ -26,7 +35,12 @@
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;
import beast.base.inference.distribution.OneOnX;


Expand Down Expand Up @@ -184,4 +198,100 @@ private void setValue(Input<RealParameter> input, double value) {
}
}


protected void addSingleItem(BEASTInterface beastObject) {
Pane itemBox0 = FXUtils.newVBox();
Pane itemBox = FXUtils.newHBox();

SmallButton editButton = new SmallButton("e", true, SmallButton.ButtonType.square);
editButton.setId(beastObject.getID() + ".editButton");
editButton.setTooltip(new Tooltip("Expand/collapse item in the list"));
editButton.setButtonType(SmallButton.ButtonType.toolbar);
m_editButton.add(editButton);
itemBox.getChildren().add(editButton);

InputEditor editor = addPluginItem(itemBox, beastObject);

SmallLabel validateLabel = new SmallLabel("x", "red");
itemBox.getChildren().add(validateLabel);
validateLabel.setVisible(true);
m_validateLabels.add(validateLabel);

itemBox0.getChildren().add(itemBox);
VBox expandBox = createExpandBox(beastObject, editor, editButton);

editButton.setOnAction(e-> {
expandBox.setVisible(!expandBox.isVisible());
if (expandBox.isVisible()) {
try {
editButton.setImg(DOWN_ICON);
}catch (Exception e2) {
// ignore
}
expandBox.setPrefHeight(USE_COMPUTED_SIZE);
//expandBox.setMinHeight(m_box.getPrefHeight());
expandBox.setMinHeight(400);
expandBox.setVisible(true);
expandBox.setManaged(true);
g_collapsedIDs.remove(m_beastObject.getID());
} else {
try {
editButton.setImg(RIGHT_ICON);
}catch (Exception e2) {
// ignore
}
expandBox.setPrefHeight(0);
expandBox.setMinHeight(0);
expandBox.setVisible(false);
expandBox.setManaged(false);
g_collapsedIDs.add(m_beastObject.getID());
}
});
try {
if (!g_collapsedIDs.contains(m_beastObject.getID())) {
editButton.setImg(DOWN_ICON);
} else {
editButton.setImg(RIGHT_ICON);
}
} catch (Exception e) {
// ignore
}
itemBox0.getChildren().add(expandBox);

m_listBox.getChildren().add(itemBox0);

} // addSingleItem

private VBox createExpandBox(BEASTInterface beastObject, InputEditor editor, SmallButton editButton) {
VBox expandBox = FXUtils.newVBox();
FossilCalibrationInputEditor fossilCalibrationEditor = new FossilCalibrationInputEditor(doc);
FossilPrior prior = (FossilPrior) beastObject;
fossilCalibrationEditor.init(prior.calibrationDistr, beastObject, -1, m_bExpandOption, m_bAddButtons);
expandBox.getChildren().clear();
expandBox.getChildren().add(fossilCalibrationEditor);

if (g_collapsedIDs.contains(m_beastObject.getID())) {
expandBox.setPrefHeight(0);
expandBox.setMinHeight(0);
expandBox.setVisible(false);
expandBox.setManaged(false);
} else {
expandBox.setPrefHeight(USE_COMPUTED_SIZE);
expandBox.setMinHeight(expandBox.getPrefHeight());
expandBox.setVisible(true);
expandBox.setManaged(true);
}

if (editor instanceof Expandable) {
((Expandable)editor).setExpandBox(expandBox);
}
String id = m_beastObject.getID();
expandBox.setVisible(!g_collapsedIDs.contains(id));

m_listBox.getChildren().add(expandBox);
return expandBox;
}



}
2 changes: 1 addition & 1 deletion src/cladeage/app/ca/CAPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ protected void refresh() {

series.getData().clear();
for (int i = 0; i < ages.length; i++) {
series.getData().add(new XYChart.Data<Number,Number>(ages[i], fyPoints[i]));
series.getData().add(new XYChart.Data<Number,Number>(ages[ages.length - 1 - i], fyPoints[i]));
}


Expand Down

0 comments on commit f443d0e

Please sign in to comment.