use of cbit.vcell.desktop.Annotation in project vcell by virtualcell.
the class ApplicationPropertiesTreeModel method populateRootNode.
/**
* Insert the method's description here.
* Creation date: (11/28/00 2:41:43 PM)
* @param bioModelNode cbit.vcell.desktop.BioModelNode
* @param bioModelInfo cbit.vcell.biomodel.BioModelInfo
*/
private void populateRootNode() {
rootNode.removeAllChildren();
if (simulationContext == null) {
rootNode.setUserObject("Select an application to show properties");
} else {
rootNode.setUserObject(simulationContext);
// add application type node
MathType typeInfo = simulationContext.getMathType();
BioModelNode appTypeNode = new BioModelNode(typeInfo, false);
appTypeNode.setRenderHint("type", "AppType");
rootNode.add(appTypeNode);
rootNode.add(new BioModelNode(simulationContext.getGeometry(), false));
rootNode.add(new BioModelNode(simulationContext.getMathDescription() == null ? "math not generated" : "math generated", false));
Simulation[] simArray = simulationContext.getSimulations();
if (simArray != null) {
for (Simulation sim : simArray) {
BioModelNode simNode = new BioModelNode(sim, true);
simNode.add(new BioModelNode(new Annotation(sim.getDescription()), false));
rootNode.add(simNode);
}
}
}
nodeStructureChanged(rootNode);
}
use of cbit.vcell.desktop.Annotation in project vcell by virtualcell.
the class MIRIAMAnnotationEditor method showEditFreehandText.
private void showEditFreehandText(DefaultMutableTreeNode node) {
final IdentifiableNode parentIdentifiableNode = (IdentifiableNode) ((BioModelNode) node).getParent();
final Annotation oldAnnotation = (Annotation) ((BioModelNode) node).getUserObject();
try {
String newAnnotation = DialogUtils.showAnnotationDialog(MIRIAMAnnotationEditor.this, oldAnnotation.toString());
if (BeanUtils.triggersPropertyChangeEvent(oldAnnotation, newAnnotation)) {
vcMetaData.setFreeTextAnnotation(parentIdentifiableNode.getIdentifiable(), newAnnotation);
}
} catch (UtilCancelException uce) {
// ignore
} catch (Exception exc) {
exc.printStackTrace();
DialogUtils.showErrorDialog(MIRIAMAnnotationEditor.this, "Error editing Annotation:\n" + exc.getMessage(), exc);
}
}
use of cbit.vcell.desktop.Annotation in project vcell by virtualcell.
the class MIRIAMAnnotationEditor method getJTreeMIRIAM.
private JTree getJTreeMIRIAM() {
if (jTreeMIRIAM == null) {
try {
DefaultTreeSelectionModel ivjLocalSelectionModel;
ivjLocalSelectionModel = new DefaultTreeSelectionModel();
ivjLocalSelectionModel.setSelectionMode(1);
jTreeMIRIAM = new JTree();
jTreeMIRIAM.setName("JTree1");
jTreeMIRIAM.setToolTipText("");
jTreeMIRIAM.setBounds(0, 0, 357, 405);
jTreeMIRIAM.setMinimumSize(new java.awt.Dimension(100, 72));
jTreeMIRIAM.setSelectionModel(ivjLocalSelectionModel);
jTreeMIRIAM.setRowHeight(0);
// Add cellRenderer
DefaultTreeCellRenderer dtcr = new BioModelCellRenderer(null) {
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
// System.out.println(MIRIAMAnnotationEditor.this.getClass().getName()+".getJTreeMiriam():BioModelCellRenderer "+value.getClass()+" "+
// (value instanceof cbit.vcell.desktop.BioModelNode?
// ((cbit.vcell.desktop.BioModelNode)value).getUserObject().getClass():""));
JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (value instanceof BioModelNode && ((BioModelNode) value).getUserObject() instanceof Annotation) {
component.setToolTipText("(Double-click to edit notes)");
Annotation annotation = (Annotation) ((BioModelNode) value).getUserObject();
if (annotation.toString() == null || annotation.toString().length() == 0) {
component.setText("(Double-click to edit notes)");
}
}
return component;
}
};
jTreeMIRIAM.setCellRenderer(dtcr);
MouseListener mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
super.mouseClicked(e);
TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
showPopup(e, closestMousePath);
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
super.mouseReleased(e);
TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
showPopup(e, closestMousePath);
}
public void mousePressed(MouseEvent e) {
TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
jTreeMIRIAM.setSelectionPath(closestMousePath);
showPopup(e, closestMousePath);
if (e.getClickCount() == 2) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTreeMIRIAM.getLastSelectedPathComponent();
if (node instanceof LinkNode) {
showBrowseToLink((LinkNode) node);
} else if (isNodeFreeHandTextEditable(node)) {
showEditFreehandText(node);
}
}
}
};
jTreeMIRIAM.addMouseListener(mouseListener);
} catch (java.lang.Throwable ivjExc) {
ivjExc.printStackTrace(System.out);
}
}
return jTreeMIRIAM;
}
use of cbit.vcell.desktop.Annotation in project vcell by virtualcell.
the class MiriamTreeModel method createTree.
private void createTree() {
if (!createTree) {
return;
}
MiriamManager miriamManager = vcMetaData.getMiriamManager();
TreeMap<Identifiable, Map<MiriamRefGroup, MIRIAMQualifier>> miriamDescrHeir = miriamManager.getMiriamTreeMap();
Map<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>> dateMapMap = miriamManager.getDublinCoreDateMap();
Set<Identifiable> identifiables = vcMetaData.getIdentifiableProvider().getAllIdentifiables();
TreeSet<Identifiable> sortedIdentifiables = new TreeSet<Identifiable>(new IdentifiableComparator(vcMetaData.getIdentifiableProvider()));
sortedIdentifiables.addAll(identifiables);
((DefaultMutableTreeNode) getRoot()).removeAllChildren();
for (Identifiable identifiable : sortedIdentifiables) {
Map<MiriamRefGroup, MIRIAMQualifier> refGroupMap = miriamDescrHeir.get(identifiable);
Map<DateQualifier, Set<DublinCoreDate>> dateMap = dateMapMap.get(identifiable);
VCID vcid = vcMetaData.getIdentifiableProvider().getVCID(identifiable);
String modelComponentType = vcid.getClassName();
String modelComponentName = vcid.getLocalName();
IdentifiableNode modelComponentNode = new IdentifiableNode(identifiable, modelComponentType + " : " + modelComponentName);
String freeTextAnnotation = vcMetaData.getFreeTextAnnotation(identifiable);
if (freeTextAnnotation != null) {
modelComponentNode.add(new BioModelNode(new Annotation(freeTextAnnotation), false));
} else {
modelComponentNode.add(new BioModelNode(new Annotation(""), false));
}
if (refGroupMap != null) {
for (MiriamRefGroup refGroup : refGroupMap.keySet()) {
MIRIAMQualifier qualifier = refGroupMap.get(refGroup);
for (MiriamResource miriamResource : refGroup.getMiriamRefs()) {
LinkNode linkNode = new LinkNode(qualifier, miriamResource);
modelComponentNode.add(linkNode);
}
}
}
if (dateMap != null) {
for (DublinCoreQualifier.DateQualifier qualifier : dateMap.keySet()) {
Set<DublinCoreDate> dates = dateMap.get(qualifier);
for (DublinCoreDate date : dates) {
modelComponentNode.add(new DateNode(qualifier, date));
}
}
}
((DefaultMutableTreeNode) getRoot()).add(modelComponentNode);
}
}
use of cbit.vcell.desktop.Annotation in project vcell by virtualcell.
the class MathDescriptionCellRenderer method getTreeCellRendererComponent.
/**
* Insert the method's description here.
* Creation date: (7/27/2000 6:41:57 PM)
* @return java.awt.Component
*/
public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
boolean bLoaded = false;
//
try {
if (value instanceof BioModelNode) {
BioModelNode node = (BioModelNode) value;
if (node.getUserObject() instanceof PdeEquation) {
PdeEquation pdeEquation = (PdeEquation) node.getUserObject();
Variable var = pdeEquation.getVariable();
component.setToolTipText("PDE Equation");
// \u2207 = nabla ... del operator
// \u2219 = dot
String DEL = "\u2207";
// "\u2202"; // '\u2202' is partial differentiation 'd' is regular diff
String PARTIAL_DIFF = "d";
String Super2 = "\u00b2";
String DOT = "\u2219";
// String diffusionTerm = DEL+" "+DOT+" "+"("+pdeEquation.getDiffusionExpression()+" "+DEL+" "+var.getName()+")";
String diffusionTerm = "";
if (pdeEquation.getVelocityX() != null || pdeEquation.getVelocityY() != null || pdeEquation.getVelocityZ() != null) {
if (pdeEquation.getDiffusionExpression().isZero()) {
// reaction/advection
diffusionTerm = "- " + DEL + " " + DOT + "( velocity " + var.getName() + " )";
} else {
// reaction/diffusion/advection
diffusionTerm = DEL + " " + DOT + " (" + pdeEquation.getDiffusionExpression().infix() + " " + DEL + " " + var.getName() + " - velocity " + var.getName() + ")";
}
} else {
diffusionTerm = "(" + pdeEquation.getDiffusionExpression().infix() + ") " + DEL + Super2 + " " + var.getName();
}
String gradTerm = "";
if (pdeEquation.getGradientX() != null && !pdeEquation.getGradientX().isZero()) {
gradTerm += " + " + PARTIAL_DIFF + "[" + pdeEquation.getGradientX().infix() + "]/" + PARTIAL_DIFF + "x";
}
if (pdeEquation.getGradientY() != null && !pdeEquation.getGradientY().isZero()) {
gradTerm += " + " + PARTIAL_DIFF + "[" + pdeEquation.getGradientY().infix() + "]/" + PARTIAL_DIFF + "y";
}
if (pdeEquation.getGradientZ() != null && !pdeEquation.getGradientZ().isZero()) {
gradTerm += " + " + PARTIAL_DIFF + "[" + pdeEquation.getGradientZ().infix() + "]/" + PARTIAL_DIFF + "z";
}
String sourceTerm = pdeEquation.getRateExpression().infix();
if (!sourceTerm.equals("0.0")) {
component.setText(PARTIAL_DIFF + "[" + var.getName() + "]/" + PARTIAL_DIFF + "t = " + diffusionTerm + gradTerm + " + " + sourceTerm);
} else {
component.setText(PARTIAL_DIFF + "[" + var.getName() + "]/" + PARTIAL_DIFF + "t = " + diffusionTerm + gradTerm);
}
} else if (node.getUserObject() instanceof OdeEquation) {
OdeEquation odeEquation = (OdeEquation) node.getUserObject();
Variable var = odeEquation.getVariable();
component.setToolTipText("ODE Equation");
component.setText("d[" + var.getName() + "]/dt = " + odeEquation.getRateExpression().infix());
} else if (node.getUserObject() instanceof MembraneRegionEquation) {
MembraneRegionEquation membraneRegionEquation = (MembraneRegionEquation) node.getUserObject();
Variable var = membraneRegionEquation.getVariable();
component.setToolTipText("Membrane Region Equation");
component.setText("Membrane Region Equation for " + var.getName());
} else if (node.getUserObject() instanceof JumpCondition) {
JumpCondition jumpCondition = (JumpCondition) node.getUserObject();
Variable var = jumpCondition.getVariable();
component.setToolTipText("Jump Condition");
component.setText("Flux for " + var.getName());
} else if (node.getUserObject() instanceof Constant) {
Constant constant = (Constant) node.getUserObject();
component.setToolTipText("Constant");
component.setText(constant.getName() + " = " + constant.getExpression().infix());
} else if (node.getUserObject() instanceof Function) {
Function function = (Function) node.getUserObject();
component.setToolTipText("Function");
component.setText(function.getName() + " = " + function.getExpression().infix());
} else if (node.getUserObject() instanceof SubDomain) {
SubDomain subDomain = (SubDomain) node.getUserObject();
component.setToolTipText("SubDomain");
component.setText(subDomain.getName());
} else if (node.getUserObject() instanceof FastSystem) {
component.setToolTipText("Fast System");
component.setText("Fast System");
} else if (node.getUserObject() instanceof FastInvariant) {
FastInvariant fi = (FastInvariant) node.getUserObject();
component.setToolTipText("Fast Invariant");
component.setText("fast invariant: " + fi.getFunction().infix());
} else if (node.getUserObject() instanceof FastRate) {
FastRate fr = (FastRate) node.getUserObject();
component.setToolTipText("Fast Rate");
component.setText("fast rate: " + fr.getFunction().infix());
} else if (node.getUserObject() instanceof Annotation) {
Annotation annotation = (Annotation) node.getUserObject();
component.setToolTipText("Annotation");
component.setText("\"" + annotation + "\"");
} else {
}
if (selectedFont == null && component.getFont() != null) {
selectedFont = component.getFont().deriveFont(Font.BOLD);
}
if (unselectedFont == null && component.getFont() != null) {
unselectedFont = component.getFont().deriveFont(Font.PLAIN);
}
if (bLoaded) {
component.setFont(selectedFont);
} else {
component.setFont(unselectedFont);
}
}
} catch (Throwable e) {
e.printStackTrace(System.out);
}
//
return component;
}
Aggregations