Search in sources :

Example 41 with RbmObservable

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

the class IssuePanel method invokeHyperlink.

private void invokeHyperlink(Issue issue) {
    if (selectionManager != null) {
        // followHyperlink is no-op if selectionManger null, so no point in proceeding if it is
        IssueContext issueContext = issue.getIssueContext();
        IssueSource object = issue.getSource();
        if (object instanceof DecoratedIssueSource) {
            DecoratedIssueSource dis = (DecoratedIssueSource) object;
            dis.activateView(selectionManager);
        } else if (object instanceof Parameter) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.BIOMODEL_PARAMETERS_NODE, ActiveViewID.parameters_functions), new Object[] { object });
        } else if (object instanceof StructureMapping) {
            StructureMapping structureMapping = (StructureMapping) object;
            StructureMappingNameScope structureMappingNameScope = (StructureMappingNameScope) structureMapping.getNameScope();
            SimulationContext simulationContext = ((SimulationContextNameScope) (structureMappingNameScope.getParent())).getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
        } else if (object instanceof SpatialObject) {
            SpatialObject spatialObject = (SpatialObject) object;
            SimulationContext simulationContext = spatialObject.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_objects), new Object[] { object });
        } else if (object instanceof SpatialProcess) {
            SpatialProcess spatialProcess = (SpatialProcess) object;
            SimulationContext simulationContext = spatialProcess.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_processes), new Object[] { object });
        } else if (object instanceof GeometryContext.UnmappedGeometryClass) {
            UnmappedGeometryClass unmappedGeometryClass = (UnmappedGeometryClass) object;
            SimulationContext simulationContext = unmappedGeometryClass.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
        } else if (object instanceof MicroscopeMeasurement) {
            SimulationContext simulationContext = ((MicroscopeMeasurement) object).getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.microscope_measuremments), new Object[] { object });
        } else if (object instanceof BioEvent) {
            BioEvent be = (BioEvent) object;
            SimulationContext simulationContext = be.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.events), new Object[] { object });
        } else if (object instanceof OutputFunctionIssueSource) {
            SimulationOwner simulationOwner = ((OutputFunctionIssueSource) object).getOutputFunctionContext().getSimulationOwner();
            if (simulationOwner instanceof SimulationContext) {
                SimulationContext simulationContext = (SimulationContext) simulationOwner;
                followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
            } else if (simulationOwner instanceof MathModel) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_OUTPUT_FUNCTIONS_NODE, ActiveViewID.math_output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
            }
        } else if (object instanceof Simulation) {
            Simulation simulation = (Simulation) object;
            SimulationOwner simulationOwner = simulation.getSimulationOwner();
            if (simulationOwner instanceof SimulationContext) {
                SimulationContext simulationContext = (SimulationContext) simulationOwner;
                followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.simulations), new Object[] { simulation });
            } else if (simulationOwner instanceof MathModel) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.math_simulations), new Object[] { simulation });
            }
        } else if (object instanceof GeometryContext) {
            setActiveView(new ActiveView(((GeometryContext) object).getSimulationContext(), DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition));
        } else if (object instanceof Structure) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.STRUCTURES_NODE, ActiveViewID.structures), new Object[] { object });
        } else if (object instanceof MolecularType) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE, ActiveViewID.structures), new Object[] { object });
        } else if (object instanceof ReactionStep) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
        } else if (object instanceof ReactionRule) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
        } else if (object instanceof SpeciesContextSpec) {
            SpeciesContextSpec scs = (SpeciesContextSpec) object;
            ActiveView av = new ActiveView(scs.getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.species_settings);
            followHyperlink(av, new Object[] { object });
        } else if (object instanceof ReactionCombo) {
            ReactionCombo rc = (ReactionCombo) object;
            followHyperlink(new ActiveView(rc.getReactionContext().getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.reaction_setting), new Object[] { ((ReactionCombo) object).getReactionSpec() });
        } else if (object instanceof SpeciesContext) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] { object });
        } else if (object instanceof RbmObservable) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] { object });
        } else if (object instanceof MathDescription) {
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.generated_math), new Object[] {object});
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
        } else if (object instanceof SpeciesPattern) {
            // if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
            // SpeciesContext thing = (SpeciesContext)issue.getIssueContext().getContextObject(ContextType.SpeciesContext);
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] {thing});
            // }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
            // ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] {thing});
            // }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
            // RbmObservable thing = (RbmObservable)issue.getIssueContext().getContextObject(ContextType.RbmObservable);
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] {thing});
            // } else {
            System.err.println("SpeciesPattern object missing a proper issue context.");
        // }
        } else if (object instanceof SimulationContext) {
            SimulationContext sc = (SimulationContext) object;
            IssueCategory ic = issue.getCategory();
            switch(ic) {
                case RbmNetworkConstraintsBad:
                    NetworkConstraints nc = sc.getNetworkConstraints();
                    if (issue.getMessage() == SimulationContext.IssueInsufficientMolecules) {
                        NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxMoleculesName, NetworkConstraintsTableModel.sValueType, nc.getMaxMoleculesPerSpecies() + "");
                        followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
                    } else {
                        NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxIterationName, NetworkConstraintsTableModel.sValueType, nc.getMaxIteration() + "");
                        followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
                    }
                    break;
                default:
                    followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { object });
                    break;
            }
        } else if (object instanceof Geometry) {
            if (issueContext.hasContextType(ContextType.SimContext)) {
                SimulationContext simContext = (SimulationContext) issueContext.getContextObject(ContextType.SimContext);
                followHyperlink(new ActiveView(simContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
            } else if (issueContext.hasContextType(ContextType.MathModel)) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_GEOMETRY_NODE, ActiveViewID.math_geometry), new Object[] { object });
            } else if (issueContext.hasContextType(ContextType.MathDescription)) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
            }
        } else {
            System.err.println("unknown object type in IssuePanel.invokeHyperlink(): " + object.getClass() + ", context type: " + issueContext.getContextType());
        }
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) IssueCategory(org.vcell.util.Issue.IssueCategory) MathDescription(cbit.vcell.math.MathDescription) NetworkConstraintsEntity(org.vcell.model.rbm.common.NetworkConstraintsEntity) SpeciesContext(cbit.vcell.model.SpeciesContext) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) StructureMapping(cbit.vcell.mapping.StructureMapping) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) StructureMappingNameScope(cbit.vcell.mapping.StructureMapping.StructureMappingNameScope) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) UnmappedGeometryClass(cbit.vcell.mapping.GeometryContext.UnmappedGeometryClass) SimulationOwner(cbit.vcell.solver.SimulationOwner) DecoratedIssueSource(cbit.vcell.client.desktop.DecoratedIssueSource) IssueSource(org.vcell.util.Issue.IssueSource) OutputFunctionIssueSource(cbit.vcell.solver.OutputFunctionContext.OutputFunctionIssueSource) OutputFunctionIssueSource(cbit.vcell.solver.OutputFunctionContext.OutputFunctionIssueSource) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) IssueContext(org.vcell.util.IssueContext) UnmappedGeometryClass(cbit.vcell.mapping.GeometryContext.UnmappedGeometryClass) MicroscopeMeasurement(cbit.vcell.mapping.MicroscopeMeasurement) GeometryContext(cbit.vcell.mapping.GeometryContext) Structure(cbit.vcell.model.Structure) ReactionCombo(cbit.vcell.mapping.ReactionSpec.ReactionCombo) ReactionRule(cbit.vcell.model.ReactionRule) DecoratedIssueSource(cbit.vcell.client.desktop.DecoratedIssueSource) RbmObservable(cbit.vcell.model.RbmObservable) SimulationContextNameScope(cbit.vcell.mapping.SimulationContext.SimulationContextNameScope) SimulationContext(cbit.vcell.mapping.SimulationContext) MolecularType(org.vcell.model.rbm.MolecularType) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) ReactionStep(cbit.vcell.model.ReactionStep) Parameter(cbit.vcell.model.Parameter) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) BioEvent(cbit.vcell.mapping.BioEvent) NetworkConstraints(org.vcell.model.rbm.NetworkConstraints)

Example 42 with RbmObservable

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

the class ObservablePropertiesPanel method setObservable.

private void setObservable(RbmObservable newValue) {
    if (observable == newValue) {
        return;
    }
    RbmObservable oldValue = observable;
    if (oldValue != null) {
        oldValue.removePropertyChangeListener(eventHandler);
    }
    if (newValue != null) {
        newValue.addPropertyChangeListener(eventHandler);
    }
    observable = newValue;
    observableTreeModel.setObservable(observable);
    if (observable != null) {
        shapePanel.setHighlightedRecursively(observable, LargeShapePanel.Highlight.off);
    }
    updateInterface();
    // scroll to top to show the first species pattern of the observable
    scrollPane.getViewport().setViewPosition(new Point(0, 0));
}
Also used : RbmObservable(cbit.vcell.model.RbmObservable) Point(java.awt.Point)

Example 43 with RbmObservable

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

the class ObservableTableModel method isCellEditable.

public boolean isCellEditable(int row, int columnIndex) {
    Column col = Column.values()[columnIndex];
    if (col == Column.name) {
        return true;
    }
    RbmObservable o = getValueAt(row);
    if (o == null) {
        return false;
    }
    if (col == Column.structure) {
        return false;
    }
    if (col == Column.type) {
        return true;
    }
    if (col == Column.depiction) {
        return false;
    }
    final List<SpeciesPattern> spList = o.getSpeciesPatternList();
    for (SpeciesPattern sp : spList) {
        final List<MolecularTypePattern> mtpList = sp.getMolecularTypePatterns();
        for (MolecularTypePattern mtp : mtpList) {
            MolecularType mt = mtp.getMolecularType();
            if (mt.getComponentList().size() != 0) {
                return false;
            }
        }
    }
    return true;
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) RbmObservable(cbit.vcell.model.RbmObservable) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 44 with RbmObservable

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

the class ObservableTableModel method propertyChange.

@Override
public void propertyChange(PropertyChangeEvent evt) {
    super.propertyChange(evt);
    Object source = evt.getSource();
    // if (source == getModel().getRbmModelContainer()) {
    if (source == getModel()) {
        if (evt.getPropertyName().equals(RbmModelContainer.PROPERTY_NAME_OBSERVABLE_LIST)) {
            refreshData();
            List<RbmObservable> oldValue = (List<RbmObservable>) evt.getOldValue();
            if (oldValue != null) {
                for (RbmObservable observable : oldValue) {
                    observable.removePropertyChangeListener(this);
                    SpeciesPattern speciesPattern = observable.getSpeciesPattern(0);
                    RbmUtils.removePropertyChangeListener(speciesPattern, this);
                }
            }
            List<RbmObservable> newValue = (List<RbmObservable>) evt.getNewValue();
            if (newValue != null) {
                for (RbmObservable observable : newValue) {
                    observable.addPropertyChangeListener(this);
                    SpeciesPattern speciesPattern = observable.getSpeciesPattern(0);
                    RbmUtils.addPropertyChangeListener(speciesPattern, this);
                }
            }
        } else if (evt.getPropertyName().equals(RbmModelContainer.PROPERTY_NAME_MOLECULAR_TYPE_LIST)) {
            // we need this?
            refreshData();
        }
    } else if (source instanceof RbmObservable) {
        RbmObservable mt = (RbmObservable) source;
        int changeRow = getRowIndex(mt);
        if (changeRow >= 0) {
            fireTableRowsUpdated(changeRow, changeRow);
        }
    // if (evt.getPropertyName().equals(RbmObservable.PROPERTY_NAME_SPECIES_PATTERN_LIST)) {
    // SpeciesPattern oldValue = (SpeciesPattern) evt.getOldValue();
    // if (oldValue != null) {
    // RbmUtils.removePropertyChangeListener(oldValue, this);
    // }
    // SpeciesPattern newValue = (SpeciesPattern) evt.getNewValue();
    // if (newValue != null) {
    // RbmUtils.addPropertyChangeListener(newValue, this);
    // }
    // }
    } else if (source instanceof SpeciesPattern) {
        fireTableRowsUpdated(0, getRowCount() - 1);
        if (evt.getPropertyName().equals(SpeciesPattern.PROPERTY_NAME_MOLECULAR_TYPE_PATTERNS)) {
            List<MolecularTypePattern> oldValue = (List<MolecularTypePattern>) evt.getOldValue();
            if (oldValue != null) {
                for (MolecularTypePattern mtp : oldValue) {
                    RbmUtils.removePropertyChangeListener(mtp, this);
                }
            }
            List<MolecularTypePattern> newValue = (List<MolecularTypePattern>) evt.getNewValue();
            if (newValue != null) {
                for (MolecularTypePattern mtp : newValue) {
                    RbmUtils.addPropertyChangeListener(mtp, this);
                }
            }
        }
    } else if (source instanceof MolecularTypePattern) {
        fireTableRowsUpdated(0, getRowCount() - 1);
        if (evt.getPropertyName().equals(MolecularTypePattern.PROPERTY_NAME_COMPONENT_PATTERN_LIST)) {
            List<MolecularComponentPattern> oldValue = (List<MolecularComponentPattern>) evt.getOldValue();
            if (oldValue != null) {
                for (MolecularComponentPattern mcp : oldValue) {
                    RbmUtils.removePropertyChangeListener(mcp, this);
                }
            }
            List<MolecularComponentPattern> newValue = (List<MolecularComponentPattern>) evt.getNewValue();
            if (newValue != null) {
                for (MolecularComponentPattern mcp : newValue) {
                    RbmUtils.addPropertyChangeListener(mcp, this);
                }
            }
        }
    } else if (source instanceof MolecularComponentPattern) {
        fireTableRowsUpdated(0, getRowCount() - 1);
        if (source.equals(MolecularComponentPattern.PROPERTY_NAME_COMPONENT_STATE)) {
            ComponentStateDefinition oldValue = (ComponentStateDefinition) evt.getOldValue();
            if (oldValue != null) {
                oldValue.removePropertyChangeListener(this);
            }
            ComponentStateDefinition newValue = (ComponentStateDefinition) evt.getNewValue();
            if (newValue != null) {
                newValue.addPropertyChangeListener(this);
            }
        }
    } else if (evt.getSource() instanceof MolecularComponent) {
        fireTableRowsUpdated(0, getRowCount() - 1);
    } else if (evt.getSource() instanceof ComponentStateDefinition) {
        fireTableRowsUpdated(0, getRowCount() - 1);
    }
// updateStructureComboBox();
}
Also used : MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularComponent(org.vcell.model.rbm.MolecularComponent) RbmObservable(cbit.vcell.model.RbmObservable) ArrayList(java.util.ArrayList) JList(javax.swing.JList) List(java.util.List) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) ComponentStateDefinition(org.vcell.model.rbm.ComponentStateDefinition)

Example 45 with RbmObservable

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

the class ObservableTableModel method getValueAt.

public Object getValueAt(int rowIndex, int columnIndex) {
    RbmObservable observable = getValueAt(rowIndex);
    Column col = Column.values()[columnIndex];
    if (observable == null) {
        if (col == Column.name) {
            return ADD_NEW_HERE_TEXT;
        }
    } else {
        switch(col) {
            case name:
                return observable.getName();
            case species_pattern:
                if (!observable.getSpeciesPatternList().isEmpty()) {
                    String speciesPatterns = "";
                    for (SpeciesPattern sp : observable.getSpeciesPatternList()) {
                        speciesPatterns += sp.toString() + " ";
                    }
                    return speciesPatterns;
                } else {
                    return ("");
                }
            case type:
                return observable.getType();
            case structure:
                return observable.getStructure();
        }
    }
    return null;
}
Also used : RbmObservable(cbit.vcell.model.RbmObservable) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Aggregations

RbmObservable (cbit.vcell.model.RbmObservable)50 SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)22 ReactionRule (cbit.vcell.model.ReactionRule)20 SpeciesContext (cbit.vcell.model.SpeciesContext)18 Structure (cbit.vcell.model.Structure)16 ArrayList (java.util.ArrayList)15 MolecularType (org.vcell.model.rbm.MolecularType)14 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)10 ReactionStep (cbit.vcell.model.ReactionStep)9 PropertyVetoException (java.beans.PropertyVetoException)8 SimulationContext (cbit.vcell.mapping.SimulationContext)7 Model (cbit.vcell.model.Model)7 BioModel (cbit.vcell.biomodel.BioModel)6 ModelException (cbit.vcell.model.ModelException)6 RbmModelContainer (cbit.vcell.model.Model.RbmModelContainer)5 ProductPattern (cbit.vcell.model.ProductPattern)5 ReactantPattern (cbit.vcell.model.ReactantPattern)5 BioModelNode (cbit.vcell.desktop.BioModelNode)4 BioPaxObject (org.vcell.pathway.BioPaxObject)4 StructureToolShapeIcon (cbit.vcell.graph.gui.StructureToolShapeIcon)3