Search in sources :

Example 1 with ReactionCanvas

use of cbit.vcell.model.ReactionCanvas in project vcell by virtualcell.

the class SimpleReactionPanel method getReactionCanvas.

/**
 * Return the ReactionCanvas property value.
 * @return cbit.vcell.model.gui.ReactionCanvas
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private ReactionCanvas getReactionCanvas() {
    if (ivjReactionCanvas == null) {
        try {
            ivjReactionCanvas = new ReactionCanvas();
            ivjReactionCanvas.setName("ReactionCanvas");
        // ivjReactionCanvas.setBounds(0, 0, 359, 117);
        // user code begin {1}
        // user code end
        } catch (java.lang.Throwable ivjExc) {
            // user code begin {2}
            // user code end
            handleException(ivjExc);
        }
    }
    return ivjReactionCanvas;
}
Also used : ReactionCanvas(cbit.vcell.model.ReactionCanvas)

Example 2 with ReactionCanvas

use of cbit.vcell.model.ReactionCanvas in project vcell by virtualcell.

the class ITextWriter method writeReactions.

// each reaction has its own table, ordered by the structures.
protected void writeReactions(Chapter physioChapter, Model model) throws DocumentException {
    if (model == null) {
        return;
    }
    Paragraph reactionParagraph = new Paragraph();
    reactionParagraph.add(new Chunk("Structures and Reactions Diagram").setLocalDestination(model.getName()));
    Section reactionDiagramSection = physioChapter.addSection(reactionParagraph, physioChapter.numberDepth() + 1);
    try {
        addImage(reactionDiagramSection, encodeJPEG(generateDocReactionsImage(model, null)));
    } catch (Exception e) {
        e.printStackTrace();
        throw new DocumentException(e.getClass().getName() + ": " + e.getMessage());
    }
    for (int i = 0; i < model.getNumStructures(); i++) {
        ReactionStep[] reactionSteps = model.getReactionSteps();
        ReactionStep rs = null;
        Table modifierTable = null;
        Table reactionTable = null;
        boolean firstTime = true;
        Section reactStructSection = null;
        for (int j = 0; j < reactionSteps.length; j++) {
            if (reactionSteps[j].getStructure() == model.getStructure(i)) {
                // can also use structureName1.equals(structureName2)
                if (firstTime) {
                    Paragraph linkParagraph = new Paragraph();
                    linkParagraph.add(new Chunk("Reaction(s) in " + model.getStructure(i).getName()).setLocalDestination(model.getStructure(i).getName()));
                    reactStructSection = physioChapter.addSection(linkParagraph, physioChapter.numberDepth() + 1);
                    firstTime = false;
                }
                rs = reactionSteps[j];
                String type;
                if (rs instanceof SimpleReaction) {
                    type = "Reaction";
                } else {
                    type = "Flux";
                }
                // write Reaction equation as a table
                // Get the image arrow cell depending on type of reactionStep : MassAction => double arrow, otherwise, forward arrow
                boolean bReversible = false;
                if (rs.getKinetics() instanceof MassActionKinetics) {
                    bReversible = true;
                }
                Cell arrowImageCell = getReactionArrowImageCell(bReversible);
                // Get reactants and products strings
                ReactionCanvas rc = new ReactionCanvas();
                rc.setReactionStep(rs);
                ReactionCanvasDisplaySpec rcdSpec = rc.getReactionCanvasDisplaySpec();
                String reactants = rcdSpec.getLeftText();
                String products = rcdSpec.getRightText();
                // Create table and add cells for reactants, arrow(s) images, products
                int[] widths = { 8, 1, 8 };
                reactionTable = getTable(3, 100, 0, 2, 2);
                // Add reactants as cell
                Cell tableCell = createCell(reactants, getBold());
                tableCell.setHorizontalAlignment(Cell.ALIGN_RIGHT);
                tableCell.setBorderColor(Color.white);
                reactionTable.addCell(tableCell);
                // add arrow(s) image as cell
                if (arrowImageCell != null) {
                    arrowImageCell.setHorizontalAlignment(Cell.ALIGN_CENTER);
                    arrowImageCell.setBorderColor(Color.white);
                    reactionTable.addCell(arrowImageCell);
                }
                // add products as cell
                tableCell = createCell(products, getBold());
                tableCell.setBorderColor(Color.white);
                reactionTable.addCell(tableCell);
                // reactionTable.setBorderColor(Color.white);
                reactionTable.setWidths(widths);
                // Identify modifiers,
                ReactionParticipant[] rpArr = rs.getReactionParticipants();
                Vector<ReactionParticipant> modifiersVector = new Vector<ReactionParticipant>();
                for (int k = 0; k < rpArr.length; k += 1) {
                    if (rpArr[k] instanceof Catalyst) {
                        modifiersVector.add(rpArr[k]);
                    }
                }
                // Write the modifiers in a separate table, if present
                if (modifiersVector.size() > 0) {
                    modifierTable = getTable(1, 50, 0, 1, 1);
                    modifierTable.addCell(createCell("Modifiers List", getBold(DEF_HEADER_FONT_SIZE), 1, 1, Element.ALIGN_CENTER, true));
                    StringBuffer modifierNames = new StringBuffer();
                    for (int k = 0; k < modifiersVector.size(); k++) {
                        modifierNames.append(((Catalyst) modifiersVector.elementAt(k)).getName() + "\n");
                    }
                    modifierTable.addCell(createCell(modifierNames.toString().trim(), getFont()));
                    modifiersVector.removeAllElements();
                }
                Section reactionSection = reactStructSection.addSection(type + " " + rs.getName(), reactStructSection.numberDepth() + 1);
                // Annotation
                VCMetaData vcMetaData = rs.getModel().getVcMetaData();
                if (vcMetaData.getFreeTextAnnotation(rs) != null) {
                    Table annotTable = getTable(1, 100, 1, 3, 3);
                    annotTable.addCell(createCell("Reaction Annotation", getBold(DEF_HEADER_FONT_SIZE), 1, 1, Element.ALIGN_CENTER, true));
                    annotTable.addCell(createCell(vcMetaData.getFreeTextAnnotation(rs), getFont()));
                    reactionSection.add(annotTable);
                // reactionSection.add(new Paragraph("\""+rs.getAnnotation()+"\""));
                }
                // reaction table
                if (reactionTable != null) {
                    reactionSection.add(reactionTable);
                    // re-set reactionTable
                    reactionTable = null;
                }
                if (modifierTable != null) {
                    reactionSection.add(modifierTable);
                    modifierTable = null;
                }
                // Write kinetics parameters, etc. in a table
                writeKineticsParams(reactionSection, rs);
            }
        }
    }
}
Also used : Table(com.lowagie.text.Table) SimpleReaction(cbit.vcell.model.SimpleReaction) ReactionCanvasDisplaySpec(cbit.vcell.model.ReactionCanvasDisplaySpec) ReactionCanvas(cbit.vcell.model.ReactionCanvas) Chunk(com.lowagie.text.Chunk) Section(com.lowagie.text.Section) DocumentException(com.lowagie.text.DocumentException) ExpressionException(cbit.vcell.parser.ExpressionException) Paragraph(com.lowagie.text.Paragraph) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) DocumentException(com.lowagie.text.DocumentException) ReactionStep(cbit.vcell.model.ReactionStep) MassActionKinetics(cbit.vcell.model.MassActionKinetics) Cell(com.lowagie.text.Cell) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Vector(java.util.Vector) Catalyst(cbit.vcell.model.Catalyst)

Example 3 with ReactionCanvas

use of cbit.vcell.model.ReactionCanvas in project vcell by virtualcell.

the class DBReactionWizardPanel method getReactionCanvas1.

/**
 * Return the ReactionCanvas1 property value.
 * @return cbit.vcell.model.gui.ReactionCanvas
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private ReactionCanvas getReactionCanvas1() {
    if (ivjReactionCanvas1 == null) {
        try {
            LineBorderBean ivjLocalBorder12 = new LineBorderBean();
            TitledBorderBean ivjLocalBorder11 = new TitledBorderBean();
            ivjLocalBorder11.setTitleFont(getFont().deriveFont(Font.BOLD));
            ivjLocalBorder11.setBorder(ivjLocalBorder12);
            ivjLocalBorder11.setTitle("Reaction Stoichiometry");
            ivjReactionCanvas1 = new ReactionCanvas();
            ivjReactionCanvas1.setName("ReactionCanvas1");
            ivjReactionCanvas1.setBorder(ivjLocalBorder11);
            ivjReactionCanvas1.setLocation(0, 0);
        // user code begin {1}
        // user code end
        } catch (java.lang.Throwable ivjExc) {
            // user code begin {2}
            // user code end
            handleException(ivjExc);
        }
    }
    return ivjReactionCanvas1;
}
Also used : LineBorderBean(org.vcell.util.gui.LineBorderBean) ReactionCanvas(cbit.vcell.model.ReactionCanvas) TitledBorderBean(org.vcell.util.gui.TitledBorderBean)

Example 4 with ReactionCanvas

use of cbit.vcell.model.ReactionCanvas in project vcell by virtualcell.

the class RXParticipantResolverPanel method getReactionCanvas1.

/**
 * Return the ReactionCanvas1 property value.
 * @return cbit.vcell.model.gui.ReactionCanvas
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private ReactionCanvas getReactionCanvas1() {
    if (ivjReactionCanvas1 == null) {
        try {
            LineBorderBean ivjLocalBorder12 = new LineBorderBean();
            TitledBorderBean ivjLocalBorder11 = new TitledBorderBean();
            ivjLocalBorder11.setTitleFont(getFont().deriveFont(Font.BOLD));
            ivjLocalBorder11.setBorder(ivjLocalBorder12);
            ivjLocalBorder11.setTitle("Reaction Stoichiometry");
            ivjReactionCanvas1 = new ReactionCanvas() {

                @Override
                public Dimension getPreferredSize() {
                    // TODO Auto-generated method stub
                    return new Dimension(100, 100);
                }
            };
            ivjReactionCanvas1.setName("ReactionCanvas1");
            ivjReactionCanvas1.setBorder(ivjLocalBorder11);
            ivjReactionCanvas1.setLocation(0, 0);
        // user code begin {1}
        // user code end
        } catch (java.lang.Throwable ivjExc) {
            // user code begin {2}
            // user code end
            handleException(ivjExc);
        }
    }
    return ivjReactionCanvas1;
}
Also used : LineBorderBean(org.vcell.util.gui.LineBorderBean) ReactionCanvas(cbit.vcell.model.ReactionCanvas) TitledBorderBean(org.vcell.util.gui.TitledBorderBean) Dimension(java.awt.Dimension)

Aggregations

ReactionCanvas (cbit.vcell.model.ReactionCanvas)4 LineBorderBean (org.vcell.util.gui.LineBorderBean)2 TitledBorderBean (org.vcell.util.gui.TitledBorderBean)2 VCMetaData (cbit.vcell.biomodel.meta.VCMetaData)1 Catalyst (cbit.vcell.model.Catalyst)1 MassActionKinetics (cbit.vcell.model.MassActionKinetics)1 ReactionCanvasDisplaySpec (cbit.vcell.model.ReactionCanvasDisplaySpec)1 ReactionParticipant (cbit.vcell.model.ReactionParticipant)1 ReactionStep (cbit.vcell.model.ReactionStep)1 SimpleReaction (cbit.vcell.model.SimpleReaction)1 ExpressionException (cbit.vcell.parser.ExpressionException)1 Cell (com.lowagie.text.Cell)1 Chunk (com.lowagie.text.Chunk)1 DocumentException (com.lowagie.text.DocumentException)1 Paragraph (com.lowagie.text.Paragraph)1 Section (com.lowagie.text.Section)1 Table (com.lowagie.text.Table)1 Dimension (java.awt.Dimension)1 Vector (java.util.Vector)1