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);
}
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;
}
}
}
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;
}
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);
}
}
Aggregations