Search in sources :

Example 1 with Annotation

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);
}
Also used : Simulation(cbit.vcell.solver.Simulation) MathType(org.vcell.util.document.BioModelChildSummary.MathType) BioModelNode(cbit.vcell.desktop.BioModelNode) Annotation(cbit.vcell.desktop.Annotation)

Example 2 with Annotation

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);
    }
}
Also used : UtilCancelException(org.vcell.util.UtilCancelException) IdentifiableNode(cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode) Annotation(cbit.vcell.desktop.Annotation) UtilCancelException(org.vcell.util.UtilCancelException) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException)

Example 3 with Annotation

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;
}
Also used : MouseEvent(java.awt.event.MouseEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) BioModelNode(cbit.vcell.desktop.BioModelNode) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) Annotation(cbit.vcell.desktop.Annotation) JTree(javax.swing.JTree) Dimension(java.awt.Dimension) MouseListener(java.awt.event.MouseListener) DefaultTreeSelectionModel(javax.swing.tree.DefaultTreeSelectionModel) TreePath(javax.swing.tree.TreePath) BioModelCellRenderer(cbit.vcell.desktop.BioModelCellRenderer) LinkNode(cbit.vcell.xml.gui.MiriamTreeModel.LinkNode)

Example 4 with Annotation

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);
    }
}
Also used : IdentifiableComparator(cbit.vcell.biomodel.meta.IdentifiableComparator) MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) TreeSet(java.util.TreeSet) Set(java.util.Set) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) BioModelNode(cbit.vcell.desktop.BioModelNode) DateQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) TreeSet(java.util.TreeSet) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) VCID(cbit.vcell.biomodel.meta.VCID) DublinCoreDate(org.vcell.sybil.models.dublincore.DublinCoreDate) Annotation(cbit.vcell.desktop.Annotation) Identifiable(org.vcell.util.document.Identifiable) DateQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier) DublinCoreQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier) Map(java.util.Map) TreeMap(java.util.TreeMap) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier)

Example 5 with Annotation

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;
}
Also used : JumpCondition(cbit.vcell.math.JumpCondition) Variable(cbit.vcell.math.Variable) Constant(cbit.vcell.math.Constant) JLabel(javax.swing.JLabel) FastRate(cbit.vcell.math.FastRate) BioModelNode(cbit.vcell.desktop.BioModelNode) FastInvariant(cbit.vcell.math.FastInvariant) Annotation(cbit.vcell.desktop.Annotation) PdeEquation(cbit.vcell.math.PdeEquation) SubDomain(cbit.vcell.math.SubDomain) Function(cbit.vcell.math.Function) OdeEquation(cbit.vcell.math.OdeEquation) FastSystem(cbit.vcell.math.FastSystem) MembraneRegionEquation(cbit.vcell.math.MembraneRegionEquation)

Aggregations

Annotation (cbit.vcell.desktop.Annotation)5 BioModelNode (cbit.vcell.desktop.BioModelNode)4 JLabel (javax.swing.JLabel)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 IdentifiableComparator (cbit.vcell.biomodel.meta.IdentifiableComparator)1 MiriamManager (cbit.vcell.biomodel.meta.MiriamManager)1 MiriamRefGroup (cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)1 MiriamResource (cbit.vcell.biomodel.meta.MiriamManager.MiriamResource)1 VCID (cbit.vcell.biomodel.meta.VCID)1 BioModelCellRenderer (cbit.vcell.desktop.BioModelCellRenderer)1 Constant (cbit.vcell.math.Constant)1 FastInvariant (cbit.vcell.math.FastInvariant)1 FastRate (cbit.vcell.math.FastRate)1 FastSystem (cbit.vcell.math.FastSystem)1 Function (cbit.vcell.math.Function)1 JumpCondition (cbit.vcell.math.JumpCondition)1 MembraneRegionEquation (cbit.vcell.math.MembraneRegionEquation)1 OdeEquation (cbit.vcell.math.OdeEquation)1 PdeEquation (cbit.vcell.math.PdeEquation)1 SubDomain (cbit.vcell.math.SubDomain)1