Search in sources :

Example 1 with ModelProcessSpec

use of cbit.vcell.mapping.ModelProcessSpec in project vcell by virtualcell.

the class ModelProcessSpecsPanel method initConnections.

/**
 * Initializes connections
 * @exception java.lang.Exception The exception description.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initConnections() throws java.lang.Exception {
    // user code begin {1}
    // user code end
    this.addPropertyChangeListener(ivjEventHandler);
    getScrollPaneTable().setModel(getModelProcessSpecsTableModel());
    getScrollPaneTable().setDefaultRenderer(ModelProcess.class, new DefaultScrollTableCellRenderer() {

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            defaultToolTipText = null;
            if (value instanceof ModelProcess) {
                setText(((ModelProcess) value).getName());
                defaultToolTipText = getText();
                setToolTipText(defaultToolTipText);
            }
            TableModel tableModel = table.getModel();
            if (tableModel instanceof SortTableModel) {
                DefaultScrollTableCellRenderer.issueRenderer(this, defaultToolTipText, table, row, column, (SortTableModel) tableModel);
            }
            return this;
        }
    });
    DefaultScrollTableCellRenderer rbmReactionShapeDepictionCellRenderer = new DefaultScrollTableCellRenderer() {

        List<SpeciesPatternSmallShape> spssList = new ArrayList<SpeciesPatternSmallShape>();

        SpeciesPatternSmallShape spss = null;

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (table.getModel() instanceof VCellSortTableModel<?>) {
                Object selectedObject = null;
                if (table.getModel() == ivjModelProcessSpecsTableModel) {
                    selectedObject = ivjModelProcessSpecsTableModel.getValueAt(row);
                }
                if (selectedObject != null) {
                    if (selectedObject instanceof ModelProcessSpec) {
                        ModelProcessSpec mps = (ModelProcessSpec) selectedObject;
                        ModelProcess mp = (ModelProcess) mps.getModelProcess();
                        if (mp instanceof ReactionRule) {
                            ReactionRule rr = (ReactionRule) mp;
                            Graphics panelContext = table.getGraphics();
                            spssList.clear();
                            List<ReactantPattern> rpList = rr.getReactantPatterns();
                            int xPos = 4;
                            for (int i = 0; i < rpList.size(); i++) {
                                SpeciesPattern sp = rr.getReactantPattern(i).getSpeciesPattern();
                                spss = new SpeciesPatternSmallShape(xPos, 2, sp, shapeManager, panelContext, rr, isSelected, issueManager);
                                if (i < rpList.size() - 1) {
                                    spss.addEndText("+");
                                } else {
                                    if (rr.isReversible()) {
                                        spss.addEndText("<->");
                                        xPos += 7;
                                    } else {
                                        spss.addEndText("->");
                                    }
                                }
                                xPos += spss.getWidth() + 15;
                                spssList.add(spss);
                            }
                            List<ProductPattern> ppList = rr.getProductPatterns();
                            xPos += 7;
                            for (int i = 0; i < ppList.size(); i++) {
                                SpeciesPattern sp = rr.getProductPattern(i).getSpeciesPattern();
                                spss = new SpeciesPatternSmallShape(xPos, 2, sp, shapeManager, panelContext, rr, isSelected, issueManager);
                                if (i < ppList.size() - 1) {
                                    spss.addEndText("+");
                                }
                                xPos += spss.getWidth() + 15;
                                spssList.add(spss);
                            }
                        } else {
                            ReactionStep rs = (ReactionStep) mp;
                            Graphics panelContext = table.getGraphics();
                            spssList.clear();
                            int xPos = 4;
                            int extraSpace = 0;
                            for (int i = 0; i < rs.getNumReactants(); i++) {
                                SpeciesPattern sp = rs.getReactant(i).getSpeciesContext().getSpeciesPattern();
                                spss = new SpeciesPatternSmallShape(xPos, 2, sp, shapeManager, panelContext, rs, isSelected, issueManager);
                                if (i < rs.getNumReactants() - 1) {
                                    spss.addEndText("+");
                                } else {
                                    if (rs.isReversible()) {
                                        spss.addEndText("<->");
                                        extraSpace += 7;
                                    } else {
                                        spss.addEndText("->");
                                    }
                                }
                                int offset = sp == null ? 17 : 15;
                                offset += extraSpace;
                                int w = spss.getWidth();
                                xPos += w + offset;
                                spssList.add(spss);
                            }
                            xPos += 8;
                            for (int i = 0; i < rs.getNumProducts(); i++) {
                                SpeciesPattern sp = rs.getProduct(i).getSpeciesContext().getSpeciesPattern();
                                if (i == 0 && rs.getNumReactants() == 0) {
                                    xPos += 14;
                                }
                                spss = new SpeciesPatternSmallShape(xPos, 2, sp, shapeManager, panelContext, rs, isSelected, issueManager);
                                if (i == 0 && rs.getNumReactants() == 0) {
                                    spss.addStartText("->");
                                }
                                if (i < rs.getNumProducts() - 1) {
                                    spss.addEndText("+");
                                }
                                int offset = sp == null ? 17 : 15;
                                int w = spss.getWidth();
                                xPos += w + offset;
                                spssList.add(spss);
                            }
                        }
                    }
                } else {
                    spssList.clear();
                }
            }
            setText("");
            return this;
        }

        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            for (SpeciesPatternSmallShape spss : spssList) {
                if (spss == null) {
                    continue;
                }
                spss.paintSelf(g);
            }
        }
    };
    getScrollPaneTable().setDefaultRenderer(SpeciesPattern.class, rbmReactionShapeDepictionCellRenderer);
    // ivjScrollPaneTable.getColumnModel().getColumn(ModelProcessSpecsTableModel.ColumnType.COLUMN_DEPICTION.ordinal()).setCellRenderer(rbmReactionShapeDepictionCellRenderer);
    // ivjScrollPaneTable.getColumnModel().getColumn(ModelProcessSpecsTableModel.ColumnType.COLUMN_DEPICTION.ordinal()).setPreferredWidth(180);
    getScrollPaneTable().getSelectionModel().addListSelectionListener(ivjEventHandler);
}
Also used : VCellSortTableModel(cbit.vcell.client.desktop.biomodel.VCellSortTableModel) SortTableModel(org.vcell.util.gui.sorttable.SortTableModel) ReactionRule(cbit.vcell.model.ReactionRule) ProductPattern(cbit.vcell.model.ProductPattern) SpeciesPatternSmallShape(cbit.vcell.graph.SpeciesPatternSmallShape) ModelProcessSpec(cbit.vcell.mapping.ModelProcessSpec) ModelProcess(cbit.vcell.model.ModelProcess) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) Graphics(java.awt.Graphics) VCellSortTableModel(cbit.vcell.client.desktop.biomodel.VCellSortTableModel) JTable(javax.swing.JTable) ReactionStep(cbit.vcell.model.ReactionStep) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) ArrayList(java.util.ArrayList) List(java.util.List) Component(java.awt.Component) VCellSortTableModel(cbit.vcell.client.desktop.biomodel.VCellSortTableModel) TableModel(javax.swing.table.TableModel) SortTableModel(org.vcell.util.gui.sorttable.SortTableModel) ReactantPattern(cbit.vcell.model.ReactantPattern)

Example 2 with ModelProcessSpec

use of cbit.vcell.mapping.ModelProcessSpec in project vcell by virtualcell.

the class ModelProcessSpecsTableModel method getValueAt.

/**
 * getValueAt method comment.
 */
public Object getValueAt(int row, int col) {
    ModelProcessSpec modelProcessSpec = getValueAt(row);
    ColumnType columnType = columns.get(col);
    switch(columnType) {
        case COLUMN_NAME:
            {
                return modelProcessSpec.getModelProcess();
            }
        case COLUMN_TYPE:
            {
                return modelProcessSpec.getModelProcess().getDisplayType();
            }
        case COLUMN_ENABLED:
            {
                return new Boolean(!modelProcessSpec.isExcluded());
            }
        case COLUMN_FAST:
            {
                if (!(modelProcessSpec.getModelProcess() instanceof SimpleReaction)) {
                    return new Boolean(false);
                } else {
                    return new Boolean(modelProcessSpec.isFast());
                }
            }
        default:
            {
                return null;
            }
    }
}
Also used : SimpleReaction(cbit.vcell.model.SimpleReaction) ModelProcessSpec(cbit.vcell.mapping.ModelProcessSpec)

Example 3 with ModelProcessSpec

use of cbit.vcell.mapping.ModelProcessSpec in project vcell by virtualcell.

the class ModelProcessSpecsTableModel method computeData.

protected List<ModelProcessSpec> computeData() {
    ArrayList<ModelProcessSpec> allParameterList = new ArrayList<ModelProcessSpec>();
    if (getSimulationContext() != null) {
        allParameterList.addAll(Arrays.asList(getSimulationContext().getReactionContext().getReactionSpecs()));
        allParameterList.addAll(Arrays.asList(getSimulationContext().getReactionContext().getReactionRuleSpecs()));
    } else {
        return null;
    }
    boolean bSearchInactive = searchText == null || searchText.length() == 0;
    if (bSearchInactive) {
        return allParameterList;
    }
    String lowerCaseSearchText = bSearchInactive ? null : searchText.toLowerCase();
    ArrayList<ModelProcessSpec> parameterList = new ArrayList<ModelProcessSpec>();
    for (ModelProcessSpec parameter : allParameterList) {
        if (bSearchInactive || parameter.getModelProcess().getName().toLowerCase().contains(lowerCaseSearchText) || parameter.getModelProcess().getStructure().getName().toLowerCase().contains(lowerCaseSearchText)) /*|| parameter.getNameScope().getPathDescription().toLowerCase().contains(lowerCaseSearchText)
				|| parameter.getName().toLowerCase().contains(lowerCaseSearchText)
				|| parameter.getExpression() != null && parameter.getExpression().infix().toLowerCase().contains(lowerCaseSearchText)
				|| parameter.getDescription().toLowerCase().contains(lowerCaseSearchText)*/
        {
            parameterList.add(parameter);
        }
    }
    return parameterList;
}
Also used : ModelProcessSpec(cbit.vcell.mapping.ModelProcessSpec) ArrayList(java.util.ArrayList)

Example 4 with ModelProcessSpec

use of cbit.vcell.mapping.ModelProcessSpec in project vcell by virtualcell.

the class ModelProcessSpecsTableModel method setValueAt.

public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    ModelProcessSpec modelProcessSpec = getValueAt(rowIndex);
    ColumnType columnType = columns.get(columnIndex);
    try {
        switch(columnType) {
            case COLUMN_ENABLED:
                {
                    boolean bEnabled = ((Boolean) aValue).booleanValue();
                    if (modelProcessSpec instanceof ReactionSpec) {
                        ReactionSpec reactionSpec = (ReactionSpec) modelProcessSpec;
                        if (bEnabled) {
                            reactionSpec.setReactionMapping(ReactionSpec.INCLUDED);
                        } else {
                            reactionSpec.setReactionMapping(ReactionSpec.EXCLUDED);
                        }
                    } else if (modelProcessSpec instanceof ReactionRuleSpec) {
                        ReactionRuleSpec reactionRuleSpec = (ReactionRuleSpec) modelProcessSpec;
                        if (bEnabled) {
                            reactionRuleSpec.setReactionRuleMapping(ReactionRuleMappingType.INCLUDED);
                        } else {
                            reactionRuleSpec.setReactionRuleMapping(ReactionRuleMappingType.EXCLUDED);
                        }
                    }
                    fireTableRowsUpdated(rowIndex, rowIndex);
                    break;
                }
            case COLUMN_FAST:
                {
                    boolean bFast = ((Boolean) aValue).booleanValue();
                    if (modelProcessSpec instanceof ReactionSpec) {
                        ReactionSpec reactionSpec = (ReactionSpec) modelProcessSpec;
                        if (bFast) {
                            reactionSpec.setReactionMapping(ReactionSpec.FAST);
                        } else {
                            reactionSpec.setReactionMapping(ReactionSpec.INCLUDED);
                        }
                    }
                    fireTableRowsUpdated(rowIndex, rowIndex);
                    break;
                }
        }
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace(System.out);
    }
}
Also used : ModelProcessSpec(cbit.vcell.mapping.ModelProcessSpec) ReactionSpec(cbit.vcell.mapping.ReactionSpec) ReactionRuleSpec(cbit.vcell.mapping.ReactionRuleSpec)

Aggregations

ModelProcessSpec (cbit.vcell.mapping.ModelProcessSpec)4 ArrayList (java.util.ArrayList)2 VCellSortTableModel (cbit.vcell.client.desktop.biomodel.VCellSortTableModel)1 SpeciesPatternSmallShape (cbit.vcell.graph.SpeciesPatternSmallShape)1 ReactionRuleSpec (cbit.vcell.mapping.ReactionRuleSpec)1 ReactionSpec (cbit.vcell.mapping.ReactionSpec)1 ModelProcess (cbit.vcell.model.ModelProcess)1 ProductPattern (cbit.vcell.model.ProductPattern)1 ReactantPattern (cbit.vcell.model.ReactantPattern)1 ReactionRule (cbit.vcell.model.ReactionRule)1 ReactionStep (cbit.vcell.model.ReactionStep)1 SimpleReaction (cbit.vcell.model.SimpleReaction)1 Component (java.awt.Component)1 Graphics (java.awt.Graphics)1 List (java.util.List)1 JTable (javax.swing.JTable)1 TableModel (javax.swing.table.TableModel)1 SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)1 DefaultScrollTableCellRenderer (org.vcell.util.gui.DefaultScrollTableCellRenderer)1 SortTableModel (org.vcell.util.gui.sorttable.SortTableModel)1