use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.
the class MathDescriptionTreeModel method createBaseTree.
/**
* Insert the method's description here.
* Creation date: (11/28/00 1:06:51 PM)
* @return cbit.vcell.desktop.BioModelNode
* @param docManager cbit.vcell.clientdb.DocumentManager
*/
private BioModelNode createBaseTree() {
if (getMathDescription() == null) {
return new BioModelNode(" ", false);
}
//
// make root node
//
BioModelNode rootNode = new BioModelNode("math description", true);
//
// create subTree of Constants
//
BioModelNode constantRootNode = new BioModelNode("constants", true);
Enumeration<Constant> enum1 = getMathDescription().getConstants();
while (enum1.hasMoreElements()) {
Constant constant = enum1.nextElement();
BioModelNode constantNode = new BioModelNode(constant, false);
constantRootNode.add(constantNode);
}
if (constantRootNode.getChildCount() > 0) {
rootNode.add(constantRootNode);
}
//
// create subTree of Functions
//
BioModelNode functionRootNode = new BioModelNode("functions", true);
Enumeration<Function> enum2 = getMathDescription().getFunctions();
while (enum2.hasMoreElements()) {
Function function = enum2.nextElement();
BioModelNode functionNode = new BioModelNode(function, false);
functionRootNode.add(functionNode);
}
if (functionRootNode.getChildCount() > 0) {
rootNode.add(functionRootNode);
}
//
// create subTree of VolumeSubDomains and MembraneSubDomains
//
BioModelNode volumeRootNode = new BioModelNode("volume domains", true);
BioModelNode membraneRootNode = new BioModelNode("membrane domains", true);
Enumeration<SubDomain> enum3 = getMathDescription().getSubDomains();
while (enum3.hasMoreElements()) {
SubDomain subDomain = enum3.nextElement();
if (subDomain instanceof cbit.vcell.math.CompartmentSubDomain) {
CompartmentSubDomain volumeSubDomain = (CompartmentSubDomain) subDomain;
BioModelNode volumeSubDomainNode = new BioModelNode(volumeSubDomain, true);
if (// stochastic subtree
getMathDescription().isNonSpatialStoch()) {
// add stoch variable initial conditions
BioModelNode varIniConditionNode = new BioModelNode("variable_initial_conditions", true);
for (VarIniCondition varIni : volumeSubDomain.getVarIniConditions()) {
BioModelNode varIniNode = new BioModelNode(varIni, false);
varIniConditionNode.add(varIniNode);
}
volumeSubDomainNode.add(varIniConditionNode);
// add jump processes
for (JumpProcess jp : volumeSubDomain.getJumpProcesses()) {
BioModelNode jpNode = new BioModelNode(jp, true);
// add probability rate.
String probRate = "P_" + jp.getName();
BioModelNode prNode = new BioModelNode("probability_rate = " + probRate, false);
jpNode.add(prNode);
// add Actions
Enumeration<Action> actions = Collections.enumeration(jp.getActions());
while (actions.hasMoreElements()) {
Action action = actions.nextElement();
BioModelNode actionNode = new BioModelNode(action, false);
jpNode.add(actionNode);
}
volumeSubDomainNode.add(jpNode);
}
} else // non-stochastic subtree
{
//
// add equation children
//
Enumeration<Equation> eqnEnum = volumeSubDomain.getEquations();
while (eqnEnum.hasMoreElements()) {
Equation equation = eqnEnum.nextElement();
BioModelNode equationNode = new BioModelNode(equation, false);
volumeSubDomainNode.add(equationNode);
}
//
// add fast system
//
FastSystem fastSystem = volumeSubDomain.getFastSystem();
if (fastSystem != null) {
BioModelNode fsNode = new BioModelNode(fastSystem, true);
Enumeration<FastInvariant> enumFI = fastSystem.getFastInvariants();
while (enumFI.hasMoreElements()) {
FastInvariant fi = enumFI.nextElement();
fsNode.add(new BioModelNode(fi, false));
}
Enumeration<FastRate> enumFR = fastSystem.getFastRates();
while (enumFR.hasMoreElements()) {
FastRate fr = enumFR.nextElement();
fsNode.add(new BioModelNode(fr, false));
}
volumeSubDomainNode.add(fsNode);
}
}
volumeRootNode.add(volumeSubDomainNode);
} else if (subDomain instanceof MembraneSubDomain) {
MembraneSubDomain membraneSubDomain = (MembraneSubDomain) subDomain;
BioModelNode membraneSubDomainNode = new BioModelNode(membraneSubDomain, true);
//
// add equation children
//
Enumeration<Equation> eqnEnum = membraneSubDomain.getEquations();
while (eqnEnum.hasMoreElements()) {
Equation equation = eqnEnum.nextElement();
BioModelNode equationNode = new BioModelNode(equation, false);
membraneSubDomainNode.add(equationNode);
}
//
// add jump condition children
//
Enumeration<JumpCondition> jcEnum = membraneSubDomain.getJumpConditions();
while (jcEnum.hasMoreElements()) {
JumpCondition jumpCondition = jcEnum.nextElement();
BioModelNode jcNode = new BioModelNode(jumpCondition, false);
membraneSubDomainNode.add(jcNode);
}
//
// add fast system
//
FastSystem fastSystem = membraneSubDomain.getFastSystem();
if (fastSystem != null) {
BioModelNode fsNode = new BioModelNode(fastSystem, true);
Enumeration<FastInvariant> enumFI = fastSystem.getFastInvariants();
while (enumFI.hasMoreElements()) {
FastInvariant fi = enumFI.nextElement();
fsNode.add(new BioModelNode(fi, false));
}
Enumeration<FastRate> enumFR = fastSystem.getFastRates();
while (enumFR.hasMoreElements()) {
FastRate fr = enumFR.nextElement();
fsNode.add(new BioModelNode(fr, false));
}
membraneSubDomainNode.add(fsNode);
}
membraneRootNode.add(membraneSubDomainNode);
}
}
if (volumeRootNode.getChildCount() > 0) {
rootNode.add(volumeRootNode);
}
if (membraneRootNode.getChildCount() > 0) {
rootNode.add(membraneRootNode);
}
return rootNode;
}
use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.
the class GuiUtils method selectClickTreePath.
public static void selectClickTreePath(JTree jtree, MouseEvent e) {
Point mousePoint = e.getPoint();
TreePath clickPath = jtree.getPathForLocation(mousePoint.x, mousePoint.y);
if (clickPath == null) {
return;
}
Object rightClickNode = clickPath.getLastPathComponent();
if (rightClickNode == null || !(rightClickNode instanceof BioModelNode)) {
return;
}
boolean bFound = false;
TreePath[] selectedPaths = jtree.getSelectionPaths();
if (selectedPaths != null) {
for (TreePath tp : selectedPaths) {
if (tp.equals(clickPath)) {
bFound = true;
break;
}
}
}
if (!bFound) {
jtree.setSelectionPath(clickPath);
}
}
use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.
the class BioModelEditorPathwayCommonsPanel method initialize.
private void initialize() {
searchTextField = new TextFieldAutoCompletion();
searchTextField.addActionListener(eventHandler);
searchTextField.putClientProperty("JTextField.variant", "search");
filterTextField = new TextFieldAutoCompletion();
filterTextField.addActionListener(eventHandler);
filterTextField.addKeyListener(eventHandler);
filterTextField.putClientProperty("JTextField.variant", "filter");
searchButton = new JButton("Search");
searchButton.addActionListener(eventHandler);
sortButton = new JButton("Sort");
sortButton.addActionListener(eventHandler);
showPathwayButton = new JButton("Preview");
showPathwayButton.addActionListener(eventHandler);
showPathwayButton.setEnabled(false);
gotoPathwayButton = new JButton("Open Web Link");
gotoPathwayButton.addActionListener(eventHandler);
gotoPathwayButton.setEnabled(false);
responseTree = new JTree();
responseTreeModel = new ResponseTreeModel();
responseTree.setModel(responseTreeModel);
ToolTipManager.sharedInstance().registerComponent(responseTree);
CollapsiblePanel searchPanel = new CollapsiblePanel("Search", true);
searchPanel.getContentPanel().setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.LINE_START;
searchPanel.getContentPanel().add(searchTextField, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.insets = new Insets(0, 4, 0, 0);
searchPanel.getContentPanel().add(searchButton, gbc);
setPreferredSize(new Dimension(475, 300));
setLayout(new GridBagLayout());
int gridy = 0;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 4);
add(searchPanel, gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.fill = GridBagConstraints.BOTH;
add(new JScrollPane(responseTree), gbc);
gridy++;
CollapsiblePanel filterPanel = new CollapsiblePanel("Filter", true);
filterPanel.getContentPanel().setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.insets = new Insets(2, 2, 2, 2);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.LINE_START;
filterPanel.getContentPanel().add(filterTextField, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.insets = new Insets(0, 4, 0, 0);
filterPanel.getContentPanel().add(sortButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 4);
filterPanel.expand(true);
add(filterPanel, gbc);
// JPanel optionsField = new JPanel(new GridLayout());
// ButtonGroup buttonGroup = new ButtonGroup();
// JRadioButton o1, o2, o3;
// o1 = new JRadioButton(" Entity ");
// buttonGroup.add(o1);
// optionsField.add(o1);
// o2 = new JRadioButton(" Database ");
// buttonGroup.add(o2);
// optionsField.add(o2);
// o3 = new JRadioButton(" Organism ");
// buttonGroup.add(o3);
// optionsField.add(o3);
// o3.setSelected(true);
//
// gridy ++;
// CollapsiblePanel optionsPanel = new CollapsiblePanel("Group by... ", true);
// optionsPanel.getContentPanel().setLayout(new GridBagLayout());
// gbc = new GridBagConstraints();
// gbc.gridx = 0;
// gbc.gridy = gridy;
// gbc.weightx = 1.0;
// gbc.fill = GridBagConstraints.HORIZONTAL;
// gbc.anchor = GridBagConstraints.LINE_START;
// optionsPanel.getContentPanel().add(optionsField, gbc);
//
// gbc = new GridBagConstraints();
// gbc.gridx = 0;
// gbc.gridy = gridy;
// gbc.weightx = 1.0;
// gbc.gridwidth = GridBagConstraints.REMAINDER;
// gbc.fill = GridBagConstraints.HORIZONTAL;
// gbc.insets = new Insets(4,4,4,4);
// optionsPanel.expand(false);
// add(optionsPanel, gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 1);
add(showPathwayButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 1, 4, 4);
add(gotoPathwayButton, gbc);
sortButton.setIcon(bAscending ? VCellIcons.sortDownIcon : VCellIcons.sortUpIcon);
ResponseTreeCellRenderer renderer = new ResponseTreeCellRenderer();
// renderer.setLeafIcon(null);
// renderer.setClosedIcon(null);
// renderer.setOpenIcon(null);
renderer.setLeafIcon(VCellIcons.pathwayLeafIcon);
responseTree.setCellRenderer(renderer);
responseTree.setRootVisible(false);
responseTree.getSelectionModel().addTreeSelectionListener(eventHandler);
responseTree.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() <= 1) {
return;
}
showPathway();
}
});
responseTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
Object obj = responseTree.getLastSelectedPathComponent();
if (obj == null || !(obj instanceof BioModelNode)) {
return;
}
BioModelNode selectedNode = (BioModelNode) obj;
Object userObject = selectedNode.getUserObject();
setSelectedObjects(new Object[] { userObject });
}
});
}
use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.
the class BioModelEditorSabioPanel method computeSelectedKineticLaw.
public SBEntity computeSelectedKineticLaw() {
Object object = responseTree.getLastSelectedPathComponent();
if (object == null || !(object instanceof BioModelNode)) {
return null;
}
Object userObject = ((BioModelNode) object).getUserObject();
if (userObject instanceof SBEntity) {
return (SBEntity) userObject;
}
return null;
}
use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.
the class BioModelEditorTreeCellRenderer method getTreeCellRendererComponent.
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (regularFont == null) {
regularFont = getFont();
boldFont = regularFont.deriveFont(Font.BOLD);
}
Font font = regularFont;
Icon icon = null;
String labelText = null;
String toolTipPrefix = "";
String toolTipSuffix = "";
if (value instanceof LinkNode) {
LinkNode ln = (LinkNode) value;
String link = ln.getLink();
String text = ln.getText();
String qualifier = ln.getMiriamQualifier().getDescription();
if (link != null) {
String colorString = (sel) ? "white" : "blue";
toolTipPrefix = "double-click to open link " + link;
labelText = "<html>" + qualifier + " <font color=\"" + colorString + "\"><a href=" + link + ">" + text + "</a></font></html>";
} else {
String colorString = (sel) ? "white" : "black";
labelText = "<html>" + qualifier + " <font color=\"" + colorString + "\">" + text + "</font></html>";
}
} else if (value instanceof BioModelNode) {
BioModelNode node = (BioModelNode) value;
Object userObj = node.getUserObject();
if (userObj instanceof BioModel) {
font = boldFont;
icon = VCellIcons.documentIcon;
labelText = ((BioModel) userObj).getName();
toolTipPrefix = "BioModel: ";
} else if (userObj instanceof SimulationContext) {
// --- root: application name
font = boldFont;
// icon = VCellIcons.applicationIcon;
SimulationContext simContext = (SimulationContext) userObj;
if (simContext.isRuleBased()) {
if (simContext.getGeometry().getDimension() == 0) {
icon = VCellIcons.appRbmNonspIcon;
toolTipSuffix = "Rule Based / Non spatial";
}
} else if (simContext.isStoch()) {
if (simContext.getGeometry().getDimension() == 0) {
icon = VCellIcons.appStoNonspIcon;
toolTipSuffix = "Stochastic / Non spatial";
} else {
icon = VCellIcons.appStoSpatialIcon;
toolTipSuffix = "Stochastic / Spatial";
}
} else {
// deterministic
if (simContext.getGeometry().getDimension() == 0) {
icon = VCellIcons.appDetNonspIcon;
toolTipSuffix = "Deterministic / Non spatial";
} else {
icon = VCellIcons.appDetSpatialIcon;
toolTipSuffix = "Deterministic / Spatial";
}
}
labelText = /*"Application: " + */
((SimulationContext) userObj).getName();
toolTipPrefix = "Application: ";
} else if (userObj instanceof DocumentEditorTreeFolderNode) {
// --- 1st level folders
DocumentEditorTreeFolderNode folder = (DocumentEditorTreeFolderNode) userObj;
labelText = folder.getName();
if (folder.isBold()) {
font = boldFont;
}
DocumentEditorTreeFolderClass folderClass = folder.getFolderClass();
switch(folderClass) {
// break;
case REACTIONS_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
int numReactions = bioModel.getModel().getNumReactions();
if (bioModel.getModel().getRbmModelContainer() != null) {
numReactions += bioModel.getModel().getRbmModelContainer().getReactionRuleList().size();
}
labelText = folder.getName() + " (" + numReactions + ")";
}
break;
case STRUCTURES_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + bioModel.getModel().getNumStructures() + ")";
}
break;
case SPECIES_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + bioModel.getModel().getNumSpeciesContexts() + ")";
}
break;
case MOLECULAR_TYPES_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
RbmModelContainer rbmModelContainer = bioModel.getModel().getRbmModelContainer();
if (rbmModelContainer == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + rbmModelContainer.getMolecularTypeList().size() + ")";
}
}
break;
case OBSERVABLES_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
RbmModelContainer rbmModelContainer = bioModel.getModel().getRbmModelContainer();
if (rbmModelContainer == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + rbmModelContainer.getObservableList().size() + ")";
}
}
break;
case APPLICATIONS_NODE:
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + bioModel.getNumSimulationContexts() + ")";
}
break;
case REACTION_DIAGRAM_NODE:
icon = VCellIcons.diagramIcon;
break;
// break;
case GEOMETRY_NODE:
icon = VCellIcons.geometryIcon;
break;
case SPECIFICATIONS_NODE:
icon = VCellIcons.settingsIcon;
break;
case PROTOCOLS_NODE:
icon = VCellIcons.protocolsIcon;
break;
case SIMULATIONS_NODE:
icon = VCellIcons.simulationIcon;
break;
case PARAMETER_ESTIMATION_NODE:
icon = VCellIcons.fittingIcon;
break;
case PATHWAY_DIAGRAM_NODE:
icon = VCellIcons.diagramIcon;
break;
case PATHWAY_OBJECTS_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + bioModel.getPathwayModel().getBiopaxObjects().size() + ")";
}
break;
case BIOPAX_SUMMARY_NODE:
icon = VCellIcons.textNotesIcon;
break;
case BIOPAX_TREE_NODE:
icon = VCellIcons.tableIcon;
break;
}
}
}
setIcon(icon);
setFont(font);
setText(labelText);
if (toolTipSuffix.length() == 0) {
toolTipSuffix = labelText;
}
setToolTipText(toolTipPrefix + toolTipSuffix);
return this;
}
Aggregations